/* Schaffner OS — modern apothecary system */
:root {
  --paper: #f3f0e8;
  --card: #fcfbf7;
  --card-2: #f8f6ef;
  --ink: #21261f;
  --ink-2: #5b6156;
  --ink-3: #8e9385;
  --line: #e0dccc;
  --line-2: #ebe7da;
  --fir: #16211a;
  --fir-2: #1f2d23;
  --fir-3: #2a3a2e;
  --fir-line: #2c3a30;
  --accent: #a8652f;        /* copper */
  --accent-ink: #8a4f20;
  --moss: #2f6b4a;          /* compounding green */
  --moss-soft: #e3ebe2;
  --good: #2f6b4a;
  --warn: #97690f;
  --warn-soft: #f3e9d2;
  --bad: #9c392b;
  --bad-soft: #f1dfd9;
  --serif: 'Newsreader', Georgia, serif;
  --sans: 'Public Sans', 'Helvetica Neue', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input { font: inherit; color: inherit; }

.app { display: flex; min-height: 100vh; min-width: 1280px; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 236px; flex-shrink: 0; background: var(--fir); color: #e8e6da;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-logo { padding: 26px 22px 20px; border-bottom: 1px solid var(--fir-line); }
.sidebar-logo img { width: 158px; display: block; }
.sidebar-os {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.22em; color: #9aa792;
  margin-top: 10px; text-transform: uppercase; text-align: center; width: 158px;
}
.nav { padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.2em; text-transform: uppercase;
  color: #6e7d6c; padding: 14px 12px 7px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 9px 12px; border-radius: 7px; color: #c4c8b8; font-size: 13.5px; font-weight: 500;
  border: 1px solid transparent;
}
.nav-item:hover { background: var(--fir-2); color: #eceadf; }
.nav-item.active { background: var(--fir-2); color: #f3f1e7; border-color: var(--fir-line); }
.nav-item .nav-num { font-family: var(--mono); font-size: 10px; color: #6e7d6c; width: 16px; }
.nav-item.active .nav-num { color: var(--accent-bright, #c98b52); }
.nav-badge {
  margin-left: auto; font-family: var(--mono); font-size: 10px; color: #16211a;
  background: #c98b52; border-radius: 99px; padding: 1px 7px; font-weight: 500;
}
.sidebar-stores { padding: 4px 12px; }
.store-row {
  display: flex; align-items: center; gap: 9px; padding: 7px 12px; border-radius: 7px;
  color: #aab3a2; font-size: 12.5px; width: 100%; text-align: left;
}
.store-row:hover { background: var(--fir-2); }
.store-row .dot { width: 7px; height: 7px; border-radius: 99px; background: #5d8a6b; flex-shrink: 0; }
.store-row .dot.busy { background: #c98b52; }
.store-row .mono { margin-left: auto; font-family: var(--mono); font-size: 10.5px; color: #6e7d6c; }
.sidebar-foot {
  margin-top: auto; padding: 16px 22px 20px; border-top: 1px solid var(--fir-line);
  display: flex; align-items: center; gap: 11px;
}
.sidebar-foot .avatar {
  width: 34px; height: 34px; border-radius: 99px; background: var(--fir-3);
  display: grid; place-items: center; font-family: var(--serif); font-size: 14px; color: #d9d6c6;
}
.sidebar-foot .who { font-size: 12.5px; color: #e3e1d3; font-weight: 600; }
.sidebar-foot .role { font-size: 11px; color: #8a9484; }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: baseline; gap: 18px;
  padding: 26px 36px 0;
}
.topbar h1 { font-family: var(--serif); font-weight: 500; font-size: 27px; letter-spacing: -0.01em; }
.topbar .date { color: var(--ink-3); font-size: 13px; }
.scope { margin-left: auto; display: flex; gap: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--card); }
.scope button {
  padding: 7px 14px; font-size: 12.5px; font-weight: 500; color: var(--ink-2);
  border-right: 1px solid var(--line-2);
}
.scope button:last-child { border-right: none; }
.scope button.on { background: var(--ink); color: var(--card); }
.content { padding: 22px 36px 48px; display: flex; flex-direction: column; gap: 18px; }

/* ---------- Primitives ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 11px; }
.card-pad { padding: 20px 22px; }
.sect {
  display: flex; align-items: baseline; gap: 10px; margin-bottom: 2px;
}
.sect h2 {
  font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--ink-2);
}
.sect .rule { flex: 1; border-top: 1px solid var(--line); transform: translateY(-2px); }
.sect .more { font-size: 12px; color: var(--accent-ink); font-weight: 600; }
.sect .more:hover { text-decoration: underline; }

.big-num { font-family: var(--serif); font-weight: 500; letter-spacing: -0.01em; font-variant-numeric: lining-nums; }
.kicker {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3);
}
.delta { font-size: 12px; font-weight: 600; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }

.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600;
  border-radius: 6px; padding: 2px 8px; white-space: nowrap;
}
.badge.ok { background: var(--moss-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.neutral { background: var(--card-2); color: var(--ink-2); border: 1px solid var(--line-2); }
.badge.comp { background: var(--moss); color: #f0f3ec; }
.badge.mono { font-family: var(--mono); font-weight: 500; }

.storetag {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; color: var(--ink-2);
  border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; background: var(--card-2);
}

/* ---------- Tables ---------- */
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; font-family: var(--mono); font-size: 10px; font-weight: 500;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3);
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data th.num { text-align: right; }
table.data .mono { font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
table.data tbody tr.click:hover { background: var(--card-2); cursor: pointer; }
table.data tbody tr.sel { background: var(--moss-soft); }
.compact table.data td { padding: 7px 14px; }
.compact table.data th { padding: 8px 14px; }

/* ---------- Command center ---------- */
.cc-controls { display: flex; align-items: center; gap: 10px; }
.cc-controls .lbl { font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); margin-right: 2px; }
.cmp-toggle {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line);
  background: var(--card); border-radius: 8px; padding: 7px 13px; font-size: 12.5px; color: var(--ink-2);
}
.cmp-toggle .box {
  width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--line);
  background: var(--card); display: grid; place-items: center; font-size: 10px; line-height: 1; color: var(--card);
}
.cmp-toggle:hover { border-color: var(--ink-3); }
.cmp-toggle.on { color: var(--ink); font-weight: 600; }
.cmp-toggle.on .box { background: var(--moss); border-color: var(--moss); }
.loc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.loc-card { padding: 18px 20px 14px; position: relative; transition: border-color .15s; }
.loc-card:hover { border-color: var(--ink-3); }
.loc-card.dim { opacity: 0.45; }
.loc-head { display: flex; align-items: baseline; gap: 8px; }
.loc-head .name { font-family: var(--serif); font-size: 19px; font-weight: 500; white-space: nowrap; }
.loc-head .status { margin-left: auto; }
.loc-sub { font-size: 11.5px; color: var(--ink-3); margin-top: 1px; }
.loc-rev { display: flex; align-items: baseline; gap: 9px; margin-top: 14px; }
.loc-rev .big-num { font-size: 33px; }
.loc-stats { display: flex; gap: 0; margin-top: 12px; border-top: 1px solid var(--line-2); padding-top: 11px; }
.loc-stat { flex: 1; }
.loc-stat + .loc-stat { border-left: 1px solid var(--line-2); padding-left: 14px; }
.loc-stat .v { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.loc-stat .k { font-size: 10.5px; color: var(--ink-3); margin-top: 0px; }

.cc-row { display: grid; grid-template-columns: 1.62fr 1fr; gap: 14px; align-items: stretch; }

.margin-story { display: flex; flex-direction: column; }
.margin-pair { display: grid; grid-template-columns: 1fr 1fr; margin-top: 14px; }
.margin-cell + .margin-cell { border-left: 1px solid var(--line-2); padding-left: 20px; }
.margin-cell .big-num { font-size: 44px; line-height: 1.05; }
.margin-cell.comp .big-num { color: var(--moss); }
.margin-cell .lbl { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.margin-bar { height: 8px; border-radius: 99px; background: var(--line-2); margin-top: 12px; overflow: hidden; }
.margin-bar i { display: block; height: 100%; border-radius: 99px; }
.margin-note {
  margin-top: auto; padding-top: 16px; font-family: var(--serif); font-style: italic;
  font-size: 15.5px; color: var(--ink-2); line-height: 1.45;
}
.margin-note b { color: var(--moss); font-weight: 600; }

.alert-strip { display: flex; flex-direction: column; }
.alert-row {
  display: flex; align-items: baseline; gap: 11px; padding: 11px 18px;
  border-bottom: 1px solid var(--line-2); font-size: 13px;
}
.alert-row:last-child { border-bottom: none; }
.alert-row .sev { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; transform: translateY(-1px); }
.sev.bad { background: var(--bad); } .sev.warn { background: #c9962e; } .sev.ok { background: var(--good); }
.alert-row .t { color: var(--ink-3); font-size: 11.5px; margin-left: auto; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Insights ---------- */
.insight-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.insight-card { padding: 22px 24px 18px; display: flex; flex-direction: column; gap: 10px; }
.insight-card .tag { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; }
.insight-card .tag.money { color: var(--moss); }
.insight-card .tag.bad { color: var(--bad); }
.insight-card .tag.warn { color: var(--warn); }
.insight-card h3 { font-family: var(--serif); font-size: 21px; font-weight: 500; line-height: 1.25; letter-spacing: -0.005em; }
.insight-card p { font-size: 13.5px; color: var(--ink-2); line-height: 1.55; text-wrap: pretty; }
.insight-facts { display: flex; gap: 0; border-top: 1px solid var(--line-2); padding-top: 12px; margin-top: 2px; }
.insight-facts > div { flex: 1; }
.insight-facts > div + div { border-left: 1px solid var(--line-2); padding-left: 16px; }
.insight-facts .v { font-family: var(--serif); font-size: 19px; font-weight: 500; }
.insight-facts .k { font-size: 10.5px; color: var(--ink-3); }
.insight-action { align-self: flex-start; margin-top: 4px; font-size: 12.5px; font-weight: 600; color: var(--accent-ink); }
.insight-action:hover { text-decoration: underline; }

.ask { padding: 6px 6px 6px 20px; display: flex; align-items: center; gap: 12px; }
.ask .prompt-mark { font-family: var(--serif); font-style: italic; font-size: 19px; color: var(--moss); }
.ask input { flex: 1; border: none; outline: none; background: transparent; font-size: 15px; padding: 12px 0; }
.ask input::placeholder { color: var(--ink-3); }
.ask button.go {
  background: var(--ink); color: var(--card); border-radius: 8px; padding: 10px 18px;
  font-size: 13px; font-weight: 600;
}
.ask button.go:hover { background: #000; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 99px;
  padding: 6px 13px; font-size: 12.5px; color: var(--ink-2);
}
.chip:hover { border-color: var(--ink-3); color: var(--ink); }
.answer { padding: 20px 24px; display: flex; gap: 14px; }
.answer .who {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--moss); white-space: nowrap; padding-top: 4px;
}
.answer p { font-size: 14.5px; line-height: 1.6; max-width: 72ch; text-wrap: pretty; }
.answer .q { font-family: var(--serif); font-style: italic; color: var(--ink-2); margin-bottom: 6px; font-size: 15px; }

/* ---------- Compounding ---------- */
.comp-layout { display: grid; grid-template-columns: 1.45fr 1fr; gap: 14px; align-items: start; }
.formula-detail { position: sticky; top: 18px; }
.fd-head { padding: 20px 22px 16px; border-bottom: 1px solid var(--line-2); }
.fd-head h3 { font-family: var(--serif); font-size: 19px; font-weight: 500; line-height: 1.3; }
.fd-head .form { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; }
.fd-meta { display: grid; grid-template-columns: 1fr 1fr 1fr; padding: 14px 22px; gap: 10px; border-bottom: 1px solid var(--line-2); }
.fd-meta .v { font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.fd-meta .v.mono { font-family: var(--mono); font-weight: 500; font-size: 12.5px; }
.fd-meta .k { font-size: 10px; color: var(--ink-3); font-family: var(--mono); letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 2px; }
.fd-cost { padding: 6px 22px 16px; }
.fd-margin { padding: 14px 22px 18px; border-top: 1px solid var(--line-2); background: var(--card-2); border-radius: 0 0 11px 11px; }
.fd-margin .row { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; }
.fd-margin .row.total { font-weight: 700; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; }
.fd-margin .row.total .moss { color: var(--moss); }
.marginbar-mini { display: inline-block; width: 64px; height: 5px; background: var(--line-2); border-radius: 99px; vertical-align: middle; margin-right: 8px; }
.marginbar-mini i { display: block; height: 100%; background: var(--moss); border-radius: 99px; }

/* ---------- Queue ---------- */
.queue-board { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; align-items: start; }
.queue-col-head { display: flex; align-items: baseline; gap: 7px; padding: 2px 4px 9px; }
.queue-col-head .n { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }
.queue-col-head h4 { font-size: 12px; font-weight: 700; letter-spacing: 0.02em; }
.queue-col { display: flex; flex-direction: column; gap: 9px; }
.rx-card { padding: 12px 13px; border-radius: 9px; cursor: pointer; transition: border-color .12s; }
.rx-card:hover { border-color: var(--ink-3); }
.rx-card.sel { border-color: var(--moss); box-shadow: 0 0 0 1px var(--moss); }
.rx-card .rxno { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }
.rx-card .drug { font-size: 12.5px; font-weight: 600; margin: 3px 0 1px; line-height: 1.35; }
.rx-card .pt { font-size: 11.5px; color: var(--ink-2); }
.rx-card .foot { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.rx-card .wait { margin-left: auto; font-size: 10.5px; font-variant-numeric: tabular-nums; color: var(--ink-3); }
.rx-card .wait.slow { color: var(--bad); font-weight: 700; }
.rx-detail { padding: 14px 18px; display: flex; gap: 22px; align-items: baseline; flex-wrap: wrap; }
.rx-detail .k { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); display: block; }
.rx-detail .v { font-size: 13px; font-weight: 600; }

/* ---------- Inventory ---------- */
.inv-tools { display: flex; gap: 10px; align-items: center; }
.inv-search {
  flex: 0 0 280px; display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 7px 12px;
}
.inv-search input { border: none; outline: none; background: none; width: 100%; font-size: 13px; }
.filt { display: inline-flex; flex: none; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--card); }
.filt button { padding: 7px 14px; font-size: 12.5px; line-height: 1; white-space: nowrap; color: var(--ink-2); border-right: 1px solid var(--line-2); transition: background .12s ease, color .12s ease; }
.filt button:hover:not(.on) { background: var(--card-2); color: var(--ink); }
.filt button:last-child { border-right: none; }
.filt button.on { background: var(--ink); color: var(--card); }

/* ---------- Reports ---------- */
.report-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: stretch; }
.report-card { display: flex; flex-direction: column; }
.report-card .rc-head { padding: 20px 22px 12px; }
.report-card h3 { font-family: var(--serif); font-size: 19px; font-weight: 500; }
.report-card .period { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); margin-top: 3px; }
.report-card p { padding: 0 22px; font-size: 13px; color: var(--ink-2); line-height: 1.5; text-wrap: pretty; }
.report-card .preview { margin: 14px 14px 0; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; background: var(--card-2); }
.report-card .preview table.data { font-size: 12px; }
.report-card .preview td, .report-card .preview th { padding: 7px 12px; }
.report-card .rc-foot { margin-top: auto; padding: 14px 14px 14px; }
.btn-run {
  width: 100%; text-align: center; border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 0; font-size: 13px; font-weight: 600; color: var(--ink); background: var(--card);
}
.btn-run:hover { background: var(--ink); color: var(--card); border-color: var(--ink); }

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--card); font-size: 13px; padding: 10px 20px;
  border-radius: 99px; z-index: 50; animation: toast-in .2s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- Workflow: tabs, drawer, station, patient ---------- */
.qtabs { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--card); width: max-content; }
.qtabs button { padding: 8px 16px; font-size: 13px; font-weight: 600; color: var(--ink-2); border-right: 1px solid var(--line-2); }
.qtabs button:last-child { border-right: none; }
.qtabs button.on { background: var(--ink); color: var(--card); }
.qtabs .cnt { font-family: var(--mono); font-size: 10.5px; margin-left: 6px; opacity: 0.75; }

.wc-chip { background: var(--moss); color: #f0f3ec; border-radius: 8px; padding: 8px 14px; font-size: 12.5px; font-weight: 600; }
.rx-card.hit { border-color: var(--moss); box-shadow: 0 0 0 1px var(--moss); background: #f0f4ed; }

.scrim { position: fixed; inset: 0; background: rgba(18, 26, 20, 0.38); z-index: 40; animation: fade-in 0.15s ease-out; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 600px; max-width: 94vw; background: var(--card);
  border-left: 1px solid var(--line); z-index: 41; overflow-y: auto; animation: drawer-in 0.18s ease-out;
}
@keyframes drawer-in { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { padding: 22px 26px 16px; border-bottom: 1px solid var(--line-2); }
.drawer-head h3 { font-family: var(--serif); font-size: 21px; font-weight: 500; line-height: 1.3; }
.pt-link { color: var(--moss); font-weight: 700; font-size: 14.5px; }
.pt-link:hover { text-decoration: underline; }
.drawer-sec { padding: 16px 26px; border-bottom: 1px solid var(--line-2); }
.drawer-sec .h { font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 9px; }
.sig-line { font-family: var(--serif); font-style: italic; font-size: 16.5px; }
.kv { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.kv .k { font-size: 9.5px; font-family: var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 2px; }
.kv .v { font-size: 13.5px; font-weight: 600; }

.adj { background: var(--fir); color: #e8e6da; border-radius: 10px; padding: 16px 18px; }
.adj .row { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; color: #aab3a2; }
.adj .row .mono { font-family: var(--mono); color: #e8e6da; }
.adj .gp { display: flex; align-items: baseline; gap: 10px; border-top: 1px solid var(--fir-line); margin-top: 10px; padding-top: 10px; }
.adj .gp .big-num { font-size: 30px; color: #fff; }
.adj .gp.neg .big-num { color: #e08770; }
.chip-status { font-size: 11px; font-weight: 700; border-radius: 6px; padding: 2px 9px; }
.chip-status.paid { background: #2f6b4a; color: #eef3ec; }
.chip-status.cash { background: #c98b52; color: #1d150c; }
.chip-status.pending { background: #c9962e; color: #1d1a10; }
.chip-status.rejected { background: var(--bad); color: #f6e9e4; }

.dur { background: var(--warn-soft); border: 1px solid #e0c990; border-radius: 10px; padding: 14px 16px; font-size: 13.5px; line-height: 1.5; }
.dur b { color: #6e4f0c; }
.dur .acts { display: flex; gap: 8px; margin-top: 11px; }
.btn-sm { border: 1px solid var(--line); border-radius: 7px; padding: 6px 13px; font-size: 12.5px; font-weight: 600; background: var(--card); }
.btn-sm:hover { border-color: var(--ink-3); }
.btn-sm.dark { background: var(--ink); color: var(--card); border-color: var(--ink); }
.btn-sm.dark:hover { background: #000; }
.ok-line { font-size: 13px; color: var(--good); font-weight: 500; }
.tl { display: flex; flex-direction: column; gap: 8px; }
.tl .t-row { display: flex; gap: 12px; font-size: 12.5px; }
.tl .t-time { font-family: var(--mono); font-size: 11px; color: var(--ink-3); width: 72px; flex-shrink: 0; text-align: right; }

.station {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(1080px, 94vw); max-height: 90vh; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; z-index: 41; display: flex; flex-direction: column; overflow: hidden; animation: fade-in 0.18s ease-out;
}
.station-head { display: flex; align-items: center; gap: 12px; padding: 15px 22px; border-bottom: 1px solid var(--line-2); }
.station-body { display: grid; grid-template-columns: 1.08fr 1fr; overflow: auto; }
.station-left { background: #e9e4d6; padding: 26px; display: flex; align-items: flex-start; justify-content: center; border-right: 1px solid var(--line-2); }
.paper {
  background: #fbf7ec; width: 100%; max-width: 440px; border: 1px solid #d8d2bd;
  box-shadow: 0 8px 22px rgba(30, 35, 28, 0.18); transform: rotate(-0.7deg);
  padding: 26px 30px 20px; font-size: 13px; color: #2a2c26;
  background-image: repeating-linear-gradient(0deg, rgba(120, 110, 80, 0.03) 0 2px, transparent 2px 4px);
}
.paper .clinic { font-family: var(--serif); font-size: 17px; font-weight: 600; }
.paper .addr { font-size: 10.5px; color: #6e6a58; margin-top: 2px; }
.paper hr { border: none; border-top: 1px solid #cfc8ae; margin: 12px 0; }
.paper .rxsym { font-family: var(--serif); font-size: 32px; line-height: 1; }
.hand { font-family: 'Caveat', cursive; font-size: 21px; line-height: 1.3; color: #2c3b56; }
.paper .field { display: flex; gap: 10px; margin: 7px 0; align-items: baseline; }
.paper .field .lab { font-size: 9px; font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.1em; color: #8a8468; width: 64px; flex-shrink: 0; }
.paper .signature { font-family: 'Caveat', cursive; font-size: 27px; color: #27406b; transform: rotate(-2deg); margin: 26px 0 -6px 120px; }
.paper .sigline { border-top: 1px solid #9a9478; margin-top: 8px; padding-top: 4px; font-size: 9.5px; color: #8a8468; display: flex; justify-content: space-between; }
.station-right { padding: 20px 26px; display: flex; flex-direction: column; }
.vrow { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; align-items: baseline; }
.vrow .lab { color: var(--ink-3); font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; flex-shrink: 0; }
.vrow .val { font-weight: 600; text-align: right; }
.vrow .tick { color: var(--good); margin-left: 6px; }
.station-actions { margin-top: auto; display: flex; gap: 10px; padding-top: 18px; }
.btn-primary { flex: 1.4; background: var(--moss); color: #f0f3ec; border-radius: 9px; padding: 12px 0; font-size: 14px; font-weight: 700; }
.btn-primary:hover { background: #275a3e; }
.btn-ghost { flex: 1; border: 1px solid var(--line); border-radius: 9px; padding: 12px 0; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--warn); color: var(--warn); }
.xclose { margin-left: auto; font-size: 16px; color: var(--ink-3); padding: 4px 8px; border-radius: 6px; }
.xclose:hover { background: var(--card-2); color: var(--ink); }

.code-chip { font-family: var(--mono); font-size: 11px; background: var(--bad-soft); color: var(--bad); border-radius: 6px; padding: 2px 7px; white-space: nowrap; }
tr.dimrow td { opacity: 0.4; }

.pt-head { display: flex; align-items: center; gap: 18px; padding: 20px 24px; flex-wrap: wrap; }
.pt-head h2 { font-family: var(--serif); font-size: 25px; font-weight: 500; }
.pt-meta { display: flex; gap: 16px; font-size: 13px; color: var(--ink-2); flex-wrap: wrap; }
.pt-badges { margin-left: auto; display: flex; gap: 8px; }
.allergy-strip { background: var(--warn-soft); border: 1px solid #e0c990; border-radius: 10px; padding: 10px 16px; font-size: 13px; color: #6e4f0c; display: flex; gap: 10px; align-items: baseline; }
.pt-grid { display: grid; grid-template-columns: 1.55fr 1fr; gap: 14px; align-items: start; }
.notes .n-row { padding: 12px 18px; border-bottom: 1px solid var(--line-2); font-size: 13px; line-height: 1.5; }
.notes .n-row:last-child { border-bottom: none; }
.notes .n-meta { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); margin-bottom: 3px; }
.backlink { font-size: 12.5px; font-weight: 600; color: var(--accent-ink); }
.backlink:hover { text-decoration: underline; }
.alert-row.click { cursor: pointer; }
.alert-row.click:hover { background: var(--card-2); }
.alert-row .golink { color: var(--accent-ink); font-weight: 600; font-size: 12px; white-space: nowrap; }

/* ---------- Intake ---------- */
.intake-row { display: flex; align-items: center; gap: 16px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.intake-row:last-child { border-bottom: none; }
.intake-row.hero { background: #f2f6ef; }
.intake-kind { font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); width: 138px; flex-shrink: 0; line-height: 1.6; }
.intake-main { flex: 1; min-width: 0; }
.intake-main .drug { font-weight: 600; font-size: 13.5px; }
.intake-main .who { font-size: 12.5px; color: var(--ink-2); margin-top: 1px; }
.fax-thumb { width: 42px; height: 54px; background: #fbf7ec; border: 1px solid #d8d2bd; transform: rotate(-2deg); flex-shrink: 0; padding: 6px 5px; display: flex; flex-direction: column; gap: 4px; }
.fax-thumb i { display: block; height: 2px; background: #c9c2a8; }
.fax-thumb i:nth-child(2) { width: 70%; }
.fax-thumb i:last-child { width: 50%; }

.entry-sec { padding: 14px 28px; border-bottom: 1px solid var(--line-2); }
.match { background: var(--moss-soft); border: 1px solid #c5d6c4; border-radius: 10px; padding: 12px 16px; display: flex; gap: 10px; align-items: baseline; font-size: 13.5px; flex-wrap: wrap; }
.match .check { color: var(--moss); font-weight: 700; }
.quiet-link { font-size: 12px; color: var(--ink-3); text-decoration: underline; }
.quiet-link:hover { color: var(--ink-2); }
.field-row { display: grid; grid-template-columns: 128px 1fr; gap: 14px; align-items: baseline; padding: 7px 0; }
.field-row .flab { font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); }
.inp { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font-size: 13.5px; background: var(--card); width: 100%; }
.sigcode { font-family: var(--mono); background: var(--card-2); border: 1px solid var(--line-2); border-radius: 7px; padding: 8px 12px; font-size: 13px; white-space: nowrap; }
.ins-radio { display: flex; gap: 10px; }
.ins-card { flex: 1; border: 1.5px solid var(--line); border-radius: 10px; padding: 11px 14px; cursor: pointer; font-size: 13px; text-align: left; }
.ins-card.on { border-color: var(--moss); background: #f2f6ef; }
.ins-card .plan { font-weight: 700; }
.ins-card .det { font-size: 11px; color: var(--ink-3); font-family: var(--mono); margin-top: 2px; }
.clin-strip { font-size: 13px; color: var(--good); font-weight: 500; }
.paid-panel { background: var(--moss-soft); border: 1px solid #c5d6c4; border-radius: 10px; padding: 16px 18px; animation: drawer-in 0.25s ease-out; }
.paid-panel .rows { display: flex; gap: 0; margin-top: 10px; }
.paid-panel .rows > div { flex: 1; }
.paid-panel .rows > div + div { border-left: 1px solid #c5d6c4; padding-left: 14px; }
.paid-panel .v { font-family: var(--serif); font-size: 19px; font-weight: 500; }
.paid-panel .k { font-size: 10px; font-family: var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }

/* --- Entry surfaces added for fax / phone / manual paths --- */
.paper .fax-head { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.04em; color: #8a8468; border-bottom: 1px dashed #cfc8ae; padding-bottom: 6px; margin-bottom: 8px; }
.xnote { background: #fbf3e2; border: 1px solid #e6d3a6; border-radius: 9px; padding: 10px 14px; font-size: 12.5px; color: #7a5d1e; }

.callrec { background: var(--card); border: 1px solid var(--line-2); border-radius: 12px; padding: 18px 20px; width: 100%; box-shadow: 0 6px 18px rgba(0,0,0,0.06); }
.callrec .cr-grid { display: grid; grid-template-columns: 96px 1fr; gap: 8px 14px; margin: 14px 0; }
.callrec .cr-k { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); }
.callrec .cr-v { font-size: 13px; color: var(--ink); }
.callrec .cr-readback { background: var(--moss-soft); border: 1px solid #c5d6c4; color: var(--moss); font-weight: 600; font-size: 12.5px; border-radius: 8px; padding: 9px 12px; }
.callrec .cr-foot { font-size: 11px; color: var(--ink-3); margin-top: 12px; line-height: 1.5; }

.seg { display: inline-flex; justify-self: start; width: fit-content; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { padding: 8px 16px; font-size: 12.5px; font-weight: 600; background: var(--card); border: none; border-right: 1px solid var(--line); color: var(--ink-2); }
.seg button:last-child { border-right: none; }
.seg button.on { background: var(--ink); color: var(--card); }

.ta-wrap { position: relative; }
.ta-drop { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--card); border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 10px 28px rgba(0,0,0,0.14); z-index: 5; overflow: hidden; }
.ta-opt { padding: 9px 13px; font-size: 13px; cursor: pointer; border-bottom: 1px solid var(--line-2); }
.ta-opt:last-child { border-bottom: none; }
.ta-opt:hover { background: var(--card-2); }

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

/* ============================================================
   Responsive — mobile & tablet
   Desktop (>1280px) is untouched; below that the layout adapts.
   ============================================================ */
.menu-btn { display: none; }
.sidebar-scrim { display: none; }

/* --- Small laptop / tablet landscape: relax the hard min-width --- */
@media (max-width: 1280px) {
  .app { min-width: 0; }
  .content { padding: 22px 24px 48px; }
  .topbar { padding: 24px 24px 0; }
  .loc-grid { grid-template-columns: 1fr 1fr; }
  .report-grid { grid-template-columns: 1fr 1fr; }
  .cc-row { grid-template-columns: 1fr; }
  .queue-board { grid-template-columns: repeat(5, minmax(168px, 1fr)); overflow-x: auto; padding-bottom: 8px; }
  .content .card { overflow-x: auto; }
}

/* --- Tablet portrait & below: sidebar becomes an off-canvas drawer --- */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; height: 100dvh;
    z-index: 60; transform: translateX(-100%);
    transition: transform 0.22s ease; box-shadow: 0 0 44px rgba(0, 0, 0, 0.32);
  }
  .sidebar.open { transform: none; }
  .sidebar-scrim {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(18, 26, 20, 0.42); opacity: 0; pointer-events: none;
    transition: opacity 0.2s ease;
  }
  .sidebar-scrim.on { opacity: 1; pointer-events: auto; }

  .menu-btn {
    display: inline-flex; flex-direction: column; justify-content: center; gap: 4px;
    width: 38px; height: 38px; flex-shrink: 0; align-self: center;
    border: 1px solid var(--line); border-radius: 9px; background: var(--card); padding: 0 9px;
  }
  .menu-btn span { display: block; height: 2px; background: var(--ink); border-radius: 2px; }

  .topbar { align-items: center; }
  .insight-grid { grid-template-columns: 1fr; }
  .comp-layout { grid-template-columns: 1fr; }
  .formula-detail { position: static; }
  .pt-grid { grid-template-columns: 1fr; }
  .station-body { grid-template-columns: 1fr; }
  .cc-controls, .inv-tools, .pt-head, .station-actions, .rx-detail { flex-wrap: wrap; }
}

/* --- Phone: single-column everything --- */
@media (max-width: 640px) {
  .content { padding: 16px 15px 40px; gap: 14px; }
  .topbar { flex-wrap: wrap; gap: 10px; padding: 16px 15px 0; }
  .topbar h1 { font-size: 22px; order: 1; }
  .menu-btn { order: 0; }
  .scope { order: 2; margin-left: auto; }
  .topbar .date { order: 4; flex-basis: 100%; }

  .loc-grid { grid-template-columns: 1fr; }
  .report-grid { grid-template-columns: 1fr; }
  .fd-meta { grid-template-columns: 1fr 1fr; }
  .kv { grid-template-columns: 1fr 1fr; }
  .field-row { grid-template-columns: 1fr; gap: 4px; }
  .ins-radio { flex-direction: column; }
  .inv-search { flex: 1 1 100%; }
  .intake-row { flex-wrap: wrap; }
  .intake-kind { width: 100%; }

  .loc-rev .big-num { font-size: 28px; }
  .margin-cell .big-num { font-size: 34px; }

  /* Full-screen modal & drawer */
  .station {
    width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh;
    top: 0; left: 0; transform: none; border-radius: 0;
  }
  .station-left { display: none; }
  .station-body { grid-template-columns: 1fr; }
  .drawer { width: 100vw; max-width: 100vw; }
}

/* ---------- Reports ---------- */
.rpt-layout { display: grid; grid-template-columns: 232px 1fr; gap: 14px; align-items: start; }
.rpt-rail { overflow: hidden; position: sticky; top: 18px; }
.rr-item { display: flex; gap: 11px; width: 100%; text-align: left; padding: 13px 15px; border-bottom: 1px solid var(--line-2); align-items: flex-start; }
.rr-item:last-child { border-bottom: none; }
.rr-item.on { background: var(--moss-soft); box-shadow: inset 3px 0 0 var(--moss); }
.rr-item:not(.disabled):hover { background: var(--card-2); }
.rr-item.disabled { opacity: 0.5; cursor: default; }
.rr-n { font-size: 10px; color: var(--ink-3); padding-top: 2px; letter-spacing: 0.05em; }
.rr-text { display: flex; flex-direction: column; gap: 2px; }
.rr-title { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.rr-desc { font-size: 11px; color: var(--ink-3); }
.rr-phase { font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--warn); background: var(--warn-soft); padding: 1px 5px; border-radius: 99px; margin-left: 4px; vertical-align: middle; }

.rpt-pane { min-width: 0; }
.rpt-body { display: flex; flex-direction: column; gap: 14px; }
.rpt-head { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.rpt-head h2 { font-family: var(--serif); font-size: 26px; font-weight: 500; letter-spacing: -0.01em; }
.rpt-sub { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; }
.rpt-head-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.rpt-head-tools > * { flex: none; }
.rpt-head-tools .btn-run { width: auto; padding: 9px 18px; white-space: nowrap; }

.rpt-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); }
.rpt-kpi { padding: 16px 20px; border-right: 1px solid var(--line-2); }
.rpt-kpi:last-child { border-right: none; }
.rpt-kpi .v { font-size: 29px; margin-top: 4px; }
.rpt-kpi .ph-cat, .ph-cat { font-family: var(--sans); font-size: 15px; font-weight: 600; }
.rk-sub { font-size: 11px; color: var(--ink-3); margin-top: 2px; }

.rpt-two { display: grid; grid-template-columns: 0.85fr 1.15fr; gap: 14px; align-items: start; }
.rpt-foot { font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); margin-top: 16px; text-align: right; }
.pdmp-foot { font-family: var(--mono); font-size: 11px; color: var(--ink-2); padding: 12px 16px; border-top: 1px solid var(--line-2); background: var(--card-2); }
.rpt-callout { margin-top: 14px; padding: 12px 14px; background: var(--warn-soft); border-radius: 8px; font-size: 13px; color: var(--ink); line-height: 1.5; }

/* Donut + legend */
.donut-block { display: flex; gap: 18px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.donut-legend { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 7px; }
.dl-row { display: grid; grid-template-columns: 14px 1fr auto auto; gap: 8px; align-items: center; font-size: 12.5px; }
.dl-dot { width: 10px; height: 10px; border-radius: 3px; }
.dl-name { color: var(--ink); }
.dl-val { color: var(--ink-2); font-size: 12px; }
.dl-pct { color: var(--ink-3); font-size: 11.5px; min-width: 42px; text-align: right; }

/* Horizontal bars */
.hbars { display: flex; flex-direction: column; gap: 12px; }
.hbar { display: grid; grid-template-columns: 200px 1fr 64px; gap: 12px; align-items: center; }
.hb-label { display: flex; flex-direction: column; }
.hb-label > span:first-child { font-size: 13px; font-weight: 600; }
.hb-sub { font-size: 11px; color: var(--ink-3); }
.hb-track { height: 12px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.hb-track i { display: block; height: 100%; background: var(--moss); border-radius: 99px; }
.hb-val { text-align: right; font-size: 13px; font-weight: 600; color: var(--ink); }

/* Change tags */
.chg { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chg.up { color: var(--good); }
.chg.down { color: var(--bad); }
.chg.flat { color: var(--ink-3); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable.on { color: var(--accent-ink); }

/* Prescriber single view */
.presc-layout { display: grid; grid-template-columns: 216px 1fr; gap: 14px; align-items: start; }
.presc-list { overflow: hidden; position: sticky; top: 18px; }
.pl-head { padding: 10px 12px; border-bottom: 1px solid var(--line-2); }
.pl-back { font-size: 12px; color: var(--accent-ink); font-weight: 600; }
.pl-back:hover { text-decoration: underline; }
.pl-item { display: flex; flex-direction: column; gap: 1px; width: 100%; text-align: left; padding: 10px 13px; border-bottom: 1px solid var(--line-2); }
.pl-item:last-child { border-bottom: none; }
.pl-item.on { background: var(--moss-soft); box-shadow: inset 3px 0 0 var(--moss); }
.pl-item:hover { background: var(--card-2); }
.pl-name { font-size: 12.5px; font-weight: 600; }
.pl-cat { font-size: 11px; color: var(--ink-3); }

.presc-hd { padding: 18px 20px; }
.ph-top { display: flex; justify-content: space-between; align-items: flex-start; }
.presc-hd h3 { font-family: var(--serif); font-size: 21px; font-weight: 500; margin-top: 3px; }
.ph-presc { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; }
.ph-nav { display: flex; gap: 6px; }
.ph-nav button { width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 7px; font-size: 16px; color: var(--ink-2); background: var(--card); }
.ph-nav button:hover { background: var(--ink); color: var(--card); border-color: var(--ink); }
.ph-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-2); }
.ph-kpis .v { font-size: 22px; margin-top: 3px; }

.analysis-card { padding: 18px 20px; }
.ac-label { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 8px; }
.analysis-card p { font-size: 13.5px; color: var(--ink); line-height: 1.6; text-wrap: pretty; }
.ac-rec { display: flex; gap: 10px; align-items: baseline; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line-2); font-size: 13px; color: var(--ink); }
.ac-rec-tag { flex-shrink: 0; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--moss); background: var(--moss-soft); padding: 3px 8px; border-radius: 99px; }

@media (max-width: 1100px) {
  .rpt-layout { grid-template-columns: 1fr; }
  .rpt-rail { position: static; display: grid; grid-template-columns: repeat(2, 1fr); }
  .rpt-two { grid-template-columns: 1fr; }
  .presc-layout { grid-template-columns: 1fr; }
  .presc-list { position: static; }
  .hbar { grid-template-columns: 140px 1fr 56px; }
}
