/* ════════════════════════════════════════════════════════════════
   Station UI — shared design system for every page behind login.
   See DESIGN_MIGRATION.md for rollout status and the source spec.
   ════════════════════════════════════════════════════════════════ */

:root {
  /* Brand */
  --st-sage: #8FBC8F;
  --st-sage-d: #5f9060;
  --st-teal: #20B2AA;
  --st-teal-d: #14807a;
  --st-grad: linear-gradient(135deg, var(--st-sage), var(--st-teal));

  /* Tones — the surface/fill value of each semantic colour. */
  --st-blue: #3b82f6;
  --st-amber: #f59e0b;
  --st-green: #16a34a;
  --st-red: #ef4444;
  --st-violet: #7c69ef;

  /* Deep variants, for the same colour used as TEXT.
     The fill tones above are chosen to read against a surface, not to be read
     on one: --st-green on white measures ~3.3:1, under the 4.5:1 AA floor for
     body text. These are the deep shades the chip vocabulary already uses,
     promoted to tokens so "the token for green text" exists. Extends the
     --st-sage-d / --st-teal-d convention: dark mode redefines each to the
     bright tone, since the deep shade is unreadable on a dark surface. */
  --st-blue-d: #1d4ed8;
  --st-amber-d: #b45309;
  --st-green-d: #15803d;
  --st-red-d: #b91c1c;
  --st-violet-d: #5b21b6;

  /* Surfaces */
  --st-surface: #ffffff;
  --st-surface-2: #f5faf8;
  --st-canvas: #eef3f1;

  /* Lines */
  --st-line: #dde6e2;
  --st-line-soft: #e8efec;

  /* Ink */
  --st-ink: #16241f;
  --st-ink-2: #566b62;
  --st-ink-3: #8a9d94;

  /* Radii */
  --st-r-sm: 9px;
  --st-r-md: 13px;
  --st-r-lg: 18px;

  /* Shadows */
  --st-sh-1: 0 1px 2px rgba(20, 40, 33, 0.06), 0 1px 1px rgba(20, 40, 33, 0.04);
  --st-sh-2: 0 6px 16px rgba(20, 40, 33, 0.10), 0 2px 6px rgba(20, 40, 33, 0.06);
  --st-sh-3: 0 20px 48px rgba(20, 40, 33, 0.20), 0 8px 20px rgba(20, 40, 33, 0.10);

  /* Categorical chart palette.
     Charts were the one surface the design language never covered, so every
     page that drew one invented its own series colors — the same seven-hex
     array was copy-pasted across dashboards, led by a teal that isn't
     --st-teal. Brand-led and ordered by descending salience, so a two-series
     chart gets sage/teal and a seven-series chart still separates.
     Read from JS via assets/js/station-charts.js rather than re-literalled. */
  --st-c1: #20B2AA;   /* teal   — brand primary */
  --st-c2: #8FBC8F;   /* sage   — brand secondary */
  --st-c3: #f59e0b;   /* amber  */
  --st-c4: #3b82f6;   /* blue   */
  --st-c5: #7c69ef;   /* violet */
  --st-c6: #ef4444;   /* red    */
  --st-c7: #16a34a;   /* green  */
}

[data-bs-theme="dark"] {
  --st-sage: #7aa87a;
  --st-sage-d: #5f9060;
  --st-teal: #2bc9c0;
  --st-teal-d: #1a938a;
  --st-grad: linear-gradient(135deg, var(--st-sage), var(--st-teal));

  --st-blue: #5b93f7;
  --st-amber: #fbbf24;
  --st-green: #34d066;
  --st-red: #f87171;
  --st-violet: #9384f9;

  /* Deep text variants collapse onto the bright tones on a dark surface —
     same reason --st-teal-d lightens here rather than darkening further. */
  --st-blue-d: var(--st-blue);
  --st-amber-d: var(--st-amber);
  --st-green-d: var(--st-green);
  --st-red-d: var(--st-red);
  --st-violet-d: var(--st-violet);

  /* Chart series, brightened for the dark canvas — the light-mode values
     sit too close to --st-surface to separate against it. */
  --st-c1: #2bc9c0;
  --st-c2: #a3cfa3;
  --st-c3: #fbbf24;
  --st-c4: #5b93f7;
  --st-c5: #9384f9;
  --st-c6: #f87171;
  --st-c7: #34d066;

  --st-surface: #1a231f;
  --st-surface-2: #212d27;
  --st-canvas: #141c18;

  --st-line: #2d3a34;
  --st-line-soft: #263029;

  --st-ink: #eaf2ee;
  --st-ink-2: #a9bdb3;
  --st-ink-3: #718077;

  --st-sh-1: 0 1px 2px rgba(0, 0, 0, 0.25), 0 1px 1px rgba(0, 0, 0, 0.18);
  --st-sh-2: 0 6px 16px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.22);
  --st-sh-3: 0 20px 48px rgba(0, 0, 0, 0.50), 0 8px 20px rgba(0, 0, 0, 0.30);
}

.station-scope {
  font-variant-numeric: tabular-nums;
}

/* ── Tone helpers ─────────────────────────────────────────────── */
.t-teal   { --tone: var(--st-teal);   --tone-soft: rgba(32, 178, 170, 0.12); }
.t-blue   { --tone: var(--st-blue);   --tone-soft: rgba(59, 130, 246, 0.12); }
.t-amber  { --tone: var(--st-amber);  --tone-soft: rgba(245, 158, 11, 0.12); }
.t-green  { --tone: var(--st-green);  --tone-soft: rgba(22, 163, 74, 0.12); }
.t-red    { --tone: var(--st-red);    --tone-soft: rgba(239, 68, 68, 0.12); }
.t-sage   { --tone: var(--st-sage);   --tone-soft: rgba(143, 188, 143, 0.14); }
.t-violet { --tone: var(--st-violet); --tone-soft: rgba(124, 105, 239, 0.12); }

/* ── Station bar ──────────────────────────────────────────────── */
.station-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
  background: var(--st-surface);
  border: 1px solid var(--st-line);
  border-radius: var(--st-r-lg);
  box-shadow: var(--st-sh-1);
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.station-bar .sb-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--st-r-md);
  background: var(--st-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 22px;
  flex-shrink: 0;
}
.station-bar .sb-text { flex: 1 1 auto; min-width: 200px; }
.station-bar .sb-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--st-teal-d);
  margin: 0 0 2px;
}
.station-bar .sb-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--st-ink);
  margin: 0;
  line-height: 1.25;
}
.station-bar .sb-meta {
  font-size: 13px;
  color: var(--st-ink-2);
  margin-top: 2px;
}
.station-bar .sb-clock {
  font-size: 13px;
  color: var(--st-ink-2);
  font-variant-numeric: tabular-nums;
}
.station-bar .sb-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(22, 163, 74, 0.12);
  color: var(--st-green);
  font-size: 12px;
  font-weight: 600;
}
.station-bar .sb-live::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--st-green);
}
.station-bar .sb-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.btn-st {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--st-r-sm);
  border: 1px solid var(--st-line);
  background: var(--st-surface);
  color: var(--st-ink);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.btn-st:hover { border-color: var(--st-teal); color: var(--st-ink); box-shadow: var(--st-sh-1); }
.btn-st-solid {
  border: none;
  background: var(--st-grad);
  color: #fff;
}
.btn-st-solid:hover { color: #fff; box-shadow: var(--st-sh-2); }

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--st-r-sm);
  border: 1px solid var(--st-line);
  background: var(--st-surface);
  color: var(--st-ink-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, color 0.15s;
}
.icon-btn:hover { color: var(--st-teal-d); }
.icon-btn.spinning i { animation: st-spin 0.8s linear infinite; }
@keyframes st-spin { to { transform: rotate(360deg); } }

/* ── Stat rail ─────────────────────────────────────────────────── */
.stat-rail {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat {
  /* No --tone here: a .t-* helper on the same element would lose to it on
     source order. Each use below falls back to teal when no tone is set. */
  display: block;
  background: var(--st-surface);
  border: 1px solid var(--st-line);
  border-radius: var(--st-r-md);
  padding: 16px 18px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--st-sh-1);
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
  overflow: hidden;
}
a.stat:hover { transform: translateY(-2px); box-shadow: var(--st-sh-2); }
.stat::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--tone, var(--st-teal));
}
.stat-top {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--st-ink-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.stat-top .tag {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tone, var(--st-teal));
  flex-shrink: 0;
}
.stat-val {
  font-size: 26px;
  font-weight: 700;
  color: var(--st-ink);
  line-height: 1.1;
}
.stat-sub {
  font-size: 12px;
  color: var(--st-ink-3);
  margin-top: 4px;
}
.stat-meter {
  margin-top: 10px;
  height: 5px;
  border-radius: 999px;
  background: var(--tone-soft, rgba(32, 178, 170, 0.12));
  overflow: hidden;
}
.stat-meter > span {
  display: block;
  height: 100%;
  background: var(--tone, var(--st-teal));
  border-radius: 999px;
}

/* ── Launchpad ─────────────────────────────────────────────────── */
.launchpad {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.lp {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--st-surface);
  border: 1px solid var(--st-line);
  border-radius: var(--st-r-md);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.lp:hover {
  border-color: var(--tone, var(--st-teal));
  box-shadow: var(--st-sh-2);
  transform: translateY(-1px);
  color: inherit;
}
.lp-ic {
  /* Same reason as .stat — no --tone declaration, fall back per property. */
  width: 42px;
  height: 42px;
  border-radius: var(--st-r-sm);
  background: var(--tone-soft, rgba(32, 178, 170, 0.12));
  color: var(--tone, var(--st-teal));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.lp-txt { flex: 1; min-width: 0; }
.lp-t { font-size: 14px; font-weight: 600; color: var(--st-ink); }
.lp-d { font-size: 12px; color: var(--st-ink-3); margin-top: 1px; }
.lp-go { color: var(--st-ink-3); flex-shrink: 0; transition: transform 0.15s; }
.lp:hover .lp-go { transform: translateX(3px); color: var(--st-teal-d); }

/* ── Panel ─────────────────────────────────────────────────────── */
.panel {
  background: var(--st-surface);
  border: 1px solid var(--st-line);
  border-radius: var(--st-r-lg);
  box-shadow: var(--st-sh-1);
  margin-bottom: 22px;
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--st-line-soft);
}
.panel-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--st-ink);
  margin: 0;
  flex: 1;
}
.panel-tools { display: flex; align-items: center; gap: 8px; }
.panel-body { padding: 20px; }
.panel-foot {
  padding: 12px 20px;
  border-top: 1px solid var(--st-line-soft);
  background: var(--st-surface-2);
  font-size: 13px;
  color: var(--st-ink-2);
}

/* ── Section label ─────────────────────────────────────────────── */
.sec-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 28px 0 14px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--st-ink-2);
}
.sec-label::before {
  content: "";
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: var(--st-grad);
}
.sec-label .rule { flex: 1; height: 1px; background: var(--st-line); }
.sec-label a { font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--st-teal-d); text-decoration: none; }

/* ── Segmented control ────────────────────────────────────────── */
.seg {
  display: inline-flex;
  padding: 3px;
  background: var(--st-surface-2);
  border: 1px solid var(--st-line);
  border-radius: 999px;
  gap: 2px;
}
.seg > a, .seg > button {
  padding: 6px 14px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--st-ink-2);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.seg > a.active, .seg > button.active {
  background: var(--st-surface);
  color: var(--st-ink);
  box-shadow: var(--st-sh-1);
}

/* ── Chips ────────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--st-surface-2);
  color: var(--st-ink-2);
}
.chip-normal    { background: rgba(32, 178, 170, 0.12); color: var(--st-teal-d); }
.chip-urgent    { background: rgba(245, 158, 11, 0.14); color: #b45309; }
.chip-emergency { background: rgba(239, 68, 68, 0.14); color: #b91c1c; }
.chip-waiting    { background: rgba(245, 158, 11, 0.14); color: #b45309; }
.chip-in-service { background: rgba(59, 130, 246, 0.14); color: #1d4ed8; }
.chip-completed  { background: rgba(22, 163, 74, 0.14); color: #15803d; }

/* Promoted from page-local <style> blocks (queue_dashboard, pharmacist_
   dashboard, billing_center) where the same violet-family tone had been
   redefined three times under three names. Per the spec: a page that needs a
   variant adds a modifier here, not a parallel component. */
.chip-seen   { background: rgba(124, 105, 239, 0.12); color: #4338ca; }
.chip-credit { background: rgba(124, 105, 239, 0.12); color: #5b21b6; }
.chip-card   { background: rgba(124, 105, 239, 0.12); color: #5b21b6; }
.chip-ins    { background: rgba(59, 130, 246, 0.14); color: #1d4ed8; }

/* Priority chips read as small-caps labels rather than sentence-case status. */
.chip-pri { text-transform: uppercase; font-weight: 700; letter-spacing: 0.03em; }

/* ── Queue table vocabulary ───────────────────────────────────── */
.qtable { width: 100%; border-collapse: collapse; }
.qtable tr { border-bottom: 1px solid var(--st-line-soft); }
.qtable td, .qtable th { padding: 12px 10px; font-size: 13px; }
.qtable th { color: var(--st-ink-3); text-transform: uppercase; font-size: 11px; letter-spacing: 0.04em; }
.dept-rail { display: flex; align-items: center; gap: 8px; }
.who { display: flex; align-items: center; gap: 10px; }
.who img, .who .avatar {
  width: 34px; height: 34px; border-radius: 50%; object-fit: cover;
  background: var(--st-grad); color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.wait { font-variant-numeric: tabular-nums; color: var(--st-ink-2); font-size: 13px; }
.acts { display: flex; align-items: center; gap: 6px; }
.act {
  width: 30px; height: 30px; border-radius: var(--st-r-sm);
  border: 1px solid var(--st-line); background: var(--st-surface);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--st-ink-2); text-decoration: none;
}
.act:hover { border-color: var(--st-teal); color: var(--st-teal-d); }

/* ── Empty state ──────────────────────────────────────────────── */
.empty { text-align: center; padding: 48px 20px; color: var(--st-ink-3); }
.empty-ic { font-size: 40px; color: var(--st-line); margin-bottom: 12px; }

/* ── Toasts ───────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1080;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.st-toast {
  min-width: 260px;
  padding: 12px 16px;
  border-radius: var(--st-r-md);
  background: var(--st-surface);
  border: 1px solid var(--st-line);
  box-shadow: var(--st-sh-3);
  color: var(--st-ink);
  font-size: 13px;
}

@media (max-width: 640px) {
  .station-bar { padding: 14px 16px; }
  .station-bar .sb-actions { margin-left: 0; width: 100%; justify-content: flex-start; }
}

/* ── Dark-mode text contrast ──────────────────────────────────────
   The chip colors and the "-d" (deep) brand shade are picked for dark
   text on a light surface. Under [data-bs-theme="dark"] the same values
   land dark-on-dark — measured 2.4–3.2:1, all below WCAG AA. Repoint
   those *text* uses at the lighter tone tokens; the tinted backgrounds
   already carry their own alpha and stay as they are.
   ──────────────────────────────────────────────────────────────── */
[data-bs-theme="dark"] .chip-normal     { color: var(--st-teal); }
[data-bs-theme="dark"] .chip-urgent,
[data-bs-theme="dark"] .chip-waiting    { color: var(--st-amber); }
[data-bs-theme="dark"] .chip-emergency  { color: var(--st-red); }
[data-bs-theme="dark"] .chip-in-service { color: var(--st-blue); }
[data-bs-theme="dark"] .chip-completed  { color: var(--st-green); }
[data-bs-theme="dark"] .chip-seen,
[data-bs-theme="dark"] .chip-credit,
[data-bs-theme="dark"] .chip-card      { color: var(--st-violet); }
[data-bs-theme="dark"] .chip-ins       { color: var(--st-blue); }

[data-bs-theme="dark"] .station-bar .sb-eyebrow,
[data-bs-theme="dark"] .sec-label a,
[data-bs-theme="dark"] .icon-btn:hover,
[data-bs-theme="dark"] .act:hover,
[data-bs-theme="dark"] .lp:hover .lp-go { color: var(--st-teal); }
