:root {
  color-scheme: light;
  --ink: #172126;
  --muted: #607079;
  --line: #d8e0df;
  --surface: #ffffff;
  --page: #eef4f1;
  --green: #126a58;
  --teal: #0e8294;
  --gold: #b87913;
  --red: #b74844;
  --shadow: 0 12px 32px rgba(27, 42, 44, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--page);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

.app-header {
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  gap: 24px;
  min-height: 178px;
  padding: 0 32px;
  color: #fff;
  background: linear-gradient(
    180deg,
    #c91620 0%,
    #c91620 33.333%,
    #ffffff 33.333%,
    #ffffff 66.666%,
    #0b0b0d 66.666%,
    #0b0b0d 100%
  );
  border-bottom: 6px solid #0b0b0d;
}

.app-header > div {
  display: grid;
  grid-template-rows: 1fr 1fr 1fr;
  min-height: inherit;
  width: 100%;
}

.header-logo {
  align-self: center;
  justify-self: center;
  width: min(72px, 18vw);
  aspect-ratio: 1;
  border: 2px solid #0b0b0d;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
}

.eyebrow {
  align-self: center;
  margin: 0;
  color: #ffffff;
  font-size: clamp(1rem, 2.1vw, 1.35rem);
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  align-self: center;
  justify-self: center;
  grid-row: 3;
  font-size: 14px;
  line-height: 1;
  letter-spacing: 0;
  text-align: center;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.24);
}

h2 {
  font-size: 1rem;
  letter-spacing: 0;
}

main {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 22px 32px 36px;
}

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

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

.metric {
  padding: 16px 18px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 2rem;
  line-height: 1;
}

.controls {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(150px, 1fr));
  gap: 14px;
  margin-top: 16px;
  padding: 16px;
}

label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  height: 42px;
  border: 1px solid #c7d3d1;
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
  background: #fbfdfc;
  font: inherit;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(14, 130, 148, 0.28);
  outline-offset: 1px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 16px 0;
}

.tab,
.utility-button {
  height: 38px;
  border: 1px solid #bfd0ce;
  border-radius: 6px;
  padding: 0 14px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

.tab.is-active {
  color: #fff;
  border-color: var(--green);
  background: var(--green);
}

.utility-button {
  color: var(--green);
}

.view {
  display: none;
  overflow: hidden;
}

.view.is-active {
  display: block;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.section-title p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.table-shell {
  overflow: auto;
  max-height: 63vh;
}

table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid #edf1f0;
  text-align: left;
  vertical-align: top;
  font-size: 0.92rem;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #405258;
  background: #f8fbfa;
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

tbody tr:hover {
  background: #f8fbfa;
}

.empty-row td {
  padding: 34px 14px;
  color: var(--muted);
  text-align: center;
}

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

.panel {
  min-height: 260px;
  padding: 16px;
  box-shadow: none;
}

.panel h2 {
  margin-bottom: 14px;
}

.bars {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(100px, 160px) 1fr 58px;
  align-items: center;
  gap: 10px;
}

.bar-label,
.bar-value {
  color: #33464b;
  font-size: 0.88rem;
}

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

.bar-fill {
  height: 100%;
  width: var(--width);
  background: var(--green);
}

.bar-row:nth-child(2n) .bar-fill {
  background: var(--teal);
}

.bar-row:nth-child(3n) .bar-fill {
  background: var(--gold);
}

.bar-row:nth-child(4n) .bar-fill {
  background: var(--red);
}

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

.sheet-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #edf1f0;
}

.sheet-item span {
  color: var(--muted);
}

@media (max-width: 920px) {
  .app-header {
    align-items: stretch;
    flex-direction: column;
    min-height: 166px;
    padding: 0 20px;
  }

  main {
    padding: 18px 16px 28px;
  }

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

  .search-wrap {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .summary-grid,
  .controls,
  .insight-grid {
    grid-template-columns: 1fr;
  }

  .tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .tab,
  .utility-button {
    padding: 0 10px;
    font-size: 0.86rem;
  }

  .section-title {
    align-items: stretch;
    flex-direction: column;
  }
}
