/* bad-review-monitor dashboard — dark design system.
   Palette values come from the validated data-viz reference palette (dark
   column), validated against this surface with scripts/validate_palette.js:
   categorical slots 1-3 pass lightness band, chroma floor, CVD separation,
   normal-vision floor, and 3:1 contrast. Do not hand-tune these hexes. */

:root {
  color-scheme: dark;

  /* surfaces */
  --plane:        #0d0d0d;   /* page background */
  --surface:      #141416;   /* card / chart surface */
  --surface-2:    #191a1d;   /* raised: table headers, inputs */
  --surface-3:    #202126;   /* hover state */

  /* ink */
  --ink:          #ffffff;
  --ink-2:        #c3c2b7;
  --ink-muted:    #898781;

  /* lines */
  --hairline:     rgba(255, 255, 255, 0.08);
  --hairline-2:   rgba(255, 255, 255, 0.14);
  --grid:         #2c2c2a;
  --baseline:     #383835;

  /* data series (dark steps) */
  --series-1:     #3987e5;
  --series-2:     #d95926;
  --series-3:     #199e70;

  /* status (fixed, never themed) */
  --good:         #0ca30c;
  --warning:      #fab219;
  --serious:      #ec835a;
  --critical:     #d03b3b;

  /* stars map onto severity, worst = most critical */
  --star-1:       #d03b3b;
  --star-2:       #ec835a;
  --star-3:       #fab219;

  --radius:       14px;
  --radius-sm:    9px;
  --ease:         cubic-bezier(0.4, 0.14, 0.3, 1);
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-2);
  background: var(--plane);
  /* Two very soft accent washes keep the near-black plane from reading flat.
     Fixed attachment so they don't drift while scrolling. */
  background-image:
    radial-gradient(70rem 40rem at 12% -10%, rgba(57, 135, 229, 0.10), transparent 60%),
    radial-gradient(50rem 34rem at 100% 0%, rgba(217, 89, 38, 0.06), transparent 60%);
  background-attachment: fixed;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ── layout ─────────────────────────────────────────────────────────── */

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

.sidebar {
  border-right: 1px solid var(--hairline);
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 26px;
  background: rgba(13, 13, 13, 0.6);
  backdrop-filter: blur(12px);
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--series-1), #1c5cab);
  box-shadow: 0 3px 14px rgba(57, 135, 229, 0.4);
  font-size: 15px;
}
.brand-name { color: var(--ink); font-weight: 640; letter-spacing: -0.01em; line-height: 1.15; }
.brand-sub { font-size: 11px; color: var(--ink-muted); }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--ink-muted); padding: 0 10px; margin-bottom: 6px;
}
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: var(--radius-sm);
  color: var(--ink-2); font-weight: 500;
  position: relative;
  transition: background 160ms var(--ease), color 160ms var(--ease), transform 160ms var(--ease);
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a:active { transform: scale(0.985); }
.nav a.active { background: var(--surface-3); color: var(--ink); }
.nav a.active::before {
  content: ""; position: absolute; left: -14px; top: 50%;
  width: 3px; height: 19px; margin-top: -9.5px;
  border-radius: 0 3px 3px 0; background: var(--series-1);
  box-shadow: 0 0 12px var(--series-1);
}
.nav .ico { width: 17px; text-align: center; opacity: 0.85; font-size: 14px; }

.sidebar-foot { margin-top: auto; padding: 0 8px; font-size: 11.5px; color: var(--ink-muted); }
.sidebar-foot a { text-decoration: underline; text-underline-offset: 2px; }
.sidebar-foot a:hover { color: var(--ink-2); }

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

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 17px 26px;
  border-bottom: 1px solid var(--hairline);
  position: sticky; top: 0; z-index: 20;
  background: rgba(13, 13, 13, 0.72);
  backdrop-filter: blur(14px);
}
.topbar h1 { margin: 0; font-size: 17px; font-weight: 620; color: var(--ink); letter-spacing: -0.015em; }
.topbar .sub { font-size: 12.5px; color: var(--ink-muted); }
.spacer { flex: 1; }

.content { padding: 26px; display: flex; flex-direction: column; gap: 22px; }

/* ── cards ──────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 18px 20px;
  transition: border-color 200ms var(--ease), transform 200ms var(--ease),
              box-shadow 200ms var(--ease);
}
.card-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.card-title { color: var(--ink); font-weight: 600; font-size: 14px; }
.card-note { font-size: 12px; color: var(--ink-muted); }

/* ── stat tiles ─────────────────────────────────────────────────────── */

.kpi-row {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(184px, 1fr));
}
.tile {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 15px 17px 14px;
  position: relative; overflow: hidden;
  transition: border-color 200ms var(--ease), transform 200ms var(--ease),
              box-shadow 200ms var(--ease);
}
.tile::after {   /* accent hairline that wipes in on hover */
  content: ""; position: absolute; inset: 0 auto auto 0; height: 2px; width: 100%;
  background: linear-gradient(90deg, var(--series-1), transparent);
  transform: scaleX(0); transform-origin: left;
  transition: transform 420ms var(--ease);
}
.tile:hover { border-color: var(--hairline-2); transform: translateY(-2px);
              box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); }
.tile:hover::after { transform: scaleX(1); }

.tile-label { font-size: 11.5px; color: var(--ink-muted); letter-spacing: 0.015em; }
.tile-value {
  color: var(--ink); font-size: 27px; font-weight: 640;
  letter-spacing: -0.02em; line-height: 1.25; margin-top: 3px;
  /* proportional figures: tabular-nums makes standalone numbers look loose */
}
.tile-foot { display: flex; align-items: center; gap: 7px; margin-top: 5px;
             font-size: 11.5px; color: var(--ink-muted); }

.hero {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 22px;
}
.hero-value {
  font-family: var(--font);          /* never a display/serif face */
  font-size: 54px; font-weight: 660; line-height: 1; letter-spacing: -0.035em;
  color: var(--ink);
}
.hero-label { font-size: 12.5px; color: var(--ink-muted); }

/* delta — direction × whether up is good */
.delta { display: inline-flex; align-items: center; gap: 4px; font-weight: 560; }
.delta.up { color: var(--good); }
.delta.down { color: var(--critical); }
.delta.flat { color: var(--ink-muted); }

/* ── meter (ratio against a limit) ──────────────────────────────────── */

.meter { margin-top: 9px; }
.meter-track {
  height: 7px; border-radius: 99px; overflow: hidden;
  background: #184f95;                       /* lighter step of the same ramp */
  opacity: 0.34;
}
.meter-fill {
  height: 100%; border-radius: 99px; background: var(--series-1);
  width: 0; transition: width 900ms var(--ease);
}
.meter.is-warning .meter-fill { background: var(--warning); }
.meter.is-critical .meter-fill { background: var(--critical); }
.meter-legend { display: flex; justify-content: space-between; margin-top: 6px;
                font-size: 11px; color: var(--ink-muted); }

/* ── charts ─────────────────────────────────────────────────────────── */

.grid-2 {
  display: grid; gap: 14px; align-items: start;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
}

.chart { width: 100%; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }      /* solid hairline */
.chart .axis-line { stroke: var(--baseline); stroke-width: 1; }
.chart text { fill: var(--ink-muted); font-size: 10.5px; font-family: var(--font);
              font-variant-numeric: tabular-nums; }
.chart .area { fill: var(--series-1); opacity: 0.10; }
.chart .line { fill: none; stroke: var(--series-1); stroke-width: 2;
               stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.chart .bar { fill: var(--series-1); transition: opacity 140ms var(--ease); }
.chart .bar:hover { opacity: 0.78; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .crosshair { stroke: var(--hairline-2); stroke-width: 1; }
.chart .end-label { fill: var(--ink); font-weight: 600; }

/* line draw-in */
.chart .line.animate {
  stroke-dasharray: var(--len); stroke-dashoffset: var(--len);
  animation: draw 1000ms var(--ease) forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }
.chart .area.animate { animation: fade 700ms 260ms var(--ease) backwards; }
@keyframes fade { from { opacity: 0; } }
.chart .bar.animate { animation: grow 620ms var(--ease) backwards; transform-origin: left center; }
@keyframes grow { from { transform: scaleX(0); } }

.tooltip {
  position: fixed; z-index: 60; pointer-events: none;
  background: var(--surface-3);
  border: 1px solid var(--hairline-2);
  border-radius: 9px; padding: 8px 11px;
  font-size: 12px; color: var(--ink);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  opacity: 0; transform: translateY(3px);
  transition: opacity 130ms var(--ease), transform 130ms var(--ease);
  white-space: nowrap;
}
.tooltip.show { opacity: 1; transform: translateY(0); }
.tooltip .tt-key { color: var(--ink-muted); }
.tooltip .tt-val { font-weight: 620; font-variant-numeric: tabular-nums; }

/* table-view twin — every chart has one */
.table-toggle {
  background: none; border: 1px solid var(--hairline); color: var(--ink-muted);
  border-radius: 7px; padding: 3px 9px; font-size: 11px; cursor: pointer;
  font-family: var(--font);
  transition: color 150ms var(--ease), border-color 150ms var(--ease), background 150ms var(--ease);
}
.table-toggle:hover { color: var(--ink); border-color: var(--hairline-2); background: var(--surface-2); }
.chart-table { display: none; margin-top: 12px; }
.chart-table.show { display: block; }

/* ── filters ────────────────────────────────────────────────────────── */

.filters {
  display: flex; flex-wrap: wrap; gap: 11px; align-items: flex-end;
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 11px; color: var(--ink-muted); letter-spacing: 0.02em; }
.field select, .field input {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  color: var(--ink); border-radius: var(--radius-sm);
  padding: 8px 11px; font-size: 13px; font-family: var(--font);
  min-width: 148px;
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease), background 150ms var(--ease);
}
.field select:hover, .field input:hover { border-color: var(--hairline-2); }
.field select:focus, .field input:focus {
  outline: none; border-color: var(--series-1);
  box-shadow: 0 0 0 3px rgba(57, 135, 229, 0.22);
}

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 15px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer;
  font-size: 13px; font-weight: 550; font-family: var(--font);
  background: var(--series-1); color: #fff;
  transition: transform 150ms var(--ease), box-shadow 200ms var(--ease), filter 150ms var(--ease);
}
.btn:hover { filter: brightness(1.09); box-shadow: 0 6px 20px rgba(57, 135, 229, 0.36); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: var(--surface-2); color: var(--ink-2); border-color: var(--hairline); }
.btn.ghost:hover { background: var(--surface-3); color: var(--ink); box-shadow: none; }

/* ── table ──────────────────────────────────────────────────────────── */

.table-wrap {
  border: 1px solid var(--hairline); border-radius: var(--radius);
  overflow: hidden; background: var(--surface);
}
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2); color: var(--ink-muted);
  font-weight: 560; font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase;
  text-align: left; padding: 10px 13px; white-space: nowrap;
  border-bottom: 1px solid var(--hairline);
}
tbody td {
  padding: 11px 13px; border-bottom: 1px solid var(--hairline);
  vertical-align: top; color: var(--ink-2);
}
tbody tr { transition: background 130ms var(--ease); }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-strong { color: var(--ink); font-weight: 560; }
.review-text { max-width: 30rem; color: var(--ink-2); }
.empty { padding: 46px 20px; text-align: center; color: var(--ink-muted); }
.empty-big { font-size: 15px; color: var(--ink-2); margin-bottom: 4px; }

/* ── badges & pills ─────────────────────────────────────────────────── */

.stars {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 99px; font-weight: 620; font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.stars-1 { color: var(--star-1); background: rgba(208, 59, 59, 0.14); }
.stars-2 { color: var(--star-2); background: rgba(236, 131, 90, 0.14); }
.stars-3 { color: var(--star-3); background: rgba(250, 178, 25, 0.14); }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 550;
  border: 1px solid var(--hairline);
}
/* status always ships icon + label, never color alone */
.pill.success { color: var(--good); background: rgba(12, 163, 12, 0.13); border-color: rgba(12, 163, 12, 0.3); }
.pill.failed  { color: var(--critical); background: rgba(208, 59, 59, 0.14); border-color: rgba(208, 59, 59, 0.32); }
.pill.running { color: var(--warning); background: rgba(250, 178, 25, 0.13); border-color: rgba(250, 178, 25, 0.3); }
.pill.neutral { color: var(--ink-muted); background: var(--surface-2); }

.chip {
  display: inline-flex; align-items: center; gap: 5px; max-width: 100%;
  padding: 2px 8px; border-radius: 7px; font-size: 12px;
  background: var(--surface-2); border: 1px solid var(--hairline);
  color: var(--ink-2);
}
.chip .verified { color: var(--good); }
.chip.none { color: var(--ink-muted); background: transparent; border-style: dashed; }

.linkset { display: inline-flex; gap: 9px; }
.linkset a {
  color: var(--ink-muted); font-size: 12px;
  border-bottom: 1px solid transparent;
  transition: color 140ms var(--ease), border-color 140ms var(--ease);
}
.linkset a:hover { color: var(--series-1); border-bottom-color: var(--series-1); }

/* ── login ──────────────────────────────────────────────────────────── */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 372px;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 18px; padding: 30px;
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.6);
  animation: rise 520ms var(--ease) backwards;
}
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
.login-card .brand { padding: 0; margin-bottom: 22px; }
.login-card h2 { margin: 0 0 5px; font-size: 19px; color: var(--ink); font-weight: 620; }
.login-card p.hint { margin: 0 0 20px; font-size: 12.5px; color: var(--ink-muted); }
.login-card .field { width: 100%; }
.login-card .field input { width: 100%; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 16px; }
.form-error {
  margin: 0 0 14px; padding: 9px 12px; border-radius: var(--radius-sm);
  background: rgba(208, 59, 59, 0.13); border: 1px solid rgba(208, 59, 59, 0.32);
  color: var(--critical); font-size: 12.5px;
}

/* ── entrance ───────────────────────────────────────────────────────── */

.reveal { animation: reveal 520ms var(--ease) backwards; }
.reveal:nth-child(2) { animation-delay: 60ms; }
.reveal:nth-child(3) { animation-delay: 120ms; }
.reveal:nth-child(4) { animation-delay: 180ms; }
.reveal:nth-child(5) { animation-delay: 240ms; }
@keyframes reveal { from { opacity: 0; transform: translateY(9px); } }

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

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: row; align-items: center;
    gap: 14px; overflow-x: auto; border-right: none;
    border-bottom: 1px solid var(--hairline); padding: 12px 14px;
  }
  .nav { flex-direction: row; }
  .nav-label, .sidebar-foot, .brand-sub { display: none; }
  .nav a.active::before { display: none; }
  .content { padding: 18px 14px; }
}
