@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w: 220px;
  --amber: #f59e0b;
  --amber-light: #fef3c7;
  --amber-dark: #92400e;
  --amber-rgb: 245,158,11;
  --stone-50: #fafaf9;
  --stone-100: #f5f5f4;
  --stone-200: #e7e5e3;
  --stone-400: #a8a29e;
  --stone-500: #78716c;
  --stone-900: #1c1917;
  --green: #16a34a;
  --green-light: #dcfce7;
  --blue: #2563eb;
  --blue-light: #dbeafe;
  --red: #dc2626;
  --red-light: #fee2e2;
  --purple: #7c3aed;
  --purple-light: #ede9fe;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --radius: 10px;
}

[data-theme="ocean"] {
  --amber: #0891b2;
  --amber-light: #cffafe;
  --amber-dark: #164e63;
  --amber-rgb: 8,145,178;
}

[data-theme="forest"] {
  --amber: #059669;
  --amber-light: #d1fae5;
  --amber-dark: #064e3b;
  --amber-rgb: 5,150,105;
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--stone-50);
  color: #292524;
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--stone-900);
  color: var(--stone-100);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
}
.sidebar-logo { padding: 20px 16px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-logo h1 { font-size: 15px; font-weight: 700; color: #fff; display: flex; align-items: center; gap: 8px; }
.sidebar-logo span { font-size: 11px; color: var(--stone-400); margin-top: 2px; display: block; }
.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 7px;
  text-decoration: none; font-size: 13px; font-weight: 500;
  color: var(--stone-400); transition: all .15s; margin-bottom: 2px;
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover { color: #fff; background: rgba(255,255,255,.06); }
.sidebar-nav a.active { color: #fff; background: rgba(var(--amber-rgb),.12); border-left-color: var(--amber); }
.sidebar-nav a svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 11px; color: var(--stone-400); }

.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: white; border-bottom: 1px solid var(--stone-200);
  padding: 0 24px; height: 52px;
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.mobile-menu-btn {
  display: none; align-items: center; justify-content: center;
  width: 32px; height: 32px; border: none; background: transparent;
  color: #292524; cursor: pointer; flex-shrink: 0; margin-right: -4px;
}
.mobile-menu-btn svg { width: 22px; height: 22px; }
.sidebar-backdrop { display: none; }
.topbar-title { font-size: 15px; font-weight: 600; color: #292524; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--stone-400); }
.content { padding: 24px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.card {
  background: white; border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
  border: 1px solid var(--stone-200);
}
.card .label { font-size: 11px; color: var(--stone-500); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 8px; font-weight: 600; }
.card .value { font-size: 28px; font-weight: 700; color: #292524; line-height: 1; }
.card .sub { font-size: 11px; color: var(--stone-400); margin-top: 6px; }
.card-icon { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 8px; margin-bottom: 12px; }
.card-icon svg { width: 18px; height: 18px; }
.card.green .card-icon { background: var(--green-light); color: var(--green); }
.card.green .value { color: var(--green); }
.card.blue .card-icon { background: var(--blue-light); color: var(--blue); }
.card.blue .value { color: var(--blue); }
.card.amber .card-icon { background: var(--amber-light); color: var(--amber-dark); }
.card.amber .value { color: var(--amber-dark); }
.card.purple .card-icon { background: var(--purple-light); color: var(--purple); }
.card.purple .value { color: var(--purple); }

.table-wrap { background: white; border-radius: var(--radius); border: 1px solid var(--stone-200); box-shadow: var(--shadow); overflow-x: auto; margin-bottom: 20px; }
.section-title { font-size: 13px; font-weight: 600; color: #292524; margin-bottom: 12px; margin-top: 24px; }
table { width: 100%; border-collapse: collapse; }
th { background: var(--stone-50); padding: 10px 14px; text-align: left; font-size: 11px; text-transform: uppercase; color: var(--stone-500); letter-spacing: .6px; font-weight: 600; border-bottom: 1px solid var(--stone-200); }
td { padding: 11px 14px; border-top: 1px solid var(--stone-100); font-size: 13px; }
tr:hover td { background: var(--stone-50); }
td a { color: var(--blue); text-decoration: none; font-weight: 500; }
td a:hover { text-decoration: underline; }

th[onclick] { cursor: pointer; user-select: none; }
th[onclick]:hover { background: var(--stone-100); }
th.sorted[data-sort-dir="asc"]::after { content: " ↑"; }
th.sorted[data-sort-dir="desc"]::after { content: " ↓"; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 7px; font-size: 13px; font-weight: 500; cursor: pointer; border: none; text-decoration: none; transition: opacity .15s; }
.btn:hover { opacity: .85; }
.btn-primary { background: var(--amber); color: #292524; }
.btn-danger { background: var(--red-light); color: var(--red); }
.btn-neutral { background: var(--stone-100); color: #292524; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

.year-filter { display: flex; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; }
.year-btn { padding: 6px 16px; border-radius: 20px; border: 1px solid var(--stone-200); background: white; font-size: 12px; font-weight: 500; cursor: pointer; color: var(--stone-500); text-decoration: none; transition: all .15s; }
.year-btn:hover, .year-btn.active { background: var(--amber); border-color: var(--amber); color: #292524; }

.flash { padding: 10px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }
.flash-success { background: var(--green-light); color: #166534; }
.flash-error { background: var(--red-light); color: #991b1b; }
.flash-warning { background: var(--amber-light); color: var(--amber-dark); }

.badge-transferred {
  display: inline-block; padding: 2px 8px; border-radius: 5px;
  background: var(--red); color: #fff; font-size: 10px; font-weight: 700;
  letter-spacing: .4px; text-transform: uppercase; vertical-align: middle;
  margin-left: 8px;
}

.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12px; font-weight: 500; color: var(--stone-500); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .4px; }
.form-input { width: 100%; padding: 8px 12px; border: 1px solid var(--stone-200); border-radius: 7px; font-size: 13px; font-family: inherit; outline: none; transition: border .15s; }
.form-input:focus { border-color: var(--amber); }

.upload-zone { border: 2px dashed var(--stone-200); border-radius: var(--radius); padding: 40px; text-align: center; background: white; cursor: pointer; transition: border-color .15s; }
.upload-zone:hover { border-color: var(--amber); }
.upload-zone p { color: var(--stone-400); font-size: 13px; margin-top: 8px; }

.chart-wrap { background: white; border-radius: var(--radius); border: 1px solid var(--stone-200); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--stone-50); }
.login-card { background: white; border-radius: var(--radius); padding: 40px; width: 360px; box-shadow: 0 4px 24px rgba(0,0,0,.08); }
.login-card h1 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.login-card p { color: var(--stone-400); font-size: 13px; margin-bottom: 24px; }

/* ── Мобильная вёрстка ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .mobile-menu-btn { display: flex; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 2px 0 12px rgba(0,0,0,.15);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop {
    display: block; position: fixed; inset: 0;
    background: rgba(0,0,0,.4); z-index: 90;
  }
  .main { margin-left: 0; }
  .content { padding: 14px; }
  .topbar { padding: 0 14px; }
  .grid { grid-template-columns: 1fr; }
  .card .value { font-size: 22px; }
  th, td { padding: 9px 10px; font-size: 12px; }
  .login-card { width: 100%; max-width: 360px; padding: 28px; }
}
