:root {
  --bg: var(--tg-theme-bg-color, #f5f5f1);
  --surface: var(--tg-theme-secondary-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #171917);
  --muted: var(--tg-theme-hint-color, #747a75);
  --accent: var(--tg-theme-button-color, #1e7652);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --border: color-mix(in srgb, var(--text) 10%, transparent);
  --danger: #c8413a; --warn: #c98516; --good: #25835d;
  --shadow: 0 8px 28px rgba(22, 35, 28, .07);
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; color: var(--text); background: var(--bg); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; min-height: 100vh; }
button, input, select { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; padding: calc(14px + env(safe-area-inset-top)) 18px 12px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(18px); }
.topbar h1 { margin: 0; font-size: 22px; letter-spacing: -.04em; }
.eyebrow { color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .18em; }
.icon-button { width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); font-size: 22px; }
main { max-width: 860px; margin: auto; padding: 4px 14px calc(92px + env(safe-area-inset-bottom)); }
.gate { min-height: 60vh; display: grid; place-content: center; justify-items: center; text-align: center; color: var(--muted); }
.gate h2 { color: var(--text); margin-bottom: 4px; }
.status-icon { font-size: 40px; }
.loader { width: 30px; height: 30px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.diag-code { font-size: 11px; color: var(--muted); font-family: ui-monospace, monospace; margin-top: 6px; }
.segmented { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); margin-bottom: 14px; }
.segmented button { border: 0; min-height: 40px; border-radius: 10px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 650; }
.segmented button.active { background: var(--accent); color: var(--accent-text); }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 2px 10px; }
.section-title h2 { margin: 0; font-size: 19px; letter-spacing: -.025em; }
.section-title small, .muted, .updated { color: var(--muted); }
.updated { text-align: center; font-size: 12px; margin: 18px 0; }
.notice { border-radius: 16px; padding: 14px 15px; margin: 10px 0 14px; background: color-mix(in srgb, var(--warn) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 22%, transparent); }
.notice.danger { background: color-mix(in srgb, var(--danger) 11%, var(--surface)); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.notice b { display: block; font-size: 16px; margin-bottom: 5px; }
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.card { min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 17px; padding: 14px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { margin: 5px 0 2px; font-size: 24px; font-weight: 750; letter-spacing: -.04em; }
.trend { font-size: 12px; font-weight: 650; }
.trend.up { color: var(--good); } .trend.down { color: var(--danger); } .trend.flat { color: var(--muted); }
.chart-card { padding: 12px 8px 8px; overflow: hidden; }
.chart-controls { display: flex; gap: 7px; padding: 3px 7px 10px; flex-wrap: wrap; }
.chip, .filter { min-height: 38px; border: 1px solid var(--border); border-radius: 999px; padding: 0 13px; background: var(--surface); }
.chip.active { color: var(--accent-text); background: var(--accent); border-color: var(--accent); }
svg.chart { width: 100%; height: 190px; display: block; overflow: visible; }
.axis { stroke: var(--border); stroke-width: 1; }.line { fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.quick-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.quick { min-height: 74px; border: 0; text-align: left; font-weight: 700; background: var(--surface); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); }
.funnel { display: grid; gap: 8px; }
.funnel-row { display: grid; grid-template-columns: 88px 1fr auto; gap: 8px; align-items: center; }
.bar { height: 10px; border-radius: 6px; background: color-mix(in srgb, var(--accent) 18%, var(--surface)); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.toolbar { display: grid; gap: 9px; margin-bottom: 12px; }
.search { width: 100%; min-height: 46px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 14px; padding: 0 14px; }
.filters { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 3px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.list { display: grid; gap: 10px; }
.item-card { cursor: pointer; }
.item-top { display: flex; gap: 10px; justify-content: space-between; align-items: flex-start; }
.item-card h3 { margin: 0 0 3px; font-size: 15px; line-height: 1.3; }
.badge { flex: none; display: inline-block; border-radius: 999px; padding: 4px 8px; font-size: 10px; font-weight: 800; letter-spacing: .03em; background: color-mix(in srgb, var(--muted) 12%, transparent); }
.badge.GOOD { color: var(--good); }.badge.BAD,.badge.STOP_CANDIDATE { color: var(--danger); }.badge.WATCH { color: var(--warn); }
.metrics-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-top: 12px; }
.metric-mini { min-width: 0; }.metric-mini span { display: block; color: var(--muted); font-size: 10px; }.metric-mini b { font-size: 14px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.detail-grid .card span { display: block; color: var(--muted); font-size: 11px; }.detail-grid .card b { font-size: 15px; }
.back { border: 0; background: none; color: var(--accent); padding: 6px 0 12px; font-weight: 650; }
.external-link { display: block; text-align: center; text-decoration: none; min-height: 46px; line-height: 46px; border-radius: 13px; color: var(--accent-text); background: var(--accent); font-weight: 700; margin-top: 12px; }
.status-list { display: grid; gap: 9px; }.status-row { display: flex; justify-content: space-between; align-items: center; }.status-row strong { font-size: 14px; }.status-row small { display: block; color: var(--muted); }
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(4, 1fr); padding: 7px 8px calc(7px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 94%, transparent); border-top: 1px solid var(--border); backdrop-filter: blur(20px); }
.bottom-nav button { min-height: 52px; border: 0; background: none; color: var(--muted); font-size: 10px; font-weight: 650; }.bottom-nav button span { display: block; font-size: 21px; line-height: 24px; }.bottom-nav button.active { color: var(--accent); }
@media (min-width: 680px) { .kpis { grid-template-columns: repeat(4, 1fr); }.quick-grid { grid-template-columns: repeat(4, 1fr); }.list { grid-template-columns: repeat(2, minmax(0,1fr)); }.detail-grid { grid-template-columns: repeat(4,1fr); } }
