/* Clinic Agent — minimal black & white UI. One accent per clinic (--accent) marks focus only:
   active nav, primary actions, selections, focus rings, the lead chart series. */

/* ---------- tokens ---------- */
:root {
  color-scheme: light;
  --canvas: #F4F4F5;
  --surface: #FFFFFF;
  --surface-2: #F7F7F8;
  --ink: #0A0A0A;
  --text: #18181B;
  --muted: #64646C;
  --line: #E7E7EA;
  --line-strong: #D4D4D8;

  --accent: #0A0A0A;
  --on-accent: #FFFFFF;

  --ok: #15803D;   --ok-soft: #ECFDF3;
  --warn: #A16207; --warn-soft: #FEF9E7;
  --bad: #B91C1C;  --bad-soft: #FEF2F2;
  --info: #1D4ED8; --info-soft: #EFF4FF;
  --off: #52525B;  --off-soft: #F1F1F3;

  --series-2: #B4B4BC;

  --r-lg: 18px; --r-md: 12px; --r-sm: 8px;
  --shadow: 0 1px 2px rgba(10, 10, 10, .04), 0 1px 1px rgba(10, 10, 10, .02);
  --shadow-pop: 0 8px 24px rgba(10, 10, 10, .12);
  --ease: cubic-bezier(.2, .8, .2, 1);
}
/* Dark: follows the device unless the viewer picked a theme (data-theme on <html>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --canvas: #0A0A0A;
    --surface: #141414;
    --surface-2: #1B1B1C;
    --ink: #FAFAFA;
    --text: #F4F4F5;
    --muted: #A1A1AA;
    --line: #262628;
    --line-strong: #36363A;
    --accent: #FAFAFA;
    --on-accent: #0A0A0A;
    --ok: #4ADE80;   --ok-soft: #10261A;
    --warn: #FACC15; --warn-soft: #2A2410;
    --bad: #F87171;  --bad-soft: #2C1414;
    --info: #93B4FF; --info-soft: #141D33;
    --off: #A1A1AA;  --off-soft: #1F1F22;
    --series-2: #4B4B52;
    --shadow: none;
    --shadow-pop: 0 8px 24px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #0A0A0A;
  --surface: #141414;
  --surface-2: #1B1B1C;
  --ink: #FAFAFA;
  --text: #F4F4F5;
  --muted: #A1A1AA;
  --line: #262628;
  --line-strong: #36363A;
  --accent: #FAFAFA;
  --on-accent: #0A0A0A;
  --ok: #4ADE80;   --ok-soft: #10261A;
  --warn: #FACC15; --warn-soft: #2A2410;
  --bad: #F87171;  --bad-soft: #2C1414;
  --info: #93B4FF; --info-soft: #141D33;
  --off: #A1A1AA;  --off-soft: #1F1F22;
  --series-2: #4B4B52;
  --shadow: none;
  --shadow-pop: 0 8px 24px rgba(0, 0, 0, .5);
}
/* Derived from --accent wherever it is set (root or a clinic's inline style on <body>). */
body { --accent-soft: color-mix(in srgb, var(--accent) 9%, transparent);
       --ring: color-mix(in srgb, var(--accent) 45%, transparent);
       --series-1: var(--accent); }

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--canvas); color: var(--text);
  font-family: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  font-size: 15px; line-height: 1.6;
}
a { color: inherit; text-decoration: none; }
p a, .flash a, dd a, td a, .link, .known-doc a, .muted a { color: var(--text); text-decoration: underline;
  text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
p a:hover, .flash a:hover, dd a:hover, td a:hover, .muted a:hover { text-decoration-color: currentColor; }
td a.btn { text-decoration: none; }
h1 { font-size: 1.65rem; line-height: 1.25; font-weight: 700; letter-spacing: -.01em; margin: 0 0 1.25rem;
     display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; color: var(--ink); }
h2 { font-size: 1.05rem; font-weight: 700; margin: 0 0 1rem; color: var(--ink); }
h3 { font-size: .95rem; font-weight: 600; margin: 0; display: flex; gap: .5rem; align-items: center; color: var(--ink); }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; }
.ic { flex: 0 0 auto; vertical-align: middle; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.skip { position: absolute; inset-inline-start: 1rem; top: -3rem; background: var(--ink); color: var(--canvas);
        padding: .5rem 1rem; border-radius: var(--r-sm); z-index: 100; }
.skip:focus { top: 1rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 1rem;
  background: var(--surface); border-inline-end: 1px solid var(--line); padding: 1.1rem .9rem;
}
.brand { display: flex; align-items: center; gap: .65rem; padding: .35rem .45rem; border-radius: var(--r-md); }
.brand:hover { background: var(--surface-2); }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.brand-text strong { font-size: .95rem; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; flex: 0 0 auto;
        background: var(--accent); color: var(--on-accent); }
.logo.big { width: 52px; height: 52px; border-radius: 15px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.side-label { font-size: .72rem; font-weight: 600; color: var(--muted); padding: .25rem .7rem .4rem; letter-spacing: .02em; }
.side-nav a {
  display: flex; align-items: center; gap: .7rem; padding: .62rem .75rem; border-radius: var(--r-md);
  color: var(--muted); font-weight: 500; transition: background .15s var(--ease), color .15s var(--ease);
}
.side-nav a:hover { background: var(--surface-2); color: var(--ink); }
.side-nav a.on { background: var(--accent); color: var(--on-accent); }
.side-nav a .count { margin-inline-start: auto; }
.count { display: inline-block; min-width: 1.4em; padding: 0 .4em; border-radius: 99px; background: var(--bad); color: #fff;
         font-size: .72rem; font-weight: 700; text-align: center; line-height: 1.6; }
.count[hidden] { display: none; }
.side-nav a.on .count { background: var(--on-accent); color: var(--accent); }
.side-foot { display: flex; align-items: center; gap: .4rem; border-top: 1px solid var(--line); padding-top: .9rem; }
.me-card { display: flex; align-items: center; gap: .6rem; flex: 1; min-width: 0; padding: .35rem .45rem; border-radius: var(--r-md); }
.me-card:hover { background: var(--surface-2); }
.me-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.me-text strong { font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-md); cursor: pointer;
            border: 1px solid transparent; background: transparent; color: var(--muted); }
.theme-btn span { display: inline-flex; }
.theme-btn .t-light, .theme-btn .t-dark { display: none; }
:root[data-theme="light"] .theme-btn .t-auto, :root[data-theme="dark"] .theme-btn .t-auto { display: none; }
:root[data-theme="light"] .theme-btn .t-light, :root[data-theme="dark"] .theme-btn .t-dark { display: inline-flex; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.main-col { min-width: 0; display: flex; flex-direction: column; }
.page { width: 100%; max-width: 1240px; margin: 0 auto; padding: 2rem 2rem 4rem; }
.page.wide { max-width: 1520px; }
.inline { display: inline; margin: 0; }

.banner { display: flex; gap: .5rem; align-items: center; padding: .7rem 2rem; font-weight: 500; font-size: .92rem; border-bottom: 1px solid var(--line); }
.banner.danger { background: var(--bad-soft); color: var(--bad); }
.banner.warning { background: var(--warn-soft); color: var(--warn); }
.banner.info { background: var(--info-soft); color: var(--info); }

@media (max-width: 960px) {
  .app { display: block; }
  .sidebar { position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; flex-wrap: wrap; gap: .5rem;
             padding: .6rem 16px; border-inline-end: 0; border-bottom: 1px solid var(--line); }
  .brand { flex: 1; min-width: 0; }
  .brand-text .small { display: none; }
  .side-foot { border: 0; padding: 0; }
  .me-text { display: none; }
  .side-nav { order: 3; flex: 1 1 100%; flex-direction: row; overflow-x: auto; gap: .25rem; padding-bottom: .1rem; }
  .side-label { display: none; }
  .side-nav a { white-space: nowrap; padding: .45rem .7rem; }
  .page { padding: 1.25rem 16px 3rem; }
  .banner { padding: .65rem 16px; }
}

/* ---------- page head & layout helpers ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head h1, .page-head h2 { margin: 0; }
.card > .page-head { margin-bottom: .9rem; }
.grid.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); gap: 1rem; margin-bottom: 1rem; }
.grid.two > * { min-width: 0; }
.grid.two > .card { margin-bottom: 0; }
.stack { display: flex; flex-direction: column; gap: .9rem; }
.stack fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .9rem; min-width: 0; }
.row { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; min-width: 0; }
.row > .btn { flex: 0 0 auto; }
.row.wrap > * { flex-basis: 160px; }
.row-inline { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.pad { padding: 1.25rem; margin: 0; }
.pad-sm { padding: .7rem; margin: 0; border-bottom: 1px solid var(--line); }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.35rem;
        margin-bottom: 1rem; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow-x: auto; }
.card.narrow { max-width: 600px; }
.card > h2.pad { margin: 0; padding: 1.2rem 1.35rem .4rem; }

/* ---------- forms ---------- */
label { display: flex; flex-direction: column; gap: .35rem; font-weight: 500; font-size: .88rem; color: var(--text); }
label.check { flex-direction: row; align-items: center; gap: .55rem; cursor: pointer; }
input, select, textarea {
  font: inherit; font-size: .95rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r-md); padding: .6rem .8rem; width: 100%; min-height: 42px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); margin: 0; flex: 0 0 auto; }
input[type=color] { padding: 3px; width: 46px; height: 42px; cursor: pointer; }
fieldset:disabled { opacity: .6; }
textarea { resize: vertical; line-height: 1.6; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 42px;
  font: inherit; font-weight: 600; font-size: .9rem; padding: .55rem 1.05rem; border-radius: var(--r-md); cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); white-space: nowrap;
  transition: background .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease);
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.small { min-height: 34px; padding: .3rem .75rem; font-size: .84rem; border-radius: 10px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 86%, var(--canvas)); }
.btn.success { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.full { width: 100%; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.success, :root:not([data-theme="light"]) .btn.danger { color: #0A0A0A; } }
:root[data-theme="dark"] .btn.success, :root[data-theme="dark"] .btn.danger { color: #0A0A0A; }
.danger-text { color: var(--bad) !important; }
.warn-text { color: var(--warn); }
button.x { border: 0; background: none; color: inherit; cursor: pointer; font-size: 1.1rem; line-height: 1; padding: 0 .2rem; opacity: .55; }
button.x:hover { opacity: 1; color: var(--bad); }

/* segmented control (pills) */
.seg { display: inline-flex; gap: .2rem; background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
       padding: .25rem; flex-wrap: wrap; }
.seg a { display: inline-flex; align-items: center; gap: .35rem; padding: .38rem .95rem; border-radius: 999px; color: var(--muted);
         font-size: .88rem; font-weight: 500; }
.seg a:hover { color: var(--ink); background: var(--surface-2); }
.seg a.on { background: var(--accent); color: var(--on-accent); }
.page-head + .seg, h1 + .seg { margin-bottom: 1rem; }

.filters { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; align-items: center; }
.filters input { max-width: 300px; }
.filters select { max-width: 200px; }
.inline-filters { margin: 0; }

/* ---------- flash ---------- */
.flash { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; padding: .75rem 1rem; border-radius: var(--r-md);
         margin-bottom: 1rem; font-weight: 500; border: 1px solid transparent; }
.flash.success { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 20%, transparent); }
.flash.error { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 20%, transparent); }
.flash.warning { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 20%, transparent); }
.flash.small { font-size: .85rem; padding: .5rem .8rem; margin: 0; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: .8rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .78rem; color: var(--muted); font-weight: 600; background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
td.end { text-align: end; white-space: nowrap; }
td.start, dd.start { text-align: start; }
td input { min-width: 90px; }
tr.dim td { opacity: .5; }
.actions { display: flex; gap: .4rem; justify-content: flex-end; align-items: center; flex-wrap: wrap; }

/* ---------- badges & tags ---------- */
.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .12rem .6rem; border-radius: 999px; font-size: .76rem;
         font-weight: 600; border: 1px solid transparent; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.active, .badge.appt-completed { background: var(--ok-soft); color: var(--ok); }
.badge.grace, .badge.appt-no_show { background: var(--warn-soft); color: var(--warn); }
.badge.expired { background: var(--bad-soft); color: var(--bad); }
.badge.suspended, .badge.appt-cancelled { background: var(--off-soft); color: var(--off); }
.badge.appt-booked { background: var(--info-soft); color: var(--info); }
.badge.appt-confirmed { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.tag { display: inline-block; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 0 .55rem;
       font-size: .76rem; color: var(--muted); }

/* ---------- facts (label/value) ---------- */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .55rem 1.25rem; margin: 0; }
.facts dt { color: var(--muted); font-size: .88rem; }
.facts dd { margin: 0; font-weight: 500; }
.facts.small dd { font-weight: 400; }

/* ---------- KPI / stat tiles ---------- */
.stats, .kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat, .kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.15rem 1.25rem;
              display: flex; flex-direction: column; gap: .2rem; box-shadow: var(--shadow); color: var(--text); }
a.stat:hover { border-color: var(--line-strong); }
.stat .num, .kpi-num { font-size: 2rem; font-weight: 700; line-height: 1.15; letter-spacing: -.02em; color: var(--ink);
                      font-variant-numeric: tabular-nums; }
.stat span:last-child, .kpi-label { color: var(--muted); font-size: .85rem; }
.kpi-label { order: -1; font-weight: 500; }
.kpi-sub { color: var(--muted); font-size: .8rem; }
.stat { position: relative; padding-inline-start: 1.5rem; }
.stat::before { content: ""; position: absolute; inset-inline-start: 0; top: 1.1rem; bottom: 1.1rem; width: 3px; border-radius: 3px; background: var(--ok); }
.stat.warn::before { background: var(--warn); }
.stat.bad::before { background: var(--bad); }
.stat.off::before { background: var(--off); }
.stat.money::before { background: var(--accent); }
.kpi-help { color: var(--muted); font-size: .75rem; line-height: 1.5; margin-top: .4rem; border-top: 1px dashed var(--line); padding-top: .4rem; }
.kpi-warn { color: var(--warn); font-size: .76rem; line-height: 1.5; margin-top: .25rem; }
.meter { height: 6px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; margin-top: .45rem; }
.meter span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.range-note { margin: -.6rem 0 1.1rem; }

/* ---------- empty states, timeline ---------- */
.empty-state { text-align: center; padding: 3.5rem 1rem; color: var(--muted); }
.empty-state .big { display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: 50%;
                    background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); }
.small-empty { padding: 2rem 1rem; }
.timeline { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.timeline li { display: flex; gap: .5rem; flex-wrap: wrap; align-items: baseline; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }

details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
details.pop, details.add { display: inline-block; }
details.add { margin-top: 1rem; display: block; }
details[open] > form { margin-top: .7rem; }
details.pop[open] { display: block; position: relative; }

/* ---------- login ---------- */
.login-page { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 400px; padding: 2rem; }
.login-head { text-align: center; margin-bottom: 1.5rem; }
.login-head .logo { margin: 0 auto; }
.login-head h1 { justify-content: center; margin: .9rem 0 .25rem; }
.login-head p { margin: 0; }

/* ---------- bot status ---------- */
.bot-state { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .8rem 1rem; border-radius: var(--r-md); font-weight: 600;
             margin-bottom: 1rem; border: 1px solid var(--line); background: var(--surface); }
.bot-state .dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 18%, transparent); }
.bot-state.on { color: var(--ok); }
.bot-state.off { color: var(--bad); }
.model-tag { margin-inline-start: auto; font-weight: 400; color: var(--muted); }

/* ---------- doctors, scheduling, appointments ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.cards > .card { margin: 0; }
a.card.doctor { display: flex; flex-direction: column; gap: .7rem; transition: border-color .15s var(--ease); }
a.card.doctor:hover { border-color: var(--ink); }
a.card.dim { opacity: .55; }
.doctor-head { display: flex; align-items: center; gap: .75rem; }
.doctor-head > div { flex: 1; min-width: 0; }
.avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; flex: 0 0 auto;
          background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.avatar.sm { width: 34px; height: 34px; font-size: .85rem; }
table.week th { width: 92px; background: none; color: var(--text); font-size: .9rem; }
table.week td, table.week th { padding: .5rem; }
.shift { display: inline-flex; align-items: center; gap: .25rem; background: var(--surface-2); border: 1px solid var(--line);
         border-radius: 999px; padding: .1rem .55rem; margin: .1rem; font-weight: 600; font-size: .86rem; font-variant-numeric: tabular-nums; }
.shift-form { margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed var(--line); }
.daypicker { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { flex-direction: row; }
.chip input, .slot input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { border: 1px solid var(--line-strong); border-radius: 999px; padding: .3rem .85rem; cursor: pointer; font-weight: 500; }
.chip input:checked + span, .slot input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip input:focus-visible + span, .slot input:focus-visible + span { outline: 2px solid var(--ring); outline-offset: 2px; }
.daybar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.daybar input[type=date], .daybar select { width: auto; }
.daylabel { display: flex; gap: .4rem; align-items: center; min-width: 170px; justify-content: center; font-weight: 500; }
.inline-label { flex-direction: row; align-items: center; gap: .5rem; }
.inline-label input { width: auto; }
.quickdays, .doctor-pick { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-bottom: 1rem; }
.chip-link { display: inline-flex; gap: .3rem; align-items: center; border: 1px solid var(--line-strong); border-radius: 999px;
             padding: .32rem .9rem; color: var(--text); font-size: .88rem; }
.chip-link:hover { border-color: var(--ink); }
.chip-link.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip-link.on .muted { color: inherit; opacity: .75; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: .45rem; margin-bottom: 1rem; }
.slot { flex-direction: row; }
.slot span { display: block; width: 100%; text-align: center; border: 1px solid var(--line-strong); border-radius: var(--r-md);
             padding: .5rem 0; cursor: pointer; font-variant-numeric: tabular-nums; font-weight: 600; }
.slot span:hover { border-color: var(--ink); }
table.appts .actions { flex-wrap: wrap; }
.agenda { list-style: none; margin: 0; padding: 0; }
.agenda li { display: grid; grid-template-columns: 64px 1fr auto auto; gap: .75rem; align-items: center; padding: .65rem 0; border-bottom: 1px solid var(--line); }
.agenda li:last-child { border-bottom: 0; }
.agenda li.past { opacity: .5; }
.agenda .time { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.mini-appt { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; padding: .45rem 0; border-bottom: 1px dashed var(--line); font-size: .85rem; }
.card.handoffs { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.card.handoffs li.urgent { color: var(--bad); font-weight: 600; }
.kill { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px dashed var(--line); }
@media (max-width: 640px) {
  .agenda li { grid-template-columns: 56px 1fr; }
  .agenda li > :nth-child(n+3) { grid-column: 2; }
  .row { flex-direction: column; align-items: stretch; }
  .facts { grid-template-columns: 1fr; gap: .1rem; }
  .facts dd { margin-bottom: .55rem; }
}

/* ---------- chat (test chat + inbox) ---------- */
.chat-layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 1rem; margin-bottom: 1.25rem; align-items: start; }
.chat-layout > .card { margin: 0; min-width: 0; }
.conv-list { max-height: 660px; overflow-y: auto; }
.conv { display: flex; flex-direction: column; gap: .15rem; padding: .75rem 1rem; border-bottom: 1px solid var(--line); }
.conv:hover { background: var(--surface-2); }
.conv.on { background: var(--accent-soft); box-shadow: inset -3px 0 0 var(--accent); }
.conv-name { font-weight: 600; }
.conv .badge { align-self: flex-start; }
.chat { display: flex; flex-direction: column; gap: .75rem; }
.chat-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding-bottom: .75rem; border-bottom: 1px solid var(--line); }
.bubbles { display: flex; flex-direction: column; gap: .5rem; max-height: 580px; overflow-y: auto; padding: .35rem; }
.bubble { max-width: 76%; padding: .6rem .9rem; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; }
.bubble.patient { align-self: flex-start; background: var(--ink); color: var(--canvas); border-start-start-radius: 4px; }
.bubble.bot { align-self: flex-end; background: var(--surface-2); border: 1px solid var(--line); border-start-end-radius: 4px; }
.bubble.staff { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.bubble .who { display: flex; gap: .3rem; align-items: center; font-size: .74rem; color: var(--muted); font-weight: 600; margin-bottom: .2rem; white-space: normal; }
.bubble .at { display: block; font-size: .7rem; opacity: .6; margin-top: .3rem; }
.tool-line { align-self: flex-end; font-size: .8rem; color: var(--muted); max-width: 90%; }
.tool-line summary { display: inline-flex; gap: .3rem; align-items: center; }
.tool-line code { display: block; white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--line); padding: .45rem .65rem;
                  border-radius: var(--r-sm); margin-top: .3rem; font-size: .76rem; text-align: left; }
.tool-line.err summary { color: var(--warn); }
.bubbles .step { display: none; }
.bubbles.show-steps .step { display: block; }
.toggle-steps { align-self: flex-end; color: var(--muted); }
.composer { display: flex; gap: .5rem; align-items: flex-end; border: 1px solid var(--line-strong); border-radius: var(--r-lg);
            padding: .4rem; background: var(--surface); }
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer textarea { border: 0; box-shadow: none; min-height: 44px; background: transparent; }
.composer textarea:focus { box-shadow: none; }
.mic-btn { gap: .35rem; padding-inline: .8rem; }
.mic-btn .mic-time:empty { display: none; }
.mic-btn .mic-time { font-variant-numeric: tabular-nums; font-size: .85rem; }
.mic-btn.rec { background: var(--bad); border-color: var(--bad); color: #fff; }
.mic-btn.rec svg { animation: mic-pulse 1.2s ease-in-out infinite; }
@keyframes mic-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .mic-btn.rec svg { animation: none; } }

.inbox { display: grid; grid-template-columns: 330px minmax(0, 1fr) 270px; gap: 1rem; align-items: start; }
.inbox > .card { margin: 0; }
.inbox-list { max-height: calc(100dvh - 230px); overflow-y: auto; }
.inbox-item { display: grid; grid-template-columns: auto 1fr auto; gap: .65rem; align-items: center; padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
.inbox-item:hover { background: var(--surface-2); }
.inbox-item.on { background: var(--accent-soft); box-shadow: inset -3px 0 0 var(--accent); }
.inbox-item .who { display: flex; flex-direction: column; min-width: 0; }
.inbox-item .preview { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-item .meta { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; }
.inbox-item.waiting strong::after { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--bad);
                                    margin-inline-start: .4rem; vertical-align: middle; }
.ch { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); }
.inbox-chat .bubbles { max-height: calc(100dvh - 380px); min-height: 280px; }
.inbox-side .side-h { font-size: .85rem; margin: 1.1rem 0 .5rem; color: var(--muted); }
@media (max-width: 1150px) { .inbox { grid-template-columns: 290px minmax(0, 1fr); } .inbox-side { grid-column: 1 / -1; } }
@media (max-width: 800px) {
  .inbox, .chat-layout { grid-template-columns: 1fr; }
  .inbox-list, .conv-list { max-height: 260px; }
  .bubble { max-width: 92%; }
}

/* ---------- reports & charts ---------- */
.viz-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .9rem; }
.viz-head h2, .viz-head h3 { margin: 0; }
.legend { display: flex; gap: 1rem; font-size: .84rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: .4rem; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw-1 { background: var(--series-1); }
.sw-2 { background: var(--series-2); }
.chart-wrap { position: relative; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .grid.base { stroke: var(--line-strong); }
.chart .tick { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart .s1 { fill: var(--series-1); }
.chart .s2 { fill: var(--series-2); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit.on { fill: var(--ink); fill-opacity: .05; }
.tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--canvas); border-radius: 10px;
       padding: .5rem .7rem; font-size: .8rem; box-shadow: var(--shadow-pop); white-space: nowrap; line-height: 1.55; }
.table-view { margin-top: .8rem; }
.table-view summary { color: var(--muted); font-size: .85rem; }
.hbars { display: flex; flex-direction: column; gap: .8rem; }
.hbar-row { display: grid; grid-template-columns: minmax(110px, 190px) 1fr auto; gap: .2rem .8rem; align-items: center; }
.hbar-name { font-weight: 500; }
.hbar-track { height: 12px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.hbar { display: block; height: 100%; background: var(--series-1); border-radius: 4px 0 0 4px; }
.hbar-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.hbar-note { grid-column: 2 / -1; margin-top: -.35rem; }
@media (max-width: 640px) {
  .hbar-row { grid-template-columns: 1fr auto; }
  .hbar-track { grid-column: 1 / -1; grid-row: 2; }
  .hbar-note { grid-column: 1 / -1; }
}

/* ---------- assistant teaching ---------- */
.teach-steps { display: flex; gap: .75rem; align-items: stretch; flex-wrap: wrap; margin-bottom: 1.5rem; }
.tstep { flex: 1 1 210px; display: flex; gap: .7rem; align-items: center; background: var(--surface); border: 1px solid var(--line);
         border-radius: var(--r-lg); padding: .9rem 1rem; box-shadow: var(--shadow); }
.tstep > div { display: flex; flex-direction: column; }
.teach-steps > .btn { align-self: center; }
.tnum { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center;
        background: var(--ink); color: var(--canvas); font-weight: 700; font-size: .85rem; }
.tnum.sm { width: 24px; height: 24px; font-size: .78rem; margin-inline-end: .4rem; }
.teach-section { margin-bottom: 2.2rem; }
.teach-section > h2, .teach-section > .viz-head h2 { display: flex; align-items: center; }
.known-doc { padding: .55rem 0; border-bottom: 1px dashed var(--line); }
.known-doc:last-child { border-bottom: 0; }
.add-card { border-style: dashed; border-color: var(--line-strong); box-shadow: none; }
.add-card summary { color: var(--ink); font-weight: 600; display: flex; gap: .4rem; align-items: center; }
.add-card[open] summary { margin-bottom: 1rem; }
.cat-h { margin: 1.4rem 0 .7rem; font-size: .95rem; }
.k-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1rem; }
.k-card { margin: 0; display: flex; flex-direction: column; gap: .55rem; }
.k-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.k-head strong { color: var(--ink); }
.k-body { font-size: .92rem; line-height: 1.75; color: var(--text); }
.k-edit summary { display: inline-flex; gap: .3rem; align-items: center; color: var(--muted); }
.k-edit[open] { border-top: 1px dashed var(--line); padding-top: .7rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .7rem; }
.chip-btn { font: inherit; font-size: .82rem; border: 1px dashed var(--line-strong); background: var(--surface); color: var(--text);
            border-radius: 999px; padding: .3rem .8rem; cursor: pointer; }
.chip-btn:hover { border-color: var(--ink); border-style: solid; }
.chip-btn::before { content: "+ "; font-weight: 700; }

/* ---------- channels, AI settings, accent picker ---------- */
.channel-card { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.1rem; }
.channel-card.risky { margin-top: 1rem; border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.channels { margin-top: 1rem; margin-bottom: 0; }
.channel-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.provider-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .75rem; }
.provider-opt { flex-direction: row; align-items: flex-start; gap: .65rem; border: 1px solid var(--line-strong); border-radius: var(--r-lg);
                padding: .9rem 1rem; cursor: pointer; font-weight: 400; }
.provider-opt:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.provider-opt input { margin-top: .25rem; }
.provider-opt > span { display: flex; flex-direction: column; }
.swatches { display: flex; flex-wrap: wrap; gap: .55rem; }
.swatch { position: relative; flex-direction: row; }
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch span { display: inline-flex; align-items: center; gap: .5rem; border: 1px solid var(--line-strong); border-radius: 999px;
               padding: .3rem .8rem .3rem .35rem; cursor: pointer; font-size: .86rem; font-weight: 500; }
.swatch i { width: 22px; height: 22px; border-radius: 50%; background: var(--c); border: 1px solid rgba(127, 127, 127, .3); }
.swatch input:checked + span { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.swatch input:focus-visible + span { outline: 2px solid var(--ring); outline-offset: 2px; }
