:root {
  --bg: #07090d;
  --fg: #e6edf3;
  --accent: #0098d8;
  --muted: #8b97a6;
  --border: rgba(255, 255, 255, 0.1);
  --panel: rgba(255, 255, 255, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}

.brand {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 17px;
  letter-spacing: -0.02em;
  color: var(--fg);
  text-decoration: none;
}
.brand span { color: var(--accent); }

.topbar nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  margin-left: 14px;
  transition: color 0.15s;
}
.topbar nav a:hover { color: var(--fg); }
.topbar nav a.cta {
  color: #000;
  background: var(--accent);
  padding: 7px 14px;
  border-radius: 8px;
  font-weight: 500;
}
.topbar nav a.cta:hover { opacity: 0.9; }

.wrap {
  flex: 1;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  padding: 56px 24px;
}
.wrap.wide { max-width: 880px; }
/* 3 boxes @ 900px + 2 gaps @ 20px + 2 side paddings @ 48px = 2836px, centered */
.wrap.xwide { max-width: 2836px; padding-left: 48px; padding-right: 48px; }

h1 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}
.sub { color: var(--muted); font-size: 14px; margin: 0 0 28px; }

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 16px 0 6px;
}

input[type="email"],
input[type="password"] {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--fg);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
input:focus {
  border-color: rgba(0, 152, 216, 0.6);
  background: rgba(255, 255, 255, 0.06);
}

button {
  width: 100%;
  margin-top: 22px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #000;
  font-size: 15px;
  font-weight: 500;
  padding: 12px;
  cursor: pointer;
  transition: opacity 0.15s;
}
button:hover { opacity: 0.9; }

.alt { margin-top: 22px; font-size: 14px; color: var(--muted); }
.alt a { color: var(--accent); text-decoration: none; }
.alt a:hover { text-decoration: underline; }

.notice {
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
  margin-bottom: 20px;
}
.notice.error { background: rgba(239, 68, 68, 0.12); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.25); }
.notice.ok { background: rgba(0, 152, 216, 0.1); color: var(--accent); border: 1px solid rgba(0, 152, 216, 0.25); }
.notice.warn { background: rgba(234, 179, 8, 0.1); color: #fde047; border: 1px solid rgba(234, 179, 8, 0.25); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 28px;
}
.card {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 14px;
  padding: 20px;
}
.card h3 { margin: 0 0 6px; font-size: 15px; font-weight: 600; }
.card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.card .big { font-size: 26px; font-weight: 600; color: var(--fg); margin-bottom: 2px; }

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; }

.foot {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 24px;
}

/* ---- Pre-market dashboard ---- */
.pm-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.pm-meta { color: var(--muted); font-size: 13px; }
.pm-meta .src { color: var(--accent); }
.pm-live {
  margin-left: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent);
  vertical-align: middle;
}

/* Futures/rates — a flowing list inside its own box */
.pm-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
}
.pm-bar .q { display: flex; align-items: baseline; gap: 7px; font-size: 13px; white-space: nowrap; }
.pm-bar .q .name { color: var(--muted); }
.pm-bar .q .last { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-weight: 600; }
.pm-bar .q .chg { font-size: 12px; }

.pm-overview {
  font-size: 14px;
  line-height: 1.55;
  margin: 0;
}

/* Masonry: every section is a box; boxes stack into three columns. */
.pm-grid {
  column-count: 3;
  column-gap: 20px;
  margin-top: 16px;
}
/* Two-column masonry (Stocks, Indices). Declared before the media queries so
   they still collapse it to one column on narrow screens. */
.pm-grid.pm-grid-two { column-count: 2; }
@media (max-width: 1400px) { .pm-grid:not(.pm-grid-one) { column-count: 2; } }
@media (max-width: 760px)  { .pm-grid:not(.pm-grid-one) { column-count: 1; } }

/* Most Active: a single full-width box, capped at 1260px (1800px − 30%). */
.pm-grid.pm-grid-one { column-count: 1; max-width: 1148px; }
.pm-grid.pm-grid-one .pm-section { width: 100%; }

/* Two Most Active boxes side by side, each exactly half the page width (drops
   the single-box 1148px cap). min-width:0 lets a box shrink below its table's
   min-width so the two always fit as a row; the inner .pm-scroll handles any
   table overflow. Stacks only on truly narrow (mobile) viewports. */
.pm-dup { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.pm-dup .pm-grid-one { flex: 1 1 0; min-width: 0; max-width: none; }
@media (max-width: 760px) { .pm-dup .pm-grid-one { flex-basis: 100%; } }

.pm-section {
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  margin: 0 0 20px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 14px;
  padding: 16px 18px;
}
.pm-section > h2 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.up { color: var(--accent); }
.down { color: #fca5a5; }
.flat { color: var(--muted); }

table.pm {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.pm th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
table.pm td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.pm tr:last-child td { border-bottom: 0; }
table.pm .sym { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-weight: 600; }

/* Fresh News: give the Time column ~20% more room so "h:mm ET" never wraps. */
table.pm.pm-news th:nth-child(2),
table.pm.pm-news td:nth-child(2) { width: 86px; white-space: nowrap; }

/* Watchlist glow: rows whose ticker is on our Stocks page get a soft accent
   highlight wherever they appear in third-party tables (Most Active, Pre-Market). */
table.pm tr.pm-glow td {
  background: rgba(0, 152, 216, 0.09);
}
table.pm tr.pm-glow td:first-child {
  box-shadow: inset 3px 0 0 0 var(--accent);
}
table.pm tr.pm-glow .sym,
table.pm tr.pm-glow td:first-child {
  color: var(--accent);
  text-shadow: 0 0 10px rgba(0, 152, 216, 0.6);
}

/* Markets: horizontal scroll for the wide Yahoo Most-Active table on narrow screens. */
.pm-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* 5-day spark chart cell on the Most Active table. */
table.pm-yahoo td.spark-cell { width: 96px; padding: 4px 8px; vertical-align: middle; }
table.pm-yahoo td.spark-cell svg.spark { display: block; width: 88px; height: 26px; }

/* Sortable column headers on the Most Active table. */
.pm-hint { color: var(--muted); font-style: italic; }
table.pm-yahoo th.pm-sortable {
  cursor: pointer;
  user-select: none;
}
table.pm-yahoo th.pm-sortable:hover { color: var(--accent); }
table.pm-yahoo th.pm-sortable::after {
  content: "\2195"; /* up-down arrow, idle */
  margin-left: 5px;
  opacity: 0.4;
  font-size: 10px;
}
table.pm-yahoo th.pm-asc::after  { content: "\2191"; opacity: 1; color: var(--accent); }
table.pm-yahoo th.pm-desc::after { content: "\2193"; opacity: 1; color: var(--accent); }
table.pm.pm-yahoo { min-width: 760px; }
table.pm.pm-yahoo td { white-space: nowrap; }
table.pm.pm-yahoo th { white-space: normal; vertical-align: bottom; } /* wrap headers */
/* Columns auto-size to their content (no forced widths). The spark and 52-wk
   range cells size to their inline SVGs; everything else to text. */
table.pm.pm-yahoo a { color: var(--accent); text-decoration: none; }
table.pm.pm-yahoo a:hover { text-decoration: underline; }

/* 52-week range bar cell (low–high track with a current-price pin). Sizes to
   its inline SVG; no forced column width. */
table.pm-yahoo td.range-cell { vertical-align: middle; padding: 4px 8px; }
table.pm-yahoo svg.range52 { display: block; width: 150px; height: 32px; }
table.pm-yahoo svg.range52 text { fill: var(--muted); font-size: 9px; font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; }

.pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.pill.high { background: rgba(239, 68, 68, 0.12); color: #fca5a5; border-color: rgba(239, 68, 68, 0.25); }
.pill.med  { background: rgba(234, 179, 8, 0.1); color: #fde047; border-color: rgba(234, 179, 8, 0.25); }
.pill.low  { background: rgba(0, 152, 216, 0.1); color: var(--accent); border-color: rgba(0, 152, 216, 0.25); }
.pill.bmo, .pill.amc { background: var(--panel); }

.pm-list { margin: 0; padding-left: 18px; }
.pm-list li { margin: 7px 0; line-height: 1.5; }

.pm-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.pm-tags .tag {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
}

.pm-empty {
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
}
