/* bisestats result converter — the BISE Results Observatory design system.
 *
 * The tokens, radii and component shapes are lifted from the main site
 * (app/globals.css and app/page.tsx on the site's `main` branch) so the two read
 * as one product: the same navy hero and sticky header, the same teal eyebrow
 * labels over tight-tracked headings, the same white cards on the #f4f7f6
 * ground with #dfe8e5 borders.
 *
 * The site builds these from Tailwind utilities. This app is served by a small
 * Python process with no build step, so they are written out as classes here.
 */

:root {
  --ink: #153447;
  --navy: #0b283a;
  --navy-hover: #123b50;
  --teal: #0e8f83;
  --teal-dark: #0e7169;
  --teal-hover: #0b766e;
  --teal-tint: #eaf7f5;
  --teal-tint-strong: #d6f0ec;
  --teal-soft: #8bcac1;
  --mint: #6ed7c9;
  --gold: #f2bc57;
  --gold-tint: #fff4d9;
  --gold-ink: #9a6500;
  --ground: #f4f7f6;
  --surface: #ffffff;
  --surface-soft: #f8fbfa;
  --line: #dfe8e5;
  --line-strong: #cddbd7;
  --line-soft: #eef2f1;
  --muted: #64748b;
  --muted-soft: #94a3b8;
  --rose: #e11d48;
  --rose-tint: #fff1f2;
  --rose-ink: #be123c;
  --emerald: #147a4b;
  --emerald-tint: #e7f8ef;
  --r-lg: 0.625rem;
  --r-xl: 0.75rem;
  --r-2xl: 1rem;
  --r-3xl: 1.5rem;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ground);
  color: var(--ink);
  font-family: Geist, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.02em; }
h1 { font-size: 2.25rem; line-height: 1.15; letter-spacing: -0.04em; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.2rem; }
p { margin: 0; }
a { color: var(--teal-dark); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; }

.shell { margin: 0 auto; max-width: 80rem; padding: 0 1.25rem; }
@media (min-width: 640px) { .shell { padding: 0 2rem; } }

.stack > * + * { margin-top: 0.75rem; }
.muted { color: var(--muted); }
.small { font-size: 0.8125rem; }
.tiny { font-size: 0.75rem; }
.mono { font-family: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace; }
.center { text-align: center; }
.grow { flex: 1 1 auto; }
.nowrap { white-space: nowrap; }

.eyebrow {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--teal);
}
.eyebrow-light { color: var(--mint); }

/* ---------------------------------------------------------------- header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(11, 40, 58, 0.95);
  backdrop-filter: blur(16px);
  color: #fff;
}
.site-header .bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
}
.brand { display: flex; align-items: center; gap: 0.75rem; color: #fff; font-weight: 600; }
.brand:hover { text-decoration: none; }
.brand .mark {
  display: grid;
  place-items: center;
  height: 2.5rem;
  width: 2.5rem;
  border-radius: var(--r-xl);
  background: var(--teal);
  flex: none;
}
.brand .name { display: block; font-size: 0.875rem; line-height: 1.2; }
.brand .sub { display: none; font-size: 0.75rem; color: rgba(255, 255, 255, 0.55); font-weight: 400; }
@media (min-width: 640px) { .brand .sub { display: block; } }

.site-nav { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; }
.nav-link {
  border-radius: 9999px;
  padding: 0.5rem 1rem;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 500;
}
.nav-link:hover { background: rgba(255, 255, 255, 0.1); color: #fff; text-decoration: none; }
.nav-badge {
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.1);
  border-radius: 9999px;
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
}
@media (max-width: 700px) { .nav-hide-sm { display: none; } }

/* ------------------------------------------------------------------ hero */

.hero {
  position: relative;
  overflow: hidden;
  background: var(--navy);
  color: #fff;
  padding: 3.5rem 0 6rem;
}
.hero h1 { max-width: 44rem; }
@media (min-width: 640px) { .hero h1 { font-size: 3.25rem; } }
.hero p.lede {
  margin-top: 1.25rem;
  max-width: 40rem;
  color: rgba(255, 255, 255, 0.65);
  font-size: 1rem;
  line-height: 1.75;
}
.hero-compact { padding: 2.5rem 0 4.5rem; }
.hero-compact h1 { font-size: 1.9rem; letter-spacing: -0.03em; }
@media (min-width: 640px) { .hero-compact h1 { font-size: 2.5rem; } }

.pull-up { margin-top: -4rem; position: relative; z-index: 1; }
.section { padding: 2.5rem 0; }

/* ----------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-3xl);
  padding: 1.75rem;
}
@media (min-width: 640px) { .card { padding: 2rem; } }
.card-tight { padding: 1.25rem; border-radius: var(--r-2xl); }
.card-soft { background: var(--surface-soft); }
.card-navy { background: var(--navy); color: #fff; border-color: transparent; }
.card-navy .muted { color: rgba(255, 255, 255, 0.6); }
.card-flush { padding: 0; overflow: hidden; }
.card-head {
  padding: 1.5rem 1.75rem;
  border-bottom: 1px solid var(--line-soft);
}
.card-body { padding: 1.5rem 1.75rem; }
.card-foot {
  padding: 1.25rem 1.75rem;
  border-top: 1px solid var(--line-soft);
  background: var(--surface-soft);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.grid { display: grid; gap: 1rem; }
@media (min-width: 900px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid-side { grid-template-columns: minmax(0, 1fr) 22rem; }
}

.stat { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-2xl); padding: 1.25rem; }
.stat .label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--teal); }
.stat .value { margin-top: 0.5rem; font-size: 1.75rem; font-weight: 600; letter-spacing: -0.02em; }
.stat .note { margin-top: 0.25rem; font-size: 0.8125rem; color: var(--muted); }

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 1px solid transparent;
  border-radius: var(--r-xl);
  padding: 0.75rem 1.25rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-hover); }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--navy-hover); }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--teal-soft); }
.btn-quiet { background: transparent; color: var(--teal-dark); padding: 0.5rem 0.75rem; }
.btn-quiet:hover { background: var(--teal-tint); }
.btn-sm { padding: 0.45rem 0.85rem; font-size: 0.8125rem; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }

/* ---------------------------------------------------------------- forms */

.field { display: block; margin-top: 1rem; }
.field:first-child { margin-top: 0; }
.field > .label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 0.4rem; }
.field > .hint { display: block; font-size: 0.75rem; color: var(--muted); margin-top: 0.35rem; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="file"],
select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2xl);
  background: var(--surface);
  padding: 0.8rem 0.9rem;
  font: inherit;
  font-size: 0.9375rem;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(14, 143, 131, 0.1);
}
input[type="file"] { padding: 0.65rem 0.75rem; background: var(--surface-soft); }
select { appearance: none; background-image: none; }

.check {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.875rem;
  cursor: pointer;
  padding: 0.3rem 0;
}
.check input { margin: 0.2rem 0 0; accent-color: var(--teal); width: 1rem; height: 1rem; flex: none; }

/* --------------------------------------------------------------- notices */

.notice {
  border-radius: var(--r-2xl);
  border: 1px solid var(--line);
  background: var(--surface-soft);
  padding: 0.9rem 1.1rem;
  font-size: 0.875rem;
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
}
.notice svg { flex: none; margin-top: 0.1rem; }
.notice-error { border-color: #fecdd3; background: var(--rose-tint); color: var(--rose-ink); }
.notice-warn { border-color: #f6dfae; background: var(--gold-tint); color: var(--gold-ink); }
.notice-ok { border-color: #bbe7d0; background: var(--emerald-tint); color: var(--emerald); }
.notice-info { border-color: var(--teal-soft); background: var(--teal-tint); color: var(--teal-dark); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 9999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--teal-tint);
  color: var(--teal-dark);
}
.pill-ok { background: var(--emerald-tint); color: var(--emerald); }
.pill-warn { background: var(--gold-tint); color: var(--gold-ink); }
.pill-error { background: var(--rose-tint); color: var(--rose-ink); }
.pill-muted { background: var(--line-soft); color: var(--muted); }

/* ---------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; text-align: left; }
table.data thead th {
  background: var(--ground);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 0.9rem 1.25rem;
  white-space: nowrap;
}
table.data tbody td { padding: 0.9rem 1.25rem; border-top: 1px solid var(--line-soft); vertical-align: top; }
table.data tbody tr:hover { background: var(--surface-soft); }

/* -------------------------------------------------------- column picker */

.picker-group { border: 1px solid var(--line); border-radius: var(--r-2xl); overflow: hidden; }
.picker-group + .picker-group { margin-top: 0.85rem; }
.picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.1rem;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line-soft);
}
.picker-head .title { display: flex; align-items: center; gap: 0.6rem; font-weight: 600; font-size: 0.9375rem; }
.picker-head input { accent-color: var(--teal); width: 1rem; height: 1rem; }
.picker-body {
  display: grid;
  gap: 0.15rem 1.25rem;
  padding: 0.85rem 1.1rem;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, var(--ground) 72%, rgba(244, 247, 246, 0));
  padding: 1rem 0 1.25rem;
}

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

.site-footer { border-top: 1px solid var(--line); background: var(--surface); margin-top: 3rem; }
.site-footer .bar {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.75rem 0;
  font-size: 0.75rem;
  color: var(--muted);
}
@media (min-width: 640px) { .site-footer .bar { flex-direction: row; } }

/* ------------------------------------------------------------- progress */

.bar-track { height: 0.5rem; border-radius: 9999px; background: var(--line-soft); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 9999px; background: var(--teal); transition: width 0.5s ease; }

.spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--teal-tint-strong);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 3s; }
  .bar-fill { transition: none; }
}

/* ------------------------------------------------------------ file picker */

.dropzone {
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-2xl);
  background: var(--surface-soft);
  padding: 1.5rem 1.25rem;
  text-align: center;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.dropzone.is-over { border-color: var(--teal); background: var(--teal-tint); }
.dropzone .hint { display: block; margin-top: 0.5rem; font-size: 0.75rem; color: var(--muted); }
.dropzone input[type="file"] { display: none; }

.filelist { list-style: none; margin: 0.85rem 0 0; padding: 0; }
.filelist li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--surface);
  font-size: 0.8125rem;
}
.filelist li + li { margin-top: 0.4rem; }
.filelist .name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filelist .size { color: var(--muted); font-variant-numeric: tabular-nums; }
.filelist .drop {
  border: 0; background: none; cursor: pointer; color: var(--muted);
  font-size: 1.1rem; line-height: 1; padding: 0 0.25rem; border-radius: 999px;
}
.filelist .drop:hover { color: var(--rose-ink); background: var(--rose-tint); }

/* ---------------------------------------------------------------- charts */

.chart { margin: 0; }
.chart + .chart { margin-top: 1.75rem; }
.chart-title { font-size: 0.9375rem; font-weight: 600; margin-bottom: 0.15rem; }
.chart-caption { margin-top: 0.5rem; font-size: 0.75rem; line-height: 1.6; color: var(--muted); }
.chart-scroll { overflow-x: auto; }
.chart-scroll svg { min-width: 520px; display: block; }

.summary-grid { display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 900px) { .summary-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.summary-grid .stat { padding: 1rem; }
.summary-grid .stat .value { font-size: 1.5rem; }

table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

.danger-link {
  border: 0; background: none; padding: 0; cursor: pointer;
  font: inherit; font-size: 0.8125rem; font-weight: 600; color: var(--rose-ink);
}
.danger-link:hover { text-decoration: underline; }
