/* ==========================================================================
   TrackImpact design system
   --------------------------------------------------------------------------
   One shared stylesheet for every page (linked from base.html). The visual
   identity is "editorial intelligence": a scholarly serif (Source Serif 4)
   for display + a disciplined sans (Inter) for UI and data, set on warm
   paper with an ink-navy accent. Self-hosted variable fonts — no CDN.

   Page templates keep their own <style> blocks for layout, but colors flow
   from these tokens (var(--accent) etc.), so retheming happens here.
   ========================================================================== */

/* ---- fonts (variable, latin subset, self-hosted) ------------------------ */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/Inter-Variable.woff2") format("woff2");
}
@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 200 900;
  font-stretch: normal;
  font-display: swap;
  src: url("/static/fonts/SourceSerif4-Variable.woff2") format("woff2");
}
@font-face {
  font-family: "Source Serif 4";
  font-style: italic;
  font-weight: 200 900;
  font-display: swap;
  src: url("/static/fonts/SourceSerif4-Italic-Variable.woff2") format("woff2");
}

/* ---- tokens ------------------------------------------------------------- */
:root {
  /* surfaces */
  --bg: #f7f5ef;            /* warm paper */
  --surface: #ffffff;       /* cards, header */
  --surface-2: #f3f0e8;     /* hover tint, wells */
  --fg: #212733;            /* ink (navy-cast) */
  --muted: #5f6774;
  --faint: #8a90a0;
  --border: #e3dfd4;        /* warm hairline */
  --border-strong: #cfc9ba;

  /* brand */
  --accent: #1e4d75;        /* ink navy — links, primary actions */
  --accent-hover: #163a59;
  --accent-soft: #e8eef5;   /* tinted chips/wells behind navy text */
  --brand-warm: #b45a1f;    /* burnt sienna — the counterpoint hue */

  /* semantics */
  --warn: #b45a1f;
  --good: #2a7d52;
  --danger: #a83a3a;
  --warn-soft: #f7ead9;
  --good-soft: #e3f0e8;

  /* type */
  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-display: "Source Serif 4", Georgia, "Times New Roman", serif;

  /* shape */
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-card: 0 1px 2px rgba(33, 39, 51, 0.05);
  --shadow-pop: 0 10px 32px rgba(33, 39, 51, 0.14);
}

/* ---- base -------------------------------------------------------------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-ui);
  font-optical-sizing: auto;
  background: var(--bg);
  color: var(--fg);
  margin: 0;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 28px 28px; }

h1, h2, h3, .serif {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-weight: 620;
  letter-spacing: -0.01em;
  line-height: 1.22;
  color: var(--fg);
}
h1 { font-size: 30px; margin: 0.4em 0 0.45em; }
h2 { font-size: 21px; margin: 1.5em 0 0.55em; }
h3 { font-size: 16.5px; margin: 1.3em 0 0.45em; }
h4, h5 { font-family: var(--font-ui); font-weight: 600; }

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

small { font-size: 12.5px; }
hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
::selection { background: #d8e4ef; }

code, pre {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.92em;
}

/* Muted "kicker" label above titles — small caps, tracked. */
.kicker {
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Big statistics wear the serif with lining tabular figures. */
.stat, .big-number {
  font-family: var(--font-display);
  font-weight: 640;
  font-variant-numeric: lining-nums tabular-nums;
  letter-spacing: -0.015em;
  color: var(--fg);
}

/* ---- forms & buttons ---------------------------------------------------- */
button, input[type="submit"] {
  font: 500 13.5px/1.45 var(--font-ui);
  padding: 7px 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--fg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
button:hover, input[type="submit"]:hover { background: var(--surface-2); }
button.primary, input[type="submit"].primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
button.primary:hover, input[type="submit"].primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
button.danger { color: var(--danger); }
button.danger:hover { border-color: var(--danger); background: #faf1f1; }

label { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-top: 12px; }
input[type="text"], input[type="email"], input[type="date"], input[type="url"],
input[type="number"], select, textarea {
  width: 100%;
  font: 400 14px/1.5 var(--font-ui);
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--fg);
}
textarea { min-height: 80px; }
input:focus-visible, select:focus-visible, textarea:focus-visible,
button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1.5px;
}
form.inline { display: inline; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

/* ---- tables ------------------------------------------------------------- */
table { border-collapse: collapse; font-variant-numeric: lining-nums tabular-nums; }
th {
  font: 600 11px/1.4 var(--font-ui);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-strong);
}
td { padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 14px; }
tbody tr:hover { background: rgba(243, 240, 232, 0.55); }

/* ---- cards & shared components ------------------------------------------ */
.card, .activity {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.activity { margin-bottom: 10px; }
.activity.unconfirmed { border-left: 3px solid var(--warn); }
.activity.confirmed { border-left: 3px solid var(--good); opacity: 0.88; }
.activity .meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.activity .title a { color: var(--fg); text-decoration: none; font-weight: 550; }
.activity .title a:hover { text-decoration: underline; text-decoration-color: var(--faint); }
.activity .summary { font-size: 14px; color: var(--fg); opacity: 0.85; margin-top: 4px; }

.pill {
  display: inline-block;
  padding: 1.5px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  font-weight: 550;
  margin-right: 6px;
  white-space: nowrap;
}
.pill.low-conf { background: var(--warn-soft); border-color: #ecd9bf; color: #8a4a1d; }

.empty { color: var(--muted); text-align: center; padding: 48px 0; }

/* ---- site chrome: header ------------------------------------------------ */
.site-head {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 80;
  margin-bottom: 26px;
}
.head-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  min-height: 54px;
}
.head-inner nav { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--fg);
  padding: 10px 0;
}
.brand .mark { display: block; width: 22px; height: 22px; }
.brand .word {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 660;
  letter-spacing: -0.012em;
  line-height: 1;
}
.brand .word b { font-weight: 660; color: var(--accent); }

.head-inner nav > a, .nav-menu > summary {
  color: var(--muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  margin: 0;
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.head-inner nav > a:hover, .nav-menu > summary:hover { color: var(--fg); background: var(--surface-2); }
.head-inner nav > a.active, .nav-menu.active > summary { color: var(--accent); font-weight: 600; }
.nav-menu { position: relative; }
.nav-menu > summary::-webkit-details-marker { display: none; }
.nav-menu > summary::marker { content: ""; }
.nav-menu > summary .chev { font-size: 9px; opacity: 0.5; translate: 0 1px; }
.nav-menu[open] > summary { background: var(--surface-2); color: var(--fg); }
.nav-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 90;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  padding: 6px;
  min-width: 210px;
}
.nav-panel.right { left: auto; right: 0; }
.nav-panel a, .nav-panel button {
  display: block;
  width: 100%;
  text-align: left;
  color: var(--fg);
  margin: 0;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 450;
  padding: 7px 10px;
  border-radius: 6px;
  background: none;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}
.nav-panel a:hover, .nav-panel button:hover { background: var(--surface-2); color: var(--fg); }
.nav-panel .sep { height: 1px; background: var(--border); margin: 5px 4px; }
.nav-panel .grp {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--faint);
  padding: 8px 10px 2px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.nav-badge {
  display: inline-block;
  padding: 0 6px;
  margin-left: 4px;
  background: var(--brand-warm);
  color: #fff;
  border-radius: 9px;
  font-size: 10.5px;
  font-weight: 600;
  vertical-align: 1px;
}
.nav-spacer { flex: 1 1 auto; }
.head-link {
  align-self: center;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
}
.head-link:hover { color: var(--fg); }

/* ---- upgrade banner ------------------------------------------------------ */
.upgrade-banner {
  background: var(--warn-soft);
  border: 1px solid #ecd9bf;
  border-left: 3px solid var(--warn);
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--fg);
}
.upgrade-banner a { color: var(--accent); font-weight: 550; }

/* ---- footer -------------------------------------------------------------- */
.site-foot {
  border-top: 1px solid var(--border);
  margin-top: 56px;
  padding: 26px 28px 34px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
}
.site-foot .foot-brand {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 620;
  color: var(--fg);
  margin-bottom: 6px;
}
.site-foot a { color: var(--muted); text-decoration: none; margin: 0 8px; }
.site-foot a:hover { color: var(--fg); text-decoration: underline; }

/* ---- print / PDF export -------------------------------------------------- */
@media print {
  .site-head, .site-foot, .no-print { display: none !important; }
  .wrap { max-width: none !important; margin: 0 !important; padding: 0 !important; }
  a { text-decoration: none !important; color: inherit !important; }
  body { background: #fff; }
}

/* ---- small screens ------------------------------------------------------- */
@media (max-width: 720px) {
  .wrap { padding: 0 16px 16px; }
  .head-inner { padding: 0 16px; }
  .site-head { margin-bottom: 18px; }
  h1 { font-size: 25px; }
  .row { flex-direction: column; }
}
