:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-soft: #f9fafc;
  --ink: #172033;
  --muted: #667085;
  --muted-2: #98a2b3;
  --line: #d9dee8;
  --blue: #2f6bff;
  --teal: #0f9f8f;
  --amber: #d88a04;
  --rose: #d94a62;
  --green: #159957;
  --violet: #7755cc;
  --shadow: 0 18px 50px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

body {
  margin: 0;
  min-width: 320px;
}

button,
input,
textarea,
select {
  font: inherit;
}

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

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(32px, 5vw, 56px);
  line-height: 0.95;
  font-weight: 820;
  letter-spacing: 0;
}

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

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 8px 14px;
  font-weight: 720;
  cursor: pointer;
}

.button:hover {
  border-color: #b8c0d1;
  background: #fdfefe;
}

.button:disabled {
  color: var(--muted-2);
  cursor: wait;
}

.status-pill {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid #badfd9;
  background: #eefaf8;
  color: #087265;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 760;
  white-space: nowrap;
}

.status-pill.error {
  border-color: #f3bdc7;
  background: #fff1f3;
  color: #b4233b;
}

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

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

.kpi-card {
  min-height: 148px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-top: 4px solid var(--accent, var(--blue));
}

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

.kpi-value {
  margin-top: 12px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1;
  font-weight: 840;
}

.kpi-sub {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.delta {
  color: var(--green);
  font-weight: 760;
}

.delta.down {
  color: var(--rose);
}

.layout-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.panel {
  padding: 18px;
  min-width: 0;
}

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

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

.panel-header p,
.panel-meta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.chart-canvas {
  width: 100%;
  height: 360px;
  display: block;
}

.chart-compact {
  height: 292px;
}

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

.bar-row {
  display: grid;
  gap: 7px;
}

.bar-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.bar-label {
  color: var(--ink);
  font-weight: 740;
}

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

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent, var(--blue));
}

.table-panel {
  margin-top: 14px;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  background: var(--surface);
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid #edf0f6;
  text-align: right;
  font-size: 13px;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  background: var(--surface-soft);
  font-weight: 760;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.error-state {
  border: 1px solid #f3bdc7;
  border-radius: 8px;
  background: #fff1f3;
  color: #8f1d32;
  padding: 16px;
  font-size: 14px;
}

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

@media (max-width: 820px) {
  .shell {
    width: min(100% - 20px, 1480px);
    padding-top: 18px;
  }

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

  .toolbar {
    justify-content: flex-start;
  }

  .kpi-grid,
  .layout-grid {
    grid-template-columns: 1fr;
  }

  .chart-canvas,
  .chart-compact {
    height: 280px;
  }
}
