:root {
  --bg: #f1f5f9;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #1e3a8a;
  --brand2: #2563eb;
  --brand-soft: #eff6ff;
  --c-plan: #0f766e;
  --c-reg: #2563eb;
  --c-rec: #7c3aed;
  --c-conf-a: #d97706;
  --c-conf-u: #059669;
  --c-rev: #dc2626;
  --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;
}
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: 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 18px;
  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(6, 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);
}

/* панели */
.grid2 {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  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 16px;
  font-size: 12px;
  color: var(--muted);
}

/* воронка */
.funnel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.fstep {
  display: grid;
  grid-template-columns: 190px 1fr auto;
  align-items: center;
  gap: 12px;
}
.fstep .name {
  font-size: 12.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.fstep .name i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}
.bar-track {
  background: #f1f5f9;
  border-radius: 8px;
  height: 26px;
  position: relative;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 8px;
  transition: width 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}
.fstep .pct {
  font-size: 12px;
  font-weight: 700;
  width: 52px;
  text-align: right;
  color: var(--muted);
}

canvas {
  max-height: 260px;
}

/* таблица */
.table-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.tabs {
  display: flex;
  gap: 4px;
  padding: 12px 16px 0;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
}
.tab {
  border: none;
  background: transparent;
  padding: 9px 15px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-radius: 9px 9px 0 0;
  border-bottom: 3px solid transparent;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 7px;
}
.tab i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}
.tab:hover {
  color: var(--ink);
  background: #f8fafc;
}
.tab.active {
  color: var(--brand);
  border-bottom-color: var(--brand2);
  background: var(--brand-soft);
}
.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 14px;
  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:first-child,
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: 11px 14px;
  text-align: right;
  border-bottom: 1px solid #f1f5f9;
  white-space: nowrap;
}
tbody td.lname {
  text-align: left;
  font-weight: 600;
}
tbody td.idx {
  text-align: center;
  color: var(--muted);
  width: 42px;
}
tbody tr:hover td {
  background: #f8fafc;
}
tbody tr.total-row td {
  font-weight: 700;
  background: #eff6ff;
  border-bottom: 2px solid var(--line);
}
tbody tr.total-row:hover td {
  background: #e0ecff;
}
.zero {
  color: #cbd5e1;
}
.expander {
  cursor: pointer;
}
.expander .chev {
  display: inline-block;
  transition: transform 0.2s;
  color: var(--brand2);
  margin-right: 6px;
  font-size: 11px;
}
.expander.open .chev {
  transform: rotate(90deg);
}
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.b-budget {
  background: #ecfdf5;
  color: #047857;
}
.b-contract {
  background: #eef2ff;
  color: #4338ca;
}
.detail-row td {
  background: #fbfcfe;
  padding: 0;
}
.detail-inner {
  padding: 14px 20px 16px;
}
.detail-inner h5 {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.mini {
  width: 100%;
  border-collapse: collapse;
}
.mini th,
.mini td {
  padding: 7px 10px;
  font-size: 12.5px;
  text-align: right;
  border-bottom: 1px solid #eef2f7;
}
.mini th:first-child,
.mini td:first-child {
  text-align: left;
  color: var(--muted);
}
.mini thead th {
  background: transparent;
  position: static;
  text-transform: none;
  letter-spacing: 0;
  border-bottom: 1px solid var(--line);
}
.tag-tur {
  color: var(--muted);
  font-size: 11px;
}
.foot {
  padding: 12px 18px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.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;
}

/* пагинация */
.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;
}

/* мобильные карточки */
#cards {
  display: none;
  padding: 12px;
}
.ucard {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  margin-bottom: 10px;
  background: #fff;
}
.ucard.total {
  background: var(--brand-soft);
  border-color: #c7dbff;
}
.ucard .uc-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
}
.ucard .uc-num {
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
  min-width: 20px;
}
.ucard .uc-name {
  font-weight: 700;
  font-size: 14px;
  flex: 1;
  line-height: 1.3;
}
.ucard .uc-total {
  font-size: 19px;
  font-weight: 800;
  color: var(--brand);
  white-space: nowrap;
}
.ucard .uc-chev {
  color: var(--brand2);
  font-size: 12px;
  transition: transform 0.2s;
  margin-top: 2px;
}
.ucard.open .uc-chev {
  transform: rotate(90deg);
}
.uc-metrics {
  display: flex;
  gap: 8px;
  margin-top: 11px;
}
.uc-metrics .m {
  flex: 1;
  background: #f8fafc;
  border-radius: 9px;
  padding: 8px 10px;
}
.uc-metrics .m .ml {
  font-size: 10.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 600;
}
.uc-metrics .m .mv {
  font-size: 16px;
  font-weight: 700;
  margin-top: 2px;
}
.uc-detail {
  margin-top: 12px;
  border-top: 1px dashed var(--line);
  padding-top: 10px;
  display: none;
}
.ucard.open .uc-detail {
  display: block;
}
.uc-detail h6 {
  margin: 0 0 7px;
  font-size: 10.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.uc-detail .tourgrid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
}
.uc-detail .tg {
  background: #f8fafc;
  border-radius: 7px;
  padding: 6px 4px;
  text-align: center;
}
.uc-detail .tg.act {
  background: #eff6ff;
  outline: 1px solid #bcd4ff;
}
.uc-detail .tg .tl {
  font-size: 9.5px;
  color: var(--muted);
}
.uc-detail .tg .tv {
  font-size: 12px;
  font-weight: 700;
  margin-top: 1px;
}
.uc-detail .row2 {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-top: 8px;
  color: var(--muted);
}
.uc-detail .row2 b {
  color: var(--ink);
}

/* адаптив */
@media (max-width: 1100px) {
  .kpis {
    grid-template-columns: repeat(3, 1fr);
  }
  .grid2 {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 720px) {
  .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%;
  }
  .toolbar .btn {
    flex: 1 1 calc(50% - 5px);
    justify-content: center;
  }
  .kpis {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .kpi .val {
    font-size: 22px;
  }
  .card {
    padding: 15px;
  }
  .fstep {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .fstep .name {
    font-size: 12px;
  }
  .fstep .pct {
    display: none;
  }
  .bar-track {
    height: 24px;
  }
  .tbl-scroll {
    display: none;
  }
  #cards {
    display: block;
  }
  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .tab {
    white-space: nowrap;
    flex: 0 0 auto;
  }
  .foot {
    flex-direction: column;
    gap: 4px;
  }
  .pager-pages {
    margin-left: 0;
    width: 100%;
    justify-content: center;
  }
}
@media (max-width: 380px) {
  .kpis {
    grid-template-columns: 1fr;
  }
}
@media print {
  .topbar,
  .toolbar,
  .tabs,
  .grid2,
  .pager {
    display: none;
  }
  body {
    padding-top: 0;
  }
}
