* {
  box-sizing: border-box;
}

:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #111827;
  --muted: #5f6b7a;
  --line: #d8dee6;
  --head: #edf1f5;
  --blue: #1d4ed8;
  --green: #047857;
  --red: #b91c1c;
  --shadow: 0 10px 24px rgba(17, 24, 39, 0.08);
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

a {
  color: inherit;
}

.topnav {
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.nav-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand {
  font-weight: 800;
  font-size: 17px;
  text-decoration: none;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-links a,
.btn {
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 11px;
  font-size: 14px;
  background: transparent;
  cursor: pointer;
}

.nav-links a:hover {
  background: #f3f4f6;
}

.nav-links a.active {
  background: #eef2ff;
  color: var(--blue);
  font-weight: 700;
}

.btn.primary {
  background: var(--blue);
  color: #ffffff;
}

.btn.secondary {
  background: #ffffff;
  border-color: var(--line);
}

.wrap {
  max-width: 1180px;
  margin: 24px auto;
  padding: 0 18px 32px;
}

.hero {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.hero h1 {
  margin: 0 0 10px;
  font-size: 34px;
  line-height: 1.15;
}

.hero p {
  margin: 0;
  color: var(--muted);
  max-width: 760px;
  line-height: 1.55;
}

.actions {
  margin-top: 18px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel,
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.card h3,
.panel h2,
.panel h3 {
  margin: 0 0 8px;
}

.card p,
.panel p,
.muted {
  color: var(--muted);
  line-height: 1.5;
}

.metric {
  font-size: 26px;
  font-weight: 800;
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--red);
}

.form {
  max-width: 430px;
  margin: 30px auto;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.form h1 {
  margin: 0 0 14px;
  font-size: 24px;
}

.field {
  margin-bottom: 12px;
}

.field label {
  display: block;
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 5px;
}

.field input,
.field select {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
}

.notice {
  border: 1px solid #fde68a;
  background: #fffbeb;
  color: #92400e;
  border-radius: 6px;
  padding: 12px;
  margin: 14px 0;
}

.error {
  border: 1px solid #fca5a5;
  background: #fee2e2;
  color: #991b1b;
  border-radius: 6px;
  padding: 12px;
  margin: 14px 0;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid #e5e7eb;
  text-align: right;
  white-space: nowrap;
  font-size: 14px;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  background: var(--head);
  cursor: pointer;
  position: sticky;
  top: 50px;
  z-index: 2;
}

tr:hover td {
  background: #f9fafb;
}

.search {
  width: 260px;
  max-width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 12px 0;
  flex-wrap: wrap;
}

.footer {
  color: var(--muted);
  font-size: 12px;
  margin-top: 10px;
}

/* --- Subscriber webapp additions --- */

.card.highlight {
  border-color: var(--blue);
  box-shadow: var(--shadow);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-form {
  display: inline;
  margin: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  color: #3730a3;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 700;
}

.chip button {
  border: none;
  background: transparent;
  color: #6366f1;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.chip button:hover {
  color: var(--red);
}

.symbol-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 6px;
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fbfcfe;
}

.symbol-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}

.symbol-item:hover {
  background: #eef2ff;
}

th[data-dir="asc"]::after {
  content: " \25B2";
  font-size: 10px;
}

th[data-dir="desc"]::after {
  content: " \25BC";
  font-size: 10px;
}

/* --- Run comparison page --- */

/* Compact table: 13 columns fit the page width without horizontal scrolling */
table.compact th,
table.compact td {
  padding: 6px 7px;
  font-size: 12.5px;
}

table.compact th {
  white-space: normal;
  line-height: 1.25;
  text-align: center;
  vertical-align: bottom;
  position: static;
}

table.compact td {
  white-space: nowrap;
}

.verify-banner {
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
  color: #92400e;
  font-size: 13.5px;
  padding: 10px 0;
}

/* Run stepper: walks the compared pair back and forth through the session.
   Spent directions stay visible but inert — a control that disappears at the
   end of the day is more confusing than one that is plainly used up. */
.run-stepper {
  align-items: center;
  gap: 8px;
  margin: 4px 0 12px;
}

.btn.is-disabled {
  cursor: default;
  opacity: 0.45;
  pointer-events: none;
}

/* Data-freshness strip. The normal state is quiet and informational; the stale
   state is red and unmissable, because a subscriber trading on yesterday's
   numbers believing they are live is the worst outcome this app can produce. */
.freshness {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  color: #475569;
  font-size: 13px;
  margin: 12px 0;
  padding: 8px 12px;
}

.freshness-stale {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
  font-size: 14px;
  font-weight: 500;
}

/* Market open/closed indicator inside the (non-stale) freshness strip only —
   deliberately scoped to these two spans, not a blanket text color, since the
   stale-state alarm message above also contains the word "open" in an
   unrelated sentence and must stay unstyled. */
.market-open {
  color: #15803d;
  font-weight: 600;
}

.market-closed {
  color: #b91c1c;
  font-weight: 600;
}

.verify-banner .btn {
  margin-left: 10px;
  padding: 4px 10px;
  font-size: 12.5px;
}

/* --- Site footer + legal pages --- */

.site-footer {
  border-top: 1px solid var(--line);
  background: #f7f9fc;
  margin-top: 28px;
  padding: 18px 0 26px;
}

.footer-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 18px;
}

.footer-disclaimer {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
  margin: 0 0 10px;
  max-width: 900px;
}

.footer-links {
  color: var(--muted);
  font-size: 12.5px;
  margin: 4px 0 0;
}

.footer-links a {
  color: var(--blue);
  text-decoration: none;
}

.footer-links a:hover {
  text-decoration: underline;
}

.legal h2 {
  font-size: 17px;
  margin: 22px 0 8px;
}

.legal h2:first-child {
  margin-top: 0;
}

.legal p, .legal li {
  color: var(--text);
  line-height: 1.65;
  max-width: 820px;
}

.legal ul {
  padding-left: 22px;
}

.legal table {
  max-width: 820px;
  margin: 10px 0;
}

.legal td, .legal th {
  text-align: left;
  white-space: normal;
}

.run-pickers {
  background: #f7f9fc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 0;
}

.run-pickers label {
  font-weight: 700;
  font-size: 13px;
}

th.th-earlier {
  background: #eef1f6;
}

th.th-latest {
  background: #e3ebf7;
}

.vsep-left {
  border-left: 3px solid #94a3b8 !important;
}

tr.group-head td {
  background: #e8edf3 !important;
  font-weight: 800;
  border-top: 2px solid var(--line);
}

/* ΔLatest group tints (A–D gains in green, E–H losses in red, NA amber) */
tr.grp-A td { background: rgba(34, 197, 94, 0.08); }
tr.grp-B td { background: rgba(34, 197, 94, 0.14); }
tr.grp-C td { background: rgba(34, 197, 94, 0.22); }
tr.grp-D td { background: rgba(34, 197, 94, 0.30); }
tr.grp-E td { background: rgba(239, 68, 68, 0.08); }
tr.grp-F td { background: rgba(239, 68, 68, 0.14); }
tr.grp-G td { background: rgba(239, 68, 68, 0.22); }
tr.grp-H td { background: rgba(239, 68, 68, 0.30); }
tr.grp-NA td { background: rgba(245, 158, 11, 0.10); }

.star-yellow {
  color: #eab308;
  font-size: 17px;
}

.star-blue {
  color: #2563eb;
  font-size: 17px;
}

.star-green {
  color: #16a34a;
  font-size: 17px;
}

.symlink {
  text-decoration: none;
  color: var(--blue);
}

.symlink:hover {
  text-decoration: underline;
}

.featured-panel {
  border-color: #c7d2fe;
  background: linear-gradient(180deg, #f5f7ff, #ffffff);
}

.featured-card {
  border-color: #c7d2fe;
  text-decoration: none;
  display: block;
}

.featured-card:hover {
  box-shadow: var(--shadow);
}

/* OHLC candle table column colors (from stockInfo.jsp) */
.ohlc-table td:nth-child(1), .ohlc-table th:nth-child(1) { color: #b45309; }
.ohlc-table td:nth-child(2), .ohlc-table th:nth-child(2) { color: #2563eb; }
.ohlc-table td:nth-child(3), .ohlc-table th:nth-child(3) { color: #047857; }
.ohlc-table td:nth-child(4), .ohlc-table th:nth-child(4) { color: #7c3aed; }
.ohlc-table td:nth-child(5), .ohlc-table th:nth-child(5) { color: #92400e; }
.ohlc-table td:nth-child(6), .ohlc-table th:nth-child(6) { color: #c2410c; }

.ohlc-table th {
  position: sticky;
  top: 0;
}

/* --- Readability additions --- */

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
}

.pill.up {
  background: #ecfdf5;
  color: var(--green);
  border: 1px solid #a7f3d0;
}

.pill.down {
  background: #fef2f2;
  color: var(--red);
  border: 1px solid #fecaca;
}

details.help {
  margin-top: 14px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 16px;
}

details.help summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--blue);
  outline: none;
}

details.help summary:hover {
  text-decoration: underline;
}

details.help ul {
  margin: 10px 0 4px;
  padding-left: 20px;
  color: var(--muted);
}

details.help li {
  margin-bottom: 6px;
  line-height: 1.5;
}

details.help li strong {
  color: var(--text);
}

th[title] {
  text-decoration: underline dotted #9ca3af;
  text-underline-offset: 3px;
}

/* --- Compare view: presentation pass ---------------------------------
   Everything below is scoped to classes only used on the compare page
   (compare-toolbar, btn-group, btn-signal-*, compare-table, move-pill),
   never to the bare shared classes (.btn, .toolbar, table.compact) that
   dashboard.jsp and myPredictions.jsp also rely on — so none of this can
   change how any other page looks. */

/* Toolbar: named clusters instead of one wall of identical buttons, so the
   thirteen filters read as four small, scannable decisions rather than one
   long guess. */
.compare-toolbar {
  align-items: flex-start;
  gap: 18px 22px;
}

.btn-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn-group-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding-left: 2px;
}

.btn-group-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Star-signal buttons carry the same color as their row-level star, so the
   toolbar and the Signals column read as one system rather than two. Color
   only appears on the INACTIVE state; the active state stays solid blue like
   every other selected filter on the site, so "this is the current view"
   remains a single, unambiguous signal. The star glyph turns white when
   active for the same reason — a colored star on a blue background would
   fight the label text instead of matching it. */
.btn-star {
  display: inline-block;
}

.btn-signal.secondary.btn-signal-yellow { border-left: 3px solid #eab308; }
.btn-signal.secondary.btn-signal-blue   { border-left: 3px solid #2563eb; }
.btn-signal.secondary.btn-signal-green  { border-left: 3px solid #16a34a; }

.btn-signal-yellow .btn-star { color: #eab308; }
.btn-signal-blue   .btn-star { color: #2563eb; }
.btn-signal-green  .btn-star { color: #16a34a; }

.btn-signal.primary .btn-star { color: #ffffff; }

/* Run pickers + stepper: a touch more presence than a plain gray box. */
.run-pickers {
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.04);
}

.run-pickers select.search {
  font-weight: 600;
}

.run-stepper {
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
}

.run-stepper .btn {
  font-weight: 700;
}

/* The comparison table itself. A new class, not a redefinition of the
   shared table.compact rules dashboard.jsp and myPredictions.jsp also use —
   every rule here is scoped under .compare-table so it cannot leak. */
.compare-table th {
  font-size: 12.5px;
  font-weight: 800;
  color: #1e293b;
  letter-spacing: 0.01em;
  padding: 8px 9px;
}

.compare-table td {
  font-size: 13px;
  padding: 7px 9px;
}

/* A sticky header was tried here and reverted: .table-wrap sets overflow-x:
   auto for horizontal scrolling on narrow screens, and per the CSS Overflow
   spec a non-visible overflow-x forces overflow-y to compute to auto as well
   — even when overflow-y: visible is written explicitly, confirmed directly
   in-browser. That silently makes .table-wrap the sticky containing block
   instead of the page viewport, and since .table-wrap itself never scrolls
   internally (the whole page does), the header never actually sticks — it
   just scrolls away with everything else. Fixing it properly needs a
   JS-synced cloned header or dropping the horizontal-scroll wrapper this
   table needs on mobile; not worth that cost for what was a nice-to-have,
   so the header stays in normal flow, matching every other page's table. */
.compare-table thead th {
  box-shadow: 0 1px 0 var(--line);
}

.compare-table th.th-earlier { background: #e8edf6; }
.compare-table th.th-latest  { background: #dce6f5; }

.compare-table .vsep-left {
  border-left: 3px solid var(--blue) !important;
}

.compare-table tr.group-head td {
  border-top: 2px solid #cbd5e1;
  border-left: 4px solid #64748b;
  font-size: 13.5px;
}

.compare-table .star-yellow,
.compare-table .star-blue,
.compare-table .star-green {
  font-size: 18px;
}

/* Actual Move: the single number the grouped view is sorted by, and the one
   most worth being able to spot on a page of hundreds of rows — so it gets a
   filled pill instead of just colored text, the same way the rest of the
   table already uses color to mean something rather than to decorate. */
.move-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12.5px;
}

.move-pill.positive {
  background: rgba(34, 197, 94, 0.16);
  color: #15803d;
}

.move-pill.negative {
  background: rgba(239, 68, 68, 0.14);
  color: #b91c1c;
}

@media (max-width: 800px) {
  .compare-toolbar {
    gap: 14px;
  }

  .btn-group-buttons .btn {
    width: auto;
  }
}

@media (max-width: 800px) {
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar .btn,
  .toolbar .search {
    width: 100%;
  }

  th, td {
    padding: 8px 8px;
    font-size: 13px;
  }
}

@media (max-width: 800px) {
  .grid,
  .grid.two {
    grid-template-columns: 1fr;
  }

  .hero h1 {
    font-size: 27px;
  }

  .nav-inner {
    align-items: flex-start;
    flex-direction: column;
  }
}
