/* ==================================================================
   NH ARES Winlink Archive — stylesheet (modern refresh)
   Light-mode, system fonts (fast + reliable on low bandwidth), with a
   refined "field operations console" identity: cool slate neutrals,
   layered depth, and monospace treatment for radio identifiers.
   ================================================================== */

:root {
  color-scheme: light;

  --bg:          #eef2f7;
  --surface:     #ffffff;
  --surface-2:   #f1f4f9;
  --surface-3:   #e7ecf3;
  --ink:         #0f1728;
  --ink-2:       #334155;
  --muted:       #64748b;
  --line:        #e3e8f0;
  --line-2:      #d2dae5;

  --accent:      #2563eb;
  --accent-strong:#1d4ed8;
  --accent-wash: #e8f0ff;
  --signal:      #0e9bb0;   /* secondary series / technical accent */

  --danger:      #dc2626;
  --danger-wash: #fef2f2;
  --ok:          #059669;
  --focus:       #3b82f6;

  --r-lg: 18px;
  --r:    14px;
  --r-sm: 10px;
  --r-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
  --shadow:    0 1px 2px rgba(15,23,42,.05), 0 8px 24px -12px rgba(15,23,42,.22);
  --shadow-lg: 0 2px 4px rgba(15,23,42,.05), 0 24px 48px -20px rgba(15,23,42,.30);

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body { background: var(--bg); color: var(--ink); }
body {
  font-family: var(--sans);
  margin: 0;
  line-height: 1.6;
  font-size: 16px;
  letter-spacing: -0.003em;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  background-image: radial-gradient(1200px 400px at 50% -120px, rgba(37,99,235,.06), transparent 70%);
  background-repeat: no-repeat;
}

/* Signal strip — the identity flourish */
body::before {
  content: "";
  display: block;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--signal) 55%, var(--accent));
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 2px; }

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 50%, transparent);
  outline-offset: 2px;
  border-radius: 6px;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 18px 64px; }

/* ---------- Sticky translucent nav + account bar ---------- */
.topnav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 22px;
  margin: 0 -18px 20px;
  padding: 12px 18px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topnav ul {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-wrap: wrap; gap: 4px 4px;
}
.topnav ul a {
  display: inline-block;
  font-weight: 550;
  font-size: .92rem;
  color: var(--ink-2);
  padding: 5px 10px;
  border-radius: var(--r-sm);
}
.topnav ul a:hover { color: var(--ink); background: var(--surface-3); text-decoration: none; }

.account { display: flex; align-items: center; gap: 12px; }
.whoami { color: var(--muted); font-size: .88rem; }
.logout-form { margin: 0; }

/* ---------- Masthead ---------- */
.masthead {
  display: flex; align-items: center; gap: 18px;
  margin: 6px 0 22px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.masthead img {
  width: 92px; height: auto; display: block;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
}
.site-title {
  font-size: clamp(1.35rem, 1rem + 1.4vw, 1.85rem);
  font-weight: 750;
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.site-title a { color: inherit; }
.site-title a:hover { color: var(--accent); text-decoration: none; }
.page-title {
  font-size: .82rem;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin: 8px 0 0;
  color: var(--accent);
}

h2 { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.015em; margin: 28px 0 12px; }
h3 { font-size: 1.05rem; font-weight: 650; margin: 18px 0 8px; }
.section-title { margin-top: 30px; }

.muted { color: var(--muted); }
.error { color: var(--danger); font-weight: 600; }

/* Monospace treatment for radio identifiers */
.callsign { font-family: var(--mono); font-weight: 600; letter-spacing: .01em; color: var(--ink); }

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  font: inherit; font-weight: 600; font-size: .92rem;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--r-sm);
  padding: 8px 14px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background .14s ease, border-color .14s ease, transform .06s ease, box-shadow .14s ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--line-2); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(180deg, #3b82f6, var(--accent));
  border-color: var(--accent-strong);
  color: #fff;
  box-shadow: 0 1px 2px rgba(37,99,235,.4), 0 8px 20px -8px rgba(37,99,235,.5);
}
.btn-primary:hover { background: linear-gradient(180deg, var(--accent), var(--accent-strong)); }
.btn-ghost { background: transparent; border-color: var(--line-2); padding: 6px 12px; font-size: .88rem; }
.btn-ghost:hover { background: var(--surface); }
.btn-block { display: block; width: 100%; padding: 12px; font-size: 1rem; }

.controls { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }

/* ---------- Panels (details/summary) ---------- */
.panel {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: 14px 18px;
  margin: 14px 0;
}
.panel > summary {
  cursor: pointer; font-weight: 700; list-style: none;
  display: flex; align-items: center; gap: 10px;
}
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary::before {
  content: ""; width: 8px; height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform .18s ease; flex: none;
}
.panel[open] > summary::before { transform: rotate(45deg); }
.panel > summary small { color: var(--muted); font-weight: 500; }
.panel-month { background: var(--surface-2); border-color: var(--line); }

/* ---------- Trends panel ---------- */
.trends { padding: 16px 18px 18px; }
.trends-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.trends-title {
  margin: 0; font-size: .82rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2);
}
.range-tabs { display: inline-flex; gap: 3px; padding: 3px; background: var(--surface-2); border-radius: var(--r-pill); }
.range-tabs a {
  font-size: .82rem; font-weight: 600; color: var(--muted);
  border-radius: var(--r-pill); padding: 5px 14px; line-height: 1;
}
.range-tabs a:hover { color: var(--ink); text-decoration: none; }
.range-tabs a.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }
.trends-chart {
  margin-top: 14px; padding: 8px 4px 0;
  background: linear-gradient(180deg, var(--surface-2), transparent);
  border-radius: var(--r);
}
.trends-note { margin: 10px 0 0; font-size: .88rem; }

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto; margin-top: 14px;
  border: 1px solid var(--line); border-radius: var(--r);
}
table.nhares-table { border-collapse: collapse; width: 100%; background: var(--surface); font-size: .95rem; }
table.nhares-table th, table.nhares-table td {
  padding: 11px 14px; border-bottom: 1px solid var(--line);
  text-align: left; vertical-align: top;
}
table.nhares-table thead th {
  position: sticky; top: 0;
  background: var(--surface-2);
  font-weight: 700; font-size: .72rem; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted); white-space: nowrap;
}
table.nhares-table tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
table.nhares-table tbody tr:hover { background: var(--accent-wash); }
table.nhares-table tbody tr:last-child td { border-bottom: none; }
table.nhares-table tbody td:first-child { font-weight: 550; color: var(--ink); }
table.nhares-table td.num, table.nhares-table th.num { text-align: right; white-space: nowrap; }

.checkin-list { list-style: none; padding: 0; margin: 14px 0; display: grid; gap: 8px; }
.checkin-list a { display: inline-block; }

/* ---------- Prose (markdown + embedded check-in HTML) ---------- */
.prose, .intro {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 22px 24px; box-shadow: var(--shadow-sm);
}
.intro { margin-bottom: 18px; }
.intro p:first-child { font-size: 1.05rem; color: var(--ink); }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p { margin: 12px 0; }
.prose ul, .prose ol { margin: 12px 0 12px 22px; }
.prose hr { border: none; border-top: 1px solid var(--line); margin: 20px 0; }
.prose blockquote {
  margin: 14px 0; padding: 10px 16px;
  border-left: 3px solid var(--accent); background: var(--surface-2);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.prose code { font-family: var(--mono); font-size: .92em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.prose pre { overflow-x: auto; padding: 14px 16px; background: #0b1220; color: #e5edff; border-radius: var(--r); }
.prose pre code { color: inherit; background: none; padding: 0; }
.prose table { border-collapse: collapse; width: 100%; margin: 14px 0; }
.prose th, .prose td { border: 1px solid var(--line); padding: 9px 11px; text-align: left; }
.prose th { background: var(--surface-2); }

.backlink { margin-top: 18px; }

/* ---------- Alerts ---------- */
.alert {
  background: var(--danger-wash);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  color: var(--danger);
  border-radius: var(--r-sm); padding: 11px 15px; margin: 14px 0; font-weight: 500;
}

/* ---------- Login ---------- */
.login-body {
  background: var(--bg);
  background-image: radial-gradient(900px 500px at 50% -10%, rgba(37,99,235,.10), transparent 60%);
}
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 32px 18px; }
.login-card {
  width: 100%; max-width: 420px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 22px; box-shadow: var(--shadow-lg);
  padding: 34px 30px 28px; text-align: center;
}
.login-logo {
  margin: 0 auto 16px; display: block;
  padding: 10px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r);
}
.login-title { font-size: 1.4rem; font-weight: 750; letter-spacing: -0.02em; margin: 0 0 4px; }
.login-sub { color: var(--muted); margin: 0 0 20px; font-size: .95rem; }
.login-form { text-align: left; }
.login-form label { display: block; font-weight: 600; font-size: .86rem; margin: 14px 0 6px; color: var(--ink-2); }
.login-form input {
  width: 100%; font: inherit;
  padding: 12px 13px; border: 1px solid var(--line-2);
  border-radius: var(--r-sm); background: var(--surface); color: var(--ink);
  transition: border-color .14s ease, box-shadow .14s ease;
}
.login-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-wash); }
.login-form .btn-block { margin-top: 22px; }
.login-help { color: var(--muted); font-size: .85rem; margin: 18px 0 0; text-align: center; }
.login-version { font-family: var(--mono); font-size: .76rem; color: var(--muted); margin: 12px 0 0; text-align: center; }
.login-body .alert { text-align: left; }

/* ---------- Footer / version ---------- */
.site-footer {
  margin-top: 34px; padding-top: 16px; border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px;
  color: var(--muted); font-size: .82rem;
}
.app-version { font-family: var(--mono); }

/* ---------- Responsive ---------- */
@media (max-width: 620px) {
  .site-title { font-size: 1.3rem; }
  .masthead { gap: 14px; }
  .masthead img { width: 68px; }
  .topnav { justify-content: flex-start; }
  .account { width: 100%; justify-content: space-between; }
  .prose, .intro { padding: 18px; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
