:root {
  --bg: #111613;
  --panel: #19201c;
  --panel-2: #212a25;
  --line: #2c3731;
  --text: #e8eee9;
  --muted: #93a198;
  --accent: #6fcf97;
  --up: #4fc483;
  --down: #f0686a;
  --warn: #e7b85a;
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6f4; --panel: #ffffff; --panel-2: #eef2ef; --line: #dbe2dd;
    --text: #17201b; --muted: #5d6b62; --accent: #23824f; --up: #1d8a4f; --down: #c93c3f; --warn: #a86f00;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.title { display: flex; align-items: baseline; gap: 10px; }
h1 { font-size: 20px; margin: 0; letter-spacing: -0.01em; }
.status { font-size: 12px; color: var(--muted); }
.status.live::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--up); margin-right: 6px; vertical-align: 1px; }
.status.stale::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); margin-right: 6px; vertical-align: 1px; }
.icon-btn { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; width: 38px; height: 38px; font-size: 18px; cursor: pointer; }
.icon-btn.spin { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

main { max-width: 980px; margin: 0 auto; padding: 14px 14px 24px; }
.tab { display: none; }
.tab.active { display: block; }

h2 { font-size: 15px; margin: 22px 4px 10px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
h2:first-child { margin-top: 6px; }
.note { font-size: 13px; color: var(--muted); margin: 6px 4px 12px; line-height: 1.45; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi .label { font-size: 12px; color: var(--muted); }
.kpi .value { font-size: 22px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 10px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; cursor: pointer; transition: border-color .15s; }
.card:hover { border-color: var(--accent); }
.card .row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card .tkr { font-weight: 700; font-size: 17px; }
.card .name { color: var(--muted); font-size: 13px; }
.card .price { font-weight: 650; font-variant-numeric: tabular-nums; }
.card .meta { font-size: 13px; color: var(--muted); margin-top: 8px; line-height: 1.4; }

.chg { font-size: 13px; font-variant-numeric: tabular-nums; }
.up { color: var(--up); }
.down { color: var(--down); }
.warn { color: var(--warn); }

.pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.pill.good { color: var(--up); border-color: color-mix(in srgb, var(--up) 40%, transparent); }
.pill.bad { color: var(--down); border-color: color-mix(in srgb, var(--down) 40%, transparent); }
.pill.mid { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }

.checks { list-style: none; padding: 0; margin: 10px 0 0; font-size: 13px; }
.checks li { padding: 3px 0; display: flex; gap: 8px; }
.checks li .ok { color: var(--up); }
.checks li .no { color: var(--down); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel-2); }
tr.total td { font-weight: 700; }

.news-item { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; }
.news-item a { color: var(--text); text-decoration: none; font-weight: 600; line-height: 1.35; }
.news-item a:hover { color: var(--accent); }
.news-item .src { font-size: 12px; color: var(--muted); margin-top: 4px; }
.news-item p { font-size: 13px; color: var(--muted); margin: 6px 0 0; line-height: 1.4; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 10px; scrollbar-width: none; }
.chips button { flex: none; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px; font-size: 13px; cursor: pointer; }
.chips button.active { background: var(--accent); color: #0d1410; border-color: var(--accent); font-weight: 600; }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 6;
  display: flex; justify-content: space-around;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
@media (min-width: 800px) { .tabs { padding-left: calc(50% - 400px); padding-right: calc(50% - 400px); } }
.tabs button { flex: 1; background: none; border: none; color: var(--muted); font-size: 13px; font-weight: 600; padding: 10px 4px; border-radius: 10px; cursor: pointer; }
.tabs button.active { color: var(--accent); background: var(--panel-2); }

.sheet { position: fixed; inset: 0; z-index: 10; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; }
.sheet.hidden { display: none; }
.sheet-inner { position: relative; background: var(--bg); width: 100%; max-width: 760px; max-height: 92vh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 20px 18px calc(24px + env(safe-area-inset-bottom)); border: 1px solid var(--line); }
@media (min-width: 800px) { .sheet { align-items: center; } .sheet-inner { border-radius: 18px; } }
.close { position: sticky; top: 0; float: right; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 50%; width: 34px; height: 34px; font-size: 20px; cursor: pointer; }
.sheet h3 { margin: 0 0 2px; font-size: 22px; }
.field { margin: 14px 0; }
.field .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 3px; }
.field .v { font-size: 14px; line-height: 1.5; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-top: 12px; }

.banner { background: var(--panel-2); border: 1px dashed var(--line); border-radius: var(--radius); padding: 12px 14px; font-size: 13px; color: var(--muted); line-height: 1.45; margin-bottom: 10px; }
.empty { color: var(--muted); font-size: 14px; padding: 18px 4px; }
