/* ОДА · Бухгалтерия — стили.
   Токены, типографика и компоненты перенесены из портала ГК «ОДА» (Claudemp,
   portal/public/index.html, 29.09.2026), чтобы бухгалтерия выглядела частью группы: фирменная
   палитра --oda-*, затемнённые оттенки для графиков, светофор --tl-* (приглушённый, а не
   сигнальный: он красит полтаблицы сразу), шрифт Golos Text с подмножеством latin-ext (в нём ₽). */

:root {
  color-scheme: light;
  --oda-green: #69a74c;      --oda-green-light: #a0bf45;
  --oda-blue: #9cbdf2;       --oda-blue-light: #9bd1f2;
  --oda-mist: #c2d1cf;       --oda-mist-light: #ededed;
  --oda-slate: #5a6666;      --oda-graphite: #5b5b5b;

  --plane: #f2f5f4;
  --surface-1: #ffffff;
  --surface-2: #f6f8f7;
  --surface-3: #eef2f1;
  --text-primary: #1e2729;
  --text-secondary: #5a6666;
  --text-muted: #6f7b79;
  --border: rgba(90, 102, 102, 0.16);
  --border-strong: rgba(90, 102, 102, 0.30);
  --gridline: #e2e9e7;
  --shadow-sm: 0 1px 2px rgba(30, 39, 41, .06), 0 1px 3px rgba(30, 39, 41, .04);
  --shadow-md: 0 2px 6px rgba(30, 39, 41, .07), 0 8px 24px rgba(30, 39, 41, .07);
  --shadow-lg: 0 12px 40px rgba(30, 39, 41, .16);

  --accent: #4e8c3a;
  --accent-contrast: #ffffff;
  --accent-tint: rgba(105, 167, 76, .12);
  --accent-ring: rgba(105, 167, 76, .35);

  --status-good: #3e8e3e;
  --status-warn: #b57d14;
  --status-critical: #c4443e;

  --tl-good: #5f9c46;
  --tl-bad: #c4443e;
  --tl-mix-1: 8%; --tl-mix-2: 17%; --tl-mix-3: 28%; --tl-mix-4: 40%;
}

/* Тёмная тема — по настройке системы, если явно не выбрана светлая. Селектор с :not() стоит
   ВНУТРИ @media намеренно: снаружи он включал бы тёмные токены и в светлой системной теме. */
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --plane: #12171a;
    --surface-1: #1b2225;
    --surface-2: #222a2d;
    --surface-3: #2a3336;
    --text-primary: #eef3f2;
    --text-secondary: #b3c0be;
    --text-muted: #8d9b99;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.22);
    --gridline: #2b3437;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .40);
    --shadow-md: 0 2px 6px rgba(0, 0, 0, .38), 0 8px 24px rgba(0, 0, 0, .34);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .55);
    --accent: #8cc46a;
    --accent-contrast: #14211a;
    --accent-tint: rgba(140, 196, 106, .16);
    --accent-ring: rgba(140, 196, 106, .40);
    --status-good: #6cbf5f;
    --status-warn: #d8ab48;
    --status-critical: #e2706a;
    --tl-good: #8cc46a; --tl-bad: #d98079;
    --tl-mix-1: 9%; --tl-mix-2: 16%; --tl-mix-3: 24%; --tl-mix-4: 34%;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane: #12171a; --surface-1: #1b2225; --surface-2: #222a2d; --surface-3: #2a3336;
  --text-primary: #eef3f2; --text-secondary: #b3c0be; --text-muted: #8d9b99;
  --border: rgba(255, 255, 255, 0.10); --border-strong: rgba(255, 255, 255, 0.22);
  --gridline: #2b3437;
  --accent: #8cc46a; --accent-contrast: #14211a;
  --accent-tint: rgba(140, 196, 106, .16); --accent-ring: rgba(140, 196, 106, .40);
  --status-good: #6cbf5f; --status-warn: #d8ab48; --status-critical: #e2706a;
  --tl-good: #8cc46a; --tl-bad: #d98079;
  --tl-mix-1: 9%; --tl-mix-2: 16%; --tl-mix-3: 24%; --tl-mix-4: 34%;
}

@font-face {
  font-family: 'Golos Text'; font-style: normal; font-weight: 400 900; font-display: swap;
  src: url('assets/fonts/golos-text-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Golos Text'; font-style: normal; font-weight: 400 900; font-display: swap;
  src: url('assets/fonts/golos-text-cyrillic-ext.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: 'Golos Text'; font-style: normal; font-weight: 400 900; font-display: swap;
  src: url('assets/fonts/golos-text-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Golos Text'; font-style: normal; font-weight: 400 900; font-display: swap;
  src: url('assets/fonts/golos-text-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

* { box-sizing: border-box; }
html { overflow-x: hidden; }
body {
  margin: 0; min-height: 100vh;
  background: var(--plane); color: var(--text-primary);
  font: 400 14px/1.5 'Golos Text', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums;
}
a { color: var(--accent); }
h3 { font-size: 14px; margin: 18px 0 8px; display: flex; align-items: center; flex-wrap: wrap; }
h4 { display: flex; align-items: center; }

/* ---------- шапка ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--surface-1); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand img { width: 30px; height: 30px; }
.brand b { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.brand span { color: var(--text-muted); font-weight: 500; }
.nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; align-items: center; }
.nav .who { color: var(--text-secondary); font-size: 13px; margin-right: 6px; }
.nav button { font: inherit; font-size: 13px; font-weight: 600; border: 0; background: none; color: var(--text-secondary);
  padding: 7px 11px; border-radius: 8px; cursor: pointer; }
.nav button:hover { background: var(--surface-2); color: var(--text-primary); }
.nav button.active { background: var(--accent-tint); color: var(--accent); }
.stand-flag { background: var(--status-warn); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }

main { max-width: 1320px; margin: 0 auto; padding: 20px 16px 48px; }

/* ---------- формы входа ---------- */
.auth-box { max-width: 420px; margin: 8vh auto 0; }
.auth-box .card { padding: 24px; }
.auth-box h1 { font-size: 20px; margin: 0 0 6px; }
.auth-box p { margin: 0 0 14px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); margin-bottom: 5px; }
.field input, .field select {
  width: 100%; font: inherit; font-size: 15px; padding: 10px 12px; border-radius: 9px;
  border: 1px solid var(--border-strong); background: var(--surface-1); color: var(--text-primary);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.field input.code { letter-spacing: .3em; font-size: 20px; text-align: center; font-variant-numeric: tabular-nums; }
.form-error { color: var(--status-critical); font-weight: 600; min-height: 1.5em; margin: 0 0 10px; }
.form-ok { color: var(--status-good); font-weight: 600; }
.secret { font: 600 16px/1.6 ui-monospace, 'Cascadia Mono', Consolas, monospace; letter-spacing: .08em;
  background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 9px; padding: 10px 12px;
  word-break: break-all; margin: 8px 0 14px; }
.once { background: color-mix(in srgb, var(--status-warn) 12%, var(--surface-1));
  border: 1px solid color-mix(in srgb, var(--status-warn) 40%, var(--border)); border-radius: 10px; padding: 12px 14px; margin: 12px 0; }
.inline-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 12px; align-items: end; }

/* ---------- кнопки ---------- */
.btn {
  font: inherit; font-weight: 600; font-size: 13px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 17px; border-radius: 9px; margin-bottom: 14px;
  background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--border-strong);
  cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-tint); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn.primary:hover { filter: brightness(1.08); color: var(--accent-contrast); }
.btn.small { padding: 6px 10px; font-size: 12px; margin: 2px 4px 2px 0; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: grayscale(.4); }
.btn.wide { width: 100%; }

.mode-switch { display: inline-flex; align-items: center; margin-left: auto; }
.mode-btn {
  font: inherit; font-size: 13px; font-weight: 600; padding: 6px 15px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface-1); color: var(--text-secondary);
}
.mode-switch .mode-btn:first-child { border-radius: 9px 0 0 9px; }
.mode-switch .mode-btn:last-child { border-radius: 0 9px 9px 0; }
.mode-switch .mode-btn + .mode-btn { border-left: none; }
p > .mode-btn, div > .mode-btn:only-child { border-radius: 9px; }
.mode-btn:hover { color: var(--text-primary); background: var(--surface-2); }
.mode-btn.active { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.mode-btn:disabled { opacity: .5; cursor: progress; }

/* ---------- карточки и таблицы ---------- */
.muted { color: var(--text-muted); }
.muted.warn, .warn { color: var(--status-critical); }
.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px;
  padding: 18px; margin-bottom: 20px; min-width: 0; box-shadow: var(--shadow-sm);
}
.card h2 {
  font-size: 15px; margin: 0 0 14px; font-weight: 650; letter-spacing: -0.008em;
  display: flex; align-items: center; flex-wrap: wrap;
}
.section-head { display: flex; align-items: center; gap: 12px; margin: 6px 0 14px; flex-wrap: wrap; }
.section-head h2 { font-size: 18px; margin: 0; display: flex; align-items: center; }
.section-head::after { content: ''; flex: 1; min-width: 16px; height: 1px; background: var(--border); }
.section-head .mode-switch { order: 2; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--gridline); vertical-align: top; }
thead th {
  color: var(--text-muted); font-weight: 700; font-size: 11px; letter-spacing: .05em;
  text-transform: uppercase; background: var(--surface-2);
  border-bottom: 1px solid var(--border-strong); white-space: nowrap;
}
thead th:first-child { border-top-left-radius: 10px; }
thead th:last-child { border-top-right-radius: 10px; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
th.num { text-align: right; }
td .muted { font-size: 11.5px; }
details summary { cursor: pointer; color: var(--text-secondary); }
details ul { margin: 6px 0 0; padding-left: 18px; }

.settle-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; margin-bottom: 14px; }
.settle-grid .settle-col { min-width: 0; }
.settle-col h4 { margin: 6px 0; font-size: 14px; }
@media (max-width: 640px) { .settle-grid { grid-template-columns: 1fr; } }

/* ---------- плитки сводки ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi-tile {
  min-width: 0; position: relative; background-color: var(--surface-1);
  background-image: linear-gradient(180deg, #a0bf45, #66a64c);
  background-repeat: no-repeat; background-size: 3px 100%; background-position: left top;
  border: 1px solid var(--border); border-radius: 14px; padding: 15px 16px 16px; box-shadow: var(--shadow-sm);
}
.kpi-tile.kpi-blue { background-image: linear-gradient(180deg, #9bd1f2, #6ea4e0); }
.kpi-tile.kpi-mist { background-image: linear-gradient(180deg, #ededed, #c2d1cf); }
.kpi-tile.kpi-warn { background-image: linear-gradient(180deg, #e0b355, #c4443e); }
.kpi-tile .label { color: var(--text-muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .045em; display: flex; align-items: center; }
.kpi-tile .value { font-size: 22px; font-weight: 700; margin-top: 6px; letter-spacing: -0.015em; line-height: 1.2; overflow-wrap: anywhere; }
.kpi-tile .sub { color: var(--text-secondary); font-size: 12px; margin-top: 3px; }
.kpi-tile .sub.warn { color: var(--status-critical); font-weight: 600; }

/* ---------- светофор ---------- */
.tl-good-2 { background: color-mix(in srgb, var(--tl-good) var(--tl-mix-2), var(--surface-1)); }
.tl-bad-1 { background: color-mix(in srgb, var(--tl-bad) var(--tl-mix-1), var(--surface-1)); }
.tl-bad-3 { background: color-mix(in srgb, var(--tl-bad) var(--tl-mix-3), var(--surface-1)); }
tbody tr:hover td.tl-good-2 { background: color-mix(in srgb, var(--tl-good) var(--tl-mix-2), var(--surface-2)); }
tbody tr:hover td.tl-bad-1 { background: color-mix(in srgb, var(--tl-bad) var(--tl-mix-1), var(--surface-2)); }
tbody tr:hover td.tl-bad-3 { background: color-mix(in srgb, var(--tl-bad) var(--tl-mix-3), var(--surface-2)); }

.badge { display: inline-flex; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--border-strong); color: var(--text-secondary); white-space: nowrap; }
.badge.good { color: var(--status-good); border-color: color-mix(in srgb, var(--status-good) 40%, transparent); }
.badge.bad { color: var(--status-critical); border-color: color-mix(in srgb, var(--status-critical) 40%, transparent); }

/* ---------- подсказки «?» ----------
   Как в портале: покоящийся тултип — псевдоэлемент от иконки; на наведении/фокусе app.js
   переводит его в position: fixed с посчитанными координатами, чтобы его не обрезал ни один
   контейнер с overflow (таблицы, <details>). */
.hint {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; border-radius: 50%; flex: none;
  background: var(--surface-3); color: var(--text-muted); border: 1px solid var(--border-strong);
  font-size: 10px; font-weight: 700; line-height: 1; margin-left: 6px; cursor: help;
  position: relative; vertical-align: middle; text-transform: none; letter-spacing: normal;
}
.hint:hover, .hint:focus-visible { background: var(--accent-tint); color: var(--accent); border-color: var(--accent); outline: none; }
.hint::after {
  content: attr(data-tip);
  position: absolute; left: 50%; bottom: 100%; transform: translate(-50%, -8px);
  background: var(--text-primary); color: var(--surface-1);
  padding: 9px 11px; border-radius: 8px; font-size: 12px; font-weight: 400;
  text-transform: none; letter-spacing: normal; line-height: 1.45;
  width: max-content; max-width: 260px; white-space: normal; text-align: left;
  box-shadow: var(--shadow-lg); pointer-events: none; z-index: 30;
  /* В ПОКОЕ ПОДСКАЗКИ НЕТ В РАСКЛАДКЕ ВОВСЕ. В портале невидимый (opacity: 0) тултип занимал
     место и распирал scrollWidth — отсюда фантомная горизонтальная прокрутка и заплатки на
     половине вкладок. display: none убирает причину; размеры для позиционирования меряет
     линейка .hint-meter, а не сам тултип. */
  display: none;
}
.hint:hover::after, .hint:focus-visible::after, .hint:focus::after { display: block; }
.hint.is-tip-out::after {
  position: fixed; left: var(--tip-l); top: var(--tip-t); right: auto; bottom: auto; transform: none;
  box-sizing: border-box; max-width: var(--tip-w, 260px);
}
.hint-meter {
  position: fixed; left: -10000px; top: 0; z-index: -1;
  padding: 9px 11px; border-radius: 8px; font-size: 12px; font-weight: 400; line-height: 1.45;
  text-transform: none; letter-spacing: normal; text-align: left;
  width: max-content; white-space: normal; visibility: hidden; pointer-events: none;
}

footer { text-align: center; padding: 24px 16px 32px; color: var(--text-muted); font-size: 12px; }
footer img { height: 26px; opacity: .8; display: block; margin: 0 auto 6px; }

@media (max-width: 640px) {
  .topbar { padding: 10px 16px; }
  .nav { margin-left: 0; width: 100%; }
  .kpi-tile .value { font-size: 19px; }
}
