/* Сверка актов. Цвет несёт смысл: зелёный — сходится, жёлтый — проверить, красный — расхождение. */

:root {
  color-scheme: light;        /* тему выбирает assets/theme.js; окно входа внутри программы берёт её же — иначе браузер подложит под него белый фон */
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --text: #1a1d24;
  --muted: #667085;
  --line: #e5e8ee;
  --accent: #3355d8;
  --accent-soft: #eaf0ff;
  --accent-text: #ffffff;
  --ok: #0f7a55;       --ok-bg: #e7f6ef;
  --warn: #a15c07;     --warn-bg: #fdf3e1;
  --bad: #b3261e;      --bad-bg: #fdecea;
  --panel-line: #dcdfe6;   /* рамка вокруг результата сверки */
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 16px 32px -20px rgba(16, 24, 40, .18);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12151b;  --surface: #1b1f27;  --surface-2: #212632;
  --text: #e9ebf1;  --muted: #98a2b3;  --line: #2c3140;
  --accent: #7d9dff;  --accent-soft: #232c4a;  --accent-text: #10131a;
  --ok: #4cc79a;  --ok-bg: #16302a;
  --warn: #f0b45a;  --warn-bg: #362b17;
  --bad: #ff8a80;  --bad-bg: #3a1f1d;
  --panel-line: #272b35;
  --shadow: 0 10px 28px -18px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.page { max-width: 1040px; min-height: 100vh; margin: 0 auto; padding: 28px 20px 20px; display: flex; flex-direction: column; }

header.top { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 16px; margin-bottom: 24px; }
header.top h1 { margin: 0; font-size: 21px; font-weight: 650; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; }
header.top .logo { width: 32px; height: 32px; flex: none; }
header.top .tagline { margin: 2px 0 0 42px; color: var(--muted); font-size: 14px; }
@media (max-width: 640px) {
  header.top { flex-direction: column; align-items: flex-start; }
  header.top > .theme-toggle { margin-left: 0; }
}
.foot { margin-top: auto; padding-top: 48px; }
.foot-inner { padding-top: 16px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 8px 24px; flex-wrap: wrap; }
.foot a { color: inherit; text-decoration: none; }
.foot a:hover { text-decoration: underline; }
.foot-links { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--text); font-size: 13px; }
.foot-mail { color: var(--muted); font-size: 12px; opacity: .65; }
.foot-right { display: flex; gap: 6px 18px; flex-wrap: wrap; }
.foot-ver { color: var(--muted); font-size: 12px; opacity: .65; }

/* «Ваша конфиденциальность» в подвале: ссылка открывает карточку над собой, без скриптов */
.privacy { position: relative; }
.privacy summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.privacy summary::-webkit-details-marker { display: none; }
.privacy summary:hover, .privacy[open] summary { text-decoration: underline; }
.privacy-card {
  position: absolute; left: 0; bottom: calc(100% + 10px); z-index: 10;
  width: min(340px, calc(100vw - 40px)); padding: 14px 16px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  font-size: 13px; line-height: 1.5;
}
.privacy-card b { display: block; margin-bottom: 4px; color: var(--accent); }
.privacy-card p { margin: 0; color: var(--muted); }

h2 { margin: 0; font-size: 16px; }
h3 { margin: 0; font-size: 14px; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

button { font: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-weight: 500;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font-size: 13px; text-decoration: underline; }

/* ---------- Загрузка ---------- */
.slots { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: stretch; margin-bottom: 20px; }
.swap { align-self: center; margin-top: 35px; }   /* по центру карточек, а не вместе с заголовками над ними */
.slot {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; min-width: 0;
}
.slot-col { display: flex; flex-direction: column; min-width: 0; }
.slot-col > .slot { flex: 1; }
.block-title { font-size: 16px; margin: 0 0 10px; }

.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 116px; padding: 16px; text-align: center; cursor: pointer;
  border: 2px dashed var(--line); border-radius: var(--radius-sm); color: var(--muted);
  transition: border-color .12s, background .12s;
}
.drop:hover, .drop.dragover, .drop:focus-within { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.drop strong { color: var(--text); font-weight: 600; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }

/* распознавание скана: та же плашка, что для загрузки, с полосой хода */
.drop.scanning { cursor: default; border-style: solid; border-color: var(--accent); background: var(--accent-soft); gap: 6px; }
.drop.scanning .scan-page { color: var(--accent); font-size: 13px; font-variant-numeric: tabular-nums; }
.progress { width: min(280px, 85%); height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress > span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width .4s ease; }
.scan-note { margin-top: 10px; padding: 8px 12px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); font-size: 13px; }

.file-org { font-size: 17px; font-weight: 600; margin: 0 0 2px; overflow-wrap: anywhere; }
.file-meta { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.slot-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.remove { background: none; border: 0; color: var(--muted); font-size: 22px; line-height: 1; padding: 0 4px; }
.remove:hover { color: var(--bad); }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 500; margin-top: 10px; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }

.slot-note { margin-top: 10px; font-size: 13px; color: var(--muted); }
.slot-error { margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: var(--bad-bg); color: var(--bad); font-size: 13px; }
.slot-error.same-org { margin-bottom: 12px; }
.gap-top { margin-top: 18px; }
.gap-bottom { margin-bottom: 6px; }
details.warns { margin-top: 10px; font-size: 13px; }
details.warns summary { cursor: pointer; color: var(--warn); }
details.warns ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); }

/* ---------- Итог ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }

.verdict { border-radius: var(--radius); padding: 20px 22px; margin-bottom: 16px; border: 1px solid transparent; }
.verdict.ok { background: var(--ok-bg); color: var(--ok); }
.verdict.warn { background: var(--warn-bg); color: var(--warn); }
.verdict.bad { background: var(--bad-bg); color: var(--bad); }
.verdict .label { font-size: 13px; opacity: .85; }
.verdict .big { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin: 2px 0 6px; font-variant-numeric: tabular-nums; }
.verdict .facts { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; color: var(--text); }
.verdict .facts b { font-weight: 600; }
.verdict .amounts-only { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 14px; color: var(--text); display: grid; gap: 4px; }
.verdict .amounts-only .doc { font-weight: 600; font-variant-numeric: tabular-nums; }
.verdict .forecast { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 14px; color: var(--text); }
.verdict .forecast b { font-weight: 600; font-variant-numeric: tabular-nums; }
.verdict .forecast details.fold { margin-top: 6px; font-size: 13px; color: var(--muted); }
.verdict .forecast .caveats { margin: 0; padding-left: 18px; font-size: 13px; color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
th.num, td.num { text-align: right; }
th.date, td.date { width: 1%; white-space: nowrap; font-variant-numeric: tabular-nums; }   /* дата слева, под заголовком, колонка по ширине даты */
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
tr.total td { font-weight: 600; border-top: 2px solid var(--line); background: none; }
td.diff.zero { color: var(--ok); }
td.diff.nonzero { color: var(--bad); font-weight: 600; }
.table-scroll { overflow-x: auto; }

.note { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
.reasons { padding-left: 18px; display: grid; gap: 10px; }
.reasons .table-scroll { margin-top: 6px; }
.reasons td { color: var(--text); }
.bridge-sum { font-size: 14px; margin: 0 0 8px; }

/* ---------- Письмо ---------- */
.tabs { display: flex; gap: 4px; margin-bottom: 10px; border-bottom: 1px solid var(--line); }
.tab { background: none; border: 0; padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab .count { background: var(--surface-2); border-radius: 999px; padding: 0 8px; margin-left: 6px; font-size: 12px; }
textarea.letter {
  width: 100%; min-height: 170px; resize: vertical; padding: 12px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font-family: inherit; font-size: 14px; line-height: 1.6;
}
.letter-actions { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.copied { color: var(--ok); font-size: 13px; }

/* ---------- Разделы «что проверить» ---------- */
.result-panel { border: 1px solid var(--panel-line); border-radius: calc(var(--radius) + 4px); padding: 18px 18px 2px; }
.block { margin-bottom: 24px; }
.block > .card { margin-bottom: 0; }
details.section { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); margin-bottom: 12px; }
details.section > summary { list-style: none; cursor: pointer; padding: 14px 18px; display: flex; align-items: center; gap: 10px; font-weight: 600; }
details.section > summary::-webkit-details-marker { display: none; }
details.section > summary::before { content: "▸"; color: var(--muted); font-size: 12px; transition: transform .12s; }
details.section[open] > summary::before { transform: rotate(90deg); }
details.section .count { margin-left: auto; font-weight: 500; }
details.section .body { padding: 0 18px 14px; }
.tone-bad > summary { color: var(--bad); }
.tone-warn > summary { color: var(--warn); }
details.fold > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: "▸"; color: var(--muted); font-size: 12px; transition: transform .12s; }
details.fold[open] > summary::before { transform: rotate(90deg); }
details.fold[open] > summary { margin-bottom: 6px; }
details.fold.plain > summary { font-weight: inherit; font-size: inherit; gap: 6px; }   /* шеврон в списке: как обычная строка */
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--surface-2); color: var(--muted); margin-left: 6px; }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.doc-main { font-weight: 500; overflow-wrap: anywhere; }
.doc-sub { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.pair-note { color: var(--text); font-size: 13px; overflow-wrap: anywhere; }
.tone-warn .pair-note { color: var(--warn); font-weight: 500; }
/* шапка таблицы сальдо: название организации второй строкой, длинное — переносится, колонка не растягивается */
th.side-head { white-space: normal; width: 30%; }
th.side-head .org { font-size: 12px; font-weight: 400; text-transform: none; letter-spacing: 0; overflow-wrap: anywhere; margin-top: 2px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.banner { margin-bottom: 12px; padding: 12px 16px; border-radius: var(--radius); font-size: 14px; }
.banner.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn); }
.banner.bad { background: var(--bad-bg); color: var(--bad); border: 1px solid var(--bad); font-weight: 600; }
.banner b { font-weight: 700; }

.empty { color: var(--muted); padding: 32px 16px; text-align: center; }
.steps { color: var(--muted); font-size: 14px; }
.steps b { color: var(--text); }
.check-btn { padding: 10px 32px; font-size: 15px; font-weight: 600; }
.check-btn:disabled { opacity: .45; cursor: default; filter: none; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 760px) {
  .slots { grid-template-columns: 1fr; }
  .swap { justify-self: center; margin-top: 0; }
  .pair { grid-template-columns: 1fr; }
  .verdict .big { font-size: 24px; }
  .result-panel { padding: 12px 10px 2px; }
}
td.note-cell { white-space: normal; }   /* «совпадает с учётом сторно / документа прошлого периода» с пояснением — переносится */
