:root {
  --bg:         #EEF2F7;
  --surface:    #FFFFFF;
  --border:     #DDE3EE;
  --navy:       #0A1628;
  --navy-mid:   #1E3A5F;
  --blue:       #0057B8;
  --blue-light: #E8F0FD;
  --text:       #111827;
  --muted:      #6B7280;
  --green:      #16A34A;
  --green-bg:   #DCFCE7;
  --red:        #DC2626;
  --red-bg:     #FEE2E2;
  --amber:      #B45309;
  --amber-bg:   #FEF3C7;
  --radius:     8px;
  --shadow:     0 1px 4px rgba(0,0,0,.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* ── Accessibility ────────────────────────────────────── */
.skip-link {
  position: fixed;
  top: -48px;
  left: 8px;
  z-index: 1000;
  background: var(--blue);
  color: #fff;
  padding: 10px 16px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  transition: top .15s ease;
}
.skip-link:focus {
  top: 8px;
  outline: 3px solid #fff;
  outline-offset: 2px;
}

/* ── Header ─────────────────────────────────────────── */
header {
  background: var(--navy);
  color: #fff;
  padding: 0 24px;
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0;
}
.logo { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; color: #fff; text-decoration: none; }
.logo span { color: #60A5FA; }
.header-meta { font-size: 13px; color: #94A3B8; }
.header-meta strong { color: #CBD5E1; }

/* ── Main container ──────────────────────────────────── */
main { max-width: 1400px; margin: 0 auto; padding: 24px 24px 48px; }

/* ── Intro strip ─────────────────────────────────────── */
.intro {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 28px;
  display: flex;
  align-items: flex-start;
  gap: 20px;
}
.intro-icon { flex-shrink: 0; line-height: 0; }
.intro h1 { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.intro p  { color: var(--muted); font-size: 13px; max-width: 680px; }

/* ── Section headings ────────────────────────────────── */
.section-heading {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
}

/* ── Top Picks grid ──────────────────────────────────── */
.top-picks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 32px;
}
.pick-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  overflow: hidden;
  transition: box-shadow .15s, transform .15s;
}
.pick-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.12); transform: translateY(-2px); }
.pick-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.pick-card-top > div:first-child { min-width: 0; }
.pick-ticker   { font-size: 20px; font-weight: 800; color: var(--navy-mid); }
.pick-name     { font-size: 11px; color: var(--muted); margin-top: 3px; line-height: 1.35;
                 overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-category { font-size: 11px; color: var(--blue); background: var(--blue-light);
                 padding: 2px 7px; border-radius: 20px; margin-top: 10px; display: inline-block;
                 max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-stats    { margin-top: 12px; display: flex; gap: 12px; flex-wrap: wrap; }
.pick-stat label { display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.pick-stat span  { font-size: 15px; font-weight: 700; }

/* ── Grade badge ─────────────────────────────────────── */
.grade {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 800;
  flex-shrink: 0;
}
.grade-Ap  { background: #DCFCE7; color: #15803D; }
.grade-A   { background: #D1FAE5; color: #059669; }
.grade-Bp  { background: #ECFDF5; color: #10B981; }
.grade-B   { background: #FEF9C3; color: #CA8A04; }
.grade-C   { background: #FEF3C7; color: #B45309; }
.grade-D   { background: #FEE2E2; color: #DC2626; }
.grade-F   { background: #FEE2E2; color: #991B1B; }

/* ── Controls ────────────────────────────────────────── */
.controls {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}
.controls select,
.controls input {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 11px;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color .15s;
}
.controls select:focus,
.controls input:focus { border-color: var(--blue); }
.controls input { min-width: 200px; }
.controls label { font-size: 13px; color: var(--muted); }
.controls-spacer { flex: 1; }
.result-count { font-size: 13px; color: var(--muted); }

/* ── View mode toggle ────────────────────────────────── */
.view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.view-toggle button {
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.view-toggle button.active {
  background: var(--navy);
  color: #fff;
}
.mode-beginner .col-expert { display: none; }

/* ── Table ───────────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 280px);
  margin-bottom: 32px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  background: var(--navy);
  color: #CBD5E1;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 12px 14px;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  position: sticky;
  top: 0;
  z-index: 2;
}
thead th:hover { background: var(--navy-mid); color: #fff; }
thead th:focus-within { background: var(--navy-mid); color: #fff; }
thead th .sort-icon { opacity: .4; margin-left: 4px; }
thead th.sorted .sort-icon { opacity: 1; }

tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #F8FAFF; }
tbody td { padding: 11px 14px; vertical-align: middle; white-space: nowrap; }

.td-rank    { color: var(--muted); font-size: 12px; font-weight: 600;
              padding-left: 10px; padding-right: 2px; }
.td-grade   { padding-left: 2px; padding-right: 2px; }
.td-ticker  { font-weight: 800; font-size: 14px; color: var(--navy-mid);
              padding-left: 2px; padding-right: 10px; }
.td-ticker a { color: inherit; text-decoration: none; }
.td-ticker a:hover { color: var(--blue); text-decoration: underline; }
.td-name    { max-width: 160px; white-space: nowrap; overflow: hidden;
              text-overflow: ellipsis; color: var(--muted); font-size: 12px;
              padding-left: 2px; }
.td-cat     { font-size: 11px; color: var(--blue); background: var(--blue-light);
              padding: 2px 8px; border-radius: 20px; display: inline-block; }
.td-income  { font-size: 11px; color: var(--green); background: var(--green-bg);
              padding: 2px 8px; border-radius: 20px; display: inline-block; margin-left: 4px; }

/* ── Site-wide search palette ────────────────────────────────────────── */
.sp-trigger {
  display: inline-flex; align-items: center; gap: 8px; margin-left: auto;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18);
  color: #CBD5E1; border-radius: 999px; padding: 7px 12px; cursor: pointer;
  font: inherit; font-size: 13px; line-height: 1;
}
.sp-trigger:hover { background: rgba(255,255,255,.16); color: #fff; }
.sp-trigger:focus-visible { outline: 2px solid #60A5FA; outline-offset: 2px; }
.sp-trigger-icon { font-size: 15px; }
.sp-kbd, .sp-foot kbd {
  font: inherit; font-size: 11px; border: 1px solid rgba(255,255,255,.25);
  border-radius: 4px; padding: 1px 5px; color: inherit;
}
@media (max-width: 720px) { .sp-trigger-text, .sp-kbd { display: none; } }

.sp-overlay {
  position: fixed; inset: 0; z-index: 200; background: rgba(10,22,40,.45);
  display: flex; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px;
}
.sp-overlay[hidden] { display: none; }
.sp-panel {
  width: 100%; max-width: 560px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
  box-shadow: 0 18px 48px rgba(10,22,40,.28);
}
.sp-input {
  width: 100%; border: 0; border-bottom: 1px solid var(--border);
  padding: 16px 18px; font: inherit; font-size: 16px; color: var(--text);
  background: transparent; box-sizing: border-box;
}
.sp-input:focus { outline: none; }
.sp-list { list-style: none; margin: 0; padding: 6px; max-height: 46vh; overflow-y: auto; }
.sp-item {
  display: flex; align-items: baseline; gap: 10px; padding: 9px 12px;
  border-radius: 8px; cursor: pointer;
}
.sp-item.active { background: var(--blue-light); }
.sp-kind {
  flex: 0 0 auto; font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; padding: 2px 7px; border-radius: 20px;
}
.sp-kind-e { background: var(--blue-light); color: var(--blue); }
.sp-kind-h { background: var(--green-bg); color: var(--green); }
.sp-kind-c { background: var(--amber-bg); color: var(--amber); }
.sp-item.active .sp-kind-e { background: #fff; }
.sp-label { font-weight: 700; color: var(--navy); font-size: 14px; }
.sp-sub {
  color: var(--muted); font-size: 12px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.sp-empty { padding: 18px 14px; color: var(--muted); font-size: 13px; }
.sp-foot {
  display: flex; gap: 14px; padding: 9px 14px; border-top: 1px solid var(--border);
  font-size: 11px; color: var(--muted);
}
.sp-foot kbd { border-color: var(--border); }
/* Visually hidden, but announced: screen readers get the result count without
   it appearing twice on screen. */
.sp-status {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* The mobile sort control has no purpose on desktop, where the column headers
   are themselves the sort buttons. This base rule must precede the 720px block
   below: both selectors have the same specificity, so whichever is declared
   last wins, and putting display:none after the media query would hide the
   control at every width. */
.mobile-sort { display: none; align-items: center; gap: 8px; margin-bottom: 10px; }
.mobile-sort label { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.mobile-sort select {
  flex: 1; padding: 9px 10px; font: inherit; font-size: 14px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
}

/* ── Mobile: the ranking table becomes a stack of cards ──────
   A 17-column table on a phone means horizontal scrolling, which hides the
   columns that matter behind a gesture most people never make. Below 720px the
   same DOM is re-laid-out as cards: each row is a card, each cell becomes a
   labelled line via the data-label attribute set in rank_row_html/renderTable.

   Re-laying out rather than rendering a second markup path means there is only
   ever one source of truth for a row - the card and the table cannot drift, and
   sorting, filtering and the watchlist keep working untouched. */
@media (max-width: 720px) {
  .table-wrap {
    overflow-x: visible;
    overflow-y: visible;
    max-height: none;
    background: transparent;
    border: 0;
    border-radius: 0;
  }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td {
    display: block;
    width: auto;
  }
  /* The header row drives sorting on desktop; on mobile the sort control is the
     dedicated select below, so the visually-redundant header is removed from
     the accessibility tree too rather than just hidden. */
  .table-wrap thead { display: none; }

  .table-wrap tbody tr {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px 10px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
  }
  .table-wrap tbody tr:hover { background: var(--surface); }

  .table-wrap tbody td {
    padding: 4px 0;
    white-space: normal;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    font-size: 13px;
    border: 0;
  }
  .table-wrap tbody td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    flex: 0 0 auto;
  }

  /* Card header: rank, grade, ticker and name are the identity of the card, so
     they lose their labels and sit at the top rather than reading as
     "RANK  #1 / GRADE  A" like the metric rows below them. */
  .table-wrap tbody td.td-rank,
  .table-wrap tbody td.td-grade,
  .table-wrap tbody td.td-ticker,
  .table-wrap tbody td.td-name { display: block; padding: 0; }
  .table-wrap tbody td.td-rank::before,
  .table-wrap tbody td.td-grade::before,
  .table-wrap tbody td.td-ticker::before,
  .table-wrap tbody td.td-name::before { content: none; }

  .table-wrap tbody td.td-rank {
    position: absolute; top: 12px; right: 14px;
    font-size: 12px; color: var(--muted);
  }
  .table-wrap tbody td.td-grade {
    position: absolute; top: 30px; right: 14px;
  }
  .table-wrap tbody td.td-ticker {
    font-size: 17px; padding-right: 62px;
  }
  /* Also the separator between the card header and its metric rows. */
  .table-wrap tbody td.td-name {
    max-width: none; white-space: normal; overflow: visible;
    font-size: 12px; line-height: 1.35;
    padding-right: 62px; margin-bottom: 8px;
    border-bottom: 1px solid var(--border); padding-bottom: 9px;
  }

  .mobile-sort { display: flex; }
}

/* ── Watchlist: star toggles, toast, and the /watchlist page ── */
.wl-star { background: none; border: 0; cursor: pointer; padding: 0 5px 0 0; margin: 0;
           font-size: 15px; line-height: 1; color: #C7CEDB; vertical-align: baseline;
           transition: color .12s, transform .12s; }
.wl-star:hover { color: #F0B429; transform: scale(1.18); }
.wl-star.is-on { color: #F0B429; }
.wl-star:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 3px; }
.wl-btn { display: inline-flex; align-items: center; gap: 7px; background: var(--surface);
          border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 14px;
          font: inherit; font-size: 13px; font-weight: 700; color: var(--navy-mid);
          cursor: pointer; box-shadow: var(--shadow); }
.wl-btn:hover { border-color: #F0B429; color: var(--navy); }
.wl-btn.is-on { background: #FEF7E6; border-color: #F0B429; color: #8A6100; }
.wl-toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 14px);
            background: var(--navy); color: #fff; font-size: 13.5px; padding: 11px 18px;
            border-radius: var(--radius); box-shadow: 0 6px 22px rgba(0,0,0,.22);
            opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
            z-index: 9999; max-width: 92vw; }
.wl-toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.wl-toast a { color: #93C5FD; }
.nav-count { display: inline-block; background: #F0B429; color: #3A2A00; font-size: 10px;
             font-weight: 800; border-radius: 10px; padding: 1px 6px; margin-left: 5px;
             vertical-align: middle; }
/* Pages that don't load watchlist.js leave the badge empty — hide it there. */
.nav-count:empty { display: none; }
.wl-summary { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 18px; }
@media (max-width: 900px) { .wl-summary { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .wl-summary { grid-template-columns: 1fr; } }
.wl-empty { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
            padding: 40px 26px; text-align: center; color: var(--muted); }
.wl-empty h3 { font-size: 17px; color: var(--navy); margin-bottom: 8px; }
.wl-empty p { font-size: 13.5px; max-width: 560px; margin: 0 auto 16px; line-height: 1.7; }
.wl-input { width: 82px; font: inherit; font-size: 12.5px; padding: 4px 6px; text-align: right;
            border: 1px solid var(--border); border-radius: 5px; background: var(--surface);
            color: var(--text); }
.wl-input:focus { border-color: var(--blue); outline: none; }
.wl-remove { background: none; border: 0; cursor: pointer; color: var(--muted);
             font-size: 15px; line-height: 1; padding: 2px 5px; border-radius: 4px; }
.wl-remove:hover { color: var(--red); background: var(--red-bg); }
.wl-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 16px 0 8px; }
.wl-actions button { font: inherit; font-size: 12.5px; font-weight: 600; padding: 6px 12px;
                     border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
                     color: var(--navy-mid); cursor: pointer; }
.wl-actions button:hover { border-color: var(--blue); color: var(--blue); }
.wl-note { font-size: 11.5px; color: var(--muted); margin-top: 10px; line-height: 1.65; }

.pos  { color: var(--green); font-weight: 600; }
.neg  { color: var(--red);   font-weight: 600; }
.zero { color: var(--muted); }

.risk-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.risk-VeryLow  { background:#DCFCE7; color:#15803D; }
.risk-Low      { background:#D1FAE5; color:#059669; }
.risk-Moderate { background:#FEF9C3; color:#CA8A04; }
.risk-High     { background:#FEE2E2; color:#DC2626; }
.risk-VeryHigh { background:#FEE2E2; color:#991B1B; }
.risk-Unknown  { background:#F1F5F9; color:#64748B; }

/* ── Value Calculator ─────────────────────────────────── */
.val-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}
.val-Cheap   { background: var(--green-bg); color: #15803D; }
.val-Fair    { background: #F1F5F9;         color: #475569; }
.val-Rich    { background: var(--red-bg);   color: var(--red); }
.val-Unknown { background: #F1F5F9;         color: #64748B; }

.range-bar-wrap { margin: 4px 0 20px; }
.range-bar {
  position: relative;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, #DCFCE7, #FEF3C7, #FEE2E2);
  margin-bottom: 8px;
}
.range-marker {
  position: absolute;
  top: -4px;
  width: 4px;
  height: 16px;
  background: var(--navy);
  border-radius: 2px;
  transform: translateX(-2px);
}
.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}
.range-current { font-weight: 700; color: var(--navy-mid); }

/* ── Correlation Checker ───────────────────────────────── */
.corr-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 4px;
}
.corr-chart-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px 10px;
}
.corr-chart-box canvas { width: 100%; height: auto; display: block; }
@media (max-width: 720px) {
  .corr-charts { grid-template-columns: 1fr; }
}

/* ── Tooltip ─────────────────────────────────────────── */
.tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.th-sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  padding: 2px;
}
.tip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  border: 0;
  color: inherit;
  font-size: 9px;
  cursor: help;
  flex-shrink: 0;
}
.th-sort-btn:focus-visible,
.tip-icon:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
  border-radius: 3px;
}
.tip-box {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1E293B;
  color: #E2E8F0;
  font-size: 11px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  padding: 8px 12px;
  border-radius: 6px;
  width: 200px;
  line-height: 1.5;
  white-space: normal;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
  pointer-events: none;
}
.tip:hover .tip-box, .tip:focus-within .tip-box { display: block; }

/* ── Glossary ────────────────────────────────────────── */
.glossary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 32px;
}
.glossary summary {
  padding: 16px 20px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid transparent;
}
.glossary[open] summary { border-bottom-color: var(--border); }
.glossary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0;
}
.glossary-item {
  padding: 16px 20px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.glossary-item:nth-child(n) { }
.glossary-term { font-weight: 700; margin-bottom: 4px; font-size: 13px; }
.glossary-def  { font-size: 13px; color: var(--muted); line-height: 1.55; }
.glossary-good { color: var(--green); font-size: 11px; font-weight: 600; margin-top: 4px; }

/* ── Footer ──────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  padding: 20px 24px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  max-width: 1400px;
  margin: 0 auto;
}

/* ── Footer link columns ──────────────────────────────── */
.footer-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 20px;
  text-align: left;
  max-width: 1000px;
  margin: 0 auto 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.footer-heading {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--navy-mid);
  margin-bottom: 10px;
}
.footer-col a {
  display: block;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  padding: 3px 0;
}
.footer-col a:hover { color: var(--blue); text-decoration: underline; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
  main, footer { padding-left: 14px; padding-right: 14px; }
  .header-inner { flex-direction: column; align-items: flex-start; gap: 6px; }
  .intro { flex-direction: column; }
  .controls { flex-direction: column; }
  .controls input { min-width: 100%; }
  .footer-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Nav links ───────────────────────────────────────── */
.header-nav { display: flex; gap: 2px; }
.nav-link {
  color: #94A3B8;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  transition: color .15s, background .15s;
}
.nav-link:hover { color: #fff; background: rgba(255,255,255,.1); }
.nav-link.active { color: #fff; background: rgba(255,255,255,.15); }

/* ── Tool page tabs ──────────────────────────────────── */
.tool-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 28px;
}
.tool-tab {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.tool-tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.tool-tab:hover:not(.active) { color: var(--text); }

/* ── Tool description block ──────────────────────────── */
.tool-desc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--blue);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 20px 24px;
  margin-bottom: 24px;
  font-size: 13px;
  line-height: 1.7;
}
.tool-desc h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 10px;
}
.tool-desc p { color: var(--muted); margin-bottom: 8px; }
.tool-desc p:last-child { margin-bottom: 0; }
.tool-desc strong { color: var(--text); }
.tool-desc ul { color: var(--muted); margin: 4px 0 10px 18px; }
.tool-desc li { margin-bottom: 4px; }
.tool-desc ul:last-child { margin-bottom: 0; }

/* ── Quiz widget ──────────────────────────────────────── */
.quiz-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px 26px; max-width: 640px; margin: 0 auto;
}
.quiz-progress { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 14px; }
.quiz-progress-bar { height: 4px; background: var(--bg); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.quiz-progress-fill { height: 100%; background: var(--blue); transition: width .2s; }
.quiz-question { font-size: 17px; font-weight: 700; color: var(--navy); margin-bottom: 18px; }
.quiz-options { display: flex; flex-direction: column; gap: 10px; }
.quiz-option {
  text-align: left; padding: 14px 16px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); font-size: 13.5px; cursor: pointer; transition: border-color .15s, background .15s;
}
.quiz-option:hover { border-color: var(--blue); background: var(--blue-light); }
.quiz-back { display: inline-block; margin-top: 16px; font-size: 12px; color: var(--muted); cursor: pointer; text-decoration: underline; }
.quiz-result-tag {
  display: inline-block; background: var(--blue-light); color: var(--blue); font-weight: 700; font-size: 11px;
  text-transform: uppercase; letter-spacing: .04em; padding: 4px 10px; border-radius: 20px; margin-bottom: 10px;
}
.quiz-result h3 { font-size: 19px; color: var(--navy); margin-bottom: 8px; }
.quiz-result p { font-size: 13.5px; color: var(--muted); line-height: 1.6; margin-bottom: 16px; }
.quiz-tickers { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.quiz-ticker-card { flex: 1; min-width: 150px; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; }
.quiz-ticker-card .tk { font-weight: 700; font-size: 14px; color: var(--navy); }
.quiz-ticker-card .tk a { color: inherit; text-decoration: none; }
.quiz-ticker-card .tk-meta { font-size: 11.5px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.quiz-restart { font-size: 12px; color: var(--blue); cursor: pointer; text-decoration: underline; }
.tool-tabs { flex-wrap: wrap; }

/* ── Comparator ──────────────────────────────────────── */
.comp-selects {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.comp-select-group label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
}
.comp-selects select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  outline: none;
}
.comp-selects select:focus { border-color: var(--blue); }
.comp-label { font-weight: 600; color: var(--muted); font-size: 12px; }
.comp-ticker-header { font-size: 20px; font-weight: 800; color: var(--navy-mid); }
#comp-result table th,
#comp-result table td { text-align: center; }
#comp-result table td.comp-label { text-align: left; }

/* ── Fee Calculator ──────────────────────────────────── */
.calc-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.form-group input,
.form-group select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus { border-color: var(--blue); }
.form-group .er-display {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--surface);
  color: var(--muted);
}

.fee-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.fee-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}
.fee-stat label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
}
.fee-stat span { font-size: 20px; font-weight: 800; }

.fee-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.fee-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.fee-table thead th {
  background: var(--navy);
  color: #CBD5E1;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 12px 16px;
  text-align: left;
}
.fee-table tbody td { padding: 10px 16px; border-bottom: 1px solid var(--border); }
.fee-table tbody tr:last-child td { border-bottom: none; }
.fee-table tbody tr:hover { background: #F8FAFF; }

.bar-row {
  display: flex;
  height: 14px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg);
  min-width: 80px;
  width: 100%;
}
.bar-fill { height: 100%; background: var(--blue); transition: width .3s; }
.bar-drag { height: 100%; background: #FECACA; transition: width .3s; }

.tool-placeholder {
  text-align: center;
  padding: 60px 24px;
  color: var(--muted);
  font-size: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ── Income cards (Dividend Estimator) ───────────────── */
.income-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.income-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}
.income-card label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
}
.income-val { font-size: 24px; font-weight: 800; color: var(--green); }
.income-sub { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ── Portfolio builder ───────────────────────────────── */
.portfolio-builder {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}
.portfolio-header {
  display: grid;
  grid-template-columns: 1fr 120px 36px;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 0 2px;
}
.portfolio-row {
  display: grid;
  grid-template-columns: 1fr 120px 36px;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}
.portfolio-row select,
.portfolio-row input[type="number"] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.portfolio-row select:focus,
.portfolio-row input:focus { border-color: var(--blue); }
.prow-pct-wrap { display: flex; align-items: center; gap: 5px; }
.prow-pct-wrap input { min-width: 0; }
.pct-symbol { font-size: 13px; color: var(--muted); flex-shrink: 0; }
.remove-btn {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s, border-color .15s;
  flex-shrink: 0;
}
.remove-btn:hover { background: var(--red-bg); color: var(--red); border-color: #FECACA; }
.add-btn {
  padding: 8px 16px;
  border: 1px solid var(--blue);
  border-radius: 6px;
  background: var(--blue-light);
  color: var(--blue);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.add-btn:hover { background: var(--blue); color: #fff; }

@media (max-width: 768px) {
  .comp-selects { grid-template-columns: 1fr; }
  .calc-form { grid-template-columns: 1fr; }
  .fee-table thead th:nth-child(5),
  .fee-table tbody td:nth-child(5) { display: none; }
  .portfolio-header,
  .portfolio-row { grid-template-columns: 1fr 90px 36px; }
  .income-cards { grid-template-columns: 1fr 1fr; }
}

/* ── Guide article ────────────────────────────────────── */
.guide-toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 24px;
}
.guide-toc-title {
  font-size: 13px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 10px;
}
.guide-toc ol { margin-left: 18px; columns: 2; column-gap: 24px; }
.guide-toc li { margin-bottom: 6px; font-size: 13px; break-inside: avoid; }
.guide-toc a { color: var(--blue); text-decoration: none; }
.guide-toc a:hover { text-decoration: underline; }

.guide-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-bottom: 20px;
}
.guide-section h2 {
  font-size: 17px; font-weight: 800; color: var(--navy);
  margin-bottom: 12px; scroll-margin-top: 20px;
}
.guide-section h3 { font-size: 14px; font-weight: 700; color: var(--navy-mid); margin: 18px 0 8px; }
.guide-section p { font-size: 13.5px; color: var(--text); line-height: 1.75; margin-bottom: 12px; }
.guide-section p:last-child { margin-bottom: 0; }
.guide-section ul, .guide-section ol { margin: 4px 0 14px 20px; font-size: 13.5px; line-height: 1.7; }
.guide-section ul:last-child, .guide-section ol:last-child { margin-bottom: 0; }
.guide-section li { margin-bottom: 6px; }
.guide-section strong { color: var(--navy); }
.guide-section a { color: var(--blue); }

.guide-callout {
  background: var(--blue-light);
  border-left: 3px solid var(--blue);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 14px 18px;
  margin: 14px 0;
  font-size: 13px;
  line-height: 1.65;
}
.guide-callout strong { color: var(--navy); }
.guide-callout.warn { background: var(--amber-bg); border-left-color: var(--amber); }
.guide-callout.warn strong { color: #92400E; }

.guide-table { width: 100%; border-collapse: collapse; margin: 10px 0 16px; font-size: 13px; }
.guide-table th { text-align: left; background: var(--bg); padding: 8px 12px; font-weight: 700; border-bottom: 2px solid var(--border); }
.guide-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; color: var(--muted); }
.guide-table tr:last-child td { border-bottom: none; }

.guide-steps { list-style: none; margin: 4px 0 14px; counter-reset: step; }
.guide-steps li {
  position: relative; padding-left: 34px; margin-bottom: 14px; font-size: 13.5px; line-height: 1.7;
}
.guide-steps li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--blue); color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

.guide-faq details { border-bottom: 1px solid var(--border); padding: 12px 0; }
.guide-faq details:last-child { border-bottom: none; }
.guide-faq summary { font-weight: 700; cursor: pointer; font-size: 13.5px; color: var(--navy); list-style: none; }
.guide-faq summary::-webkit-details-marker { display: none; }
.guide-faq summary::before { content: '+ '; color: var(--blue); }
.guide-faq details[open] summary::before { content: '– '; }
.guide-faq p { margin-top: 8px; font-size: 13px; color: var(--muted); line-height: 1.7; }

.guide-cta {
  text-align: center; padding: 32px 24px; background: var(--navy);
  border-radius: var(--radius); margin-top: 8px;
}
.guide-cta h3 { color: #fff; font-size: 16px; margin-bottom: 6px; }
.guide-cta p { color: #94A3B8; font-size: 13px; margin-bottom: 18px; }
.guide-cta-buttons { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.guide-cta-buttons a {
  background: var(--blue); color: #fff; text-decoration: none; padding: 10px 22px;
  border-radius: 6px; font-weight: 600; font-size: 13px; transition: background .15s;
}
.guide-cta-buttons a:hover { background: #0046a0; }
.guide-cta-buttons a.secondary { background: rgba(255,255,255,.1); }
.guide-cta-buttons a.secondary:hover { background: rgba(255,255,255,.18); }

@media (max-width: 768px) {
  .guide-section { padding: 18px 18px; }
  .guide-toc ol { columns: 1; }
}
