/* Тема «СтройФинанс»: светлый фон, тёмно-синее меню, белые карточки, оранжевый акцент. */
:root,
:root[data-theme="light"] {
  --bg: #f2f5f9;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e6ebf2;
  --line-strong: #d7dfea;
  --accent: #CC0605;
  --accent-hover: #A80404;
  --accent-ink: #ffffff;
  --accent-soft: #fff3e5;
  --accent-soft-line: #f7d9b8;
  --accent-soft-ink: #8a4b0f;
  --link: #A80404;
  --focus: #8fb3f0;
  --warn: #b7791f;
  --warn-soft: #fdf6e3;
  --warn-line: #f0d9a8;
  --warn-ink: #6d4300;
  --bad: #dc2f4b;
  --bad-soft: #fdecef;
  --bad-line: #f2c0c8;
  --good: #0e9f74;
  --good-soft: #e6f7f0;
  --good-line: #b9e6d5;
  --side: #0c1424;
  --side-ink: #cbd5e1;
  --side-strong: #ffffff;
  --side-muted: #94a3b8;
  --side-line: rgba(255, 255, 255, .08);
  --side-hover: rgba(255, 255, 255, .06);
  --side-active: rgba(204, 6, 5, .16);
  --side-active-ink: #f8b25a;
  --side-ico-filter: none;
  --side-weight: 500;
  --side-fs: 13px;
  --logo-bg: #CC0605;
  --logo-ink: #0c1424;
  --th-bg: #f8fafc;
  --row-hover: #f8fafc;
  --total-bg: #f1f5f9;
  --group-bg: #eef2f8;
  --chip-bg: #eef2f8;
  --input-bg: #ffffff;
  --btn-bg: #ffffff;
  --btn-hover-line: #b9c4d4;
  --line-bg: #f8fafc;
  --overlay: rgba(15, 23, 42, .45);
  --radius: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 10px 28px -20px rgba(15, 23, 42, .25);
  --shadow-md: 0 1px 2px rgba(15, 23, 42, .05), 0 18px 40px -26px rgba(15, 23, 42, .35);
  --c1: #CC0605; --c2: #0e9f74; --c3: #2f6fed; --c4: #7c5cf4;
  --c5: #0ea5a4; --c6: #b7791f; --c7: #64748b; --c8: #dc2f4b;
  --c-in: #0e9f74; --c-out: #dc2f4b;
  --warn-bg: #fdf6e3;
}

body { background: var(--bg); }

/* ---------- Каркас ---------- */
.layout { grid-template-columns: 236px 1fr; }
.side {
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(204, 6, 5, .08), transparent 60%),
    linear-gradient(180deg, #0d1626 0%, #0a111e 100%);
  border-right: 1px solid rgba(255, 255, 255, .05);
  color: var(--side-muted);
  padding: 18px 12px 16px;
}
.brand { color: #fff; font-size: 13px; font-weight: 700; padding: 4px 8px 18px; }
.brand .logo {
  width: 38px; height: 38px; border-radius: 11px; font-size: 18px;
  background: linear-gradient(135deg, #CC0605, #CC0605); color: #0c1424;
  box-shadow: 0 8px 20px -10px rgba(204, 6, 5, .8);
}
.brand small { color: #94a3b8; font-size: 9.5px; font-weight: 400; }
.nav { gap: 3px; }
.nav a {
  color: #94a3b8; border-radius: 10px; padding: 9px 10px; font-size: 13px; font-weight: 500;
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: #e2e8f0; }
.nav a.active { background: rgba(204, 6, 5, .16); color: #f8b25a; font-weight: 600; }
.nav .ico { opacity: .9; }
.side .who { border-top: 1px solid rgba(255, 255, 255, .08); color: #94a3b8; font-size: 10.5px; }
.side .who button { color: #e2e8f0; }
.side .theme-toggle { color: #94a3b8; }

/* ---------- Карточки ---------- */
.panel {
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  padding: 18px;
}
.panel > h2 { font-size: 15px; letter-spacing: -.01em; }
.metric {
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  padding: 16px 16px 14px;
  position: relative;
  overflow: hidden;
  background: #fff;
}
.metric::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 3px;
  background: var(--c1);
}
.metric:nth-child(6n+1)::before { background: #CC0605; }
.metric:nth-child(6n+2)::before { background: #7c5cf4; }
.metric:nth-child(6n+3)::before { background: #0ea5a4; }
.metric:nth-child(6n+4)::before { background: #0e9f74; }
.metric:nth-child(6n+5)::before { background: #2f6fed; }
.metric:nth-child(6n+6)::before { background: #dc2f4b; }
.metric .label {
  text-transform: uppercase; letter-spacing: .06em; font-size: 9.5px; font-weight: 600; color: var(--muted);
}
.metric .value { font-size: 23px; font-weight: 750; letter-spacing: -.02em; margin-top: 6px; }
.metric .note { font-size: 10.5px; margin-top: 4px; }
.metric.accent { border-color: var(--line); }
.metric.good-metric .value { color: var(--good); }
.metric.neg-metric .value { color: var(--bad); }

/* ---------- Кнопки и поля ---------- */
.btn, button.btn {
  border-radius: 10px; border: 1px solid var(--line-strong); background: #fff;
  font-weight: 600; min-height: 36px;
}
.btn:hover { border-color: #b9c4d4; background: #fff; }
.btn.primary {
  background: linear-gradient(180deg, #CC0605, #CC0605);
  border-color: #CC0605; color: #fff;
  box-shadow: 0 8px 18px -10px rgba(204, 6, 5, .7);
}
.btn.primary:hover { background: linear-gradient(180deg, #CC0605, #A80404); border-color: #A80404; }
.btn.small { border-radius: 8px; }
input, select, textarea { border-radius: 10px; }
.field label { font-size: 11px; color: var(--muted); }
input, select, textarea { border: 1px solid var(--line-strong); background: #fff; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(204, 6, 5, .15); outline: none; }

/* ---------- Таблицы ---------- */
table { border-radius: 12px; }
th { background: var(--th-bg); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
td, th { border-color: var(--line); }
tbody tr:hover { background: var(--row-hover); }

/* ---------- Мобильный каркас ---------- */
.topbar { background: #fff; border-bottom: 1px solid var(--line); color: var(--ink); }
.topbar .t { font-weight: 700; }
.side .who a, .side .who { color: #94a3b8; }

/* ---------- Вход ---------- */
.login .brand .logo { width: 44px; height: 44px; border-radius: 13px; font-size: 20px; }
.login { box-shadow: var(--shadow-md); border-radius: 20px; }

/* ---------- Графики ---------- */
.dds-kpi .metric .value { font-size: 20px; }
.pf-tile { border-radius: 14px; }
.hb-track { opacity: .35; }

@media (max-width: 760px) {
  .layout { display: block; }
  .side {
    background: #0c1424;
    box-shadow: 0 24px 60px -20px rgba(15, 23, 42, .5);
  }
  .metric .value { font-size: 20px; }
  .panel { padding: 14px; }
}

.brand .logo { object-fit: cover; border-radius: 11px; background: none; box-shadow: 0 8px 18px -10px rgba(15, 40, 90, .55); }

/* Тёмная тема: подписи полей и списки — контрастнее */
:root[data-theme="dark"] .field label,
:root[data-theme="dark"] .field .help { color: #dbe6f7; }
:root[data-theme="dark"] .field label { font-weight: 600; }
:root[data-theme="dark"] select,
:root[data-theme="dark"] input,
:root[data-theme="dark"] textarea { color: #eaf1fb; }
:root[data-theme="dark"] select option { color: #0f172a; background: #ffffff; }

/* Тёмная тема: нативные поля (select/date/file) — светлый фон, чёрный текст */
:root[data-theme="dark"] select,
:root[data-theme="dark"] input[type="date"],
:root[data-theme="dark"] input[type="file"] {
  background: #ffffff;
  color: #0f172a;
  border-color: #cbd5e1;
  color-scheme: light;
}
:root[data-theme="dark"] select option { color: #0f172a; background: #ffffff; }
:root[data-theme="dark"] input[type="file"]::file-selector-button {
  color: #0f172a; background: #eef2f8; border: 1px solid #cbd5e1; border-radius: 6px; padding: 5px 10px; margin-right: 8px;
}
