:root {
  --bg: #0a0f1c;
  --bg-2: #0e1525;
  --card: #111a2b;
  --card-2: #162034;
  --line: #1d2940;
  --line-2: #2a3953;
  --text: #e8edf6;
  --muted: #8d9ab2;
  --accent: #6366f1;
  --accent-2: #7c83ff;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --violet: #a78bfa;
  --blue: #60a5fa;
  --teal: #2dd4bf;
  --radius: 12px;
  /* оттенки текста статусов и служебные цвета */
  --ok-text: #86efac;
  --err-text: #fca5a5;
  --warn-text: #fcd34d;
  --sent-text: #bfdbfe;
  --signed-text: #ddd6fe;
  --salary-text: #99f6e4;
  --icon-doc: #e2e8f0;
  --icon-edit: #facc15;
  --border-hover: #3a4d75;
  --row-hover: rgba(255,255,255,.015);
  --badge-hover: rgba(255,255,255,.04);
  --shadow: rgba(0,0,0,.45);
  --backdrop: rgba(3,7,18,.7);
  --logo-bg: #fff;
  color-scheme: dark;
}

/* ---------- светлая тема ---------- */
:root[data-theme="light"] {
  --bg: #f4f6fb;
  --bg-2: #ffffff;
  --card: #ffffff;
  --card-2: #f7f8fb;
  --line: #e3e7ef;
  --line-2: #cfd6e3;
  --text: #172033;
  --muted: #5f6b82;
  --accent: #4f46e5;
  --accent-2: #6366f1;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --violet: #7c3aed;
  --blue: #2563eb;
  --teal: #0d9488;
  --ok-text: #15803d;
  --err-text: #b91c1c;
  --warn-text: #b45309;
  --sent-text: #1d4ed8;
  --signed-text: #6d28d9;
  --salary-text: #0f766e;
  --icon-doc: #334155;
  --icon-edit: #ca8a04;
  --border-hover: #aab4c8;
  --row-hover: rgba(15,23,42,.025);
  --badge-hover: rgba(15,23,42,.04);
  --shadow: rgba(15,23,42,.15);
  --backdrop: rgba(15,23,42,.35);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { margin: 0; }
label { display: block; font-size: 12px; color: var(--muted); margin: 0 0 4px; }

/* ---------- controls ---------- */
.input {
  width: 100%;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  min-height: 40px;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
textarea.input { resize: vertical; }
select.input { cursor: pointer; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 10px;
  padding: 9px 16px; font-weight: 600; min-height: 40px; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--card-2); border-color: var(--border-hover); }
.btn:focus-visible, .icon-btn:focus-visible, .badge:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 6px 20px -6px rgba(99,102,241,.6); }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-danger { background: transparent; border-color: rgba(239,68,68,.5); color: var(--err-text); }
.btn-danger:hover { background: rgba(239,68,68,.12); border-color: var(--red); }
.btn-sm { padding: 6px 12px; min-height: 34px; font-size: 13px; }
.btn[disabled] { opacity: .6; cursor: progress; }
.icon-btn {
  width: 36px; height: 36px; display: inline-grid; place-items: center;
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 9px; padding: 0;
  transition: background .15s, border-color .15s;
}
.icon-btn:hover { background: var(--card-2); border-color: var(--border-hover); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn.i-doc { color: var(--icon-doc); }
.icon-btn.i-sign { color: var(--amber); }
.icon-btn.i-edit { color: var(--icon-edit); }
.icon-btn.i-del { color: var(--muted); }
.icon-btn.i-del:hover { color: var(--red); border-color: rgba(239,68,68,.5); }

/* ---------- login ---------- */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: var(--bg);
  background:
    radial-gradient(900px 500px at 15% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
    radial-gradient(700px 500px at 110% 110%, color-mix(in srgb, var(--teal) 14%, transparent), transparent 70%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--line);
  border-radius: 20px; padding: 32px 32px 24px; display: grid; gap: 18px;
  box-shadow: 0 30px 80px -30px var(--shadow);
}
.login-logo {
  justify-self: center; background: var(--logo-bg); border-radius: 12px; padding: 10px 16px;
  box-shadow: 0 1px 0 var(--line);
}
.login-logo img { display: block; width: 190px; height: auto; }
.login-head { text-align: center; }
.login-head h1 { font-size: 22px; margin: 0; }
.login-head p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.pwd-field label { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.pwd-wrap { position: relative; }
.pwd-wrap input {
  width: 100%; height: 50px; padding: 0 48px 0 44px;
  background: var(--bg-2); color: var(--text); border: 1px solid var(--line-2); border-radius: 12px;
  font: 600 18px/1 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; letter-spacing: .12em;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none; appearance: none;
}
.pwd-wrap input::placeholder { color: var(--muted); opacity: .6; letter-spacing: .2em; }
.pwd-wrap input:hover { border-color: var(--border-hover); }
.pwd-wrap input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
.pwd-wrap input:disabled { opacity: .55; cursor: not-allowed; background: var(--bg-2); color: var(--muted); }
/* автозаполнение браузера не должно перекрашивать поле в серый */
.pwd-wrap input:-webkit-autofill,
.pwd-wrap input:-webkit-autofill:hover,
.pwd-wrap input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--bg-2) inset;
  caret-color: var(--text);
  transition: background-color 9999s ease-out;
}
.pwd-lock { position: absolute; left: 14px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.pwd-eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; display: grid; place-items: center; border: 0; border-radius: 9px;
  background: transparent; color: var(--muted);
}
.pwd-eye:hover { color: var(--text); background: var(--badge-hover); }
.pwd-eye:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 0; }
.pwd-eye svg { width: 18px; height: 18px; }
.pwd-eye.on { color: var(--accent); }
.btn-lg { min-height: 50px; font-size: 16px; border-radius: 12px; }
.login-msg { min-height: 20px; margin: -6px 0 -6px; color: var(--err-text); font-size: 13px; text-align: center; }
.login-msg:empty { display: none; }
.login-foot { margin: 0; text-align: center; font-size: 12px; color: var(--muted); }
.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* ---------- layout ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--bg-2);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 18px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.wrap { max-width: 1640px; margin: 0 auto; padding: 24px; }

.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--c, var(--accent));
  border-radius: var(--radius); padding: 18px 18px 16px;
}
.kpi-label { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.kpi-value { font-size: 24px; font-weight: 800; margin: 8px 0 2px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 16px; border-bottom: 1px solid var(--line); }
.toolbar .search { flex: 1 1 320px; }
.toolbar select { width: auto; min-width: 180px; }
.shown { color: var(--muted); font-size: 13px; }
.shown b { color: var(--text); }

.table-scroll { overflow-x: auto; }
.grid { width: 100%; border-collapse: collapse; min-width: 1400px; }
.grid td:nth-child(2) { min-width: 220px; max-width: 320px; }
.grid th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 700; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.grid td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr:hover { background: var(--row-hover); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.right { text-align: right; }
.inv-no { font-weight: 800; }
.sub { font-size: 12px; color: var(--muted); }
.sum { font-weight: 700; }
.actions { display: flex; gap: 6px; justify-content: flex-end; }
.status-cell { white-space: nowrap; }
.status-date { font-size: 12px; color: var(--muted); margin-top: 4px; padding-left: 4px; }

.badge {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 5px 12px;
  font-size: 13px; font-weight: 600; border: 1px solid var(--line-2); background: transparent; color: var(--muted);
  transition: filter .15s, background .15s;
}
.badge:hover { background: var(--badge-hover); }
.badge svg { width: 14px; height: 14px; }
.badge.b-paid { color: var(--ok-text); background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.5); }
.badge.b-unpaid svg { color: var(--amber); }
.badge.b-partial { color: var(--err-text); background: rgba(239,68,68,.13); border-color: rgba(239,68,68,.5); }
.badge.b-partial svg { color: var(--red); }
.badge.b-sent { color: var(--sent-text); background: rgba(96,165,250,.14); border-color: rgba(96,165,250,.5); }
.badge.b-signed { color: var(--signed-text); background: rgba(167,139,250,.16); border-color: rgba(167,139,250,.55); }
.badge.b-salary { color: var(--salary-text); background: rgba(45,212,191,.13); border-color: rgba(45,212,191,.5); }
.sal-owed { color: var(--warn-text); }

.empty { padding: 48px 16px; text-align: center; color: var(--muted); }
.empty .btn { margin-top: 12px; }

/* ---------- popover ---------- */
.pop {
  position: absolute; z-index: 50; width: 260px; background: var(--card-2); border: 1px solid var(--line-2);
  border-radius: 12px; padding: 14px; box-shadow: 0 18px 40px var(--shadow); display: grid; gap: 8px;
}
.pop-title { font-weight: 700; }
.pop-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.pop-paid-row { display: grid; grid-template-columns: 1fr 76px; gap: 6px; }
.pop-paid-hint { min-height: 16px; }
.pop-paid-full { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--text); font-size: 13px; cursor: pointer; }
.pop-paid-full input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ---------- dialogs ---------- */
.dlg {
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0;
  background: var(--card); color: var(--text); border: 1px solid var(--line-2); border-radius: 16px;
}
.dlg[open] { display: flex; flex-direction: column; }
.dlg > form { display: flex; flex-direction: column; min-height: 0; max-height: calc(100vh - 34px); }
.dlg-wide { width: min(1080px, calc(100vw - 32px)); }
.dlg-sm { width: min(420px, calc(100vw - 32px)); }
.dlg::backdrop { background: var(--backdrop); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { font-size: 18px; }
.dlg-body { padding: 20px; overflow: auto; display: grid; gap: 14px; min-height: 0; }
.dlg-body h3 { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-top: 6px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 12px; }
.row2.tight { gap: 8px; }
.align-end { align-items: start; }
.with-btn { display: flex; gap: 8px; }
.with-btn .input { flex: 1; }
.box { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin: 0; display: grid; gap: 10px; min-width: 0; }
.box legend { padding: 0 6px; font-weight: 700; font-size: 13px; }
.box > .btn { justify-self: start; }
.hint { margin: 0; font-size: 12px; color: var(--muted); }
.form-err { margin: 0; color: var(--err-text); min-height: 18px; }

.items-scroll { overflow-x: auto; }
.items { width: 100%; border-collapse: collapse; min-width: 640px; }
.items th { font-size: 12px; color: var(--muted); font-weight: 600; text-align: left; padding: 0 6px 6px; }
.items td { padding: 4px 6px 4px 0; vertical-align: top; }
.items td:nth-child(1) { width: 50%; }
.items td:nth-child(2) { width: 80px; }
.items td:nth-child(3) { width: 90px; }
.items td:nth-child(4) { width: 130px; }
.items td:nth-child(5) { width: 130px; padding-top: 14px; }
.items td:nth-child(6) { width: 40px; }
.items textarea.input { min-height: 40px; resize: vertical; }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: inline-block; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line-2);
  color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; background: var(--bg-2);
}
.seg input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* переключатели карточек в настройках — как фильтры-чипы: включённые подсвечены */
.kpi-toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.kpi-toggles label { margin: 0; }
.kpi-toggles input { position: absolute; opacity: 0; pointer-events: none; }
.kpi-toggles span {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 999px;
  border: 1px solid var(--line-2); color: var(--muted); font-size: 13px; font-weight: 500;
  cursor: pointer; background: var(--bg-2); transition: background .15s, border-color .15s, color .15s;
}
.kpi-toggles span::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); flex: none;
}
.kpi-toggles input:checked + span { color: var(--text); border-color: var(--accent); background: rgba(99,102,241,.10); }
.kpi-toggles input:checked + span::before { background: var(--accent); }
.kpi-toggles input:focus-visible + span { outline: 2px solid var(--accent-2); outline-offset: 2px; }

.totals { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: grid; gap: 6px; align-self: stretch; align-content: center; }
.totals div { display: flex; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }
.totals .grand { font-size: 18px; font-weight: 800; border-top: 1px solid var(--line-2); padding-top: 8px; margin-top: 2px; }
.totals .salary { color: var(--muted); font-size: 12px; }

.ref-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ref-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; }
.ref-list .sub { display: block; }
.ref-list .ref-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ---------- report ---------- */
.report-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; align-items: end; }
.report-head { margin: 6px 0 10px; }
.report-head h3 { color: var(--text); text-transform: none; letter-spacing: 0; font-size: 17px; margin: 0; }
.rep-table { width: 100%; border-collapse: collapse; min-width: 900px; }
.rep-table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.rep-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); }
.rep-table .grp td { background: var(--bg-2); font-weight: 700; }
.rep-table .subtotal td { font-weight: 700; border-bottom: 1px solid var(--line-2); }
.rep-table .grand td { font-weight: 800; font-size: 15px; border-top: 2px solid var(--line-2); }
.rep-table .salary-col { color: var(--ok-text); font-weight: 700; }
.salary-summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin: 12px 0 16px; }
.salary-card { background: var(--bg-2); border: 1px solid var(--line); border-left: 3px solid var(--green); border-radius: 10px; padding: 10px 14px; }
.salary-card b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.salary-card .sub { display: block; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100;
  background: var(--card-2); border: 1px solid var(--line-2); padding: 10px 16px; border-radius: 10px;
  box-shadow: 0 10px 30px var(--shadow); max-width: calc(100vw - 32px);
}
.toast.err { border-color: rgba(239,68,68,.6); color: var(--err-text); }

#pdfStage { position: fixed; left: -10000px; top: 0; }

/* ---------- настройки ---------- */
.dlg-mid { width: min(720px, calc(100vw - 32px)); }
.set-block { display: grid; gap: 12px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.set-block:last-child { border-bottom: 0; padding-bottom: 0; }
.set-block h4 { margin: 8px 0 0; font-size: 13px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
label.btn { margin: 0; color: var(--text); font-size: 14px; cursor: pointer; }
.bk-type { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; margin-left: 6px; border: 1px solid var(--line-2); color: var(--muted); vertical-align: 1px; }
.bk-type.auto { color: var(--salary-text); border-color: color-mix(in srgb, var(--teal) 50%, transparent); }
.bk-type.restore { color: var(--warn-text); border-color: color-mix(in srgb, var(--amber) 50%, transparent); }

/* ---------- выписка ---------- */
.drop {
  display: grid; place-items: center; gap: 4px; text-align: center; padding: 34px 16px; margin: 14px 0 10px;
  border: 2px dashed var(--line-2); border-radius: 14px; background: var(--bg-2); cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--bg-2)); }
.drop-title { font-size: 16px; font-weight: 700; color: var(--text); }
code { font-size: 12.5px; padding: 1px 5px; border-radius: 5px; background: var(--bg-2); border: 1px solid var(--line); }
.bank-progress { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.bank-progress b { font-size: 15px; }
.pay-card { border: 1px solid var(--line-2); border-radius: 14px; overflow: hidden; }
.pay-card-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: baseline; padding: 14px 16px; background: var(--bg-2); border-bottom: 1px solid var(--line); }
.pay-card-head h3 { margin: 0; color: var(--text); text-transform: none; letter-spacing: 0; font-size: 16px; }
.pay-amount { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.pay-grid { display: grid; grid-template-columns: 170px 1fr; gap: 6px 14px; padding: 14px 16px; margin: 0; }
.pay-grid dt { color: var(--muted); font-size: 13px; }
.pay-grid dd { margin: 0; overflow-wrap: anywhere; }
.pay-purpose { background: color-mix(in srgb, var(--amber) 10%, transparent); border-radius: 8px; padding: 6px 10px; }
.pay-reason { margin: 0 16px 14px; font-size: 13px; color: var(--warn-text); }
.pay-pick { display: grid; gap: 8px; padding: 14px 16px; border-top: 1px solid var(--line); }
.cand-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 280px; overflow: auto; }
.cand-list label { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; margin: 0; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; color: var(--text); font-size: 14px; }
.cand-list label:hover { border-color: var(--border-hover); }
.cand-list input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.cand-list label:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.cand-list .sub { display: block; }
.cand-tag { font-size: 11px; font-weight: 700; color: var(--ok-text); margin-left: 6px; }
.rep-sum { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.rep-sum div { background: var(--bg-2); border: 1px solid var(--line); border-left: 3px solid var(--c, var(--accent)); border-radius: 10px; padding: 10px 14px; }
.rep-sum b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.rep-list { width: 100%; border-collapse: collapse; min-width: 640px; }
.rep-list th { text-align: left; font-size: 12px; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line-2); }
.rep-list .sub { display: block; }
.rep-list td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }


/* ---------- responsive ---------- */
@media (max-width: 1560px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .topbar { padding: 12px 16px; position: static; }
  .top-actions .btn { padding: 8px 12px; }
  .brand { font-size: 16px; }
  .wrap { padding: 16px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 20px; }
  .toolbar select { flex: 1 1 140px; min-width: 0; }
  .row2, .row3 { grid-template-columns: 1fr; }
  .pay-grid { grid-template-columns: 1fr; gap: 2px; }
  .pay-grid dd { margin-bottom: 6px; }
  .login-card { padding: 24px 20px 20px; }
  .dlg-body { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }


/* =====================================================================
   Оформление 2.0: боковое меню, заголовок страницы, карточки, чипы
   ===================================================================== */
:root {
  --font: "Fira Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --side-w: 248px;
}
body { font-family: var(--font); font-size: 14px; font-feature-settings: "tnum" 1; }
button, input, select, textarea { font-family: inherit; }
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }

/* ---------- каркас ---------- */
.shell:not([hidden]) { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px;
  padding: 18px 14px; background: var(--card); border-right: 1px solid var(--line);
}
.side-brand { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 4px 8px 18px; }
.side-logo { background: var(--logo-bg); border-radius: 10px; padding: 8px 12px; box-shadow: 0 0 0 1px var(--line); }
.side-logo img { display: block; width: 150px; height: auto; }
.side-title { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; padding-top: 12px; border-top: 1px solid var(--line); }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 42px;
  padding: 0 12px; border: 0; border-radius: 10px; background: transparent; color: var(--muted);
  font-size: 14.5px; font-weight: 500; text-align: left; white-space: nowrap;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.nav-item svg { width: 19px; height: 19px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-item:hover { background: var(--badge-hover); color: var(--text); }
.nav-item:focus-visible { outline: 2px solid var(--accent-2); outline-offset: -2px; }
.nav-item.active { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--text); font-weight: 600; }
.nav-item.active svg { color: var(--accent-2); }
.nav-item.active::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
#btnLogout:hover { color: var(--err-text); }
:root[data-theme="light"] .i-moon, :root:not([data-theme="light"]) .i-sun { display: none; }

.wrap { max-width: 1560px; width: 100%; margin: 0 auto; padding: 28px 32px 40px; }

/* ---------- заголовок страницы ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 28px; line-height: 1.15; font-weight: 700; letter-spacing: -.01em; }
.page-sub { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.btn-cta { min-height: 46px; padding: 0 20px; font-size: 15px; border-radius: 12px; gap: 8px; }
.btn { transition: background .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease), box-shadow .15s var(--ease); }
.btn:active:not([disabled]) { transform: translateY(1px); }
.btn-primary { box-shadow: 0 8px 22px -10px color-mix(in srgb, var(--accent) 80%, transparent); }

/* ---------- карточки показателей ---------- */
.kpis { gap: 14px; margin-bottom: 22px; }
.kpi {
  display: flex; flex-direction: column; align-items: stretch; gap: 0; text-align: left; width: 100%;
  font: inherit; color: var(--text); cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-left: 1px solid var(--line);
  border-radius: 14px; padding: 16px 16px 15px;
  transition: border-color .15s var(--ease), transform .15s var(--ease), box-shadow .15s var(--ease);
}
.kpi:hover { border-color: color-mix(in srgb, var(--c) 55%, var(--line)); transform: translateY(-2px); box-shadow: 0 14px 30px -18px var(--shadow); }
.kpi:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-label { font-size: 11.5px; letter-spacing: .07em; }
.kpi-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none;
  color: var(--c); background: color-mix(in srgb, var(--c) 15%, transparent); }
.kpi-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.kpi-value { font-size: 26px; font-weight: 700; margin: 10px 0 2px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value small { font-size: 16px; font-weight: 500; color: var(--muted); }
.kpi-sub { font-size: 12.5px; }
.kpi-bar { display: block; height: 5px; border-radius: 99px; background: var(--line); margin-top: 12px; overflow: hidden; }
.kpi-bar i { display: block; height: 100%; border-radius: inherit; background: var(--c); transition: width .5s var(--ease); }

/* ---------- панель таблицы ---------- */
.panel { border-radius: 16px; box-shadow: 0 1px 0 var(--line); }
.toolbar { gap: 10px; padding: 16px 16px 12px; border-bottom: 0; }
.search-wrap { position: relative; flex: 1 1 340px; }
.search-wrap svg { position: absolute; left: 13px; top: 50%; width: 17px; height: 17px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.search-wrap .input { padding-left: 40px; min-height: 42px; }
.toolbar select { min-height: 42px; }
.input { transition: border-color .15s var(--ease), box-shadow .15s var(--ease); }
.input:hover { border-color: var(--border-hover); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.shown { margin-left: auto; }
.chips { display: flex; gap: 8px; padding: 0 16px 14px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; flex: none; min-height: 34px; padding: 0 6px 0 13px;
  border-radius: 999px; border: 1px solid var(--line-2); background: transparent; color: var(--muted);
  font-size: 13.5px; font-weight: 500; transition: all .15s var(--ease);
}
.chip:hover { color: var(--text); border-color: var(--border-hover); }
.chip:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.chip-n { min-width: 24px; height: 22px; padding: 0 7px; border-radius: 999px; display: grid; place-items: center; font-size: 12px; font-weight: 600; background: var(--badge-hover); color: var(--muted); }
.chip.on { background: color-mix(in srgb, var(--accent) 14%, transparent); border-color: color-mix(in srgb, var(--accent) 60%, transparent); color: var(--text); }
.chip.on .chip-n { background: var(--accent); color: #fff; }

.grid th { position: sticky; top: 0; z-index: 1; background: var(--card); font-size: 11.5px; padding: 12px 16px; }
.grid td { padding: 13px 16px; }
.grid tbody tr { transition: background .12s var(--ease); }
.inv-no { font-size: 15px; }
.buyer { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar {
  width: 36px; height: 36px; flex: none; border-radius: 10px; display: grid; place-items: center;
  font-size: 13px; font-weight: 700; letter-spacing: .02em;
  color: hsl(var(--h) 70% 72%); background: hsl(var(--h) 55% 50% / .16);
}
:root[data-theme="light"] .avatar { color: hsl(var(--h) 60% 36%); background: hsl(var(--h) 70% 50% / .13); }
.buyer-txt { display: flex; flex-direction: column; min-width: 0; }
.buyer-name { font-weight: 600; }
.sum { font-size: 15px; }
.badge { padding: 5px 11px; font-size: 12.5px; font-weight: 500; }
.badge.b-paid, .badge.b-sent, .badge.b-signed, .badge.b-salary, .badge.b-partial { font-weight: 600; }
.icon-btn { width: 34px; height: 34px; border-radius: 9px; background: transparent; border-color: transparent; }
.icon-btn:hover { background: var(--badge-hover); border-color: var(--line-2); }
.grid tbody tr:hover .icon-btn { border-color: var(--line); }

.empty { display: grid; justify-items: center; gap: 6px; padding: 56px 16px; }
.empty-title { font-size: 17px; color: var(--text); }
.empty .btn { margin-top: 10px; }

.grid { min-width: 920px; }
.grid td.num .sub { white-space: normal; max-width: 170px; margin-left: auto; }
.grid td, .grid th { padding-left: 13px; padding-right: 13px; }
.exec-line { display: inline-flex; align-items: center; gap: 5px; margin-top: 3px; font-size: 12.5px; color: var(--text); opacity: .85; }
.exec-line svg { width: 13px; height: 13px; color: var(--muted); }
.status-date { white-space: normal; }
@media (max-width: 1500px) {
  .wrap { padding-left: 24px; padding-right: 24px; }
  .actions { display: grid; grid-template-columns: repeat(2, 32px); gap: 4px; justify-content: end; }
  .actions .icon-btn { width: 32px; height: 32px; }
}
.grid td:nth-child(2) { min-width: 200px; max-width: 340px; }
.status-cell .status-item + .status-item { margin-top: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* ---------- окна ---------- */
.dlg { border-radius: 18px; box-shadow: 0 40px 100px -30px rgba(0,0,0,.55); }
.dlg[open] { animation: dlg-in .2s var(--ease); }
.dlg[open]::backdrop { animation: fade-in .2s var(--ease); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.dlg-head { padding: 18px 22px; }
.dlg-head h2 { font-size: 19px; font-weight: 700; }
.dlg-body { padding: 22px; }
.dlg-foot { padding: 14px 22px; background: color-mix(in srgb, var(--bg) 40%, var(--card)); border-radius: 0 0 18px 18px; }
.dlg-head .icon-btn { border-color: var(--line); }
.toast { border-radius: 12px; padding: 12px 18px; font-weight: 500; animation: dlg-in .2s var(--ease); }
.pop { border-radius: 14px; animation: dlg-in .15s var(--ease); }

/* ---------- адаптивность ---------- */
@media (max-width: 1100px) {
  .shell:not([hidden]) { display: block; }
  .side {
    position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; align-items: center; gap: 8px;
    padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--line);
  }
  .side-brand { padding: 0; flex: none; }
  .side-logo { padding: 6px 9px; }
  .side-logo img { width: 112px; }
  .side-title { display: none; }
  .side-nav, .side-foot { flex-direction: row; overflow-x: auto; scrollbar-width: none; }
  .side-nav { flex: 1 1 auto; min-width: 0; }
  .side-foot { margin-top: 0; padding-top: 0; border-top: 0; flex: none; }
  .nav-item { width: auto; min-height: 40px; padding: 0 12px; }
  .nav-item.active::before { left: 12px; right: 12px; top: auto; bottom: -11px; width: auto; height: 3px; border-radius: 3px 3px 0 0; }
  .theme-label, #btnLogout span { display: none; }
  .wrap { padding: 22px 20px 32px; }
}
@media (max-width: 760px) {
  .side { flex-wrap: wrap; padding: 10px 12px 0; position: static; }
  .side-brand { order: 1; }
  .side-foot { order: 2; margin-left: auto; }
  .side-nav { order: 3; flex-basis: 100%; margin: 0 -12px; padding: 4px 8px 6px; }
  .nav-item.active::before { bottom: -6px; }
  .wrap { padding: 18px 16px 28px; }
  .page-head h1 { font-size: 24px; }
  .btn-cta { width: 100%; }
  .kpis { gap: 10px; }
  .kpi { padding: 13px 13px 12px; }
  .kpi-value { font-size: 20px; }
  .kpi-icon { width: 30px; height: 30px; }
  .search-wrap { flex-basis: 100%; }
  .toolbar select { flex: 1 1 160px; }
  .shown { margin-left: 0; flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .dlg[open], .dlg[open]::backdrop, .toast, .pop { animation: none; }
  .kpi:hover { transform: none; }
}

/* ===================== Бланк счёта (PDF) ===================== */
.inv-page {
  width: 794px; background: #fff; color: #000;
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 12px; line-height: 1.3;
  padding: 36px 42px 12px 94px; position: relative;
}
.inv-page * { color: #000; }
.inv-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 40px; }
.inv-top img { height: 35px; }
.inv-contacts { text-align: right; color: #666; font-size: 12.5px; line-height: 2.2; }
.inv-contacts div { color: #666; }
.inv-caption { margin-bottom: 14px; font-size: 12.5px; }
.inv-bank { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.inv-bank td { border: 1px solid #000; padding: 4px 8px; vertical-align: top; }
.inv-title { text-align: center; font-size: 20px; font-weight: 700; margin: 34px 0 22px; }
.inv-payer { font-size: 12.5px; margin-bottom: 14px; line-height: 1.45; }
.inv-items { width: 100%; border-collapse: collapse; border: 2px solid #000; font-size: 12.5px; }
.inv-items th { border: 1px solid #000; padding: 3px 5px; font-weight: 700; text-align: center; }
.inv-items td { border: 1px solid #000; padding: 3px 5px; vertical-align: top; }
.inv-items td.c { text-align: center; }
.inv-items td.r { text-align: right; white-space: nowrap; }
.inv-sum { margin-left: auto; border-collapse: collapse; font-size: 12.5px; margin-top: 6px; }
.inv-sum td { padding: 4px 3px 4px 18px; text-align: right; white-space: nowrap; }
.inv-sum .b td { font-weight: 700; }
.inv-words { margin-top: 40px; font-size: 12.5px; line-height: 2; }
.inv-info { margin-top: 30px; font-size: 12.5px; min-height: 60px; }
.inv-info b { display: block; margin-bottom: 4px; }
.inv-line { border-top: 2px solid #000; margin: 14px 0 0; }
.inv-signs { position: relative; margin-top: 46px; font-size: 12.5px; min-height: 168px; }
.inv-sign-row { display: grid; grid-template-columns: 150px 1fr 1fr; align-items: end; height: 70px; }
.inv-sign-row .role { font-weight: 700; padding-bottom: 12px; }
.inv-sign-row .field { position: relative; text-align: center; margin-right: 34px; }
.inv-sign-row .field .ln { border-bottom: 1px solid #000; height: 18px; font-size: 13px; }
.inv-sign-row .field .cap { font-size: 9.5px; margin-top: 2px; }
.inv-sign-row .field img.sg { position: absolute; left: 50%; bottom: 8px; width: 118px; transform: translateX(-50%); }
.inv-stamp { position: absolute; left: 136px; top: -2px; width: 152px; opacity: .95; }
.inv-mp { position: absolute; left: 190px; top: 150px; font-size: 11px; }

/* ===================== Отчёт (PDF) ===================== */
.rep-print { width: 1122px; background: #fff; color: #000; padding: 36px 40px; font-family: Arial, sans-serif; font-size: 12px; }
.rep-print * { color: #000; }
.rep-print h1 { font-size: 20px; margin: 0 0 4px; }
.rep-print .rp-sub { color: #444; margin-bottom: 16px; }
.rep-print table { width: 100%; border-collapse: collapse; min-width: 0; }
.rep-print th, .rep-print td { border: 1px solid #999; padding: 5px 7px; text-align: left; font-size: 12px; }
.rep-print th { background: #eef1f6; font-weight: 700; color: #000; }
.rep-print .num { text-align: right; }
.rep-print .grp td { background: #f5f6f8; }
.rep-print .subtotal td, .rep-print .grand td { background: #fafafa; font-weight: 700; }
.rep-print .grand td { font-size: 13px; }
.rep-print .salary-col, .rep-print .sal-owed { color: #000; }
.rep-print .sal-owed { font-weight: 700; }
.rep-print .rp-sal { width: auto; margin-bottom: 18px; }
.rep-print .rp-sal td:not(:first-child), .rep-print .rp-sal th:not(:first-child) { text-align: right; }

/* ===================== XML для Диадока ===================== */
.edo-intro { display: grid; gap: 10px; }
.edo-lead { margin: 0; }
.edo-own { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg-2); }
.edo-own span { color: var(--muted); font-size: 13px; }
.edo-own b { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; overflow-wrap: anywhere; }
.edo-own b.edo-bad { color: var(--err-text); }
.edo-list { display: grid; gap: 12px; }
.edo-item { border: 1px solid var(--line-2); border-radius: 14px; padding: 14px 16px; display: grid; gap: 10px; }
.edo-item.edo-ok { border-color: rgba(34, 197, 94, .45); }
.edo-item.edo-warn { border-color: rgba(245, 158, 11, .45); }
.edo-item.edo-err { border-color: rgba(239, 68, 68, .45); }
.edo-item-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.edo-item-title b { display: block; font-size: 15px; color: var(--text); }
.edo-item-title .sub { font-size: 12.5px; color: var(--muted); }
.edo-tag { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
.edo-tag-ok { color: var(--ok-text); background: rgba(34, 197, 94, .12); border-color: rgba(34, 197, 94, .5); }
.edo-tag-warn { color: var(--warn-text); background: rgba(245, 158, 11, .12); border-color: rgba(245, 158, 11, .5); }
.edo-tag-err { color: var(--err-text); background: rgba(239, 68, 68, .12); border-color: rgba(239, 68, 68, .5); }
.edo-file-rows { display: grid; gap: 6px; font-size: 13px; }
.edo-file-rows > div { display: grid; grid-template-columns: 120px 1fr; gap: 10px; align-items: baseline; }
.edo-file-rows span { color: var(--muted); font-size: 12.5px; }
.edo-file-rows code { overflow-wrap: anywhere; }
.edo-file-rows code.edo-new { font-weight: 600; }
.edo-warn { margin: 0; padding-left: 18px; color: var(--warn-text); font-size: 12.5px; display: grid; gap: 4px; }
.edo-guid { display: grid; gap: 8px; padding: 12px; border-radius: 12px; background: var(--bg-2); border: 1px dashed var(--line-2); }
.edo-guid label { font-size: 13px; color: var(--text); }
.edo-actions { display: flex; gap: 8px; flex-wrap: wrap; }
