:root {
  color-scheme: light;
  --ink: #12243a;
  --ink-2: #32465c;
  --muted: #6d7d8c;
  --surface: #ffffff;
  --surface-2: #f4f7f8;
  --line: #dbe4e8;
  --teal: #168b87;
  --teal-soft: #dff4f1;
  --blue: #315b9d;
  --green: #287d57;
  --gold: #c78321;
  --coral: #d95b4d;
  --shadow: 0 20px 48px rgba(18, 36, 58, 0.12);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  color: var(--ink);
  background: #edf2f4;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  min-height: 100svh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 72px;
  padding: 12px clamp(16px, 3vw, 32px);
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 230px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: #fff;
  background: var(--ink);
  border-radius: var(--radius);
  font-weight: 850;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 0.78rem;
}

.view-tabs {
  display: flex;
  gap: 6px;
  padding: 5px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.view-tab,
.program-filter {
  min-height: 38px;
  padding: 0 14px;
  color: var(--ink-2);
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  font-weight: 760;
}

.view-tab.is-active,
.program-filter.is-active {
  color: #fff;
  background: var(--ink);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-shell:not([data-view="staff"]) #reset-demo,
.app-shell:not([data-view="staff"]) #add-procedure {
  display: none;
}

.staff-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  max-width: 180px;
  overflow: hidden;
  padding: 8px 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: var(--radius);
  font-weight: 800;
}

.button {
  padding: 0 15px;
  border: 1px solid transparent;
}

.button.primary {
  color: #fff;
  background: var(--teal);
}

.button.secondary {
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
}

.button.danger {
  color: #fff;
  background: var(--coral);
}

.icon-button {
  width: 40px;
  border: 1px solid var(--line);
  background: #fff;
}

.notice {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px clamp(16px, 3vw, 32px);
  color: #3d4b57;
  background: #fff9e9;
  border-bottom: 1px solid #ead8a8;
  font-size: 0.9rem;
}

.auth-body {
  align-items: center;
  background:
    linear-gradient(135deg, rgba(22, 111, 113, 0.15), rgba(44, 123, 229, 0.08)),
    var(--surface-2);
  display: flex;
  min-height: 100vh;
}

.auth-shell {
  margin: 0 auto;
  max-width: 460px;
  padding: 24px;
  width: 100%;
}

.auth-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.auth-brand {
  align-items: center;
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.auth-brand div {
  display: grid;
  gap: 2px;
}

.auth-brand span:last-child,
.auth-panel p {
  color: var(--muted);
}

.auth-panel h1 {
  font-size: 28px;
  margin: 0 0 8px;
}

.auth-form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.auth-form label {
  color: var(--ink);
  display: grid;
  font-size: 0.82rem;
  font-weight: 800;
  gap: 7px;
}

.auth-form input {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit;
  padding: 12px;
}

.auth-alert {
  background: #fff3d9;
  border: 1px solid #f1c96a;
  border-radius: var(--radius);
  color: #7c5600;
  margin-bottom: 18px;
  padding: 12px;
}

.view-panel {
  display: none;
}

.view-panel.is-active {
  display: block;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: calc(100svh - 116px);
}

.sidebar {
  padding: 22px 18px;
  background: #0d1d31;
  color: #fff;
}

.sidebar-section {
  margin-bottom: 24px;
}

.sidebar h2 {
  margin: 0 0 10px;
  color: #cbd9e7;
  font-size: 0.8rem;
  text-transform: uppercase;
}

.search-label {
  display: block;
  margin-bottom: 8px;
  color: #cbd9e7;
  font-size: 0.82rem;
  font-weight: 800;
}

.sidebar input,
.sidebar select,
.composer textarea,
.procedure-dialog input,
.procedure-dialog select {
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.program-filter {
  justify-content: flex-start;
  width: 100%;
  margin-bottom: 7px;
  color: #d9e6ef;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.program-filter.is-active {
  background: var(--teal);
}

.mini-list {
  display: grid;
  gap: 8px;
}

.mini-list div {
  padding: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
}

.mini-list strong,
.mini-list span {
  display: block;
}

.mini-list span {
  color: #bacbd7;
  font-size: 0.82rem;
}

.work-area {
  padding: 22px;
  overflow: hidden;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric-card {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(18, 36, 58, 0.06);
}

.metric-card strong {
  display: block;
  font-size: 1.85rem;
}

.metric-card span {
  color: var(--muted);
  font-size: 0.88rem;
}

.queue-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.88fr) minmax(420px, 1.12fr);
  gap: 16px;
  align-items: start;
}

.queue-panel,
.detail-panel,
.patient-phone,
.template-card,
.procedure-dialog form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 0.74rem;
  font-weight: 880;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 2rem;
  line-height: 1.08;
}

h2 {
  font-size: 1.18rem;
  line-height: 1.2;
}

h3 {
  margin-bottom: 8px;
  font-size: 1rem;
}

.queue-count {
  padding: 6px 10px;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-weight: 760;
}

.patient-list {
  display: grid;
  max-height: calc(100svh - 300px);
  overflow: auto;
}

.patient-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 14px 16px;
  text-align: left;
  background: #fff;
  border: 0;
  border-bottom: 1px solid var(--line);
}

.patient-row:hover,
.patient-row.is-active {
  background: #eef8f7;
}

.patient-row strong,
.patient-row span {
  display: block;
}

.patient-row .meta {
  color: var(--muted);
  font-size: 0.84rem;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 9px;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.78rem;
  font-weight: 820;
}

.status-ready {
  color: #0f5132;
  background: #e7f6ee;
  border-color: #b7dfc9;
}

.status-forms {
  color: #755315;
  background: #fff3d9;
  border-color: #efd28d;
}

.status-call,
.status-risk {
  color: #832c23;
  background: #ffe8e5;
  border-color: #e9b6af;
}

.detail-panel {
  min-height: 600px;
}

.detail-header,
.detail-section {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.detail-header p,
.detail-section p,
.template-card p,
.patient-context p {
  color: var(--muted);
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: start;
  justify-content: flex-end;
}

.readiness-bar {
  height: 10px;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: 999px;
}

.readiness-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--green));
}

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

.check-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.check-item input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--teal);
}

.thread {
  display: grid;
  gap: 8px;
  max-height: 280px;
  padding-right: 4px;
  overflow: auto;
}

.message {
  max-width: 82%;
  padding: 10px 12px;
  border-radius: var(--radius);
}

.message.staff {
  justify-self: end;
  color: #fff;
  background: var(--blue);
}

.message.patient {
  justify-self: start;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.message small {
  display: block;
  margin-top: 5px;
  opacity: 0.72;
}

.composer {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.composer textarea {
  min-height: 84px;
  resize: vertical;
}

.composer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.patient-shell {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: clamp(22px, 5vw, 60px);
  align-items: start;
  padding: 42px clamp(18px, 5vw, 64px);
}

.patient-phone {
  max-width: 420px;
  overflow: hidden;
}

.phone-status {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  color: #fff;
  background: var(--ink);
}

.patient-card {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.patient-card h2 {
  margin-bottom: 8px;
}

.patient-task {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  margin-top: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.patient-task input {
  width: 20px;
  height: 20px;
  accent-color: var(--teal);
}

.patient-context {
  padding-top: 26px;
}

.patient-context h1 {
  max-width: 780px;
  font-size: 3.6rem;
}

.context-art {
  max-width: 760px;
  margin-top: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.template-page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 46px clamp(18px, 4vw, 0px);
}

.staff-access-page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 46px clamp(18px, 4vw, 0px);
}

.section-heading {
  max-width: 760px;
  margin-bottom: 22px;
}

.section-heading h1 {
  font-size: 3rem;
  margin-bottom: 12px;
}

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

.staff-access-layout {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(280px, 1fr);
  gap: 16px;
  margin-bottom: 18px;
}

.staff-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.staff-card h2 {
  margin: 0 0 14px;
}

.staff-form {
  display: grid;
  gap: 14px;
}

.staff-form label {
  color: var(--ink);
  display: grid;
  font-size: 0.82rem;
  font-weight: 800;
  gap: 7px;
}

.staff-form input,
.staff-form select,
.copy-row input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit;
  padding: 12px;
}

.invite-output-label {
  display: block;
  margin: 16px 0 8px;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 800;
}

.staff-invite-text {
  width: 100%;
  min-height: 210px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit;
  line-height: 1.45;
  padding: 12px;
}

.full-width {
  width: 100%;
  margin-top: 10px;
}

.copy-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.staff-user-list {
  display: grid;
  gap: 10px;
}

.staff-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.staff-user-row strong,
.staff-user-row span,
.staff-user-row small {
  display: block;
}

.staff-user-row span,
.staff-user-row small,
#temp-password-panel p {
  color: var(--muted);
}

.staff-user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.template-card {
  min-height: 260px;
  padding: 24px;
}

.template-index {
  display: inline-block;
  margin-bottom: 18px;
  color: var(--teal);
  font-weight: 900;
}

.template-card ul {
  display: grid;
  gap: 8px;
  margin: 16px 0 0;
  padding-left: 20px;
  color: var(--ink-2);
}

.procedure-dialog {
  width: min(560px, calc(100% - 28px));
  padding: 0;
  border: 0;
  background: transparent;
}

.procedure-dialog::backdrop {
  background: rgba(9, 21, 34, 0.48);
}

.procedure-dialog form {
  display: grid;
  gap: 13px;
  padding: 20px;
}

.procedure-dialog label {
  display: grid;
  gap: 6px;
  color: var(--ink-2);
  font-size: 0.9rem;
  font-weight: 760;
}

.dialog-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.dialog-heading h2 {
  margin: 0;
}

.empty-state {
  padding: 28px;
  color: var(--muted);
}

.audit-list {
  display: grid;
  gap: 8px;
}

.audit-list div {
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.audit-list strong,
.audit-list span {
  display: block;
}

.audit-list strong {
  text-transform: capitalize;
}

.audit-list span {
  color: var(--muted);
  font-size: 0.84rem;
}

@media (max-width: 1120px) {
  .dashboard-grid,
  .queue-layout,
  .patient-shell {
    grid-template-columns: 1fr;
  }

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

  .sidebar-section {
    margin-bottom: 0;
  }

  .patient-list {
    max-height: none;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .brand {
    min-width: 0;
  }

  .view-tabs,
  .topbar-actions {
    width: 100%;
  }

  .view-tabs {
    overflow-x: auto;
  }

  .view-tab {
    flex: 1 0 auto;
  }

  .topbar-actions .button {
    flex: 1;
  }

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

  .sidebar,
  .metrics-grid,
  .checklist,
  .template-grid,
  .staff-access-layout {
    grid-template-columns: 1fr;
  }

  .work-area {
    padding: 14px;
  }

  .detail-header,
  .panel-heading,
  .staff-user-row {
    flex-direction: column;
  }

  .detail-actions,
  .composer-row,
  .staff-user-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .button,
  .detail-actions button {
    width: 100%;
  }

  .patient-context h1,
  .section-heading h1 {
    font-size: 2.25rem;
  }
}
