:root {
  --bg: #f6f7f9; --card: #ffffff; --text: #111827; --muted: #6b7280;
  --border: #e5e7eb; --accent: #2563eb; --up: #15803d; --down: #b91c1c;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f17; --card: #131a26; --text: #e5e7eb; --muted: #9ca3af;
    --border: #243044; --accent: #60a5fa; --up: #4ade80; --down: #f87171;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text); line-height: 1.45;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 1.5rem; margin: .5rem 0 .25rem; }
.container { max-width: 960px; margin: 0 auto; padding: 1rem; }
.muted { color: var(--muted); font-size: .85rem; }

/* top bar */
.topbar { background: var(--card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar .container { display: flex; align-items: center; flex-wrap: wrap; gap: .25rem .75rem; padding-block: .5rem; }
.brand { font-weight: 700; color: var(--text); }
.nav-links { display: flex; flex-wrap: wrap; gap: .1rem; }
.nav-links a, .linklike {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 .7rem;
  border-radius: 10px; color: var(--text); font-size: .95rem;
}
.nav-links a:hover { background: var(--bg); }
.logout { margin-left: auto; }
.linklike { background: none; border: 0; cursor: pointer; font: inherit; font-size: .95rem; color: var(--muted); }

/* cards and tiles */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.cards { display: grid; gap: .75rem; grid-template-columns: 1fr; margin-top: 1rem; }
@media (min-width: 640px) { .cards { grid-template-columns: repeat(2, 1fr); } }
a.market-card { display: block; color: inherit; }
a.market-card:active { transform: scale(.99); }
.row { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.market-card h2 { margin: 0 0 .4rem; font-size: 1.05rem; }
.chip { font-size: .75rem; padding: .1rem .55rem; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); }
.big { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; }
.badge { font-weight: 600; font-size: .9rem; }
.up { color: var(--up); } .down { color: var(--down); } .flat { color: var(--muted); }

.tiles { display: grid; gap: .75rem; grid-template-columns: 1fr 1fr; margin: 1rem 0; }
.tiles .tile:first-child { grid-column: 1 / -1; }
@media (min-width: 640px) {
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .tiles .tile:first-child { grid-column: auto; }
}

/* chart */
.range { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin: .25rem 0 .75rem; }
.range button { background: var(--card); color: var(--text); border: 0; padding: 0 1rem; min-height: 44px; font: inherit; cursor: pointer; }
.range button.active { background: var(--accent); color: #fff; }
.chart-wrap { position: relative; height: 260px; }
@media (min-width: 640px) { .chart-wrap { height: 340px; } }

/* table */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 1rem; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: .6rem .5rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; }

/* forms (16px text stops iPhones from zooming in on tap) */
input:not([type=checkbox]):not([type=hidden]), select {
  width: 100%; min-height: 44px; padding: .5rem .7rem; font-size: 16px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--card); color: var(--text);
}
main button[type=submit] {
  min-height: 44px; padding: 0 1.2rem; font: inherit; font-weight: 600;
  background: var(--accent); color: #fff; border: 0; border-radius: 10px; cursor: pointer;
}
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.ok { color: var(--up); } .bad { color: var(--down); }

.range a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 1rem;
  background: var(--card); color: var(--text);
}
.range a.active { background: var(--accent); color: #fff; }
.section { margin-top: 1rem; }
#data-table { scroll-margin-top: 70px; }

.controls { display: flex; flex-wrap: wrap; gap: .25rem 1rem; align-items: center; }
.h2 { font-size: 1.05rem; margin: 0 0 .5rem; }
.outlook-row {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .6rem 0; border-bottom: 1px solid var(--border);
}
.right { text-align: right; }
.big-sm { font-size: 1.2rem; font-weight: 700; }

.range button[hidden] { display: none; }