/* mtg-forecaster UI - dark, calm, card-first. Plain CSS, no build step.
   Readability rules: 15px+ body text, 1.6 line height, high-contrast secondary
   text, numbers in tabular figures, one accent colour for actions, green for money. */
:root {
  color-scheme: dark;
  --bg: #1c2025;
  --panel: #23282f;
  --panel-2: #2b313a;
  --panel-3: #323a45;
  --border: #353d48;
  --text: #f1f3f5;
  --muted: #aab3bf;
  --faint: #7d8794;
  --accent: #90caf9;          /* actions, links */
  --accent-ink: #0d1b2a;      /* text on accent buttons */
  --accent-soft: rgba(144, 202, 249, .14);
  --money: #66bb6a;
  --up: #66bb6a;
  --up-soft: rgba(102, 187, 106, .15);
  --down: #ef6c6c;
  --down-soft: rgba(239, 108, 108, .15);
  --warn: #ffb74d;
  --warn-soft: rgba(255, 183, 77, .14);
  --gold-soft: rgba(255, 183, 77, .08);
  --radius: 10px;
  --font: Roboto, "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.6 var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1 { font-size: 28px; line-height: 1.25; margin: 0 0 6px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 20px; line-height: 1.3; margin: 0 0 14px; font-weight: 700; }
h3 { font-size: 16px; margin: 0 0 8px; font-weight: 600; }
p { margin: 0 0 10px; }
code { font-family: var(--mono); font-size: .9em; background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.mono, .num { font-variant-numeric: tabular-nums; }
.money { color: var(--money); }
.up { color: var(--up); }
.down { color: var(--down); }
.warn-text { color: var(--warn); }
.icon { width: 20px; height: 20px; fill: currentColor; flex: none; }

/* ---------- App shell: sidebar + app bar ---------- */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: #1f242a; border-right: 1px solid var(--border); position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; padding: 0 18px; height: 60px; border-bottom: 1px solid var(--border); color: var(--text); }
.brand:hover { text-decoration: none; }
.brand .dot { width: 26px; height: 26px; border-radius: 7px; background: url(/static/icon-192.png) center/cover; flex: none; }
.nav { padding: 8px 0; }
.nav .section { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding: 16px 20px 6px; }
.nav a { display: flex; align-items: center; gap: 16px; padding: 10px 20px; color: var(--text); font-weight: 500; font-size: 15px; }
.nav a .icon { color: var(--muted); }
.nav a:hover { background: var(--panel-2); text-decoration: none; }
.nav a.active { background: var(--panel-3); }
.nav a.active, .nav a.active .icon { color: var(--accent); }
.nav .count { margin-left: auto; font-size: 13px; color: var(--faint); }
.appbar { position: sticky; top: 0; z-index: 10; height: 60px; display: flex; align-items: center; gap: 14px; padding: 0 28px;
  background: rgba(28, 32, 37, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.appbar form { flex: 1; max-width: 560px; position: relative; }
.appbar form .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.appbar input[type=search] { padding-left: 42px; height: 40px; border-radius: 20px; background: var(--panel); }
.main { min-width: 0; }
.content { padding: 28px 32px 72px; max-width: 1280px; margin: 0 auto; }
.page-head { margin-bottom: 22px; }
.page-head p { color: var(--muted); font-size: 16px; margin: 0; }
.section-title { display: flex; align-items: baseline; gap: 12px; margin: 34px 0 14px; }
.section-title h2 { margin: 0; }
.section-title a { margin-left: auto; font-weight: 500; }

/* ---------- Building blocks ---------- */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.panel + .panel { margin-top: 16px; }
.grid { display: grid; gap: 16px; align-items: start; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid.stretch { align-items: stretch; }
.grid.detail { grid-template-columns: minmax(200px, 320px) minmax(0, 1fr); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 14px; }

/* KPI tiles: big coloured number, small label under it */
.kpi { text-align: center; padding: 22px 16px; }
.kpi .value { font-size: 32px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; color: var(--accent); }
.kpi .value.money { color: var(--money); }
.kpi .label { color: var(--muted); font-size: 14px; margin-top: 6px; }
.kpi .delta { font-size: 13px; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* Quick actions */
.qa { display: block; text-align: center; padding: 26px 20px; color: var(--text); }
.qa:hover { background: var(--panel-2); text-decoration: none; }
.qa .icon { width: 36px; height: 36px; color: var(--accent); margin-bottom: 10px; }
.qa strong { display: block; font-size: 17px; margin-bottom: 4px; }
.qa span { color: var(--muted); font-size: 14px; }

/* Highlight cards (most valuable, top mover, best idea) */
.highlight { display: grid; grid-template-columns: 96px 1fr; gap: 16px; align-items: center; }
.highlight img { width: 96px; border-radius: 6px; }
.highlight .eyebrow { font-size: 13px; font-weight: 600; color: var(--warn); text-transform: uppercase; letter-spacing: .06em; }
.highlight .big { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.panel.gold { background: linear-gradient(0deg, var(--gold-soft), var(--gold-soft)), var(--panel); border-color: #5a4a2e; }
.panel.blue { background: linear-gradient(0deg, var(--accent-soft), var(--accent-soft)), var(--panel); border-color: #34506b; }
.panel.green { background: linear-gradient(0deg, var(--up-soft), var(--up-soft)), var(--panel); border-color: #2f5a3a; }

/* Forms */
input, select, textarea, button { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type=search], input[type=text], input[type=password] { width: 100%; }
label { font-size: 13px; color: var(--muted); display: block; margin-bottom: 5px; }
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--accent); color: var(--accent-ink);
  border-color: transparent; cursor: pointer; font-weight: 600; font-size: 14px; letter-spacing: .02em; padding: 9px 16px; border-radius: 8px; }
.btn:hover, button:hover { filter: brightness(1.08); text-decoration: none; }
.btn.secondary, button.secondary { background: transparent; color: var(--accent); border-color: #3d5670; }
.btn.ghost, button.ghost { background: transparent; color: var(--muted); border-color: transparent; }
button[disabled] { opacity: .5; cursor: default; }

/* Segmented control (tabs that look like MUI toggle buttons) */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; flex-wrap: wrap; }
.seg a { padding: 8px 16px; color: var(--muted); font-weight: 600; font-size: 14px; }
.seg a + a { border-left: 1px solid var(--border); }
.seg a.active { background: var(--accent); color: var(--accent-ink); }
.seg a:hover { text-decoration: none; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--text); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; color: var(--faint); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
td.num, th.num { text-align: right; white-space: nowrap; }
table tr:hover td { background: rgba(255, 255, 255, .025); }
.table-wrap { overflow-x: auto; }
.thumb { width: 40px; border-radius: 4px; display: block; }
.cardimg { width: 100%; max-width: 320px; border-radius: 4.75% / 3.5%; box-shadow: 0 8px 28px rgba(0, 0, 0, .45); }

/* Card grid (binder view) */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 20px; }
.tile { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 10px 10px 14px; text-align: center; }
.tile a.img img { width: 100%; display: block; aspect-ratio: 488 / 680; object-fit: cover; border-radius: 4.75% / 3.5%; background: var(--panel-2); }
.tile .sealed-img { aspect-ratio: 488 / 680; display: grid; place-items: center; background: #fff; border-radius: 8px; overflow: hidden; }
.tile .sealed-img img { width: 100%; object-fit: contain; }
.tile .name { font-weight: 700; font-size: 15px; margin-top: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .set { font-style: italic; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .price { color: var(--accent); font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stepper { display: inline-flex; align-items: center; gap: 2px; margin-top: 8px; border: 1px solid var(--border); border-radius: 8px; }
.stepper button { background: transparent; color: var(--muted); padding: 2px 10px; font-size: 18px; line-height: 1.2; border: 0; }
.stepper button:hover { color: var(--text); }
.stepper span { min-width: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Badges, chips, outlook pills */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .03em; white-space: nowrap; text-transform: uppercase; }
.badge.strong_buy { background: var(--up); color: #0c1f10; }
.badge.buy { background: var(--up-soft); color: var(--up); }
.badge.watch { background: var(--accent-soft); color: var(--accent); }
.badge.hold { background: var(--panel-3); color: var(--muted); }
.badge.sell { background: var(--down); color: #2a0b0b; }
.badge.avoid { background: var(--down-soft); color: var(--down); }
.chip { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 12px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip:hover { text-decoration: none; }
.outlook { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; border: 1px solid var(--border); color: var(--faint); font-variant-numeric: tabular-nums; }
.pill.up { color: var(--up); border-color: #2f5a3a; background: var(--up-soft); }
.pill.down { color: var(--down); border-color: #6b3434; background: var(--down-soft); }

/* Opportunity card */
.opp { display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; gap: 18px; align-items: start; }
.opp > a img { width: 84px; border-radius: 5px; display: block; }
.opp .title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.opp .title strong { font-size: 17px; }
.opp .headline { font-size: 16px; font-weight: 600; margin: 6px 0 10px; color: var(--text); }
.opp .meta { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.reasons { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.reasons li { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 8px; }
.reasons li .mark { font-weight: 700; line-height: 1.6; }
.reasons li.bull .mark { color: var(--up); }
.reasons li.bear .mark { color: var(--down); }
.reasons li.info .mark { color: var(--faint); }
.reasons .rt { font-weight: 600; }
.reasons .rx { color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.reasons .rx.open { -webkit-line-clamp: unset; display: block; }
.opp .aside { text-align: right; min-width: 132px; }
.opp .aside .price { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.conf { display: inline-flex; gap: 3px; vertical-align: middle; }
.conf i { width: 7px; height: 7px; border-radius: 50%; background: var(--panel-3); }
.conf i.on { background: var(--accent); }

.signal { border-left: 3px solid var(--border); padding: 8px 0 8px 14px; }
.signal + .signal { margin-top: 6px; }
.signal.bull { border-color: var(--up); }
.signal.bear { border-color: var(--down); }
.signal.neutral { border-color: var(--accent); }
.signal .title { font-weight: 600; }

.callout { background: var(--accent-soft); border: 1px solid #34506b; border-radius: var(--radius); padding: 14px 16px; }
.callout.warn { background: var(--warn-soft); border-color: #5a4a2e; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.flash { background: var(--up-soft); color: var(--up); border: 1px solid #2f5a3a; padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; }
.progress { height: 10px; border-radius: 5px; background: var(--panel-3); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); }

/* Charts */
svg.chart { width: 100%; height: auto; display: block; }
svg.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }
svg.chart .line.alt { stroke: var(--faint); stroke-dasharray: 4 3; stroke-width: 1.5; }
svg.chart .area { fill: var(--accent); opacity: .08; }
svg.chart .grid-line { stroke: var(--border); stroke-width: 1; }
svg.chart text { fill: var(--faint); font-size: 11px; font-family: var(--font); }
svg.chart .event { stroke: var(--warn); stroke-dasharray: 3 3; }
svg.spark { width: 90px; height: 24px; }
svg.spark path { fill: none; stroke-width: 1.5; }
.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut-wrap svg { width: 150px; height: 150px; flex: none; }
.legend { display: grid; gap: 6px; font-size: 14px; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }

details summary { cursor: pointer; font-weight: 600; }
.prose { max-width: 860px; }
.prose h2 { margin-top: 28px; }
.prose li { margin: 4px 0; }

/* Status block, menus, phone navigation */
.status { padding: 16px 20px 20px; margin-top: auto; border-top: 1px solid var(--border); line-height: 1.7; }
.status button { padding: 5px 12px; font-size: 13px; }
.mobile-only { display: none; }
.tabbar { display: none; }
.menu a { display: flex; align-items: center; gap: 14px; padding: 15px 18px; border-bottom: 1px solid var(--border); color: var(--text); font-weight: 500; }
.menu a .icon { color: var(--muted); }
.menu a:last-child { border-bottom: 0; }
.menu a:hover { background: var(--panel-2); text-decoration: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .mobile-only { display: block; }
  .appbar { padding: 0 14px; }
  .appbar .brand { display: flex; border: 0; padding: 0; height: auto; }
  .content { padding: 18px 16px calc(92px + env(safe-area-inset-bottom)); }
  h1 { font-size: 23px; }
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .grid.cols-2, .grid.cols-3, .grid.detail { grid-template-columns: minmax(0, 1fr); }
  .grid.detail .cardimg { max-width: 260px; margin: 0 auto; display: block; }
  .kpi { padding: 16px 10px; }
  .kpi .value { font-size: 24px; }
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .panel { padding: 16px; }
  .opp { grid-template-columns: 64px minmax(0, 1fr); gap: 12px; }
  .opp > a img { width: 64px; }
  .opp .aside { grid-column: 1 / -1; text-align: left; display: flex; gap: 14px; align-items: baseline; flex-wrap: wrap; }
  th, td { padding: 9px 7px; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: #1f242a; border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); padding: 4px 0; }
  .tabbar a .icon { width: 22px; height: 22px; }
  .tabbar a.active { color: var(--accent); }
  .tabbar a:hover { text-decoration: none; }
}
@media (min-width: 901px) { .appbar .brand { display: none; } }
.grid > .panel, .grid > * + .panel { margin-top: 0; }
@media (max-width: 900px) {
  .qa-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; gap: 8px; }
  .qa-grid .qa { padding: 14px 6px; }
  .qa-grid .qa .icon { width: 28px; height: 28px; margin-bottom: 4px; }
  .qa-grid .qa strong { font-size: 13px; line-height: 1.3; margin: 0; }
  .qa-grid .qa span { display: none; }
  .highlight { grid-template-columns: 72px 1fr; }
  .highlight img { width: 72px; }
}

/* Sets, ownership badges, bulk editing */
.set-icon { width: 22px; height: 22px; filter: invert(1); opacity: .9; vertical-align: middle; flex: none; }
.set-icon.big { width: 56px; height: 56px; }
.set-link { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 500; }
.set-link:hover { color: var(--accent); }
.set-head { display: flex; gap: 18px; align-items: center; }
.tile { position: relative; }
.tile .pick { position: absolute; top: 16px; left: 16px; width: 20px; height: 20px; z-index: 2; accent-color: var(--accent); cursor: pointer; }
.owned-badge, .cond-badge { position: absolute; top: 14px; z-index: 2; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 1px 8px; }
.owned-badge { right: 14px; background: var(--up); color: #0c1f10; }
.cond-badge { right: 14px; background: rgba(20, 24, 29, .85); color: var(--text); border: 1px solid var(--border); }
.owned-pill { background: var(--up-soft); color: var(--up); font-weight: 700; border-radius: 999px; padding: 1px 9px; }
.rarity { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #9aa3ad; vertical-align: middle; }
.rarity.uncommon { background: #b8c7d3; } .rarity.rare { background: #d9b25f; } .rarity.mythic { background: #e2663b; } .rarity.special, .rarity.bonus { background: #b36bd6; }
.small-btn { padding: 5px 12px; font-size: 13px; }
.icon-btn { padding: 4px 10px; }
button.danger, .btn.danger { background: transparent; color: var(--down); border-color: #6b3434; }
button.danger:hover { background: var(--down-soft); }
.bulkbar { position: sticky; top: 64px; z-index: 5; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px;
  padding: 10px 14px; background: rgba(35, 40, 47, .96); border: 1px solid var(--border); border-radius: var(--radius); backdrop-filter: blur(6px); }
.bulkbar select { padding: 7px 10px; }
.holding-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; padding: 12px 0; border-bottom: 1px solid var(--border); }
.holding-row:last-of-type { border-bottom: 0; }
label.inline { display: flex; flex-direction: column; gap: 3px; margin: 0; }
@media (max-width: 900px) { .bulkbar { top: 64px; } .bulkbar .spacer { display: none; } .set-icon.big { width: 40px; height: 40px; } }
.tile-controls { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 8px; }
.tile-controls .stepper { margin-top: 0; }
.tile-controls .pick { position: static; width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.cond-chip { font-size: 12px; font-weight: 700; color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; }
