:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --line: #dde3ec;
  --text: #1d2531;
  --muted: #6b7a90;
  --accent: #1f6feb;
  --accent-dark: #17539c;
  --good: #1a7f4b;
  --bad: #b42318;
  --head: #eef2f8;
  --shadow: 0 1px 3px rgba(16, 30, 54, .08), 0 6px 20px rgba(16, 30, 54, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.45 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px; background: var(--panel);
  border-bottom: 1px solid var(--line); box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 17px; margin: 0; letter-spacing: .2px; }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: 13px; }
.topbar .nav { display: flex; gap: 14px; align-items: center; font-size: 14px; }

.wrap { padding: 16px 18px; max-width: none; margin: 0 auto; }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); padding: 16px; margin-bottom: 18px;
}
.panel h2 { margin: 0 0 12px; font-size: 15px; }
.panel .hint { color: var(--muted); font-size: 13px; }

.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); }
input, select, textarea, button {
  font: inherit; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(31,111,235,.25); border-color: var(--accent); }
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; min-height: 200px; width: 100%; }

button {
  cursor: pointer; background: var(--accent); color: #fff; border-color: var(--accent);
  font-weight: 600; transition: background .15s;
}
button:hover { background: var(--accent-dark); }
button.ghost { background: #fff; color: var(--text); border-color: var(--line); font-weight: 500; }
button.ghost:hover { background: var(--head); }
button.danger { background: var(--bad); border-color: var(--bad); }

.status { font-size: 13px; color: var(--muted); min-height: 18px; }
.status.err { color: var(--bad); }
.status.ok { color: var(--good); }

.table-scroll { overflow: auto; max-height: 72vh; border-radius: 10px; box-shadow: 0 0 0 1px var(--line); }
table { border-collapse: separate; border-spacing: 0; width: 100%; table-layout: fixed; font-size: 13px; }
thead { position: sticky; top: 0; z-index: 5; }
thead th {
  background: var(--head);
  text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--line);
  white-space: normal; line-height: 1.15; vertical-align: bottom;
}
thead th.group {
  text-align: center; font-weight: 700; font-size: 12.5px;
  background: #e5ebf5; letter-spacing: .2px;
}
thead th.group-start, tbody td.group-start { box-shadow: inset 1px 0 0 var(--line); }
thead th.left { text-align: left; }
thead th .col-title { font-weight: 700; display: block; margin-bottom: 5px; overflow-wrap: break-word; }
/* фильтр по значениям: кнопка в шапке + всплывающая панель с галочками */
.vfilter { margin-top: 2px; }
.vfilter-btn {
  width: 100%; padding: 3px 6px; font-size: 11.5px; font-weight: 400; text-align: left;
  background: #fff; color: var(--text); border: 1px solid var(--line); border-radius: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer;
}
.vfilter-btn:hover { background: #f2f6fd; }
.vfilter-btn.active { background: #e8f0ff; border-color: var(--accent); color: var(--accent-dark); font-weight: 600; }
.vpanel {
  position: fixed; z-index: 60; width: 288px; max-height: 360px; display: flex; flex-direction: column;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; font-size: 13px;
  box-shadow: 0 12px 32px rgba(16, 30, 54, .22);
}
.vpanel-head { padding: 8px 12px; font-weight: 700; background: var(--head); border-bottom: 1px solid var(--line); border-radius: 10px 10px 0 0; }
.vpanel-cal { display: flex; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.vpanel-cal input { flex: 1 1 auto; min-width: 0; }
.vpanel-cal button { flex: 0 0 auto; padding: 6px 8px; font-size: 12px; }
.vpanel-search { margin: 8px 12px 0; padding: 5px 8px; font-size: 12.5px; }
.vpanel-list { flex: 1 1 auto; overflow: auto; padding: 6px 12px 8px; }
.vpanel-list label { display: flex; align-items: center; gap: 7px; padding: 3px 0; cursor: pointer; white-space: nowrap; }
.vpanel-list label input { width: auto; margin: 0; }
.vpanel-all { font-weight: 600; border-bottom: 1px solid #eef1f6; padding-bottom: 6px !important; margin-bottom: 4px; }
.vpanel-foot { display: flex; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); }
.vpanel-foot button { flex: 1 1 0; padding: 5px 8px; font-size: 12.5px; }
tbody td { padding: 6px 8px; border-bottom: 1px solid #eef1f6; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tbody td:first-child, tbody td:nth-child(2) { text-align: left; }
tbody td:nth-child(2) { white-space: normal; overflow-wrap: anywhere; }
tbody tr:hover { background: #f8fafd; }
tbody tr:nth-child(even) { background: #fcfdff; }
tbody tr:nth-child(even):hover { background: #f5f8fd; }
tfoot td { position: sticky; bottom: 0; background: #eef2f8; font-weight: 700; padding: 9px 10px; text-align: right; border-top: 2px solid var(--line); }
tfoot td:first-child { text-align: left; }

/* при горизонтальной прокрутке учётный день и касса остаются на месте */
thead th:nth-child(1), thead th:nth-child(2),
tbody td:nth-child(1), tbody td:nth-child(2),
tfoot td:nth-child(1), tfoot td:nth-child(2) {
  position: sticky; left: 0; z-index: 4; background: var(--panel);
}
thead th:nth-child(2), tbody td:nth-child(2), tfoot td:nth-child(2) { left: 104px; }
thead th:nth-child(1), thead th:nth-child(2) { background: var(--head); z-index: 7; }
tfoot td:nth-child(1), tfoot td:nth-child(2) { background: var(--head); z-index: 5; }
tbody tr:nth-child(even) td:nth-child(1), tbody tr:nth-child(even) td:nth-child(2) { background: #fcfdff; }
tbody tr:hover td:nth-child(1), tbody tr:hover td:nth-child(2) { background: #f8fafd; }
td.zero { color: #b9c2d0; }
td.negative { color: var(--bad); }

.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 360px; }
.login-card h1 { font-size: 19px; margin: 0 0 4px; text-align: center; }
.login-card .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.login-card .field { margin-bottom: 12px; }
.login-card button { width: 100%; }

.users-table { width: 100%; font-size: 13.5px; }
.users-table th, .users-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid #eef1f6; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--head); color: var(--muted); }
.badge.admin { background: #e8f0ff; color: var(--accent-dark); }
.badge.off { background: #fde8e6; color: var(--bad); }
.badge.on { background: #e6f6ec; color: var(--good); }
.out { background: #0f172a; color: #d6e2f5; border-radius: 10px; padding: 12px; font-size: 12.5px; max-height: 260px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
/* на узких экранах таблица уходит в горизонтальную прокрутку, а не сжимается в кашу */
@media (max-width: 1100px) {
  .table-scroll { overflow-x: auto; }
  table { min-width: 1040px; }
}

/* ── страница настроек: загрузка файлов ─────────────────────────────── */
.hint { color: #9aa4b2; font-size: 13px; line-height: 1.5; margin: 0 0 12px; max-width: 820px; }
.drop {
  border: 2px dashed #3a4354; border-radius: 10px; padding: 22px; text-align: center;
  margin-bottom: 12px; transition: border-color .15s, background .15s;
}
.drop.over { border-color: #5b8def; background: rgba(91,141,239,.08); }
.drop p { margin: 8px 0 0; color: #9aa4b2; font-size: 13px; }
.check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #c7d0dd; }

/* ── настройки: выбор столбцов отчёта ───────────────────────────────── */
.cols-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-bottom: 14px; }
.cols-card, .cols-ops { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fbfcfe; }
.cols-group { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.cols-item { display: flex; align-items: center; gap: 6px; font-size: 13px; padding: 2px 0; }
.cols-ops-items { display: flex; flex-wrap: wrap; gap: 6px 20px; }
.cols-item.inline { padding: 0; }

/* ── панель «Скрыть столбцы» в параметрах отчёта ────────────────────── */
.hide-panel {
  margin-top: 14px; padding: 14px; border: 1px solid var(--line);
  border-radius: 10px; background: #fbfcfe;
}
.hide-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.hide-head strong { font-size: 14px; }
.hide-head span { font-size: 12.5px; color: var(--muted); }
@media (max-width: 720px) { .cols-grid { grid-template-columns: 1fr; } }

/* modal */
.modal-overlay{position:fixed;inset:0;background:rgba(15,23,42,.45);display:flex;align-items:center;justify-content:center;z-index:100;}
.modal{background:#fff;border-radius:12px;padding:20px 24px;min-width:320px;max-width:480px;box-shadow:0 20px 60px rgba(0,0,0,.25);}
.modal h3{margin:0 0 12px;font-size:16px;}
.modal-list{display:flex;flex-direction:column;gap:8px;margin:12px 0;max-height:300px;overflow:auto;}
.modal-list .check{display:flex;align-items:center;gap:8px;cursor:pointer;color:var(--text);}
