:root {
  color-scheme: light;
  --ink: #1f2933;
  --muted: #687884;
  --line: #dde8ee;
  --paper: #f8fbfd;
  --white: #ffffff;
  --blue-soft: #d9edf7;
  --blue-pale: #eef8fc;
  --blue: #74aeca;
  --blue-deep: #3d7f9f;
  --coral: #c96d5a;
  --gold: #d3a85c;
  --shadow: 0 16px 42px rgba(38, 91, 115, 0.08);
}

* {
  box-sizing: border-box;
}

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

body.locked {
  overflow: hidden;
}

.password-gate {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: var(--paper);
}

.password-gate.hidden {
  display: none;
}

.password-card {
  width: min(430px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.password-copy {
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
}

.password-label {
  display: block;
  margin-top: 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.password-card input {
  width: 100%;
  min-height: 44px;
  margin-top: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  font: inherit;
}

.password-card button {
  width: 100%;
  margin-top: 14px;
  background: var(--blue-deep);
  color: var(--white);
}

.password-error {
  min-height: 18px;
  margin-top: 8px;
  color: var(--coral);
  font-size: 12px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 4vw, 48px) 18px;
  border-bottom: 1px solid var(--line);
  background: var(--white);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue-deep);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 4vw, 44px);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

h2 .info-button {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin-left: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--blue-pale);
  color: var(--blue-deep);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  padding: 0;
  vertical-align: 2px;
}

h2 .info-button:hover {
  background: var(--blue-soft);
}

h2 .info-button::after {
  content: attr(data-tooltip);
  position: absolute;
  z-index: 20;
  left: 50%;
  bottom: calc(100% + 10px);
  width: min(280px, 72vw);
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  text-align: left;
  transform: translateX(-50%) translateY(4px);
  transition: opacity 140ms ease, transform 140ms ease;
  white-space: normal;
}

h2 .info-button:hover::after,
h2 .info-button:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

main {
  padding: 22px clamp(18px, 4vw, 48px) 48px;
}

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

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(4, minmax(58px, 1fr));
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--blue-pale);
}

.period-mode {
  grid-template-columns: repeat(2, minmax(92px, 1fr));
}

select,
button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  font: inherit;
}

select {
  min-width: 180px;
  padding: 0 36px 0 12px;
}

button {
  padding: 0 14px;
  cursor: pointer;
}

.segmented button {
  min-height: 38px;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0 12px;
}

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

.status-strip,
.kpi-grid,
.panel-grid,
.decision-grid {
  display: grid;
  gap: 14px;
}

.status-strip {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 14px;
}

.status-strip > div,
.metric-card,
.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.decision-grid {
  grid-template-columns: 1.05fr 1fr 1.25fr;
  margin-bottom: 14px;
}

.status-strip > div {
  padding: 14px 16px;
}

.status-strip span,
.metric-card span,
.panel-head span,
.trend {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric-description {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.status-strip strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
}

.kpi-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin-bottom: 14px;
}

.metric-card {
  min-height: 132px;
  padding: 16px;
}

.metric-card strong {
  display: block;
  margin: 10px 0 8px;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1;
}

.trend.positive {
  color: var(--blue-deep);
}

.trend.negative {
  color: var(--coral);
}

.health-panel {
  background: var(--white);
}

.health-score {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 14px;
}

.health-score strong {
  font-size: 58px;
  line-height: 1;
}

.health-score span {
  color: var(--muted);
  font-size: 16px;
}

.driver-list,
.forecast-list,
.alert-list,
.target-list,
.signal-list,
.ownership-list {
  display: grid;
  gap: 10px;
}

.driver-row,
.forecast-row,
.target-row,
.signal-row {
  display: grid;
  gap: 7px;
}

.driver-label,
.forecast-row,
.target-label,
.signal-row,
.alert-item {
  font-size: 13px;
}

.driver-label,
.target-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.driver-track,
.target-track {
  height: 9px;
  border-radius: 999px;
  background: var(--blue-pale);
  overflow: hidden;
}

.driver-fill,
.target-fill {
  height: 100%;
  width: var(--value);
  background: var(--blue);
}

.target-fill.warning,
.driver-fill.warning {
  background: var(--gold);
}

.target-fill.danger,
.driver-fill.danger {
  background: var(--coral);
}

.forecast-row {
  grid-template-columns: 1fr auto;
  align-items: baseline;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}

.forecast-row span,
.signal-row span {
  color: var(--muted);
}

.forecast-row strong,
.signal-row strong {
  font-size: 18px;
}

.alert-item {
  border-left: 4px solid var(--gold);
  background: #fffaf0;
  border-radius: 6px;
  padding: 10px 11px;
}

.alert-item.danger {
  border-left-color: var(--coral);
  background: #fff4f1;
}

.alert-item.good {
  border-left-color: var(--blue);
  background: var(--blue-pale);
}

.signal-row {
  grid-template-columns: 1fr auto;
  align-items: baseline;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}

.ownership-row {
  display: grid;
  grid-template-columns: 120px 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.ownership-year {
  font-weight: 750;
}

.ownership-track {
  height: 11px;
  border-radius: 999px;
  background: var(--blue-pale);
  overflow: hidden;
}

.ownership-fill {
  width: var(--value);
  height: 100%;
  background: var(--blue);
}

.ownership-fill.current {
  background: var(--blue-deep);
}

.ownership-value {
  font-weight: 750;
  text-align: right;
}

.ownership-change {
  color: var(--muted);
  text-align: right;
  min-width: 74px;
}

.ownership-change.positive {
  color: var(--blue-deep);
}

.ownership-change.negative {
  color: var(--coral);
}

.panel-grid {
  grid-template-columns: 2fr 1fr 1fr;
  margin-bottom: 14px;
}

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

.panel-wide {
  grid-column: span 2;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 14px;
}

.chart {
  min-height: 310px;
}

.chart svg {
  width: 100%;
  height: 310px;
  display: block;
}

.axis-label {
  fill: var(--muted);
  font-size: 11px;
}

.bar-list,
.future-list {
  display: grid;
  gap: 12px;
}

.bar-item {
  display: grid;
  gap: 7px;
}

.bar-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.bar-track {
  height: 11px;
  border-radius: 999px;
  background: var(--blue-pale);
  overflow: hidden;
}

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

.bar-fill.retail {
  background: var(--blue-deep);
}

.bar-fill.danger {
  background: var(--coral);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

th .sort-button {
  min-height: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: inherit;
  font-weight: inherit;
  padding: 0;
  text-align: inherit;
  width: 100%;
}

th .sort-button.active {
  color: var(--ink);
}

th .sort-button.active::after {
  content: " " attr(data-sort-direction);
  color: var(--blue-deep);
}

.future-row {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.future-track {
  height: 8px;
  border-radius: 999px;
  background: var(--blue-pale);
  overflow: hidden;
}

.future-fill {
  height: 100%;
  width: var(--value);
  background: var(--blue);
}

@media (max-width: 1120px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .panel-grid,
  .decision-grid {
    grid-template-columns: 1fr;
  }

  .panel-wide {
    grid-column: auto;
  }
}

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

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

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

  .segmented {
    width: 100%;
  }

  .ownership-row {
    grid-template-columns: 1fr auto;
  }

  .ownership-track,
  .ownership-change {
    grid-column: span 2;
  }
}
