/* FirstPass portal — jarvis-ui tokens, dark-first, brand emerald accent.
   Kickoff (locked): accent=#34d399 family · dark-first · comfortable · r-control 10px */
:root {
  --canvas: #101114;
  --surface: #17181c;
  --surface-2: #1c1e23;
  --input-bg: #0d0e11;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.13);

  --text: #f2f3f5;
  --text-2: #c3c7cf;
  --text-3: #8b909c;
  --text-muted: #5d626e;

  /* brand emerald (measured on dark: ink 9.6:1 on surface, on-accent 10+:1 on fill) */
  --accent: #34d399;
  --accent-strong: #4fe0ab;      /* hover on dark goes LIGHTER */
  --accent-ink: #3fd99e;
  --accent-soft: rgba(52, 211, 153, 0.12);
  --on-accent: #06241a;

  --success: #34b27e; --success-soft: rgba(52, 178, 126, 0.14);
  --warning: #e29b3d; --warning-soft: rgba(226, 155, 61, 0.14);
  --danger:  #e0636c; --danger-soft:  rgba(224, 99, 108, 0.14);
  --danger-ink: #f28b92;          /* danger as TEXT: 8.0:1 on canvas, 6.8:1 on its hover tint (--danger drops to 4.4:1 on --danger-soft) */
  --info:    #6a95e0; --info-soft:    rgba(106, 149, 224, 0.14);

  --shadow-card: 0 0 0 1px rgba(255,255,255,.08);
  --ring-focus: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);

  --r-control: 10px; --r-card: 16px; --r-hero: 20px; --r-chip: 12px; --r-pill: 999px;
  --fs-caption: 12px; --fs-body: 14px; --fs-h3: 18px; --fs-h2: 22px; --fs-h1: 28px; --fs-kpi: 27px;
  --card-pad: 22px; --grid-gap: 24px; --sidebar-w: 248px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --sans: 'Geist', ui-sans-serif, system-ui, sans-serif;
  --mono: 'Geist Mono', ui-monospace, Menlo, monospace;
}
@font-face { font-family: 'Geist'; src: url('/static/fonts/geist-latin.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Geist Mono'; src: url('/static/fonts/geistmono-latin.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; }
body { background: var(--canvas); color: var(--text); font-family: var(--sans); font-size: var(--fs-body); line-height: 1.5; }
h1, h2, h3 { text-wrap: balance; }
a { color: inherit; text-decoration: none; }
[data-num] { font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.side {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.side .brand { display: flex; align-items: center; padding: 4px 10px 18px; }
.side .brand img { height: 24px; width: auto; }
.side .brand .mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: var(--on-accent); font-family: var(--mono); font-weight: 800; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  height: 40px; padding: 0 12px; border-radius: var(--r-control);
  color: var(--text-2); font-weight: 500;
}
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-ink); }
.side .spacer { flex: 1; }
.main { padding: 28px 32px; max-width: 1160px; width: 100%; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: var(--fs-h2); font-weight: 700; letter-spacing: -0.01em; }
.page-head .meta { color: var(--text-3); font-size: 13px; }

/* ---------- cards & grid ---------- */
.grid { display: grid; gap: var(--grid-gap); }
.kpis { grid-template-columns: repeat(4, 1fr); }
.card { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-card); padding: var(--card-pad); }
.kpi .label { font-size: 12px; font-weight: 500; color: var(--text-3); }
.kpi .value { font-size: var(--fs-kpi); font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 6px; display: flex; align-items: baseline; gap: 10px; }
.kpi .delta { font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: var(--r-pill); }
.kpi .delta.ok { color: var(--success); background: var(--success-soft); }
.kpi .delta.warn { color: var(--warning); background: var(--warning-soft); }
.kpi .sub { font-size: var(--fs-caption); color: var(--text-3); margin-top: 4px; }
.two-col { grid-template-columns: 1.6fr 1fr; margin-top: var(--grid-gap); }
.card h2 { font-size: 15px; font-weight: 600; margin-bottom: 16px; }

/* ---------- chart ---------- */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 150px; }
/* flex-basis 0 + min-width 0: the columns share the card width instead of each
   growing to its date label (14 labels pushed the page to 455px at 375) */
.bars .col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; height: 100%; }
.bars .bar { width: 100%; max-width: 26px; background: var(--accent); border-radius: 6px 6px 0 0; min-height: 2px; opacity: .92; }
.bars .bar.zero { background: var(--surface-2); }
.bars .d { font-size: var(--fs-caption); color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
/* The daily chart thins its date labels by ITS OWN width (not the viewport):
   14 labels need ~560px, and the card is narrow on phones AND on ~1024px
   desktops beside the endpoint card. Today (last column) always keeps its label. */
.bars.daily { container-type: inline-size; }
@container (max-width: 560px) { .bars.daily .col:nth-last-child(even) .d { visibility: hidden; } }
/* The chart card is stretched to the endpoint card's height beside it: give
   that height to the chart instead of leaving air under the bars. */
.chart-card { display: flex; flex-direction: column; }
.chart-card .bars.daily { flex: 1 1 auto; height: auto; min-height: 160px; }

/* ---------- endpoint split ---------- */
.split-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.split-row:first-of-type { border-top: 0; }
.chip { width: 36px; height: 36px; border-radius: var(--r-chip); background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; flex: none; }
.chip svg { width: 18px; height: 18px; }
.split-row .name { font-weight: 500; color: var(--text-2); font-family: var(--mono); font-size: 12.5px; }
.split-row .n { margin-left: auto; font-weight: 650; font-variant-numeric: tabular-nums; }

/* ---------- table ---------- */
.tbl-card { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-card); overflow-x: auto; overflow-y: hidden; margin-top: var(--grid-gap); }
.tbl-card h2 { font-size: 15px; font-weight: 600; padding: 18px var(--card-pad) 0; }
table { width: 100%; border-collapse: collapse; margin-top: 12px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); background: var(--surface-2); padding: 10px var(--card-pad); }
td { padding: 12px var(--card-pad); border-top: 1px solid var(--border); font-size: 13.5px; color: var(--text-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .mono { font-family: var(--mono); font-size: 12.5px; }
.pill { display: inline-block; font-size: 12px; font-weight: 500; padding: 2px 10px; border-radius: var(--r-pill); }
.pill.ok { color: var(--success); background: var(--success-soft); }
.pill.warn { color: var(--warning); background: var(--warning-soft); }
.pill.bad { color: var(--danger-ink); background: var(--danger-soft); }
.pill.dim { color: var(--text-3); background: var(--surface-2); }
.reason { font-family: var(--mono); font-size: 12px; color: var(--text-3); margin-left: 4px; }

/* ---------- key & code ---------- */
.keybox { display: flex; align-items: center; gap: 10px; background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--r-control); padding: 10px 14px; font-family: var(--mono); font-size: 12.5px; color: var(--text-2); overflow-x: auto; }
.code { background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--r-control); padding: 14px 16px; font-family: var(--mono); font-size: 12.5px; line-height: 1.7; overflow-x: auto; white-space: pre; color: var(--text-2); margin-top: 12px; }

/* ---------- forms & buttons ---------- */
label { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
input[type=text], input[type=password], input[type=number], select {
  width: 100%; min-width: 0; height: 40px; background: var(--input-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-control); padding: 0 12px;
  font: inherit;
}
/* browser default placeholder (#757575) is 4.19:1 on --input-bg; --text-3 is 5.9:1 */
::placeholder { color: var(--text-3); opacity: 1; }
select {
  appearance: none; padding-right: 36px; cursor: pointer; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b909c' stroke-width='2' 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 12px center; background-size: 16px;
}
input:focus, select:focus { outline: none; box-shadow: var(--ring-focus); background-color: var(--surface); }
/* two fields side by side on desktop, stacked on phones (see responsive block) */
.form-row { display: grid; grid-template-columns: 1fr 160px; gap: 12px; }
.form-row > * { min-width: 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; white-space: nowrap;
  min-height: 40px; padding: 0 18px; border: 0; border-radius: var(--r-control);
  background: var(--accent); color: var(--on-accent); font: inherit; font-weight: 600;
  cursor: pointer; transition: transform 120ms var(--ease-out), background 120ms var(--ease-out);
}
.btn:hover { background: var(--accent-strong); }
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.btn.ghost { background: transparent; color: var(--text-2); border: 1px solid var(--border-strong); }
.btn.ghost:hover { background: var(--surface-2); }
/* destructive secondary: outline, never a brand-green fill */
.btn.danger { background: transparent; color: var(--danger-ink); border: 1px solid var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
/* hit areas: inline row actions are 32px tall; they, copy buttons and icon-only
   controls keep a 40x40 target via ::before without changing their visual size */
.btn.row-action { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn.row-action, .copy-btn, .hit { position: relative; }
.btn.row-action::before, .copy-btn::before, .hit::before {
  content: ""; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: max(100%, 40px); height: max(100%, 40px);
}
/* checkbox: the wrapping label is the 40x40 target */
label.check { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; min-width: 40px; margin: 0; cursor: pointer; }
label.check input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.err { color: var(--danger); font-size: 13px; margin-top: 10px; }

/* ---------- empty state ---------- */
.empty { text-align: center; padding: 40px 20px; }
.empty .chip { margin: 0 auto 12px; background: var(--surface-2); color: var(--text-3); }
.empty .t { font-weight: 500; }
.empty .d { font-size: 13px; color: var(--text-3); margin-top: 4px; }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: var(--r-hero); box-shadow: var(--shadow-card); padding: 32px; }
.auth-card .brand { display: flex; align-items: center; margin-bottom: 22px; }
.auth-card .brand img { height: 30px; width: auto; }
.auth-card .brand .mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: var(--on-accent); font-family: var(--mono); font-weight: 800; }
.auth-card p.hint { color: var(--text-3); font-size: 13px; margin: 8px 0 20px; }
.auth-card form > * + * { margin-top: 14px; }

/* ---------- responsive (phone <640 · tablet/fold 640–1023 · desktop ≥1024) ---------- */
html { color-scheme: dark; }
html, body { overflow-x: clip; }
/* grid/flex children default to min-width:auto, so a long code block or key box
   widened the whole column past the viewport on phones */
.shell > .main, .grid > *, .tbl-card, .card { min-width: 0; }
@media (max-width: 1023px) {
  :root { --sidebar-w: 88px; --grid-gap: 20px; }
  /* icon rail: labels hidden, icons stay tappable (40px rows) */
  .side { padding: 16px 10px; align-items: center; }
  .side .brand { padding: 4px 0 14px; justify-content: center; }
  .side .brand img { height: 22px; max-width: 60px; object-fit: contain; object-position: left; }
  .nav-item { width: 56px; justify-content: center; padding: 0; font-size: 0; gap: 0; }
  .nav-item svg { width: 20px; height: 20px; }
  .side .btn { white-space: normal; line-height: 1.25; } /* 64px-wide rail: wrap, don't spill */
  .main { padding: 24px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 639px) {
  :root { --grid-gap: 16px; --card-pad: 16px; --fs-kpi: 24px; }
  .shell { grid-template-columns: 1fr; }
  .side { position: sticky; top: 0; z-index: 10; height: auto; flex-direction: row; align-items: center; padding: 8px 12px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .side .brand { padding: 0 8px 0 0; }
  .side .spacer { display: none; }
  .side .btn { white-space: nowrap; }
  .nav-item { width: 44px; height: 44px; flex: none; }
  .main { padding: 16px; }
  .kpis { grid-template-columns: 1fr; }
  .page-head { margin-bottom: 16px; }
  .form-row { grid-template-columns: 1fr; }
  /* 14 bars in ~311px: tighter gap, label every other day (today always labelled) */
  .bars { gap: 4px; }
  th, td { padding-left: 12px; padding-right: 12px; white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
