/* ---------------------------------------------------------------------------
   Palette roles. Light values are the defaults; the dark values are declared
   under both the OS media query and the [data-theme] scope so the in-page
   toggle wins in either direction.
   --------------------------------------------------------------------------- */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --hover-wash: rgba(11, 11, 11, 0.04);

  --series-1: #2a78d6;
  --series-1-fill: rgba(42, 120, 214, 0.14);

  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;

  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --hover-wash: rgba(255, 255, 255, 0.06);
    --series-1: #3987e5;
    --series-1-fill: rgba(57, 135, 229, 0.18);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --gridline: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --hover-wash: rgba(255, 255, 255, 0.06);
  --series-1: #3987e5;
  --series-1-fill: rgba(57, 135, 229, 0.18);
}

* {
  box-sizing: border-box;
}

/* An author `display` rule outranks the UA stylesheet's [hidden] rule, so the
   attribute silently stops working on anything styled below. Restore it. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--page);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}

h1,
h2 {
  margin: 0;
  font-weight: 600;
}
h1 {
  font-size: 17px;
  letter-spacing: -0.01em;
}
h2 {
  font-size: 14px;
}

.sub,
.cap-note {
  margin: 2px 0 0;
  color: var(--text-secondary);
  font-size: 12.5px;
}

/* ---- top bar ------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 20px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 9px;
}
.tab {
  font: inherit;
  font-size: 13px;
  padding: 6px 14px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover {
  color: var(--text-primary);
}
.tab.is-active {
  background: var(--surface-1);
  color: var(--text-primary);
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

th.num,
td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
td.num {
  color: var(--text-primary);
}

.btn {
  font: inherit;
  font-size: 13px;
  padding: 7px 13px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover:not(:disabled) {
  background: var(--hover-wash);
}
.btn.primary {
  background: var(--series-1);
  border-color: transparent;
  color: #fff;
  font-weight: 500;
}
.btn.primary:hover:not(:disabled) {
  filter: brightness(1.08);
}
.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

/* ---- banner -------------------------------------------------------------- */
.banner {
  margin: 14px 20px 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-1);
  font-size: 13px;
  color: var(--text-secondary);
}
.banner strong {
  color: var(--text-primary);
}
.banner code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  background: var(--hover-wash);
  padding: 1px 5px;
  border-radius: 4px;
}
.banner.error {
  border-left: 3px solid var(--critical);
}
.banner.busy {
  border-left: 3px solid var(--series-1);
}

main {
  padding: 16px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 1500px;
}

/* ---- filters ------------------------------------------------------------- */
.filters {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  padding: 12px 14px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 130px;
}
.field.grow {
  flex: 1 1 200px;
}
.field > span {
  font-size: 11.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field input,
.field select {
  font: inherit;
  font-size: 13px;
  padding: 6px 8px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--page);
  color: var(--text-primary);
  width: 100%;
}

/* ---- stat tiles ---------------------------------------------------------- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}
.tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.tile .label {
  font-size: 11.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tile .value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 2px;
}
.tile .value.small {
  font-size: 18px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.tile .value.medium {
  font-size: 24px;
}
.tile .foot {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ---- cards & charts ------------------------------------------------------ */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px 10px;
  margin: 0;
}
.charts {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  align-items: start;
  gap: 16px;
}
@media (max-width: 940px) {
  .charts {
    grid-template-columns: minmax(0, 1fr);
  }
}
figcaption {
  margin-bottom: 10px;
}
.plot {
  width: 100%;
}
.plot svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.grid-line {
  stroke: var(--gridline);
  stroke-width: 1;
  shape-rendering: crispEdges;
}
.axis-line {
  stroke: var(--baseline);
  stroke-width: 1;
  shape-rendering: crispEdges;
}
.tick-text {
  fill: var(--text-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.series-line {
  fill: none;
  stroke: var(--series-1);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.series-area {
  fill: var(--series-1-fill);
  stroke: none;
}
.bar {
  fill: var(--series-1);
}
.bar-label {
  fill: var(--text-secondary);
  font-size: 12px;
}
.bar-value {
  fill: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.hit {
  fill: transparent;
  cursor: pointer;
}
.bar.is-hot {
  filter: brightness(1.12);
}
.crosshair {
  stroke: var(--baseline);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}
.focus-dot {
  fill: var(--series-1);
  stroke: var(--surface-1);
  stroke-width: 2;
}
.empty-note {
  fill: var(--text-muted);
  font-size: 12.5px;
}

/* ---- tooltip ------------------------------------------------------------- */
.tooltip {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  background: var(--surface-1);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12.5px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
  max-width: 260px;
}
.tooltip .tt-key {
  color: var(--text-secondary);
}
.tooltip .tt-val {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---- table --------------------------------------------------------------- */
.table-card {
  padding-bottom: 4px;
}
.table-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.table-scroll {
  overflow-x: auto;
  max-height: 620px;
  overflow-y: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 6px 10px;
  border-bottom: 1px solid var(--baseline);
  background: var(--surface-1);
  position: sticky;
  top: 0;
  white-space: nowrap;
}
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--gridline);
  vertical-align: top;
  color: var(--text-secondary);
}
tbody tr:hover td {
  background: var(--hover-wash);
}
.col-date {
  width: 96px;
}
.col-who {
  width: 130px;
}
.col-mod {
  width: 140px;
}
.col-kind {
  width: 132px;
}
/* Several chips can stack in one cell when an issue is more than one thing. */
td .kind + .kind {
  margin-top: 3px;
}
.col-sev {
  width: 108px;
}
/* Type: a text label, never colour alone. Flow gaps are outlined rather than
   filled so they read as a different class of thing, not a worse severity. */
.kind {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  border: 1px solid transparent;
  color: var(--text-secondary);
  background: var(--hover-wash);
}
.kind-bug {
  color: var(--text-primary);
  font-weight: 500;
}
.kind-product_gap {
  color: var(--series-1);
  border-color: var(--series-1);
  background: transparent;
  font-weight: 500;
}
.kind-expected {
  color: var(--text-muted);
}
.col-status {
  width: 108px;
}
.col-link {
  width: 78px;
}
td.date .year {
  color: var(--text-muted);
  font-size: 11.5px;
}
.assignees {
  color: var(--text-muted);
  font-size: 11.5px;
  margin-top: 2px;
}
.meta-note {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 3px;
  white-space: nowrap;
}
/* Marks bugs that arrived bundled in one Slack message. */
.multi {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  vertical-align: 1px;
}
/* Status: text label only — no colour dependency. */
.status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  text-transform: capitalize;
  white-space: nowrap;
  color: var(--text-secondary);
  background: var(--hover-wash);
}
.status-fixed {
  color: var(--good);
  font-weight: 500;
}
.status-open {
  color: var(--text-primary);
}
td.date {
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
td.summary {
  color: var(--text-primary);
}
.mod-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}
/* Severity: a colour dot plus its label — never colour alone. */
.sev {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  text-transform: capitalize;
}
.sev-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
  background: var(--text-muted);
}
.sev-blocker .sev-dot,
.sev-critical .sev-dot {
  background: var(--critical);
}
.sev-major .sev-dot {
  background: var(--serious);
}
.sev-minor .sev-dot {
  background: var(--warning);
}
.sev-trivial .sev-dot {
  background: var(--good);
}
.row-link {
  color: var(--series-1);
  text-decoration: none;
  font-size: 12px;
  white-space: nowrap;
}
.row-link:hover {
  text-decoration: underline;
}
.empty-row td {
  text-align: center;
  color: var(--text-muted);
  padding: 34px 10px;
}

/* A sample size smaller than the fix count means the metric covers only part
   of the person's work — dim it so it reads as a caveat, not a headline. */
td.num.weak {
  color: var(--text-muted);
}

/* Sprint table: a compact run of "N Name" chips in one cell. */
.col-sprint {
  width: 130px;
}
.who {
  display: inline-block;
  margin: 0 10px 2px 0;
  font-size: 12.5px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.who b {
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* A count that links into Jira. Underlined on hover only, so the tables stay
   quiet until you go looking for a way through. */
.drill {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted var(--baseline);
}
.drill:hover {
  color: var(--series-1);
  border-bottom-color: var(--series-1);
}
a.who.drill {
  border-bottom: none;
}
a.who.drill:hover b,
a.who.drill:hover {
  color: var(--series-1);
}
.hit.is-link {
  cursor: pointer;
}
.tooltip .tt-hint {
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--text-muted);
}

/* ---- sign-in gate --------------------------------------------------------- */
body.is-gated {
  overflow: hidden;
}
#auth-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--page);
}
.auth-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 34px;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}
.auth-card h1 {
  font-size: 20px;
  margin-bottom: 6px;
}
.auth-sub {
  color: var(--text-secondary);
  font-size: 13.5px;
  margin: 0 0 20px;
}
.auth-btn {
  width: 100%;
  padding: 10px 16px;
  font-size: 14px;
}
.auth-note {
  color: var(--text-muted);
  font-size: 12px;
  margin: 14px 0 0;
}
.auth-error {
  color: var(--critical);
  font-size: 12.5px;
  margin: 14px 0 0;
  text-align: left;
  line-height: 1.45;
}
.whoami {
  color: var(--text-secondary);
  font-size: 12.5px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
