/* ==========================================================================
   Super AI admin — light clinical-AI theme (royal blue + electric green,
   Syne display / DM Sans text), modelled on the rxmdx.com design language.
   ========================================================================== */

:root {
  color-scheme: light;

  --blue: #1a35c8;
  --blue-mid: #2545e0;
  --blue-dark: #0f1f8a;
  --blue-light: #eef1fd;
  --blue-pale: #f5f7ff;
  --green: #00e64d;
  --green-dark: #00b83d;
  --green-pale: #edfff4;
  --orange: #eb6834;
  --red: #dc2626;
  --red-pale: #fef2f2;
  --amber: #b45309;
  --amber-pale: #fffbeb;

  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --dim: #9ca3af;
  --border: #e5e7eb;
  --border-b: #c7cff5;
  --surface: #ffffff;
  --bg: #f7f8fc;

  --radius: 14px;
  --radius-lg: 18px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.04);
  --shadow-hover: 0 12px 36px rgba(26, 53, 200, 0.1);
  --shadow-blue: 0 3px 14px rgba(26, 53, 200, 0.28);

  --sidebar-w: 256px;
  --sidebar-w-collapsed: 76px;
  --topbar-h: 68px;

  --font-display: "DM Sans", system-ui, sans-serif;
  --font-body: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --brand: #1a35c8;
  --brand-hover: #2545e0;
  --brand-2: #2545e0;
  --brand-3: #0f1f8a;
  --glass: rgba(255, 255, 255, 0.92);
  --input-bg: #ffffff;
  --track: #f1f3f8;
  --grid-line: #eef0f4;
  --row-line: #f0f1f5;
  --neutral-bg: #f3f4f6;
  --hot-bg: #fff1ea;
  --hot-fg: #b1440f;
  --ok-fg: #047a2c;
  --ok-border: #b5f2c9;
  --err-border: #fecaca;
  --warn-c: #d97706;
  --low-fg: #3b4fc4;
  --code-bg: #0f1733;
  --code-fg: #d6ddff;
  --grid-ink: rgba(26, 53, 200, 0.035);
  --glow-1: rgba(26, 53, 200, 0.09);
  --glow-2: rgba(0, 230, 77, 0.07);
  --ring: rgba(26, 53, 200, 0.1);
  --tip-bg: #111827;
  --tip-fg: #ffffff;
  --tip-muted: rgba(255, 255, 255, 0.7);
  --thumb: #ffffff;
  --series-line: #2545e0;
  --series-resist: #eb6834;
  --series-specimen: #0f1f8a;
  --series-rx: #00b83d;
  --cat-1: #2545e0;
  --cat-2: #eb6834;
  --cat-3: #1baf7a;
  --cat-4: #eda100;
  --cat-5: #e87ba4;
  --cat-6: #7c4ddb;
  --cat-other: #9ca3af;
  --sev-low: #9aa8f0;
  --sev-med: #5c73e8;
  --sev-high: #0f1f8a;
}

/* Dark theme — the same token names re-stepped for a navy surface. Declared for
   an explicit choice (data-theme="dark") and for the OS preference when the
   viewer has left the switcher on "system" (no data-theme attribute). */
:root[data-theme="dark"] {
  color-scheme: dark;
  --blue: #8ea2ff;
  --blue-mid: #a9b8ff;
  --blue-dark: #c9d2ff;
  --blue-light: #1b2450;
  --blue-pale: #141b31;
  --green-dark: #1fc35a;
  --green-pale: rgba(0, 230, 77, 0.12);
  --orange: #f07a4a;
  --red: #f87171;
  --red-pale: rgba(248, 113, 113, 0.12);
  --amber: #fbbf24;
  --amber-pale: rgba(251, 191, 36, 0.12);
  --text: #e8ebf5;
  --text-2: #c5cbe0;
  --muted: #8f97b0;
  --dim: #646c86;
  --border: #232b45;
  --border-b: #3a4680;
  --surface: #111729;
  --bg: #0a0e1a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 12px 36px rgba(0, 0, 0, 0.45);
  --shadow-blue: 0 3px 14px rgba(26, 53, 200, 0.45);
  --brand: #1d38cc;
  --brand-hover: #2a48e8;
  --brand-2: #2545e0;
  --brand-3: #0f1f8a;
  --glass: rgba(13, 18, 33, 0.85);
  --input-bg: #0c1122;
  --track: #1d2540;
  --grid-line: #1f2742;
  --row-line: #1a2139;
  --neutral-bg: #1c2236;
  --hot-bg: rgba(240, 122, 74, 0.14);
  --hot-fg: #ffa47d;
  --ok-fg: #4ade80;
  --ok-border: rgba(74, 222, 128, 0.3);
  --err-border: rgba(248, 113, 113, 0.3);
  --warn-c: #f59e0b;
  --low-fg: #a3b1f8;
  --code-bg: #070b16;
  --code-fg: #d6ddff;
  --grid-ink: rgba(120, 140, 255, 0.05);
  --glow-1: rgba(60, 90, 255, 0.14);
  --glow-2: rgba(0, 230, 77, 0.06);
  --ring: rgba(120, 140, 255, 0.22);
  --tip-bg: #e8ebf5;
  --tip-fg: #0b1020;
  --tip-muted: rgba(11, 16, 32, 0.65);
  --thumb: #2a3566;
  --series-line: #6f86ff;
  --series-resist: #f07a4a;
  --series-specimen: #a3b1f8;
  --series-rx: #1fc35a;
  --cat-1: #5b74f0;
  --cat-2: #d95926;
  --cat-3: #199e70;
  --cat-4: #c98500;
  --cat-5: #d55181;
  --cat-6: #9085e9;
  --cat-other: #6b7280;
  --sev-low: #3a4fc4;
  --sev-med: #6378ee;
  --sev-high: #a3b1f8;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --blue: #8ea2ff;
    --blue-mid: #a9b8ff;
    --blue-dark: #c9d2ff;
    --blue-light: #1b2450;
    --blue-pale: #141b31;
    --green-dark: #1fc35a;
    --green-pale: rgba(0, 230, 77, 0.12);
    --orange: #f07a4a;
    --red: #f87171;
    --red-pale: rgba(248, 113, 113, 0.12);
    --amber: #fbbf24;
    --amber-pale: rgba(251, 191, 36, 0.12);
    --text: #e8ebf5;
    --text-2: #c5cbe0;
    --muted: #8f97b0;
    --dim: #646c86;
    --border: #232b45;
    --border-b: #3a4680;
    --surface: #111729;
    --bg: #0a0e1a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 12px 36px rgba(0, 0, 0, 0.45);
    --shadow-blue: 0 3px 14px rgba(26, 53, 200, 0.45);
    --brand: #1d38cc;
    --brand-hover: #2a48e8;
    --brand-2: #2545e0;
    --brand-3: #0f1f8a;
    --glass: rgba(13, 18, 33, 0.85);
    --input-bg: #0c1122;
    --track: #1d2540;
    --grid-line: #1f2742;
    --row-line: #1a2139;
    --neutral-bg: #1c2236;
    --hot-bg: rgba(240, 122, 74, 0.14);
    --hot-fg: #ffa47d;
    --ok-fg: #4ade80;
    --ok-border: rgba(74, 222, 128, 0.3);
    --err-border: rgba(248, 113, 113, 0.3);
    --warn-c: #f59e0b;
    --low-fg: #a3b1f8;
    --code-bg: #070b16;
    --code-fg: #d6ddff;
    --grid-ink: rgba(120, 140, 255, 0.05);
    --glow-1: rgba(60, 90, 255, 0.14);
    --glow-2: rgba(0, 230, 77, 0.06);
    --ring: rgba(120, 140, 255, 0.22);
    --tip-bg: #e8ebf5;
    --tip-fg: #0b1020;
    --tip-muted: rgba(11, 16, 32, 0.65);
  --thumb: #2a3566;
    --series-line: #6f86ff;
    --series-resist: #f07a4a;
    --series-specimen: #a3b1f8;
    --series-rx: #1fc35a;
    --cat-1: #5b74f0;
    --cat-2: #d95926;
    --cat-3: #199e70;
    --cat-4: #c98500;
    --cat-5: #d55181;
    --cat-6: #9085e9;
    --cat-other: #6b7280;
    --sev-low: #3a4fc4;
    --sev-med: #6378ee;
    --sev-high: #a3b1f8;
  }
}

/* ---------------------------------------------------------------- base */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Faint blueprint grid + soft blue/green glows behind every page. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid-ink) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-ink) 1px, transparent 1px);
  background-size: 52px 52px;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(600px circle at 95% -5%, var(--glow-1), transparent 70%),
    radial-gradient(420px circle at 10% 100%, var(--glow-2), transparent 70%);
  animation: glowDrift 18s ease-in-out infinite alternate;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0;
  color: var(--text);
}
h1 { font-size: clamp(24px, 2.6vw, 32px); }
h2 { font-size: 20px; }
h3 { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; }

p { margin: 0; }

a {
  color: var(--blue);
  text-decoration: none;
  transition: color 0.18s;
}
a:hover { color: var(--blue-mid); }

.icon { flex-shrink: 0; }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }

::selection { background: var(--blue-light); color: var(--blue-dark); }

/* ---------------------------------------------------------------- motion */

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}
@keyframes ping {
  0% { transform: scale(1); opacity: 0.55; }
  100% { transform: scale(2.6); opacity: 0; }
}
@keyframes glowDrift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-40px, 30px, 0); }
}
@keyframes floatY {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
@keyframes shine {
  from { transform: translateX(-120%) skewX(-20deg); }
  to { transform: translateX(260%) skewX(-20deg); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes scan {
  from { transform: translateY(-100%); }
  to { transform: translateY(100%); }
}

/* Staggered entrance: <div class="reveal" style="--d:3"> */
.reveal {
  animation: fadeUp 0.6s var(--ease) both;
  animation-delay: calc(var(--d, 0) * 70ms + 80ms);
}

.live-dot {
  position: relative;
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
  animation: blink 2s infinite;
}
.live-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--green);
  animation: ping 2s ease-out infinite;
}

/* ---------------------------------------------------------------- shell */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--glass);
  backdrop-filter: blur(14px);
  border-right: 1px solid var(--border);
  z-index: 60;
  transition: width 0.3s var(--ease), transform 0.3s var(--ease);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  height: var(--topbar-h);
  padding: 0 1rem 0 1.15rem;
  border-bottom: 1px solid var(--border);
}

.brand-mark {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(140deg, var(--brand-2), var(--brand-3));
  box-shadow: var(--shadow-blue);
}
.brand-mark::after {
  content: "";
  position: absolute;
  top: -3px;
  right: -3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid var(--surface);
  animation: blink 2.4s infinite;
}

.brand-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.03em;
  color: var(--text);
}
.brand-text em {
  font-style: normal;
  color: var(--blue);
}

.sidebar-collapse-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s var(--ease);
}
.sidebar-collapse-toggle:hover {
  border-color: var(--border-b);
  color: var(--blue);
  background: var(--blue-light);
}

.sidebar-section-label {
  padding: 1.25rem 1.35rem 0.4rem;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0 0.75rem 1rem;
}

.sidebar-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.62rem 0.8rem;
  margin-bottom: 2px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  transition: color 0.18s, background 0.18s, transform 0.18s var(--ease);
}
.sidebar-link:hover {
  color: var(--blue);
  background: var(--blue-pale);
  transform: translateX(2px);
}
.sidebar-link.active {
  color: var(--blue);
  font-weight: 700;
  background: var(--blue-light);
}
.sidebar-link.active::before {
  content: "";
  position: absolute;
  left: -0.75rem;
  top: 22%;
  bottom: 22%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--green);
  box-shadow: 0 0 12px rgba(0, 230, 77, 0.6);
}

.sidebar-foot {
  padding: 0.9rem;
}

.engine-card {
  position: relative;
  overflow: hidden;
  padding: 1rem;
  border-radius: var(--radius);
  color: #fff;
  background: var(--brand);
}
.engine-card::before {
  content: "";
  position: absolute;
  top: -50%;
  right: -30%;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.12), transparent 70%);
}
.engine-card::after {
  content: "";
  position: absolute;
  bottom: -60%;
  left: -10%;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 230, 77, 0.25), transparent 70%);
}
.engine-card-status {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
}
.engine-card strong {
  position: relative;
  display: block;
  margin-top: 0.35rem;
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: -0.02em;
}
.engine-card span.engine-card-sub {
  position: relative;
  display: block;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
}

/* collapsed rail */
html.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
html.sidebar-collapsed .brand-text,
html.sidebar-collapsed .sidebar-link-text,
html.sidebar-collapsed .sidebar-section-label,
html.sidebar-collapsed .engine-card { display: none; }
html.sidebar-collapsed .sidebar-brand { flex-direction: column; justify-content: center; gap: 0.4rem; padding: 0.5rem; height: auto; min-height: var(--topbar-h); }
html.sidebar-collapsed .sidebar-collapse-toggle { transform: rotate(180deg); }
html.sidebar-collapsed .sidebar-nav { padding-top: 1rem; }
html.sidebar-collapsed .sidebar-link { justify-content: center; padding: 0.7rem; }
html.sidebar-collapsed .sidebar-link:hover { transform: none; }

.sidebar-backdrop { display: none; }

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ---------------------------------------------------------------- topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 2rem;
  background: var(--glass);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  animation: slideDown 0.5s var(--ease) both;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}
.topbar-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.topbar-crumb {
  font-size: 13px;
  color: var(--dim);
  white-space: nowrap;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.topbar-right form { margin: 0; }

.topbar-search {
  position: relative;
  display: flex;
  align-items: center;
}
.topbar-search .icon {
  position: absolute;
  left: 0.8rem;
  color: var(--dim);
  pointer-events: none;
}
.topbar-search input {
  width: 240px;
  height: 38px;
  padding: 0 0.9rem 0 2.35rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--blue-pale);
  font: inherit;
  font-size: 13px;
  color: var(--text);
  transition: all 0.25s var(--ease);
}
.topbar-search input:focus {
  outline: none;
  width: 300px;
  border-color: var(--blue);
  background: var(--input-bg);
  box-shadow: 0 0 0 4px var(--ring);
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
}
.admin-avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 14px;
  color: #fff;
  background: linear-gradient(140deg, var(--brand-2), var(--brand-3));
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--border-b);
}
.admin-avatar::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid var(--surface);
}

/* ---------------------------------------------------------------- content */

.content {
  flex: 1;
  width: 100%;
  /* max-width: 1480px; */
  margin: 0 auto;
  padding: 1.75rem 2rem 3rem;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.page-header h1 {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.page-header p {
  margin-top: 0.45rem;
  color: var(--muted);
  font-size: 15px;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0.7rem;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--blue);
}
.eyebrow::before {
  content: "";
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: var(--green);
}

.pill-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  border-radius: 99px;
  background: var(--blue-light);
  border: 1px solid var(--border-b);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--blue);
}

/* ---------------------------------------------------------------- cards */

.card {
  position: relative;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  margin-bottom: 1.5rem;
  transition: border-color 0.22s, box-shadow 0.22s, transform 0.22s var(--ease);
}
.card-hover:hover {
  border-color: var(--border-b);
  box-shadow: var(--shadow-hover);
  transform: translateY(-3px);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
}
.card-head h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.card-head p {
  margin-top: 0.2rem;
  font-size: 12.5px;
  color: var(--muted);
}
.card-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}
.card-link .icon { transition: transform 0.2s var(--ease); }
.card-link:hover .icon { transform: translateX(3px); }

.grid {
  display: grid;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}
.grid > .card { margin-bottom: 0; }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-1-1 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* ---------------------------------------------------------------- hero */

.hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 2rem;
  padding: 2.2rem 2.4rem;
  margin-bottom: 1.25rem;
  border-radius: 20px;
  color: #fff;
  background: var(--brand);
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: linear-gradient(100deg, transparent 20%, #000 90%);
}
.hero-glow-1,
.hero-glow-2 {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  animation: floatY 7s ease-in-out infinite;
}
.hero-glow-1 {
  top: -60%;
  right: -5%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.1), transparent 70%);
}
.hero-glow-2 {
  bottom: -70%;
  left: 20%;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(0, 230, 77, 0.2), transparent 70%);
  animation-delay: -3s;
}
.hero > :not(.hero-glow-1):not(.hero-glow-2) { position: relative; }
.hero .pill-eyebrow {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.22);
  color: #fff;
}
.hero h1 {
  margin-top: 0.9rem;
  color: #fff;
  font-size: clamp(26px, 3vw, 38px);
}
.hero h1 span { color: var(--green); }
.hero p {
  margin-top: 0.6rem;
  max-width: 520px;
  font-size: 15px;
  color: rgba(255, 255, 255, 0.78);
}

/* date-range segmented control */
.range-tabs {
  display: inline-flex;
  gap: 3px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(6px);
}
.range-tabs a {
  padding: 0.45rem 0.85rem;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.82);
  white-space: nowrap;
  transition: all 0.2s var(--ease);
}
.range-tabs a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}
.range-tabs a.active {
  color: var(--brand);
  background: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}

/* ---------------------------------------------------------------- KPI tiles */

.kpi {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.kpi-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  color: var(--blue);
  background: var(--blue-light);
  border: 1px solid var(--border-b);
  transition: transform 0.3s var(--ease);
}
.kpi:hover .kpi-icon { transform: rotate(-8deg) scale(1.08); }
.kpi-label {
  margin-top: 1rem;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}
.kpi-value {
  margin-top: 0.15rem;
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.kpi-value small {
  font-size: 0.5em;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: -0.01em;
}
.kpi-foot {
  margin-top: 0.45rem;
  font-size: 12.5px;
  color: var(--muted);
}
.kpi-spark {
  display: block;
  width: 100%;
  height: 38px;
  margin-top: 0.8rem;
}

.delta {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}
.delta-up { color: var(--ok-fg); background: var(--green-pale); }
.delta-down { color: var(--red); background: var(--red-pale); }
.delta-flat { color: var(--muted); background: var(--neutral-bg); }

/* ---------------------------------------------------------------- charts */

.chart {
  position: relative;
  width: 100%;
}
.chart svg { display: block; overflow: visible; }
.chart-area { height: 280px; flex: 1; min-height: 280px; }
.card-chart { display: flex; flex-direction: column; }

.chart .grid-line { stroke: var(--grid-line); stroke-width: 1; }
.chart .axis-label { fill: var(--dim); font-size: 11px; font-family: var(--font-body); }
.chart .series-line {
  fill: none;
  stroke: var(--series-line);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.chart .series-area { opacity: 0; transition: opacity 1s ease 0.6s; }
.chart.is-drawn .series-area { opacity: 1; }
.chart .crosshair { stroke: var(--border-b); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .hover-dot { fill: var(--surface); stroke: var(--series-line); stroke-width: 2; }
.chart .last-dot { fill: var(--green-dark); stroke: var(--surface); stroke-width: 2; }
.chart .last-ping { fill: var(--green); transform-box: fill-box; transform-origin: center; animation: ping 2s ease-out infinite; }

.viz-tip {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  min-width: 120px;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  background: var(--tip-bg);
  color: var(--tip-fg);
  font-size: 12px;
  box-shadow: 0 10px 30px rgba(17, 24, 39, 0.25);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s, transform 0.12s;
}
.viz-tip.show { opacity: 1; transform: translateY(0); }
.viz-tip strong {
  display: block;
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: -0.02em;
}
.viz-tip span { color: var(--tip-muted); }
.viz-tip .tip-key {
  display: inline-block;
  width: 12px;
  height: 2px;
  margin-right: 6px;
  vertical-align: middle;
  border-radius: 2px;
}

/* donut */
.donut-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
}
.donut {
  position: relative;
  width: 190px;
  height: 190px;
}
.donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut circle.seg {
  fill: none;
  stroke-width: 22;
  cursor: pointer;
  transition: stroke-dasharray 1.1s var(--ease), stroke-width 0.2s var(--ease), opacity 0.2s;
}
.donut circle.seg:hover,
.donut circle.seg.hl { stroke-width: 28; }
.donut.dim circle.seg:not(.hl) { opacity: 0.35; }
.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}
.donut-center strong {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
}
.donut-center span {
  max-width: 110px;
  margin-top: 0.3rem;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.25;
}

.legend {
  width: 100%;
  list-style: none;
  margin: 0;
  padding: 0;
}
.legend li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  font-size: 12.5px;
  cursor: default;
  transition: background 0.15s;
}
.legend li:hover,
.legend li.hl { background: var(--blue-pale); }
.legend .swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}
.legend .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
}
.legend .val {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.legend .pct {
  width: 3.2em;
  text-align: right;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

/* horizontal bars */
.hbars {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.hbar-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.3rem;
  font-size: 12.5px;
}
.hbar-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
  font-weight: 500;
}
.hbar-val {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.hbar-track {
  height: 8px;
  border-radius: 99px;
  background: var(--track);
  overflow: hidden;
}
/* Width comes from --w; the grow-in is a keyframe from 0 so it works without JS. */
.hbar-fill {
  height: 100%;
  width: var(--w, 0);
  border-radius: 0 4px 4px 0;
  background: var(--bar, var(--series-line));
  animation: growX 1.1s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 60ms + 250ms);
}
@keyframes growX {
  from { width: 0; }
}
.hbar-row:hover .hbar-fill { filter: brightness(1.12); }
.hbar-row:hover .hbar-name { color: var(--text); }

/* stacked severity bar */
.stack {
  display: flex;
  gap: 2px;
  height: 14px;
  border-radius: 99px;
  overflow: hidden;
  background: var(--track);
}
.stack-seg {
  width: var(--w, 0);
  height: 100%;
  cursor: pointer;
  transition: filter 0.15s;
  animation: growX 1.1s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 120ms + 250ms);
}
.stack-seg:hover { filter: brightness(1.15); }
.stack-legend {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.8rem;
}
.stack-legend div { font-size: 12px; color: var(--muted); }
.stack-legend strong {
  display: block;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}
.stack-legend .swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 5px;
  border-radius: 2px;
}

.divider {
  height: 1px;
  margin: 1.3rem 0;
  background: var(--border);
}

/* medication ranking */
.rank-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: rank;
}
.rank-list li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px dashed var(--border);
}
.rank-list li:last-child { border-bottom: none; }
.rank-list li::before {
  counter-increment: rank;
  content: counter(rank);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 13px;
  color: var(--blue);
  background: var(--blue-light);
}
.rank-list li:first-child::before {
  color: #fff;
  background: var(--brand);
}
.rank-list .hbar-track { margin-top: 0.35rem; height: 6px; }
.rank-name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rank-val {
  font-weight: 700;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* recent activity feed */
.feed {
  list-style: none;
  margin: 0;
  padding: 0;
}
.feed li a {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.8rem;
  padding: 0.65rem 0.6rem;
  margin: 0 -0.6rem;
  border-radius: 12px;
  color: inherit;
  transition: background 0.18s, transform 0.18s var(--ease);
}
.feed li a:hover {
  background: var(--blue-pale);
  transform: translateX(3px);
}
.feed-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: var(--blue);
  background: var(--blue-light);
}
.feed-title {
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.feed-sub {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.feed-meta {
  text-align: right;
  font-size: 11.5px;
  color: var(--dim);
  white-space: nowrap;
}

/* ---------------------------------------------------------------- confidence & repeats */

/* Ring gauge: pathLength=100 so the offset is simply 100 - value. */
.gauge {
  position: relative;
  width: var(--size, 132px);
  height: var(--size, 132px);
  flex-shrink: 0;
}
.gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge circle { fill: none; stroke-width: 9; }
.gauge .gauge-track { stroke: var(--gauge-track, var(--track)); }
.gauge .gauge-val {
  stroke: var(--gauge-color, var(--series-line));
  stroke-linecap: round;
  stroke-dasharray: 100 100;
  stroke-dashoffset: var(--off, 100);
  animation: gaugeIn 1.5s 0.3s var(--ease) both;
}
@keyframes gaugeIn {
  from { stroke-dashoffset: 100; }
}
.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.gauge-center strong {
  font-family: var(--font-display);
  font-size: calc(var(--size, 132px) * 0.24);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}
.gauge-center strong small { font-size: 0.5em; color: var(--muted); }
.gauge-center span {
  margin-top: 0.3rem;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.hero .gauge { --gauge-track: rgba(255, 255, 255, 0.16); --gauge-color: var(--green); }
.hero .gauge-center strong { color: #fff; }
.hero .gauge-center strong small,
.hero .gauge-center span { color: rgba(255, 255, 255, 0.7); }

.kpi .gauge { --size: 58px; }
.kpi .gauge circle { stroke-width: 11; }

/* Inline meter for table cells: number + short bar, colour by band (the number always carries the value). */
.conf {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.conf-bar {
  position: relative;
  width: 54px;
  height: 6px;
  border-radius: 99px;
  background: var(--track);
  overflow: hidden;
}
.conf-bar i {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--w, 0);
  border-radius: 99px;
  background: var(--c, var(--series-line));
  animation: growX 0.9s var(--ease) both;
  animation-delay: calc(var(--r, 0) * 25ms + 150ms);
}
.conf-high { --c: var(--green-dark); color: var(--ok-fg); }
.conf-mid { --c: var(--series-line); color: var(--blue); }
.conf-low { --c: var(--warn-c); color: var(--amber); }
.conf-none { color: var(--dim); font-weight: 500; font-size: 12.5px; }

.repeat-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--blue);
  background: var(--blue-light);
}
.repeat-badge.hot { color: var(--hot-fg); background: var(--hot-bg); }
.repeat-badge.none { color: var(--dim); background: var(--neutral-bg); font-weight: 600; }

/* vertical column histogram (server-rendered, grows in via keyframes) */
.cols {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 150px;
  padding-top: 1.4rem;
}
.col {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  outline: none;
}
.col-val {
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.col-bar {
  width: 100%;
  max-width: 56px;
  height: var(--h, 0);
  min-height: 3px;
  border-radius: 6px 6px 0 0;
  background: var(--c, var(--series-line));
  transform-origin: bottom;
  animation: growY 1s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 90ms + 250ms);
  transition: filter 0.15s, transform 0.15s;
}
.col:hover .col-bar,
.col:focus-visible .col-bar { filter: brightness(1.12); }
@keyframes growY {
  from { transform: scaleY(0); }
}
.cols-axis {
  display: flex;
  gap: 10px;
  padding-top: 0.45rem;
  border-top: 1px solid var(--border);
}
.cols-axis span {
  flex: 1;
  text-align: center;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
}

.conf-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 1.75rem;
}
.conf-stat-row {
  display: flex;
  gap: 1.5rem;
  margin-top: 0.9rem;
}
.conf-stat-row div { font-size: 12px; color: var(--muted); }
.conf-stat-row strong {
  display: block;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.type-conf-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 60px auto;
  align-items: center;
  gap: 0.9rem;
  padding: 0.5rem 0;
  border-bottom: 1px dashed var(--border);
  font-size: 13px;
}
.type-conf-row:last-child { border-bottom: none; }
.type-conf-row .n { color: var(--dim); font-size: 12px; text-align: right; }

.hero-stats {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.hero-stat {
  text-align: center;
  color: rgba(255, 255, 255, 0.72);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.hero-stat strong {
  display: block;
  margin-bottom: 0.2rem;
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  color: #fff;
  text-transform: none;
}
.hero-stat-divider {
  width: 1px;
  align-self: stretch;
  background: rgba(255, 255, 255, 0.18);
}

/* ---------------------------------------------------------------- theme switcher */

.theme-switch {
  position: relative;
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 11px;
  background: var(--blue-pale);
  border: 1.5px solid var(--border);
}
.theme-switch button {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s;
}
.theme-switch button:hover { color: var(--text); }
.theme-switch button[aria-pressed="true"] { color: var(--blue); }
.theme-switch button:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
/* sliding thumb behind the active option */
.theme-switch::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 30px;
  height: 28px;
  border-radius: 8px;
  background: var(--thumb);
  box-shadow: 0 2px 8px rgba(17, 24, 39, 0.12);
  transform: translateX(calc(var(--pos, 0) * 32px));
  transition: transform 0.35s var(--ease);
}
.theme-switch[data-pos="1"] { --pos: 1; }
.theme-switch[data-pos="2"] { --pos: 2; }
.theme-switch .icon { transition: transform 0.4s var(--ease); }
.theme-switch button[aria-pressed="true"] .icon { transform: rotate(-20deg) scale(1.08); }

.login-theme {
  position: fixed;
  top: 1.1rem;
  right: 1.1rem;
  z-index: 10;
}

/* Theme change: a circular reveal from the clicked button where the View
   Transitions API exists, otherwise a short colour cross-fade. */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}
html.theme-fade,
html.theme-fade *,
html.theme-fade *::before,
html.theme-fade *::after {
  transition: background-color 0.35s ease, border-color 0.35s ease, color 0.35s ease, fill 0.35s ease, stroke 0.35s ease !important;
}

/* ---------------------------------------------------------------- buttons */

.btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s var(--ease);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}
.btn-primary {
  color: #fff;
  background: var(--brand);
  box-shadow: var(--shadow-blue);
}
.btn-primary::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 40%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.28), transparent);
  transform: translateX(-120%) skewX(-20deg);
}
.btn-primary:hover {
  color: #fff;
  background: var(--brand-hover);
  transform: translateY(-2px);
}
.btn-primary:hover::after { animation: shine 0.8s var(--ease); }
.btn-secondary {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) {
  color: var(--blue);
  border-color: var(--blue);
  background: var(--blue-light);
}
.btn-green {
  color: #fff;
  background: var(--green-dark);
  box-shadow: 0 3px 14px rgba(0, 184, 61, 0.3);
}
.btn-green:hover { color: #fff; background: #00a336; transform: translateY(-2px); }
.btn-sm { padding: 7px 14px; font-size: 13px; border-radius: 8px; }
.btn-icon { padding: 0; width: 34px; height: 34px; }
.btn-block { width: 100%; }

/* ---------------------------------------------------------------- forms */

.form-group { margin-bottom: 1.1rem; }
.form-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}
.input,
.form-group input,
.select-control {
  width: 100%;
  height: 44px;
  padding: 0 0.95rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--input-bg);
  font: inherit;
  font-size: 14px;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.select-control {
  width: auto;
  height: 38px;
  padding-right: 2rem;
  font-size: 13px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  cursor: pointer;
}
.input:focus,
.form-group input:focus,
.select-control:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 4px var(--ring);
}

.search-box {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 1;
  min-width: 220px;
  max-width: 420px;
}
.search-box .icon {
  position: absolute;
  left: 0.8rem;
  color: var(--dim);
  pointer-events: none;
}
.search-box input {
  width: 100%;
  height: 38px;
  padding: 0 0.9rem 0 2.35rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--input-bg);
  font: inherit;
  font-size: 13px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-box input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 4px var(--ring);
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 1.2rem;
}

/* ---------------------------------------------------------------- tables */

.table-wrap {
  overflow-x: auto;
  margin: 0 -1.4rem;
  padding: 0 1.4rem;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
thead th {
  padding: 0.7rem 0.9rem;
  text-align: left;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--blue-pale);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
thead th:first-child { border-radius: 10px 0 0 10px; border-left: 1px solid var(--border); }
thead th:last-child { border-radius: 0 10px 10px 0; border-right: 1px solid var(--border); }
tbody td {
  padding: 0.8rem 0.9rem;
  white-space: nowrap;
  border-bottom: 1px solid var(--row-line);
  vertical-align: middle;
}
tbody tr {
  animation: fadeUp 0.45s var(--ease) both;
  animation-delay: calc(var(--r, 0) * 25ms);
  transition: background 0.15s;
}
tbody tr:hover { background: var(--blue-pale); }
tbody tr:last-child td { border-bottom: none; }
tr.row-link { cursor: pointer; }
tr.row-link:hover td:first-child a { color: var(--blue-mid); }

.cell-primary { font-weight: 600; }
.cell-secondary { font-size: 12px; color: var(--muted); }

.count-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  padding: 0 8px;
  border-radius: 7px;
  font-weight: 700;
  font-size: 12px;
  color: var(--blue);
  background: var(--blue-light);
}
.count-chip.zero { color: var(--dim); background: var(--neutral-bg); }
.count-chip.warn { color: var(--hot-fg); background: var(--hot-bg); }

/* ---------------------------------------------------------------- badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 3px 10px 3px 8px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--muted);
  background: var(--neutral-bg);
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-green { color: var(--ok-fg); background: var(--green-pale); }
.badge-low { color: var(--low-fg); background: var(--blue-light); }
.badge-med { color: var(--amber); background: var(--amber-pale); }
.badge-high { color: var(--red); background: var(--red-pale); }
.badge-blue { color: var(--blue); background: var(--blue-light); }

/* ---------------------------------------------------------------- pagination */

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-top: 1.1rem;
  margin-top: 0.4rem;
  border-top: 1px solid var(--border);
}
.pagination-summary { font-size: 13px; color: var(--muted); }
.pagination-summary strong { color: var(--text); }
.pagination-controls { display: flex; align-items: center; gap: 0.6rem; }
.pagination-page { font-size: 13px; font-weight: 600; white-space: nowrap; }

/* ---------------------------------------------------------------- flash / empty */

.flash {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 1rem;
  margin-bottom: 1.25rem;
  border-radius: 12px;
  border: 1.5px solid;
  font-size: 14px;
  font-weight: 500;
  animation: fadeUp 0.4s var(--ease) both;
}
.flash-success { color: var(--ok-fg); background: var(--green-pale); border-color: var(--ok-border); }
.flash-error { color: var(--red); background: var(--red-pale); border-color: var(--err-border); }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--muted);
}
.empty-state .icon { width: 36px; height: 36px; color: var(--border-b); }

/* ---------------------------------------------------------------- detail page */

.detail-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.back-link:hover { color: var(--blue); }
.back-link .icon { transition: transform 0.2s var(--ease); }
.back-link:hover .icon { transform: translateX(-3px); }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 1.1rem 1.5rem;
  margin: 0;
}
.detail-grid dt {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}
.detail-grid dd {
  margin: 0.25rem 0 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.chip-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.chip-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 600;
  transition: all 0.2s var(--ease);
  animation: fadeUp 0.45s var(--ease) both;
  animation-delay: calc(var(--r, 0) * 50ms + 200ms);
}
.chip-row:hover {
  border-color: var(--border-b);
  background: var(--blue-pale);
  transform: translateX(3px);
}
.chip-row .icon { color: var(--blue); }
.chip-row > span { display: flex; align-items: center; gap: 0.55rem; min-width: 0; }

.rx-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
}
.rx-card {
  padding: 1rem 1.1rem;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  transition: all 0.22s var(--ease);
  animation: fadeUp 0.45s var(--ease) both;
  animation-delay: calc(var(--r, 0) * 60ms + 250ms);
}
.rx-card:hover {
  border-color: var(--border-b);
  box-shadow: var(--shadow-hover);
  transform: translateY(-3px);
}
.rx-card h4 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.rx-brand { font-size: 12px; color: var(--muted); }
.rx-dose {
  margin: 0.7rem 0;
  padding: 0.5rem 0.65rem;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--blue-dark);
  background: var(--blue-pale);
}
.rx-meter { margin-top: 0.45rem; font-size: 11.5px; color: var(--muted); }
.rx-meter .hbar-track { height: 5px; margin-top: 0.2rem; }

.section-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 1rem;
  border-radius: 12px;
  background: var(--blue-pale);
  border: 1px solid var(--border);
}
.section-tabs button {
  padding: 0.45rem 0.9rem;
  border: none;
  border-radius: 9px;
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s var(--ease);
}
.section-tabs button:hover { color: var(--blue); }
.section-tabs button.active {
  color: var(--blue);
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(26, 53, 200, 0.12);
}
[data-tab-panel][hidden] { display: none; }

.json-block summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  list-style: none;
  font-family: var(--font-display);
  font-weight: 700;
}
.json-block summary::-webkit-details-marker { display: none; }
.json-block summary .icon { transition: transform 0.25s var(--ease); color: var(--blue); }
.json-block[open] summary .icon { transform: rotate(90deg); }
.json-block pre {
  margin: 1rem 0 0;
  padding: 1rem 1.1rem;
  max-height: 34rem;
  overflow: auto;
  border-radius: 12px;
  background: var(--code-bg);
  color: var(--code-fg);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  animation: fadeIn 0.3s ease both;
}

/* ---------------------------------------------------------------- login */

.login-page {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  min-height: 100vh;
}
.login-aside {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 3rem;
  color: #fff;
  background: var(--brand);
}
.login-aside::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 52px 52px;
}
.login-aside > :not(.hero-glow-1):not(.hero-glow-2) { position: relative; }
.login-aside .hero-glow-1 { top: -20%; right: -30%; }
.login-aside .hero-glow-2 { bottom: -20%; left: -10%; width: 420px; height: 420px; }
.login-aside .brand-text { color: #fff; }
.login-aside .brand-text em { color: var(--green); }
.login-aside .brand-mark { background: #fff; color: var(--brand); }
.login-aside .brand-mark::after { border-color: var(--brand); }
.login-aside h2 {
  max-width: 460px;
  color: #fff;
  font-size: clamp(30px, 3.4vw, 46px);
  line-height: 1.06;
  animation: fadeUp 0.6s 0.3s var(--ease) both;
}
.login-aside h2 span { color: var(--green); }
.login-aside p {
  max-width: 420px;
  margin-top: 1rem;
  font-size: 15px;
  color: rgba(255, 255, 255, 0.75);
  animation: fadeUp 0.6s 0.45s var(--ease) both;
}
.login-brand-row { display: flex; align-items: center; gap: 0.7rem; }
.trust-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 1.8rem;
  animation: fadeUp 0.6s 0.6s var(--ease) both;
}
.trust-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.trust-pill .icon { color: var(--green); }

/* floating preview card on the login aside */
.login-preview {
  width: min(360px, 100%);
  padding: 1rem 1.1rem;
  border-radius: 16px;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 20px 50px rgba(8, 15, 70, 0.35);
  animation: fadeUp 0.7s 0.75s var(--ease) both, floatY 6s 1.5s ease-in-out infinite;
}
.login-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.login-preview-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.7rem;
  font-size: 13px;
  font-weight: 600;
}
.login-preview .hbar-track { margin-top: 0.3rem; }
.login-preview .hbar-fill { animation-delay: 1s; animation-duration: 1.4s; }

.login-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--surface);
}
.login-card {
  width: 100%;
  max-width: 400px;
  animation: fadeUp 0.6s 0.2s var(--ease) both;
}
.login-card h1 { margin-top: 1rem; font-size: 32px; }
.login-card .subtitle {
  margin: 0.5rem 0 1.8rem;
  color: var(--muted);
  font-size: 15px;
}
.login-card .btn { margin-top: 0.4rem; padding: 13px 24px; }
.login-foot {
  margin-top: 2rem;
  font-size: 12px;
  color: var(--dim);
  text-align: center;
}

/* ---------------------------------------------------------------- error pages */

.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  min-height: 100vh;
  padding: 2rem;
  text-align: center;
}
.error-page .code {
  font-family: var(--font-display);
  font-size: clamp(90px, 16vw, 160px);
  font-weight: 800;
  letter-spacing: -0.06em;
  line-height: 1;
  background: linear-gradient(140deg, var(--brand-2), var(--brand-3) 60%, var(--green-dark));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: fadeUp 0.6s var(--ease) both, floatY 6s 0.6s ease-in-out infinite;
}
.error-page h1 { animation: fadeUp 0.6s 0.15s var(--ease) both; }
.error-page p { color: var(--muted); max-width: 420px; animation: fadeUp 0.6s 0.25s var(--ease) both; }
.error-page .btn { margin-top: 1rem; animation: fadeUp 0.6s 0.35s var(--ease) both; }

/* ---------------------------------------------------------------- responsive */

@media (max-width: 1280px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 > :last-child { grid-column: 1 / -1; }
}

@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    left: 0;
    transform: translateX(-100%);
    width: var(--sidebar-w) !important;
    box-shadow: 0 20px 60px rgba(17, 24, 39, 0.2);
  }
  .sidebar.open { transform: translateX(0); }
  html.sidebar-collapsed .brand-text,
  html.sidebar-collapsed .sidebar-link-text,
  html.sidebar-collapsed .sidebar-section-label { display: initial; }
  html.sidebar-collapsed .engine-card { display: block; }
  .sidebar-collapse-toggle { display: none; }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(17, 24, 39, 0.35);
    backdrop-filter: blur(2px);
    animation: fadeIn 0.2s ease both;
  }
  .sidebar.open + .sidebar-backdrop { display: block; }
  .menu-toggle { display: inline-flex; }
  .grid-2-1,
  .grid-1-1 { grid-template-columns: minmax(0, 1fr); }
  .topbar-search input { width: 180px; }
  .topbar-search input:focus { width: 220px; }
  .login-page { grid-template-columns: 1fr; }
  .login-aside { display: none; }
}

@media (max-width: 720px) {
  .content { padding: 1.25rem 1rem 2.5rem; }
  .topbar { padding: 0 1rem; }
  .topbar-search,
  .admin-badge-name,
  .topbar-crumb,
  .logout-text { display: none; }
  .hero { grid-template-columns: 1fr; padding: 1.6rem 1.4rem; }
  .range-tabs { overflow-x: auto; max-width: 100%; }
  .grid-kpi,
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .conf-panel { grid-template-columns: minmax(0, 1fr); justify-items: center; }
  .card { padding: 1.15rem; }
  .table-wrap { margin: 0 -1.15rem; padding: 0 1.15rem; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
  }
}
