/* =========================================================================
   HR Dashboard — оформление
   Палитра графиков проверена валидатором (CVD, контраст, светлотный диапазон)
   ========================================================================= */

:root {
  color-scheme: light;

  --surface-1: #ffffff;          /* карточки, поверхность графиков */
  --surface-2: #f4f5f7;          /* фон страницы */
  --surface-3: #eceef1;          /* подложки, hover */
  --sidebar-bg: #15161a;
  --sidebar-ink: #e7e8ec;
  --sidebar-muted: #8f939d;

  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;

  --grid: #e6e7ea;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --border-strong: rgba(11, 11, 11, 0.18);

  /* Категориальные слоты (проверены: adjacent CVD ΔE 9.2, normal ΔE 27.6) */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;

  /* Порядковая шкала для воронки (одна тональность, монотонная светлота) */
  --ord-1: #86b6ef;
  --ord-2: #5598e7;
  --ord-3: #2a78d6;
  --ord-4: #1c5cab;
  --ord-5: #104281;

  /* Статусы — зарезервированы, всегда с текстом или иконкой */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-ink: #006300;
  --critical-ink: #b02a2a;
  --good-wash: #e8f7e8;
  --warning-wash: #fef5e0;
  --critical-wash: #fceaea;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(11, 11, 11, .06), 0 4px 14px rgba(11, 11, 11, .05);
  --shadow-lg: 0 12px 40px rgba(11, 11, 11, .18);
  --sidebar-w: 248px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --surface-1: #1a1a19;
  --surface-2: #0d0d0d;
  --surface-3: #26262a;
  --sidebar-bg: #0a0a0c;
  --sidebar-ink: #e7e8ec;
  --sidebar-muted: #7f838d;

  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;

  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;

  --ord-1: #9ec5f4;
  --ord-2: #6da7ec;
  --ord-3: #3987e5;
  --ord-4: #256abf;
  --ord-5: #184f95;

  --good-ink: #0ca30c;
  --critical-ink: #e66767;
  --good-wash: rgba(12, 163, 12, .14);
  --warning-wash: rgba(250, 178, 25, .14);
  --critical-wash: rgba(208, 59, 59, .16);

  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .3);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }

/* Атрибут hidden должен побеждать любые display из правил ниже
   (.shell, .login-screen и .modal-root задают свой display). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--surface-2);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }

a { color: var(--series-1); }

button, input, select, textarea { font: inherit; color: inherit; }

/* ------------------------------- Вход -------------------------------- */

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1000px 500px at 15% -10%, rgba(42, 120, 214, .16), transparent 60%),
    radial-gradient(900px 500px at 100% 110%, rgba(27, 175, 122, .12), transparent 60%),
    var(--surface-2);
}

.login-card {
  width: min(400px, 100%);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 28px;
  display: grid;
  gap: 16px;
}

.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 4px; }
.login-brand h1 { font-size: 19px; }
.login-brand p { margin: 2px 0 0; font-size: 13px; color: var(--text-secondary); }

.login-mark, .logo-mark {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--series-1);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .04em;
  flex: none;
}

.login-error {
  margin: 0;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--critical-wash);
  color: var(--critical-ink);
  font-size: 13px;
}

/* ------------------------------ Каркас ------------------------------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.logo-text { display: grid; line-height: 1.25; min-width: 0; }
.logo-text strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo-text span { font-size: 11px; color: var(--sidebar-muted); }

.sidebar-close { display: none; margin-left: auto; color: var(--sidebar-ink); }

.nav { flex: 1; overflow-y: auto; padding: 12px 10px; display: grid; gap: 2px; align-content: start; }

.nav-group {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--sidebar-muted);
  padding: 14px 10px 6px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-ink);
  text-decoration: none;
  font-size: 13.5px;
  border: 0;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background .12s;
}

.nav-item:hover { background: rgba(255, 255, 255, .07); }
.nav-item.active { background: var(--series-1); color: #fff; font-weight: 550; }
.nav-item .nav-icon { width: 17px; text-align: center; opacity: .85; flex: none; }
.nav-item.active .nav-icon { opacity: 1; }

.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255, 255, 255, .08); display: grid; gap: 9px; }

.user-chip { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  display: grid; place-items: center;
  font-weight: 650; font-size: 13px; flex: none;
}
.user-meta { display: grid; line-height: 1.3; min-width: 0; }
.user-meta strong { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta span { font-size: 11px; color: var(--sidebar-muted); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 20px;
  background: linear-gradient(96deg, #6a3fd0 0%, #7b46e0 48%, #8f5bea 100%);
  color: #fff;
  border-bottom: 1px solid rgba(0, 0, 0, .12);
}
:root[data-theme="dark"] .topbar {
  background: linear-gradient(96deg, #4b2a95 0%, #5a34ab 48%, #6a3fc4 100%);
}

.topbar-title { min-width: 0; flex: 1; }
.topbar-title h1 { font-size: 16.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title p { margin: 1px 0 0; font-size: 12px; opacity: .78; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-actions { display: flex; align-items: center; gap: 7px; flex: none; }

.topbar .icon-btn { color: #fff; }
.topbar .icon-btn:hover { background: rgba(255, 255, 255, .16); }

.topbar .btn {
  background: rgba(255, 255, 255, .14);
  border-color: rgba(255, 255, 255, .26);
  color: #fff;
}
.topbar .btn:hover { background: rgba(255, 255, 255, .26); }
.topbar .btn.active { background: #fff; color: #5a34ab; border-color: #fff; font-weight: 600; }

.period-picker { display: flex; align-items: center; gap: 7px; font-size: 12px; opacity: .85; }
.period-picker select {
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, .26);
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.period-picker select option { color: var(--text-primary); background: var(--surface-1); }

.content { padding: 22px; flex: 1; outline: none; }

.menu-btn { display: none; }

/* ------------------------------ Кнопки ------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-1);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  transition: background .12s, border-color .12s, opacity .12s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--series-1); border-color: var(--series-1); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--series-1) 86%, #000); }
.btn-danger { color: var(--critical-ink); border-color: color-mix(in srgb, var(--critical) 40%, transparent); }
.btn-danger:hover { background: var(--critical-wash); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; }

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font-size: 15px;
  color: inherit;
}
.icon-btn:hover { background: var(--surface-3); }

/* ---------------------------- Дашборд -------------------------------- */

.dash-hint {
  font-size: 12.5px;
  color: var(--text-secondary);
  letter-spacing: .01em;
}
.dash-hint b { color: var(--text-primary); letter-spacing: .04em; }

.alert-list { display: grid; gap: 8px; }
.alert-row { display: flex; gap: 10px; align-items: flex-start; }
.alert-text { flex: 1; font-size: 13px; line-height: 1.45; }

/* --- Плитки --- */

.tile-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.tile {
  --tone-bg: var(--surface-1);
  --tone-ink: var(--text-primary);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 5px;
  padding: 20px 14px 18px;
  min-height: 172px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: var(--tone-bg);
  color: var(--tone-ink);
  cursor: pointer;
  overflow: hidden;
  font: inherit;
  transition: transform .14s ease, box-shadow .14s ease, filter .14s ease;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); filter: brightness(1.02); }
.tile:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }

.tile-num {
  position: absolute;
  top: 10px; left: 12px;
  font-size: 10.5px;
  opacity: .45;
  font-variant-numeric: tabular-nums;
}

.tile-grip { position: absolute; top: 8px; right: 9px; opacity: 0; transition: opacity .14s; }
.grip-icon { width: 16px; height: 16px; opacity: .5; }
.tile-grip svg circle { fill: currentColor; stroke: none; }

.tile-top { display: block; margin-bottom: 2px; opacity: .72; }
.tile-icon { width: 26px; height: 26px; display: block; }

.tile-value {
  font-size: 30px;
  font-weight: 680;
  letter-spacing: -.025em;
  line-height: 1.1;
  display: flex;
  align-items: baseline;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: center;
}
.tile-unit { font-size: 12px; font-weight: 500; opacity: .62; letter-spacing: 0; }

.tile-title { font-size: 13px; font-weight: 600; line-height: 1.3; }
.tile-caption {
  font-size: 11px;
  line-height: 1.35;
  opacity: .62;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tile-badge { margin-top: 3px; }
.tile-badge .status-badge { background: rgba(255, 255, 255, .55); }
:root[data-theme="dark"] .tile-badge .status-badge { background: rgba(0, 0, 0, .3); }

.tile-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: rgba(0, 0, 0, .07);
}
:root[data-theme="dark"] .tile-bar { background: rgba(255, 255, 255, .09); }
.tile-bar-fill { display: block; height: 100%; background: var(--series-1); }
.tile-bar-fill.good { background: var(--good); }
.tile-bar-fill.warn { background: var(--warning); }
.tile-bar-fill.bad { background: var(--critical); }

/* Красная зона — подчёркиваем само число, бейдж рядом даёт словесную расшифровку */
.tile.status-red .tile-value { color: var(--critical-ink); }
.tile.status-none .tile-value { opacity: .42; }

/* Пастельные группы: люди / подбор / риск / деньги / время / развитие */
.tone-blue   { --tone-bg: #dce8fa; }
.tone-violet { --tone-bg: #e3ddf8; }
.tone-rose   { --tone-bg: #f8dedf; }
.tone-peach  { --tone-bg: #f9e5d4; }
.tone-mint   { --tone-bg: #d7f0e4; }
.tone-lilac  { --tone-bg: #eddef4; }

:root[data-theme="dark"] .tone-blue   { --tone-bg: #182739; --tone-ink: #e8eef7; }
:root[data-theme="dark"] .tone-violet { --tone-bg: #23203c; --tone-ink: #eae7f7; }
:root[data-theme="dark"] .tone-rose   { --tone-bg: #382125; --tone-ink: #f7e8e9; }
:root[data-theme="dark"] .tone-peach  { --tone-bg: #382b1e; --tone-ink: #f7ede2; }
:root[data-theme="dark"] .tone-mint   { --tone-bg: #15312a; --tone-ink: #e2f3ec; }
:root[data-theme="dark"] .tone-lilac  { --tone-bg: #2c1f36; --tone-ink: #f1e6f6; }

/* --- Режим перетаскивания --- */

.tile-grid.sorting .tile {
  cursor: grab;
  touch-action: none;
  user-select: none;
  animation: tile-wiggle 2.4s ease-in-out infinite;
}
.tile-grid.sorting .tile:hover { transform: none; }
.tile-grid.sorting .tile-grip { opacity: 1; }
.tile-grid.sorting .tile:nth-child(even) { animation-delay: -1.2s; }

@keyframes tile-wiggle {
  0%, 100% { rotate: -.35deg; }
  50% { rotate: .35deg; }
}

.tile.dragging {
  cursor: grabbing;
  z-index: 20;
  animation: none;
  rotate: 0deg;
  box-shadow: var(--shadow-lg);
  transition: none;
}

@media (prefers-reduced-motion: reduce) {
  .tile-grid.sorting .tile { animation: none; }
  .tile { transition: none; }
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px 2px 5px;
  border-radius: 999px;
  white-space: nowrap;
}
.status-badge .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
/* Специально через .status-badge: те же имена классов висят и на плитках,
   где они означают состояние блока, а не оформление бейджа. */
.status-badge.status-green { background: var(--good-wash); color: var(--good-ink); }
.status-badge.status-green .dot { background: var(--good); }
.status-badge.status-amber { background: var(--warning-wash); color: #8a6100; }
:root[data-theme="dark"] .status-badge.status-amber { color: var(--warning); }
.status-badge.status-amber .dot { background: var(--warning); }
.status-badge.status-red { background: var(--critical-wash); color: var(--critical-ink); }
.status-badge.status-red .dot { background: var(--critical); }
.status-badge.status-none { background: var(--surface-3); color: var(--text-muted); }
.status-badge.status-none .dot { background: var(--axis); }

/* --------------------------- Панели/секции --------------------------- */

.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.panel-head h2, .panel-head h3 { font-size: 14px; }
.panel-head .sub { font-size: 12px; color: var(--text-secondary); }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 16px; }
.panel-body.tight { padding: 0; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.stack { display: grid; gap: 14px; }

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.stat-tile { background: var(--surface-1); padding: 13px 15px; }
.stat-tile .label { font-size: 11.5px; color: var(--text-secondary); }
.stat-tile .value { font-size: 21px; font-weight: 650; letter-spacing: -.02em; margin-top: 2px; }
.stat-tile .note { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }
.stat-tile .value.good { color: var(--good-ink); }
.stat-tile .value.bad { color: var(--critical-ink); }

/* ------------------------------ Таблицы ------------------------------ */

.table-wrap { overflow-x: auto; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data th, table.data td {
  padding: 9px 14px;
  text-align: left;
  border-bottom: 1px solid var(--grid);
  vertical-align: middle;
}
table.data thead th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .045em;
  color: var(--text-muted);
  font-weight: 600;
  background: var(--surface-1);
  position: sticky;
  top: 0;
  white-space: nowrap;
  z-index: 1;
}
table.data tbody tr:hover { background: var(--surface-3); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.actions { text-align: right; white-space: nowrap; }
table.data .row-danger { background: var(--critical-wash); }
table.data .row-danger:hover { background: color-mix(in srgb, var(--critical) 16%, transparent); }

.chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  background: var(--surface-3);
  color: var(--text-secondary);
  white-space: nowrap;
}
.chip.ok { background: var(--good-wash); color: var(--good-ink); }
.chip.warn { background: var(--warning-wash); color: #8a6100; }
:root[data-theme="dark"] .chip.warn { color: var(--warning); }
.chip.bad { background: var(--critical-wash); color: var(--critical-ink); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.toolbar .spacer { flex: 1; }
.toolbar input[type="search"], .toolbar select, .toolbar input[type="month"] {
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  font-size: 13px;
  min-width: 130px;
}
.toolbar input[type="search"] { min-width: 210px; }

.empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
}

.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-secondary);
}

/* ------------------------------ Графики ------------------------------ */

.chart { width: 100%; display: block; overflow: visible; }
.chart text { font-family: var(--font); }
.chart .axis-label { fill: var(--text-muted); font-size: 11px; }
.chart .value-label { fill: var(--text-secondary); font-size: 11px; font-weight: 600; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .ref-line { stroke: var(--critical); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .ref-text { fill: var(--critical-ink); font-size: 10.5px; font-weight: 600; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .mark { transition: opacity .12s; }
.chart .mark.dim { opacity: .35; }

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; flex: none; }

.chart-tip {
  position: fixed;
  z-index: 90;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 8px 11px;
  font-size: 12.5px;
  max-width: 260px;
  opacity: 0;
  transition: opacity .1s;
}
.chart-tip.show { opacity: 1; }
.chart-tip .tip-title { font-weight: 650; margin-bottom: 3px; }
.chart-tip .tip-row { display: flex; gap: 10px; justify-content: space-between; color: var(--text-secondary); }
.chart-tip .tip-row b { color: var(--text-primary); font-variant-numeric: tabular-nums; }

/* Прогресс-полоса (используется в таблицах: укомплектованность, KPI) */
.bar-cell { display: flex; align-items: center; gap: 9px; min-width: 130px; }
.bar-track { flex: 1; height: 7px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--series-1); }
.bar-fill.good { background: var(--good); }
.bar-fill.warn { background: var(--warning); }
.bar-fill.bad { background: var(--critical); }
.bar-num { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text-secondary); min-width: 42px; text-align: right; }

/* ------------------------------- Формы ------------------------------- */

.field { display: grid; gap: 5px; font-size: 13px; }
.field > span { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.field input, .field select, .field textarea {
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--series-1) 55%, transparent);
  outline-offset: -1px;
  border-color: var(--series-1);
}
.field textarea { min-height: 72px; resize: vertical; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field-check { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.field-check input { width: 17px; height: 17px; }

/* ------------------------------ Модалка ------------------------------ */

.modal-root { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 18px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(9, 9, 12, .5); backdrop-filter: blur(2px); }
.modal {
  position: relative;
  width: min(640px, 100%);
  max-height: 88vh;
  background: var(--surface-1);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
}
.modal.wide { width: min(1000px, 100%); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 15px; flex: 1; }
.modal-body { padding: 18px; overflow-y: auto; display: grid; gap: 13px; }
.modal-foot { padding: 13px 18px; border-top: 1px solid var(--border); display: flex; gap: 9px; justify-content: flex-end; }

/* ---------------------------- Уведомления ---------------------------- */

.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: grid; gap: 9px; }
.toast {
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--series-1);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 11px 15px;
  font-size: 13px;
  max-width: 360px;
  animation: slide-in .18s ease-out;
}
.toast.ok { border-left-color: var(--good); }
.toast.err { border-left-color: var(--critical); }
@keyframes slide-in { from { transform: translateX(14px); opacity: 0; } }

/* ----------------------------- Служебное ----------------------------- */

.loader { display: flex; align-items: center; gap: 10px; padding: 44px; color: var(--text-secondary); justify-content: center; }
.spinner {
  width: 17px; height: 17px;
  border: 2px solid var(--grid);
  border-top-color: var(--series-1);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.scrim { position: fixed; inset: 0; background: rgba(9, 9, 12, .45); z-index: 35; }

.mono { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

.methodology-text { font-size: 13px; line-height: 1.55; color: var(--text-secondary); }
.methodology-text b { color: var(--text-primary); }

.formula {
  background: var(--surface-3);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.formula b { color: var(--text-primary); }

/* --------------------------- Адаптивность ---------------------------- */

@media (max-width: 1500px) {
  .tile-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 1180px) {
  .tile-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1000px) {
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 820px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .sidebar-close { display: grid; }
  .menu-btn { display: grid; }
  .content { padding: 15px; }
  .topbar { padding: 10px 14px; gap: 10px; }
  .period-picker span { display: none; }
  .field-row { grid-template-columns: minmax(0, 1fr); }
  .toasts { right: 12px; left: 12px; bottom: 12px; }
  .toast { max-width: none; }
}

@media (max-width: 820px) {
  .tile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile { min-height: 150px; padding: 16px 10px 15px; }
  .tile-value { font-size: 25px; }
}

@media (max-width: 400px) {
  .tile-grid { grid-template-columns: minmax(0, 1fr); }
  .topbar-title p { display: none; }
}

@media print {
  .sidebar, .topbar-actions, .menu-btn, .toolbar, .actions { display: none !important; }
  .kpi-card, .panel { box-shadow: none; break-inside: avoid; }
  body { background: #fff; }
}
