:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-strong: #f0f4f7;
  --ink: #1d2733;
  --muted: #687789;
  --line: #d8e1ea;
  --blue: #2864b8;
  --teal: #138579;
  --amber: #b06a00;
  --red: #c13d3d;
  --green: #26734d;
  --violet: #6c5fa7;
  --radius: 8px;
  --shadow: 0 16px 40px rgba(30, 49, 70, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

.topbar {
  min-height: 168px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 32px clamp(18px, 4vw, 56px) 28px;
  background:
    linear-gradient(90deg, rgba(40, 100, 184, 0.96), rgba(19, 133, 121, 0.92)),
    #2864b8;
  color: #fff;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 12px;
  opacity: 0.86;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.08;
  letter-spacing: 0;
}

h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

.topbar-meta {
  align-self: flex-end;
  max-width: 440px;
  text-align: right;
  font-size: 14px;
  line-height: 1.65;
  color: rgba(255, 255, 255, 0.86);
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 10px clamp(18px, 4vw, 56px);
  background: rgba(245, 247, 250, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius);
  padding: 9px 14px;
  min-width: max-content;
  cursor: pointer;
}

.tab.active {
  background: var(--surface);
  color: var(--blue);
  border-color: var(--line);
  box-shadow: 0 6px 18px rgba(20, 43, 73, 0.08);
}

.app-shell {
  padding: 24px clamp(18px, 4vw, 56px) 52px;
}

.section-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 18px;
  align-items: start;
}

.section-grid > * {
  min-width: 0;
}

.panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

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

.panel-header > * {
  min-width: 0;
}

.panel-header p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

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

.kpi {
  min-height: 108px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

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

.kpi-value {
  margin-top: 10px;
  font-size: 30px;
  line-height: 1;
  font-weight: 760;
}

.kpi-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.status-row,
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.summary-grid h3 {
  margin-bottom: 10px;
  font-size: 15px;
}

.mini-list {
  display: grid;
  gap: 8px;
}

.mini-list > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdff;
}

.toolbar {
  margin-bottom: 12px;
}

.toolbar input,
.toolbar select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

.toolbar input {
  min-width: min(420px, 100%);
  flex: 1;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.badge.red {
  background: #fbe8e8;
  color: var(--red);
}

.badge.green {
  background: #e5f4ed;
  color: var(--green);
}

.badge.amber {
  background: #fff2d8;
  color: var(--amber);
}

.badge.blue {
  background: #e7effb;
  color: var(--blue);
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: #fff;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
  line-height: 1.45;
}

th {
  position: sticky;
  top: 0;
  background: #f7fafc;
  color: #526273;
  font-size: 12px;
  font-weight: 700;
  z-index: 1;
}

th.sortable {
  cursor: pointer;
}

tbody tr:hover {
  background: #fbfdff;
}

.metric {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stars {
  color: #b66b00;
  white-space: nowrap;
}

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

.bar-row {
  display: grid;
  grid-template-columns: minmax(120px, 220px) 1fr minmax(48px, auto);
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

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

.bar-fill {
  height: 100%;
  min-width: 2px;
  background: linear-gradient(90deg, var(--blue), var(--teal));
}

.bar-fill.red {
  background: linear-gradient(90deg, var(--red), #e58b58);
}

.bar-fill.amber {
  background: linear-gradient(90deg, var(--amber), #d8a23b);
}

.insight-list,
.review-list {
  display: grid;
  gap: 12px;
}

.insight {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
  background: #fff;
}

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

.insight p,
.review-card p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.review-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.review-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.review-title h3 {
  font-size: 16px;
}

.review-text-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.quote-box {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 112px;
}

.quote-box h4 {
  margin: 0 0 8px;
  color: #526273;
  font-size: 12px;
}

.quote-box p {
  margin: 0;
  color: var(--ink);
}

.link {
  color: var(--blue);
  text-decoration: none;
}

.link:hover {
  text-decoration: underline;
}

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

.danger {
  color: var(--red);
}

.good {
  color: var(--green);
}

.empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.pager {
  justify-content: space-between;
  margin-top: 12px;
}

.pager button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 8px 12px;
  cursor: pointer;
}

.pager button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.matrix-cell {
  min-width: 86px;
}

.delta-neg {
  color: var(--red);
}

.delta-pos {
  color: var(--green);
}

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

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

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

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    min-height: 190px;
  }

  .topbar-meta {
    align-self: flex-start;
    text-align: left;
  }

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

  .panel {
    padding: 14px;
  }

  .review-title,
  .panel-header {
    flex-direction: column;
  }

  .review-text-grid {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}
