:root {
  --ink: #1b1f1d;
  --muted: #55605b;
  --line: #d9dfdc;
  --bg: #f5f7f6;
  --card: #ffffff;
  --brand: #1f5f4a;
  --brand-ink: #ffffff;
  --ok: #1f6b3a;
  --ok-bg: #e3f3e8;
  --risk: #7a4b00;
  --risk-bg: #fff1cc;
  --drop: #a12a2a;
  --drop-bg: #fde6e6;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

* { box-sizing: border-box; }
body { margin: 0; font-size: 1rem; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; margin-top: 1.25rem; }
p { margin: 0 0 0.75rem; }
code { font-size: 0.9em; background: var(--bg); padding: 0 0.25em; border-radius: 4px; overflow-wrap: anywhere; }

.wrap { width: 100%; max-width: 920px; margin: 0 auto; padding: 0 1rem; }
.top { background: var(--brand); color: var(--brand-ink); padding: 1.5rem 0 1.25rem; margin-bottom: 1rem; }
.lead { font-size: 1.05rem; }
.privacy { font-size: 0.95rem; opacity: 0.92; margin: 0; }
.hint { color: var(--muted); font-size: 0.9rem; font-weight: normal; }
.top .hint { color: inherit; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 1rem; top: 1rem; background: #fff; color: var(--ink); padding: 0.5rem 0.75rem; border-radius: 8px; z-index: 10; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

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

.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 1rem; text-align: center; display: grid; gap: 0.6rem; justify-items: center; }
.drop.over { border-color: var(--brand); background: var(--ok-bg); }
.drop p { margin: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0.55rem 1rem; border-radius: 10px; border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink); font: inherit; font-weight: 600; cursor: pointer; text-align: center; }
.btn:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--brand); }
.btn-small { min-height: 44px; padding: 0.4rem 0.8rem; font-size: 0.95rem; }
.btn:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid #f0b429; outline-offset: 2px; }
#file:focus + .btn { outline: 3px solid #f0b429; outline-offset: 2px; }

.fields { display: grid; gap: 0.35rem; margin-top: 1rem; }
.fields label { font-weight: 600; margin-top: 0.4rem; }
input[type="text"], textarea { width: 100%; font: inherit; padding: 0.6rem 0.7rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
textarea { resize: vertical; font-size: 0.95rem; }

.errors { margin-top: 1rem; padding: 0.75rem; border-radius: 8px; background: var(--drop-bg); color: var(--drop); border: 1px solid #f3b9b9; }
.warnings { margin-top: 0.75rem; color: var(--muted); font-size: 0.9rem; }
summary { cursor: pointer; min-height: 32px; }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
.stat { border: 1px solid var(--line); border-radius: 10px; padding: 0.75rem; display: grid; }
.stat .num { font-size: 1.8rem; font-weight: 700; line-height: 1.1; }
.stat-active { background: var(--ok-bg); color: var(--ok); border-color: #bfe3cb; }
.stat-risk { background: var(--risk-bg); color: var(--risk); border-color: #f2d68a; }
.stat-dropped { background: var(--drop-bg); color: var(--drop); border-color: #f3b9b9; }

.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .threshold { stroke: var(--risk); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .bar { fill: var(--brand); }
.chart .bar-low { fill: #c98a00; }
.chart .axis { fill: var(--muted); font-size: 13px; }
.chart .value { fill: var(--ink); font-size: 13px; font-weight: 600; }
.chart .value-tight { font-size: 11px; }

table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; padding: 0.45rem 0.35rem; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
th { font-weight: 600; color: var(--muted); }
.table-scroll { overflow-x: auto; }
.table-wrap { margin-top: 0.75rem; }

.nudges { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.75rem; }
.nudge { border: 1px solid var(--line); border-radius: 10px; padding: 0.75rem; display: grid; gap: 0.5rem; }
.nudge p { margin: 0; }
.nudge-head { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; justify-content: space-between; }
.why { font-size: 0.95rem; }
.badge { display: inline-block; font-size: 0.8rem; font-weight: 700; padding: 0.15rem 0.55rem; border-radius: 999px; white-space: nowrap; }
.badge-active { background: var(--ok-bg); color: var(--ok); }
.badge-at-risk { background: var(--risk-bg); color: var(--risk); }
.badge-dropped { background: var(--drop-bg); color: var(--drop); }

.foot { color: var(--muted); font-size: 0.9rem; padding-bottom: 2rem; }

@media (min-width: 640px) {
  h1 { font-size: 2rem; }
  .card { padding: 1.25rem 1.5rem; }
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .drop { grid-auto-flow: column; justify-content: center; align-items: center; }
  .fields { grid-template-columns: max-content 1fr; align-items: center; column-gap: 1rem; }
  .fields label { margin-top: 0; }
  .nudges { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: no-preference) {
  .btn { transition: filter 0.15s ease; }
}
