:root {
  --bg: #edf2ef;
  --panel: #f8fbf9;
  --border: #c8d4ce;
  --text: #1d2c30;
  --muted: #5c7378;
  --accent: #148f77;
  --accent-strong: #0f7a65;
  --warn: #c25a2b;
}

* { box-sizing: border-box; }

@font-face {
  font-family: 'Prometo';
  src: local('Prometo');
  font-display: swap;
}

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: 'Prometo', 'Source Sans 3', sans-serif;
  color: var(--text);
  background: linear-gradient(145deg, #f2f6f4 0%, #e7edeb 100%);
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    'topbar'
    'main';
  width: 100%;
}

.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(248, 251, 249, 0.9);
  backdrop-filter: blur(8px);
  width: 100%;
  max-width: 100%;
}

.topbar > div:first-child {
  min-width: 0;
}

.top-headline {
  display: flex;
  align-items: baseline;
  gap: 14px;
  min-width: 0;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  font-weight: 700;
}

.app-brand {
  margin: 0;
  font-family: 'Prometo', 'Space Grotesk', sans-serif;
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.03em;
  color: var(--accent-strong);
  text-transform: uppercase;
}

.title {
  margin: 0;
  font-family: 'Prometo', 'Space Grotesk', sans-serif;
  font-size: 24px;
  color: #2f4f52;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  min-width: 0;
  gap: 12px;
}

.whoami {
  min-height: 38px;
  min-width: 38px;
  width: auto;
  height: 38px;
  padding: 6px 12px 6px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  font-weight: 800;
  color: var(--accent-strong);
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  font-size: 14px;
  letter-spacing: 0.02em;
}

.whoami-btn {
  cursor: pointer;
}

.whoami-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid #b7cec4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #eef8f4;
  color: var(--accent-strong);
  flex: 0 0 24px;
}

.whoami-icon svg {
  width: 14px;
  height: 14px;
}

.whoami-name {
  line-height: 1;
  white-space: nowrap;
}

button {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 16px;
  cursor: pointer;
}

button.ghost {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}

.icon-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.main {
  grid-area: main;
  padding: 18px 20px;
  min-height: 0;
  width: 100%;
  max-width: 100%;
}

.embed-mode .main {
  padding: 0;
}

#outlet {
  height: 100%;
  min-height: 0;
}

.embed-card {
  padding: 0;
  overflow: hidden;
  height: 100%;
}

.embed-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: transparent;
}

.embed-mode .embed-card {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.dashboard-meta {
  margin-bottom: 12px;
}

.dashboard-meta .small {
  margin: 0;
}

.topic-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.topic-card {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 14px 30px rgba(35, 57, 53, 0.08);
  padding: 16px;
}

.topic-card--full {
  grid-column: 1 / -1;
}

.topic-card h2 {
  margin: 0;
  font-family: 'Prometo', 'Space Grotesk', sans-serif;
  font-size: 22px;
}

.topic-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.topic-btn {
  display: inline-block;
  text-decoration: none;
  border: 1px solid var(--accent-strong);
  border-radius: 999px;
  padding: 9px 14px;
  font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
  background: var(--accent);
  color: #fff;
}

.topic-btn.sm {
  padding: 7px 12px;
  font-size: 13px;
}

.topic-btn.action {
  background: #cd6618;
  border-color: #cd6618;
  color: #fff7f2;
}

.topic-btn.disabled {
  background: #fff;
  color: var(--muted);
  border-color: var(--border);
  pointer-events: none;
  cursor: default;
}

.panel-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}

.topic-queue {
  margin-top: 12px;
}

.ticket-embed-wrap {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
}

.ticket-embed-frame {
  display: block;
  width: 100%;
  height: 820px;
  border: 0;
}

.ticket-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.topic-queue h3 {
  margin: 0;
  font-size: 16px;
  font-family: 'Prometo', 'Space Grotesk', sans-serif;
}

.queue-subline {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.queue-badge {
  display: inline-block;
  min-width: 26px;
  padding: 2px 8px;
  text-align: center;
  border-radius: 999px;
  border: 1px solid #b5d7cc;
  background: #e8f7f1;
  color: var(--accent-strong);
  font-weight: 800;
}

.queue-list {
  margin: 10px 0 0;
  padding-left: 18px;
}

.queue-list li {
  margin: 6px 0;
}

.queue-link {
  color: #1d5f99;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.queue-link:hover {
  color: #0f4677;
}

.app-modal {
  border: none;
  border-radius: 18px;
  padding: 0;
  max-width: min(940px, 92vw);
  width: 92vw;
  background: transparent;
}

.app-modal::backdrop {
  background: rgba(18, 27, 32, 0.4);
}

.app-modal__panel {
  background: #f8fbfa;
  border: 1px solid #c7d5d0;
  border-radius: 18px;
  padding: 20px;
}

.app-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.stack {
  max-width: 980px;
  margin: 0 auto;
  display: grid;
  gap: 14px;
}

.card {
  /* Defensive overrides: some other pages define fixed card widths. */
  width: auto;
  max-width: none;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 14px 30px rgba(35, 57, 53, 0.08);
  padding: 16px;
}

.card h2 {
  margin: 0;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 18px;
}

.card h2 + .small {
  margin-top: 8px;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.pill {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  font-weight: 700;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}

.metric {
  font-size: 34px;
  font-family: 'Space Grotesk', sans-serif;
  margin: 10px 0 0;
}

.small {
  color: var(--muted);
  margin: 6px 0 0;
}

.text-warn {
  color: #b34831;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 12px;
}

.field {
  display: block;
}

.field label {
  display: block;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #2d464a;
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 16px;
  background: #fff;
}

.password-field-wrap {
  display: flex;
  width: 100%;
  gap: 8px;
  align-items: center;
}

.password-field-wrap .password-input {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  padding-right: 52px;
}

.password-toggle {
  width: 40px;
  height: 40px;
  min-width: 40px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  color: #335559;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.password-toggle svg {
  width: 18px;
  height: 18px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.row-actions.spread {
  justify-content: space-between;
  align-items: center;
}

button.sm {
  padding: 8px 12px;
  font-size: 14px;
}

/* Profile page: keep the form elements consistent and readable. */
.profile-page .field input {
  font-size: 16px;
  padding: 12px 14px;
}

.profile-page button {
  font-size: 14px;
  padding: 9px 13px;
}

.profile-page button.ghost {
  padding: 8px 12px;
}

button.primary {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  font-weight: 800;
}

button.action {
  background: #cd6618;
  color: #fff7f2;
  border-color: #cd6618;
  font-weight: 800;
}

button.danger {
  background: #fff1ed;
  border-color: #f0b9a7;
  color: #7c2a12;
  font-weight: 800;
}

.role-checkbox-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px 14px;
}

.checked-listbox {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 10px 12px;
  max-height: 220px;
  overflow: auto;
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 16px;
  font-family: 'Prometo', 'Space Grotesk', sans-serif;
}

.checkbox-row input[type='checkbox'] {
  width: 18px;
  height: 18px;
  margin: 0;
}

.hr {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.table th,
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid #e1ebe6;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  letter-spacing: 0.01em;
}

.table td.device,
.table th.device {
  width: 44%;
}

.table td.date,
.table th.date {
  white-space: nowrap;
  width: 18%;
}

.table td.status,
.table th.status {
  white-space: nowrap;
  width: 12%;
}

.table td.wrap {
  word-break: break-word;
  overflow-wrap: anywhere;
}

.table th {
  font-weight: 900;
  color: #1f3e40;
  background: #f1f7f4;
}

.table tr:last-child td {
  border-bottom: none;
}

.selectable-row {
  cursor: pointer;
}

.selected-row td {
  background: #e9f6f1;
}

.schedule-period h3 {
  margin: 0;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 16px;
}

.schedule-period h4 {
  margin: 0;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14px;
}

.schedule-defaults {
  margin-top: 10px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: #f7fcf9;
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
}

.schedule-defaults strong {
  display: block;
  width: 100%;
  font-size: 13px;
  color: #2a4847;
  margin-bottom: 2px;
}

.schedule-defaults label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.schedule-defaults input {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 8px;
  font-size: 14px;
  background: #fff;
}

.table-scroll {
  overflow-x: auto;
}

.table.compact th,
.table.compact td {
  padding: 8px 10px;
}

.cycle-week-block {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: #fbfefd;
}

@media (max-width: 920px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      'topbar'
      'nav'
      'main';
  }

  .nav {
    border-right: none;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 8px;
    overflow-x: auto;
  }

  .nav-link {
    margin: 0;
    white-space: nowrap;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .topic-grid {
    grid-template-columns: 1fr;
  }

  .topic-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .top-headline {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .ticket-head-actions {
    width: 100%;
  }

}
