/* Панель ОС. Цвета — токены light-dark(); тема по системе телефона/компьютера. */
:root {
  color-scheme: light dark;
  --bg: light-dark(#f6f7f9, #111418);
  --surface: light-dark(#ffffff, #1a1e24);
  --surface-2: light-dark(#f0f2f5, #232830);
  --text: light-dark(#1b1f24, #e7eaee);
  --muted: light-dark(#5d6670, #9aa3ad);
  --line: light-dark(#e2e5e9, #2e343c);
  --accent: light-dark(#1f5fbf, #7aa7ff);
  --danger: light-dark(#b42318, #ff8a80);
  --ok: light-dark(#1e7d3c, #6fd48f);
  --warn: light-dark(#a15c00, #f5b454);
  /* статусы объекта — порядковая шкала одного оттенка (проверено validate_palette.js --ordinal, 27.09.2026);
     «неизвестно» — нейтральный серый вне шкалы. Цвет всегда рядом с подписью. */
  --st-unknown: light-dark(#a3a29b, #6b6b66);
  --st-not_started: light-dark(#86b6ef, #184f95);
  --st-delivered: light-dark(#5598e7, #256abf);
  --st-installed: light-dark(#2a78d6, #3987e5);
  --st-accepted: light-dark(#1c5cab, #6da7ec);
  --st-paid: light-dark(#104281, #b7d3f6);
  --series-1: light-dark(#2a78d6, #3987e5);
  --grid: light-dark(#e6e8eb, #2b3037);
  --radius: 10px;
  accent-color: var(--accent);
}
* { 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); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.35rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.05rem; margin: 1.6rem 0 .6rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }

.top { position: sticky; top: 0; z-index: 1000; display: flex; flex-wrap: wrap; align-items: center; gap: .3rem 1rem;
  padding: .55rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-weight: 650; color: var(--text); }
.top nav { display: flex; gap: .2rem; flex-wrap: wrap; flex: 1; }
.top nav a { padding: .3rem .6rem; border-radius: 8px; color: var(--text); }
.top nav a[aria-current="page"] { background: var(--surface-2); font-weight: 600; }
@media (max-width: 700px) {
  .top nav { order: 3; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -.4rem; }
  .top nav a { white-space: nowrap; }
  .top form { margin-left: auto; }
}
main { max-width: 1180px; margin: 0 auto; padding: 1rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.grid { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.kpi .v { font-size: 1.6rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: .85rem; }
.cols { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 900px) { .cols { grid-template-columns: 3fr 2fr; } }

.badge { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; font-size: .85rem; }
.badge::before { content: ""; width: .65rem; height: .65rem; border-radius: 50%; background: var(--dot, var(--st-unknown)); }
.st-unknown { --dot: var(--st-unknown); } .st-not_started { --dot: var(--st-not_started); }
.st-delivered { --dot: var(--st-delivered); } .st-installed { --dot: var(--st-installed); }
.st-accepted { --dot: var(--st-accepted); } .st-paid { --dot: var(--st-paid); }
.bar { display: flex; height: .7rem; border-radius: 99px; overflow: hidden; background: var(--surface-2); gap: 2px; }
.bar span { background: var(--dot); }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .8rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .8rem; }
.chip { padding: .25rem .6rem; border: 1px solid var(--line); border-radius: 99px; background: var(--surface);
  color: var(--text); font-size: .85rem; }
.chip[aria-current="true"] { border-color: var(--accent); background: var(--surface-2); font-weight: 600; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
textarea { width: 100%; min-height: 4.5rem; resize: vertical; }
button, .btn { padding: .5rem .9rem; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent);
  color: light-dark(#fff, #0b1220); font-weight: 600; cursor: pointer; }
button.link { background: none; border: 0; color: var(--muted); padding: .3rem; font-weight: 400; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; }
th, td { padding: .5rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
@media (max-width: 640px) { .wide { display: none; } th, td { padding: .45rem .5rem; } }

.dl { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.dl dt { color: var(--muted); } .dl dd { margin: 0; }
#map { height: 420px; border-radius: var(--radius); border: 1px solid var(--line); margin-bottom: 1rem; }
@media (max-width: 640px) { #map { height: 320px; } }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: .6rem 0; border-bottom: 1px solid var(--line); }
.feed .meta { font-size: .8rem; color: var(--muted); }
.feed .text { white-space: pre-wrap; overflow-wrap: anywhere; }

.auth { max-width: 380px; margin: 8vh auto; }
.auth form { display: grid; gap: .8rem; }
.auth label { display: grid; gap: .3rem; font-weight: 600; font-size: .9rem; }
.error { color: var(--danger); } .success { color: var(--ok); } .warn { color: var(--warn); }
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.chart { width: 100%; height: auto; display: block; }

/* график: столбики одного ряда, подсказка при наведении, таблица — под графиком */
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--series-1); }
.chart .hit { fill: transparent; }
.chart g.col:hover .bar { opacity: .75; }
.chart .val { fill: var(--text); font-size: 11px; font-weight: 600; }
.stack { display: flex; gap: 2px; height: 14px; border-radius: 4px; overflow: hidden; margin: .4rem 0 .6rem; }
.stack span { background: var(--dot); min-width: 2px; }
.legend a { color: var(--text); }
.legend { display: flex; flex-wrap: wrap; gap: .3rem 1rem; list-style: none; padding: 0; margin: 0; font-size: .85rem; }
details.data summary { cursor: pointer; color: var(--muted); font-size: .85rem; margin-top: .5rem; }
.thumbs { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .4rem; }
.thumbs img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.messages .warning { color: var(--warn); } .messages .success { color: var(--ok); }

/* наряды: стадия — текстом, просрочка — цвет опасности + слово «просрочен» (не только цвет) */
.stage { font-size: .85rem; white-space: nowrap; padding: .1rem .45rem; border-radius: 99px; background: var(--surface-2); }
.stage-done, .stage-accepted { color: var(--ok); }
.stage-cancelled { color: var(--muted); text-decoration: line-through; }
.late { color: var(--danger); font-weight: 600; font-size: .85rem; }
tr.overdue td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
fieldset.check { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 .6rem; padding: .5rem .7rem; }
fieldset.check legend { font-size: .9rem; padding: 0 .3rem; }
fieldset.check label { margin-right: .9rem; white-space: nowrap; }
fieldset.check input[type=text] { width: 100%; margin-top: .4rem; }
.cal { display: grid; gap: 2px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cal-head, .cal-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.cal-head span { background: var(--surface-2); color: var(--muted); font-size: .8rem; padding: .3rem .4rem; }
.cal-day { background: var(--surface); min-height: 5.5rem; padding: .3rem; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal-day.out { background: var(--surface-2); color: var(--muted); }
.cal-day.today .cal-date { color: var(--accent); font-weight: 700; }
.cal-date { font-size: .8rem; }
.cal-o { font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text);
  background: var(--surface-2); border-radius: 4px; padding: 0 .25rem; }
.cal-o.overdue { box-shadow: inset 2px 0 0 var(--danger); }
.cal-list { list-style: none; padding: 0; } .cal-list li { padding: .35rem 0; border-bottom: 1px solid var(--line); }
@media (max-width: 640px) { .cal { display: none; } }
@media (min-width: 641px) { .cal-list-title, .cal-list { display: none; } }
@media (max-width: 640px) {
  .orders-table thead { display: none; }
  .orders-table tr { display: grid; grid-template-columns: 1fr auto; gap: .15rem .8rem; padding: .55rem .7rem;
    border-bottom: 1px solid var(--line); }
  .orders-table td { border: 0; padding: 0; }
  .orders-table td.num { text-align: left; }
  .orders-table tr.overdue td:first-child { box-shadow: none; }
  .orders-table tr.overdue { box-shadow: inset 3px 0 0 var(--danger); }
}
button.secondary { background: var(--surface); color: var(--accent); }
