:root {
  --bg: #ffffff;
  --subtle: #f8fafc;
  --subtle-2: #f1f5f9;
  --border: #e8ecf2;
  --border-strong: #d5dce6;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #8a97a8;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;

  --green: #047857;  --green-50: #ecfdf5;
  --amber: #b45309;  --amber-50: #fffbeb;
  --red: #dc2626;    --red-50: #fef2f2;
  --violet: #6d28d9; --violet-50: #f5f3ff;
  --rose: #e11d48;   --rose-50: #fff1f2;
  --teal: #0f766e;   --teal-50: #f0fdfa;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow-lg: 0 24px 48px -12px rgba(15, 23, 42, .25);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body.modal-open { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
.ic { flex-shrink: 0; display: block; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.link { color: var(--primary); font-weight: 500; font-size: 13px; }
.link:hover { text-decoration: underline; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 24px;
  padding: 20px 14px;
  background: #fff;
  border-right: 1px solid var(--border);
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.logo { display: grid; place-items: center; border-radius: 10px; background: var(--primary); color: #fff; flex-shrink: 0; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -.01em; line-height: 1.2; }
.brand-sub { font-size: 12px; color: var(--text-3); }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 10px;
  border: 0; border-radius: 8px; background: none;
  color: var(--text-2); font-weight: 500; text-align: left; cursor: pointer;
}
.nav-item:hover { background: var(--subtle); color: var(--text); }
.nav-item.active { background: var(--primary-50); color: var(--primary); }
.nav-badge { margin-left: auto; background: var(--amber-50); color: var(--amber); font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 2px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 16px 32px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 20px; font-weight: 650; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title p { color: var(--text-3); font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding-left: 14px; border-left: 1px solid var(--border); }
.user-name { font-weight: 600; font-size: 13px; line-height: 1.25; }
.user-role { font-size: 12px; color: var(--text-3); }
.icon-btn.menu-btn { display: none; }
.scrim { display: none; }
.content { width: 100%; max-width: 1280px; padding: 28px 32px 56px; display: flex; flex-direction: column; gap: 20px; }

/* ---------- Primitives ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 14px;
  border-radius: 8px; border: 1px solid transparent;
  font-weight: 550; font-size: 13.5px; white-space: nowrap; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: #fff; border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover { background: var(--subtle); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--subtle-2); color: var(--text); }
.btn-success { background: var(--green-50); color: var(--green); border-color: #a7f3d0; }
.btn-success:hover { background: #d1fae5; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red-50); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn-block { width: 100%; }
.icon-btn {
  display: grid; place-items: center; width: 34px; height: 34px;
  border: 0; border-radius: 8px; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--subtle-2); color: var(--text); }

.avatar {
  --av: var(--primary);
  display: inline-grid; place-items: center; flex-shrink: 0;
  width: 36px; height: 36px; border-radius: 50%;
  background: color-mix(in srgb, var(--av) 12%, white);
  color: var(--av); font-weight: 650; font-size: 13px;
}
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 550; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-pending { background: var(--amber-50); color: var(--amber); }
.badge-confirmed { background: var(--primary-50); color: var(--primary); }
.badge-completed { background: var(--green-50); color: var(--green); }
.badge-cancelled { background: var(--subtle-2); color: var(--text-3); }

.tag { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--subtle-2); color: var(--text-2); }
.tag-red { background: var(--red-50); color: var(--red); }
.tag-violet { background: var(--violet-50); color: var(--violet); }
.tag-blue { background: var(--primary-50); color: var(--primary); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }

.card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card.flush .card-head { padding: 18px 20px 0; }
.card-head h2 { font-size: 15px; font-weight: 650; letter-spacing: -.01em; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-3-1 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; align-items: start; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat { display: flex; gap: 14px; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); min-width: 0; }
.stat-ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0; }
.stat-body { min-width: 0; }
.stat-label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.stat-value { font-size: 20px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tone-blue { background: var(--primary-50); color: var(--primary); }
.tone-teal { background: var(--teal-50); color: var(--teal); }
.tone-violet { background: var(--violet-50); color: var(--violet); }
.tone-rose { background: var(--rose-50); color: var(--rose); }
.tone-amber { background: var(--amber-50); color: var(--amber); }
.tone-green { background: var(--green-50); color: var(--green); }

/* Lists */
.list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid var(--border); min-width: 0; }
.list > .row:first-child { border-top: 0; padding-top: 0; }
.list.boxed > .row { padding: 14px 20px; }
.list.boxed > .row:first-child { padding-top: 14px; }
.row-click { cursor: pointer; border-radius: 0; }
.row-click:hover .row-title { color: var(--primary); }
.row-click:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.row .chev { color: var(--text-3); }
.date-tile { width: 46px; flex-shrink: 0; text-align: center; border: 1px solid var(--border); border-radius: 10px; padding: 4px 0; background: var(--subtle); }
.date-tile span { display: block; font-size: 10.5px; font-weight: 600; text-transform: uppercase; color: var(--primary); letter-spacing: .04em; }
.date-tile strong { display: block; font-size: 17px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.time-col { width: 72px; flex-shrink: 0; font-weight: 600; font-variant-numeric: tabular-nums; font-size: 13px; }
.type-ic { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0; }
.type-visit { background: var(--primary-50); color: var(--primary); }
.type-lab { background: var(--violet-50); color: var(--violet); }
.type-imaging { background: var(--teal-50); color: var(--teal); }

.empty { text-align: center; padding: 28px 12px; color: var(--text-3); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty strong { color: var(--text-2); font-weight: 600; }
.empty .btn { margin-top: 8px; }

/* Tabs, chips, toolbar */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; justify-content: space-between; }
.tabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--subtle-2); border-radius: 10px; flex-wrap: wrap; }
.tab { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-weight: 550; font-size: 13px; color: var(--text-2); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.tab:hover { color: var(--text); }
.tab.active { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(15, 23, 42, .08); }
.tab-count { font-size: 11px; background: var(--border); color: var(--text-2); padding: 0 6px; border-radius: 999px; font-weight: 600; }
.tab.active .tab-count { background: var(--primary-50); color: var(--primary); }
.search { position: relative; min-width: 240px; flex: 0 1 320px; }
.search .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search input { width: 100%; height: 38px; padding: 0 12px 0 36px; border: 1px solid var(--border-strong); border-radius: 8px; background: #fff; outline: none; }
.search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }

/* Table */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; min-width: 760px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; padding: 12px 16px; background: var(--subtle); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fbfcfe; }
.cell-strong { font-weight: 600; display: block; }
.cell-sub { font-size: 12.5px; color: var(--text-3); display: block; }
.cell-person { display: flex; align-items: center; gap: 10px; }
a.cell-person:hover .cell-strong { color: var(--primary); }
.cell-actions { display: flex; gap: 6px; justify-content: flex-end; }
.clamp { max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Vitals / key-value */
.vitals { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.vital { padding: 12px; border-radius: 10px; background: var(--subtle); border: 1px solid var(--border); }
.vital-label { font-size: 12px; color: var(--text-2); }
.vital-value { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.vital-value small { font-size: 12px; font-weight: 500; color: var(--text-3); margin-left: 2px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; margin: 0; }
.kv dt { color: var(--text-3); font-size: 13px; }
.kv dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.section-label { font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; margin: 16px 0 8px; }
.section-label:first-child { margin-top: 0; }

/* Patient header (doctor view) */
.patient-head { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.patient-head-main { flex: 1; min-width: 220px; }
.patient-head h2 { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.patient-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--text-2); font-size: 13px; margin-top: 4px; }
.patient-head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.alert-strip { display: flex; align-items: center; gap: 8px; margin-top: 14px; padding: 10px 12px; border-radius: 10px; background: var(--red-50); color: var(--red); font-size: 13px; font-weight: 500; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-weight: 500; font-size: 13px; }
.back:hover { color: var(--primary); }

/* Medication cards */
.med-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.med { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; gap: 12px; background: #fff; box-shadow: var(--shadow); }
.med-name { font-weight: 650; }
.med-dose { font-size: 13px; color: var(--text-2); }
.med-meta { font-size: 12px; color: var(--text-3); margin-top: 6px; }

.doctor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.doctor-card { display: flex; flex-direction: column; gap: 12px; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.doctor-card .who { display: flex; gap: 12px; align-items: center; }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 550; color: var(--text-2); }
.field input, .field select, .field textarea, .dyn-row input, .dyn-row select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: 8px; background: #fff; outline: none;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .dyn-row input:focus, .dyn-row select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.fieldset-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fieldset-head strong { font-size: 13px; }
.dyn-row { display: grid; grid-template-columns: 2fr 1fr 1.4fr .8fr auto; gap: 8px; align-items: center; }
.dyn-row.lab-row { grid-template-columns: 2fr 1fr 1.2fr 1fr auto; }
.hint { font-size: 12px; color: var(--text-3); }

.doc-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 8px; }
.doc-opt { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--border-strong); border-radius: 10px; cursor: pointer; }
.doc-opt input { position: absolute; opacity: 0; pointer-events: none; }
.doc-opt strong { display: block; font-size: 13px; }
.doc-opt small { color: var(--text-3); font-size: 12px; }
.doc-opt:has(input:checked) { border-color: var(--primary); background: var(--primary-50); box-shadow: 0 0 0 1px var(--primary); }
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.slot { position: relative; }
.slot input { position: absolute; opacity: 0; pointer-events: none; }
.slot span { display: block; text-align: center; padding: 8px 4px; border: 1px solid var(--border-strong); border-radius: 8px; font-size: 13px; font-weight: 550; cursor: pointer; font-variant-numeric: tabular-nums; }
.slot span:hover { border-color: var(--primary); color: var(--primary); }
.slot input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.slot input:disabled + span { background: var(--subtle); color: var(--text-3); text-decoration: line-through; cursor: not-allowed; border-color: var(--border); }
.slot input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.slot-note { grid-column: 1 / -1; padding: 12px; border-radius: 8px; background: var(--subtle); color: var(--text-2); font-size: 13px; }

/* Record detail */
.rec-head { display: flex; gap: 14px; align-items: flex-start; }
.rec-head h3 { font-size: 17px; font-weight: 650; }
.dx { padding: 12px 14px; border-radius: 10px; background: var(--primary-50); color: #1e3a8a; font-weight: 550; }
.notes { white-space: pre-wrap; color: var(--text-2); }
.mini-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mini-table th { text-align: left; font-weight: 600; color: var(--text-3); font-size: 12px; padding: 8px 10px; background: var(--subtle); border-bottom: 1px solid var(--border); }
.mini-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); }
.mini-table tr:last-child td { border-bottom: 0; }
.mini-wrap { border: 1px solid var(--border); border-radius: 10px; overflow: auto; }
.flag-high { color: var(--red); font-weight: 600; }
.flag-low { color: var(--amber); font-weight: 600; }
.flag-normal { color: var(--green); font-weight: 600; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(15, 23, 42, .35); display: grid; place-items: center; padding: 16px; animation: fade .15s ease-out; }
.modal { width: 100%; max-width: 560px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); animation: pop .18s ease-out; }
.modal.wide { max-width: 760px; }
.modal.narrow { max-width: 420px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 16px; font-weight: 650; }
.modal-body { padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--subtle); border-radius: 0 0 16px 16px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* Toast */
#toast-root { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; align-items: center; gap: 8px; padding: 11px 14px; border-radius: 10px; background: var(--text); color: #fff; font-weight: 500; font-size: 13px; box-shadow: var(--shadow-lg); animation: pop .2s ease-out; transition: opacity .3s, transform .3s; }
.toast-success .ic { color: #6ee7b7; }
.toast-error .ic { color: #fca5a5; }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; background: radial-gradient(1200px 500px at 50% -10%, var(--primary-50), #fff 70%); }
.login-card { width: 100%; max-width: 860px; }
.login-head { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; margin-bottom: 32px; }
.login-head h1 { font-size: 28px; font-weight: 700; letter-spacing: -.03em; }
.login-head p { color: var(--text-2); margin-top: 4px; }
.role-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.role-card { background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 24px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 1px 3px rgba(15, 23, 42, .05), 0 8px 24px -12px rgba(15, 23, 42, .1); }
.role-card h2 { font-size: 17px; font-weight: 650; }
.role-card p { color: var(--text-2); font-size: 13.5px; margin-top: -8px; }
.role-ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; }
.role-card ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); flex: 1; }
.role-card li { display: flex; gap: 8px; align-items: center; }
.role-card li .ic { color: var(--green); }
.login-note { text-align: center; color: var(--text-3); font-size: 12.5px; margin-top: 20px; }


/* ---------- Calendar ---------- */
.cal-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cal-title { font-size: 16px; font-weight: 650; letter-spacing: -.01em; margin-left: 6px; }
.cal-chip {
  display: block; width: 100%; min-width: 0; text-align: left; cursor: pointer;
  border: 0; border-left: 3px solid; border-radius: 5px; padding: 2px 6px;
  font-size: 12px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-chip:hover { filter: brightness(.96); }
.cal-chip.lg { padding: 4px 7px; white-space: normal; }
.cal-chip.lg strong { display: block; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-chip.lg small { display: block; font-size: 11.5px; font-weight: 500; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-pending { background: var(--amber-50); color: var(--amber); border-color: #f59e0b; }
.st-confirmed { background: var(--primary-50); color: #1e40af; border-color: var(--primary); }
.st-completed { background: var(--green-50); color: var(--green); border-color: #10b981; }

.cal-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-dow { padding: 10px; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; background: var(--subtle); border-bottom: 1px solid var(--border); }
.cal-cell { min-height: 118px; min-width: 0; padding: 6px; display: flex; flex-direction: column; gap: 3px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); cursor: pointer; }
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell:hover { background: #fbfcfe; }
.cal-cell.other { background: var(--subtle); }
.cal-cell.other .cal-daynum { color: var(--text-3); }
.cal-daynum { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cal-cell.today .cal-daynum { background: var(--primary); color: #fff; }
.cal-more { font-size: 12px; font-weight: 500; color: var(--text-2); padding: 0 6px; }

.cal-week-wrap { overflow-x: auto; }
.cal-week { display: grid; grid-template-columns: 72px repeat(7, minmax(118px, 1fr)); min-width: 900px; }
.cal-wh { padding: 10px 6px; text-align: center; background: var(--subtle); border-bottom: 1px solid var(--border); border-left: 1px solid var(--border); cursor: pointer; position: sticky; top: 0; }
.cal-wh:hover .dnum { color: var(--primary); }
.cal-wh.corner { border-left: 0; cursor: default; }
.cal-wh .dow { font-size: 11.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.cal-wh .dnum { font-size: 19px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.cal-wh .dcount { font-size: 11px; color: var(--text-3); }
.cal-wh.today .dow, .cal-wh.today .dnum { color: var(--primary); }
.cal-time { padding: 4px 10px 0 0; text-align: right; font-size: 11.5px; color: var(--text-3); border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cal-slot { min-height: 52px; min-width: 0; padding: 3px; display: flex; flex-direction: column; gap: 3px; border-left: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.cal-slot.today-col { background: #fafcff; }
.cal-slot.lunch { background: repeating-linear-gradient(45deg, #f8fafc, #f8fafc 6px, #f1f5f9 6px, #f1f5f9 12px); }
.cal-slot.open { cursor: pointer; }
.cal-slot.open:hover { background: var(--primary-50); }
.cal-slot.open:hover::after { content: '+ Book'; margin: auto; font-size: 12px; font-weight: 600; color: var(--primary); }

.day-row { display: grid; grid-template-columns: 92px minmax(0, 1fr); border-bottom: 1px solid var(--border); }
.day-row:last-child { border-bottom: 0; }
.day-time { padding: 14px 16px; font-size: 13px; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.day-body { padding: 8px 16px; display: flex; flex-direction: column; gap: 8px; min-width: 0; border-left: 1px solid var(--border); justify-content: center; }
.day-appt { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-left: 3px solid; border-radius: 10px; flex-wrap: wrap; }
.day-appt .row-title a:hover { text-decoration: underline; }
.day-empty { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 30px; font-size: 13px; color: var(--text-3); }

.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 12.5px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; border-left: 3px solid; margin-right: 6px; vertical-align: -1px; }

@media (max-width: 560px) {
  .cal-cell { min-height: 64px; padding: 4px 3px; }
  .cal-dow { padding: 8px 4px; font-size: 10.5px; text-align: center; }
  .cal-chip:not(.lg) { font-size: 0; height: 6px; padding: 0; border-left: 0; border-radius: 3px; }
  .cal-chip.st-pending:not(.lg) { background: #f59e0b; }
  .cal-chip.st-confirmed:not(.lg) { background: var(--primary); }
  .cal-chip.st-completed:not(.lg) { background: #10b981; }
  .cal-more { font-size: 10px; padding: 0; }
  .day-row { grid-template-columns: 70px minmax(0, 1fr); }
  .day-time { padding: 12px 8px; font-size: 12px; }
  .day-body { padding: 8px 10px; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3-1 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 264px; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .nav-open .sidebar { transform: none; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .3); z-index: 30; }
  .icon-btn.menu-btn { display: grid; }
  .topbar { padding: 12px 16px; }
  .topbar-title h1 { font-size: 17px; }
  .topbar-title p { display: none; }
  .user-meta { display: none; }
  .user-chip { padding-left: 10px; }
  .topbar-right .btn span { display: none; }
  .topbar-right .btn { width: 38px; padding: 0; }
  .content { padding: 16px 16px 40px; gap: 16px; }
  .grid-2 { grid-template-columns: 1fr; gap: 16px; }
  .role-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr; gap: 10px; }
  .row { flex-wrap: wrap; }
  .row-actions { width: 100%; padding-left: 60px; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .dyn-row, .dyn-row.lab-row { grid-template-columns: 1fr 1fr; }
  .dyn-row > :first-child { grid-column: 1 / -1; }
  .search { min-width: 0; flex: 1 1 100%; }
  .card { padding: 16px; }
  .modal-backdrop { padding: 0; align-items: end; }
  .modal { max-height: 92vh; border-radius: 16px 16px 0 0; }
  .modal-foot { border-radius: 0; }
}
