/*
 * OM Extraction Console — visual language pulled from perennial-agents/jll-console
 * (web/src/index.css) and perennial-agents/perennial-process's console-template.
 * Tokens, the auth card, buttons/controls/pills/cards/table.grid below are the
 * same values those consoles ship; the dropzone and severity-bar styles are new,
 * built to match.
 */

:root {
  --accent: #ed1c24;
  --ink: #231f20;
  --bg: #f4f5f6;
  --line: #e8e6e4;
  --brand-navy: #003f52;

  --accent-text:    #003f52;
  --accent-press:   #c4141b;
  --accent-soft:    color-mix(in srgb, var(--accent) 10%, white);
  --accent-soft-bd: color-mix(in srgb, var(--accent) 20%, white);

  --surface: #ffffff;
  --surface-sunken: #f7f7f8;

  --line-soft: #f2f0ef;
  --line-input: #bfc3c3;

  --ink-muted: #56555e;
  --ink-faint: #6f6d76;

  --good: #2b7f5b; --good-bg: #f0f7f4; --good-bd: #d3e8dd;
  --warn: #7a5c12; --warn-bg: #fff8e6; --warn-bd: #f0dca0;
  --bad:  #8a2b2b; --bad-bg:  #fdf1f1; --bad-bd:  #f0caca;
  --mute: #4c5658; --mute-bg: #eceded; --mute-bd: #d8d9d9;
  --open-fg: #00637f; --open-bg: #e8f4f8; --open-bd: #bcdde8;

  --auth-bg: #231f20;
  --auth-logo: #ffffff;
  --auth-logo-mark: #ed1c24;

  --radius: 6px;
  --radius-card: 10px;
  --radius-pill: 999px;

  --shadow-sm: -2px -2px 5px rgba(255, 255, 255, 0.9), 2px 2px 5px rgba(20, 24, 31, 0.08);
  --shadow: -4px -4px 10px rgba(255, 255, 255, 0.9), 4px 4px 10px rgba(20, 24, 31, 0.08);
  --shadow-inset: inset 2px 2px 5px rgba(20, 24, 31, 0.07), inset -2px -2px 5px rgba(255, 255, 255, 0.9);
  --shadow-lg: 0 10px 28px rgba(20, 24, 31, 0.1), 0 2px 6px rgba(20, 24, 31, 0.05);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --dur-fast: 120ms;
  --dur-press: 160ms;
  --dur-pop: 200ms;

  --gutter-card: 14px;
  --cardhead-h: 38px;

  --fs-tile: 21px;
  --fs-body: 13.5px;
  --fs-note: 12.5px;
  --fs-label: 12px;
  --fs-micro: 10.5px;
  --track-eyebrow: 0.02em;

  --font-brand: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;

  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font-brand);
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font-family: inherit; font-size: inherit; color: var(--ink); }
button { cursor: pointer; }
a { color: var(--accent-text); }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius); }

/* ===================================================================== auth */
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--auth-bg);
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: inset 0 3px 0 var(--accent), var(--shadow-lg);
  width: 100%;
  max-width: 400px;
}
.auth-head { padding: 30px 28px 4px; display: flex; justify-content: center; }
.auth-body { padding: 26px 28px 28px; }
.auth-body h2 { margin: 0 0 20px; font-size: 17px; font-weight: 650; color: var(--ink); text-align: center; }
.auth-body label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 5px; color: var(--ink-muted); }
.auth-body .control { width: 100%; margin-bottom: 14px; }
.auth-body .btn { width: 100%; height: 40px; }
.error {
  background: var(--bad-bg); color: var(--bad); padding: 9px 12px;
  border-radius: var(--radius); font-size: 12.5px; margin-bottom: 14px;
}

/* =================================================================== shell */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  height: 64px; flex: 0 0 auto; display: flex; align-items: center;
  gap: 12px; padding: 0 24px; background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar .title { font-size: 15px; font-weight: 650; color: var(--ink); }
.topbar .spacer { flex: 1; }
.topbar .user { font-size: 12.5px; color: var(--ink-faint); margin-right: 10px; }
.topbar-search { margin-left: 20px; width: 260px; }
.topbar-search .control { width: 100%; height: 32px; }
@media (max-width: 760px) { .topbar-search { display: none; } }
main.content { flex: 1; padding: 24px; max-width: 1180px; margin: 0 auto; width: 100%; }

/* ================================================================== controls */
.control {
  height: 36px; padding: 0 10px; font-size: 14px;
  border: 1px solid var(--line-input); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); outline: none;
  box-shadow: var(--shadow-inset);
  transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}
.control:focus { border-color: var(--accent); box-shadow: var(--ring); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: var(--radius);
  border: 1px solid var(--line-input); background: var(--surface); color: var(--ink);
  font-weight: 550; white-space: nowrap; text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: background var(--dur-fast) ease, border-color var(--dur-fast) ease,
    color var(--dur-fast) ease, transform var(--dur-press) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .btn:hover { background: var(--surface-sunken); border-color: var(--brand-navy); }
}
.btn:active { background: var(--line); box-shadow: var(--shadow-inset); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 2px 2px 5px rgba(20,24,31,.12); }
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { background: var(--accent-press); border-color: var(--accent-press); }
}
.btn-primary:active { background: var(--accent-press); box-shadow: inset 2px 2px 5px rgba(20,24,31,.18); }
.btn:disabled, .btn-primary:disabled { background: var(--surface-sunken); border-color: var(--line); color: var(--ink-muted); cursor: not-allowed; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-link { border: none; background: none; color: var(--brand-navy); padding: 2px 4px; font-weight: 550; border-radius: 4px; }
@media (hover: hover) and (pointer: fine) {
  .btn-link:hover { color: var(--accent-text); background: var(--accent-soft); }
}

/* ====================================================================== pills */
.pill { display: inline-block; padding: 2px 9px; border-radius: var(--radius-pill); font-size: 11.5px; font-weight: 650; line-height: 17px; letter-spacing: .01em; white-space: nowrap; }
.pill-good { background: var(--good-bg); color: var(--good); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-bad  { background: var(--bad-bg);  color: var(--bad); }
.pill-mute { background: var(--mute-bg); color: var(--mute); }
.pill-open { background: var(--open-bg); color: var(--open-fg); }

/* ====================================================================== banner */
.banner { display: flex; align-items: flex-start; gap: 10px; background: var(--open-bg); border: 1px solid var(--open-bd); color: var(--open-fg); padding: 9px 12px; border-radius: var(--radius); font-size: 13px; line-height: 1.5; }
.banner-error { background: var(--bad-bg); border-color: var(--bad-bd); color: var(--bad); }
.banner-warn  { background: var(--warn-bg); border-color: var(--warn-bd); color: var(--warn); }
.banner-good  { background: var(--good-bg); border-color: var(--good-bd); color: var(--good); }

/* ====================================================================== cards */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm); padding: 0 var(--gutter-card) 14px; margin-bottom: 20px;
}
.card-h { font-size: var(--fs-body); font-weight: 700; letter-spacing: var(--track-eyebrow); color: var(--accent-text); margin: 0; }
.card > .card-h, .card > .card-head {
  height: var(--cardhead-h); display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--line-soft);
  margin: 0 calc(-1 * var(--gutter-card)); padding: 0 var(--gutter-card);
}
.card-head { justify-content: space-between; }
.card-head .actions { display: flex; gap: 6px; }
.card > * { margin-top: 12px; }
.card > .card-h:first-child, .card > .card-head:first-child { margin-top: 0; }
.card > *:last-child { margin-bottom: 0; }

/* ======================================================================= kpis */
/* Two columns so three tiles wrap to two rows rather than a lone strip. */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 20px; }
@media (max-width: 480px) { .kpis { grid-template-columns: 1fr; } }
.kpi { padding: 12px 16px 14px; border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); margin-right: -1px; margin-bottom: -1px; }
.kpi .label { font-size: var(--fs-micro); font-weight: 700; letter-spacing: var(--track-eyebrow); color: var(--ink-faint); margin-bottom: 4px; text-transform: uppercase; }
.kpi .value { font-size: 26px; font-weight: 680; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--ink); line-height: 1.15; }
.kpi .sub { font-size: 11.5px; color: var(--ink-faint); margin-top: 2px; }
.kpi.accent .value { color: var(--accent-text); }

/* stat tiles (per-OM headline facts) */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { background: var(--surface-sunken); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 10px 12px; }
.tile .label { font-size: var(--fs-micro); font-weight: 700; letter-spacing: var(--track-eyebrow); color: var(--ink-faint); text-transform: uppercase; margin-bottom: 4px; }
.tile .value { font-size: var(--fs-tile); font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; }
.tile .meta { font-size: 11px; color: var(--ink-faint); margin-top: 4px; }
.alt-toggle {
  display: block; margin-top: 3px; padding: 0; border: 0; background: none;
  font-size: 11px; font-weight: 600; color: var(--warn); cursor: pointer;
}
.alt-toggle:hover { text-decoration: underline; }
.alt-toggle .caret { display: inline-block; transition: transform var(--dur-fast) ease; }
.alt-toggle.open .caret { transform: rotate(180deg); }
.alt-list { margin-top: 5px; padding-top: 5px; border-top: 1px solid var(--line-soft); }
.alt-row { font-size: 12px; color: var(--ink); padding: 2px 0; font-variant-numeric: tabular-nums; }
.alt-row .muted { font-size: 11px; margin-left: 5px; }

/* =============================================================== digest */
.digest-file { border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow-sm); padding: 14px 16px; }
.digest-file-h { font-size: var(--fs-body); font-weight: 700; color: var(--accent-text); letter-spacing: var(--track-eyebrow); margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--line-soft); }
.digest-md { font-size: 13px; line-height: 1.55; max-height: 480px; overflow: auto; }
.digest-md h1 { font-size: 17px; margin: 0 0 10px; }
.digest-md h2 { font-size: 14.5px; margin: 18px 0 8px; color: var(--accent-text); }
.digest-md h2:first-child { margin-top: 0; }
.digest-md h3, .digest-md h4 { font-size: 13.5px; margin: 14px 0 6px; }
.digest-md p { margin: 0 0 10px; }
.digest-md blockquote { margin: 0 0 10px; padding: 8px 12px; background: var(--surface-sunken); border-left: 3px solid var(--accent-soft-bd); color: var(--ink-muted); font-size: 12.5px; }
.digest-md hr { border: none; border-top: 1px solid var(--line); margin: 14px 0; }
.digest-md table.grid td, .digest-md table.grid th { white-space: normal; }
.digest-md .tablewrap { margin-bottom: 12px; max-height: none; }

/* ============================================================ run progress */
.runprog-track {
  height: 10px; background: var(--surface-sunken); border: 1px solid var(--line-soft);
  border-radius: var(--radius-pill); overflow: hidden;
}
.runprog-fill {
  height: 100%; background: var(--accent); border-radius: var(--radius-pill);
  transition: width var(--dur-pop) var(--ease-out);
}
/* No counter from the backend yet: a bar that sweeps rather than one that
   claims a position it does not know. */
.runprog-fill.indet {
  width: 34%;
  background: linear-gradient(90deg, var(--line) 0%, var(--accent) 50%, var(--line) 100%);
  animation: sweep 1.4s var(--ease-out) infinite;
}
@keyframes sweep { from { transform: translateX(-110%); } to { transform: translateX(300%); } }
.runprog-line { font-size: var(--fs-body); color: var(--ink); font-variant-numeric: tabular-nums; }
.runprog-line .runprog-last { color: var(--ink-muted); }
.runprog-meta { font-size: var(--fs-note); color: var(--ink-faint); font-variant-numeric: tabular-nums; }

/* =============================================================== telemetry */
/* "not priced" is a sentence, not a figure — it does not want the tile's
   21px numeral treatment. */
.tile .value.na { font-size: 14px; font-weight: 600; color: var(--ink-faint); }
.telem-slow { margin-top: 12px; }

/* ============================================================ severity chart */
.sevbar-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); }
.sevbar-row:last-child { border-bottom: none; }
.sevbar-name { flex: 0 0 260px; font-size: 12.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.sevbar-name:hover { color: var(--accent-text); text-decoration: underline; }
.sevbar-track { flex: 1; height: 14px; background: var(--surface-sunken); border-radius: 4px; overflow: hidden; }
.sevbar-fill { height: 100%; border-radius: 4px; transition: width var(--dur-pop) var(--ease-out); }
.sevbar-fill.normal { background: var(--good); }
.sevbar-fill.elevated { background: var(--warn); }
.sevbar-fill.outlier { background: var(--bad); }
.sevbar-count { flex: 0 0 34px; text-align: right; font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--ink-muted); }
.sevbar-secs { flex: 0 0 50px; text-align: right; font-size: 11.5px; font-variant-numeric: tabular-nums; color: var(--ink-faint); }
.sevbar-badge { flex: 0 0 auto; }
.sevlegend { display: flex; gap: 16px; font-size: 11.5px; color: var(--ink-faint); margin-bottom: 6px; }
.sevlegend .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.sevlegend .dot.normal { background: var(--good); }
.sevlegend .dot.elevated { background: var(--warn); }
.sevlegend .dot.outlier { background: var(--bad); }

/* ===================================================================== table */
.tablewrap { overflow: auto; border-radius: var(--radius); }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; font-variant-numeric: tabular-nums; }
table.grid th { position: sticky; top: 0; background: var(--surface-sunken); text-align: left; font-size: 11px; color: var(--ink-faint); font-weight: 500; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.grid th.num { text-align: right; }
table.grid td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); color: var(--ink); vertical-align: middle; }
table.grid td.num { text-align: right; }
table.grid tbody tr { transition: background var(--dur-fast) ease; }
@media (hover: hover) and (pointer: fine) { table.grid tbody tr:hover { background: var(--surface-sunken); } }
table.grid tbody tr:last-child td { border-bottom: none; }
.sub-line { display: block; font-size: 11.5px; color: var(--ink-faint); margin-top: 1px; }

/* ==================================================================== search */
.search-result { cursor: pointer; }
.search-result:hover { border-color: var(--brand-navy); }
.search-hit { font-size: 12.5px; padding: 5px 0; color: var(--ink-muted); border-bottom: 1px solid var(--line-soft); }
.search-hit:last-child { border-bottom: none; }
mark { background: var(--accent-soft); color: var(--ink); border-radius: 2px; padding: 0 1px; }

/* =================================================================== dropzone */
.dropzone {
  border: 2px dashed var(--line-input); border-radius: var(--radius-card);
  background: var(--surface-sunken); padding: 44px 24px; text-align: center;
  transition: border-color var(--dur-fast) ease, background var(--dur-fast) ease;
  margin-bottom: 20px;
}
.dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .dz-title { font-size: 15px; font-weight: 650; color: var(--ink); margin-bottom: 6px; }
.dropzone .dz-sub { font-size: 12.5px; color: var(--ink-faint); margin-bottom: 16px; }
.dropzone input[type=file] { display: none; }

.progress-line { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--ink-muted); }
.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--line-input); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==================================================================== misc */
.muted { color: var(--ink-faint); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.crumbs { font-size: 12.5px; color: var(--ink-faint); margin-bottom: 14px; }
.crumbs a { color: var(--brand-navy); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.checks-list { margin: 0; padding-left: 0; list-style: none; }
.checks-list li { padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.checks-list li:last-child { border-bottom: none; }
.checks-list code { background: var(--surface-sunken); padding: 1px 4px; border-radius: 3px; font-size: 12px; }
.dl-row { display: flex; gap: 8px; flex-wrap: wrap; }
.runlist-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.runlist-item:last-child { border-bottom: none; }
.runlist-item:hover { background: var(--surface-sunken); }
.runlist-item .rmeta { flex: 1; }
.runlist-item .rtime { font-size: 12px; color: var(--ink-faint); }
