/* ═══════════════════════════════════════════
   theme.css — Финансовая ОС v2
   Светлая тема · Компонентная система
═══════════════════════════════════════════ */

/* ── ПЕРЕМЕННЫЕ ── */
:root {
  --bg:            #f0f3fb;
  --surface:       #ffffff;
  --card:          #ffffff;
  --border:        rgba(15,23,42,0.07);
  --border-strong: rgba(15,23,42,0.14);
  --shadow:        0 1px 4px rgba(15,23,42,0.06), 0 4px 16px rgba(15,23,42,0.04);
  --text:          #0f172a;
  --text-muted:    #64748b;
  --text-dim:      #94a3b8;
  --accent:        #6366f1;
  --positive:      #10b981;
  --negative:      #ef4444;
  --warning:       #f59e0b;
  --life:          #3b82f6;
  --fun:           #a855f7;
  --invest:        #10b981;
  --risks:         #ef4444;
  --line:          transparent;
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg); color: var(--text);
  min-height: 100vh; font-size: 13px;
}

/* ── TOPBAR ── */
.topbar {
  display: flex; align-items: center;
  padding: 0 24px; height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 300;
  gap: 0;
}
.back-link {
  color: var(--text-muted); text-decoration: none;
  font-size: 0.8rem; font-weight: 500;
  display: flex; align-items: center; gap: 6px;
  padding-right: 16px; border-right: 1px solid var(--border); margin-right: 16px;
  transition: color 0.15s; white-space: nowrap;
}
.back-link:hover { color: var(--text); }
.topbar-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.9rem; font-weight: 600; flex: 1;
}
.topbar-sub {
  font-size: 0.68rem; color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
  margin-left: 8px;
}
.btn-logout {
  background: transparent; border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-dim);
  font-size: 0.75rem; padding: 5px 12px; cursor: pointer;
  transition: all 0.15s; font-family: 'Inter', sans-serif;
}
.btn-logout:hover { border-color: var(--border-strong); color: var(--text-muted); }

/* ── MAIN LAYOUT ── */
.main { max-width: 1080px; margin: 0 auto; padding: 24px 24px 80px; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 14px; border-radius: 100px; border: 1px solid;
  font-size: 0.78rem; font-weight: 600; cursor: pointer;
  transition: all 0.15s; font-family: 'Inter', sans-serif;
  white-space: nowrap; background: transparent;
}
.btn-ghost  { border-color: var(--border-strong); color: var(--text-muted); }
.btn-ghost:hover  { background: rgba(99,102,241,0.06); color: var(--text); border-color: rgba(99,102,241,0.25); }
.btn-primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.btn-primary:hover { background: #4f46e5; border-color: #4f46e5; }
.btn-accent  { border-color: rgba(99,102,241,0.25); background: rgba(99,102,241,0.08); color: var(--accent); }
.btn-accent:hover  { background: rgba(99,102,241,0.14); }
.btn-danger  { border-color: rgba(239,68,68,0.25); background: rgba(239,68,68,0.07); color: var(--negative); }
.btn-danger:hover  { background: rgba(239,68,68,0.13); }
.btn-sm { padding: 5px 11px; font-size: 0.72rem; }

/* ── CARD ── */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 20px;
  box-shadow: var(--shadow);
}
.card:hover { border-color: var(--border-strong); }

/* ── SECTION HEADER ── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; margin-top: 28px;
}
.section-title {
  font-family: 'Space Grotesk', sans-serif; font-size: 0.9rem; font-weight: 600;
}

/* ── ACTION BAR ── */
.action-bar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.action-bar-left { flex: 1; }
.action-bar-label {
  font-family: 'Space Grotesk', sans-serif; font-size: 0.7rem;
  font-weight: 600; letter-spacing: 0.8px; text-transform: uppercase; color: var(--text-muted);
}
.action-bar-title {
  font-family: 'Space Grotesk', sans-serif; font-size: 1rem; font-weight: 700; color: var(--text);
}

/* ── METRIC CHIP ── */
.mchip {
  flex: 1; min-width: 130px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px 16px;
  position: relative; overflow: hidden; box-shadow: var(--shadow);
}
.mchip::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--line, transparent);
}
.mchip-label { font-size: 0.62rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.8px; font-weight: 600; margin-bottom: 4px; }
.mchip-value { font-family: 'JetBrains Mono', monospace; font-size: 1.15rem; font-weight: 500; letter-spacing: -0.3px; }
.mchip-sub   { font-size: 0.65rem; color: var(--text-dim); margin-top: 3px; }

/* ── PROGRESS ── */
.prog-bg { height: 5px; background: var(--border); border-radius: 100px; overflow: hidden; }
.prog-fill { height: 100%; border-radius: 100px; transition: width 0.4s; }

/* ── BADGE ── */
.badge {
  display: inline-flex; align-items: center;
  font-size: 0.65rem; font-weight: 600; border-radius: 100px;
  padding: 2px 9px; border: 1px solid;
}
.badge-green  { color: var(--positive); background: rgba(16,185,129,0.08); border-color: rgba(16,185,129,0.2); }
.badge-red    { color: var(--negative); background: rgba(239,68,68,0.08);  border-color: rgba(239,68,68,0.2); }
.badge-yellow { color: var(--warning);  background: rgba(245,158,11,0.08); border-color: rgba(245,158,11,0.2); }
.badge-accent { color: var(--accent);   background: rgba(99,102,241,0.08); border-color: rgba(99,102,241,0.2); }
.badge-dim    { color: var(--text-dim); background: rgba(148,163,184,0.08); border-color: rgba(148,163,184,0.18); }

/* ── FORM ELEMENTS ── */
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 0.62rem; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; color: var(--text-muted); }
.field input, .field select, .field textarea {
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 8px; color: var(--text);
  font-family: 'JetBrains Mono', monospace; font-size: 0.82rem;
  padding: 7px 10px; transition: border-color 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: rgba(99,102,241,0.4);
  background: rgba(99,102,241,0.03);
}
.field input::placeholder { color: var(--text-dim); }

/* ── TABLE ── */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  font-size: 0.62rem; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.6px;
  padding: 8px 12px; text-align: left;
  border-bottom: 1px solid var(--border);
}
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 0.82rem; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: rgba(99,102,241,0.02); }
.tbl td.mono { font-family: 'JetBrains Mono', monospace; }

/* ── COLOR HELPERS ── */
.col-pos   { color: var(--positive); }
.col-neg   { color: var(--negative); }
.col-warn  { color: var(--warning); }
.col-dim   { color: var(--text-dim); }
.col-muted { color: var(--text-muted); }
.col-accent { color: var(--accent); }

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center; padding: 40px 20px;
  color: var(--text-dim); font-size: 0.85rem;
}
.empty-state-icon { font-size: 2rem; margin-bottom: 8px; }

/* ── TAB BAR ── */
.tab-bar { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  background: none; border: none; cursor: pointer;
  font-family: 'Inter', sans-serif; font-size: 0.82rem; font-weight: 500;
  color: var(--text-muted); padding: 9px 16px;
  border-bottom: 2px solid transparent; transition: all 0.15s;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ── PERIOD SWITCHER OVERRIDES ── */
.period-sw-label { color: var(--text-muted) !important; }
.period-sw-btn {
  background: rgba(99,102,241,0.08) !important;
  border: 1px solid rgba(99,102,241,0.15) !important;
  color: var(--accent) !important;
}
.period-sw-btn:hover { background: rgba(99,102,241,0.16) !important; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(15,23,42,0.1); border-radius: 3px; }

/* ── RESPONSIVE ── */
@media (max-width: 600px) {
  .main { padding: 16px 16px 60px; }
  .topbar { padding: 0 16px; }
}
