/* =============================================================
   Matrix Dental v0.2 — Phase 3 Visual System
   Light theme, Edge cyan accent #00D4FF
   ============================================================= */

:root {
  /* COLOR — EDGE CYAN ACCENT */
  --accent: #00D4FF;
  --accent-dim: #0099B8;
  --accent-soft: #7FE3FF;
  --accent-glow: rgba(0, 212, 255, 0.15);
  --accent-glow-strong: rgba(0, 212, 255, 0.30);

  /* COLOR — LIGHT SURFACES */
  --bg: #F8F9FA;
  --bg-elevated: #FFFFFF;
  --bg-subtle: #F1F3F5;
  --bg-tinted: #F0FAFE;

  /* COLOR — BORDERS */
  --border: #E5E7EB;
  --border-strong: #CBD5E1;

  /* COLOR — TEXT */
  --text: #0F172A;
  --text-dim: #475569;
  --text-muted: #94A3B8;
  --text-on-accent: #04222B;

  /* SEMANTIC */
  --success: #10B981; --success-bg: #ECFDF5; --success-border: #A7F3D0;
  --warning: #F59E0B; --warning-bg: #FFFBEB; --warning-border: #FDE68A;
  --danger:  #EF4444; --danger-bg:  #FEF2F2; --danger-border:  #FECACA;
  --info:    var(--accent);
  --info-bg: var(--bg-tinted);
  --info-border: var(--accent-soft);

  /* ROLE STRIPE COLOURS (timeline cards) */
  --role-doctor:      var(--accent);
  --role-assistant:   #14B8A6;   /* teal */
  --role-manager:     #6366F1;   /* indigo / blue */
  --role-accounts:    #84CC16;   /* lime */
  --role-coordinator: #06B6D4;   /* mint */
  --role-reception:   #C9A227;   /* gold */
  --role-cleaner:     #A855F7;   /* purple */
  --role-system:      #F97316;   /* orange */

  /* TYPE */
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body:    'Inter', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, monospace;

  /* SPACING (4px base) */
  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem;
  --space-4: 1rem;    --space-5: 1.5rem; --space-6: 2rem;
  --space-7: 3rem;

  /* RADII */
  --radius-sm: 6px;  --radius-md: 10px; --radius-lg: 14px;
  --radius-xl: 20px; --radius-pill: 999px;

  /* SHADOWS (light, cyan-tinted) */
  --shadow-xs:   0 1px 2px rgba(15,23,42,0.04);
  --shadow-sm:   0 1px 3px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
  --shadow-md:   0 4px 12px rgba(15,23,42,0.06), 0 2px 4px rgba(15,23,42,0.04);
  --shadow-lg:   0 12px 32px rgba(15,23,42,0.08), 0 4px 8px rgba(15,23,42,0.04);
  --shadow-cyan: 0 4px 16px var(--accent-glow);
  --shadow-focus:0 0 0 3px var(--accent-glow-strong);

  /* MOTION */
  --ease-out:    cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast: 120ms; --dur-base: 200ms; --dur-slow: 320ms;

  --tap-target: 44px;

  /* LAYOUT TOKENS */
  --topbar-h: 56px;
  --cmdbar-h: 44px;
  --gutter: 24px;
}

/* =============================================================
   RESET / BASE
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1,h2,h3,h4,h5 { font-family: var(--font-display); margin: 0; font-weight: 600; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
:focus-visible { outline: none; box-shadow: var(--shadow-focus); border-radius: var(--radius-sm); }

/* =============================================================
   TOPBAR
   ============================================================= */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-5);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.topbar__brand { display: flex; align-items: center; gap: var(--space-3); }
.topbar__logo { display: flex; }
.topbar__title { line-height: 1.15; }
.topbar__name { font-family: var(--font-display); font-weight: 700; font-size: 15px; color: var(--text); }
.topbar__sub  { font-size: 11px; color: var(--text-muted); }

.topbar__center { text-align: center; }
.topbar__clock { font-family: var(--font-mono); font-size: 17px; font-weight: 500; color: var(--text); letter-spacing: 0.5px; }
.topbar__date  { font-size: 11px; color: var(--text-muted); }

.topbar__right { display: flex; align-items: center; gap: var(--space-3); justify-content: flex-end; }

.conn { display: inline-flex; align-items: center; gap: var(--space-2); font-size: 12px; color: var(--text-dim); padding: 4px 10px; border-radius: var(--radius-pill); background: var(--bg-subtle); }
.conn__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.conn__dot--ok       { background: var(--success); box-shadow: 0 0 0 3px rgba(16,185,129,0.18); }
.conn__dot--degraded { background: var(--warning); box-shadow: 0 0 0 3px rgba(245,158,11,0.18); }
.conn__dot--down     { background: var(--danger);  box-shadow: 0 0 0 3px rgba(239,68,68,0.18); }
.conn__dot--checking { background: var(--text-muted); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 0.4; } 50% { opacity: 1; } }

.role-switcher { display: inline-flex; align-items: center; gap: var(--space-2); }
.role-switcher__label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.role-switcher__select {
  appearance: none; -webkit-appearance: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 6px 28px 6px 10px;
  font-size: 13px; font-weight: 500;
  color: var(--text);
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2.5' stroke-linecap='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: border-color var(--dur-fast) var(--ease-out);
}
.role-switcher__select:hover { border-color: var(--accent); }

/* =============================================================
   OFFLINE BANNER
   ============================================================= */
.offline-banner {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 8px 16px;
  background: var(--warning-bg);
  border-bottom: 1px solid var(--warning-border);
  color: #92400E;
  font-weight: 500; font-size: 13px;
}
.offline-banner__icon { font-size: 16px; }

/* =============================================================
   COMMAND BAR (Layer 2)
   ============================================================= */
.cmdbar {
  position: sticky;
  top: var(--topbar-h);
  z-index: 40;
  display: flex; align-items: center; gap: var(--space-3);
  margin: var(--space-4) var(--gutter) 0;
  padding: 0 var(--space-3);
  height: var(--cmdbar-h);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out);
}
.cmdbar:focus-within {
  border-color: var(--accent);
  box-shadow: var(--shadow-cyan);
}
.cmdbar__mic {
  flex: 0 0 auto;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg-subtle);
  color: var(--text-dim);
  display: inline-flex; align-items: center; justify-content: center;
  transition: all var(--dur-fast) var(--ease-out);
}
.cmdbar__mic:hover { background: var(--bg-tinted); color: var(--accent-dim); }
.cmdbar__mic.is-armed   { background: var(--accent-glow); color: var(--accent-dim); }
.cmdbar__mic.is-recording { background: var(--accent); color: var(--text-on-accent); animation: pulse-cyan 1s ease-in-out infinite; }
@keyframes pulse-cyan {
  0%,100% { box-shadow: 0 0 0 0 var(--accent-glow-strong); }
  50%     { box-shadow: 0 0 0 8px transparent; }
}

.cmdbar__input {
  flex: 1 1 auto;
  height: 100%;
  border: none; background: transparent;
  font-size: 14px; color: var(--text);
  outline: none;
}
.cmdbar__input::placeholder { color: var(--text-muted); }

.cmdbar__pills { display: flex; gap: 6px; }
.ctx-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 4px 4px 10px;
  background: var(--bg-tinted);
  border: 1px solid var(--accent-soft);
  border-radius: var(--radius-pill);
  font-size: 12px; color: var(--accent-dim);
  font-weight: 500;
}
.ctx-pill__icon { color: var(--accent); }
.ctx-pill__close {
  width: 20px; height: 20px;
  border: none; background: transparent;
  color: var(--accent-dim);
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1;
}
.ctx-pill__close:hover { background: var(--accent-glow); }

.cmdbar__hint {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  padding: 2px 6px; border-radius: var(--radius-sm);
}

/* Command result panel */
.cmd-panel {
  position: relative;
  margin: var(--space-2) var(--gutter) 0;
  background: var(--bg-elevated);
  border: 1px solid var(--accent-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  max-height: 400px;
  overflow: hidden;
  display: flex; flex-direction: column;
  animation: slideDown var(--dur-base) var(--ease-out);
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.cmd-panel__header {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--bg-tinted);
}
.cmd-panel__title { font-family: var(--font-display); font-weight: 600; color: var(--accent-dim); font-size: 13px; }
.cmd-panel__close {
  width: 28px; height: 28px; border: none; background: transparent; color: var(--text-dim); border-radius: 50%; font-size: 18px;
}
.cmd-panel__close:hover { background: var(--bg-subtle); }
.cmd-panel__body { padding: var(--space-4); overflow-y: auto; font-size: 13px; line-height: 1.55; color: var(--text); }
.cmd-panel__body pre { font-family: var(--font-mono); font-size: 12px; background: var(--bg-subtle); padding: var(--space-3); border-radius: var(--radius-md); overflow-x: auto; }

/* =============================================================
   SCREEN / LAYOUT
   ============================================================= */
.screen {
  padding: var(--space-4) var(--gutter) var(--space-7);
  min-height: calc(100vh - var(--topbar-h) - var(--cmdbar-h));
}

.screen-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin: var(--space-4) 0 var(--space-5);
  gap: var(--space-4);
  flex-wrap: wrap;
}
.screen-header__title { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; color: var(--text); }
.screen-header__sub   { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.screen-header__meta  { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* Generic card */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  padding: var(--space-5);
}
.card--accent { border-color: var(--accent-soft); background: linear-gradient(180deg, var(--bg-tinted) 0%, var(--bg-elevated) 60%); }
.card--flat   { box-shadow: none; }
.card__title  { font-family: var(--font-display); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: var(--space-3); }

/* Pills */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 600;
  background: var(--bg-subtle); color: var(--text-dim);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.pill::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; flex: 0 0 6px;
}
.pill--info     { background: var(--info-bg);     color: var(--accent-dim); border-color: var(--info-border); }
.pill--accent   { background: var(--accent);      color: var(--text-on-accent); border-color: var(--accent); }
.pill--success  { background: var(--success-bg);  color: #047857;        border-color: var(--success-border); }
.pill--warning  { background: var(--warning-bg);  color: #92400E;        border-color: var(--warning-border); }
.pill--danger   { background: var(--danger-bg);   color: #B91C1C;        border-color: var(--danger-border); }
.pill--ghost    { background: transparent; color: var(--text-dim); border-color: var(--border-strong); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--tap-target); min-width: var(--tap-target);
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-weight: 600; font-size: 13px;
  background: var(--bg-elevated); color: var(--text);
  border-color: var(--border-strong);
  transition: all var(--dur-fast) var(--ease-out);
}
.btn:hover { border-color: var(--accent); background: var(--bg-tinted); }
.btn--accent  { background: var(--accent); color: var(--text-on-accent); border-color: var(--accent); }
.btn--accent:hover { background: var(--accent-dim); border-color: var(--accent-dim); color: #fff; }
.btn--success { background: var(--success); color: #fff; border-color: var(--success); }
.btn--success:hover { filter: brightness(0.95); }
.btn--danger  { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn--ghost   { background: transparent; color: var(--text-dim); border-color: var(--border); }
.btn--lg      { height: 56px; font-size: 15px; padding: 0 var(--space-5); }
.btn--xl      { height: 80px; font-size: 17px; padding: 0 var(--space-6); border-radius: var(--radius-lg); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elevated); color: var(--text-dim);
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { color: var(--accent-dim); border-color: var(--accent); }

/* =============================================================
   DOCTOR — chair list / review queue
   ============================================================= */
.doctor-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) 2fr;
  gap: var(--space-5);
}
@media (max-width: 900px) { .doctor-grid { grid-template-columns: 1fr; } }

.chair-list { display: flex; flex-direction: column; gap: var(--space-2); }
.chair-item {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border-strong);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.chair-item:hover { border-left-color: var(--accent); box-shadow: var(--shadow-sm); transform: translateX(2px); }
.chair-item.is-current { border-left-color: var(--accent); background: var(--bg-tinted); }
.chair-item.is-done    { opacity: 0.55; }
.chair-item__time { font-family: var(--font-mono); font-weight: 600; color: var(--text-dim); font-size: 13px; }
.chair-item__name { font-weight: 600; color: var(--text); }
.chair-item__sub  { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.chair-item__flags { display: flex; gap: 4px; flex-wrap: wrap; }

.review-queue { display: flex; flex-direction: column; gap: var(--space-3); }
.review-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform var(--dur-base) var(--ease-out), opacity var(--dur-base) var(--ease-out);
}
.review-card.is-dismissed { transform: translateX(-120%); opacity: 0; }
.review-card__header {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  font-size: 12px; color: var(--text-dim);
}
.review-card__type { font-family: var(--font-display); font-weight: 600; color: var(--text); font-size: 13px; }
.review-card__body { padding: var(--space-4); font-size: 13px; line-height: 1.6; color: var(--text); }
.review-card__body pre { font-family: var(--font-mono); font-size: 12px; background: var(--bg-subtle); padding: var(--space-3); border-radius: var(--radius-md); white-space: pre-wrap; }
.review-card__footer {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  background: var(--bg-subtle);
  font-size: 11px; color: var(--text-muted);
  border-top: 1px solid var(--border);
}
.review-card__actions {
  display: flex;
  height: 56px;
  border-top: 1px solid var(--border);
}
.review-card__actions .btn {
  flex: 1; height: 100%; border-radius: 0; border: none;
  border-right: 1px solid var(--border);
}
.review-card__actions .btn:last-child { border-right: none; }

.review-card__readbar {
  height: 4px; background: var(--bg-subtle); position: relative; overflow: hidden;
}
.review-card__readbar-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--warning), var(--accent));
  transition: width 3s linear;
}
.review-card[data-risk="high"] .review-card__readbar-fill { background: linear-gradient(90deg, var(--danger), var(--warning)); }

/* =============================================================
   ASSISTANT
   ============================================================= */
.assistant-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-5);
}
@media (max-width: 900px) { .assistant-grid { grid-template-columns: 1fr; } }
.chair-status-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3);
}
.chair-tile {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  background: var(--bg-elevated);
  text-align: center;
  font-weight: 600;
}
.chair-tile--ready { border-color: var(--success); background: var(--success-bg); color: #047857; }
.chair-tile--occupied { border-color: var(--accent); background: var(--bg-tinted); color: var(--accent-dim); }
.chair-tile--turnover { border-color: var(--warning); background: var(--warning-bg); color: #92400E; }
.chair-tile__sub { font-size: 11px; font-weight: 500; margin-top: 4px; opacity: 0.85; }

.chairside-cta { padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-3); align-items: center; }

/* Chair-side iPad mid-procedure quiet mode */
.chairside {
  position: fixed; inset: 0;
  background: #FAFBFC;
  display: flex; flex-direction: column;
  z-index: 80;
}
.chairside__header {
  height: 64px;
  border-bottom: 4px solid var(--accent);
  display: flex; align-items: center;
  padding: 0 var(--space-5);
  gap: var(--space-4);
  background: #fff;
}
.chairside__patient { font-family: var(--font-display); font-size: 18px; font-weight: 600; color: var(--text); }
.chairside__procedure { color: var(--text-dim); font-size: 14px; }
.chairside__exit { margin-left: auto; }

.chairside__body {
  flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-5);
  padding: var(--space-5);
  overflow: hidden;
}
.chairside__pane { background: #fff; border-radius: var(--radius-lg); padding: var(--space-5); overflow-y: auto; }
.chairside__pane h3 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: var(--space-3); }
.chairside__transcript { font-family: var(--font-mono); font-size: 14px; line-height: 1.8; color: var(--text-dim); white-space: pre-wrap; }
.chairside__transcript .live { color: var(--text); background: var(--bg-tinted); padding: 2px 4px; }

.chairside__actionbar {
  height: 88px;
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--space-5);
}
.chairside__ptt {
  width: 96px; height: 96px;
  border-radius: 50%;
  border: none;
  background: var(--accent-glow);
  color: var(--accent-dim);
  display: inline-flex; align-items: center; justify-content: center;
  margin-top: -32px;
  box-shadow: var(--shadow-md);
  font-size: 36px;
  transition: all var(--dur-base) var(--ease-out);
}
.chairside__ptt.is-recording {
  background: var(--accent);
  color: var(--text-on-accent);
  animation: pulse-cyan 1.2s ease-in-out infinite;
}
.chairside__action-btn {
  min-width: 200px; height: 80px;
  font-size: 17px; font-weight: 600;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-strong);
  background: #fff; color: var(--text);
}
.chairside__action-btn--alert { border-color: var(--warning); color: #92400E; background: var(--warning-bg); }
.chairside__action-btn--end   { border-color: var(--danger);  color: var(--danger); }

/* =============================================================
   PRACTICE MANAGER — pulse view
   ============================================================= */
.pulse-view { display: flex; flex-direction: column; gap: var(--space-4); }
.pulse-band {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}
.pulse-band__head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: var(--space-3);
}
.pulse-band__title { font-family: var(--font-display); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }

.staff-dots { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: var(--space-2); }
.staff-dot {
  display: flex; align-items: center; gap: var(--space-2);
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  font-size: 12px;
  font-weight: 500;
}
.staff-dot__avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--bg-tinted); color: var(--accent-dim);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 600;
  border: 2px solid var(--success);
}
.staff-dot[data-status="break"] .staff-dot__avatar { border-color: var(--warning); }
.staff-dot[data-status="off"]   .staff-dot__avatar { border-color: var(--text-muted); }
.staff-dot[data-status="busy"]  .staff-dot__avatar { border-color: var(--accent); }

.flow-river {
  position: relative;
  height: 80px;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
}
.flow-slot {
  flex: 1;
  border-right: 1px solid var(--border);
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 10px; color: var(--text-muted);
}
.flow-slot.is-booked { background: var(--bg-tinted); color: var(--accent-dim); }
.flow-slot.is-at-risk {
  background: var(--warning-bg); color: #92400E;
  animation: glow-warning 2s ease-in-out infinite;
}
@keyframes glow-warning { 0%,100% { box-shadow: inset 0 0 0 0 var(--warning); } 50% { box-shadow: inset 0 0 0 2px var(--warning); } }
.flow-slot__label { font-weight: 600; font-size: 11px; }
.flow-slot__time  { font-family: var(--font-mono); }
.flow-now {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}
.flow-now::after {
  content: "NOW";
  position: absolute; top: -16px; left: -14px;
  font-family: var(--font-mono); font-size: 9px; font-weight: 700;
  color: var(--accent-dim);
  background: var(--bg-tinted);
  padding: 1px 4px; border-radius: 4px;
}

.exception-feed { display: flex; flex-direction: column; gap: var(--space-2); }
.exception-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  font-size: 13px;
}
.exception-item__icon { font-size: 16px; }
.exception-item__time { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); margin-left: auto; }

/* =============================================================
   ACCOUNTS
   ============================================================= */
.accounts-grid { display: flex; flex-direction: column; gap: var(--space-4); }
.money-headline {
  background: linear-gradient(135deg, var(--bg-tinted) 0%, var(--bg-elevated) 100%);
  border: 1px solid var(--accent-soft);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: grid; grid-template-columns: 1fr auto; align-items: center;
  gap: var(--space-4);
}
.money-headline__big {
  font-family: var(--font-display); font-weight: 700;
  font-size: 36px;
  color: var(--accent-dim);
  letter-spacing: -0.02em;
}
.money-headline__sub { font-size: 13px; color: var(--text-dim); margin-top: 4px; }

.stuck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--space-3); }
.stuck-card {
  padding: var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 4px solid var(--warning);
  border-radius: var(--radius-md);
}
.stuck-card[data-severity="high"]   { border-left-color: var(--danger); }
.stuck-card[data-severity="medium"] { border-left-color: var(--warning); }
.stuck-card[data-severity="low"]    { border-left-color: var(--accent); }
.stuck-card__title { font-weight: 600; color: var(--text); margin-bottom: 4px; }
.stuck-card__amount { font-family: var(--font-mono); font-size: 18px; font-weight: 600; color: var(--text); margin: var(--space-2) 0; }
.stuck-card__sub { font-size: 12px; color: var(--text-dim); }
.stuck-card__action { margin-top: var(--space-3); }

/* =============================================================
   TREATMENT COORDINATOR — Kanban
   ============================================================= */
.kanban {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr);
  gap: var(--space-3);
  overflow-x: auto;
  padding-bottom: var(--space-3);
}
.kanban-col {
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  display: flex; flex-direction: column;
  min-height: 300px;
}
.kanban-col__head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: var(--space-3);
}
.kanban-col__title { font-family: var(--font-display); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); }
.kanban-col__count { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); background: var(--bg-elevated); padding: 1px 8px; border-radius: var(--radius-pill); }

.kanban-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-2);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.kanban-card:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.kanban-card[data-doc="bhamjee"]   { border-left-color: var(--accent); }
.kanban-card[data-doc="vorster"]   { border-left-color: var(--role-coordinator); }
.kanban-card[data-doc="haffajee"]  { border-left-color: var(--role-manager); }
.kanban-card[data-doc="mayet"]     { border-left-color: var(--role-cleaner); }
.kanban-card[data-doc="chrismarie"]{ border-left-color: var(--role-reception); }
.kanban-card__name { font-weight: 600; color: var(--text); font-size: 13px; }
.kanban-card__sub  { font-size: 11px; color: var(--text-dim); margin-top: 4px; }
.kanban-card__age  { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.kanban-card__age.is-stale { color: var(--warning); font-weight: 600; }

/* =============================================================
   RECEPTION
   ============================================================= */
.reception-grid { display: grid; grid-template-rows: 1fr 1fr; gap: var(--space-4); height: calc(100vh - 200px); min-height: 600px; }

.wa-swimlanes {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3);
  height: 100%;
  overflow: hidden;
}
.wa-lane {
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.wa-lane__head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: var(--space-3);
}
.wa-lane__title { font-family: var(--font-display); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); }
.wa-lane__list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: var(--space-2); }

.wa-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  font-size: 12px;
}
.wa-card__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.wa-card__name { font-weight: 600; color: var(--text); }
.wa-card__time { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); }
.wa-card__msg { color: var(--text-dim); margin-bottom: var(--space-2); font-style: italic; padding-left: 8px; border-left: 2px solid var(--border-strong); }
.wa-card__draft { background: var(--bg-tinted); padding: var(--space-2); border-radius: var(--radius-sm); border: 1px dashed var(--accent-soft); color: var(--text); margin-bottom: var(--space-2); }
.wa-card__actions { display: flex; gap: 6px; }
.wa-card__actions .btn { height: 32px; min-width: 32px; padding: 0 var(--space-3); font-size: 12px; }

.diary-list { display: flex; flex-direction: column; gap: 4px; }
.diary-row {
  display: grid;
  grid-template-columns: 64px 1fr auto auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
}
.diary-row__time { font-family: var(--font-mono); color: var(--text-dim); font-weight: 500; }
.diary-row__name { font-weight: 500; color: var(--text); }
.diary-row__sub  { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

.caller-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 90;
  animation: fadeIn var(--dur-base) var(--ease-out);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.caller-overlay__card {
  background: var(--bg-elevated);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  text-align: center;
  min-width: 360px;
  box-shadow: var(--shadow-lg);
  animation: pop var(--dur-slow) var(--ease-spring);
}
@keyframes pop { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.caller-overlay__icon { font-size: 56px; margin-bottom: var(--space-3); color: var(--accent); }
.caller-overlay__name { font-family: var(--font-display); font-size: 24px; font-weight: 600; color: var(--text); }
.caller-overlay__sub  { font-size: 13px; color: var(--text-dim); margin-top: 4px; margin-bottom: var(--space-5); }
.caller-overlay__actions { display: flex; gap: var(--space-2); }
.caller-overlay__btn { flex: 1; }

/* =============================================================
   CLEANER — room board
   ============================================================= */
.room-board {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-3);
}
.room-tile {
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  min-height: 120px;
  display: flex; flex-direction: column; justify-content: space-between;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.room-tile:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.room-tile[data-status="clean"] { border-color: var(--success); background: var(--success-bg); }
.room-tile[data-status="needs-turnover"] { border-color: var(--warning); background: var(--warning-bg); }
.room-tile[data-status="dirty"] { border-color: var(--danger); background: var(--danger-bg); }
.room-tile__name  { font-family: var(--font-display); font-weight: 600; font-size: 16px; color: var(--text); }
.room-tile__status { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.room-tile__icon  { font-size: 28px; align-self: flex-end; }

.turnover-checklist { display: flex; flex-direction: column; gap: var(--space-2); }
.turnover-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  min-height: 64px;
}
.turnover-item.is-done { background: var(--success-bg); border-color: var(--success-border); text-decoration: line-through; color: var(--text-dim); }
.turnover-item input[type="checkbox"] { width: 24px; height: 24px; accent-color: var(--accent); }

/* =============================================================
   PATIENT TIMELINE DRAWER
   ============================================================= */
.drawer {
  position: fixed; inset: 0; z-index: 70;
}
.drawer[hidden] { display: none; }
.drawer__backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  animation: fadeIn var(--dur-base) var(--ease-out);
}
.drawer__panel {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: min(640px, 100%);
  background: var(--bg);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideInRight var(--dur-slow) var(--ease-out);
}
@keyframes slideInRight { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.drawer__header {
  position: sticky; top: 0; z-index: 2;
  min-height: 96px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  padding: var(--space-4);
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: var(--space-3);
  align-items: center;
}
.patient-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--bg-tinted); color: var(--accent-dim);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 600; font-size: 20px;
  border: 2px solid var(--accent-soft);
}
.patient-meta__name { font-family: var(--font-display); font-weight: 700; font-size: 18px; color: var(--text); }
.patient-meta__line { font-size: 12px; color: var(--text-dim); }
.patient-flags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }

.drawer__close {
  position: absolute; top: 12px; right: 12px;
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  font-size: 20px; color: var(--text-dim);
}

.drawer__ribbon {
  display: flex; gap: 0;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  align-items: center;
}
.case-step {
  flex: 1;
  display: flex; flex-direction: column; align-items: center;
  position: relative;
  color: var(--text-muted);
  font-weight: 500;
}
.case-step::before {
  content: ""; width: 16px; height: 16px; border-radius: 50%;
  background: var(--bg-elevated);
  border: 2px solid var(--border-strong);
  margin-bottom: 4px;
}
.case-step:not(:last-child)::after {
  content: ""; position: absolute; top: 7px; left: 50%; right: -50%;
  height: 2px; background: var(--border-strong);
  z-index: 0;
}
.case-step.is-done { color: var(--text-dim); }
.case-step.is-done::before { background: var(--success); border-color: var(--success); }
.case-step.is-current { color: var(--accent-dim); font-weight: 600; }
.case-step.is-current::before { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-glow); }

.drawer__body {
  flex: 1; overflow-y: auto;
  padding: var(--space-4);
  display: flex; flex-direction: column;
  gap: var(--space-3);
}

.timeline-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  border-left: 8px solid var(--role-doctor);
  display: flex; flex-direction: column;
  gap: var(--space-2);
  min-height: 88px;
}
.timeline-card[data-role="doctor"]      { border-left-color: var(--role-doctor); }
.timeline-card[data-role="assistant"]   { border-left-color: var(--role-assistant); }
.timeline-card[data-role="manager"]     { border-left-color: var(--role-manager); }
.timeline-card[data-role="accounts"]    { border-left-color: var(--role-accounts); }
.timeline-card[data-role="coordinator"] { border-left-color: var(--role-coordinator); }
.timeline-card[data-role="reception"]   { border-left-color: var(--role-reception); }
.timeline-card[data-role="cleaner"]     { border-left-color: var(--role-cleaner); }
.timeline-card[data-role="system"]      { border-left-color: var(--role-system); }

.timeline-card__head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: var(--text-muted);
}
.timeline-card__type { font-family: var(--font-display); font-weight: 600; font-size: 12px; color: var(--text); text-transform: uppercase; letter-spacing: 0.04em; }
.timeline-card__body { font-size: 13px; color: var(--text); line-height: 1.55; }
.timeline-card__body pre { font-family: var(--font-mono); font-size: 12px; white-space: pre-wrap; }

/* =============================================================
   TOASTS
   ============================================================= */
.toasts {
  position: fixed; bottom: var(--space-5); right: var(--space-5);
  display: flex; flex-direction: column; gap: var(--space-2);
  z-index: 100;
  pointer-events: none;
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--space-3) var(--space-4);
  font-size: 13px;
  pointer-events: auto;
  min-width: 240px;
  animation: slideUp var(--dur-base) var(--ease-out);
}
@keyframes slideUp { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.toast--success { border-left-color: var(--success); }
.toast--warning { border-left-color: var(--warning); }
.toast--danger  { border-left-color: var(--danger); }

/* =============================================================
   UTILITIES
   ============================================================= */
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.mono { font-family: var(--font-mono); }
.row { display: flex; align-items: center; gap: var(--space-2); }
.stack { display: flex; flex-direction: column; gap: var(--space-2); }
.stack-3 { gap: var(--space-3); }
.spacer { flex: 1; }
.hidden, [hidden] { display: none !important; }

/* Responsive: collapse topbar center on narrow */
@media (max-width: 720px) {
  :root { --gutter: 12px; }
  .topbar { grid-template-columns: 1fr auto; }
  .topbar__center { display: none; }
  .topbar__sub { display: none; }
  .role-switcher__label { display: none; }
  .doctor-grid { grid-template-columns: 1fr; }
  .money-headline { grid-template-columns: 1fr; }
  .money-headline__big { font-size: 28px; }
  .reception-grid { grid-template-rows: auto auto; height: auto; }
  .wa-swimlanes { grid-template-columns: 1fr; height: auto; }
  .chairside__body { grid-template-columns: 1fr; }
}

/* Print/audit clean */
@media print {
  .topbar, .cmdbar, .toasts, .drawer__close { display: none; }
}
