:root {
  --bg: #f1f5f9;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #1e3a8a;
  --brand2: #2563eb;
  --brand-soft: #eff6ff;
  --c-budget: #2563eb;
  --c-contract: #dc2626;
  --c-full: #0ea5e9;
  --c-part: #f59e0b;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
}
* {
  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;
}

.wrap {
  max-width: 1220px;
  margin: 0 auto;
  padding: 22px 24px 60px;
}
.page-title {
  margin: 6px 2px 18px;
}
.page-title h1 {
  font-size: 22px;
  margin: 0 0 4px;
  color: var(--brand);
}
.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: 20px;
}
.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: 9px;
  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: 150px;
}
.btn {
  padding: 0 16px;
  cursor: pointer;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #fff;
}
.btn:hover {
  border-color: var(--brand2);
}
.btn.primary {
  background: var(--brand2);
  color: #fff;
  border-color: var(--brand2);
}
.btn.primary:hover {
  background: #1d4ed8;
}
.toolbar .spacer {
  margin-left: auto;
}
.search {
  position: relative;
}
.search input {
  height: 38px;
  border-radius: 9px;
  border: 1px solid var(--line);
  padding: 0 14px 0 36px;
  font-size: 14px;
  width: 240px;
  font-family: inherit;
}
.search svg {
  position: absolute;
  left: 11px;
  top: 11px;
  color: var(--muted);
}

/* KPI */
.kpis {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 15px 16px;
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--accent);
}
.kpi .lbl {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.kpi .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
}
.kpi .val {
  font-size: 26px;
  font-weight: 700;
  margin-top: 8px;
  letter-spacing: -0.5px;
}
.kpi .sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 3px;
}
.kpi .sub b {
  color: var(--ink);
}

/* charts row */
.charts {
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr;
  gap: 20px;
  margin-bottom: 20px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.card h3 {
  margin: 0 0 2px;
  font-size: 15px;
}
.card .hint {
  margin: 0 0 14px;
  font-size: 12px;
  color: var(--muted);
}
.donut-wrap {
  position: relative;
  height: 210px;
}
.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.donut-center b {
  font-size: 24px;
  font-weight: 800;
}
.donut-center span {
  font-size: 11px;
  color: var(--muted);
}
canvas {
  max-height: 230px;
}

/* table */
.table-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.tbl-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
}
.tbl-head h3 {
  margin: 0;
  font-size: 15px;
}
.tbl-scroll {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
thead th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 2;
  text-align: right;
  padding: 11px 16px;
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 2px solid var(--line);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
thead th.lname {
  text-align: left;
}
thead th .arw {
  opacity: 0.35;
  font-size: 10px;
  margin-left: 3px;
}
thead th.sorted .arw {
  opacity: 1;
  color: var(--brand2);
}
tbody td {
  padding: 12px 16px;
  text-align: right;
  border-bottom: 1px solid #f1f5f9;
  white-space: nowrap;
}
tbody td.lname {
  text-align: left;
  font-weight: 600;
  white-space: normal;
  min-width: 260px;
}
tbody td.lname a {
  color: var(--brand2);
  text-decoration: none;
}
tbody td.lname a:hover {
  text-decoration: underline;
}
tbody tr:hover td {
  background: #f8fafc;
}
tbody tr.total-row td {
  font-weight: 700;
  background: #eff6ff;
  border-bottom: 2px solid var(--line);
}
.zero {
  color: #cbd5e1;
}
.bar-mini {
  display: inline-block;
  height: 6px;
  border-radius: 3px;
  background: var(--c-budget);
  vertical-align: middle;
  margin-left: 8px;
}
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.p-b {
  background: #eff6ff;
  color: #1d4ed8;
}
.p-c {
  background: #fef2f2;
  color: #b91c1c;
}
.foot {
  padding: 12px 18px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.nodata {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 16px;
}

/* mobile cards */
#cards {
  display: none;
  padding: 12px;
}
.scard {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  margin-bottom: 10px;
  background: #fff;
}
.scard.total {
  background: var(--brand-soft);
  border-color: #c7dbff;
}
.scard .sc-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.scard .sc-name {
  font-weight: 700;
  font-size: 14px;
  line-height: 1.3;
}
.scard .sc-name a {
  color: inherit;
  text-decoration: none;
}
.scard .sc-total {
  font-size: 20px;
  font-weight: 800;
  color: var(--brand);
  white-space: nowrap;
}
.sc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 11px;
}
.sc-grid .m {
  background: #f8fafc;
  border-radius: 9px;
  padding: 8px 10px;
}
.sc-grid .m .ml {
  font-size: 10.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 600;
}
.sc-grid .m .mv {
  font-size: 15px;
  font-weight: 700;
  margin-top: 2px;
}
.sc-bar {
  height: 8px;
  border-radius: 5px;
  margin-top: 11px;
  overflow: hidden;
  display: flex;
}
.sc-bar i {
  display: block;
  height: 100%;
}

@media (max-width: 1100px) {
  .kpis {
    grid-template-columns: repeat(3, 1fr);
  }
  .charts {
    grid-template-columns: 1fr 1fr;
  }
  .charts .wide {
    grid-column: 1/-1;
  }
}
@media (max-width: 720px) {
  .wrap {
    padding: 16px 14px 48px;
  }
  .page-title h1 {
    font-size: 17px;
  }
  .toolbar {
    padding: 12px;
    gap: 10px;
  }
  .toolbar .field {
    flex: 1 1 calc(50% - 5px);
  }
  .toolbar select {
    width: 100%;
    min-width: 0;
  }
  .toolbar .spacer {
    display: none;
  }
  .toolbar .field.search-field {
    flex: 1 1 100%;
  }
  .search,
  .search input {
    width: 100%;
  }
  .toolbar .btn {
    flex: 1 1 calc(33% - 7px);
    justify-content: center;
    padding: 0 8px;
  }
  .kpis {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .kpi .val {
    font-size: 21px;
  }
  .charts {
    grid-template-columns: 1fr;
  }
  .tbl-scroll {
    display: none;
  }
  #cards {
    display: block;
  }
  .tbl-head {
    padding: 14px;
  }
}
@media (max-width: 380px) {
  .kpis {
    grid-template-columns: 1fr;
  }
}
@media print {
  .topbar,
  .toolbar,
  .charts {
    display: none;
  }
  body {
    padding-top: 0;
  }
}

/* пагинация */
.pager {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.pager .page-size {
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 0 26px 0 10px;
  min-width: 0;
  font-size: 13px;
}
.pager-info {
  font-size: 12px;
  color: var(--muted);
}
.pager-pages {
  margin-left: auto;
  display: flex;
  gap: 5px;
  align-items: center;
}
.page-btn {
  min-width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  padding: 0 8px;
}
.page-btn:hover:not(:disabled) {
  border-color: var(--brand2);
  color: var(--brand2);
}
.page-btn.active {
  background: var(--brand2);
  border-color: var(--brand2);
  color: #fff;
}
.page-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.page-dots {
  color: var(--muted);
  padding: 0 2px;
}
@media (max-width: 720px) {
  .pager-pages {
    margin-left: 0;
    width: 100%;
    justify-content: center;
  }
}
@media print {
  .pager {
    display: none;
  }
}
