:root {
  --ink: #173e43;
  --ink-deep: #103439;
  --teal: #087d78;
  --teal-dark: #075d5b;
  --mint: #eef9f5;
  --mint-strong: #dff1ea;
  --line: #d8e7e2;
  --line-soft: #e9f2ef;
  --muted: #718486;
  --muted-dark: #53686a;
  --white: #ffffff;
  --gold: #c98729;
  --gold-soft: #fff5df;
  --green: #28775b;
  --green-soft: #e8f6ed;
  --red: #b34d4d;
  --red-soft: #fff0ef;
  --blue-soft: #eef3ff;
  --shadow: 0 18px 45px rgba(23, 62, 67, .08);
  --shadow-sm: 0 8px 22px rgba(23, 62, 67, .06);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; color: var(--ink); background: #f6fbf9; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { min-height: 76px; padding: 0 28px; display: flex; align-items: center; gap: 24px; color: #fff; background: var(--ink-deep); position: sticky; top: 0; z-index: 10; box-shadow: 0 4px 18px rgba(16, 52, 57, .14); }
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; margin-right: auto; }
.brand-mark { width: 37px; height: 37px; border: 1px solid rgba(255,255,255,.38); border-radius: 12px 12px 12px 4px; display: grid; place-items: center; color: #d4eee7; font-size: 11px; font-weight: 900; letter-spacing: -.05em; transform: rotate(-4deg); }
.brand-copy { display: grid; gap: 2px; }
.brand-copy strong { font-size: 14px; letter-spacing: -.01em; }
.brand-copy small { color: #a6c4c0; font-size: 10px; font-weight: 600; letter-spacing: .03em; }
.nav-tabs { display: flex; align-items: center; gap: 5px; }
.nav-tab { border: 1px solid transparent; padding: 10px 13px; border-radius: 10px; color: #b9d3d0; background: transparent; font-size: 12px; font-weight: 800; }
.nav-tab:hover, .nav-tab.active { color: var(--ink-deep); background: #f8fffc; }
.topbar-status { display: inline-flex; align-items: center; gap: 7px; color: #b9d3d0; border-left: 1px solid rgba(255,255,255,.16); padding-left: 20px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #7de0a7; box-shadow: 0 0 0 4px rgba(125, 224, 167, .12); }

.prototype-banner { padding: 10px max(20px, calc((100vw - 1190px) / 2)); display: flex; align-items: center; gap: 10px; color: #486669; background: #eef8f5; border-bottom: 1px solid var(--line); font-size: 11px; }
.prototype-banner p { margin: 0; line-height: 1.45; }
.prototype-banner strong { color: var(--ink); }
.banner-icon { width: 17px; height: 17px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid #83aaa5; border-radius: 50%; color: var(--teal); font-size: 11px; font-weight: 900; }
.banner-close { margin-left: auto; border: 0; color: #73908e; background: transparent; font-size: 19px; line-height: 1; }

main { width: min(1190px, 100%); flex: 1; margin: 0 auto; padding: 48px 22px 60px; }
.view { animation: page-in .35s ease both; }
@keyframes page-in { from { opacity: .2; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }
.booking-layout { display: grid; grid-template-columns: minmax(0, .87fr) minmax(520px, 1.13fr); gap: clamp(34px, 7vw, 100px); align-items: center; }
.booking-intro { padding: 14px 0 0 8px; }
.eyebrow, .section-kicker { margin: 0 0 10px; color: var(--teal); font-size: 10px; font-weight: 900; letter-spacing: .17em; line-height: 1.2; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 17px; color: var(--ink-deep); font-size: clamp(38px, 5.2vw, 68px); letter-spacing: -.065em; line-height: .98; max-width: 590px; }
.booking-intro .lede { max-width: 475px; }
.lede { color: var(--muted-dark); font-size: 16px; line-height: 1.65; }
.intro-rule { width: 54px; height: 4px; border-radius: 2px; background: var(--gold); margin: 31px 0 27px; }
.trust-list { display: grid; gap: 18px; max-width: 430px; }
.trust-item { display: flex; gap: 12px; align-items: flex-start; }
.trust-icon { width: 29px; height: 29px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 10px; color: var(--teal-dark); background: var(--mint-strong); font-size: 9px; font-weight: 900; }
.trust-item strong { display: block; color: var(--ink); font-size: 13px; }
.trust-item small { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.emergency-note { display: flex; gap: 10px; max-width: 445px; margin-top: 36px; padding: 13px 15px; color: #6f5a37; background: #fff8eb; border: 1px solid #f0e2c9; border-radius: 12px; }
.emergency-note .note-mark { width: 19px; height: 19px; flex: 0 0 auto; display: grid; place-items: center; color: #966c29; border: 1px solid #d7b46b; border-radius: 50%; font-size: 11px; font-weight: 900; }
.emergency-note strong { font-size: 11px; }
.emergency-note p { margin: 3px 0 0; font-size: 11px; line-height: 1.45; }

.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.booking-card { padding: clamp(22px, 4vw, 34px); }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.card-heading.compact { margin-bottom: 19px; }
.card-heading h2, .toolbar h2 { margin: 0; color: var(--ink-deep); font-size: 21px; letter-spacing: -.04em; }
.secure-badge, .month-pill, .staff-only, .audit-lock { display: inline-flex; align-items: center; gap: 5px; padding: 6px 9px; border-radius: 99px; color: var(--teal-dark); background: var(--mint); font-size: 10px; font-weight: 800; white-space: nowrap; }
.secure-badge span { font-size: 14px; }
.field-grid { display: grid; gap: 13px; }
.two-col { grid-template-columns: 1fr 1fr; }
.field { margin-bottom: 15px; }
.field label { display: flex; align-items: baseline; gap: 4px; margin-bottom: 7px; color: var(--ink); font-size: 11px; font-weight: 850; }
.field label span { color: var(--red); }
.field label em { color: var(--muted); font-size: 10px; font-style: normal; font-weight: 600; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: #fff; padding: 12px 12px; outline: none; font-size: 13px; transition: border-color .16s, box-shadow .16s, background .16s; }
input::placeholder, textarea::placeholder { color: #a9b8b7; }
input:hover, select:hover, textarea:hover { border-color: #a7c5bf; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8, 125, 120, .12); }
textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
.field-help { display: block; margin-top: 6px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.check-row { position: relative; display: flex; gap: 10px; align-items: flex-start; margin: 2px 0 20px; color: var(--muted-dark); font-size: 11px; line-height: 1.48; cursor: pointer; }
.check-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check-box { width: 17px; height: 17px; flex: 0 0 auto; margin-top: 1px; border: 1px solid #b8ccc8; border-radius: 5px; background: #fff; }
.check-row input:checked + .check-box { border-color: var(--teal); background: var(--teal); box-shadow: inset 0 0 0 3px #fff; }
.check-row small { display: block; color: #8b9a9a; font-size: 10px; }
.form-footer { display: flex; align-items: center; gap: 15px; }
.form-footer p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.4; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; border: 0; border-radius: 10px; padding: 12px 15px; font-size: 12px; font-weight: 850; transition: transform .15s, background .15s, color .15s, border-color .15s; }
.button:hover { transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--teal); box-shadow: 0 7px 14px rgba(8, 125, 120, .18); }
.button-primary:hover { background: var(--teal-dark); }
.button-secondary { color: var(--teal-dark); background: var(--mint-strong); }
.button-secondary:hover { background: #d0e9e0; }
.button-quiet { color: var(--muted-dark); background: transparent; border: 1px solid var(--line); }
.button-quiet:hover { color: var(--red); border-color: #e3bdbc; background: #fff8f7; }
.form-message { display: none; margin-top: 15px; padding: 12px; border-radius: 10px; color: var(--green); background: var(--green-soft); font-size: 12px; line-height: 1.45; }
.form-message.visible { display: block; }
.form-message.error { color: var(--red); background: var(--red-soft); }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 20; max-width: min(360px, calc(100vw - 44px)); padding: 12px 14px; border: 1px solid #bfe0d6; border-radius: 10px; color: var(--teal-dark); background: #f1fbf7; box-shadow: var(--shadow); font-size: 11px; font-weight: 750; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .18s, transform .18s; }
.toast:not(:empty) { opacity: 1; transform: translateY(0); }
.toast[data-error="true"] { border-color: #e6baba; color: var(--red); background: var(--red-soft); }
.bottom-strip { display: flex; align-items: center; gap: 14px; margin-top: 35px; color: #75908e; font-size: 10px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.strip-line { width: 34px; height: 1px; background: #b7d0cb; }

.dashboard-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 25px; }
.dashboard-head h1 { margin-bottom: 12px; font-size: clamp(36px, 5vw, 58px); }
.dashboard-head .lede { margin-bottom: 0; font-size: 14px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.data-boundary { display: flex; align-items: center; gap: 11px; padding: 12px 14px; margin-bottom: 17px; border: 1px solid #bfe0d6; border-radius: 12px; background: #f1fbf7; color: var(--muted-dark); font-size: 11px; }
.boundary-icon { width: 24px; height: 24px; display: grid; place-items: center; color: var(--teal); border: 1px solid #abd4c8; border-radius: 50%; font-size: 16px; }
.data-boundary strong { display: block; color: var(--ink); font-size: 11px; }
.data-boundary span:not(.boundary-icon):not(.version-tag) { display: block; margin-top: 2px; }
.version-tag { margin-left: auto; padding: 4px 7px; border: 1px solid #c6e2d9; border-radius: 6px; color: var(--teal-dark); background: #fff; font-family: ui-monospace, monospace; font-size: 10px; white-space: nowrap; }
.metrics-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; margin-bottom: 17px; }
.metric-card { padding: 18px 19px 16px; border-top: 3px solid var(--teal); }
.metric-card.gold { border-top-color: var(--gold); }
.metric-card.green { border-top-color: var(--green); }
.metric-card.red { border-top-color: var(--red); }
.metric-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.metric-label { color: var(--muted); font-size: 11px; font-weight: 750; }
.metric-icon { color: var(--teal); font-size: 17px; }
.metric-card.gold .metric-icon { color: var(--gold); }
.metric-card.green .metric-icon { color: var(--green); }
.metric-card.red .metric-icon { color: var(--red); }
.metric-number { margin-top: 9px; color: var(--ink-deep); font-size: 31px; font-weight: 900; letter-spacing: -.07em; }
.metric-note { margin-top: 4px; color: var(--muted); font-size: 10px; }
.dashboard-grid { display: grid; gap: 17px; }
.top-grid { grid-template-columns: minmax(0, 1.65fr) minmax(300px, .8fr); }
.bottom-grid { grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); margin-top: 17px; }
.table-card, .trend-card, .selected-card, .audit-card { padding: 21px; }
.toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 13px; }
.filters { display: flex; gap: 7px; align-items: center; }
.filters select { width: auto; min-width: 126px; padding: 9px 10px; font-size: 11px; }
.search-box { display: flex; align-items: center; gap: 6px; min-width: 154px; padding: 0 9px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: #fff; }
.search-box:focus-within { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8,125,120,.1); }
.search-box input { min-width: 0; padding: 9px 0; border: 0; box-shadow: none !important; font-size: 11px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 11px; }
.table th { padding: 10px 8px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 9px; letter-spacing: .1em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.table td { padding: 12px 8px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: #f8fcfa; }
.table strong { color: var(--ink); font-size: 12px; }
.muted { color: var(--muted); }
.patient-line { margin-top: 3px; color: var(--muted); font-size: 10px; }
.badge { display: inline-flex; align-items: center; padding: 4px 7px; border-radius: 99px; font-size: 9px; font-weight: 850; white-space: nowrap; }
.badge.received, .badge.viewed { color: #4d6099; background: var(--blue-soft); }
.badge.allocated, .badge.rescheduled { color: #966522; background: var(--gold-soft); }
.badge.confirmed { color: var(--green); background: var(--green-soft); }
.badge.declined, .badge.cancelled { color: var(--red); background: var(--red-soft); }
.badge.new_patient { margin-top: 6px; color: #28636c; background: #e7f2f4; }
.badge.returning_patient { margin-top: 6px; color: #6d4e8f; background: #f2ecfa; }
.row-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.row-actions button { padding: 6px 7px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: #fff; font-size: 10px; font-weight: 800; }
.row-actions button:hover { border-color: #9bc8bd; color: var(--teal-dark); background: var(--mint); }
.row-actions .danger-action:hover { border-color: #e6baba; color: var(--red); background: var(--red-soft); }
.empty-state { padding: 30px 15px; border: 1px dashed var(--line); border-radius: 11px; color: var(--muted); font-size: 12px; line-height: 1.55; text-align: center; }

.trend-card { min-width: 0; }
.chart { height: 178px; display: flex; align-items: stretch; gap: 9px; padding: 15px 5px 22px; border-bottom: 1px solid var(--line); }
.bar-wrap { position: relative; flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 4px; min-width: 22px; }
.bar { width: 13px; min-height: 3px; border-radius: 5px 5px 2px 2px; background: #82bbb1; transition: height .3s ease; }
.bar.confirmed { background: var(--teal); }
.bar-label { position: absolute; bottom: -19px; color: var(--muted); font-size: 9px; }
.bar-value { position: absolute; top: -1px; color: var(--muted-dark); font-size: 8px; }
.analytics-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; color: var(--muted); font-size: 10px; }
.legend-swatch { display: inline-block; width: 8px; height: 8px; margin-right: 4px; border-radius: 2px; background: #82bbb1; }
.legend-swatch.confirmed { background: var(--teal); }
.privacy-chip { margin-left: auto; padding: 5px 7px; border-radius: 5px; color: var(--teal-dark); background: var(--mint); font-size: 9px; font-weight: 800; }

.aggregate-row { display: grid; grid-template-columns: 220px 1fr; gap: 18px; align-items: center; margin-top: 17px; padding: 20px 21px; border: 1px solid #cfe6de; border-radius: var(--radius); background: linear-gradient(105deg, #f0fbf7, #fbfffd); }
.aggregate-intro { display: flex; align-items: flex-start; gap: 11px; }
.aggregate-icon { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 11px; color: var(--teal); background: #dff2ea; font-family: Georgia, serif; font-size: 21px; }
.aggregate-intro h2 { margin: 0; font-size: 18px; letter-spacing: -.04em; }
.aggregate-intro p:last-child { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.aggregate-metrics { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.aggregate-metric { padding-left: 12px; border-left: 1px solid #d8eae4; }
.aggregate-metric strong { display: block; color: var(--ink-deep); font-size: 20px; letter-spacing: -.05em; }
.aggregate-metric span { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; line-height: 1.25; }

.detail-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.booking-code { color: var(--muted); font-family: ui-monospace, monospace; font-size: 9px; }
.detail-name { margin: 14px 0 3px; color: var(--ink-deep); font-size: 20px; font-weight: 900; letter-spacing: -.05em; }
.detail-contact { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.detail-section { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.detail-section strong { color: var(--ink); font-size: 10px; }
.detail-section p { margin: 5px 0 0; color: var(--muted-dark); font-size: 11px; line-height: 1.5; }
.detail-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 14px; }
.detail-fields label { margin: 0; color: var(--muted); font-size: 10px; font-weight: 800; }
.detail-fields input { margin-top: 6px; padding: 9px 10px; font-size: 11px; }
.private-note { margin-top: 10px; }
.private-note textarea { min-height: 70px; margin-top: 6px; font-size: 11px; }
.detail-actions { display: flex; align-items: center; gap: 7px; margin-top: 13px; }
.detail-actions .button { padding: 9px 11px; font-size: 10px; }
.detail-actions select { width: auto; flex: 1; min-width: 0; padding: 9px; font-size: 10px; }
.detail-foot { margin: 14px 0 0; color: var(--muted); font-size: 9px; line-height: 1.45; }
.audit-item { padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.audit-item:first-child { padding-top: 0; }
.audit-item:last-child { border-bottom: 0; }
.audit-top { display: flex; justify-content: space-between; gap: 10px; color: var(--ink); font-size: 11px; font-weight: 850; }
.audit-time { color: var(--muted); font-size: 9px; font-weight: 600; white-space: nowrap; }
.audit-meta { margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.audit-meta strong { color: var(--teal-dark); font-weight: 800; }

.footer { width: min(1190px, 100%); display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin: auto; padding: 19px 22px 24px; border-top: 1px solid var(--line); color: #809290; font-size: 10px; }
.footer a { color: var(--teal); font-weight: 800; text-decoration: none; }

@media (max-width: 980px) {
  .booking-layout { grid-template-columns: 1fr; gap: 37px; max-width: 700px; margin: auto; }
  .booking-intro { padding-left: 0; }
  .booking-intro h1 { max-width: 650px; }
  .top-grid { grid-template-columns: 1fr; }
  .aggregate-row { grid-template-columns: 1fr; }
  .aggregate-metrics { grid-template-columns: repeat(5, 1fr); }
}
@media (max-width: 760px) {
  .topbar { min-height: auto; padding: 14px 16px; flex-wrap: wrap; gap: 11px; }
  .brand { margin-right: auto; }
  .topbar-status { order: 3; width: 100%; border-left: 0; padding: 8px 0 0; border-top: 1px solid rgba(255,255,255,.12); }
  .nav-tabs { order: 2; }
  .nav-tab { padding: 8px 9px; font-size: 11px; }
  .prototype-banner { padding: 9px 16px; }
  main { padding: 35px 16px 46px; }
  h1 { font-size: 47px; }
  .dashboard-head { display: block; }
  .head-actions { justify-content: flex-start; margin-top: 17px; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .toolbar { display: block; }
  .filters { margin-top: 12px; }
  .search-box { flex: 1; }
  .filters select { flex: 1; }
  .bottom-grid { grid-template-columns: 1fr; }
  .aggregate-metrics { grid-template-columns: repeat(3, 1fr); row-gap: 17px; }
}
@media (max-width: 520px) {
  .two-col { grid-template-columns: 1fr; gap: 0; }
  .booking-card { padding: 21px 17px; }
  .card-heading { display: block; }
  .secure-badge { margin-top: 11px; }
  .form-footer { display: block; }
  .form-footer .button { width: 100%; }
  .form-footer p { margin-top: 10px; }
  .metrics-grid { gap: 9px; }
  .metric-card { padding: 14px; }
  .metric-number { font-size: 27px; }
  .table-card, .trend-card, .selected-card, .audit-card { padding: 16px; }
  .filters { flex-wrap: wrap; }
  .search-box, .filters select { width: 100%; flex: 1 1 100%; }
  .aggregate-row { padding: 17px 15px; }
  .aggregate-metrics { grid-template-columns: repeat(2, 1fr); }
  .aggregate-metric:nth-child(odd) { border-left: 0; padding-left: 0; }
  .footer { padding-left: 16px; padding-right: 16px; }
}
