:root {
  --bg: #fbfbfa;
  --panel: #ffffff;
  --ink: #1c1b19;
  --muted: #6b6a67;
  --line: #e5e3df;
  --accent: #2f6f4e;
  --danger: #a8352c;
  --warning: #a06a12;
  --success: #2f6f4e;
  --radius: 10px;
  font-family: ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171a;
    --panel: #1e2024;
    --ink: #ecebe8;
    --muted: #9b9a96;
    --line: #2f3237;
    --accent: #6aa587;
    --danger: #e08b82;
    --warning: #d6a95a;
    --success: #6aa587;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

header {
  padding: 1.5rem 1.5rem 1rem;
  border-bottom: 1px solid var(--line);
  position: relative;
}
header h1 { margin: 0; font-size: 1.15rem; letter-spacing: -0.01em; }
.sub { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.85rem; max-width: 60ch; }
.scope { position: absolute; top: 1.5rem; right: 1.5rem; color: var(--muted); font-size: 0.75rem; }

main { max-width: 940px; margin: 0 auto; padding: 1.5rem; }

.thread { display: flex; flex-direction: column; gap: 1rem; min-height: 40vh; }

.msg { border-radius: var(--radius); padding: 0.85rem 1rem; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; max-width: 70%; }
.msg.bot { background: var(--panel); border: 1px solid var(--line); }

.status { color: var(--muted); font-size: 0.9rem; }
.status.interp { color: var(--ink); font-size: 1rem; font-weight: 500; }
.status.error { color: var(--danger); }

.assumptions {
  margin: 0.6rem 0 0; padding-left: 1.1rem;
  color: var(--muted); font-size: 0.82rem;
}
.result { margin-top: 0.75rem; }
.empty { color: var(--muted); font-style: italic; }
.warn { color: var(--warning); font-size: 0.85rem; }

.latency { margin-top: 0.75rem; color: var(--muted); font-size: 0.7rem; font-variant-numeric: tabular-nums; }

/* -- table ---------------------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
tbody tr:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
td { font-variant-numeric: tabular-nums; }
.w-xs { width: 5rem; } .w-sm { width: 8rem; } .w-md { width: 12rem; } .w-lg { width: 18rem; }
.drillable { cursor: pointer; color: var(--accent); }

.hl-danger { color: var(--danger); font-weight: 600; }
.hl-warning { color: var(--warning); }
.hl-success { color: var(--success); }

.badge, .pill {
  display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px;
  font-size: 0.75rem; border: 1px solid var(--line); background: var(--bg);
}
.pill-review_required, .pill-discrepancy, .pill-failed, .pill-dead_letter { color: var(--danger); border-color: currentColor; }
.pill-closed, .pill-pass, .pill-confirmed, .pill-succeeded { color: var(--success); border-color: currentColor; }

.bar-wrap { display: inline-flex; align-items: center; gap: 0.4rem; }
.bar { display: inline-block; width: 60px; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }

.pager { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0; color: var(--muted); font-size: 0.8rem; }
button.page { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 6px; padding: 0.1rem 0.6rem; cursor: pointer; }
button.page:disabled { opacity: 0.4; cursor: default; }

/* -- kpi ------------------------------------------------------------------------------ */

.kpi-row { display: flex; flex-wrap: wrap; gap: 1rem; }
.kpi { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.8rem 1.1rem; min-width: 9rem; }
.kpi-label { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; }
.kpi-value { font-size: 1.7rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* -- chart ---------------------------------------------------------------------------- */

.chart { margin: 0 0 0.75rem; }
.chart svg { width: 100%; height: auto; }
.axis { stroke: var(--line); stroke-width: 1; }
.tick { fill: var(--muted); font-size: 10px; }
.line-mark { fill: none; stroke: var(--accent); stroke-width: 2; }
.area-mark { fill: color-mix(in srgb, var(--accent) 18%, transparent); stroke: none; }
.bar-mark { fill: var(--accent); }
.dot { fill: var(--accent); }
figcaption { color: var(--muted); font-size: 0.78rem; margin-top: 0.3rem; }

.list { margin: 0; padding-left: 1.1rem; font-size: 0.88rem; }
.detail { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 1rem; font-size: 0.88rem; }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; }

/* -- interaction ---------------------------------------------------------------------- */

.picker, .confirm, .feedback, .examples { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.confirm { margin-top: 0.75rem; font-size: 0.88rem; }
.feedback { margin-top: 0.5rem; }
.examples { margin: 1.25rem 0 0.75rem; }

button {
  font: inherit; font-size: 0.83rem; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 7px; padding: 0.3rem 0.7rem;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.drill { border: none; background: none; color: var(--accent); padding: 0; text-decoration: underline; }

.selection { display: inline-block; margin-bottom: 0.5rem; font-size: 0.8rem; color: var(--accent); }

#composer { display: flex; gap: 0.5rem; }
#question {
  flex: 1; font: inherit; padding: 0.6rem 0.8rem;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--ink);
}
#question:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }

/* -- generated views ------------------------------------------------------------------ */

.generated { position: relative; }
.generated iframe { background: transparent; }
.genbar {
  display: flex; align-items: center; gap: 0.6rem;
  margin-top: 0.35rem; color: var(--muted); font-size: 0.7rem;
}
.genbar button { font-size: 0.7rem; padding: 0.1rem 0.45rem; }

/* -- one block per question ------------------------------------------------------------ */

.interps { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 0.15rem; }
.interp-line { font-size: 0.95rem; }
.interps .interp-line + .interp-line { padding-top: 0.35rem; border-top: 1px solid var(--line); }
.interp-line.error { color: var(--danger); font-size: 0.88rem; }
.stack > .qlabel { margin-top: 0.9rem; }
.qlabel {
  color: var(--muted); font-size: 0.72rem; margin-bottom: 0.3rem;
  text-transform: uppercase; letter-spacing: 0.03em;
}
