:root {
  --bg: #f4f7f6;
  --surface: #ffffff;
  --surface-2: #edf4f2;
  --line: #d5e1de;
  --text: #1d2b2c;
  --muted: #607172;
  --green: #13856f;
  --green-dark: #0d5f53;
  --blue: #225f91;
  --red: #b54a48;
  --amber: #aa741b;
  --shadow: 0 14px 34px rgba(23, 55, 54, .08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1760px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 38px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 3vw, 46px);
  line-height: 1.05;
}

h2 {
  margin: 0;
  font-size: 22px;
}

h3 {
  margin: 0;
  font-size: 16px;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-pill,
.source-chip,
.risk-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.status-pill.is-ok {
  color: var(--green-dark);
  background: #dff2eb;
}

.status-pill.is-error,
.risk-chip.bad {
  color: #8f2523;
  background: #f8dfdc;
}

.risk-chip.warn {
  color: #80540d;
  background: #fff0cf;
}

.risk-chip.good {
  color: var(--green-dark);
  background: #dff2eb;
}

.primary-action,
.apply-action {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  color: #fff;
  background: var(--green);
  font-weight: 800;
}

.primary-action:hover,
.apply-action:hover {
  background: var(--green-dark);
}

.filters-panel {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(180px, 1.1fr) minmax(260px, 2fr) 150px 150px auto 130px;
  gap: 10px;
  align-items: end;
  margin-bottom: 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

label {
  display: grid;
  gap: 6px;
}

label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

select,
input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
}

.quick-range {
  display: grid;
  grid-template-columns: repeat(3, minmax(78px, 1fr));
  gap: 6px;
}

.quick-range button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--green-dark);
  background: var(--surface-2);
  font-weight: 800;
}

.content {
  display: grid;
  gap: 18px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(8, minmax(130px, 1fr));
  gap: 10px;
}

.metric-card,
.source-card,
.panel,
.insight,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 112px;
  padding: 14px;
  display: grid;
  align-content: space-between;
  gap: 10px;
}

.metric-card strong {
  display: block;
  font-size: clamp(22px, 2vw, 32px);
  line-height: 1;
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-card small {
  color: var(--muted);
  line-height: 1.35;
}

.top-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr);
  gap: 18px;
}

.panel {
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
}

.panel-header p {
  margin: 4px 0 0;
  color: var(--muted);
}

.insights-grid {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.insight {
  padding: 13px;
  box-shadow: none;
}

.insight b {
  display: block;
  margin-bottom: 5px;
}

.insight p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.source-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 12px;
}

.source-card {
  padding: 16px;
}

.source-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.source-head p {
  margin: 5px 0 0;
  color: var(--muted);
}

.source-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.mini-metric {
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-2);
}

.mini-metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.mini-metric strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
  white-space: nowrap;
}

.funnel {
  display: grid;
  gap: 8px;
}

.funnel-row {
  display: grid;
  grid-template-columns: 88px 1fr 76px;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.funnel-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dde8e5;
}

.funnel-fill {
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
  background: var(--green);
}

.chart-wrap {
  padding: 14px 16px 18px;
}

.chart-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.chart-tabs button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
}

.chart-tabs button.active {
  color: #fff;
  border-color: var(--green);
  background: var(--green);
}

.bar-chart {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(42px, 1fr));
  gap: 8px;
  align-items: end;
  min-height: 260px;
  padding-top: 6px;
}

.bar-item {
  display: grid;
  align-items: end;
  gap: 8px;
  min-width: 0;
}

.bar {
  min-height: 2px;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, #1b9078, #225f91);
}

.bar-value {
  min-height: 32px;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.bar-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fbfa;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

td.number,
th.number {
  text-align: right;
}

.campaign-name {
  max-width: 460px;
  font-weight: 800;
}

.muted {
  color: var(--muted);
}

.changes-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.change-item {
  display: grid;
  grid-template-columns: 160px 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.change-item p {
  margin: 3px 0 0;
  color: var(--muted);
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 60px 20px;
  color: var(--muted);
  text-align: center;
}

.loader {
  width: 42px;
  height: 42px;
  border: 4px solid var(--line);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.error-box {
  padding: 18px;
  border: 1px solid #f0b8b5;
  border-radius: 8px;
  color: #842522;
  background: #fff1f0;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1320px) {
  .filters-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-strip,
  .source-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .top-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 1760px);
    padding-top: 14px;
  }

  .hero,
  .hero-actions,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .filters-panel,
  .summary-strip,
  .source-grid,
  .source-metrics {
    grid-template-columns: 1fr;
  }

  .quick-range {
    grid-template-columns: 1fr;
  }

  .change-item {
    grid-template-columns: 1fr;
  }
}
