:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1d2330;
  --muted: #667085;
  --border: #e3e6eb;
  --accent: #2557d6;
  --accent-soft: #e8eefc;
  --pos: #18794e;
  --neg: #b42318;
  --warn-bg: #fff6e0;
  --warn: #8a5a00;
  --ok-bg: #e7f6ee;
  --err-bg: #fdecea;
  --radius: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.6rem 0 .6rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* шапка */
.top { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.top-inner { max-width: 1280px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; min-height: 52px; }
.brand { font-weight: 650; margin-right: 16px; color: var(--text); }
.nav a { padding: 6px 10px; border-radius: 6px; color: var(--text); display: inline-block; }
.nav a:hover { background: var(--accent-soft); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--neg); color: #fff; font-size: .75rem; text-align: center; margin-left: 4px; }
.badge.soft { background: var(--accent-soft); color: var(--accent); }
.spacer { flex: 1; }
main { max-width: 1280px; margin: 0 auto; padding: 20px 16px 60px; }

/* сообщения */
.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 6px; background: var(--accent-soft); }
.messages li.success { background: var(--ok-bg); }
.messages li.error { background: var(--err-bg); }
.messages li.warning { background: var(--warn-bg); }

/* карточки и таблицы */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.tile .num { font-size: 1.6rem; font-weight: 650; }
.tile .label { color: var(--muted); font-size: .85rem; }
.tile.alert { border-color: var(--neg); }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; background: #fafbfc; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tr.dim td { color: var(--muted); }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.nowrap { white-space: nowrap; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: .78rem; background: #eef0f3; color: var(--muted); white-space: nowrap; }
.tag.tax { background: #fdf0d5; color: #7a4b00; }
.tag.neutral { background: #e8eefc; color: #23439a; }
.tag.household { background: #e9f5ec; color: #23613a; }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.err { background: var(--err-bg); color: var(--neg); }
.tag.ok { background: var(--ok-bg); color: var(--pos); }

/* формы */
form.inline { display: inline; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 12px; }
.filters label { display: flex; flex-direction: column; font-size: .8rem; color: var(--muted); gap: 2px; }
input[type=text], input[type=search], input[type=password], input[type=date], input[type=number], select, textarea {
  font: inherit; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--text); max-width: 100%;
}
textarea { width: 100%; }
button, .btn {
  font: inherit; padding: 6px 14px; border-radius: 6px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; display: inline-block;
}
button.secondary, .btn.secondary { background: #fff; color: var(--accent); }
button.danger { background: #fff; color: var(--neg); border-color: var(--neg); }
button.small, .btn.small { padding: 2px 8px; font-size: .85rem; }
.btn:hover { text-decoration: none; }
.form-grid p { margin: 0 0 12px; display: flex; flex-direction: column; gap: 3px; max-width: 640px; }
.form-grid label { font-weight: 600; font-size: .9rem; }
.form-grid .helptext { color: var(--muted); font-size: .8rem; }
.form-grid input[type=checkbox] { align-self: flex-start; }
.errorlist { color: var(--neg); margin: 0; padding-left: 18px; font-size: .85rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0 16px; }
.login-box { max-width: 380px; margin: 60px auto; }
.qr { background: #fff; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); width: 220px; }
code { background: #eef0f3; padding: 1px 5px; border-radius: 4px; font-size: .9em; word-break: break-all; }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 12px; }

@media (max-width: 700px) {
  .brand { width: 100%; padding-top: 8px; }
  th, td { padding: 6px; }
  .hide-sm { display: none; }
}
.site-footer { max-width: 1200px; margin: 32px auto 24px; padding: 0 16px; text-align: center; }
.form-grid p.check { flex-direction: row; }
.form-grid p.check label { font-weight: 400; }
.legal { max-width: 820px; margin: 0 auto; line-height: 1.55; }
.legal h2 { margin-top: 28px; font-size: 1.15rem; }
.legal .legal-nav { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.legal .legal-nav .active { font-weight: 700; text-decoration: none; color: inherit; }
.lang-switch { margin-left: 12px; }
.lang-switch button.link { background: none; border: none; padding: 0 4px; color: var(--muted); cursor: pointer; font: inherit; text-decoration: underline; }
.lang-switch button.link.active { color: inherit; font-weight: 700; text-decoration: none; }
