:root {
  --bg: #f5f7f4;
  --panel: #ffffff;
  --ink: #1d2528;
  --muted: #627074;
  --line: #dfe6e1;
  --green: #176f57;
  --red: #b23b3b;
  --blue: #245f9f;
  --gold: #a66a16;
  --shadow: 0 10px 30px rgba(25, 38, 35, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 22px clamp(16px, 3.5vw, 40px) 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfa;
}

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

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 820px;
  margin-bottom: 0;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 4px;
  font-size: 17px;
}

h3 {
  margin-bottom: 3px;
  font-size: 14px;
}

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

main {
  display: grid;
  gap: 14px;
  padding: 18px clamp(16px, 3.5vw, 40px) 32px;
}

.toolbar,
.tableTools,
.panelHead,
.sectionHead,
.detailHead,
.chartControls,
.segmented,
.metrics,
.split {
  display: flex;
  gap: 12px;
}

.toolbar {
  align-items: end;
  flex-wrap: wrap;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

select,
input,
.ghostButton {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--ink);
  font: inherit;
}

select {
  min-width: 178px;
  padding: 0 34px 0 12px;
}

input {
  min-width: 220px;
  padding: 0 12px;
}

.compactSelect {
  min-width: 112px;
}

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

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

.metric {
  min-height: 96px;
  padding: 14px;
}

.metric span,
.metric small {
  display: block;
  color: var(--muted);
}

.metric span {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin: 8px 0 6px;
  font-size: clamp(21px, 2.4vw, 29px);
  line-height: 1;
}

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

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

.panel {
  padding: 14px;
  overflow: hidden;
}

.panelHead {
  align-items: start;
  justify-content: space-between;
  margin-bottom: 10px;
}

.sectionHead,
.detailHead {
  align-items: start;
  justify-content: space-between;
}

.sectionHead {
  margin-bottom: 10px;
}

.detailHead {
  gap: 10px;
  margin-bottom: 8px;
}

.panelHead p,
.sectionHead p,
.detailHead p {
  margin-bottom: 0;
  font-size: 13px;
}

.moversBlock {
  display: grid;
}

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

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

.moverPanel {
  padding: 10px 12px;
}

.adjustmentPanel {
  padding: 10px 12px;
}

.moverHead {
  margin-bottom: 4px;
}

.adjustmentHead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.adjustmentHead span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

h4 {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.adjustmentList {
  display: grid;
  gap: 2px;
}

.adjustmentItem {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) minmax(164px, auto);
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  border-top: 1px solid var(--line);
  cursor: pointer;
}

.adjustmentItem:first-child {
  border-top: 0;
}

.adjustmentItem span {
  display: grid;
  width: 16px;
  height: 16px;
  place-items: center;
  border-radius: 50%;
  background: #edf2ef;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
}

.adjustmentItem strong {
  overflow: hidden;
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.adjustmentAmounts {
  display: grid;
  grid-template-columns: repeat(3, minmax(46px, auto));
  gap: 8px;
  text-align: right;
}

.adjustmentItem em {
  color: var(--ink);
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}

.adjustmentItem em small {
  display: block;
  color: var(--muted);
  font-size: 8px;
  font-weight: 800;
  text-transform: uppercase;
}

.chartControls {
  align-items: end;
  flex-wrap: wrap;
  justify-content: end;
}

.ghostButton {
  padding: 0 12px;
  background: #f7faf8;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.ghostButton:disabled {
  color: var(--muted);
  cursor: default;
  opacity: 0.5;
}

.segmented {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 3px;
}

.segmented button {
  min-width: 44px;
  height: 28px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.segmented button.active {
  background: var(--ink);
  color: white;
}

.chartWrap {
  width: 100%;
  min-height: 260px;
}

#trendChart {
  display: block;
  width: 100%;
  height: 260px;
}

.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.detailPanel {
  min-width: 0;
}

.rankList {
  display: grid;
  gap: 2px;
}

.rankItem {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) minmax(190px, auto);
  align-items: center;
  gap: 7px;
  padding: 4px 0;
  border-top: 1px solid var(--line);
  cursor: pointer;
}

.rankItem:first-child {
  border-top: 0;
}

.rankIndex {
  display: grid;
  width: 19px;
  height: 19px;
  place-items: center;
  border-radius: 50%;
  background: #edf2ef;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.rankName strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rankName span,
.rankAmount span {
  display: block;
  color: var(--muted);
  font-size: 10px;
}

.rankAmounts {
  display: grid;
  grid-template-columns: repeat(3, minmax(56px, auto));
  gap: 8px;
  text-align: right;
}

.rankAmount strong {
  display: block;
  color: var(--ink);
  font-size: 11px;
}

.rankValue {
  text-align: right;
}

.rankValue small {
  display: block;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
}

.tableTools {
  align-items: center;
  flex-wrap: wrap;
}

.tableWrap {
  overflow-x: auto;
}

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

th,
td {
  padding: 8px 9px;
  border-top: 1px solid var(--line);
  text-align: right;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

th:first-child,
th:nth-child(2),
td:first-child,
td:nth-child(2) {
  text-align: left;
}

th:first-child,
td:first-child {
  width: 76px;
  max-width: 76px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

td:nth-child(2) {
  max-width: 360px;
}

.categoryRow {
  cursor: pointer;
}

.categoryRow:hover,
.categoryRow:focus,
.rankItem:hover,
.rankItem:focus,
.adjustmentItem:hover,
.adjustmentItem:focus {
  background: #f2f6f4;
  outline: none;
}

.categoryRow.selected,
.rankItem.selected,
.adjustmentItem.selected {
  background: #eef4f8;
  box-shadow: inset 4px 0 0 var(--blue);
}

.empty {
  padding: 24px 0;
  color: var(--muted);
}

.compactEmpty {
  padding: 8px 0;
}

@media (max-width: 880px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar,
  .toolbar label,
  .toolbar select {
    width: 100%;
  }

  .metrics,
  .split,
  .detailSplit,
  .moverGrid,
  .adjustmentGrid {
    grid-template-columns: 1fr;
  }

  .panelHead,
  .sectionHead,
  .detailHead {
    align-items: stretch;
    flex-direction: column;
  }

  .chartControls,
  .chartControls label,
  .chartControls select {
    width: 100%;
  }
}
