:root {
  color-scheme: light;
  --ink: #1b2430;
  --muted: #667085;
  --line: #d8dee8;
  --paper: #f6f7f9;
  --panel: #ffffff;
  --green: #2f8f6b;
  --blue: #3366aa;
  --amber: #c88728;
  --red: #c44e52;
  --teal: #1d7f8c;
  --shadow: 0 18px 40px rgba(24, 36, 52, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(246, 247, 249, 0.96)),
    repeating-linear-gradient(90deg, rgba(51, 102, 170, 0.05) 0 1px, transparent 1px 64px);
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, sans-serif;
}

.shell {
  width: min(1420px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 84px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.select-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.select-control,
.action-button {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
  font: 700 13px "Segoe UI", Tahoma, sans-serif;
}

.select-control {
  min-width: 132px;
  padding: 0 34px 0 12px;
}

.select-control.full-width {
  width: 100%;
  margin-bottom: 14px;
}

.action-button {
  padding: 0 14px;
  cursor: pointer;
}

.action-button:hover {
  border-color: rgba(51, 102, 170, 0.38);
  background: #eef4ff;
  color: var(--blue);
}

.data-status {
  min-height: 20px;
  margin: -6px 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 52px);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
  line-height: 1.2;
}

.toolbar {
  display: flex;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.8);
}

.icon-button {
  display: grid;
  place-items: center;
  min-width: 62px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.icon-button:hover,
.icon-button.active {
  border-color: rgba(51, 102, 170, 0.24);
  background: #eef4ff;
  color: var(--blue);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 22px 0 16px;
}

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

.insight-strip article {
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
  padding: 15px;
}

.insight-strip span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.insight-strip strong {
  display: block;
  font-size: 15px;
  line-height: 1.35;
}

.kpi,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.kpi {
  min-height: 122px;
  padding: 18px;
}

.kpi-label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.kpi strong {
  display: block;
  margin: 8px 0 4px;
  font-size: clamp(27px, 4vw, 42px);
  line-height: 1;
  letter-spacing: 0;
}

.kpi small {
  color: var(--muted);
  font-size: 13px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.7fr);
  gap: 16px;
}

.panel {
  min-height: 360px;
  padding: 18px;
}

.panel.wide {
  grid-row: span 2;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.ai-section {
  margin-top: 14px;
}

.ai-section h3 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.ai-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
}

.ai-list li {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

.ai-list.subtle li {
  color: var(--muted);
  font-size: 13px;
}

canvas {
  display: block;
  width: 100%;
  max-width: 100%;
}

.rank-list {
  display: grid;
  gap: 12px;
}

.rank-item {
  display: grid;
  gap: 7px;
}

.rank-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.rank-name {
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-count {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.bar-track {
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: #edf0f4;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--green));
}

.compact {
  gap: 10px;
}

.health-list {
  display: grid;
  gap: 12px;
  margin: 0;
}

.health-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.health-list dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.health-list dd {
  margin: 0;
  font-weight: 700;
  text-align: right;
}

.hidden {
  display: none;
}

@media (max-width: 960px) {
  .kpi-grid,
  .insight-strip,
  .dashboard-grid {
    grid-template-columns: 1fr 1fr;
  }

  .panel.wide {
    grid-column: 1 / -1;
    grid-row: auto;
  }
}

@media (max-width: 680px) {
  .shell {
    width: min(100vw - 20px, 1420px);
    padding-top: 18px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    flex-wrap: wrap;
    margin-left: 0;
  }

  .select-control {
    flex: 1;
    min-width: 150px;
  }

  .action-button {
    flex: 1;
  }

  .kpi-grid,
  .insight-strip,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .toolbar {
    width: 100%;
    justify-content: space-between;
  }

  .icon-button {
    flex: 1;
  }
}
