/* Светлая тема по умолчанию; тёмная — по выбору (кнопка ◐ в шапке). */
:root {
  --bg: #f6f7f9; --surface: #ffffff; --text: #1d2330; --muted: #677085; --line: #dfe3ea;
  --accent: #2459d6; --accent-text: #ffffff;
  --ok-bg: #e7f6ec; --ok-text: #1b6b35; --warn-bg: #fff4dc; --warn-text: #7a5300; --err-bg: #fdeaea; --err-text: #9b1c1c;
  --green: #2e9e57; --yellow: #e0a800; --red: #d64040; --grey: #a3a9b6;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #14171d; --surface: #1d2129; --text: #e6e9ef; --muted: #9aa3b5; --line: #2d333f;
  --accent: #6d97ff; --accent-text: #0e1220;
  --ok-bg: #173323; --ok-text: #8fdcaa; --warn-bg: #3a2f12; --warn-text: #f5d27a; --err-bg: #3d1a1a; --err-text: #f4a6a6;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 1.4rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; }
code { font-size: .85em; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.top { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem; padding: .6rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 1.1rem; text-decoration: none; color: var(--text); }
.nav { display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
.nav a { text-decoration: none; }
.who { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .9rem; }
.page { max-width: 1200px; margin: 0 auto; padding: 1rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.25rem; margin: 0 0 1rem; }
.narrow { max-width: 460px; }
.stack { display: flex; flex-direction: column; gap: .75rem; }
label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; color: var(--muted); }
input, select, button { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: .45rem .6rem; min-height: 2.4rem; }
button { cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.link { background: none; border: none; color: var(--accent); padding: 0; min-height: 0; }
form.inline { display: inline-flex; gap: .35rem; align-items: center; margin: 0; }
.row-form { display: flex; align-items: center; gap: .75rem; margin: .5rem 0; }

.banner { border-radius: 8px; padding: .6rem .9rem; margin: 0 0 1rem; }
.banner.ok { background: var(--ok-bg); color: var(--ok-text); }
.banner.warn { background: var(--warn-bg); color: var(--warn-text); }
.banner.err { background: var(--err-bg); color: var(--err-text); }
body > .banner { margin: 0; border-radius: 0; }
.secret { font-size: 1.05rem; padding: .1rem .35rem; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; }
.tag { font-size: .75rem; padding: 0 .35rem; border-radius: 4px; background: var(--warn-bg); color: var(--warn-text); }

.head-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .75rem; }
.head-row h1 { margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; }

.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.table th, .table td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .8rem; color: var(--muted); font-weight: 600; }
.table tr.off td { color: var(--muted); }
.table td.actions { min-width: 12rem; }
.table td.actions form.inline { margin: 0 .25rem .25rem 0; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 10px; }
.filters input[type="search"] { min-width: 14rem; }

.light::before { content: ""; display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; margin-right: .35rem; vertical-align: -1px; background: var(--grey); }
.light.green::before { background: var(--green); }
.light.yellow::before { background: var(--yellow); }
.light.red::before { background: var(--red); }

.delta { display: inline-block; font-size: .75rem; margin-left: .25rem; }
.delta.up { color: var(--green); }
.delta.down { color: var(--red); }
.delta.flat { color: var(--muted); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.grid2 > .card { margin: 0 0 1rem; }
.reasons { list-style: none; padding: 0; margin: .25rem 0 .5rem; }
.reasons li { margin: .2rem 0; }
textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: .45rem .6rem; }
.report-head { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; margin-bottom: .5rem; }
.report-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .92rem; }
.tag.kind { background: var(--ok-bg); color: var(--ok-text); }
.tag.urgent { background: var(--err-bg); color: var(--err-text); }
.table tr.err-row td { background: var(--err-bg); }
.table tr.total td { font-weight: 600; }
label.check { flex-direction: row; align-items: center; gap: .35rem; }
.filters.card { padding: .6rem .75rem; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; margin-top: 1rem; }
.chart-card h2 { margin: 0 0 .4rem; font-size: 1rem; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.chart .line.cur { stroke: var(--accent); }
.chart .line.prev { stroke: var(--grey); stroke-dasharray: 5 4; }
.chart .dot { fill: var(--accent); }
details summary { cursor: pointer; }
a.draft-item { display: block; color: inherit; text-decoration: none; }
a.draft-item:hover { border-color: var(--accent); }
.clamp { max-height: 4.5em; overflow: hidden; }
.actions-row { display: flex; flex-wrap: wrap; gap: .5rem; }
form.reject { margin-top: 1rem; padding-top: .75rem; border-top: 1px solid var(--line); }
.tag.st-new { background: var(--warn-bg); color: var(--warn-text); }
.tag.st-editing { background: var(--warn-bg); color: var(--warn-text); }
.tag.st-approved, .tag.st-sent { background: var(--ok-bg); color: var(--ok-text); }
.tag.st-rejected { background: var(--err-bg); color: var(--err-text); }
.thumbs { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }
.thumbs img { width: 120px; height: 120px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
textarea { width: 100%; }
.props { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; }
.props dt { color: var(--muted); }
.props dd { margin: 0; }

/* Телефон: таблицы превращаются в карточки */
@media (max-width: 720px) {
  .page { padding: .75rem; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table thead { display: none; }
  .table tr { border-bottom: 1px solid var(--line); padding: .4rem 0; }
  .table td { border: none; padding: .2rem .7rem; }
  .table td::before { content: attr(data-label); display: block; font-size: .75rem; color: var(--muted); }
  .table td.actions { min-width: 0; }
  .filters input[type="search"] { min-width: 0; flex: 1; }
  form.inline { flex-wrap: wrap; }
  .who { margin-left: 0; }
}
.chain { margin: .25rem 0 0; padding-left: 1.2rem; }
.chain li.active { font-weight: 600; }
a.button { display: inline-block; text-align: center; text-decoration: none; padding: .55rem .9rem; border-radius: 6px; border: 1px solid var(--line); color: var(--text); background: var(--surface); }
a.button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
a.button.wide { display: block; }
.qr svg { width: 200px; height: 200px; background: #fff; padding: 6px; border-radius: 6px; }
hr { border: none; border-top: 1px solid var(--line); margin: 1rem 0; }
