:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e8edf3;
  --brand: #1e3a8a;
  --brand2: #2563eb;
  --brand-soft: #f2f6fd;
  --accent: #3b82f6;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 6px 20px rgba(15, 23, 42, 0.05);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family:
    "Segoe UI",
    system-ui,
    -apple-system,
    Roboto,
    Arial,
    sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a {
  color: inherit;
}

/* ===== layout ===== */
.wrap {
  max-width: 1220px;
  margin: 0 auto;
  padding: 22px 24px 60px;
}
.page-title {
  margin: 6px 2px 18px;
}
.page-title h1 {
  font-size: 21px;
  margin: 0 0 4px;
  color: var(--brand);
  font-weight: 700;
}
.page-title p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

/* toolbar */
.toolbar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
  margin-bottom: 18px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
select,
.btn {
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font-size: 14px;
  font-family: inherit;
}
select {
  padding: 0 32px 0 12px;
  background: #fff
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E")
    no-repeat right 10px center;
  appearance: none;
  cursor: pointer;
  min-width: 140px;
  color: var(--ink);
}
.btn {
  padding: 0 16px;
  cursor: pointer;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #fff;
  color: var(--ink);
}
.btn:hover {
  border-color: var(--accent);
  color: var(--brand2);
}
.btn.primary {
  background: var(--brand2);
  color: #fff;
  border-color: var(--brand2);
}
.btn.primary:hover {
  background: #1d4ed8;
  color: #fff;
}
.toolbar .spacer {
  margin-left: auto;
}
.search {
  position: relative;
}
.search input {
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 0 14px 0 36px;
  font-size: 14px;
  width: 250px;
  font-family: inherit;
  background: #fff;
}
.search input:focus {
  outline: none;
  border-color: var(--accent);
}
.search svg {
  position: absolute;
  left: 11px;
  top: 11px;
  color: var(--muted);
}

/* export — сегментированная группа */
.export {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  height: 38px;
  background: #fff;
}
.export button {
  border: none;
  background: transparent;
  height: 100%;
  padding: 0 13px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-left: 1px solid var(--line);
}
.export button:first-child {
  border-left: none;
}
.export button:hover {
  background: var(--brand-soft);
  color: var(--brand2);
}

/* секция */
.sec-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin: 4px 2px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sec-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* дашборд */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 15px 16px;
}
.stat .sl {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.stat .sv {
  font-size: 25px;
  font-weight: 700;
  margin-top: 6px;
  letter-spacing: -0.5px;
  color: var(--brand);
}
.stat .sd {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

.dash {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 22px;
}
.chart-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.chart-card.wide {
  grid-column: 1 / -1;
}
.chart-card h3 {
  margin: 0 0 2px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}
.chart-card .hint {
  margin: 0 0 14px;
  font-size: 12px;
  color: var(--muted);
}
.chart-wrap {
  position: relative;
  height: 260px;
}
.chart-wrap.short {
  height: 230px;
}

/* карточка категории */
.cat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 14px;
}
.cat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  cursor: pointer;
  user-select: none;
  border-left: 4px solid var(--accent);
  transition: background 0.15s;
}
.cat-head:hover {
  background: var(--brand-soft);
}
.cat-head .chev {
  color: var(--muted);
  font-size: 11px;
  transition: transform 0.2s;
}
.cat.collapsed .cat-head .chev {
  transform: rotate(-90deg);
}
.cat-head .name {
  font-size: 15px;
  font-weight: 700;
  color: var(--brand);
  flex: 1;
}
.cat-head .pill {
  font-size: 12px;
  font-weight: 600;
  color: var(--brand2);
  background: var(--brand-soft);
  padding: 4px 11px;
  border-radius: 20px;
  white-space: nowrap;
}
.cat-body {
  border-top: 1px solid var(--line);
  overflow-x: auto;
}
.cat.collapsed .cat-body {
  display: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
thead th {
  text-align: right;
  padding: 10px 18px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: #fbfcfe;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
thead th:first-child {
  text-align: left;
}
tbody td {
  padding: 11px 18px;
  text-align: right;
  border-bottom: 1px solid #f2f5f9;
  white-space: nowrap;
  color: var(--ink);
}
tbody td.loc {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
}
tbody tr:hover td {
  background: #fafbfe;
}
tbody td .cnt {
  font-weight: 700;
}
tr.total-row td {
  font-weight: 700;
  background: #fbfcfe;
  border-top: 1px solid var(--line);
  border-bottom: none;
  color: var(--brand);
}
tr.total-row td.loc {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.4px;
  color: var(--brand);
}
tr.total-row:hover td {
  background: #f4f7fc;
}

.empty {
  padding: 44px 16px;
  text-align: center;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.foot {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  padding: 2px 4px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

/* адаптив */
@media (max-width: 900px) {
  .dash {
    grid-template-columns: 1fr;
  }
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 640px) {
  .wrap {
    padding: 16px 14px 48px;
  }
  .page-title h1 {
    font-size: 18px;
  }
  .toolbar {
    padding: 12px;
    gap: 10px;
  }
  .toolbar .field {
    flex: 1 1 calc(50% - 5px);
  }
  .toolbar select {
    width: 100%;
    min-width: 0;
  }
  .toolbar .spacer {
    display: none;
  }
  .search,
  .search input {
    width: 100%;
  }
  .toolbar .field.search-field {
    flex: 1 1 100%;
  }
  .export {
    flex: 1 1 100%;
  }
  .export button {
    flex: 1;
    justify-content: center;
  }
  thead th,
  tbody td {
    padding: 10px 12px;
  }
  thead th:nth-child(3),
  tbody td:nth-child(3),
  thead th:nth-child(4),
  tbody td:nth-child(4) {
    display: none; /* прячем мин/макс на узких экранах */
  }
  .foot {
    flex-direction: column;
    gap: 4px;
  }
}
@media print {
  .topbar,
  .toolbar,
  .dash,
  .sec-title {
    display: none;
  }
  body {
    padding-top: 0;
  }
  .cat.collapsed .cat-body {
    display: block;
  }
}
