:root {
  color-scheme: light;
  --navy: #17324d;
  --blue: #2563a6;
  --teal: #0f766e;
  --line: #dbe4ee;
  --soft: #f5f8fb;
  --text: #172033;
  --muted: #64748b;
  --accent: #f4b183;
  --white: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: #edf2f7;
  font-family: Inter, Aptos, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  background: var(--white);
  border-right: 1px solid var(--line);
  padding: 18px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.brand-block {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.brand-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--navy);
}

.brand-subtitle {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.filter-stack {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

label span {
  display: block;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 5px;
  color: var(--navy);
}

select,
button {
  font: inherit;
}

select {
  width: 100%;
  min-height: 36px;
  border: 1px solid #b9c7d6;
  background: var(--white);
  color: var(--text);
  padding: 6px 9px;
}

select[multiple] {
  min-height: 106px;
}

.reset-button,
.tab {
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--navy);
  min-height: 36px;
  padding: 7px 12px;
  font-weight: 800;
  cursor: pointer;
}

.reset-button {
  width: 100%;
  margin-top: 16px;
}

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

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

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
  color: var(--navy);
}

p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.tabs {
  display: inline-flex;
  border: 1px solid var(--line);
  background: var(--white);
}

.tab {
  border: 0;
  border-right: 1px solid var(--line);
}

.tab:last-child {
  border-right: 0;
}

.tab.is-active {
  background: var(--navy);
  color: var(--white);
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.kpi-strip div {
  background: var(--white);
  border: 1px solid var(--line);
  padding: 12px 14px;
}

.kpi-strip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.kpi-strip strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
  color: var(--navy);
}

.view {
  display: none;
}

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

.grid {
  display: grid;
  gap: 14px;
  align-items: start;
}

.two-col {
  grid-template-columns: minmax(460px, 0.9fr) minmax(620px, 1.35fr);
}

.four-col {
  grid-template-columns: minmax(380px, 0.85fr) minmax(380px, 0.85fr) minmax(480px, 1fr) minmax(560px, 1.15fr);
}

.store-grid {
  grid-template-columns: repeat(2, minmax(460px, 1fr));
}

.price-grid {
  grid-template-columns: repeat(3, minmax(360px, 1fr));
}

.span-2 {
  grid-column: 1 / -1;
}

.span-3 {
  grid-column: 1 / -1;
}

.panel {
  min-width: 0;
  background: var(--white);
  border: 1px solid var(--line);
}

.panel-head {
  min-height: 38px;
  padding: 9px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--navy);
  color: var(--white);
}

.panel-head h2 {
  margin: 0;
  font-size: 13px;
  line-height: 1.2;
}

.hint {
  color: #dbeafe;
  font-size: 12px;
  font-weight: 700;
}

.table-wrap {
  overflow: auto;
  max-height: 430px;
}

.table-wrap.wide {
  max-height: 430px;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 520px;
  font-size: 12px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--blue);
  color: var(--white);
  text-align: left;
  white-space: nowrap;
  font-weight: 800;
}

.panel:nth-child(even) th {
  background: var(--teal);
}

th,
td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid #edf2f7;
  padding: 6px 8px;
  vertical-align: middle;
}

td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

td:first-child,
th:first-child {
  font-weight: 700;
}

th:first-child,
td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
}

td:first-child {
  background: inherit;
}

th:first-child {
  z-index: 3;
}

.is-sticky-col {
  position: sticky;
  z-index: 2;
}

th.is-sticky-col {
  z-index: 4;
  background: var(--blue);
}

.panel:nth-child(even) th.is-sticky-col {
  background: var(--teal);
}

td.is-sticky-col {
  background: var(--white);
  font-weight: 700;
}

tbody tr:nth-child(even) {
  background: var(--soft);
}

tbody tr:nth-child(even) td.is-sticky-col {
  background: var(--soft);
}

.total-row {
  background: #fff7df;
  font-weight: 800;
}

.total-row td.is-sticky-col {
  background: #fff7df;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .filter-stack {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

  .reset-button {
    width: auto;
  }

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

  .kpi-strip,
  .two-col,
  .four-col,
  .store-grid,
  .price-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .main {
    padding: 12px;
  }

  .filter-stack,
  .kpi-strip {
    grid-template-columns: 1fr;
  }

  .tabs {
    width: 100%;
  }

  .tab {
    flex: 1;
  }
}
