/* Помощник сметчика — административная панель.
 * Тот же визуальный язык, что у сайта пользователя (палитра, шрифты, знак),
 * но плотнее: таблицы, фильтры, боковая карточка записи. */

:root {
  --bg: #f6f4ee;
  --bg-sidebar: #efece4;
  --surface: #ffffff;
  --surface-2: #faf8f3;
  --ink: #1e1d1a;
  --ink-2: #4a4740;
  --muted: #7a766c;
  --line: #e4dfd3;
  --line-strong: #d4cdbd;
  --accent: #1f5b4e;
  --accent-ink: #ffffff;
  --accent-soft: #e3eee9;
  --accent-hover: #184a3f;
  --focus: #2f7d6a;
  --danger: #a33a2c;
  --danger-soft: #f7e6e2;
  --warn: #8a5a12;
  --warn-soft: #f8eedb;
  --info: #3c6aa6;
  --info-soft: #e5ecf6;
  --norm-bg: #edf2ee;
  --norm-ink: #1f4a40;
  --shadow-1: 0 1px 2px rgba(30, 29, 26, .06), 0 1px 1px rgba(30, 29, 26, .04);
  --shadow-2: 0 10px 30px rgba(30, 29, 26, .10), 0 2px 6px rgba(30, 29, 26, .06);
  --shadow-3: 0 24px 60px rgba(30, 29, 26, .18), 0 4px 12px rgba(30, 29, 26, .08);
  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1d1c1a; --bg-sidebar: #171614; --surface: #272622; --surface-2: #22211e;
    --ink: #ece9e1; --ink-2: #c9c4b8; --muted: #9a9588; --line: #34322d; --line-strong: #45423b;
    --accent: #7cc4ad; --accent-ink: #10201b; --accent-soft: #233630; --accent-hover: #93d3be; --focus: #7cc4ad;
    --danger: #e58a7b; --danger-soft: #3a2420; --warn: #e2b469; --warn-soft: #3a2f1c; --info: #8fb1e3; --info-soft: #222c3a;
    --norm-bg: #23332d; --norm-ink: #a7dccb;
    --shadow-1: 0 1px 2px rgba(0,0,0,.3); --shadow-2: 0 10px 30px rgba(0,0,0,.35); --shadow-3: 0 24px 60px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1d1c1a; --bg-sidebar: #171614; --surface: #272622; --surface-2: #22211e;
  --ink: #ece9e1; --ink-2: #c9c4b8; --muted: #9a9588; --line: #34322d; --line-strong: #45423b;
  --accent: #7cc4ad; --accent-ink: #10201b; --accent-soft: #233630; --accent-hover: #93d3be; --focus: #7cc4ad;
  --danger: #e58a7b; --danger-soft: #3a2420; --warn: #e2b469; --warn-soft: #3a2f1c; --info: #8fb1e3; --info-soft: #222c3a;
  --norm-bg: #23332d; --norm-ink: #a7dccb;
  --shadow-1: 0 1px 2px rgba(0,0,0,.3); --shadow-2: 0 10px 30px rgba(0,0,0,.35); --shadow-3: 0 24px 60px rgba(0,0,0,.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
svg.i { width: 17px; height: 17px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }

/* --- вход ------------------------------------------------------------- */

.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-2); padding: 28px; }
.auth-card .mark { width: 40px; height: 40px; margin-bottom: 14px; }
.auth-card h1 { font-family: var(--serif); font-weight: 400; font-size: 26px; margin: 0 0 4px; }
.auth-card p.sub { color: var(--muted); margin: 0 0 20px; }
.secret-box { background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: 10px; padding: 12px; font-family: var(--mono); font-size: 15px; letter-spacing: 1px; word-break: break-all; text-align: center; margin: 8px 0 12px; }
.otp { letter-spacing: 6px; font-family: var(--mono); font-size: 18px; text-align: center; }

/* --- каркас ----------------------------------------------------------- */

.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); height: 100vh; }
.nav { background: var(--bg-sidebar); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.nav-brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 14px; }
.nav-brand svg { width: 28px; height: 28px; }
.nav-brand b { font-family: var(--serif); font-weight: 400; font-size: 16px; display: block; line-height: 1.15; }
.nav-brand span { font-size: 11.5px; color: var(--muted); }
.nav-list { padding: 4px 8px; display: grid; gap: 2px; overflow-y: auto; flex: 1; align-content: start; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: var(--ink-2); text-decoration: none; }
.nav-item:hover { background: rgba(127, 120, 100, .12); color: var(--ink); }
.nav-item[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); font-weight: 560; }
.nav-item .count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--danger); color: #fff; font-size: 11.5px; font-weight: 650; display: inline-grid; place-items: center; }
.nav-sep { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); padding: 14px 10px 4px; }
.nav-foot { border-top: 1px solid var(--line); padding: 12px 14px; font-size: 12.5px; color: var(--muted); display: grid; gap: 6px; }
.nav-foot b { color: var(--ink); font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.roles { display: flex; gap: 4px; flex-wrap: wrap; }

.content { min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 28px; border-bottom: 1px solid var(--line); background: var(--bg); flex: none; }
.topbar h1 { font-family: var(--serif); font-weight: 400; font-size: 24px; margin: 0; }
.topbar .spacer { flex: 1; }
.stepup-pill { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); font-size: 12.5px; color: var(--ink-2); }
.stepup-pill.on { border-color: transparent; background: var(--accent-soft); color: var(--accent); }
.page { flex: 1; overflow-y: auto; padding: 22px 28px 48px; }
.page-inner { max-width: 1240px; }

/* --- элементы --------------------------------------------------------- */

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-weight: 560; font-size: 13.5px; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--ink-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: rgba(127, 120, 100, .12); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 0; background: transparent; color: var(--ink-2); }
.icon-btn:hover { background: rgba(127, 120, 100, .12); color: var(--ink); }

.input, .select, .textarea { width: 100%; height: 36px; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--surface); padding: 0 11px; outline: 0; }
.textarea { height: auto; min-height: 84px; padding: 8px 11px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field { display: grid; gap: 5px; margin-bottom: 12px; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field .help { font-size: 12px; color: var(--muted); }
.check { display: flex; gap: 9px; align-items: flex-start; margin-bottom: 10px; cursor: pointer; }
.check input { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--accent); }
.form-error { background: var(--danger-soft); color: var(--danger); border-radius: 9px; padding: 9px 12px; font-size: 13px; margin-bottom: 12px; }
.form-ok { background: var(--accent-soft); color: var(--accent); border-radius: 9px; padding: 9px 12px; font-size: 13px; margin-bottom: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row .grow { flex: 1; }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .input { width: 280px; }
.toolbar .select { width: auto; min-width: 160px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; height: 28px; padding: 0 12px; border-radius: 7px; color: var(--ink-2); font-weight: 560; font-size: 13px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-1); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 0; }
.card-head h2 { font-size: 14px; font-weight: 650; margin: 0; }
.card-body { padding: 14px 16px 16px; }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.two { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.halves { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpis.six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi { padding: 14px 16px; }
.kpi .label { font-size: 12.5px; color: var(--muted); }
.kpi .value { font-family: var(--serif); font-size: 30px; line-height: 1.15; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.kpi .value small { font-family: var(--sans); font-size: 13px; color: var(--muted); margin-left: 4px; }
.kpi .note { font-size: 12px; color: var(--muted); }
.kpi .note.bad { color: var(--danger); }
.kpi .note.ok { color: var(--accent); }

.banner { display: flex; gap: 10px; align-items: flex-start; border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; background: var(--warn-soft); color: var(--warn); }
.banner.bad { background: var(--danger-soft); color: var(--danger); }
.banner b { display: block; }

.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
table.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr.clickable { cursor: pointer; }
table.t tbody tr.clickable:hover td { background: var(--surface-2); }
table.t tbody tr.selected td { background: var(--accent-soft); }
table.t.fixed { table-layout: fixed; }
table.t .clip { max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 10px 12px; border-top: 1px solid var(--line); }

.chart { width: 100%; height: 190px; display: block; }
.chart .bar { fill: var(--accent); }
.chart .bar:hover { fill: var(--accent-hover); }
.chart .axis { stroke: var(--line); }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--sans); }

/* боковая карточка записи */
.drawer-overlay { position: fixed; inset: 0; z-index: 40; background: rgba(24, 22, 18, .28); animation: fade .15s ease-out; }
.drawer { position: fixed; z-index: 41; top: 0; right: 0; bottom: 0; width: min(640px, 100%); background: var(--surface); box-shadow: var(--shadow-3); display: flex; flex-direction: column; animation: slide .2s ease-out; }
.drawer-head { display: flex; gap: 10px; align-items: flex-start; padding: 18px 20px 12px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-family: var(--serif); font-weight: 400; font-size: 21px; margin: 0; line-height: 1.25; flex: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 20px 28px; }
.drawer-section { margin-top: 20px; }
.drawer-section h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 0 0 8px; font-weight: 650; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.doc { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; max-height: 420px; overflow-y: auto; font-size: 14px; line-height: 1.6; }
.timeline { display: grid; gap: 10px; }
.tl { display: grid; grid-template-columns: 10px 1fr; gap: 10px; font-size: 13px; }
.tl::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); margin-top: 6px; }
.tl .when { color: var(--muted); font-size: 12px; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; max-height: 260px; overflow-y: auto; }

/* модальное окно */
.overlay { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(24, 22, 18, .42); animation: fade .15s ease-out; }
.dialog { width: min(440px, 100%); background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-3); padding: 22px; animation: pop .18s ease-out; position: relative; max-height: calc(100vh - 32px); overflow-y: auto; }
.dialog h2 { font-family: var(--serif); font-weight: 400; font-size: 22px; margin: 0 0 6px; padding-right: 30px; }
.dialog .sub { color: var(--muted); margin: 0 0 16px; }
.dialog .close { position: absolute; top: 12px; right: 12px; }

.toast-host { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 70; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); padding: 9px 14px; border-radius: 11px; box-shadow: var(--shadow-2); font-size: 13.5px; animation: pop .16s ease-out; }
.toast.bad { background: var(--danger); color: #fff; }

.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 .7em; } .md ul, .md ol { margin: 0 0 .8em; padding-left: 1.3em; }
.md h3, .md h4, .md h5, .md h6 { margin: 1em 0 .4em; font-size: 15px; }
.md code { font-family: var(--mono); font-size: .9em; background: var(--surface); border: 1px solid var(--line); border-radius: 5px; padding: 0 .3em; }
.md-norm { font-family: var(--mono); font-size: .92em; background: var(--norm-bg); color: var(--norm-ink); border-radius: 5px; padding: 0 .3em; }
.md-table { overflow-x: auto; margin-bottom: .8em; }
.md table { border-collapse: collapse; font-size: 13px; }
.md th, .md td { border: 1px solid var(--line); padding: 5px 8px; text-align: left; }

@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; } }

@media (max-width: 1100px) { .kpis, .kpis.six { grid-template-columns: repeat(2, minmax(0, 1fr)); } .two, .halves { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .nav { border-right: 0; border-bottom: 1px solid var(--line); }
  .nav-list { display: flex; overflow-x: auto; padding: 4px 8px 8px; }
  .nav-sep, .nav-foot { display: none; }
  .nav-item { white-space: nowrap; }
  .topbar, .page { padding-left: 16px; padding-right: 16px; }
  .toolbar .input { width: 100%; }
  .kv { grid-template-columns: 1fr; }
}
.nav-item .count.info { background: var(--info); }

/* Документы к исправлению (25.10.2026) */
.att-list { display: flex; flex-direction: column; gap: 8px; }
.att-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.att-head { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.att-head strong { word-break: break-all; }

/* --- сообщения «Обратная связь» (28.10.2026) --------------------------- */
.msg-list { display: grid; gap: 12px; }
.msg-item { padding: 14px 16px; display: grid; gap: 10px; }
.msg-item.done { opacity: .78; }
.msg-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.msg-from { font-weight: 600; color: var(--ink); text-decoration: none; }
.msg-from:hover { text-decoration: underline; }
.msg-when { margin-left: auto; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; font-size: 14px; }
.msg-actions .btn svg { width: 15px; height: 15px; }

.msg-actions a.btn { text-decoration: none; }
