/* ============================================================
   EYE OF SAURON / AUGURY — design system v0.2 ("Watchtower")
   Source of truth: mockups/specimen-v02.html.

   Sections:
     1.  Tokens
     2.  Base + body
     3.  Layout shell
     4.  App chrome (header, nav, breadcrumb)
     5.  Page heads
     6.  Cards
     7.  Stat tiles
     8.  Buttons
     9.  Inputs / fields
    10.  Badges
    11.  Pills (filter / window / mode tabs)
    12.  Delta + magnitude bar
    13.  Hero numbers + hero stats
    14.  Tables
    15.  Health pill
    16.  Links + code
    17.  Utilities + HTMX indicator
    18.  LEGACY compatibility (will be pruned as pages get redesigned)
   ============================================================ */

/* ── 1. Tokens ──────────────────────────────────────────────── */

:root {
  /* surfaces */
  --bg-0: #0a0d12;
  --bg-1: #11151c;
  --bg-2: #181d26;
  --bg-3: #1f2530;

  /* borders */
  --border-1: #232a36;
  --border-2: #2c3442;
  --border-3: #3a4354;

  /* text */
  --text-1: #e6e9ef;
  --text-2: #aeb6c4;
  --text-3: #7a8493;
  --text-4: #525c6c;

  /* accent — ember (activity / change) */
  --accent: #ff7a3d;
  --accent-bright: #ff8e57;
  --accent-dim: #c25827;
  --accent-bg: rgba(255, 122, 61, 0.08);
  --accent-border: rgba(255, 122, 61, 0.28);

  /* state */
  --ok: #6cd58c;
  --ok-bg: rgba(108, 213, 140, 0.10);
  --warn: #e8b86b;
  --warn-bg: rgba(232, 184, 107, 0.08);
  --bad: #e87b7b;
  --bad-bg: rgba(232, 123, 123, 0.08);
  --info: #7aa6ff;

  /* type */
  --font-sans: 'Inter Tight', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* sizing */
  --fs-xs: 0.75rem;
  --fs-sm: 0.85rem;
  --fs-base: 0.95rem;
  --fs-md: 1.05rem;
  --fs-lg: 1.35rem;
  --fs-xl: 1.85rem;
  --fs-xxl: 2.4rem;
  --fs-data: 2.2rem;

  /* spacing — 4px base */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;
  --sp-8: 3rem;

  /* radii */
  --r-1: 2px;
  --r-2: 4px;
  --r-3: 6px;

  /* legacy aliases — old templates reference these names */
  --bg: var(--bg-0);
  --panel: var(--bg-1);
  --border: var(--border-1);
  --text: var(--text-1);
  --muted: var(--text-3);
}

/* ── 2. Base + body ─────────────────────────────────────────── */

* { box-sizing: border-box; }
html { font-size: 16px; }

body {
  margin: 0;
  background: var(--bg-0);
  color: var(--text-1);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  background-image:
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.012) 0px,
      rgba(255, 255, 255, 0.012) 1px,
      transparent 1px,
      transparent 3px
    );
}

::selection { background: var(--accent-dim); color: #fff; }

h1, h2, h3, h4 {
  font-family: var(--font-sans);
  color: var(--text-1);
  margin: 0;
  letter-spacing: -0.015em;
}

/* ── 3. Layout shell ────────────────────────────────────────── */

.shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--sp-5);
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--sp-5);
}

/* ── 4. App chrome (header / nav / breadcrumb) ──────────────── */

.app-header {
  background: var(--bg-1);
  border-bottom: 1px solid var(--border-1);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.brand {
  font-weight: 600;
  font-size: var(--fs-md);
  color: var(--text-1);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
}
.brand:hover { text-decoration: none; color: var(--text-1); }
.brand__mark { color: var(--accent); font-size: 1.1em; line-height: 1; }

.nav { display: flex; gap: 0.25rem; }
.nav a {
  color: var(--text-2);
  padding: 0.35rem 0.7rem;
  border-radius: var(--r-2);
  font-size: var(--fs-sm);
  font-weight: 500;
  text-decoration: none;
}
.nav a:hover { background: var(--bg-2); text-decoration: none; color: var(--text-1); }
.nav a.is-active { color: var(--text-1); background: var(--bg-2); }

.header__right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.breadcrumb {
  background: var(--bg-0);
  border-bottom: 1px solid var(--border-1);
  padding: 0.55rem 1.5rem;
  font-size: var(--fs-sm);
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.breadcrumb__sep { color: var(--text-4); }
.breadcrumb__current { color: var(--text-1); font-weight: 500; }
.breadcrumb a { color: var(--text-3); text-decoration: none; }
.breadcrumb a:hover { color: var(--text-1); text-decoration: none; }

/* tagline shown in augury where the auth indicator + health pill live on sauron */
.tagline {
  margin-left: auto;
  font-size: var(--fs-xs);
  color: var(--text-3);
}

/* ── 5. Page heads ──────────────────────────────────────────── */

.page-head { margin-bottom: var(--sp-5); }
.page-head__title {
  font-size: var(--fs-xxl);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.025em;
}
.page-head__sub {
  font-size: var(--fs-sm);
  color: var(--text-3);
  margin-top: 0.3rem;
  max-width: 60ch;
}

/* ── 6. Cards ───────────────────────────────────────────────── */

.card {
  background: var(--bg-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  padding: var(--sp-5);
  margin-bottom: var(--sp-5);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--border-1);
  gap: var(--sp-3);
  flex-wrap: wrap;
}
.card-title {
  font-size: var(--fs-md);
  font-weight: 600;
  margin: 0;
}

/* ── 6.5 Identity strip + sticky toolbar (empire page) ──────── */

.identity { margin-bottom: var(--sp-5); }
.identity__name {
  font-size: var(--fs-xxl);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.025em;
  margin: 0;
}
.identity__sub {
  font-size: var(--fs-sm);
  color: var(--text-3);
  margin-top: 0.3rem;
}

.tile-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--sp-3);
  margin-top: var(--sp-4);
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg-0);
  border-bottom: 1px solid var(--border-1);
  padding: var(--sp-3) 0;
  margin: 0 calc(-1 * var(--sp-5)) var(--sp-4);
  padding-left: var(--sp-5);
  padding-right: var(--sp-5);
}
.toolbar__inner {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  align-items: flex-end;
}
.toolbar .field { min-width: 9rem; }
.toolbar__hint {
  font-size: var(--fs-xs);
  color: var(--text-4);
  margin-left: auto;
}

/* ── 7. Stat tiles (empire identity strip) ──────────────────── */

.tile {
  background: var(--bg-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  padding: var(--sp-3) var(--sp-4);
  min-width: 0;
}
.tile__label {
  font-size: var(--fs-xs);
  color: var(--text-3);
  margin-bottom: var(--sp-1);
  font-weight: 500;
}
.tile__value {
  font-family: var(--font-mono);
  font-size: var(--fs-lg);
  font-weight: 500;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.tile__value--text {
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  font-weight: 600;
}
.tile__sub {
  font-size: var(--fs-xs);
  color: var(--text-3);
  margin-top: var(--sp-1);
}

/* ── 8. Buttons ─────────────────────────────────────────────── */

.btn {
  background: var(--bg-2);
  color: var(--text-1);
  border: 1px solid var(--border-2);
  border-radius: var(--r-2);
  padding: 0.45rem 0.9rem;
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
  text-decoration: none;
  display: inline-block;
  line-height: 1.4;
}
.btn:hover {
  border-color: var(--accent-border);
  background: var(--bg-3);
  text-decoration: none;
}
.btn--primary {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--accent-bright);
}
.btn--primary:hover {
  background: var(--accent);
  color: #0a0d12;
  border-color: var(--accent);
}
.btn--ghost {
  background: transparent;
  border-color: var(--border-1);
  color: var(--text-2);
}
.btn--sm {
  padding: 0.25rem 0.6rem;
  font-size: var(--fs-xs);
}
.btn--lg {
  padding: 0.65rem 1.1rem;
  font-size: var(--fs-md);
}

/* ── 9. Inputs / fields ─────────────────────────────────────── */

.input, .select {
  background: var(--bg-3);
  color: var(--text-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  padding: 0.45rem 0.7rem;
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  width: 100%;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input--mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.input:focus, .select:focus {
  outline: none;
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}
.field__label {
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-weight: 500;
}
.field__hint {
  font-size: var(--fs-xs);
  color: var(--text-4);
}

/* ── 10. Badges ─────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.55rem;
  border-radius: var(--r-1);
  font-size: var(--fs-xs);
  font-weight: 500;
  background: var(--bg-2);
  color: var(--text-2);
  border: 1px solid var(--border-1);
}
.badge--accent {
  background: var(--accent-bg);
  color: var(--accent-bright);
  border-color: var(--accent-border);
}
.badge--ok {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: rgba(108, 213, 140, 0.25);
}
.badge--warn {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: rgba(232, 184, 107, 0.25);
}
.badge--bad {
  background: var(--bad-bg);
  color: var(--bad);
  border-color: rgba(232, 123, 123, 0.25);
}
.badge__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ── 11. Pills ──────────────────────────────────────────────── */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 500;
  background: var(--bg-2);
  color: var(--text-2);
  border: 1px solid var(--border-1);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.pill:hover { border-color: var(--border-2); color: var(--text-1); }
.pill.is-active {
  background: var(--accent-bg);
  color: var(--accent-bright);
  border-color: var(--accent-border);
}
.pill__count {
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--text-3);
}
.pill.is-active .pill__count { color: var(--accent); }

.mode-tabs {
  display: inline-flex;
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  padding: 2px;
  gap: 2px;
}
.mode-tab {
  padding: 0.3rem 0.8rem;
  border-radius: var(--r-1);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  border: 0;
  background: transparent;
  text-decoration: none;
}
.mode-tab:hover { color: var(--text-1); text-decoration: none; }
.mode-tab.is-active {
  background: var(--accent-bg);
  color: var(--accent-bright);
}

.window-pills { display: inline-flex; gap: 0.3rem; }
.window-pill {
  padding: 0.2rem 0.55rem;
  border-radius: var(--r-1);
  font-size: var(--fs-xs);
  color: var(--text-3);
  text-decoration: none;
  border: 1px solid transparent;
}
.window-pill:hover { color: var(--text-1); text-decoration: none; }
.window-pill.is-active {
  background: var(--accent-bg);
  color: var(--accent-bright);
  border-color: var(--accent-border);
}

/* ── 12. Delta + magnitude bar ──────────────────────────────── */

.delta {
  display: inline-flex;
  align-items: baseline;
  gap: 0.2rem;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.delta--up { color: var(--accent-bright); }
.delta--down { color: var(--bad); }
.delta__sign {
  font-size: 0.75em;
  opacity: 0.75;
}

.magnitude {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  max-width: 12rem;
}
.magnitude__bar {
  flex: 1;
  height: 4px;
  background: var(--bg-3);
  border-radius: 2px;
  overflow: hidden;
}
.magnitude__fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
}
.magnitude__num {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-3);
}

/* ── 13. Hero numbers + hero stats ──────────────────────────── */

.hero-num {
  font-family: var(--font-mono);
  font-size: var(--fs-data);
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text-1);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.hero-num.is-positive { color: var(--accent-bright); }
.hero-num.is-negative { color: var(--bad); }

.hero-stat {
  background: var(--bg-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  padding: var(--sp-4);
}
.hero-stat--featured {
  border-top: 2px solid var(--info);
}
.hero-stat__label {
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-weight: 500;
  margin-bottom: var(--sp-2);
}
.hero-stat__value {
  font-family: var(--font-mono);
  font-size: var(--fs-data);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1;
}
.hero-stat--featured .hero-stat__value { color: var(--info); }

/* ── 13.5 Activity log (empire page) ────────────────────────── */

.filter-pills {
  display: inline-flex;
  gap: 0.4rem;
}
.filter-pills .pill {
  background: transparent;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  margin-top: var(--sp-4);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-1);
}
.pagination__pos {
  font-size: var(--fs-xs);
}
.btn.is-disabled {
  pointer-events: none;
  opacity: 0.4;
}

.activity-scroll {
  max-height: 60vh;
  overflow-y: auto;
  margin: 0 calc(-1 * var(--sp-5));
  padding: 0 var(--sp-5);
}
.activity-scroll .activity-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-1);
  box-shadow: 0 1px 0 var(--border-1);
  z-index: 1;
}

.activity-row.is-hidden { display: none; }

.activity-row.is-pinned td {
  background: rgba(108, 213, 140, 0.04);
  border-left: 2px solid var(--ok);
}
.activity-row.is-pinned td:first-child {
  padding-left: calc(var(--sp-3) - 2px);
}

.activity-row.is-highlighted td {
  animation: highlight-fade 2s ease-out;
}
@keyframes highlight-fade {
  0% { background: var(--accent); color: #0a0d12; }
  100% { background: transparent; }
}

.expanded-row td {
  padding: 0;
  border: 0;
}
.expanded-row.is-hidden { display: none; }
.expanded-content {
  padding: 0 var(--sp-3) var(--sp-3) calc(var(--sp-3) + 4px);
  border-left: 2px solid var(--accent-border);
  margin-left: var(--sp-3);
}
.expanded-content:empty { display: none; }

.solutions-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.solutions-close {
  font-size: 1.2rem;
  line-height: 1;
  padding: 0 0.4rem;
  color: var(--text-3);
  text-decoration: none;
}
.solutions-close:hover { color: var(--text-1); }

.chart-wrap {
  position: relative;
  height: 240px;
}

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.3rem;
  vertical-align: 1px;
}

/* pinned summary pill in row solver column */
.pinned-summary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: var(--fs-xs);
}
.pinned-summary__combo {
  color: var(--text-2);
  font-size: var(--fs-xs);
}

/* ── 14. Tables ─────────────────────────────────────────────── */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
.table th {
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-3);
  text-align: left;
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--border-1);
}
.table td {
  padding: var(--sp-3);
  border-bottom: 1px solid var(--border-1);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--bg-2); }
.table .num,
.table th.num,
.table td.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.table .timestamp {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-3);
  white-space: nowrap;
}

/* ── 15. Health pill ────────────────────────────────────────── */

.health {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 500;
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.health__time {
  font-family: var(--font-mono);
  color: var(--text-3);
  margin-left: 0.2rem;
}
.health__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-3);
}
.health--ok { color: var(--ok); border-color: rgba(108, 213, 140, 0.25); }
.health--ok .health__dot { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.health--stale { color: var(--warn); border-color: rgba(232, 184, 107, 0.25); }
.health--stale .health__dot { background: var(--warn); }
.health--broken { color: var(--bad); border-color: rgba(232, 123, 123, 0.25); }
.health--broken .health__dot { background: var(--bad); }

/* auth indicator slot in header__right */
.auth-indicator {
  font-size: var(--fs-xs);
  color: var(--text-3);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.auth-indicator a { color: var(--text-2); text-decoration: none; }
.auth-indicator a:hover { color: var(--text-1); text-decoration: underline; }
.auth-indicator__user {
  color: var(--text-1);
  font-family: var(--font-mono);
  font-size: 0.9em;
}
.link-button {
  background: none;
  border: 0;
  color: var(--text-2);
  padding: 0;
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
}
.link-button:hover { color: var(--text-1); }

/* ── 16. Links + code ───────────────────────────────────────── */

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

code, .kbd {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--bg-3);
  padding: 0.1rem 0.35rem;
  border-radius: var(--r-1);
  border: 1px solid var(--border-1);
  color: var(--text-2);
}

/* ── 15.5 Counter page (hero / stat groups / alts) ─────────── */

.paste-area {
  width: 100%;
  background: var(--bg-3);
  color: var(--text-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  padding: var(--sp-3);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  line-height: 1.5;
  resize: vertical;
  min-height: 9rem;
}
.paste-area:focus {
  outline: none;
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--sp-3);
  margin: var(--sp-4) 0;
}
.checkbox-field {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding-top: 1rem;
}
.checkbox-field input { margin: 0; accent-color: var(--accent); }
.checkbox-field label {
  font-size: var(--fs-sm);
  color: var(--text-2);
  cursor: pointer;
}
.checkbox-field small {
  display: block;
  font-size: var(--fs-xs);
  color: var(--text-4);
}

/* posture badge variants */
.badge--posture-aggressive { color: #ffb3b3; background: rgba(232,123,123,0.10); border-color: rgba(232,123,123,0.25); }
.badge--posture-normal { color: #b3d9ff; background: rgba(122,166,255,0.10); border-color: rgba(122,166,255,0.25); }
.badge--posture-careful { color: #b3ffd9; background: rgba(108,213,140,0.10); border-color: rgba(108,213,140,0.25); }

/* role tags — used in fleet-list ship listings */
.role-tag {
  display: inline-block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  padding: 0 0.35rem;
  border-radius: var(--r-1);
  margin-right: 0.4rem;
  vertical-align: 1px;
  line-height: 1.5;
}
.role-tag--absorber { color: #d99564; background: rgba(217,149,100,0.12); }
.role-tag--flanker { color: var(--info); background: rgba(122,166,255,0.12); }
.role-tag--spam { color: #d97aae; background: rgba(217,122,174,0.12); }
.role-tag--dummy { color: var(--text-4); opacity: 0.7; }

/* fleet picker (multiple-fleet-detected state) */
.fleet-picker {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}
.fleet-picker__option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  padding: 0.65rem 0.9rem;
  cursor: pointer;
  text-align: left;
  color: var(--text-1);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  transition: border-color 0.12s, background 0.12s;
}
.fleet-picker__option:hover {
  border-color: var(--accent-border);
  background: var(--bg-3);
}
.fleet-picker__owner { font-weight: 600; }
.fleet-picker__meta {
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
}

/* hero card — defender + counter side by side */
.hero {
  background: var(--bg-1);
  border: 1px solid var(--border-1);
  border-top: 2px solid var(--accent);
  border-radius: var(--r-3);
  overflow: hidden;
  margin-bottom: var(--sp-5);
}
.hero__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-1);
  flex-wrap: wrap;
  gap: var(--sp-3);
}
.hero__title {
  font-size: var(--fs-md);
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.hero__meta {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  flex-wrap: wrap;
}
.hero__body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
.hero__col {
  padding: var(--sp-5);
  min-width: 0;
}
.hero__col + .hero__col { border-left: 1px solid var(--border-1); }
.hero__col-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--sp-3);
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.hero__col-label {
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.hero__col-name {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-1);
  margin-top: 0.15rem;
}
.hero__col-stat {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-sm);
  color: var(--text-3);
  text-align: right;
}
.hero__col-stat strong {
  color: var(--text-1);
  font-weight: 500;
}

/* fleet-list — used inside hero column AND alt-card body */
.fleet-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: var(--fs-sm);
}
.fleet-list__row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.4rem 0;
  border-bottom: 1px dashed var(--border-1);
}
.fleet-list__row:last-child { border-bottom: none; }
.fleet-list__count {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-1);
  font-weight: 500;
  min-width: 4ch;
  text-align: right;
}
.fleet-list__name { color: var(--text-2); }
.fleet-list__meta {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-3);
  text-align: right;
  white-space: nowrap;
}
.fleet-list__dummy {
  padding: 0.4rem 0;
  color: var(--text-4);
  font-style: italic;
  font-size: var(--fs-xs);
}

/* stat groups — outcome (wide) | cost | damage dealt */
.stat-groups {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 0;
  border-top: 1px solid var(--border-1);
  background: var(--bg-0);
}
.stat-group {
  padding: var(--sp-4) var(--sp-5);
  min-width: 0;
}
.stat-group + .stat-group { border-left: 1px solid var(--border-1); }
.stat-group__label {
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--sp-3);
}
.stat-group__rows {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--sp-3);
  font-size: var(--fs-sm);
}
.stat-row__label { color: var(--text-3); }
.stat-row__value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-1);
  font-weight: 500;
}
.stat-row__pct {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-4);
  margin-left: 0.3rem;
}
.stat-row--featured .stat-row__value { font-size: var(--fs-md); }
.stat-row--pos .stat-row__value { color: var(--ok); }
.stat-row--neg .stat-row__value { color: var(--bad); }

/* battle log — collapsed details with custom chevron */
.battle-log {
  border-top: 1px solid var(--border-1);
  background: var(--bg-0);
}
.battle-log summary {
  cursor: pointer;
  color: var(--text-3);
  font-size: var(--fs-xs);
  padding: var(--sp-3) var(--sp-5);
  list-style: none;
  user-select: none;
  transition: color 0.1s;
}
.battle-log summary::-webkit-details-marker { display: none; }
.battle-log summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 0.5rem;
  font-size: 0.7em;
  transition: transform 0.15s;
}
.battle-log[open] summary::before { transform: rotate(90deg); }
.battle-log summary:hover { color: var(--text-1); }
.battle-log pre {
  margin: 0;
  padding: var(--sp-4) var(--sp-5);
  background: var(--bg-0);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: 1.5;
  overflow-x: auto;
  border-top: 1px solid var(--border-1);
  white-space: pre-wrap;
}

/* alternatives section */
.alts-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: var(--sp-6) 0 var(--sp-3);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border-1);
}
.alts-head__title {
  font-size: var(--fs-md);
  font-weight: 600;
}
.alts-head__sub {
  font-size: var(--fs-xs);
  color: var(--text-3);
}
.alts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}
.alt-card {
  background: var(--bg-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.alt-card__head {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.alt-card__axis {
  font-size: var(--fs-xs);
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}
.alt-card__body { padding: var(--sp-4); flex: 1; }
.alt-card__stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem 1rem;
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border-1);
  background: var(--bg-0);
  font-size: var(--fs-xs);
}

@media (max-width: 900px) {
  .hero__body { grid-template-columns: 1fr; }
  .hero__col + .hero__col {
    border-left: none;
    border-top: 1px solid var(--border-1);
  }
  .stat-groups { grid-template-columns: 1fr; }
  .stat-group + .stat-group {
    border-left: none;
    border-top: 1px solid var(--border-1);
  }
}

/* ── 16.5 Form layout helpers ───────────────────────────────── */

.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.form-submit {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

/* ── 17. Utilities + HTMX indicator ─────────────────────────── */

.row { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.muted { color: var(--text-3); }
.data-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline; }

/* small viewport tightening of header */
@media (max-width: 700px) {
  .nav a { padding: 0.3rem 0.5rem; font-size: var(--fs-xs); }
  .breadcrumb { padding: 0.5rem var(--sp-3); font-size: var(--fs-xs); }
  .app-header { padding: 0.6rem var(--sp-3); gap: var(--sp-3); }
}

/* ============================================================
   18. LEGACY COMPATIBILITY
   These selectors are referenced by templates that haven't been
   redesigned yet. As each page gets its PR-2/PR-3 rebuild, the
   matching legacy selector should be removed from this section.
   ============================================================ */

/* old header was a bare <header>; new templates use .app-header.
   Bare-tag fallback so any template not yet on .app-header still
   gets reasonable chrome — once base.html is in place, this is
   only triggered if a template overrides {% block header %}. */

/* bare <h2> used as card title in not-yet-redesigned templates. Once
   each page is rebuilt with .card-title / .page-head__title, this can
   go away. */
h2 {
  font-size: var(--fs-md);
  font-weight: 600;
  margin: 0 0 var(--sp-3) 0;
}

/* raw <table> in old templates */
table { width: 100%; border-collapse: collapse; }
table th, table td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border-1);
  text-align: left;
}
table th {
  font-weight: 600;
  color: var(--text-3);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
table tr:hover td { background: var(--bg-2); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* old form controls */
input, select, button, textarea {
  background: var(--bg-3);
  border: 1px solid var(--border-1);
  color: var(--text-1);
  padding: 0.4rem 0.6rem;
  border-radius: var(--r-2);
  font: inherit;
}
button {
  background: var(--bg-2);
  cursor: pointer;
}
button:hover { border-color: var(--accent-border); background: var(--bg-3); }

/* old .grid form layout */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.grid label { display: flex; flex-direction: column; gap: 0.25rem; font-size: var(--fs-xs); color: var(--text-3); }
.grid input, .grid select { color: var(--text-1); }

/* old combo / solutions-list — used by _solutions.html */
.combo {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  background: var(--bg-2);
  border-radius: var(--r-1);
  margin: 0.1rem;
  font-size: var(--fs-sm);
  font-family: var(--font-mono);
}
.combo--meme { opacity: 0.65; font-style: italic; }

/* solutions scroll container */
.solutions-scroll {
  max-height: 24rem;
  overflow-y: auto;
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  margin: 0.25rem 0 0.5rem;
}
.solutions-scroll table { margin: 0; }
.solutions-scroll thead th {
  position: sticky;
  top: 0;
  background: var(--bg-1);
  z-index: 1;
  box-shadow: 0 1px 0 var(--border-1);
}

/* online activity heatmap (legacy markup; PR 3 will rebuild) */
.heatmap { display: flex; flex-direction: column; gap: 2px; margin: 0.75rem 0; }
.hm-row { display: grid; grid-template-columns: 3rem repeat(24, minmax(20px, 1fr)); gap: 2px; }
.heatmap--daily .hm-row { grid-template-columns: 5rem repeat(24, minmax(16px, 1fr)); }
.hm-row.hm-header .hm-hour {
  font-size: var(--fs-xs); color: var(--text-3); text-align: center; line-height: 1;
}
.hm-day { font-size: var(--fs-xs); color: var(--text-3); display: flex; align-items: center; }
.hm-cell {
  aspect-ratio: 1;
  background-color: rgba(122, 166, 255, 0);
  border: 1px solid var(--border-1);
  border-radius: var(--r-1);
  cursor: default;
}
.heatmap--daily .hm-cell { aspect-ratio: auto; height: 1rem; }
.hm-legend { display: flex; align-items: center; gap: 0.5rem; font-size: var(--fs-xs); }
.hm-gradient {
  display: inline-block; width: 8rem; height: 0.6rem;
  background: linear-gradient(to right, rgba(122, 166, 255, 0), rgba(122, 166, 255, 1));
  border: 1px solid var(--border-1); border-radius: var(--r-1);
}
.hm-modes { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin: 0.5rem 0; }
.hm-modes a { padding: 0.2rem 0.5rem; border-radius: var(--r-2); text-decoration: none; }
.hm-modes a.active { background: var(--accent-bg); color: var(--accent-bright); }
.hm-modes a:hover { background: var(--accent-bg); }

small { font-size: var(--fs-xs); }

.strategy-explainer { margin: 0.5rem 0 1rem; }
.strategy-explainer summary { cursor: pointer; color: var(--text-3); }
.strategy-explainer p { margin: 0.5rem 0; font-size: var(--fs-sm); }
