/* Market Watch: one continuous page. A ledger-like layout: a sticky section
   index, then full-width sections stacked down a single 1120px column. */
:root {
  --bg: #f4f6f7;
  --panel: #ffffff;
  --ink: #0f1b22;
  --muted: #56666f;
  --line: #d9e1e5;
  --accent: #155e8c;
  --notice: #fff6e0;
  --notice-line: #e7c56b;
  --up: #0c7a47;
  --down: #c23a2e;
  --flat: #6b7a83;
  --bar: #b9c6cd;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Source Serif 4", Georgia, "Times New Roman", serif;
  --radius: 8px;
  --gap: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1418;
    --panel: #132027;
    --ink: #e5edf0;
    --muted: #93a5ae;
    --line: #243540;
    --accent: #6fb6e4;
    --notice: #2a2412;
    --notice-line: #8c7330;
    --up: #45c486;
    --down: #f2766c;
    --flat: #93a5ae;
    --bar: #3b4f5a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
}
a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
[hidden] { display: none !important; }

.mw-wrap {
  max-width: 1120px;
  margin-inline: auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

.mw-top { background: var(--ink); color: var(--bg); }
.mw-top-inner { display: flex; align-items: baseline; gap: 12px; padding-block: 12px; }
.mw-brand { color: inherit; text-decoration: none; font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; }
.mw-top-section { font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; opacity: .75; }

.mw-notice { background: var(--notice); border-bottom: 1px solid var(--notice-line); }
.mw-notice p { margin: 0; padding-block: 10px; font-size: .9rem; }

.mw-nav {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.mw-nav-inner { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.mw-nav-inner::-webkit-scrollbar { display: none; }
.mw-nav a {
  flex: none;
  padding: 12px 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: .88rem;
  border-bottom: 2px solid transparent;
}
.mw-nav a:hover { color: var(--ink); border-bottom-color: var(--line); }

.mw-main { display: grid; gap: 56px; padding-block: 32px 64px; }
.mw-section { display: grid; gap: 20px; min-width: 0; }
.mw-section-head { display: grid; gap: 6px; max-width: 46rem; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
h1, h2 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: clamp(1.7rem, 3.2vw, 2.3rem); line-height: 1.15; }
h2 { font-size: clamp(1.35rem, 2.4vw, 1.7rem); line-height: 1.2; }
h3 { font-size: 1rem; font-weight: 600; }
.mw-headline { font-size: clamp(1.5rem, 3vw, 2.1rem); }
.mw-eyebrow { margin: 0; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.mw-note { margin: 0; font-size: .88rem; color: var(--muted); }
.mw-advice-note { margin: 0; font-size: .85rem; color: var(--muted); font-style: italic; }

.mw-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: grid;
  gap: 10px;
  align-content: start;
  min-width: 0;
}

/* Indices */
.mw-hero { display: grid; gap: 18px; }
.mw-hero-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px 24px; }
.mw-status { margin: 0; font-size: .88rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.mw-status.is-stale { color: var(--down); }
.mw-indices { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: var(--gap); }
.mw-index {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: grid;
  gap: 2px;
  font-variant-numeric: tabular-nums;
}
.mw-index-name { font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.mw-index-value { font-family: var(--font-display); font-size: 1.7rem; font-weight: 600; line-height: 1.2; }
.mw-index-change { font-size: .92rem; font-weight: 500; }
.mw-index.is-lead { border-top: 3px solid var(--accent); }

.is-up { color: var(--up); }
.is-down { color: var(--down); }
.is-flat { color: var(--flat); }

/* Analysis */
.mw-summary { display: grid; gap: 12px; max-width: 46rem; font-size: 1.05rem; }
.mw-summary p { margin: 0; }
.mw-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: var(--gap); }
.mw-tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: grid; gap: 4px; align-content: start; }
.mw-tile-label { font-size: .82rem; color: var(--muted); }
.mw-tile-value { font-family: var(--font-display); font-size: 1.55rem; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.mw-tile-note { font-size: .82rem; color: var(--muted); }
.mw-points { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: var(--gap); }
.mw-point { border-top: 2px solid var(--ink); padding-top: 12px; display: grid; gap: 6px; }
.mw-point p { margin: 0; color: var(--ink); font-size: .95rem; }

/* Movers */
.mw-breadth { display: grid; gap: 8px; }
.mw-breadth-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; gap: 2px; background: var(--line); }
.mw-breadth-bar span { min-width: 2px; }
.mw-breadth-legend { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: .9rem; font-variant-numeric: tabular-nums; }
.mw-movers { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: var(--gap); }
.mw-rank { list-style: none; margin: 0; padding: 0; display: grid; }
.mw-rank li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: baseline;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
  font-size: .92rem;
}
.mw-rank li:last-child { border-bottom: 0; }
.mw-rank-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mw-rank-name b { font-weight: 600; margin-right: 6px; }
.mw-rank-name span { color: var(--muted); }
.mw-rank-price { color: var(--muted); }
.mw-rank-change { font-weight: 500; min-width: 4.5rem; text-align: right; }

/* Sectors */
.mw-split { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: var(--gap); }
.mw-chart { min-height: 260px; min-width: 0; }
.mw-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.mw-chart text { font-family: var(--font-body); font-size: 12px; fill: var(--muted); }
.mw-chart .is-strong { fill: var(--ink); font-weight: 600; }
.mw-dir { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; margin-right: 6px; white-space: nowrap; }
.mw-dir::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* Tables */
.mw-tablebox { overflow: auto; min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.mw-card .mw-tablebox { border: 0; border-radius: 0; }
.mw-tall { max-height: 640px; }
.mw-table { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
.mw-table th, .mw-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.mw-table th { position: sticky; top: 0; z-index: 1; background: var(--panel); color: var(--muted); font-weight: 500; font-size: .82rem; white-space: nowrap; }
.mw-table th.num, .mw-table td.num { text-align: right; white-space: nowrap; }
.mw-table tbody tr:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.mw-table th button { all: unset; cursor: pointer; }
.mw-table th button:hover { color: var(--ink); }
.mw-table th[aria-sort="ascending"] button::after { content: " ↑"; }
.mw-table th[aria-sort="descending"] button::after { content: " ↓"; }
.mw-stocks td:first-child { font-weight: 600; }
.mw-stocks td:nth-child(2) { min-width: 10rem; }
.mw-exposure td { min-width: 10rem; }
.mw-exposure td:first-child { font-weight: 600; min-width: 8rem; }
@media (max-width: 720px) {
  .mw-stocks th:nth-child(2), .mw-stocks td:nth-child(2),
  .mw-stocks th:nth-child(3), .mw-stocks td:nth-child(3),
  .mw-stocks th:nth-child(6), .mw-stocks td:nth-child(6),
  .mw-stocks th:nth-child(9), .mw-stocks td:nth-child(9),
  .mw-stocks th:nth-child(10), .mw-stocks td:nth-child(10) { display: none; }
}
.mw-sym-name { display: none; }
.mw-filters { display: flex; flex-wrap: wrap; align-items: end; gap: 12px 20px; }
.mw-filters label { display: grid; gap: 4px; font-size: .82rem; color: var(--muted); flex: 1 1 200px; max-width: 320px; }
.mw-filters input, .mw-filters select {
  font: inherit;
  font-size: .95rem;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  min-width: 0;
}
.mw-count { font-size: .85rem; color: var(--muted); padding-bottom: 8px; }

/* Focus */
.mw-focus { display: grid; gap: var(--gap); }
.mw-focus-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 20px; }
.mw-focus-price { font-family: var(--font-display); font-size: 2rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.mw-focus-change { font-weight: 500; font-variant-numeric: tabular-nums; }
.mw-focus-summary { margin: 0; max-width: 46rem; font-size: 1.02rem; }
.mw-list { margin: 0; padding-left: 1.1rem; display: grid; gap: 6px; }
.mw-scenarios { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.mw-scenarios li { display: grid; gap: 2px; }

.mw-watch { margin: 0; padding-left: 1.1rem; display: grid; gap: 8px; max-width: 46rem; }

/* Footer */
.mw-footer { background: var(--panel); border-top: 1px solid var(--line); }
.mw-footer-inner { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 32px; padding-block: 36px 48px; font-size: .9rem; }
.mw-footer h2 { font-size: 1.15rem; margin-bottom: 10px; }
.mw-footer p { margin: 0 0 10px; max-width: 46rem; }
#disclaimer { border-left: 3px solid var(--notice-line); padding-left: 16px; }
.mw-sources { margin: 0; padding-left: 1.1rem; display: grid; gap: 6px; }

/* Phones: pair up the figure cards, stack the outcome table, and trim the
   stock table to the columns that fit. */
@media (max-width: 560px) {
  .mw-main { gap: 44px; padding-block: 24px 48px; }
  .mw-indices, .mw-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .mw-index, .mw-tile { padding: 12px 14px; }
  .mw-index-value { font-size: 1.3rem; }
  .mw-index-change { font-size: .8rem; }
  .mw-tile-value { font-size: 1.2rem; }
  .mw-tile-label, .mw-tile-note { font-size: .78rem; }
  .mw-card { padding: 14px; }
  .mw-focus-price { font-size: 1.7rem; }
  .mw-summary { font-size: 1rem; }

  .mw-exposure thead { display: none; }
  .mw-exposure, .mw-exposure tbody, .mw-exposure tr, .mw-exposure td { display: block; width: 100%; }
  .mw-exposure tr { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .mw-exposure tr:last-child { border-bottom: 0; }
  .mw-exposure td, .mw-exposure td:first-child { min-width: 0; border: 0; padding: 3px 0; }
  .mw-exposure td[data-label]::before { content: attr(data-label); display: block; font-size: .78rem; color: var(--muted); }

  .mw-table th, .mw-table td { padding: 8px 6px; }
  .mw-stocks { font-size: .84rem; }
  .mw-stocks th, .mw-stocks th.num { white-space: normal; }
  .mw-stocks th:nth-child(7), .mw-stocks td:nth-child(7),
  .mw-stocks th:nth-child(11), .mw-stocks td:nth-child(11) { display: none; }
  .mw-sym-name {
    display: block;
    max-width: 6.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 400;
    font-size: .78rem;
    color: var(--muted);
  }
}
