/* Cabinet styles. No external assets; colours are tokens with a dark variant. */
:root {
  --bg: #f6f6f3;
  --panel: #ffffff;
  --text: #1d1d1b;
  --muted: #6b6b66;
  --line: #e2e1dc;
  --accent: #185fa5;
  --accent-bg: #e6f1fb;
  --danger: #a32d2d;
  --danger-bg: #fcebeb;
  --ok: #3b6d11;
  --ok-bg: #eaf3de;
  --warn: #854f0b;
  --warn-bg: #faeeda;
  --radius: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1b1a;
    --panel: #242423;
    --text: #ecebe6;
    --muted: #a5a49e;
    --line: #3a3a38;
    --accent: #85b7eb;
    --accent-bg: #0c2c4c;
    --danger: #f09595;
    --danger-bg: #4a1b1b;
    --ok: #97c459;
    --ok-bg: #213410;
    --warn: #ef9f27;
    --warn-bg: #412402;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
h1 { font-size: 24px; font-weight: 600; margin: 8px 0 4px; overflow-wrap: anywhere; }
h2 { font-size: 18px; font-weight: 600; margin: 28px 0 10px; }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 6px; }
p { margin: 0 0 10px; }
code { font-size: 13px; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); }
.warn-text { color: var(--warn); }
.ok-text { color: var(--ok); }
.nowrap { white-space: nowrap; }
.pre-line { white-space: pre-line; overflow-wrap: anywhere; }
.subtitle { color: var(--muted); margin: 0 0 16px; }

/* ---------- header and navigation */
header.top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding: 10px 24px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 600; text-decoration: none; color: var(--text); white-space: nowrap; }
nav.main { display: flex; flex-wrap: wrap; gap: 2px 4px; }
nav.main a { text-decoration: none; padding: 4px 8px; border-radius: var(--radius); white-space: nowrap; }
nav.main a.active { background: var(--accent-bg); font-weight: 600; }
.mode { margin-left: auto; padding: 4px 10px; border-radius: var(--radius); font-size: 13px; }
.mode-dry_run { background: var(--ok-bg); color: var(--ok); }
.mode-test { background: var(--warn-bg); color: var(--warn); }
.mode-live { background: var(--danger-bg); color: var(--danger); font-weight: 600; }
main { max-width: 1280px; margin: 0 auto; padding: 16px 24px 48px; }

/* ---------- footer: credit of the open data behind completed addresses */
footer.credits { max-width: 1280px; margin: 0 auto; padding: 0 24px 24px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
footer.credits p { margin: 0; padding-top: 10px; border-top: 1px solid var(--line); }
footer.credits a { color: inherit; }
.registry-mark { cursor: help; }

/* ---------- messages and callouts */
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; overflow-wrap: anywhere; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-warn { background: var(--warn-bg); color: var(--warn); }
.flash-error { background: var(--danger-bg); color: var(--danger); }
.callout { border: 1px solid var(--line); border-left-width: 4px; border-radius: var(--radius); background: var(--panel); padding: 12px 16px; margin: 12px 0; }
.callout > :last-child { margin-bottom: 0; }
.callout h2 { margin: 0 0 8px; font-size: 16px; }
.callout ul { margin: 6px 0 0; padding-left: 20px; }
.callout-info { border-left-color: var(--accent); background: var(--accent-bg); }
.callout-ok { border-left-color: var(--ok); background: var(--ok-bg); }
.callout-warn { border-left-color: var(--warn); background: var(--warn-bg); }
.callout-danger { border-left-color: var(--danger); background: var(--danger-bg); }
.callout-muted { border-left-color: var(--line); color: var(--muted); }
.callout-warn b, .callout-warn strong { color: var(--warn); }
.callout-danger b, .callout-danger strong { color: var(--danger); }
.visit-info { font-size: 16px; }
.visit-info p { margin: 4px 0; }

/* ---------- badges and chips */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; line-height: 1.6; white-space: nowrap; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.badge-ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge-info { background: var(--accent-bg); color: var(--accent); border-color: transparent; }
.badge-warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge-danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 12px; }
.chip { display: inline-flex; gap: 6px; align-items: center; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); text-decoration: none; font-size: 13px; color: var(--text); }
.chip b { color: var(--muted); font-weight: 600; }
.chip.active { border-color: var(--accent); background: var(--accent-bg); color: var(--accent); }
.chip.active b { color: var(--accent); }
.chip.empty { opacity: .6; }

/* ---------- stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 12px; }
.stats a { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; text-decoration: none; color: var(--text); }
.stats a:hover { border-color: var(--accent); }
.stats b { display: block; font-size: 26px; font-weight: 600; }
.stats span { color: var(--muted); font-size: 13px; }

/* ---------- tables */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
td.num { white-space: nowrap; }
tr.row-danger td:first-child { box-shadow: inset 4px 0 0 var(--danger); }
tr.row-warn td:first-child { box-shadow: inset 4px 0 0 var(--warn); }
tr.row-muted td { color: var(--muted); }
td .sub { display: block; color: var(--muted); font-size: 13px; }
td .sources { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 13px; }
td .badge { white-space: normal; border-radius: 6px; }
td .sub .badge { margin-top: 2px; }
table.matches td:nth-child(1) { min-width: 220px; }
table.matches td:nth-child(2) { min-width: 150px; }
table.matches td:nth-child(3) { min-width: 200px; }
table.matches td:nth-child(4) { min-width: 130px; }

/* ---------- buttons and forms */
button, .btn { display: inline-block; font: inherit; font-size: 14px; line-height: 1.4; padding: 6px 12px; border-radius: var(--radius); border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; text-decoration: none; white-space: nowrap; }
button:disabled { opacity: .55; cursor: progress; }
button.ghost, .btn.ghost { background: transparent; color: var(--accent); }
button.danger, .btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.small, .btn.small { padding: 3px 10px; font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.row-actions form { margin: 0; }
input, select, textarea { font: inherit; font-size: 14px; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--text); max-width: 100%; }
input[type=checkbox] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.inline-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: end; margin: 6px 0; }
.filters label { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--muted); }
.js .when-nojs { display: none; }
.grid-form fieldset { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 16px; min-width: 0; }
.grid-form legend { font-weight: 600; padding: 0 6px; }
.grid-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); min-width: 0; }
.grid-form label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
.grid-form .wide { grid-column: 1 / -1; }
.grid-form .checks { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }

/* ---------- availability editor */
.av-rows { display: flex; flex-direction: column; gap: 8px; }
.av-row { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.av-row .days { display: flex; flex-wrap: wrap; gap: 4px; }
.grid-form .av-row label.day { flex-direction: row; align-items: center; gap: 4px; padding: 3px 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--text); font-size: 13px; cursor: pointer; }
.grid-form .av-row label.time { flex-direction: row; align-items: center; gap: 6px; }

/* ---------- facts, letters, details */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin: 0 0 12px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin: 8px 0; font: 14px/1.5 ui-monospace, Consolas, monospace; }
details { margin: 8px 0; }
summary { cursor: pointer; color: var(--accent); }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 0 24px; }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.list-plain li:last-child { border-bottom: none; }
.pager { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin: 12px 0; }
.confirm-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 16px 0; }

/* ---------- phones: tables marked .stack become one card per row */
@media (max-width: 760px) {
  header.top { padding: 8px 12px; gap: 6px 12px; }
  .mode { margin-left: 0; }
  nav.main { width: 100%; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; scrollbar-width: thin; }
  main { padding: 12px 12px 40px; }
  footer.credits { padding: 0 12px 16px; }
  .stats { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .stats a { padding: 6px 8px; }
  .stats b { font-size: 20px; }
  .stats span { font-size: 12px; line-height: 1.3; display: block; }
  h1 { font-size: 21px; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack thead { display: none; }
  table.stack tr { border-bottom: 1px solid var(--line); padding: 6px 0; }
  table.stack tbody tr:last-child { border-bottom: none; }
  table.stack td { border: none; padding: 3px 12px; }
  table.stack td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; color: var(--muted); }
  table.stack td:empty { display: none; }
  tr.row-danger, tr.row-warn { border-left: 4px solid var(--danger); }
  tr.row-warn { border-left-color: var(--warn); }
  tr.row-danger td:first-child, tr.row-warn td:first-child { box-shadow: none; }
  .facts { grid-template-columns: 1fr; gap: 0; }
  .facts dd { margin-bottom: 6px; }
  button, .btn { padding: 8px 14px; }
}
@media print {
  header.top, .actions, .row-actions, form { display: none; }
}

/* "Сделать сейчас": one card per flat, the action buttons large enough for a phone */
.todo-list { display: grid; gap: 10px; margin-bottom: 18px; }
.todo-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.todo-card.todo-planb { border-left: 4px solid var(--warn); }
.todo-card.todo-soon { opacity: .85; }
.todo-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.todo-price { font-size: 1.15em; }
.todo-text { width: 100%; margin: 8px 0 4px; font: inherit; font-size: .92em; padding: 8px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--bg); color: var(--text); resize: vertical; }
.todo-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.todo-actions form { margin: 0; }
.todo-actions .btn, .todo-actions button { min-height: 36px; }
.todo-actions button.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.todo-stats a b { font-size: 1.6em; }
