/* Halevora API console.

   A reporting surface, not a marketing one. The numbers are the interface:
   typography, alignment and tabular figures carry the page, colour is almost
   absent and never decorative. Every value here is a token, so a client skin
   stays a token swap rather than a rewrite. See PRODUCT.md. */

:root {
  /* --- surfaces: near neutral, a trace of cool so it is not flat black --- */
  --bg: oklch(0.165 0.005 265);
  --sidebar: oklch(0.145 0.005 265);
  --surface: oklch(0.205 0.006 265);
  --surface-2: oklch(0.245 0.007 265);
  --sunken: oklch(0.135 0.005 265);

  --line: oklch(0.30 0.007 265);
  --line-strong: oklch(0.38 0.008 265);

  /* --- text: every step verified against its own background at AA --- */
  --ink: oklch(0.96 0.003 265);
  --ink-2: oklch(0.78 0.006 265);
  --ink-3: oklch(0.65 0.007 265);

  /* --- one accent, for selection, focus and the primary action only --- */
  --accent: oklch(0.62 0.15 250);
  --accent-ink: oklch(0.80 0.11 250);
  --accent-weak: color-mix(in oklch, var(--accent) 18%, transparent);

  /* ink that sits on top of the accent, dark enough to stay legible on it */
  --accent-contrast: oklch(0.16 0.01 265);

  --positive: oklch(0.75 0.13 158);
  --caution: oklch(0.80 0.12 82);
  --critical: oklch(0.70 0.17 25);

  /* --- depth --- */
  --scrim: oklch(0.10 0.005 265 / 0.72);
  --shadow: 0 8px 24px oklch(0.10 0 0 / 0.4);

  /* --- one radius scale. No pills: this is a console, not a landing page --- */
  --r-0: 2px;
  --r-1: 4px;
  --r-2: 6px;
  --r-3: 10px;

  /* --- 4px spacing scale --- */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-7: 32px;
  --s-8: 40px;

  /* --- fixed type scale, ~1.2 ratio. Product UI, so no fluid headings --- */
  --t-xs: 11px;
  --t-sm: 12px;
  --t-base: 13px;
  --t-md: 14px;
  --t-lg: 17px;
  --t-xl: 22px;
  --t-2xl: 30px;

  --control-h: 32px;

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

  /* --- semantic stacking order, never an arbitrary 9999 --- */
  --z-sticky: 10;
  --z-overlay: 40;
  --z-modal: 50;
  --z-toast: 60;
}

* { box-sizing: border-box; }

/* author display rules beat the user agent rules, so say it once and loudly */
[hidden] { display: none !important; }

html { color-scheme: dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: var(--t-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }

/* One focus treatment for the whole console. Never removed, only replaced. */
:focus-visible {
  outline: 2px solid var(--accent-ink);
  outline-offset: 2px;
  border-radius: var(--r-1);
}

.mono {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.92em;
  letter-spacing: -0.01em;
}

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

.shell { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  padding: var(--s-5) var(--s-3);
  display: flex;
  flex-direction: column;
  gap: var(--s-6);
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: var(--s-2); padding: 0 var(--s-2); }
.brand-mark {
  width: 24px; height: 24px;
  border-radius: var(--r-2);
  background: var(--accent);
  display: grid; place-items: center;
  font-weight: 650; font-size: var(--t-sm);
  color: var(--accent-contrast);
}
.brand-name { font-weight: 600; font-size: var(--t-md); letter-spacing: -0.01em; }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a {
  display: flex; align-items: center; gap: var(--s-2);
  padding: 7px var(--s-2);
  border-radius: var(--r-2);
  color: var(--ink-2);
  font-size: var(--t-base);
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.nav a:hover { background: var(--surface); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--surface-2); color: var(--ink); font-weight: 550; }
.nav svg { width: 15px; height: 15px; flex: none; }

/* Signed-in identity reads as a person, not as a disabled text field. */
.sidebar-foot {
  margin-top: auto;
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2);
  border-top: 1px solid var(--line);
}
.whoami { display: flex; align-items: center; gap: var(--s-2); min-width: 0; flex: 1; }
.whoami .initial {
  width: 22px; height: 22px; flex: none;
  border-radius: var(--r-1);
  background: var(--surface-2);
  display: grid; place-items: center;
  font-size: var(--t-xs); font-weight: 600; color: var(--ink-2);
}
.whoami .name {
  font-size: var(--t-base); color: var(--ink-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.main { padding: var(--s-6) var(--s-7) var(--s-8); max-width: 1560px; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--s-5); margin-bottom: var(--s-5); flex-wrap: wrap;
}
.page-head h1 { margin: 0; font-size: var(--t-xl); letter-spacing: -0.02em; font-weight: 600; }
.page-head p { margin: 3px 0 0; color: var(--ink-2); font-size: var(--t-base); }
.head-meta { display: flex; align-items: center; gap: var(--s-2); margin-top: var(--s-3); flex-wrap: wrap; }
.head-meta .sync-note { font-size: var(--t-base); color: var(--ink-3); }

/* Headings below the page title. One h1 per view, these are h2. */
.section { margin: var(--s-7) 0 var(--s-3); }
.section h2 { margin: 0; font-size: var(--t-lg); font-weight: 600; letter-spacing: -0.015em; }
.section p { margin: 3px 0 0; color: var(--ink-2); font-size: var(--t-base); }

/* padded to clear the 24px minimum target size, not just the text height */
.backlink { display: inline-flex; align-items: center; gap: 5px; padding: var(--s-1) 0; font-size: var(--t-base); color: var(--ink-2); }
.backlink:hover { color: var(--ink); }
.detail-head h1 { margin: var(--s-2) 0 0; }
.detail-head .url-row { margin-top: var(--s-3); }

/* Note at the top of a detail tab, explaining what the table below holds. */
.tab-note { margin: 0 0 var(--s-3); color: var(--ink-2); font-size: var(--t-base); }

/* Settings panels: one column at a readable measure, not full bleed. */
.panel { max-width: 620px; }
.panel + .panel { margin-top: var(--s-4); }
.panel h3 { margin: 0; font-size: var(--t-md); font-weight: 600; }
.panel > p { margin: var(--s-1) 0 var(--s-3); color: var(--ink-2); font-size: var(--t-base); }
.panel table { margin-top: var(--s-2); }
.panel .toolbar { margin: var(--s-3) 0 0; }

/* --- controls ----------------------------------------------------------- */

/* One button shape for the whole console. A control that looks different in
   two places means one of them is wrong. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--control-h);
  padding: 0 var(--s-3);
  border-radius: var(--r-2);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--ink);
  font-size: var(--t-base); font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.btn:hover { background: color-mix(in oklch, var(--surface-2) 70%, var(--ink) 8%); }
.btn:active { background: var(--surface); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: transparent; font-weight: 550; }
.btn.primary:hover { background: color-mix(in oklch, var(--ink) 88%, var(--accent)); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface); }
.btn.danger { background: transparent; color: var(--critical); border-color: color-mix(in oklch, var(--critical) 45%, transparent); }
.btn.danger:hover { background: color-mix(in oklch, var(--critical) 12%, transparent); }
.btn.small { height: 26px; padding: 0 var(--s-2); font-size: var(--t-sm); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Row-level action. Reachable by keyboard at all times, visible on hover so
   75 of them stop competing with the numbers. */
.btn.row-action { opacity: 0; }
tbody tr:hover .btn.row-action,
.btn.row-action:focus-visible { opacity: 1; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: var(--t-base); color: var(--ink-2); font-weight: 500; }

input[type="text"], input[type="password"], input[type="number"], select {
  height: var(--control-h);
  padding: 0 var(--s-3);
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  color: var(--ink);
  font-size: var(--t-base);
  outline: none;
  transition: border-color var(--fast) var(--ease);
}
input::placeholder { color: var(--ink-3); }
input:hover, select:hover { border-color: var(--line-strong); }
input:focus-visible, select:focus-visible { border-color: var(--accent); outline-offset: 0; }

/* Native selects carry the OS arrow, which reads as a different control
   vocabulary next to the inputs. One arrow, ours. */
select {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%23a0a4ae' stroke-width='1.4' stroke-linecap='round'%3E%3Cpath d='M3 4.75 6 7.75 9 4.75'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
}

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px var(--s-2);
  border-radius: var(--r-1);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: var(--t-sm);
  color: var(--ink-2);
  white-space: nowrap;
}
.chip.accent { border-color: color-mix(in oklch, var(--accent) 45%, transparent); color: var(--accent-ink); background: var(--accent-weak); }
.chip.good { border-color: color-mix(in oklch, var(--positive) 40%, transparent); color: var(--positive); background: color-mix(in oklch, var(--positive) 12%, transparent); }
.chip.warn { border-color: color-mix(in oklch, var(--caution) 40%, transparent); color: var(--caution); background: color-mix(in oklch, var(--caution) 12%, transparent); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  padding: var(--s-5);
}

/* --- stat band ----------------------------------------------------------
   Not a grid of bordered cards. A wall of identical boxes gives every figure
   the same weight and strands the last one on its own row; a band lets the
   lead figure lead and reflows without an orphan. */

.stats {
  display: flex; flex-wrap: wrap;
  gap: var(--s-5) var(--s-8);
  padding-bottom: var(--s-5);
  margin-bottom: var(--s-6);
  border-bottom: 1px solid var(--line);
}
.stat { min-width: 0; }
.stat-label { font-size: var(--t-base); color: var(--ink-2); font-weight: 500; }
.stat-value {
  font-size: var(--t-xl);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin-top: 5px;
  overflow-wrap: anywhere;
}
/* the first figure is the one decisions hang on */
.stats > .stat:first-child .stat-value { font-size: var(--t-2xl); }
.stat-note { font-size: var(--t-sm); color: var(--ink-3); margin-top: 3px; }

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

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  background: var(--surface);
}
table { width: 100%; border-collapse: collapse; font-size: var(--t-base); }
thead th {
  text-align: left;
  font-size: var(--t-sm); font-weight: 500;
  color: var(--ink-3);
  padding: var(--s-2) var(--s-3);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: var(--surface);
}
tbody td {
  padding: 9px var(--s-3);
  border-bottom: 1px solid color-mix(in oklch, var(--line) 55%, transparent);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; white-space: nowrap; }

/* revenue is the column the eye should land on */
td.lead { color: var(--ink); font-weight: 550; }

.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.accent-text { color: var(--accent-ink); }
.strong { font-weight: 550; }

.link-title { display: flex; flex-direction: column; gap: 1px; min-width: 180px; }
.link-title .name { font-weight: 550; }
.link-title .creator { font-size: var(--t-sm); color: var(--ink-3); }

/* Relative share, drawn inline beside the figure it belongs to. Not a chart. */
.share { display: inline-block; width: 52px; height: 4px; border-radius: var(--r-0); background: var(--surface-2); vertical-align: middle; margin-right: var(--s-2); }
.share > i { display: block; height: 100%; border-radius: var(--r-0); background: var(--accent); }

/* --- toolbar ------------------------------------------------------------ */

.toolbar { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; margin-bottom: var(--s-3); }
.toolbar input[type="text"] { min-width: 240px; }
.spacer { flex: 1; }

/* --- tabs --------------------------------------------------------------- */

.tabs { display: flex; gap: var(--s-4); border-bottom: 1px solid var(--line); margin: var(--s-6) 0 var(--s-5); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  background: none; border: none; cursor: pointer;
  padding: 0 0 9px; color: var(--ink-2);
  font-size: var(--t-base);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color var(--fast) var(--ease);
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); font-weight: 550; border-bottom-color: var(--accent); }

/* --- link url ----------------------------------------------------------- */

.url-row { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.url-box {
  display: inline-flex; align-items: center; gap: var(--s-2);
  height: var(--control-h);
  padding: 0 var(--s-1) 0 var(--s-3);
  border: 1px solid var(--line); border-radius: var(--r-2);
  background: var(--sunken);
  color: var(--ink-2);
}

/* --- modal -------------------------------------------------------------- */

.overlay {
  position: fixed; inset: 0; z-index: var(--z-overlay);
  background: var(--scrim);
  display: grid; place-items: center; padding: var(--s-5);
}
.modal {
  width: min(440px, 100%);
  z-index: var(--z-modal);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-3);
  padding: var(--s-6);
}
.modal h2 { margin: 0 0 3px; font-size: var(--t-lg); letter-spacing: -0.015em; font-weight: 600; }
.modal .form { display: flex; flex-direction: column; gap: var(--s-3); margin-top: var(--s-5); }
.modal .actions { display: flex; gap: var(--s-2); justify-content: flex-end; margin-top: var(--s-6); }

/* --- states ------------------------------------------------------------- */

.state { padding: var(--s-8) var(--s-5); text-align: center; color: var(--ink-2); font-size: var(--t-base); }
.state.error { color: var(--critical); }

.skeleton {
  height: 11px; border-radius: var(--r-1);
  background: linear-gradient(90deg, var(--surface), var(--surface-2), var(--surface));
  background-size: 300% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -300% 0; } }

.toast {
  position: fixed; bottom: var(--s-6); left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--line-strong);
  padding: var(--s-2) var(--s-4); border-radius: var(--r-2);
  z-index: var(--z-toast); font-size: var(--t-base);
  box-shadow: var(--shadow);
}

/* --- sign in ------------------------------------------------------------ */

.signin { min-height: 100vh; display: grid; place-items: center; padding: var(--s-5); }
.signin .card { width: min(340px, 100%); }
.signin h1 { font-size: var(--t-lg); margin: var(--s-4) 0 3px; letter-spacing: -0.015em; font-weight: 600; }
.signin p { color: var(--ink-2); font-size: var(--t-base); margin: 0 0 var(--s-5); }
.signin form { display: flex; flex-direction: column; gap: var(--s-3); }
.signin .btn { width: 100%; }
.error-text { color: var(--critical); font-size: var(--t-base); min-height: 18px; margin-top: var(--s-2); }

/* --- responsive: structural, not fluid type ----------------------------- */

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky; top: 0; z-index: var(--z-sticky);
    height: auto; flex-direction: row; align-items: center; gap: var(--s-4);
    padding: var(--s-2) var(--s-3);
    border-right: none; border-bottom: 1px solid var(--line);
  }
  .sidebar-foot { margin: 0 0 0 auto; border-top: none; padding: 0; }
  .whoami .name { display: none; }
  .nav { flex-direction: row; }
  .main { padding: var(--s-5) var(--s-4) var(--s-7); }
  .stats { gap: var(--s-4) var(--s-6); }
  .stats > .stat:first-child .stat-value { font-size: var(--t-xl); }
  /* no hover on touch, so row actions stay visible */
  .btn.row-action { opacity: 1; }
}

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