:root {
  --ink: #17201e;
  --ink-2: #34423f;
  --muted: #71807c;
  --canvas: #f5f3ed;
  --surface: #ffffff;
  --surface-2: #f9f8f4;
  --line: #e6e4dc;
  --line-dark: #d8d5ca;
  --pine: #082f5b;
  --pine-2: #114773;
  --mint: #d8eee7;
  --mint-ink: #1e6658;
  --coral: #b88624;
  --coral-dark: #916714;
  --coral-soft: #f6ecd6;
  --amber: #e3a843;
  --amber-soft: #f8eccf;
  --blue: #517b9d;
  --blue-soft: #e3edf4;
  --lavender: #806d9c;
  --lavender-soft: #eee9f5;
  --danger: #b84e49;
  --danger-soft: #fae8e6;
  --shadow-sm: 0 1px 2px rgba(23, 32, 30, .05), 0 6px 18px rgba(23, 32, 30, .03);
  --shadow-lg: 0 20px 70px rgba(23, 32, 30, .18);
  --radius-sm: 8px;
  --radius: 13px;
  --radius-lg: 20px;
  --sidebar-w: 242px;
  --topbar-h: 68px;
  --font: "DM Sans", "Avenir Next", Arial, sans-serif;
  --display: "Manrope", "Avenir Next", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--canvas); font-family: var(--font); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { color: inherit; font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 3px solid rgba(237, 106, 90, .28); outline-offset: 2px; }
a { color: inherit; text-decoration: none; }
svg { display: block; width: 1em; height: 1em; stroke-width: 1.8; }
[hidden] { display: none !important; }
.skip-link { position: fixed; left: 16px; top: -60px; z-index: 9999; padding: 10px 14px; background: var(--ink); color: white; border-radius: 8px; transition: top .2s; }
.skip-link:focus { top: 12px; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 10px; color: var(--coral-dark); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.eyebrow.light { color: #a9d7cc; }
.tiny { font-size: 11px; }
.nowrap { white-space: nowrap; }
.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; }

/* Login */
.login-view { min-height: 100vh; display: grid; grid-template-columns: minmax(480px, .95fr) 1.05fr; background: var(--surface); }
.login-brand-panel { min-height: 100vh; padding: 42px clamp(42px, 6vw, 92px); color: white; background: var(--pine); position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; }
.login-brand-panel::before { content: ""; position: absolute; width: 720px; height: 720px; left: -360px; bottom: -480px; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; box-shadow: 0 0 0 120px rgba(255,255,255,.025), 0 0 0 240px rgba(255,255,255,.02); }
.login-brand-panel::after { content: "+"; position: absolute; right: -10px; top: 48%; color: rgba(255,255,255,.035); font: 800 360px/1 var(--display); }
.brand { display: flex; align-items: center; gap: 10px; height: 28px; font: 800 17px/1 var(--display); letter-spacing: -.04em; }
.brand em { margin-left: auto; padding: 4px 6px; border: 1px solid var(--line-dark); border-radius: 5px; color: var(--muted); font: 700 8px/1 var(--font); letter-spacing: .1em; }
.brand-light em { color: #b7d6cf; border-color: rgba(255,255,255,.2); }
.brand-mark { display: inline-flex; align-items: flex-end; justify-content: center; gap: 2px; width: 25px; height: 25px; padding: 5px; border-radius: 7px; color: white; background: var(--coral); }
.brand-mark i { width: 3px; border-radius: 2px; background: currentColor; }
.brand-mark i:nth-child(1) { height: 8px; }
.brand-mark i:nth-child(2) { height: 14px; }
.brand-mark i:nth-child(3) { height: 10px; }
.keystone-brand { min-width: 0; display: flex; align-items: center; gap: 10px; color: #082f5b; }
.keystone-brand-copy { min-width: 0; display: grid; gap: 2px; }
.keystone-brand-copy strong { overflow: hidden; font: 800 14px/1.05 var(--display); letter-spacing: -.035em; text-overflow: ellipsis; white-space: nowrap; }
.keystone-brand-copy small { color: #75827f; font-size: 7px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.keystone-brand em { margin-left: auto; padding: 4px 6px; border: 1px solid var(--line-dark); border-radius: 5px; color: var(--muted); font: 700 8px/1 var(--font); letter-spacing: .1em; }
.keystone-brand.light { color: white; }
.keystone-brand.light .keystone-brand-copy small { color: #c6d4dd; }
.keystone-brand.light em { color: #d6c291; border-color: rgba(255,255,255,.2); }
.keystone-symbol { width: 32px; height: 32px; flex: 0 0 32px; position: relative; overflow: hidden; border: 1px solid rgba(8,47,91,.09); border-radius: 9px; background: white; box-shadow: 0 1px 3px rgba(8,47,91,.08); }
.keystone-symbol img { width: 55px; height: 55px; max-width: none; position: absolute; left: -11.5px; top: -4px; }
.keystone-symbol.lg { width: 40px; height: 40px; flex-basis: 40px; border-radius: 11px; }
.keystone-symbol.lg img { width: 70px; height: 70px; left: -15px; top: -5px; }
.keystone-symbol.sm { width: 34px; height: 34px; flex-basis: 34px; border-radius: 8px; }
.keystone-symbol.sm img { width: 59px; height: 59px; left: -12.5px; top: -4px; }
.login-story { position: relative; z-index: 1; max-width: 590px; margin-top: 80px; }
.login-story h1 { margin: 0 0 24px; font: 700 clamp(44px, 5vw, 72px)/1.04 var(--display); letter-spacing: -.055em; }
.login-story > p:last-child { max-width: 500px; color: #c8d8d4; font-size: clamp(16px, 1.4vw, 20px); line-height: 1.55; }
.login-pulse-card { position: relative; z-index: 1; width: min(520px, 100%); padding: 20px; border: 1px solid rgba(255,255,255,.11); border-radius: var(--radius-lg); background: rgba(255,255,255,.075); box-shadow: inset 0 1px 0 rgba(255,255,255,.08); backdrop-filter: blur(12px); }
.pulse-row { display: flex; align-items: center; gap: 8px; color: #d7e6e2; font-size: 12px; }
.pulse-row strong { margin-left: auto; color: #8fbcb2; font-size: 11px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #62d4a8; box-shadow: 0 0 0 4px rgba(98,212,168,.13); }
.pulse-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 20px 0; }
.pulse-grid div { padding-right: 8px; border-right: 1px solid rgba(255,255,255,.1); }
.pulse-grid div:last-child { border: 0; }
.pulse-grid b { display: block; font: 700 21px/1.2 var(--display); }
.pulse-grid span { color: #9fb9b3; font-size: 11px; }
.patient-flow { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 12px; color: var(--ink); background: white; }
.patient-flow div { flex: 1; min-width: 0; }
.patient-flow strong, .patient-flow small { display: block; }
.patient-flow small { color: var(--muted); }
.fiction-note { position: relative; z-index: 1; margin-top: 18px; color: #81a299; }
.portal-lockup, .settings-lockup { margin-bottom: 22px; }
.portal-lockup .keystone-brand-copy strong, .settings-lockup .keystone-brand-copy strong { font-size: 16px; }
.subscription-lockup { margin-bottom: 20px; }
.queue-lockup { margin-bottom: 22px; }
.queue-contact { margin-top: 18px; border-color: rgba(255,255,255,.2); }
.login-form-panel { display: grid; place-items: center; padding: 40px; background: #fbfaf7; }
.login-form-wrap { width: min(430px, 100%); }
.login-form-wrap h2 { margin: 0 0 8px; font: 700 35px/1.15 var(--display); letter-spacing: -.04em; }
.login-form-wrap > .muted { margin: 0 0 32px; }
.login-form-wrap form { display: grid; gap: 18px; }
label { display: grid; gap: 7px; color: var(--ink-2); font-size: 12px; font-weight: 600; }
input, select, textarea { width: 100%; border: 1px solid var(--line-dark); border-radius: 10px; background: white; transition: border .18s, box-shadow .18s; }
input, select { height: 42px; padding: 0 12px; }
textarea { min-height: 88px; padding: 11px 12px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: #bcb8aa; }
input:focus, select:focus, textarea:focus { border-color: var(--pine-2); box-shadow: 0 0 0 3px rgba(36,88,79,.09); outline: none; }
.input-affix { display: flex; align-items: center; position: relative; }
.input-affix input { padding-right: 46px; }
.input-affix button { position: absolute; right: 4px; }
.form-meta { display: flex; align-items: center; justify-content: space-between; }
.check { display: flex; grid-template-columns: 15px auto; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: 15px; height: 15px; accent-color: var(--pine); }
.text-button { padding: 0; border: 0; color: var(--pine-2); background: none; font-weight: 700; }
.button { min-height: 39px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 14px; border: 1px solid var(--line-dark); border-radius: 9px; color: var(--ink-2); background: white; font-size: 13px; font-weight: 700; transition: transform .15s, background .15s, border .15s, box-shadow .15s; }
.button:hover { border-color: #c6c2b7; background: var(--surface-2); box-shadow: var(--shadow-sm); }
.button:active { transform: translateY(1px); }
.button.primary { color: white; border-color: var(--pine); background: var(--pine); }
.button.primary:hover { background: var(--pine-2); }
.button.coral { color: white; border-color: var(--coral); background: var(--coral); }
.button.coral:hover { background: var(--coral-dark); }
.button.soft { color: var(--pine); border-color: transparent; background: var(--mint); }
.button.danger { color: var(--danger); border-color: transparent; background: var(--danger-soft); }
.button.sm { min-height: 31px; padding: 0 10px; border-radius: 7px; font-size: 11px; }
.button[disabled] { cursor: not-allowed; opacity: .5; box-shadow: none; }
.login-button { height: 48px; justify-content: space-between; padding: 0 18px; margin-top: 2px; }
.demo-roles { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-top: 24px; color: var(--muted); font-size: 11px; }
.demo-roles button { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: white; font-size: 11px; }
.secure-note { display: flex; align-items: center; gap: 6px; margin-top: 34px; color: #8a9693; font-size: 11px; }
.secure-note svg { color: var(--pine-2); }
.appointment-contact { width: max-content; display: inline-flex; align-items: center; gap: 9px; margin-top: 24px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--pine); background: white; box-shadow: var(--shadow-sm); }
.appointment-contact > svg { color: var(--coral); font-size: 17px; }
.appointment-contact small, .appointment-contact strong { display: block; }
.appointment-contact small { color: var(--muted); font-size: 7px; font-weight: 800; letter-spacing: .1em; }
.appointment-contact strong { margin-top: 1px; font: 800 12px/1.1 var(--display); letter-spacing: .01em; }
.mobile-brand { display: none; }

/* Shell */
.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; width: var(--sidebar-w); display: flex; flex-direction: column; border-right: 1px solid var(--line); background: #faf9f6; }
.sidebar-top { height: var(--topbar-h); display: flex; align-items: center; padding: 0 18px; border-bottom: 1px solid var(--line); }
.sidebar-top .brand, .sidebar-top .keystone-brand { flex: 1; }
.sidebar-brand .keystone-brand-copy strong { font-size: 13px; }
.sidebar-brand .keystone-brand-copy small { font-size: 6px; }
.sidebar-close { display: none; }
.branch-switcher { display: grid; grid-template-columns: 34px 1fr 16px; align-items: center; gap: 9px; margin: 14px 12px 8px; padding: 10px; border: 1px solid var(--line); border-radius: 11px; background: white; cursor: pointer; }
.branch-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; color: var(--pine); background: var(--mint); font: 800 10px/1 var(--display); }
.branch-switcher small, .branch-switcher strong { display: block; }
.branch-switcher small { color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: .1em; }
.branch-switcher strong { max-width: 148px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.branch-switcher svg { color: var(--muted); font-size: 12px; }
.nav-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 11px 15px; scrollbar-width: thin; scrollbar-color: var(--line-dark) transparent; }
.nav-group { margin-top: 15px; }
.nav-group-label { margin: 0 10px 6px; color: #9aa39f; font-size: 9px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.nav-item { width: 100%; min-height: 36px; display: flex; align-items: center; gap: 10px; margin: 2px 0; padding: 0 10px; border: 0; border-radius: 8px; color: #56635f; background: transparent; font-size: 12px; text-align: left; }
.nav-item:hover { color: var(--ink); background: #f0eee7; }
.nav-item.active { color: var(--pine); background: var(--mint); font-weight: 700; }
.nav-item svg { font-size: 16px; }
.nav-item span:nth-child(2) { flex: 1; }
.nav-badge { min-width: 20px; height: 18px; display: grid; place-items: center; padding: 0 5px; border-radius: 9px; color: #68736f; background: #ebe9e2; font-size: 9px; font-style: normal; font-weight: 800; }
.nav-item.active .nav-badge { color: var(--pine); background: white; }
.sidebar-foot { padding: 10px; border-top: 1px solid var(--line); }
.role-card { width: 100%; display: grid; grid-template-columns: 34px 1fr 16px; align-items: center; gap: 9px; padding: 8px; border: 0; border-radius: 10px; background: transparent; text-align: left; }
.role-card:hover { background: #f0eee7; }
.role-card strong, .role-card small { display: block; }
.role-card strong { font-size: 11px; }
.role-card small { color: var(--muted); font-size: 9px; }
.role-card svg { color: var(--muted); }
.avatar { width: 36px; height: 36px; flex: 0 0 auto; display: inline-grid; place-items: center; border-radius: 50%; color: #32584f; background: #dcece7; font: 800 10px/1 var(--display); }
.avatar.owner { color: #5e4d39; background: #eee3d5; }
.avatar.coral { color: #943f36; background: var(--coral-soft); }
.avatar.blue { color: #355d7b; background: var(--blue-soft); }
.avatar.lavender { color: #5f4e7a; background: var(--lavender-soft); }
.avatar.amber { color: #7a5a24; background: var(--amber-soft); }
.avatar.sm { width: 29px; height: 29px; font-size: 8px; }
.avatar.lg { width: 54px; height: 54px; font-size: 14px; }
.app-main { min-height: 100vh; margin-left: var(--sidebar-w); }
.topbar { height: var(--topbar-h); position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 clamp(18px, 2.5vw, 38px); border-bottom: 1px solid var(--line); background: rgba(250,249,246,.91); backdrop-filter: blur(18px); }
.topbar-left, .topbar-actions { display: flex; align-items: center; gap: 10px; min-width: 0; }
.menu-button { display: none; }
.breadcrumbs { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 11px; }
.breadcrumbs span { color: var(--muted); }
.breadcrumbs span::after { content: "/"; margin-left: 8px; color: #b5bbb8; }
.breadcrumbs b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-button { width: 36px; height: 36px; display: inline-grid; place-items: center; padding: 0; border: 1px solid transparent; border-radius: 9px; background: transparent; }
.icon-button:hover { border-color: var(--line); background: white; }
.command-search { width: clamp(220px, 28vw, 370px); height: 38px; display: flex; align-items: center; gap: 9px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: white; font-size: 11px; text-align: left; }
.command-search span:nth-child(2) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
kbd { padding: 2px 6px; border: 1px solid var(--line); border-bottom-color: var(--line-dark); border-radius: 5px; color: #909a96; background: var(--surface-2); font: 700 9px/1.4 var(--font); }
.notification-button { position: relative; border-color: var(--line); background: white; }
.notification-button i { position: absolute; right: -3px; top: -3px; min-width: 16px; height: 16px; display: grid; place-items: center; border: 2px solid var(--surface-2); border-radius: 8px; color: white; background: var(--coral); font: 700 8px/1 var(--font); }
.topbar-contact { height: 38px; display: inline-flex; align-items: center; gap: 7px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; color: var(--pine); background: white; }
.topbar-contact > svg { color: var(--coral); font-size: 15px; }
.topbar-contact small, .topbar-contact strong { display: block; white-space: nowrap; }
.topbar-contact small { color: var(--muted); font-size: 7px; font-weight: 700; text-transform: uppercase; }
.topbar-contact strong { font: 800 10px/1.1 var(--display); }
.quick-action-trigger { color: white; border-color: var(--coral); background: var(--coral); }
.quick-action-trigger:hover { color: white; background: var(--coral-dark); }
.quick-action-trigger kbd { border-color: rgba(255,255,255,.15); color: rgba(255,255,255,.8); background: rgba(255,255,255,.13); }
#main-content { min-height: calc(100vh - var(--topbar-h)); padding: 28px clamp(18px, 2.5vw, 38px) 70px; }
.mobile-nav, .mobile-fab { display: none; }

/* Shared page UI */
.page { max-width: 1560px; margin: 0 auto; animation: pageIn .28s ease both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(4px); } }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 22px; margin-bottom: 24px; }
.page-head h1 { margin: 0 0 5px; font: 700 clamp(25px, 2.2vw, 34px)/1.15 var(--display); letter-spacing: -.045em; }
.page-head p { margin: 0; color: var(--muted); }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.date-chip { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 11px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink-2); background: white; font-size: 11px; font-weight: 600; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 0 0 13px; }
.section-title h2, .section-title h3 { margin: 0; font: 700 16px/1.25 var(--display); letter-spacing: -.025em; }
.section-title p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.section-title .link-button { margin-left: auto; }
.link-button { display: inline-flex; align-items: center; gap: 5px; padding: 0; border: 0; color: var(--pine-2); background: transparent; font-size: 11px; font-weight: 800; }
.link-button:hover { color: var(--coral-dark); }
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.card-pad { padding: 18px; }
.card.flat { box-shadow: none; }
.divider { height: 1px; margin: 16px 0; background: var(--line); }
.status { display: inline-flex; align-items: center; gap: 5px; min-height: 22px; padding: 0 8px; border-radius: 11px; color: #59645f; background: #eeede8; font-size: 9px; font-weight: 800; letter-spacing: .02em; white-space: nowrap; }
.status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .65; }
.status.mint, .status.paid, .status.completed, .status.active { color: var(--mint-ink); background: var(--mint); }
.status.coral, .status.overdue, .status.critical { color: var(--danger); background: var(--danger-soft); }
.status.amber, .status.pending, .status.waiting { color: #8d651e; background: var(--amber-soft); }
.status.blue, .status.upcoming, .status.confirmed { color: #416b89; background: var(--blue-soft); }
.status.lavender, .status.consulting { color: #66527f; background: var(--lavender-soft); }
.tag { display: inline-flex; align-items: center; min-height: 23px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: var(--surface-2); font-size: 9px; font-weight: 700; }
.dot { width: 7px; height: 7px; display: inline-block; border-radius: 50%; background: var(--muted); }
.dot.mint { background: #43a98b; }
.dot.coral { background: var(--coral); }
.dot.amber { background: var(--amber); }
.dot.blue { background: var(--blue); }
.dot.lavender { background: var(--lavender); }
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 22px; }
.kpi { min-height: 126px; padding: 16px; position: relative; overflow: hidden; }
.kpi .kpi-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; font-weight: 600; }
.kpi .kpi-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; background: var(--surface-2); font-size: 15px; }
.kpi strong { display: block; margin: 14px 0 4px; font: 700 25px/1 var(--display); letter-spacing: -.04em; }
.kpi small { color: var(--muted); font-size: 10px; }
.trend { color: var(--mint-ink); font-weight: 800; }
.trend.down { color: var(--danger); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, .85fr); gap: 18px; }
.dashboard-main, .dashboard-side { display: grid; align-content: start; gap: 18px; }
.schedule-card { padding: 18px 18px 8px; }
.schedule-row { display: grid; grid-template-columns: 52px 3px minmax(140px, 1.1fr) minmax(120px, .8fr) auto; align-items: center; gap: 12px; min-height: 64px; border-top: 1px solid var(--line); }
.schedule-row:first-of-type { border-top: 0; }
.schedule-time { color: var(--ink-2); font-size: 11px; font-weight: 700; }
.schedule-stripe { width: 3px; height: 36px; border-radius: 2px; background: var(--mint-ink); }
.schedule-stripe.coral { background: var(--coral); }
.schedule-stripe.amber { background: var(--amber); }
.schedule-patient { display: flex; align-items: center; gap: 9px; min-width: 0; }
.schedule-patient strong, .schedule-patient small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.schedule-patient strong { font-size: 12px; }
.schedule-patient small { color: var(--muted); font-size: 9px; }
.doctor-cell strong, .doctor-cell small { display: block; }
.doctor-cell strong { font-size: 10px; }
.doctor-cell small { color: var(--muted); font-size: 9px; }
.clinic-pulse { padding: 18px; color: white; border-color: var(--pine); background: var(--pine); box-shadow: none; }
.clinic-pulse .section-title h2 { color: white; }
.clinic-pulse .section-title p { color: #9ec0b8; }
.pulse-bar { height: 7px; display: flex; overflow: hidden; margin: 20px 0 12px; border-radius: 5px; background: rgba(255,255,255,.1); }
.pulse-bar i { display: block; height: 100%; }
.pulse-legend { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pulse-legend b, .pulse-legend span { display: block; }
.pulse-legend b { font: 700 17px/1.2 var(--display); }
.pulse-legend span { color: #9ebcb5; font-size: 9px; }
.insight-list { display: grid; }
.insight-item { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; min-height: 66px; border-top: 1px solid var(--line); }
.insight-item:first-child { border-top: 0; }
.insight-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; color: var(--pine); background: var(--mint); }
.insight-item strong, .insight-item small { display: block; }
.insight-item strong { font-size: 11px; }
.insight-item small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.task-list { display: grid; gap: 8px; }
.task-item { display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 9px; min-height: 48px; padding: 8px 10px; border-radius: 9px; background: var(--surface-2); }
.task-item .task-check { width: 19px; height: 19px; border: 1px solid var(--line-dark); border-radius: 6px; background: white; }
.task-item strong, .task-item small { display: block; }
.task-item strong { font-size: 10px; }
.task-item small { color: var(--muted); font-size: 9px; }

/* Tables and filters */
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.search-field { min-width: 220px; flex: 1; position: relative; }
.search-field svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-field input { padding-left: 36px; }
.segmented { display: inline-flex; align-items: center; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); }
.segmented button { min-height: 30px; padding: 0 10px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; font-size: 10px; font-weight: 700; }
.segmented button.active { color: var(--ink); background: white; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.table-card { overflow: hidden; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { height: 38px; padding: 0 14px; border-bottom: 1px solid var(--line); color: #8b9490; background: #faf9f6; font-size: 9px; font-weight: 800; letter-spacing: .06em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.data-table td { height: 58px; padding: 8px 14px; border-bottom: 1px solid var(--line); color: var(--ink-2); font-size: 11px; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr { cursor: pointer; transition: background .15s; }
.data-table tbody tr:hover { background: #fbfaf7; }
.table-person { display: flex; align-items: center; gap: 9px; min-width: 150px; }
.table-person strong, .table-person small { display: block; }
.table-person strong { color: var(--ink); font-size: 11px; }
.table-person small { color: var(--muted); font-size: 9px; }
.table-empty { padding: 46px 20px !important; text-align: center; color: var(--muted) !important; }
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 11px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.pagination-buttons { display: flex; gap: 5px; }
.pagination button { min-width: 29px; height: 27px; border: 1px solid var(--line); border-radius: 6px; background: white; font-size: 10px; }
.pagination button.active { color: white; border-color: var(--pine); background: var(--pine); }

/* Patient */
.patient-header { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px; padding: 18px; margin-bottom: 16px; }
.patient-title h1 { margin: 0 0 4px; font: 700 24px/1.2 var(--display); letter-spacing: -.035em; }
.patient-meta, .tag-row { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; color: var(--muted); font-size: 10px; }
.patient-header-actions { display: flex; gap: 7px; }
.patient-stats { display: grid; grid-template-columns: repeat(5, 1fr); margin-top: 15px; border-top: 1px solid var(--line); }
.patient-stat { padding: 13px 15px 0 0; }
.patient-stat span, .patient-stat strong { display: block; }
.patient-stat span { color: var(--muted); font-size: 9px; }
.patient-stat strong { margin-top: 3px; font-size: 11px; }
.patient-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(270px, .65fr); gap: 16px; }
.tab-bar { display: flex; align-items: center; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tab-bar button { min-height: 42px; padding: 0 13px; border: 0; border-bottom: 2px solid transparent; color: var(--muted); background: transparent; font-size: 10px; font-weight: 700; white-space: nowrap; }
.tab-bar button.active { color: var(--pine); border-bottom-color: var(--coral); }
.timeline { position: relative; padding: 18px; }
.timeline::before { content: ""; position: absolute; left: 32px; top: 28px; bottom: 28px; width: 1px; background: var(--line-dark); }
.timeline-group-label { position: relative; z-index: 1; display: inline-block; margin: 4px 0 8px 32px; padding: 3px 7px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); background: white; font-size: 8px; font-weight: 800; text-transform: uppercase; }
.timeline-event { position: relative; display: grid; grid-template-columns: 30px 1fr; gap: 10px; margin-bottom: 8px; }
.timeline-icon { position: relative; z-index: 2; width: 30px; height: 30px; display: grid; place-items: center; border: 4px solid white; border-radius: 50%; color: var(--pine); background: var(--mint); font-size: 11px; }
.timeline-content { padding: 11px 13px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); }
.timeline-content header { display: flex; justify-content: space-between; gap: 10px; }
.timeline-content h4 { margin: 0; font-size: 11px; }
.timeline-content time { color: var(--muted); font-size: 9px; }
.timeline-content p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.patient-side { display: grid; align-content: start; gap: 12px; }
.info-list { display: grid; gap: 11px; }
.info-row { display: grid; grid-template-columns: 92px 1fr; gap: 10px; font-size: 10px; }
.info-row span { color: var(--muted); }
.info-row strong { font-weight: 600; }
.alert-box { display: flex; align-items: flex-start; gap: 9px; padding: 11px; border: 1px solid #efcfc8; border-radius: 9px; color: #87463e; background: #fff5f3; font-size: 10px; }

/* Calendar / queue */
.calendar-layout { display: grid; grid-template-columns: 230px minmax(700px, 1fr); gap: 14px; }
.calendar-side { padding: 15px; }
.mini-calendar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.mini-calendar-head strong { font-size: 11px; }
.mini-calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; text-align: center; font-size: 9px; }
.mini-calendar span { height: 24px; display: grid; place-items: center; border-radius: 6px; }
.mini-calendar .day-name { color: var(--muted); font-size: 8px; font-weight: 700; }
.mini-calendar .today { color: white; background: var(--pine); font-weight: 800; }
.doctor-filter { display: grid; gap: 8px; margin-top: 20px; }
.doctor-filter label { display: flex; grid-template-columns: 12px 1fr auto; align-items: center; gap: 8px; font-size: 10px; }
.doctor-filter input { width: 12px; height: 12px; }
.calendar-board { min-width: 0; overflow-x: auto; }
.calendar-header, .calendar-body { min-width: 750px; display: grid; grid-template-columns: 55px repeat(5, 1fr); }
.calendar-header { height: 54px; border-bottom: 1px solid var(--line); }
.calendar-header > div { display: grid; place-items: center; border-left: 1px solid var(--line); font-size: 10px; }
.calendar-header > div:first-child { border-left: 0; }
.calendar-header strong, .calendar-header span { display: block; text-align: center; }
.calendar-header span { color: var(--muted); font-size: 8px; }
.calendar-body { position: relative; grid-template-rows: repeat(8, 68px); }
.cal-time { display: grid; place-items: start center; padding-top: 5px; border-top: 1px solid var(--line); color: var(--muted); font-size: 8px; }
.cal-cell { border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal-event { z-index: 2; align-self: stretch; margin: 4px; padding: 7px; overflow: hidden; border-left: 3px solid var(--mint-ink); border-radius: 7px; color: #26584d; background: #e7f3ef; font-size: 9px; cursor: pointer; }
.cal-event.coral { color: #87443d; border-color: var(--coral); background: var(--coral-soft); }
.cal-event.blue { color: #3d6582; border-color: var(--blue); background: var(--blue-soft); }
.cal-event strong, .cal-event small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-columns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; align-items: start; }
.queue-column { min-height: 450px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: #efeee9; }
.queue-column-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 2px 11px; }
.queue-column-head h3 { display: flex; align-items: center; gap: 7px; margin: 0; font-size: 11px; }
.queue-column-head span { min-width: 20px; height: 20px; display: grid; place-items: center; border-radius: 10px; color: var(--muted); background: white; font-size: 9px; font-weight: 700; }
.queue-stack { display: grid; gap: 8px; }
.queue-card { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: white; box-shadow: 0 1px 3px rgba(0,0,0,.03); }
.queue-card-top { display: flex; align-items: center; gap: 8px; }
.queue-card-top > div { min-width: 0; flex: 1; }
.queue-card-top strong, .queue-card-top small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-card-top strong { font-size: 10px; }
.queue-card-top small { color: var(--muted); font-size: 8px; }
.queue-card-meta { display: flex; justify-content: space-between; margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--line); color: var(--muted); font-size: 8px; }
.queue-card.over-wait { border-color: #eac6be; }
.wait-badge { color: var(--danger); font-weight: 800; }
.queue-empty { display: grid; place-items: center; min-height: 90px; border: 1px dashed var(--line-dark); border-radius: 9px; color: #9ba39f; font-size: 9px; text-align: center; }

/* Doctor / consultation */
.doctor-hero { display: grid; grid-template-columns: 1.3fr .7fr; gap: 14px; margin-bottom: 16px; }
.current-patient { padding: 20px; color: white; border-color: var(--pine); background: var(--pine); box-shadow: none; }
.current-patient .overline { color: #9fc5bc; font-size: 9px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.current-patient h2 { margin: 11px 0 4px; font: 700 27px/1.15 var(--display); letter-spacing: -.04em; }
.current-patient p { margin: 0; color: #b9d0cb; }
.current-patient footer { display: flex; gap: 8px; margin-top: 22px; }
.current-patient .button { border-color: rgba(255,255,255,.2); color: white; background: rgba(255,255,255,.1); }
.current-patient .button.coral { border-color: var(--coral); background: var(--coral); }
.queue-next-card { padding: 18px; }
.doctor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 16px; }
.consultation-shell { margin: -28px clamp(-38px, -2.5vw, -18px) -70px; }
.patient-ribbon { position: sticky; top: var(--topbar-h); z-index: 20; display: flex; align-items: center; gap: 12px; padding: 11px clamp(18px, 2.5vw, 38px); color: white; background: var(--pine); }
.patient-ribbon .patient-ribbon-main { min-width: 150px; }
.patient-ribbon strong, .patient-ribbon small { display: block; }
.patient-ribbon small { color: #a9c9c1; font-size: 9px; }
.ribbon-facts { flex: 1; display: flex; align-items: center; gap: 8px; overflow-x: auto; }
.ribbon-fact { padding: 5px 9px; border: 1px solid rgba(255,255,255,.12); border-radius: 7px; color: #d9e7e3; background: rgba(255,255,255,.07); font-size: 9px; white-space: nowrap; }
.ribbon-actions { display: flex; gap: 7px; }
.consultation-layout { display: grid; grid-template-columns: 180px minmax(480px, 1fr) 310px; min-height: calc(100vh - 126px); background: white; }
.consult-nav { padding: 20px 12px; border-right: 1px solid var(--line); background: #faf9f6; }
.consult-progress { margin: 0 8px 16px; }
.consult-progress span { display: flex; justify-content: space-between; color: var(--muted); font-size: 9px; }
.progress { height: 6px; overflow: hidden; margin-top: 7px; border-radius: 3px; background: var(--line); }
.progress i { display: block; height: 100%; border-radius: inherit; background: var(--mint-ink); }
.consult-nav button { width: 100%; min-height: 35px; display: flex; align-items: center; gap: 8px; padding: 0 9px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; font-size: 10px; text-align: left; }
.consult-nav button.active { color: var(--pine); background: var(--mint); font-weight: 700; }
.consult-nav button.done::after { content: "✓"; margin-left: auto; color: var(--mint-ink); }
.consult-workspace { min-width: 0; padding: 24px clamp(20px, 3vw, 44px) 80px; }
.autosave { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 9px; }
.autosave::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #47a889; }
.consult-section { margin-bottom: 25px; }
.consult-section h2 { margin: 0 0 4px; font: 700 21px/1.2 var(--display); letter-spacing: -.03em; }
.consult-section > p { margin: 0 0 14px; color: var(--muted); font-size: 10px; }
.quick-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.quick-chip { min-height: 31px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink-2); background: white; font-size: 10px; }
.quick-chip:hover, .quick-chip.selected { color: var(--pine); border-color: #9fc5bc; background: var(--mint); }
.vitals-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.vital-field { padding: 10px; border: 1px solid var(--line); border-radius: 9px; }
.vital-field label { display: block; color: var(--muted); font-size: 9px; }
.vital-field div { display: flex; align-items: baseline; gap: 4px; }
.vital-field input { height: 30px; padding: 0; border: 0; box-shadow: none; background: transparent; font: 700 16px/1 var(--display); }
.vital-field span { color: var(--muted); font-size: 9px; }
.note-field { position: relative; }
.note-field textarea { min-height: 120px; padding-bottom: 42px; line-height: 1.7; }
.note-tools { position: absolute; left: 8px; right: 8px; bottom: 8px; display: flex; gap: 5px; }
.note-tools button { min-height: 25px; display: flex; align-items: center; gap: 5px; padding: 0 7px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: white; font-size: 8px; }
.consult-footer { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 30px clamp(-44px, -3vw, -20px) -80px; padding: 12px clamp(20px, 3vw, 44px); border-top: 1px solid var(--line); background: rgba(255,255,255,.94); backdrop-filter: blur(12px); }
.consult-copilot { padding: 18px; border-left: 1px solid var(--line); background: #f8f6f0; }
.copilot-title { display: flex; align-items: center; gap: 8px; }
.ai-glyph { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; color: #fff4ed; background: var(--coral); font-weight: 800; }
.copilot-title h3, .copilot-title small { display: block; margin: 0; }
.copilot-title h3 { font: 700 12px/1.2 var(--display); }
.copilot-title small { color: var(--muted); font-size: 8px; }
.copilot-prompt { display: flex; gap: 6px; margin-top: 16px; }
.copilot-prompt input { height: 36px; font-size: 10px; }
.copilot-prompt button { width: 36px; flex: 0 0 auto; }
.ai-card { margin-top: 12px; padding: 12px; border: 1px solid #e7dcd0; border-radius: 10px; background: white; }
.ai-card header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.ai-card header strong { font-size: 9px; text-transform: uppercase; letter-spacing: .05em; }
.ai-card p, .ai-card li { color: var(--ink-2); font-size: 9px; }
.ai-card ul { margin: 7px 0 0; padding-left: 16px; }
.ai-disclaimer { margin-top: 14px; color: var(--muted); font-size: 8px; line-height: 1.5; }

/* Charts, intelligence, kanban */
.chart-card { padding: 18px; }
.chart-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.chart-head strong { display: block; font: 700 25px/1 var(--display); letter-spacing: -.04em; }
.chart-head small { color: var(--muted); font-size: 9px; }
.bar-chart { height: 170px; display: flex; align-items: flex-end; gap: 8px; margin-top: 20px; padding-top: 10px; border-bottom: 1px solid var(--line); background: repeating-linear-gradient(to bottom, transparent 0, transparent 41px, var(--line) 42px); }
.bar-col { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; position: relative; }
.bar-col i { width: min(28px, 65%); display: block; border-radius: 5px 5px 0 0; background: var(--pine); transition: height .5s ease; }
.bar-col span { position: absolute; bottom: -20px; color: var(--muted); font-size: 8px; }
.donut-wrap { display: flex; align-items: center; gap: 26px; margin-top: 20px; }
.donut { width: 120px; height: 120px; display: grid; place-items: center; position: relative; border-radius: 50%; background: conic-gradient(var(--pine) 0 44%, var(--coral) 44% 69%, var(--amber) 69% 84%, var(--blue) 84% 100%); }
.donut::after { content: ""; position: absolute; width: 76px; height: 76px; border-radius: 50%; background: white; }
.donut strong { z-index: 1; font: 700 17px/1 var(--display); }
.chart-legend { display: grid; gap: 9px; }
.chart-legend span { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 9px; }
.chart-legend b { margin-left: auto; color: var(--ink); }
.kanban { display: grid; grid-template-columns: repeat(5, minmax(210px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 8px; }
.kanban-col { min-height: 500px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #efeee9; }
.kanban-head { display: flex; align-items: center; justify-content: space-between; padding: 3px 2px 10px; }
.kanban-head h3 { margin: 0; font-size: 10px; }
.kanban-head span { color: var(--muted); font-size: 9px; }
.lead-card { margin-bottom: 7px; padding: 11px; border: 1px solid var(--line); border-radius: 9px; background: white; }
.lead-card h4 { margin: 0 0 3px; font-size: 10px; }
.lead-card p { margin: 0; color: var(--muted); font-size: 8px; }
.lead-card footer { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); color: var(--muted); font-size: 8px; }
.intelligence-hero { display: grid; grid-template-columns: 1fr 380px; gap: 16px; margin-bottom: 18px; }
.intelligence-intro { min-height: 220px; display: flex; flex-direction: column; justify-content: flex-end; padding: 28px; color: white; border-color: var(--pine); background: var(--pine); box-shadow: none; position: relative; overflow: hidden; }
.intelligence-intro::after { content: "↗"; position: absolute; right: 12px; top: -42px; color: rgba(255,255,255,.045); font: 700 210px/1 var(--display); }
.intelligence-intro h2 { max-width: 620px; margin: 0 0 8px; font: 700 29px/1.2 var(--display); letter-spacing: -.04em; }
.intelligence-intro p { max-width: 560px; margin: 0; color: #a9c9c1; }
.ask-clinic { padding: 18px; }
.ask-clinic h3 { margin: 0 0 5px; font: 700 15px/1.2 var(--display); }
.ask-input { display: flex; gap: 6px; margin-top: 14px; }
.ask-input input { height: 40px; font-size: 10px; }
.prompt-suggestions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.prompt-suggestions button { padding: 4px 7px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: var(--surface-2); font-size: 8px; }
.insight-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.big-insight { min-height: 180px; display: flex; flex-direction: column; padding: 18px; }
.big-insight .insight-number { margin: 17px 0 8px; font: 700 28px/1 var(--display); letter-spacing: -.04em; }
.big-insight h3 { margin: 0; font-size: 11px; }
.big-insight p { margin: 0; color: var(--muted); font-size: 9px; }
.big-insight footer { margin-top: auto; padding-top: 16px; }

/* Communication, settings, miscellaneous */
.inbox-layout { height: calc(100vh - 150px); min-height: 580px; display: grid; grid-template-columns: 320px minmax(400px, 1fr) 260px; overflow: hidden; }
.inbox-list { border-right: 1px solid var(--line); overflow-y: auto; }
.inbox-search { padding: 12px; border-bottom: 1px solid var(--line); }
.conversation-item { width: 100%; display: grid; grid-template-columns: 35px 1fr; gap: 9px; padding: 12px; border: 0; border-bottom: 1px solid var(--line); background: white; text-align: left; }
.conversation-item:hover, .conversation-item.active { background: #f7f5ef; }
.conversation-item strong, .conversation-item small { display: block; }
.conversation-item header { display: flex; justify-content: space-between; }
.conversation-item strong { font-size: 10px; }
.conversation-item time { color: var(--muted); font-size: 8px; }
.conversation-item p { margin: 3px 0 0; overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.channel-mark { margin-top: 4px; color: var(--mint-ink); font-size: 8px; font-weight: 700; }
.chat-panel { display: flex; flex-direction: column; min-width: 0; }
.chat-head { height: 64px; display: flex; align-items: center; gap: 10px; padding: 0 15px; border-bottom: 1px solid var(--line); }
.chat-head div { flex: 1; }
.chat-head strong, .chat-head small { display: block; }
.chat-head small { color: var(--muted); font-size: 9px; }
.chat-messages { flex: 1; display: flex; flex-direction: column; gap: 9px; padding: 18px; overflow-y: auto; background: #f8f6f0; }
.message { max-width: 75%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px 10px 10px 2px; background: white; font-size: 10px; }
.message.sent { align-self: flex-end; color: #234f45; border-color: #b8dacf; border-radius: 10px 10px 2px 10px; background: var(--mint); }
.message time { display: block; margin-top: 4px; color: var(--muted); font-size: 7px; text-align: right; }
.chat-compose { display: flex; gap: 7px; padding: 11px; border-top: 1px solid var(--line); }
.chat-compose input { height: 38px; }
.contact-panel { padding: 18px; border-left: 1px solid var(--line); }
.contact-panel h3 { margin: 10px 0 2px; font: 700 14px/1.2 var(--display); }
.contact-panel > p { margin: 0; color: var(--muted); font-size: 9px; }
.settings-layout { display: grid; grid-template-columns: 220px 1fr; gap: 16px; }
.settings-nav { padding: 8px; }
.settings-nav button { width: 100%; min-height: 38px; display: flex; align-items: center; gap: 9px; padding: 0 10px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; font-size: 10px; text-align: left; }
.settings-nav button.active { color: var(--pine); background: var(--mint); font-weight: 700; }
.settings-content { padding: 22px; }
.settings-section { max-width: 760px; }
.settings-section h2 { margin: 0 0 4px; font: 700 20px/1.2 var(--display); letter-spacing: -.03em; }
.settings-section > p { margin: 0 0 22px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; }
.form-grid .wide { grid-column: 1 / -1; }
.toggle-row { min-height: 58px; display: flex; align-items: center; gap: 12px; border-top: 1px solid var(--line); }
.toggle-row:first-of-type { border-top: 0; }
.toggle-row div { flex: 1; }
.toggle-row strong, .toggle-row small { display: block; }
.toggle-row strong { font-size: 10px; }
.toggle-row small { color: var(--muted); font-size: 9px; }
.switch { width: 36px; height: 20px; position: relative; border: 0; border-radius: 10px; background: var(--line-dark); }
.switch::after { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: left .18s; }
.switch.on { background: var(--pine-2); }
.switch.on::after { left: 18px; }
.blueprint-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.blueprint-card { padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.blueprint-card h3 { margin: 0 0 6px; font-size: 11px; }
.blueprint-card p, .blueprint-card li { color: var(--muted); font-size: 9px; }
.blueprint-card ul { margin: 6px 0 0; padding-left: 16px; }
.empty-state { display: grid; place-items: center; min-height: 300px; padding: 40px; text-align: center; }
.empty-state-icon { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 16px; color: var(--pine); background: var(--mint); font-size: 24px; }
.empty-state h2 { margin: 14px 0 4px; font: 700 18px/1.2 var(--display); }
.empty-state p { max-width: 420px; margin: 0 0 16px; color: var(--muted); }
.workflow-steps { display: flex; align-items: center; gap: 0; overflow-x: auto; padding: 12px 0 4px; }
.workflow-step { min-width: 150px; position: relative; padding: 0 16px 0 0; }
.workflow-step:not(:last-child)::after { content: ""; position: absolute; right: 3px; top: 14px; width: 10px; height: 1px; background: var(--line-dark); }
.workflow-step .step-dot { width: 27px; height: 27px; display: grid; place-items: center; border: 1px solid var(--line-dark); border-radius: 50%; color: var(--muted); background: white; font-size: 9px; font-weight: 800; }
.workflow-step.done .step-dot { color: white; border-color: var(--pine); background: var(--pine); }
.workflow-step.current .step-dot { color: white; border-color: var(--coral); background: var(--coral); box-shadow: 0 0 0 4px var(--coral-soft); }
.workflow-step strong, .workflow-step small { display: block; }
.workflow-step strong { margin-top: 7px; font-size: 9px; }
.workflow-step small { color: var(--muted); font-size: 8px; }
.treatment-progress { display: flex; align-items: center; gap: 5px; margin-top: 12px; }
.session-dot { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid var(--line-dark); border-radius: 50%; color: var(--muted); background: white; font-size: 8px; font-weight: 800; }
.session-dot.done { color: white; border-color: var(--pine); background: var(--pine); }
.session-dot.today { color: white; border-color: var(--coral); background: var(--coral); box-shadow: 0 0 0 3px var(--coral-soft); }
.treatment-progress i { width: 18px; height: 1px; background: var(--line-dark); }

/* Modal, drawer, palette, toast */
.modal-backdrop, .drawer-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(16,26,23,.42); backdrop-filter: blur(3px); animation: fadeIn .16s ease; }
.modal-backdrop { display: grid; place-items: center; padding: 18px; }
.modal { width: min(620px, 100%); max-height: min(780px, calc(100vh - 36px)); overflow-y: auto; border-radius: 17px; background: white; box-shadow: var(--shadow-lg); animation: modalIn .2s ease; }
.modal.wide { width: min(860px, 100%); }
.modal-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(12px); }
.modal-head > div { flex: 1; }
.modal-head h2 { margin: 0; font: 700 18px/1.2 var(--display); letter-spacing: -.03em; }
.modal-head p { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.modal-body { padding: 20px; }
.modal-foot { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 13px 20px; border-top: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(12px); }
.modal-foot .foot-note { margin-right: auto; color: var(--muted); font-size: 9px; }
.quick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.quick-tile { min-height: 95px; display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-end; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); text-align: left; }
.quick-tile:hover { color: var(--pine); border-color: #a8c6bd; background: var(--mint); }
.quick-tile svg { font-size: 18px; }
.quick-tile strong { font-size: 10px; }
.drawer-backdrop { display: flex; justify-content: flex-end; }
.drawer { width: min(430px, 92vw); height: 100%; overflow-y: auto; background: white; box-shadow: -12px 0 45px rgba(23,32,30,.13); animation: drawerIn .22s ease; }
.drawer .modal-head { padding-top: 22px; }
.toast-stack { position: fixed; z-index: 200; right: 20px; bottom: 20px; display: grid; gap: 8px; pointer-events: none; }
.toast { min-width: 280px; max-width: 380px; display: grid; grid-template-columns: 25px 1fr auto; align-items: center; gap: 9px; padding: 11px 12px; border: 1px solid #b8d8ce; border-radius: 10px; background: white; box-shadow: var(--shadow-lg); animation: toastIn .25s ease; pointer-events: auto; }
.toast > span:first-child { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 7px; color: var(--mint-ink); background: var(--mint); }
.toast strong, .toast small { display: block; }
.toast strong { font-size: 10px; }
.toast small { color: var(--muted); font-size: 8px; }
.toast button { border: 0; color: var(--muted); background: transparent; }
.command-palette { position: fixed; inset: 0; z-index: 150; display: grid; place-items: start center; padding-top: min(17vh, 150px); background: rgba(16,26,23,.36); backdrop-filter: blur(3px); }
.palette-box { width: min(650px, calc(100% - 28px)); overflow: hidden; border-radius: 15px; background: white; box-shadow: var(--shadow-lg); }
.palette-input { display: flex; align-items: center; gap: 9px; padding: 13px 15px; border-bottom: 1px solid var(--line); }
.palette-input input { height: 35px; border: 0; box-shadow: none; font-size: 13px; }
.palette-results { max-height: 430px; overflow-y: auto; padding: 8px; }
.palette-label { padding: 8px; color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.palette-item { width: 100%; min-height: 47px; display: flex; align-items: center; gap: 10px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; text-align: left; }
.palette-item:hover { background: var(--surface-2); }
.palette-item > span:first-child { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 8px; color: var(--pine); background: var(--mint); }
.palette-item div { flex: 1; }
.palette-item strong, .palette-item small { display: block; }
.palette-item strong { font-size: 10px; }
.palette-item small { color: var(--muted); font-size: 8px; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(.99); } }
@keyframes drawerIn { from { transform: translateX(24px); opacity: .6; } }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } }

/* Responsive */
@media (max-width: 1180px) {
  :root { --sidebar-w: 216px; }
  .command-search { width: 240px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .queue-columns { grid-template-columns: repeat(2, 1fr); }
  .insight-grid { grid-template-columns: repeat(2, 1fr); }
  .consultation-layout { grid-template-columns: 160px minmax(440px, 1fr); }
  .consult-copilot { grid-column: 1 / -1; border-top: 1px solid var(--line); border-left: 0; }
  .inbox-layout { grid-template-columns: 280px 1fr; }
  .contact-panel { display: none; }
}

@media (max-width: 900px) {
  :root { --sidebar-w: 248px; }
  .login-view { grid-template-columns: 1fr; }
  .login-brand-panel { display: none; }
  .login-form-panel { min-height: 100vh; padding: 24px; }
  .mobile-brand { display: flex; margin: 0 0 54px; }
  .mobile-brand .keystone-brand-copy strong { font-size: 15px; }
  .sidebar { transform: translateX(-105%); box-shadow: var(--shadow-lg); transition: transform .22s ease; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close, .menu-button { display: inline-grid; }
  .mobile-overlay { position: fixed; inset: 0; z-index: 35; display: none; background: rgba(17,28,25,.35); backdrop-filter: blur(2px); }
  .mobile-overlay.open { display: block; }
  .app-main { margin-left: 0; }
  .topbar { padding: 0 16px; }
  .command-search { width: 38px; justify-content: center; }
  .topbar-contact { width: 38px; justify-content: center; padding: 0; }
  .topbar-contact > span:last-child { display: none; }
  .command-search span:nth-child(2), .command-search kbd { display: none; }
  .quick-action-trigger span:nth-child(2), .quick-action-trigger kbd { display: none; }
  .quick-action-trigger { width: 38px; padding: 0; }
  #main-content { padding: 22px 16px 86px; }
  .dashboard-grid, .patient-layout, .doctor-layout, .doctor-hero, .intelligence-hero { grid-template-columns: 1fr; }
  .calendar-layout { grid-template-columns: 1fr; }
  .calendar-side { display: none; }
  .patient-header { grid-template-columns: auto 1fr; }
  .patient-header-actions { grid-column: 1 / -1; }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { display: flex; overflow-x: auto; }
  .settings-nav button { width: auto; flex: 0 0 auto; padding: 0 12px; }
  .settings-nav button svg { display: none; }
  .consultation-shell { margin: -22px -16px -86px; }
  .patient-ribbon { top: var(--topbar-h); padding: 10px 16px; }
  .ribbon-facts { display: none; }
  .consultation-layout { grid-template-columns: 1fr; }
  .consult-nav { display: flex; overflow-x: auto; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .consult-nav .consult-progress { display: none; }
  .consult-nav button { width: auto; flex: 0 0 auto; }
  .consult-copilot { display: none; }
  .consult-footer { margin-left: -20px; margin-right: -20px; }
}

@media (max-width: 650px) {
  body { font-size: 13px; }
  .topbar { height: 60px; }
  .breadcrumbs span { display: none; }
  .breadcrumbs span::after { display: none; }
  .notification-button, .quick-action-trigger { display: none; }
  #main-content { min-height: calc(100vh - 60px); padding: 18px 13px 88px; }
  .page-head { align-items: flex-start; margin-bottom: 18px; }
  .page-head h1 { font-size: 25px; }
  .page-head .page-actions .date-chip, .page-head .page-actions .button:not(.primary):not(.coral) { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi { min-height: 108px; padding: 13px; }
  .kpi strong { font-size: 21px; }
  .dashboard-grid { gap: 12px; }
  .schedule-row { grid-template-columns: 40px 3px 1fr auto; gap: 8px; }
  .doctor-cell { display: none; }
  .pulse-legend { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .toolbar { flex-wrap: wrap; }
  .search-field { flex-basis: 100%; }
  .toolbar > .button span:last-child { display: none; }
  .table-card { border-radius: 0; border-right: 0; border-left: 0; margin-right: -13px; margin-left: -13px; }
  .data-table { min-width: 680px; }
  .table-card { overflow-x: auto; }
  .pagination { position: sticky; left: 0; width: 100vw; max-width: calc(100vw - 0px); }
  .patient-header { margin-right: -13px; margin-left: -13px; border-radius: 0; border-right: 0; border-left: 0; }
  .patient-header-actions .button { flex: 1; }
  .patient-stats { grid-template-columns: repeat(2, 1fr); }
  .patient-stat:nth-child(n+3) { display: none; }
  .patient-layout { gap: 12px; }
  .patient-side { grid-row: 1; }
  .patient-side .card:not(:first-child) { display: none; }
  .queue-columns { grid-template-columns: 1fr; }
  .queue-column { min-height: auto; }
  .queue-column:nth-child(n+3) { min-height: 160px; }
  .vitals-grid, .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .wide { grid-column: 1 / -1; }
  .intelligence-intro { min-height: 250px; padding: 22px; }
  .intelligence-intro h2 { font-size: 25px; }
  .insight-grid { grid-template-columns: 1fr; }
  .kanban { margin-right: -13px; margin-left: -13px; padding: 0 13px 8px; }
  .inbox-layout { height: calc(100vh - 145px); grid-template-columns: 1fr; margin-right: -13px; margin-left: -13px; border-radius: 0; }
  .inbox-list { display: none; }
  .settings-content { padding: 16px; }
  .blueprint-grid { grid-template-columns: 1fr; }
  .quick-grid { grid-template-columns: repeat(2, 1fr); }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal { width: 100%; max-height: 91vh; border-radius: 18px 18px 0 0; }
  .drawer { width: 100%; }
  .toast-stack { right: 10px; bottom: 77px; left: 10px; }
  .toast { min-width: 0; max-width: none; }
  .mobile-nav { height: 66px; position: fixed; inset: auto 0 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr); padding: 5px max(7px, env(safe-area-inset-right)) max(5px, env(safe-area-inset-bottom)) max(7px, env(safe-area-inset-left)); border-top: 1px solid var(--line); background: rgba(250,249,246,.96); backdrop-filter: blur(14px); }
  .mobile-nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; font-size: 8px; }
  .mobile-nav button.active { color: var(--pine); }
  .mobile-nav svg { font-size: 17px; }
  .mobile-fab { position: fixed; right: 15px; bottom: 78px; z-index: 28; width: 46px; height: 46px; display: grid; place-items: center; border: 0; border-radius: 50%; color: white; background: var(--coral); box-shadow: 0 8px 25px rgba(173,72,60,.32); font-size: 20px; }
  .consultation-shell { margin: -18px -13px -88px; }
  .patient-ribbon { top: 60px; padding: 9px 13px; }
  .patient-ribbon .avatar { display: none; }
  .ribbon-actions .button:not(.coral) { display: none; }
  .consult-workspace { padding: 20px 16px 80px; }
  .consult-footer { margin: 26px -16px -80px; padding: 10px 16px; }
  .consult-footer > span { display: none; }
  .consult-footer .page-actions { width: 100%; }
  .consult-footer .button { flex: 1; }
  .vital-field { padding: 8px; }
}

@media print {
  .sidebar, .topbar, .mobile-nav, .mobile-fab, .page-actions, .button, .toolbar { display: none !important; }
  .app-main { margin: 0; }
  #main-content { padding: 0; }
  .card { box-shadow: none; }
  body { background: white; }
}
