/* =========================================================
   Awrova HMIS — dashboard demo
   Falcon-style theme: light canvas, floating white cards,
   sidebar on the canvas, teal accent, dark mode via tokens.
   Plus Jakarta Sans headings, Nunito Sans for UI and numbers.
   ========================================================= */

:root {
  --ink: #eef3f5;          /* page canvas */
  --surface: #ffffff;      /* cards */
  --surface-2: #f5f8fa;    /* raised: hover, inputs, chips, card footers */
  --surface-3: #e9eff2;

  --primary: #17a589;      /* fills only: primary buttons, active nav, focus */
  --primary-hover: #138d75;
  --primary-text: #117a65; /* teal text on white (#17a589 text fails contrast) */
  --primary-soft: #e3f4f0;
  --on-primary: #ffffff;

  --text-1: #1d2b36;
  --text-2: #56687a;
  --text-3: #8696a5;
  --line: #e2e9ed;
  --line-2: #d3dde3;

  /* chart roles, validated against --surface */
  --viz-accent: #17a589;
  --viz-deemph: #b5c2cb;
  --viz-grid: #edf1f4;
  --viz-axis: #d3dde3;

  /* status: reserved meaning, always shown with an icon + label — never teal */
  --good: #2f8f4e;     --good-soft: #e5f3e9;
  --warning: #c56a12;  --warning-soft: #fdf0e1;
  --info: #2c6fd1;     --info-soft: #e7effb;
  --critical: #d93b45; --critical-soft: #fdeaeb;

  --shadow: 0 7px 14px 0 rgba(65, 69, 88, .08), 0 3px 6px 0 rgba(0, 0, 0, .05);
  --shadow-pop: 0 0 0 1px var(--line), 0 18px 40px -12px rgba(29, 43, 54, .22);
  --toast-bg: #1d2b36;
  --toast-text: #ffffff;
  --scrim: rgba(29, 43, 54, .45);

  /* inverted sidebar (Falcon navbar-inverted), dark in both themes */
  --sb-bg: #1f2c36;
  --sb-text: #9dabb7;
  --sb-text-hi: #edf2f5;
  --sb-label: #627584;
  --sb-line: rgba(255, 255, 255, .08);
  --sb-hover: rgba(255, 255, 255, .05);
  --sb-active: rgba(31, 185, 154, .16);
  --sb-accent: #3fd0b2;

  /* the 800 logo */
  --l1: #48c9b0; --l2: #1abc9c; --l3: #17a589; --l4: #138d75; --l5: #0e6655;

  --display: "Plus Jakarta Sans", "Nunito Sans", system-ui, sans-serif;
  --sans: "Nunito Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
  --radius: 10px;
  --sb-w: 256px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --ink: #0e171c; --surface: #15222a; --surface-2: #1a2a33; --surface-3: #22343e;
  --primary: #1fb99a; --primary-hover: #29cdab; --primary-text: #52d4b9; --primary-soft: rgba(31, 185, 154, .14); --on-primary: #06231d;
  --text-1: #e4edf1; --text-2: #a3b4bd; --text-3: #73868f; --line: #22343e; --line-2: #2d434e;
  --viz-accent: #1fb99a; --viz-deemph: #4b5f69; --viz-grid: #1d2d35; --viz-axis: #2d434e;
  --good: #5cc27c; --good-soft: rgba(92, 194, 124, .14);
  --warning: #f0a04b; --warning-soft: rgba(240, 160, 75, .14);
  --info: #6aa4f5; --info-soft: rgba(106, 164, 245, .14);
  --critical: #f2737a; --critical-soft: rgba(242, 115, 122, .14);
  --shadow: 0 7px 14px 0 rgba(0, 0, 0, .25), 0 3px 6px 0 rgba(0, 0, 0, .2);
  --shadow-pop: 0 0 0 1px var(--line-2), 0 18px 40px -12px rgba(0, 0, 0, .7);
  --toast-bg: #e4edf1; --toast-text: #0e171c; --scrim: rgba(0, 0, 0, .6);
  --sb-bg: #091116; --sb-text: #8fa0aa; --sb-text-hi: #e4edf1; --sb-label: #56686f; --sb-line: rgba(255, 255, 255, .06); --sb-hover: rgba(255, 255, 255, .04); --sb-active: rgba(31, 185, 154, .14); --sb-accent: #52d4b9;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--sans); font-size: 14px; line-height: 1.55; color: var(--text-1); background: var(--ink); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
ul { list-style: none; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.25; }
em { font-style: normal; }
svg { display: block; }
.icon { width: 18px; height: 18px; flex-shrink: 0; }
.ic { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
::selection { background: var(--primary-soft); color: var(--text-1); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 15px; border-radius: 7px;
  border: 1px solid transparent; font-weight: 700; font-size: 13.5px; white-space: nowrap; transition: background-color .15s, border-color .15s, color .15s;
}
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: 0 2px 5px rgba(23, 165, 137, .25); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-default { background: var(--surface); color: var(--text-1); border-color: var(--line); box-shadow: 0 1px 2px rgba(0, 0, 0, .04); }
.btn-default:hover { color: var(--primary-text); border-color: var(--primary); }
.btn-sm { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: 6px; }
.icon-btn { position: relative; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; color: var(--text-2); transition: background-color .15s, color .15s; }
.icon-btn:hover { background: var(--surface); color: var(--primary-text); }
.link-btn { display: inline-flex; align-items: center; gap: 6px; color: var(--primary-text); font-weight: 700; font-size: 13px; }
.link-btn:hover { text-decoration: underline; }
.link-btn .icon { width: 15px; height: 15px; }

/* ---------- App frame ---------- */
.app { display: grid; grid-template-columns: var(--sb-w) minmax(0, 1fr); max-width: 1920px; min-height: 100vh; margin-inline: auto; transition: grid-template-columns .3s var(--ease); }
.app.is-collapsed { --sb-w: 76px; }

/* ---------- Sidebar (Falcon inverted: logo row on the canvas, nav in a floating dark panel) ---------- */
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 12px;
  padding: 12px 0 16px 16px; background: var(--ink);
}
.sb-top { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.sb-logo { display: flex; align-items: center; gap: 10px; color: var(--text-1); min-width: 0; }
.sb-logo-full { width: 120px; height: 20px; flex-shrink: 0; }
.sb-product { font: 800 10px var(--sans); letter-spacing: .12em; padding: 2px 6px; border-radius: 5px; background: var(--primary-soft); color: var(--primary-text); }
.sb-panel {
  flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 14px; padding: 14px 12px;
  border-radius: var(--radius); background: var(--sb-bg); color: var(--sb-text); box-shadow: var(--shadow);
  overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; scrollbar-color: var(--sb-line) transparent;
}
.hospital {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; border-radius: 8px; text-align: left;
  background: var(--sb-hover); box-shadow: inset 0 0 0 1px var(--sb-line); transition: box-shadow .15s;
}
.hospital:hover { box-shadow: inset 0 0 0 1px var(--sb-accent); }
.hospital-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0; background: var(--primary); color: var(--on-primary); font: 800 12px var(--display); }
.hospital-text { display: grid; min-width: 0; line-height: 1.3; }
.hospital-text b { font-size: 13.5px; font-weight: 700; color: var(--sb-text-hi); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hospital-text small { color: var(--sb-label); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hospital > .icon { margin-left: auto; width: 16px; height: 16px; color: var(--sb-label); }
.sb-nav { display: grid; gap: 1px; }
.sb-group { display: flex; align-items: center; gap: 8px; margin: 14px 8px 6px; font-size: 11px; font-weight: 700; letter-spacing: .04em; color: var(--sb-label); white-space: nowrap; }
.sb-group::after { content: ""; flex: 1; height: 1px; background: var(--sb-line); }
.sb-link {
  position: relative; display: flex; align-items: center; gap: 11px; padding: 6px 8px; border-radius: 6px;
  color: var(--sb-text); font-weight: 600; white-space: nowrap; transition: color .15s;
}
.sb-link .icon { width: 16px; height: 16px; color: var(--sb-text); transition: color .15s; }
.sb-link:hover, .sb-link:hover .icon { color: var(--sb-text-hi); }
.sb-link.is-active { color: var(--sb-text-hi); font-weight: 800; }
.sb-link.is-active .icon { color: var(--sb-accent); }
.sb-badge { margin-left: auto; padding: 0 7px; border-radius: 99px; background: var(--sb-active); color: var(--sb-accent); font-size: 10.5px; font-weight: 800; font-variant-numeric: tabular-nums; }
.sb-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 8px; background: var(--sb-hover); box-shadow: inset 0 0 0 1px var(--sb-line); font-size: 12.5px; line-height: 1.35; }
.sb-foot b { display: block; font-weight: 700; color: var(--sb-text-hi); }
.sb-foot small { color: var(--sb-label); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.status-dot--good { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }

/* collapsed sidebar (desktop) */
.app.is-collapsed .sidebar { padding-left: 12px; }
.app.is-collapsed .sb-logo, .app.is-collapsed .hospital-text, .app.is-collapsed .hospital > .icon,
.app.is-collapsed .sb-link span, .app.is-collapsed .sb-foot > span:last-child { display: none; }
.app.is-collapsed .sb-top { justify-content: center; }
.app.is-collapsed .sb-panel { padding-inline: 8px; }
.app.is-collapsed .sb-group { margin: 10px 0 4px; height: 1px; overflow: hidden; color: transparent; background: var(--sb-line); }
.app.is-collapsed .sb-group::after { display: none; }
.app.is-collapsed .sb-link, .app.is-collapsed .hospital, .app.is-collapsed .sb-foot { justify-content: center; padding-inline: 0; }

/* ---------- Topbar ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px;
  padding: 12px 28px; background: var(--ink);
}
.tb-menu { display: none; }
.tb-title { min-width: 0; margin-right: auto; }
.tb-title h1 { font-size: 20px; letter-spacing: -.01em; }
.tb-title p { color: var(--text-3); font-size: 12.5px; }
.tb-search { position: relative; display: flex; align-items: center; gap: 10px; width: min(360px, 32vw); height: 38px; padding: 0 10px 0 14px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); transition: border-color .15s, box-shadow .15s; }
.tb-search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.tb-search-btn { display: grid; place-items: center; width: 22px; height: 22px; color: var(--text-3); }
.tb-search-btn .icon { width: 16px; height: 16px; }
.tb-search input { flex: 1; min-width: 0; background: none; border: 0; outline: none; font-size: 13.5px; }
.tb-search input::placeholder { color: var(--text-3); }
.tb-search input::-webkit-search-cancel-button { display: none; }
kbd { padding: 1px 6px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-3); font: 600 11px var(--mono); white-space: nowrap; }
.badge { position: absolute; top: 3px; right: 3px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 99px; display: grid; place-items: center; background: var(--critical); color: #fff; font-size: 10.5px; font-weight: 800; box-shadow: 0 0 0 2px var(--ink); }
.tb-pop { position: relative; }
.user-chip { display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 10px 0 4px; border-radius: 99px; transition: background-color .15s; }
.user-chip:hover, .user-chip[aria-expanded="true"] { background: var(--surface); }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-text); font: 800 13px var(--display); }
.uc-text { display: grid; text-align: left; line-height: 1.25; }
.uc-text b { font-size: 13.5px; font-weight: 700; white-space: nowrap; }
.uc-text small { color: var(--text-3); font-size: 12px; }
.user-chip > .icon { width: 16px; height: 16px; color: var(--text-3); }
.theme-dark { display: none; }
:root[data-theme="dark"] .theme-light { display: none; }
:root[data-theme="dark"] .theme-dark { display: block; }

/* dropdown menus */
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; min-width: 240px; padding: 8px;
  border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-pop);
}
.menu-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 8px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu-label { padding: 6px 8px; color: var(--text-3); font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.menu hr { margin: 6px 0; border: 0; border-top: 1px solid var(--line); }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 7px; text-align: left; color: var(--text-2); font-weight: 600; }
.menu-item:hover { background: var(--surface-2); color: var(--primary-text); }
.menu-item .icon { width: 16px; height: 16px; color: var(--text-3); }
.menu-item[aria-checked="true"] { color: var(--primary-text); background: var(--primary-soft); }
.menu-item[aria-checked="true"] .icon { color: var(--primary-text); }
.menu-item[aria-checked="true"]::after { content: ""; margin-left: auto; width: 16px; height: 16px; background: var(--primary-text); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat; }
.notif-menu { width: 340px; }
.notif-menu li { display: flex; gap: 12px; padding: 10px; border-radius: 8px; }
.notif-menu li:hover { background: var(--surface-2); }
.notif-menu .n-ic { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0; background: var(--surface-2); color: var(--text-2); }
.notif-menu .n-ic .icon { width: 16px; height: 16px; }
.notif-menu p { font-size: 13.5px; }
.notif-menu small { color: var(--text-3); font-size: 12px; }
.notif-menu li.is-unread { background: var(--primary-soft); }
.notif-menu li.is-unread p { font-weight: 700; }
.search-results { left: 0; right: auto; width: 100%; min-width: 300px; }
.search-results li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px; border-radius: 7px; cursor: pointer; }
.search-results li[aria-selected="true"], .search-results li:hover { background: var(--surface-2); }
.search-results b { font-weight: 700; font-size: 13.5px; }
.search-results small { color: var(--text-3); font: 12px var(--mono); }
.search-results .empty { color: var(--text-3); cursor: default; }

/* ---------- Content grid ---------- */
.content { display: grid; gap: 28px; padding: 0 28px 36px; }
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 20px; align-items: start; }
.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }
.appts.is-wide { grid-column: span 12; }
.beds, .appts { align-self: stretch; }

/* card = white, soft shadow; a header row with a border under it */
.card { position: relative; padding: 18px 20px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
figure.card { margin: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: -18px -20px 16px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.card-head h3 { font-size: 15px; letter-spacing: -.005em; }
.card-sub { margin-top: 1px; color: var(--text-3); font-size: 12.5px; }
.eyebrow { font-size: 11.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--primary-text); }

/* ---------- Welcome ---------- */
.welcome { display: flex; align-items: center; gap: 24px; min-height: 248px; overflow: hidden; padding: 26px 28px; align-self: stretch; background: linear-gradient(120deg, var(--surface) 55%, var(--primary-soft)); }
.welcome-text { flex: 1; min-width: 0; display: grid; gap: 12px; }
.welcome h2 { font-size: clamp(24px, 2.4vw, 32px); font-weight: 800; letter-spacing: -.025em; line-height: 1.1; }
.welcome h2 em { color: var(--primary-text); }
.welcome-summary { max-width: 58ch; color: var(--text-2); font-size: 14.5px; }
.welcome-summary b { color: var(--text-1); font-weight: 700; }
.welcome-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.welcome-sphere { width: 210px; height: 210px; flex-shrink: 0; margin: -10px -6px -10px 0; cursor: pointer; }

/* ---------- Live queue ---------- */
.queue { display: flex; flex-direction: column; min-height: 248px; }
.live { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 99px; background: var(--critical-soft); color: var(--critical); font-size: 11.5px; font-weight: 800; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.q-now { display: grid; gap: 2px; padding: 12px 16px; border-radius: 8px; background: var(--primary-soft); }
.q-label { color: var(--primary-text); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.q-token { font-family: var(--display); font-size: 36px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; color: var(--primary-text); font-variant-numeric: tabular-nums; }
.q-token.is-new { animation: tokenIn .7s var(--ease); }
@keyframes tokenIn { from { opacity: 0; transform: translateY(10px); } }
.q-where { color: var(--text-2); font-size: 13px; }
.q-list { display: grid; gap: 2px; margin: 12px 0; }
.q-list li { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 7px 2px; border-bottom: 1px solid var(--line); font-size: 13px; }
.q-list li:last-child { border-bottom: 0; }
.q-tok { min-width: 54px; padding: 1px 8px; border-radius: 6px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); font: 700 12.5px var(--display); text-align: center; font-variant-numeric: tabular-nums; }
.q-who { min-width: 0; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-meta { color: var(--text-3); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.q-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: auto -20px -18px; padding: 10px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); color: var(--text-3); font-size: 12.5px; }

/* ---------- KPI stat tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.kpi { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto auto; column-gap: 12px; padding: 18px 20px; overflow: hidden; }
.kpi::after { content: ""; position: absolute; right: -34px; top: -34px; width: 100px; height: 100px; border-radius: 50%; border: 16px solid var(--primary-soft); opacity: .7; pointer-events: none; }
.kpi-label { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 13px; font-weight: 700; }
.kpi-label .icon { width: 30px; height: 30px; padding: 7px; border-radius: 8px; background: var(--primary-soft); color: var(--primary-text); }
.kpi-value { margin-top: 12px; font-family: var(--display); font-size: clamp(22px, 1.9vw, 28px); font-weight: 800; letter-spacing: -.02em; line-height: 1.1; white-space: nowrap; font-variant-numeric: tabular-nums; }
.kpi-value small { margin-left: 4px; color: var(--text-3); font: 600 13.5px var(--sans); letter-spacing: 0; }
.kpi-value, .kpi-foot { grid-column: 1; }
.kpi .spark { grid-column: 2; grid-row: 2 / span 2; align-self: end; margin-bottom: 2px; }
.kpi-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 8px; color: var(--text-3); font-size: 12.5px; }
.delta { display: inline-flex; align-items: center; gap: 3px; padding: 0 7px; border-radius: 99px; font-weight: 800; font-size: 12px; font-variant-numeric: tabular-nums; }
.delta .icon { width: 12px; height: 12px; }
.delta--good { color: var(--good); background: var(--good-soft); }
.delta--bad { color: var(--critical); background: var(--critical-soft); }
.delta--flat { color: var(--text-2); background: var(--surface-2); }

/* sparkline: de-emphasis line, today in the accent (with a surface ring) */
.spark-line { fill: none; stroke: var(--viz-deemph); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.spark-dot { fill: var(--viz-accent); stroke: var(--surface); stroke-width: 2; paint-order: stroke; }

/* ---------- Beds (dot grid) ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 14px; color: var(--text-2); font-size: 12.5px; }
.legend li { display: inline-flex; align-items: center; gap: 7px; }
.legend b { color: var(--text-1); font-weight: 700; font-variant-numeric: tabular-nums; }
.ward + .ward { margin-top: 14px; }
.ward-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 6px; font-size: 13px; }
.ward-head b { font-weight: 700; }
.ward-head span { color: var(--text-3); font-variant-numeric: tabular-nums; }
.ward-beds { display: flex; flex-wrap: wrap; gap: 0; margin-left: -6px; }
.bed { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; }
.bed:hover, .bed:focus-visible { background: var(--surface-2); }
.bed::before { content: ""; display: block; }
/* shape + colour per state, so state never relies on colour alone; available is an empty ring, never green next to teal */
.bed--occupied::before, .key--occupied { width: 12px; height: 12px; border-radius: 50%; background: var(--viz-accent); }
.bed--reserved::before, .key--reserved { width: 11px; height: 11px; border-radius: 3px; background: var(--info); }
.bed--cleaning::before, .key--cleaning { width: 7px; height: 7px; border-radius: 50%; background: var(--warning); }
.bed--available::before, .key--available { width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--viz-deemph); }
.key { display: inline-block; flex-shrink: 0; }

/* ---------- Appointments ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px -18px; }
.appt-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.appt-table th { padding: 9px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); color: var(--text-3); font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; text-align: left; white-space: nowrap; }
.appt-table th:first-child, .appt-table td:first-child { padding-left: 20px; }
.appt-table th:last-child, .appt-table td:last-child { padding-right: 20px; }
.appt-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.appt-table tbody tr:last-child td { border-bottom: 0; }
.appt-table tbody tr:hover td { background: var(--surface-2); }
.t-time { color: var(--text-2); font-variant-numeric: tabular-nums; }
.t-patient b { display: block; font-weight: 700; }
.t-patient small { color: var(--text-3); font: 12px var(--mono); }
.t-doctor { color: var(--text-2); }
.t-doctor small { display: block; color: var(--text-3); font-size: 12px; }
.type { color: var(--text-2); }
.appt-table.no-doctor .col-doctor, .appt-table.no-doctor .t-doctor { display: none; }
/* status chip: soft fill + icon + label */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 7px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); font-size: 12px; font-weight: 700; }
.chip .icon { width: 13px; height: 13px; }
.chip--completed { background: var(--good-soft); color: var(--good); }
.chip--consulting { background: var(--info-soft); color: var(--info); }
.chip--waiting { background: var(--warning-soft); color: var(--warning); }
.chip--scheduled { background: var(--surface-2); color: var(--text-2); box-shadow: inset 0 0 0 1px var(--line); }
.chip--noshow { background: var(--critical-soft); color: var(--critical); }

/* ---------- Role panels (alerts, approvals, lists) ---------- */
.panels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.panel { display: flex; flex-direction: column; }
.panel ul { display: grid; grid-template-columns: minmax(0, 1fr); }
.panel li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.panel li:first-child { border-top: 0; padding-top: 0; }
.p-ic { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0; background: var(--surface-2); color: var(--text-3); }
.p-ic .icon { width: 15px; height: 15px; }
.p-ic--critical { background: var(--critical-soft); color: var(--critical); }
.p-ic--warning { background: var(--warning-soft); color: var(--warning); }
.p-ic--good { background: var(--good-soft); color: var(--good); }
.p-text { flex: 1; min-width: 0; line-height: 1.35; }
.p-text b { display: block; font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-text small { color: var(--text-3); font-size: 12.5px; }
.p-level { font-size: 11.5px; font-weight: 800; color: var(--text-2); }
.p-actions { display: flex; gap: 6px; }
.panel li.has-actions { flex-wrap: wrap; row-gap: 8px; }
.panel li.has-actions .p-actions { flex-basis: 100%; padding-left: 42px; }
.p-done { display: inline-flex; align-items: center; gap: 5px; color: var(--text-2); font-size: 12.5px; font-weight: 700; }
.p-done .icon { width: 15px; height: 15px; color: var(--good); }
.panel ul { margin-bottom: 12px; }
.panel-foot { margin: auto -20px -18px; padding: 10px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.card-head .count { padding: 1px 9px; border-radius: 99px; background: var(--primary-soft); color: var(--primary-text); font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- Performance ---------- */
.perf { display: grid; gap: 16px; }
.perf-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.perf-head h2 { font-size: 20px; letter-spacing: -.01em; margin-right: 8px; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.segmented { display: inline-flex; padding: 3px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); }
.segmented button { height: 30px; padding: 0 13px; border-radius: 6px; color: var(--text-2); font-size: 13px; font-weight: 700; transition: background-color .15s, color .15s; }
.segmented button:hover { color: var(--primary-text); }
.segmented button[aria-checked="true"] { background: var(--primary); color: var(--on-primary); }
.select { position: relative; display: inline-flex; align-items: center; }
.select select { appearance: none; height: 38px; padding: 0 36px 0 14px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--text-1); font-size: 13px; font-weight: 700; cursor: pointer; }
.select select:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.select .icon { position: absolute; right: 12px; width: 15px; height: 15px; color: var(--text-3); pointer-events: none; }
.perf-summary { width: 100%; color: var(--text-2); font-size: 14px; }
.perf-summary b { color: var(--text-1); font-weight: 700; }

.view-toggle { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 6px; color: var(--text-2); font-size: 12.5px; font-weight: 700; border: 1px solid var(--line); background: var(--surface); transition: color .15s, background-color .15s, border-color .15s; }
.view-toggle:hover { color: var(--primary-text); border-color: var(--primary); }
.view-toggle[aria-pressed="true"] { background: var(--primary-soft); border-color: transparent; color: var(--primary-text); }
.view-toggle .icon { width: 14px; height: 14px; }

/* chart marks */
.viz-body { position: relative; }
.viz-body[data-view="chart"]:focus-visible { outline-offset: 4px; }
.viz { display: block; width: 100%; height: auto; overflow: visible; }
.viz-grid { stroke: var(--viz-grid); stroke-width: 1; }
.viz-axis { stroke: var(--viz-axis); stroke-width: 1; }
.viz-tick { fill: var(--text-3); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.viz-area { fill: var(--viz-accent); fill-opacity: .12; }
.viz-line { fill: none; stroke: var(--viz-accent); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.viz-dot { fill: var(--viz-accent); stroke: var(--surface); stroke-width: 2; paint-order: stroke; }
.viz-endlabel { fill: var(--primary-text); font-size: 12.5px; font-weight: 800; }
.viz-cross { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 3 3; }

.hbars { display: grid; gap: 12px; }
.hbar { display: grid; grid-template-columns: 116px minmax(0, 1fr); align-items: center; gap: 12px; padding: 2px 0; border-radius: 6px; font-size: 13px; }
.hbar-name { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hbar-bar { flex: none; height: 12px; border-radius: 0 4px 4px 0; background: var(--viz-accent); transition: filter .2s; }
.hbar:hover .hbar-bar, .hbar:focus-visible .hbar-bar { filter: brightness(1.1); }
/* emphasis: when a department is picked, it keeps the accent and the rest go grey */
.hbar.is-muted .hbar-bar { background: var(--viz-deemph); }
.hbar.is-muted .hbar-val { color: var(--text-3); }
.hbar-val { color: var(--text-1); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

.viz-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.viz-table th, .viz-table td { padding: 8px; border-top: 1px solid var(--line); text-align: left; }
.viz-table thead th { border-top: 0; background: var(--surface-2); color: var(--text-3); font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.viz-table tbody th { font-weight: 600; color: var(--text-2); }
.viz-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.viz-body[data-view="table"] { max-height: 320px; overflow: auto; }

.viz-tip {
  position: fixed; left: 0; top: 0; z-index: 60; display: grid; gap: 4px; min-width: 140px; padding: 10px 12px;
  border-radius: 8px; background: var(--surface); box-shadow: var(--shadow-pop);
  pointer-events: none; font-size: 12.5px;
}
.tip-head { color: var(--text-3); font-size: 12px; font-weight: 700; }
.tip-row { display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.tip-row strong { color: var(--text-1); font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; }
.tip-key { width: 12px; height: 3px; border-radius: 2px; }

.foot { color: var(--text-3); font-size: 12.5px; text-align: center; }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 70; transform: translateX(-50%); max-width: calc(100vw - 32px);
  padding: 11px 18px; border-radius: 8px; background: var(--toast-bg); color: var(--toast-text); font-weight: 700; font-size: 13.5px;
  box-shadow: 0 18px 40px -14px rgba(0, 0, 0, .45); animation: toastIn .4s var(--ease);
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ---------- Bottom navigation (phones only, shown in app mode) ---------- */
.bottom-nav { display: none; }
.bn-link { display: grid; justify-items: center; gap: 2px; min-width: 0; padding: 2px 0; color: var(--text-2); font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.bn-ic { display: grid; place-items: center; width: 100%; max-width: 56px; height: 30px; border-radius: 99px; transition: background-color .2s; }
.bn-ic .icon { width: 20px; height: 20px; }
.bn-link.is-active { color: var(--primary-text); }
.bn-link.is-active .bn-ic { background: var(--primary-soft); }
.bn-link:active .bn-ic { background: var(--surface-3); }
.theme-item { display: none; }

/* ---------- Touch ---------- */
html { -webkit-tap-highlight-color: transparent; }
button, a, .bed { touch-action: manipulation; }
.topbar, .bottom-nav, .sidebar, .btn, .menu-item { -webkit-user-select: none; user-select: none; }
.btn:active, .icon-btn:active { transform: scale(.97); }

/* ---------- Responsive (breakpoints: see .claude/rules/responsive.md) ---------- */
.scrim { position: fixed; inset: 0; z-index: 45; background: var(--scrim); }

/* lg: small laptops, tablets in landscape */
@media (max-width: 1280px) {
  .welcome { grid-column: span 7; }
  .queue { grid-column: span 5; }
  .beds, .appts { grid-column: span 12; }
  .chart-card { grid-column: span 12; }
  .panels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .uc-text { display: none; }
  .welcome-sphere { width: 160px; height: 160px; }
  .tb-new span { display: none; }
  .tb-new { padding: 0 12px; }
}

/* md: tablets in portrait, foldables unfolded — sidebar becomes a drawer */
@media (max-width: 960px) {
  .app, .app.is-collapsed { grid-template-columns: minmax(0, 1fr); --sb-w: 280px; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 50; width: 280px; padding: calc(12px + env(safe-area-inset-top, 0px)) 12px calc(12px + env(safe-area-inset-bottom, 0px)); box-shadow: var(--shadow-pop); transform: translateX(-100%); transition: transform .35s var(--ease); }
  .app.nav-open .sidebar { transform: none; }
  .sb-collapse { display: none; }
  .tb-menu { display: grid; }
  .topbar { padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; gap: 6px; }
  .content { padding: 0 16px 28px; gap: 20px; }
  .grid, .kpis, .panels { gap: 14px; }
  .welcome, .queue { grid-column: span 12; }
  .tb-search { width: 38px; padding: 0; justify-content: center; background: none; border-color: transparent; }
  .tb-search-btn { width: 38px; height: 38px; border-radius: 50%; color: var(--text-2); }
  .tb-search input, .tb-search kbd { display: none; }
  .tb-search.is-open { position: absolute; left: 12px; right: 12px; width: auto; z-index: 35; padding: 0 12px 0 0; background: var(--surface); border-color: var(--primary); }
  .tb-search.is-open input { display: block; }
}

/* sm + phones turned sideways: app mode — app bar, bottom nav, FAB, sheets, swipe rows, list rows */
@media (max-width: 599px), (max-width: 960px) and (max-height: 500px) and (orientation: landscape) {
  /* app bar */
  .tb-menu, #themeBtn, .tb-title p { display: none; }
  .theme-item { display: flex; }
  .topbar { padding: calc(8px + env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) 8px max(12px, env(safe-area-inset-left, 0px)); gap: 2px; }
  .tb-title h1 { font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .user-chip { height: 44px; padding: 0 0 0 4px; }
  .user-chip > .icon, .uc-text { display: none; }
  .topbar:has(.notif-menu:not([hidden]), .user-menu:not([hidden])) { z-index: 60; }

  /* FAB: the screen's one primary action */
  .tb-new { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(80px + env(safe-area-inset-bottom, 0px)); z-index: 41; width: 56px; height: 56px; padding: 0; justify-content: center; border-radius: 16px; box-shadow: 0 6px 16px rgba(23, 165, 137, .35), 0 2px 4px rgba(0, 0, 0, .12); }
  .tb-new .icon { width: 22px; height: 22px; }

  /* bottom navigation */
  .bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
    padding: 6px max(4px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(4px, env(safe-area-inset-left, 0px));
    background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(0, 0, 0, .06);
  }

  /* bottom sheets instead of dropdowns */
  .notif-menu, .user-menu {
    position: fixed; left: 0; right: 0; top: auto; bottom: 0; z-index: 60; width: auto; min-width: 0; max-height: 80vh; overflow-y: auto;
    padding: 24px 12px calc(12px + env(safe-area-inset-bottom, 0px)); border-radius: 20px 20px 0 0;
    box-shadow: 0 0 0 100vmax var(--scrim); animation: sheetIn .3s var(--ease);
  }
  .notif-menu::before, .user-menu::before { content: ""; position: absolute; top: 9px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 99px; background: var(--line-2); }
  .search-results { position: fixed; left: 12px; right: 12px; top: calc(62px + env(safe-area-inset-top, 0px)); width: auto; min-width: 0; }

  /* page */
  .content { padding: 4px max(12px, env(safe-area-inset-right, 0px)) calc(100px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px)); gap: 16px; }
  .grid, .panels { gap: 12px; }
  .panels { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 16px; border-radius: 14px; }
  .card-head { margin: -16px -16px 14px; padding: 12px 16px; }
  .table-wrap { margin: 0 -16px -16px; }
  .q-foot, .panel-foot { margin-inline: -16px; margin-bottom: -16px; padding-inline: 16px; border-radius: 0 0 14px 14px; }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }

  /* welcome */
  .welcome { flex-direction: column; align-items: stretch; min-height: 0; padding: 20px; }
  .welcome h2 { font-size: 24px; }
  .welcome-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .welcome-actions .btn { justify-content: center; }
  .welcome-actions .btn:first-child { grid-column: 1 / -1; }
  .welcome-sphere { display: none; }
  .queue { min-height: 0; }

  /* KPI tiles: swipe row with the next card peeking */
  .kpis { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; margin-inline: -12px; padding: 2px 12px 10px; scrollbar-width: none; overscroll-behavior-x: contain; }
  .kpis::-webkit-scrollbar { display: none; }
  .kpi { flex: 0 0 82%; scroll-snap-align: center; }

  /* appointments: list rows instead of a table */
  .appt-table, .appt-table tbody { display: block; }
  .appt-table thead, .col-doctor, .t-doctor, .appt-table .type { display: none; }
  .appt-table tr { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; column-gap: 10px; align-items: center; padding: 11px 16px; border-bottom: 1px solid var(--line); }
  .appt-table tbody tr:last-child { border-bottom: 0; }
  .appt-table td, .appt-table td:first-child, .appt-table td:last-child { padding: 0; border: 0; background: none; }
  .appt-table tbody tr:active { background: var(--surface-2); }
  .t-time { font-weight: 700; color: var(--text-1); }
  .t-patient { min-width: 0; }
  .t-patient b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* performance filters */
  .perf-head h2 { font-size: 18px; }
  .filters { width: 100%; }
  .segmented { flex: 1 1 auto; }
  .segmented button { flex: 1; padding: 0 8px; }
  .select { flex: 1 1 150px; }
  .select select { width: 100%; }
  .hbar { grid-template-columns: 96px minmax(0, 1fr); }
}
@keyframes sheetIn { from { transform: translateY(100%); } }

/* phone turned sideways: slimmer bars, app bar scrolls away, icons-only bottom nav */
@media (max-width: 960px) and (max-height: 500px) and (orientation: landscape) {
  .topbar { position: static; }
  .bottom-nav { padding-block: 4px calc(4px + env(safe-area-inset-bottom, 0px)); }
  .bn-link > span:last-child { display: none; }
  .tb-new { bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }
  .content { padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
  .kpi { flex-basis: 42%; }
  .notif-menu, .user-menu { left: auto; width: 420px; max-height: 90vh; }
}

/* xs: small Android, Galaxy Fold cover screen (280) */
@media (max-width: 360px) {
  .topbar { padding-inline: 8px; }
  .tb-title h1 { font-size: 16px; }
  .content { padding-inline: 10px; }
  .kpis { margin-inline: -10px; padding-inline: 10px; }
  .kpi { flex-basis: 86%; }
  .welcome { padding: 18px; }
  .welcome h2 { font-size: 22px; }
  .welcome-actions { grid-template-columns: minmax(0, 1fr); }
  .q-token { font-size: 30px; }
  .bn-link { font-size: 10.5px; }
  .appt-table tr { grid-template-columns: 44px minmax(0, 1fr) auto; column-gap: 8px; }
  .hbar { grid-template-columns: 80px minmax(0, 1fr); }
  .tb-new { right: 12px; }
}

/* any touch screen: tap targets at least 44px */
@media (pointer: coarse) {
  .icon-btn, .tb-search-btn { width: 44px; height: 44px; }
  .sb-link { padding-block: 10px; }
  .menu-item { padding-block: 12px; }
  .btn-sm, .segmented button, .view-toggle { height: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
