:root {
  color-scheme: light;
  --ink: #17313d;
  --muted: #667982;
  --navy: #123c4a;
  --navy-deep: #0b2c37;
  --teal: #0f8c82;
  --teal-dark: #087268;
  --mint: #dff3ee;
  --cream: #f6f3eb;
  --paper: #ffffff;
  --line: #dce5e5;
  --danger: #b54040;
  --danger-soft: #fce7e6;
  --amber: #b87813;
  --amber-soft: #fff0cf;
  --green: #317858;
  --green-soft: #e3f3e9;
  --blue-soft: #e6f1f5;
  --shadow: 0 18px 50px rgba(20, 57, 68, .10);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--cream); color: var(--ink); min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 7px; color: var(--teal-dark); font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 12px; font-family: Georgia, serif; font-size: clamp(38px, 5vw, 58px); line-height: 1; }
h2 { margin: 0; font-family: Georgia, serif; font-size: 30px; }
h3 { margin-bottom: 8px; font-size: 20px; }

.login-screen { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 560px) 1fr; background: var(--cream); }
.login-panel { display: flex; flex-direction: column; justify-content: center; padding: clamp(36px, 7vw, 100px); background: var(--paper); }
.brand-mark { display: grid; place-items: center; width: 58px; height: 58px; margin-bottom: 28px; border-radius: 17px; background: var(--teal); color: white; font-weight: 900; letter-spacing: -.05em; box-shadow: 0 10px 25px rgba(15, 140, 130, .25); }
.brand-mark.small { width: 39px; height: 39px; margin: 0; border-radius: 12px; font-size: 13px; }
.login-copy { max-width: 460px; margin-bottom: 28px; color: var(--muted); line-height: 1.65; }
.login-art { position: relative; overflow: hidden; background: linear-gradient(145deg, var(--navy-deep), #145564); }
.login-art::before { content: ""; position: absolute; inset: 0; opacity: .16; background-image: radial-gradient(circle at 2px 2px, white 1px, transparent 0); background-size: 30px 30px; }
.art-ring { position: absolute; width: 540px; height: 540px; right: -100px; bottom: -140px; border: 110px solid rgba(68, 201, 184, .17); border-radius: 50%; }
.art-card { position: absolute; z-index: 1; width: 260px; padding: 22px; border: 1px solid rgba(255,255,255,.18); border-radius: 20px; background: rgba(255,255,255,.12); color: white; backdrop-filter: blur(10px); box-shadow: var(--shadow); }
.art-card span, .art-card small { display: block; opacity: .72; }
.art-card strong { display: block; margin: 12px 0 5px; font-family: Georgia, serif; font-size: 28px; }
.art-card-one { left: 15%; top: 25%; transform: rotate(-3deg); }
.art-card-two { right: 12%; bottom: 24%; transform: rotate(3deg); }
.privacy-banner { border: 1px solid #eedcae; background: #fff7df; color: #72561e; }
.login-notice { margin-top: 22px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 12px; background: #f3f7f6; color: var(--muted); font-size: 12px; line-height: 1.45; }
.login-notice strong { color: var(--ink); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 245px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 26px 17px 20px; background: var(--navy-deep); color: white; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 28px; }
.brand strong, .brand span { display: block; }
.brand span { margin-top: 1px; color: #83beb9; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; }
.main-nav { display: grid; gap: 5px; }
.nav-item { width: 100%; display: flex; gap: 11px; align-items: center; padding: 11px 12px; border: 0; border-radius: 11px; background: transparent; color: #b9d0d5; text-align: left; }
.nav-item span { width: 19px; text-align: center; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.10); color: white; }
.sidebar-footer { margin-top: auto; padding: 18px 8px 0; border-top: 1px solid rgba(255,255,255,.12); }
.user-card strong, .user-card span { display: block; }
.user-card strong { font-size: 13px; }
.user-card span { margin-top: 4px; color: #91adb4; font-size: 11px; text-transform: capitalize; }
.sidebar .text-button { margin-top: 11px; color: #a8c3c7; }

.workspace { min-width: 0; }
.topbar { min-height: 94px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 20px 34px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.88); backdrop-filter: blur(10px); }
.topbar-actions { display: flex; align-items: end; gap: 12px; }
.clinic-filter { display: grid; gap: 4px; color: var(--muted); font-size: 11px; font-weight: 700; }
.clinic-filter select { min-width: 190px; }
.privacy-banner { padding: 9px 34px; font-size: 12px; }
main { padding: 30px 34px 55px; }
.view { display: none; }
.view.active { display: block; animation: fadeIn .18s ease; }
@keyframes fadeIn { from { opacity: .25; transform: translateY(3px); } }

.button { min-height: 40px; padding: 9px 16px; border: 1px solid transparent; border-radius: 10px; font-weight: 800; font-size: 13px; }
.button.primary { background: var(--teal); color: white; box-shadow: 0 7px 18px rgba(15, 140, 130, .16); }
.button.primary:hover { background: var(--teal-dark); }
.button.secondary { border-color: var(--line); background: white; color: var(--ink); }
.button.full { width: 100%; }
.button:disabled { opacity: .55; cursor: not-allowed; }
.text-button { padding: 0; border: 0; background: none; color: var(--teal-dark); font-size: 12px; font-weight: 800; }
.text-button:hover { text-decoration: underline; }
.button:focus-visible, .text-button:focus-visible, .mini-row:focus-visible, .drawer-close:focus-visible { outline: 3px solid rgba(15,140,130,.3); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.form-stack { display: grid; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; margin-top: 24px; }
.span-2 { grid-column: 1 / -1; }
label { display: grid; gap: 7px; color: #39525b; font-size: 12px; font-weight: 750; }
input, select, textarea { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #cddada; border-radius: 9px; outline: none; background: white; color: var(--ink); }
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(15,140,130,.11); }
.form-error { min-height: 18px; color: var(--danger); font-size: 12px; }
.form-message { margin: 0; color: var(--teal-dark); font-size: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }

.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(140px,1fr)); gap: 14px; margin-bottom: 18px; }
.metric-card, .panel, .callback-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: 0 5px 20px rgba(30,67,77,.04); }
.metric-card { padding: 20px; }
.metric-card span, .metric-card small { display: block; color: var(--muted); }
.metric-card span { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.metric-card strong { display: block; margin: 10px 0 4px; font-family: Georgia, serif; font-size: 31px; }
.metric-card small { font-size: 11px; }
.metric-card.alert strong { color: var(--danger); }
.panel { padding: 22px; }
.panel-heading, .section-intro, .queue-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.panel-heading { margin-bottom: 14px; }
.panel-heading h3 { margin: 0; }
.dashboard-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: 18px; }

.mini-list { display: grid; gap: 8px; }
.mini-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 12px; align-items: center; width: 100%; padding: 12px 0; border: 0; border-bottom: 1px solid #edf1f1; background: transparent; color: inherit; text-align: left; }
.mini-row:last-child { border-bottom: 0; }
.mini-row strong, .mini-row span { display: block; }
.mini-row span, .mini-row small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.mini-row .right { text-align: right; }
.empty-state { padding: 32px 12px; color: var(--muted); text-align: center; }

.queue-toolbar { flex-wrap: wrap; margin-bottom: 18px; }
.queue-toolbar input { width: min(280px, 100%); }
.queue-toolbar select { width: 170px; }
.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 11px; background: #f1f5f4; }
.segmented button { padding: 7px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 800; }
.segmented button.active { background: white; color: var(--teal-dark); box-shadow: 0 2px 6px rgba(24,57,67,.09); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 9px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 10px; letter-spacing: .08em; text-align: left; text-transform: uppercase; }
td { padding: 13px 9px; border-bottom: 1px solid #edf1f1; font-size: 12px; vertical-align: middle; }
tbody tr { cursor: default; }
tbody tr:hover { background: #f8fbfa; }
.patient-cell strong, .patient-cell span { display: block; }
.patient-cell span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.badge { display: inline-flex; align-items: center; min-height: 25px; padding: 4px 8px; border-radius: 999px; background: var(--blue-soft); color: #315f70; font-size: 10px; font-weight: 850; text-transform: capitalize; white-space: nowrap; }
.badge.booked { background: var(--green-soft); color: var(--green); }
.badge.callback_scheduled, .badge.waiting_for_clinic { background: var(--amber-soft); color: #80520b; }
.badge.not_booked, .badge.do_not_contact { background: #f0eded; color: #716363; }
.priority { font-size: 10px; font-weight: 850; text-transform: uppercase; }
.priority.high { color: var(--amber); }
.priority.urgent { color: var(--danger); }

.section-intro { margin-bottom: 20px; }
.section-intro p:last-child { margin: 0; color: var(--muted); }
.callback-board { display: grid; grid-template-columns: repeat(3, minmax(220px,1fr)); gap: 15px; }
.callback-card { padding: 18px; }
.callback-card.overdue { border-color: #e9b7b5; }
.callback-card header { display: flex; justify-content: space-between; gap: 10px; }
.callback-card h3 { margin: 11px 0 5px; }
.callback-card p { margin-bottom: 15px; color: var(--muted); font-size: 12px; }
.callback-card footer { display: flex; justify-content: space-between; align-items: center; padding-top: 12px; border-top: 1px solid #edf1f1; color: var(--muted); font-size: 11px; }
.callback-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 0 0 13px; color: var(--muted); font-size: 11px; }
.due-label { color: var(--teal-dark); font-weight: 850; }
.overdue .due-label { color: var(--danger); }
.handover-state { display: inline-flex; align-items: center; padding: 4px 7px; border-radius: 999px; background: #f0f3f3; color: var(--muted); font-size: 10px; font-weight: 800; white-space: nowrap; }
.handover-state.pending { background: var(--amber-soft); color: #80520b; }
.handover-state.sent { background: var(--blue-soft); color: #315f70; }
.handover-state.acknowledged { background: var(--green-soft); color: var(--green); }

.form-layout { display: grid; grid-template-columns: minmax(0,1.35fr) minmax(250px,.65fr); gap: 18px; align-items: start; }
.form-panel { padding: 28px; }
.guidance-card { padding: 25px; border-radius: var(--radius); background: var(--navy); color: white; }
.guidance-card .eyebrow { color: #75d4ca; }
.guidance-card ul { margin: 18px 0 0; padding-left: 18px; color: #c8dcdf; font-size: 13px; line-height: 1.8; }

.report-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 18px; }
.report-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.bar-list { display: grid; gap: 13px; }
.bar-label { display: flex; justify-content: space-between; margin-bottom: 5px; font-size: 12px; }
.bar-track { height: 8px; overflow: hidden; border-radius: 999px; background: #eaf0ef; }
.bar-fill { height: 100%; border-radius: inherit; background: var(--teal); }

.drawer-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(8,32,40,.35); }
.drawer { position: fixed; top: 0; right: 0; z-index: 21; width: min(570px, 100%); height: 100vh; overflow-y: auto; padding: 34px; background: white; box-shadow: -15px 0 50px rgba(10,40,48,.16); transform: translateX(100%); transition: transform .22s ease; }
.drawer.open { transform: translateX(0); }
.drawer-close { position: absolute; top: 18px; right: 20px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: #edf3f2; color: var(--ink); font-size: 20px; }
.drawer-header { padding-right: 36px; }
.drawer-header h2 { margin: 4px 0 7px; }
.drawer-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 15px 0 23px; }
.detail-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; padding: 16px; border-radius: 12px; background: #f5f8f7; }
.detail-grid span, .detail-grid strong { display: block; }
.detail-grid span { margin-bottom: 3px; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.detail-grid strong { font-size: 12px; }
.drawer-section { padding: 24px 0; border-bottom: 1px solid var(--line); }
.drawer-section h3 { font-size: 16px; }
.timeline { display: grid; gap: 13px; }
.timeline-item { position: relative; padding-left: 18px; }
.timeline-item::before { content: ""; position: absolute; left: 0; top: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--teal); }
.timeline-item strong, .timeline-item span { display: block; }
.timeline-item span, .timeline-item p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.timeline-handover { margin-top: 10px; padding: 10px 12px; border-left: 3px solid var(--amber); border-radius: 0 8px 8px 0; background: #fff8e8; }
.timeline-handover strong { color: #80520b; font-size: 11px; }
.attempt-form { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.attempt-form .span-2 { grid-column: 1 / -1; }
.booking-fields { display: contents; }
.attempt-group { margin: 7px 0 0; padding: 16px; border: 1px solid var(--line); border-radius: 12px; }
.attempt-group legend { padding: 0 7px; color: var(--ink); font-size: 13px; font-weight: 850; }
.attempt-group > p { margin: 0 0 14px; color: var(--muted); font-size: 11px; }
.attempt-group-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.required-field::after { content: "Required when handover is selected"; color: var(--danger); font-size: 10px; font-weight: 700; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 30; max-width: 380px; padding: 13px 17px; border-radius: 10px; background: var(--navy-deep); color: white; box-shadow: var(--shadow); font-size: 12px; }
.toast.error { background: #7b2929; }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(3,1fr); }
  .callback-board { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; width: 100%; height: auto; padding: 14px; }
  .brand { padding-bottom: 12px; }
  .main-nav { display: flex; overflow-x: auto; }
  .nav-item { flex: 0 0 auto; width: auto; }
  .sidebar-footer { display: none; }
  .topbar { align-items: flex-start; padding: 19px; }
  .topbar-actions { align-items: stretch; flex-direction: column; }
  main { padding: 22px 18px 40px; }
  .privacy-banner { padding-inline: 18px; }
  .dashboard-grid, .form-layout, .report-layout { grid-template-columns: 1fr; }
  .login-screen { grid-template-columns: 1fr; }
  .login-art { display: none; }
}
@media (max-width: 600px) {
  .topbar { flex-direction: column; }
  .topbar-actions, .clinic-filter select { width: 100%; }
  .metric-grid, .report-grid, .callback-board, .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .queue-toolbar { align-items: stretch; flex-direction: column; }
  .queue-toolbar input, .queue-toolbar select { width: 100%; }
  .drawer { padding: 25px 19px; }
  .attempt-form, .detail-grid { grid-template-columns: 1fr; }
  .attempt-form .span-2 { grid-column: auto; }
}




