/* ДзенСтат 2.0 — Система тем */

/* ===== CSS Variables ===== */
:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel2: #1e222b;
  --panel3: #252a36;
  --line: #2a2f3a;
  --line2: #353b4a;
  --txt: #e6e8ec;
  --txt2: #c5c9d3;
  --mut: #8b93a3;
  --mut2: #6b7280;
  --acc: #ffd23f;
  --acc2: #3b82f6;
  --acc3: #8b5cf6;
  --ok: #22c55e;
  --err: #ef4444;
  --warn: #f59e0b;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,.3), 0 1px 2px rgba(0,0,0,.2);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.4);
  --transition: 0.2s ease;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, Consolas, monospace;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body { background: var(--bg); color: var(--txt); font-family: var(--font); line-height: 1.5; min-height: 100vh; }
a { color: var(--acc2); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--acc); }
::selection { background: var(--acc); color: #000; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--mut2); }

/* ===== Auth Screen ===== */
.auth-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; background: linear-gradient(135deg, var(--bg) 0%, #1a1d27 100%); }
.auth-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 40px; width: 100%; max-width: 420px; box-shadow: var(--shadow-lg); }
.auth-card h1 { font-size: 28px; font-weight: 800; margin-bottom: 4px; letter-spacing: -0.5px; }
.auth-card h1 span { color: var(--acc); }
.auth-card .sub { color: var(--mut); margin-bottom: 28px; font-size: 14px; }
.auth-card label { display: block; font-weight: 600; margin: 16px 0 6px; font-size: 13px; color: var(--txt2); }
.auth-card input { width: 100%; background: var(--panel2); border: 1px solid var(--line); color: var(--txt); border-radius: var(--radius-sm); padding: 12px 14px; font: inherit; font-size: 14px; transition: border-color var(--transition); }
.auth-card input:focus { border-color: var(--acc); outline: none; box-shadow: 0 0 0 3px rgba(255,210,63,.15); }
.auth-card .btn { width: 100%; background: var(--acc); color: #000; border: 0; border-radius: var(--radius-sm); padding: 14px; font-weight: 700; font-size: 15px; cursor: pointer; margin-top: 20px; transition: all var(--transition); }
.auth-card .btn:hover { background: #ffe066; transform: translateY(-1px); }
.auth-card .btn:active { transform: translateY(0); }
.auth-card .btn:disabled { opacity: .5; cursor: default; transform: none; }
.auth-card .switch { text-align: center; margin-top: 20px; font-size: 13px; color: var(--mut); }
.auth-card .switch a { color: var(--acc); cursor: pointer; font-weight: 600; }
.auth-card .error { background: rgba(239,68,68,.12); color: #fca5a5; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-top: 10px; display: none; border: 1px solid rgba(239,68,68,.2); }
.auth-card .features { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.auth-card .features div { font-size: 13px; color: var(--mut); padding: 4px 0; display: flex; align-items: center; gap: 8px; }
.auth-card .features div::before { content: '✓'; color: var(--ok); font-weight: 700; font-size: 14px; }

/* ===== Header ===== */
header { display: flex; align-items: center; gap: 16px; padding: 12px 24px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 100; backdrop-filter: blur(12px); }
header .logo { font-weight: 800; font-size: 20px; letter-spacing: -0.5px; white-space: nowrap; }
header .logo span { color: var(--acc); }
.tabs { display: flex; gap: 2px; margin-left: 20px; flex-wrap: wrap; overflow-x: auto; }
.tab { padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer; color: var(--mut); font-weight: 600; font-size: 13px; white-space: nowrap; transition: all var(--transition); border: 1px solid transparent; }
.tab:hover { color: var(--txt2); background: var(--panel2); }
.tab.active { background: var(--panel2); color: var(--txt); border-color: var(--line); }
.user-menu { margin-left: auto; display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.user-menu .name { font-size: 13px; color: var(--mut); }
.user-menu .logout { color: var(--err); cursor: pointer; font-size: 12px; font-weight: 600; padding: 6px 10px; border-radius: var(--radius-sm); transition: all var(--transition); }
.user-menu .logout:hover { background: rgba(239,68,68,.1); }

/* ===== Main ===== */
main { padding: 24px; max-width: 1280px; margin: 0 auto; }
.screen { display: none; animation: fadeIn 0.2s ease; } .screen.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
h2 { font-size: 20px; font-weight: 700; margin-bottom: 4px; letter-spacing: -0.3px; }
.section-desc { color: var(--mut); margin-bottom: 20px; font-size: 13px; line-height: 1.6; max-width: 700px; }
.section-desc b { color: var(--txt2); font-weight: 600; }

/* ===== Cards ===== */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; transition: border-color var(--transition); }
.card:hover { border-color: var(--line2); }
.card-title { font-weight: 700; font-size: 15px; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.card-help { color: var(--mut); font-size: 12px; line-height: 1.5; margin-bottom: 14px; }

/* ===== Form Elements ===== */
label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; color: var(--txt2); }
input[type=text], input[type=number], input[type=url], textarea, select {
  width: 100%; background: var(--panel2); border: 1px solid var(--line); color: var(--txt);
  border-radius: var(--radius-sm); padding: 10px 12px; font: inherit; font-size: 13px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, textarea:focus, select:focus { border-color: var(--acc); outline: none; box-shadow: 0 0 0 3px rgba(255,210,63,.1); }
textarea { min-height: 90px; resize: vertical; }
select { cursor: pointer; }

/* ===== Buttons ===== */
.btn { background: var(--acc); color: #000; border: 0; border-radius: var(--radius-sm); padding: 10px 18px; font-weight: 700; cursor: pointer; font-size: 13px; transition: all var(--transition); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { background: #ffe066; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.sec { background: var(--panel2); color: var(--txt); border: 1px solid var(--line); }
.btn.sec:hover { background: var(--panel3); border-color: var(--line2); }
.btn.danger { background: rgba(239,68,68,.12); color: #fca5a5; border: 1px solid rgba(239,68,68,.2); }
.btn.danger:hover { background: rgba(239,68,68,.2); }
.btn.sm { padding: 6px 12px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; transform: none; }

/* ===== KPI Cards ===== */
.kpis { display: flex; gap: 12px; flex-wrap: wrap; }
.kpi { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; min-width: 140px; flex: 1; }
.kpi .v { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--mut); font-size: 12px; margin-top: 2px; }

/* ===== Toolbar ===== */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }

/* ===== Table ===== */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th { color: var(--mut); font-weight: 600; cursor: pointer; user-select: none; position: sticky; top: 0; background: var(--panel); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:hover td { background: var(--panel2); }

/* ===== Log ===== */
.log { background: #0a0c10; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; height: 160px; overflow: auto; font-family: var(--font-mono); font-size: 12px; color: var(--mut); white-space: pre-wrap; line-height: 1.6; }

/* ===== Row Layout ===== */
.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.row > div { flex: 1; min-width: 160px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media(max-width: 780px) { .grid2 { grid-template-columns: 1fr; } }

/* ===== Segment Control ===== */
.seg { display: inline-flex; gap: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { background: var(--panel2); color: var(--mut); border: 0; padding: 9px 16px; cursor: pointer; font-weight: 600; font-size: 13px; transition: all var(--transition); }
.seg button:hover { color: var(--txt2); }
.seg button.on { background: var(--acc); color: #000; }

/* ===== Channel Cards ===== */
.channel-card { display: flex; gap: 16px; align-items: center; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; background: var(--panel); transition: all var(--transition); }
.channel-card:hover { border-color: var(--line2); background: var(--panel2); }
.channel-card .info { flex: 1; min-width: 0; }
.channel-card .name { font-weight: 700; font-size: 15px; }
.channel-card .meta { color: var(--mut); font-size: 12px; margin-top: 3px; }
.channel-card .metrics { display: flex; gap: 16px; margin-top: 10px; flex-wrap: wrap; }
.channel-card .metric .val { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.channel-card .metric .lbl { font-size: 10px; color: var(--mut); text-transform: uppercase; letter-spacing: 0.5px; }
.channel-card .actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ===== Chips ===== */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 12px; margin: 3px 4px 3px 0; transition: all var(--transition); }
.chip.on { background: var(--acc); color: #000; border-color: var(--acc); }

/* ===== Heatmap ===== */
.hm { display: grid; grid-template-columns: 34px repeat(24, 1fr); gap: 2px; font-size: 10px; }
.hm .hc { aspect-ratio: 1/1; border-radius: 3px; background: var(--panel2); display: flex; align-items: center; justify-content: center; color: #0a0c10; font-weight: 700; cursor: default; transition: transform var(--transition); }
.hm .hc:hover { transform: scale(1.2); }
.hm .lbl { color: var(--mut); display: flex; align-items: center; justify-content: flex-end; padding-right: 4px; font-size: 11px; }
.hm .hh { color: var(--mut); text-align: center; font-size: 10px; }

/* ===== Bar ===== */
.bar { height: 8px; background: var(--panel2); border-radius: 4px; overflow: hidden; min-width: 60px; }
.bar > i { display: block; height: 100%; background: var(--acc); border-radius: 4px; transition: width 0.5s ease; }

/* ===== Stella Badge ===== */
.stella-badge { color: var(--acc); font-weight: 700; }
.stella-card { border-left: 3px solid var(--acc); }

/* ===== Misc ===== */
.muted { color: var(--mut); }
.ok { color: var(--ok); }
.hidden { display: none !important; }
.ext-token-box { display: flex; gap: 8px; align-items: center; }
.ext-token-box input { flex: 1; font-family: var(--font-mono); font-size: 12px; }
details { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 14px; margin: 8px 0; background: var(--panel2); }
details summary { cursor: pointer; font-weight: 600; font-size: 13px; }
details .body { white-space: pre-wrap; color: var(--mut); margin-top: 10px; max-height: 300px; overflow: auto; font-size: 13px; line-height: 1.6; }

/* ===== Info Box ===== */
.info-box { background: rgba(59,130,246,.08); border: 1px solid rgba(59,130,246,.2); border-radius: var(--radius-sm); padding: 12px 16px; font-size: 13px; color: var(--txt2); line-height: 1.6; margin-bottom: 16px; }
.info-box b { color: var(--acc2); }

/* ===== Empty State ===== */
.empty-state { text-align: center; padding: 40px 20px; color: var(--mut); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; opacity: .5; }
.empty-state .title { font-size: 16px; font-weight: 600; color: var(--txt2); margin-bottom: 6px; }
.empty-state .desc { font-size: 13px; max-width: 400px; margin: 0 auto; }

/* ===== Loading Spinner ===== */
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--acc); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Responsive ===== */
@media(max-width: 768px) {
  header { padding: 10px 16px; flex-wrap: wrap; }
  .tabs { margin-left: 0; margin-top: 8px; width: 100%; }
  main { padding: 16px; }
  .kpis { flex-direction: column; }
  .channel-card { flex-direction: column; align-items: flex-start; }
  .channel-card .actions { width: 100%; }
  .row { flex-direction: column; }
  .row > div { min-width: 100%; }
}
