/* rxBILLION brand tokens from rxbillion.com: dark green sidebar, off-white pages. */
:root {
  --forest: #0A241C;
  --forest-2: #081E17;
  --green: #0E3A2A;
  --green-2: #145A3F;
  --cream: #F3EFE6;
  --gold: #C9A44A;
  --gold-2: #E3C46F;
  --gold-line: rgba(201, 164, 74, 0.18);

  /* Off-white content */
  --page: #F5F2EA;
  --card: #FFFDF8;
  --ink: #0B1310;
  --ink-2: rgba(11, 19, 16, 0.66);
  --ink-3: rgba(11, 19, 16, 0.5);
  --rule: rgba(11, 19, 16, 0.08);
  --rule-2: rgba(11, 19, 16, 0.14);

  /* Chart roles, validated on --card: gold mark >= 3:1; sage is de-emphasis with table relief. */
  --mark: #A8853A;
  --mark-muted: #B4BFB8;
  --grid: rgba(11, 19, 16, 0.08);
  --axis: rgba(11, 19, 16, 0.24);
  --warning: #fab219;

  --font-head: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Archivo", system-ui, sans-serif;
  --font-script: "Pinyon Script", cursive;

  --sidebar-w: 248px;
  --sidebar-w-collapsed: 72px;

  /* Page content width; the page centres beyond it and the header lines up with it. */
  --page-max: 1680px;
  --page-pad: 28px;
}

* { box-sizing: border-box; }

/* The hidden attribute always wins over component display rules. */
[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

svg { flex: none; }

button:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

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

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns 0.2s ease;
}

.shell.is-collapsed { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }

/* ---------- sidebar ---------- */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 12px 12px;
  background: linear-gradient(180deg, var(--forest) 0%, var(--forest-2) 100%);
  border-right: 1px solid var(--gold-line);
  color: var(--cream);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 48px;
  padding: 0 4px 10px 8px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--gold-line);
}

.logo {
  display: inline-flex;
  align-items: center;
  color: var(--cream);
  text-decoration: none;
  white-space: nowrap;
}

.logo-rx { font-family: var(--font-script); font-size: 30px; line-height: 1; }

.logo b {
  font-family: var(--font-head);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.22em;
  margin-left: 8px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.icon-btn svg, .nav svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar .icon-btn { color: rgba(243, 239, 230, 0.7); }
.sidebar .icon-btn:hover { color: var(--cream); background: rgba(243, 239, 230, 0.07); }
.close-btn { display: none; }

.sidebar-label {
  padding: 14px 12px 6px;
  font-family: var(--font-head);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold-2);
  opacity: 0.85;
  white-space: nowrap;
}

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  color: rgba(243, 239, 230, 0.78);
  text-decoration: none;
  font-size: 14px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.nav a svg { color: rgba(227, 196, 111, 0.85); }
.nav a:hover { background: rgba(243, 239, 230, 0.06); color: var(--cream); }

.nav a[aria-current="page"] {
  background: rgba(201, 164, 74, 0.16);
  color: var(--cream);
  box-shadow: inset 2px 0 0 var(--gold);
}

.nav a[aria-current="page"] svg { color: var(--gold-2); }

.sidebar-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 8px 4px;
  border-top: 1px solid var(--gold-line);
  font-size: 12.5px;
  color: rgba(243, 239, 230, 0.7);
  min-width: 0;
}

.avatar {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--gold);
  color: var(--gold-2);
  font: 500 13px var(--font-head);
  text-transform: uppercase;
}

.viewer { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Collapsed: icons only */
.shell.is-collapsed .logo b,
.shell.is-collapsed .nav span,
.shell.is-collapsed .sidebar-label,
.shell.is-collapsed .viewer { display: none; }
.shell.is-collapsed .sidebar-head { flex-direction: column; padding: 0 0 10px; }
.shell.is-collapsed .nav a { justify-content: center; padding: 0; }
.shell.is-collapsed .sidebar-foot { justify-content: center; padding-inline: 0; }
.shell.is-collapsed .collapse-btn svg { transform: rotate(180deg); }
.shell.is-collapsed .nav + .sidebar-label + .nav { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--gold-line); }

.scrim { display: none; }

/* ---------- main ---------- */

.main { min-width: 0; }

.pagebar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 10px max(var(--page-pad), calc((100% - var(--page-max)) / 2 + var(--page-pad)));
  background: rgba(245, 242, 234, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}

.pagebar h1 {
  margin: 0;
  font-family: var(--font-head);
  font-weight: 500;
  font-size: 22px;
  letter-spacing: -0.015em;
}

.menu-btn { display: none; color: var(--ink); }
.menu-btn:hover { background: var(--rule); }

.sync { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-2);
}

.btn {
  font: 500 13.5px/1 var(--font-body);
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}

.btn.primary { color: var(--cream); background: var(--forest); border: 1px solid var(--forest); }
.btn.primary:hover { background: var(--green); }
.btn:disabled { opacity: 0.6; cursor: progress; }

.page { padding: 20px var(--page-pad) 40px; max-width: var(--page-max); margin-inline: auto; }

/* ---------- filters ---------- */

.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.filters.is-empty { display: none; }

.seg {
  display: inline-flex;
  flex-wrap: wrap;
  padding: 3px;
  border: 1px solid var(--rule-2);
  border-radius: 999px;
  background: var(--card);
}

.seg button {
  font: 500 13px/1 var(--font-body);
  color: var(--ink-2);
  background: transparent;
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
}

.seg button:hover { color: var(--ink); background: var(--rule); }
.seg button[aria-checked="true"] { color: var(--cream); background: var(--forest); }

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

.content { transition: opacity 0.2s; }
.content.is-loading { opacity: 0.55; }
.view { display: grid; gap: 16px; }
.view[hidden] { display: none; }

.notice {
  margin-bottom: 16px;
  padding: 20px 22px;
  border: 1px solid var(--rule-2);
  border-radius: 16px;
  background: var(--card);
}

.notice h2 { margin: 0 0 6px; }
.notice p { margin: 0; color: var(--ink-2); max-width: 70ch; }

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
}

.tile, .card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 16px;
  padding: 18px 20px;
  min-width: 0;
  box-shadow: 0 1px 2px rgba(11, 19, 16, 0.04);
}

.tile.hero {
  grid-column: span 2;
  color: var(--cream);
  border-color: var(--forest);
  background: radial-gradient(120% 140% at 0% 0%, rgba(201, 164, 74, 0.22), rgba(201, 164, 74, 0) 55%), var(--forest);
}

.tile-label { font-size: 13px; color: var(--ink-2); }
.tile.hero .tile-label { color: var(--gold-2); }

.tile-value {
  font-family: var(--font-head);
  font-weight: 500;
  font-size: 34px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-top: 6px;
}

.tile.hero .tile-value { font-size: 56px; }
.tile-sub { font-size: 12.5px; color: var(--ink-3); margin-top: 6px; }
.tile.hero .tile-sub { color: rgba(243, 239, 230, 0.66); }

.grid.two { display: grid; gap: 16px; grid-template-columns: 1fr; align-items: start; }

@media (min-width: 1100px) {
  .grid.two { grid-template-columns: 1fr 1fr; }
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

h2 {
  font-family: var(--font-head);
  font-weight: 500;
  font-size: 18px;
  letter-spacing: -0.01em;
  margin: 0;
}

h3.minor {
  margin: 20px 0 8px;
  font: 500 12px var(--font-head);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.sub { margin: 4px 0 0; font-size: 13px; color: var(--ink-2); }

.link-btn {
  font: 500 13px/1 var(--font-body);
  color: var(--green-2);
  background: transparent;
  border: 0;
  padding: 6px 0;
  cursor: pointer;
  white-space: nowrap;
}

.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }

/* facts lists (sync & settings) */
.facts {
  display: grid;
  grid-template-columns: minmax(120px, max-content) 1fr;
  gap: 8px 16px;
  margin: 0;
  font-size: 14px;
}

.facts dt { color: var(--ink-2); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

code {
  font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace;
  background: rgba(11, 19, 16, 0.06);
  border-radius: 5px;
  padding: 1px 5px;
}

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

.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .empty { color: var(--ink-3); font-size: 14px; padding: 36px 0; text-align: center; }

.axis-label { fill: var(--ink-3); font: 11px var(--font-body); font-variant-numeric: tabular-nums; }
.value-label { fill: var(--ink); font: 500 12px var(--font-body); }
.cat-label { fill: var(--ink-2); font: 13px var(--font-body); }

.hit { fill: transparent; outline: none; }
.col.is-hover path, .bar.is-hover path { filter: brightness(0.9); }

.legend { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 8px; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.sw-mark { background: var(--mark); }
.sw-mark-muted { background: var(--mark-muted); }

.tooltip {
  position: fixed;
  z-index: 30;
  pointer-events: none;
  min-width: 150px;
  background: var(--forest);
  color: var(--cream);
  border: 1px solid var(--gold-line);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 13px;
  box-shadow: 0 10px 28px rgba(11, 19, 16, 0.25);
}

.tooltip .tt-title { color: rgba(243, 239, 230, 0.7); font-size: 12px; margin-bottom: 4px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; }
.tooltip .tt-row strong { font-weight: 600; font-variant-numeric: tabular-nums; }
.tooltip .tt-row span { color: rgba(243, 239, 230, 0.7); }
.tooltip .tt-key { width: 12px; height: 2px; border-radius: 1px; }

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

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }

th {
  text-align: left;
  font: 500 11.5px var(--font-head);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 8px 10px;
  border-bottom: 1px solid var(--rule-2);
  white-space: nowrap;
}

td { padding: 10px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
td.empty-row { color: var(--ink-3); text-align: center; padding: 22px 0; }
td.strong { font-weight: 500; }
td .muted { color: var(--ink-2); }

.status { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot.good { background: #0ca30c; }
.dot.bad { background: #d03b3b; }
.dot.running { background: var(--gold); }

/* ---------- small screens: sidebar becomes a slide-out menu ---------- */

@media (max-width: 899px) {
  .shell, .shell.is-collapsed { grid-template-columns: minmax(0, 1fr); }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    width: min(84vw, 300px);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    visibility: hidden;
  }

  .shell.nav-open .sidebar { transform: translateX(0); visibility: visible; }

  .shell.nav-open .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 15;
    background: rgba(5, 23, 17, 0.45);
  }

  /* Collapsing is a desktop feature; the drawer always shows labels. */
  .collapse-btn { display: none; }
  .close-btn { display: inline-grid; }
  .shell.is-collapsed .logo b,
  .shell.is-collapsed .nav span,
  .shell.is-collapsed .sidebar-label,
  .shell.is-collapsed .viewer { display: revert; }
  .shell.is-collapsed .sidebar-head { flex-direction: row; padding: 0 4px 10px 8px; }
  .shell.is-collapsed .nav a { justify-content: flex-start; padding: 0 12px; }

  .menu-btn { display: inline-grid; }
  .pagebar { padding: 10px 16px; }
  .pagebar h1 { font-size: 19px; }
  .page { padding: 16px 16px 32px; }
}

@media (max-width: 560px) {
  .tile.hero { grid-column: 1 / -1; }
  .tile, .card { padding: 16px; }
  .hide-narrow { display: none; }
  .sync-status { display: none; }
}
