/* CSV Column Statistics — the whole output is a grid of numbers, so the layout
   has one job: make a column of figures scannable. That means tabular figures
   aligned right, the row label carrying the weight, and the "not counted"
   notes visibly subordinate to the numbers they qualify — a warning that looks
   like data is how a partial mean gets read as a total one. */

:root {
  --ink: #16181d;
  --ink-soft: #5b6270;
  --line: #e2e5eb;
  --bg: #f6f7f9;
  --card: #ffffff;
  --accent: #1f5eff;
  --warn-bg: #fff6e5;
  --warn-ink: #8a5a00;
  --error-bg: #fdecec;
  --error-ink: #a01b1b;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 2rem 1rem 3rem;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.wrap { max-width: 52rem; margin: 0 auto; }

.head h1 { font-size: 1.6rem; margin: 0 0 .35rem; letter-spacing: -.01em; }
.lede { margin: 0 0 1.5rem; color: var(--ink-soft); max-width: 42rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

/* -- the form ---------------------------------------------------------- */

.field { display: block; }
.label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 600;
  margin-bottom: .4rem;
}

textarea {
  width: 100%;
  padding: .7rem .8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: 13px/1.45 ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  resize: vertical;
  background: #fcfcfd;
  color: var(--ink);
}
textarea:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: .9rem;
  align-items: end;
  margin-top: .9rem;
}
.control { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--ink-soft); }
.control select {
  padding: .45rem .5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: .95rem;
}
.actions { margin-left: auto; display: flex; gap: .5rem; }

button {
  padding: .55rem 1.1rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
}
button.ghost { background: #fff; color: var(--ink); border-color: var(--line); font-weight: 500; }
button:hover { filter: brightness(1.05); }

/* -- results ----------------------------------------------------------- */

.summary p { margin: 0 0 .3rem; }
.summary strong { font-variant-numeric: tabular-nums; }

.stats-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}
.stats-table th, .stats-table td {
  padding: .5rem .6rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.stats-table thead th {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-soft);
  border-bottom-width: 2px;
}
.stats-table tbody th { font-weight: 600; }

/* Right-aligned tabular figures: the point of the whole page is comparing
   numbers down a column, which proportional digits make impossible. */
.stats-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  white-space: nowrap;
}

.note-row td { border-bottom: 1px solid var(--line); }
.note {
  font-size: .8rem;
  color: var(--warn-ink);
  background: var(--warn-bg);
  padding: .3rem .6rem;
  border-radius: 6px;
}

.flag {
  display: inline-block;
  margin-left: .4rem;
  padding: .05rem .4rem;
  border-radius: 999px;
  background: var(--warn-bg);
  color: var(--warn-ink);
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  vertical-align: middle;
}

.chip {
  display: inline-block;
  margin: 0 .25rem .25rem 0;
  padding: .1rem .45rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fafbfc;
  font-size: .78rem;
  color: var(--ink-soft);
}
.other-columns { margin-top: 1rem; }
.actions-row { margin: .9rem 0 0; }
.empty { margin: 1rem 0 0; color: var(--ink-soft); }

.error {
  background: var(--error-bg);
  color: var(--error-ink);
  border: 1px solid #f3c9c9;
  border-radius: var(--radius);
  padding: .7rem .9rem;
  margin: 0 0 1.25rem;
}

.hint { color: var(--ink-soft); font-size: .85rem; }

/* -- footer ------------------------------------------------------------ */

.foot { color: var(--ink-soft); font-size: .9rem; }
.foot details { margin-bottom: .75rem; }
.foot summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.foot p { max-width: 42rem; }
.foot code {
  background: #eef0f4;
  padding: .05rem .25rem;
  border-radius: 4px;
  font-size: .85em;
}
a { color: var(--accent); }

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8eaee;
    --ink-soft: #a2a9b6;
    --line: #2c3038;
    --bg: #14161a;
    --card: #1b1e23;
    --accent: #6f9bff;
    --warn-bg: #3a2f16;
    --warn-ink: #f0c674;
    --error-bg: #3a1e1e;
    --error-ink: #f3a3a3;
  }
  textarea, .control select { background: #15181c; }
  button.ghost { background: #22262c; }
  .chip { background: #21252b; }
  .foot code { background: #22262c; }
}

@media (max-width: 34rem) {
  .actions { margin-left: 0; width: 100%; }
  .actions button { flex: 1; }
  .stats-table th, .stats-table td { padding: .45rem .35rem; font-size: .9rem; }
}
