@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter-var.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #080B12;
  --card: #151A26;
  --card2: #171D2B;
  --accent: #8B5CF6;
  --pos: #22C55E;
  --neg: #EF4444;
  --text: #E9EDF6;
  --muted: #8B93A7;
  --border: rgba(255, 255, 255, 0.07);
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
#app { max-width: 720px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  background: rgba(8, 11, 18, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.app-icon { width: 34px; height: 34px; border-radius: 9px; }
.topbar-title { font-weight: 700; font-size: 14px; letter-spacing: 0.2px; }
.topbar-sub { font-size: 11px; color: var(--muted); }
.topbar-right { text-align: right; }
.hdr-price { font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.hdr-change { font-size: 12px; font-variant-numeric: tabular-nums; }
.up { color: var(--pos); } .down { color: var(--neg); }

main { flex: 1; padding: 14px 14px calc(78px + env(safe-area-inset-bottom, 0px)); }
.tab { animation: fade 0.22s ease; display: flex; flex-direction: column; gap: 12px; }
.tab[hidden] { display: none; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Cards */
.card {
  background: linear-gradient(180deg, var(--card2), var(--card));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}
.card.subtle { background: var(--card); box-shadow: none; }
.card-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.9px; color: var(--muted); margin-bottom: 10px; }
.muted { color: var(--muted); } .small { font-size: 13px; }

/* Hero */
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.hero-name { font-weight: 600; font-size: 15px; }
.hero-tick { color: var(--muted); font-size: 12px; margin-top: 2px; }
.status { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); background: rgba(255,255,255,0.05); padding: 5px 9px; border-radius: 999px; white-space: nowrap; }
.status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.status.open .dot { background: var(--pos); box-shadow: 0 0 8px var(--pos); }
.status.pre .dot, .status.post .dot { background: #F59E0B; box-shadow: 0 0 8px #F59E0B; }
.hero-price-row { display: flex; align-items: baseline; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.hero-price { font-size: 38px; font-weight: 800; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.hero-change { font-size: 15px; font-weight: 600; padding: 4px 10px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.hero-change.up { background: rgba(34,197,94,0.14); color: var(--pos); }
.hero-change.down { background: rgba(239,68,68,0.14); color: var(--neg); }
.hero-meta { margin-top: 10px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.hero-ext { margin-top: 6px; font-size: 12px; color: #F59E0B; }
.hero-updated { margin-top: 12px; font-size: 11px; color: var(--muted); }

/* Charts */
.mini-chart { height: 150px; position: relative; }
.big-chart { height: 380px; position: relative; }
@media (max-width: 480px) { .big-chart { height: 320px; } }
.chart-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; }
.chart-wrap { position: relative; }
.chart-legend { position: absolute; top: 6px; left: 8px; z-index: 5; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; pointer-events: none; }
.chart-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.ranges { display: flex; gap: 4px; background: rgba(255,255,255,0.04); border-radius: 10px; padding: 3px; }
.ranges button, .mode-toggle button, .seg button {
  background: transparent; border: 0; color: var(--muted); font: inherit; font-size: 12px; font-weight: 600;
  padding: 6px 10px; border-radius: 8px; cursor: pointer;
}
.ranges button.on { background: var(--accent); color: #fff; }
.mode-toggle { display: flex; gap: 4px; background: rgba(255,255,255,0.04); border-radius: 10px; padding: 3px; }
.mode-toggle button.on { background: rgba(139,92,246,0.25); color: var(--accent); }
.chart-note { margin-top: 10px; font-size: 11px; color: var(--muted); }
.dayrange { margin-top: 10px; display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.dayrange .bar { flex: 1; height: 4px; border-radius: 2px; background: rgba(255,255,255,0.08); position: relative; }
.dayrange .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 2px; background: var(--accent); }

/* Metrics */
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.metric { background: linear-gradient(180deg, var(--card2), var(--card)); border: 1px solid var(--border); border-radius: var(--radius); padding: 13px 14px; }
.metric .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.7px; }
.metric .v { font-size: 17px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.metric .s { font-size: 11px; color: var(--muted); margin-top: 2px; }
.analyst { font-size: 13px; }
.analyst .big { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.analyst-row { display: flex; justify-content: space-between; padding: 6px 0; border-top: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.analyst-row span:last-child { font-weight: 600; }

/* News */
.section-head { display: flex; justify-content: space-between; align-items: baseline; padding: 2px 2px 0; }
.section-head h2 { font-size: 17px; margin: 0; }
.section-sub { font-size: 11px; color: var(--muted); }
.news-list { display: flex; flex-direction: column; gap: 10px; }
.news-item { display: block; text-decoration: none; color: inherit; background: linear-gradient(180deg, var(--card2), var(--card)); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.news-item:active { transform: scale(0.99); }
.news-title { font-weight: 600; font-size: 14.5px; line-height: 1.35; }
.news-meta { margin-top: 6px; font-size: 11.5px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.news-src { color: var(--accent); font-weight: 600; }

/* Alerts */
.seg { display: flex; gap: 4px; background: rgba(255,255,255,0.04); border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.seg button { flex: 1; }
.seg button.on { background: var(--accent); color: #fff; }
.alert-input-row { display: flex; gap: 8px; align-items: center; }
.alert-prefix { color: var(--muted); font-weight: 600; }
#alertValue {
  flex: 1; background: rgba(255,255,255,0.05); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font: inherit; font-size: 16px; padding: 10px 12px; outline: none; min-width: 0;
}
#alertValue:focus { border-color: var(--accent); }
.btn {
  background: var(--accent); color: #fff; border: 0; border-radius: 10px; font: inherit; font-weight: 600;
  padding: 10px 16px; cursor: pointer; font-size: 14px;
}
.btn.ghost { background: rgba(255,255,255,0.06); color: var(--text); }
.alert-list { display: flex; flex-direction: column; gap: 8px; }
.alert-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: rgba(255,255,255,0.04); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.alert-item .desc { flex: 1; }
.alert-item .del { background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; padding: 2px 6px; }
.alert-item .armed { font-size: 10.5px; color: var(--pos); text-transform: uppercase; letter-spacing: 0.6px; }

/* Switch */
.switch-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; font-size: 14px; cursor: pointer; }
.switch-row input { display: none; }
.switch { width: 44px; height: 26px; border-radius: 13px; background: rgba(255,255,255,0.12); position: relative; transition: background 0.2s; flex-shrink: 0; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.switch-row input:checked + .switch { background: var(--accent); }
.switch-row input:checked + .switch::after { transform: translateX(18px); }

/* Bottom nav */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; justify-content: space-around;
  max-width: 720px; margin: 0 auto;
  background: rgba(13, 17, 26, 0.92);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
}
.bottomnav button {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 10px; font-weight: 600; padding: 4px 10px; font-family: inherit;
}
.bottomnav button svg { width: 22px; height: 22px; fill: currentColor; }
.bottomnav button.on { color: var(--accent); }

/* Toast */
.toast {
  position: fixed; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%);
  background: #1E2637; border: 1px solid var(--border); color: var(--text);
  padding: 11px 16px; border-radius: 12px; font-size: 13px; z-index: 50; max-width: 88vw;
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
}

.offline-banner { background: rgba(239,68,68,0.15); color: #FCA5A5; text-align: center; font-size: 12px; padding: 6px; border-radius: 8px; }
