:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #15171c;
  --muted: #667085;
  --border: #dfe5ee;
  --red: #d71920;
  --red-dark: #a81218;
  --green: #16845b;
  --amber: #b7791f;
  --blue: #2563eb;
  --ink: #20242c;
  --shadow: 0 18px 42px rgba(20, 24, 31, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(180deg, #ffffff 0, #f3f5f8 360px),
    var(--bg);
  color: var(--text);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px clamp(16px, 3vw, 36px);
  border-bottom: 1px solid rgba(21, 23, 28, 0.09);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
}

.brand { display: flex; align-items: center; gap: 16px; min-width: 0; }
.brand-logo {
  display: block;
  width: 112px;
  height: auto;
  flex: 0 0 auto;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 22px; line-height: 1.15; }
h2 { margin-top: 7px; font-size: clamp(30px, 5vw, 58px); line-height: 0.96; font-weight: 900; }
h3 { font-size: 18px; }

.eyebrow {
  color: var(--red);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.muted { color: var(--muted); }
.toolbar { display: flex; gap: 10px; }

select {
  height: 42px;
  min-width: 160px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
  font: inherit;
  box-shadow: 0 8px 18px rgba(20, 24, 31, 0.04);
}

main { padding: 24px clamp(16px, 3vw, 36px) 46px; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 440px);
  gap: 18px;
  align-items: stretch;
  margin-bottom: 18px;
}

.hero-copy, .legend-card, .summary-band, .explain-card, .kpi, .panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hero-copy {
  position: relative;
  overflow: hidden;
  padding: clamp(24px, 4vw, 42px);
}

.hero-copy:after {
  content: "";
  position: absolute;
  right: -80px;
  top: -100px;
  width: 260px;
  height: 260px;
  border-radius: 999px;
  background: rgba(215, 25, 32, 0.10);
}

.hero-copy p:not(.eyebrow) {
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin-top: 15px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.65;
}

.legend-card {
  display: grid;
  align-content: center;
  gap: 16px;
  padding: 24px;
  background: #15171c;
  color: #fff;
}

.legend-title { font-size: 20px; font-weight: 850; }
.legend-grid { display: grid; gap: 12px; }
.legend-grid span { display: flex; align-items: center; gap: 10px; color: #e6e9ef; }
.dot { width: 11px; height: 11px; border-radius: 50%; box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.08); }
.dot.green { background: var(--green); }
.dot.blue { background: var(--blue); }
.dot.red { background: var(--red); }
.dot.amber { background: var(--amber); }

.summary-band {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: clamp(20px, 4vw, 34px);
}

.health-card {
  display: grid;
  align-content: center;
  min-width: 250px;
  padding: 18px;
  border: 1px solid #f0d2d2;
  border-radius: 8px;
  background: linear-gradient(180deg, #fff7f7, #fff);
}

.badge, .pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
}

.badge { margin-bottom: 10px; color: #fff; background: var(--green); }
.pill { color: var(--muted); background: var(--surface-soft); border: 1px solid var(--border); }
.health-card strong { margin-bottom: 4px; font-size: 38px; line-height: 1; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.kpi {
  position: relative;
  overflow: hidden;
  min-height: 168px;
  padding: 16px;
  border-top: 4px solid var(--border);
}

.kpi.good { border-top-color: var(--green); }
.kpi.blue { border-top-color: var(--blue); }
.kpi.bad { border-top-color: var(--red); }
.kpi.warn { border-top-color: var(--amber); }
.kpi .value { margin: 10px 0 6px; font-size: 31px; font-weight: 900; line-height: 1; }
.trend { font-size: 13px; font-weight: 780; color: var(--green); }
.kpi.bad .trend { color: var(--red); }
.kpi.warn .trend { color: var(--amber); }
.kpi-help { margin-top: 12px; color: var(--muted); font-size: 12px; line-height: 1.45; }

.explain-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.explain-card {
  padding: 16px;
  background: #fff;
}

.explain-card strong { display: block; margin-bottom: 7px; font-size: 15px; }
.explain-card p { color: var(--muted); font-size: 13px; line-height: 1.55; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 18px;
}

.panel { min-width: 0; overflow: hidden; padding: 18px; }
.panel-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 18px; }

.bar-chart {
  display: grid;
  grid-template-columns: repeat(14, minmax(28px, 1fr));
  align-items: end;
  gap: 10px;
  height: 270px;
  padding-top: 10px;
}

.bar-day { display: grid; align-content: end; gap: 5px; height: 100%; min-width: 0; }
.bar-stack {
  display: flex;
  flex-direction: column-reverse;
  height: 210px;
  overflow: hidden;
  border-radius: 5px 5px 2px 2px;
  background: var(--surface-soft);
}
.seg.inbound { background: var(--green); }
.seg.outbound { background: var(--blue); }
.seg.missed { background: var(--red); }
.bar-label { color: var(--muted); font-size: 11px; text-align: center; white-space: nowrap; }

.heatmap { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.heat-cell {
  min-height: 50px;
  padding: 8px;
  border-radius: 6px;
  color: #111827;
  font-size: 12px;
  border: 1px solid rgba(215, 25, 32, 0.12);
}

.list, .stat-stack, .insights { display: grid; gap: 12px; }
.queue-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}
.queue-top { display: flex; justify-content: space-between; gap: 10px; font-weight: 800; }
.meter { height: 9px; overflow: hidden; border-radius: 999px; background: #e9edf3; }
.meter span { display: block; height: 100%; border-radius: inherit; background: var(--red); }
.queue-item.good .meter span { background: var(--green); }
.queue-item.warn .meter span { background: var(--amber); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
tbody tr:hover { background: var(--surface-soft); }

.stat-row, .insight {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}
.stat-row { display: flex; justify-content: space-between; gap: 10px; }
.stat-row strong { font-size: 20px; }
.insight strong { display: block; margin-bottom: 5px; }
.insight { border-left: 4px solid var(--red); }

@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
}

@media (max-width: 1120px) {
  .hero, .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .topbar, .summary-band { flex-direction: column; align-items: stretch; }
  .toolbar { flex-direction: column; }
  .brand-logo { width: 96px; }
  select { width: 100%; }
  .kpi-grid, .explain-grid { grid-template-columns: 1fr; }
  .bar-chart { overflow-x: auto; grid-template-columns: repeat(14, 42px); }
  .panel-head { align-items: flex-start; flex-direction: column; }
}
