:root {
  --ink: #161a1d;
  --muted: #64707d;
  --line: #d9e0e6;
  --paper: #f7f8f5;
  --panel: #ffffff;
  --blue: #145da0;
  --green: #23745a;
  --red: #b8403f;
  --amber: #d79b25;
  --steel: #eef3f7;
  /* Categorical trio, validated for CVD-safety across every pairing (see
     dataviz skill palette.md — first three slots of the reference order). */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

.topbar {
  min-height: 220px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 38px clamp(18px, 4vw, 56px);
  color: white;
  background:
    linear-gradient(90deg, rgba(14, 24, 33, 0.9), rgba(14, 24, 33, 0.45)),
    url("https://images.unsplash.com/photo-1743069624932-1a2c399d4967?auto=format&fit=crop&w=1800&q=80") center 55% / cover;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin-top: 8px;
  font-size: clamp(32px, 5vw, 64px);
  line-height: 0.96;
  letter-spacing: 0;
  max-width: 780px;
}

h2 {
  font-size: 22px;
}

main {
  padding: 22px clamp(14px, 3vw, 42px) 42px;
}

.eyebrow {
  color: inherit;
  opacity: 0.72;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.status-pill {
  border: 1px solid rgba(255, 255, 255, 0.45);
  padding: 10px 12px;
  border-radius: 999px;
  white-space: nowrap;
  background: rgba(0, 0, 0, 0.2);
}

.control-band {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

label span {
  display: block;
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
}

select,
input,
button {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  font: inherit;
  padding: 0 12px;
}

button {
  width: auto;
  cursor: pointer;
  font-weight: 800;
  color: white;
  background: var(--blue);
  border-color: var(--blue);
}

.panel,
.source-band {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel {
  padding: 18px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.up {
  color: var(--green);
}

.down {
  color: var(--red);
}

.flat {
  color: var(--muted);
}

.table-panel {
  margin-top: 14px;
}

.table-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

#searchBox {
  max-width: 230px;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

.compare-col {
  position: sticky;
  left: 0;
  background: white;
  text-align: center;
  width: 44px;
}

.compare-col input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.compare-col input[type="checkbox"]:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

th:nth-child(2),
td:nth-child(2) {
  text-align: left;
  position: sticky;
  left: 44px;
  background: white;
}

thead th {
  color: #42505d;
  background: #f0f4f7;
  font-size: 12px;
  text-transform: uppercase;
}

thead th.sortable {
  cursor: pointer;
  user-select: none;
}

thead th.sortable:hover {
  background: #e3eaf0;
  color: var(--ink);
}

thead th.sortable:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
  background: #e3eaf0;
  color: var(--ink);
}

tbody tr:hover td {
  background: #fff8e6;
}

.pending {
  color: var(--muted);
}

.source-band {
  margin-top: 14px;
  padding: 18px;
}

.source-band p {
  margin: 10px 0 14px;
  color: #394650;
  line-height: 1.55;
}

.source-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.source-links a {
  color: var(--blue);
  font-weight: 800;
}

.chart-panel {
  margin-top: 14px;
}

.chart-hint {
  margin: 10px 0 2px;
  color: var(--muted);
  font-size: 13px;
}

.chart-subtitle {
  margin: 2px 0 0;
  color: #394650;
  font-size: 13px;
  font-weight: 700;
}

.chart-wrap {
  position: relative;
  margin-top: 10px;
}

.chart-wrap:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.chart-wrap svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-grid {
  stroke: var(--line);
  stroke-width: 1;
}

.chart-axis-label {
  fill: var(--muted);
  font-size: 11px;
}

.chart-line {
  transition: stroke-width 0.1s ease;
}

.chart-endlabel {
  fill: var(--ink);
  font-size: 11px;
  font-weight: 700;
}

.chart-crosshair {
  stroke: var(--muted);
  stroke-width: 1;
}

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  transform: translate(-50%, -100%);
  background: #161a1d;
  color: #fff;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  z-index: 5;
}

.chart-tooltip .tt-month {
  font-weight: 800;
  margin-bottom: 4px;
  color: #fff;
}

.chart-tooltip .tt-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chart-tooltip .tt-key {
  width: 10px;
  height: 2px;
  display: inline-block;
  flex: 0 0 auto;
}

.chart-tooltip .tt-name {
  color: #c3c2b7;
}

.chart-tooltip .tt-value {
  font-weight: 800;
  margin-left: auto;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chart-legend-swatch {
  width: 16px;
  height: 2px;
  display: inline-block;
  border-radius: 1px;
}

.cross-search-panel {
  margin-top: 14px;
}

.cross-search-box {
  margin-top: 10px;
  max-width: 360px;
}

/* This table has no leading checkbox column, so it shouldn't inherit the
   main table's "column 2 is sticky brand name" treatment meant for that
   layout — Segment and Brand are just its first two left-aligned labels. */
.cross-search-panel th:first-child,
.cross-search-panel td:first-child,
.cross-search-panel th:nth-child(2),
.cross-search-panel td:nth-child(2) {
  text-align: left;
  position: static;
}

@media (max-width: 860px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .control-band {
    grid-template-columns: 1fr;
  }

  .panel-title {
    align-items: flex-start;
    flex-direction: column;
  }

  #searchBox,
  .cross-search-box,
  button {
    width: 100%;
  }
} /* FIX: Cleaned up trailing brackets from file wrapper error */

@media print {
  body * {
    visibility: hidden;
  }

  .table-panel,
  .table-panel * {
    visibility: visible;
  }

  .table-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    margin: 0;
    border: none;
  }

  .table-panel .table-controls,
  .compare-col {
    display: none;
  }

  /* With the checkbox column removed above, the brand column's sticky
     left:44px (sized for that now-absent column) would otherwise overlap
     the following data column instead of sitting flush at the left edge. */
  th:nth-child(2),
  td:nth-child(2) {
    position: static;
  }

  .table-wrap {
    overflow: visible;
    border: none;
  }

  table {
    min-width: 0;
  }

  th,
  td {
    white-space: normal;
  }
}