:root {
  color-scheme: light;
  --paper: #f4f0e8;
  --paper-deep: #e9e2d6;
  --ink: #18212a;
  --muted: #697078;
  --line: #cfc7bb;
  --navy: #173f5f;
  --red: #d52b1e;
  --amber: #a6651a;
  --amber-soft: #f1dfbe;
  --green: #2f6e5b;
  --white: #fffdf8;
  font-family: "Helvetica Neue", "Avenir Next", Avenir, Arial, sans-serif;
}

* { box-sizing: border-box; }

html {
  background: var(--paper);
  color: var(--ink);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(90deg, rgb(24 33 42 / 3%) 1px, transparent 1px) 0 0 / 80px 80px,
    var(--paper);
}

button, input, select { font: inherit; }
button { color: inherit; }

button:focus-visible,
svg:focus-visible,
a:focus-visible {
  outline: 3px solid #6f91a9;
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 20;
  padding: 10px 14px;
  color: white;
  background: var(--ink);
  transform: translateY(-160%);
}
.skip-link:focus { transform: translateY(0); }

.topbar {
  min-height: 74px;
  padding: 0 clamp(20px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgb(244 240 232 / 94%);
  backdrop-filter: blur(16px);
}

.brand,
.topbar-status,
.command-actions,
.period-switch,
.chart-key {
  display: flex;
  align-items: center;
}

.brand { gap: 14px; }

.cross {
  position: relative;
  width: 27px;
  height: 27px;
  flex: none;
}

.cross::before,
.cross::after {
  content: "";
  position: absolute;
  background: var(--red);
}
.cross::before { width: 9px; height: 27px; left: 9px; }
.cross::after { width: 27px; height: 9px; top: 9px; }

.brand-copy { display: grid; line-height: 1.1; }
.brand-copy strong { font-size: 18px; letter-spacing: -0.02em; }
.brand-copy small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-status {
  gap: 9px;
  color: var(--muted);
  font-size: 13px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 4px var(--amber-soft);
}
.status-dot.live {
  background: var(--green);
  box-shadow: 0 0 0 4px rgb(47 110 91 / 15%);
}
.status-dot.error {
  background: var(--red);
  box-shadow: 0 0 0 4px rgb(213 43 30 / 14%);
}

.text-button,
.copy-button {
  border: 0;
  background: none;
  cursor: pointer;
}

.text-button {
  margin-left: 8px;
  padding: 8px 0 8px 12px;
  border-left: 1px solid var(--line);
  color: var(--ink);
}

main {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 64px) 38px;
}

.command-band {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}

.aasc-filter-band {
  min-height: 88px;
  padding: 14px 0;
  display: grid;
  grid-template-columns: minmax(190px, 0.75fr) minmax(0, 1.8fr) minmax(180px, 0.65fr);
  align-items: center;
  gap: clamp(18px, 3vw, 44px);
  border-bottom: 1px solid var(--line);
}

.aasc-filter-copy {
  display: grid;
  gap: 5px;
}
.aasc-filter-copy .control-label { margin-right: 0; }
.aasc-filter-copy small,
.aasc-filter-note {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}
.aasc-filter-note { margin: 0; text-align: right; }

.aasc-toggle-group {
  display: grid;
  grid-template-columns: repeat(4, minmax(96px, 1fr));
  gap: 7px;
}

.aasc-toggle {
  --aasc-color: var(--navy);
  min-height: 52px;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: rgb(255 253 248 / 42%);
  cursor: pointer;
  opacity: 0.64;
  transition: border-color 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}
.aasc-toggle.aasc-crf { --aasc-color: #d52b1e; }
.aasc-toggle.aasc-pcps { --aasc-color: #e87524; }
.aasc-toggle.aasc-ffss { --aasc-color: #1b5ea7; }
.aasc-toggle.aasc-malte { --aasc-color: #6f2346; }
.aasc-toggle[aria-pressed="true"] {
  border-color: var(--aasc-color);
  color: var(--ink);
  background: var(--white);
  box-shadow: inset 0 -3px var(--aasc-color);
  opacity: 1;
}
.aasc-toggle:hover { opacity: 1; }
.aasc-logo {
  width: 42px;
  height: 28px;
  display: grid;
  place-items: center;
  flex: none;
}
.aasc-logo img { width: 100%; height: 100%; object-fit: contain; }
.aasc-toggle span:last-child { font-size: 12px; font-weight: 700; }

.period-switch { gap: 4px; }
.control-label {
  margin-right: 12px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.period-switch button,
.metric-tabs button {
  min-height: 36px;
  padding: 7px 12px;
  border: 0;
  border-radius: 4px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.period-switch button.active,
.metric-tabs button[aria-selected="true"] {
  color: var(--white);
  background: var(--navy);
}

.command-actions { gap: 14px; }
.active-filter { color: var(--muted); font-size: 13px; }
.copy-button {
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgb(255 253 248 / 45%);
}

.load-state {
  margin-top: 32px;
  padding: 18px 0;
  color: var(--muted);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.load-state.error { color: #8f2018; }

.situation-header {
  min-height: 176px;
  padding: 40px 0 32px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 40px;
  animation: rise-in 420ms ease both;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--red);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 10px;
  font-size: clamp(36px, 5vw, 64px);
  font-weight: 560;
  letter-spacing: -0.045em;
  line-height: 0.98;
}
h2 {
  margin-bottom: 0;
  font-size: clamp(22px, 2vw, 29px);
  font-weight: 560;
  letter-spacing: -0.03em;
}

.situation-note {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.freshness-block {
  min-width: 220px;
  padding-left: 22px;
  display: grid;
  gap: 5px;
  border-left: 1px solid var(--line);
}

.freshness-label,
.kpi-strip span,
.kpi-strip small { color: var(--muted); }
.freshness-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.freshness-block strong { font-size: 24px; font-weight: 570; }
.freshness-block span:last-child { color: var(--muted); font-size: 12px; }

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--line);
  animation: rise-in 420ms 80ms ease both;
}

.kpi-strip article {
  min-height: 148px;
  padding: 22px clamp(16px, 2vw, 28px) 20px 0;
  display: grid;
  align-content: space-between;
  border-right: 1px solid var(--line);
}
.kpi-strip article:not(:first-child) { padding-left: clamp(16px, 2vw, 28px); }
.kpi-strip article:last-child { border-right: 0; }
.kpi-strip span { font-size: 13px; }
.kpi-strip strong {
  font-size: clamp(38px, 4.5vw, 58px);
  font-weight: 530;
  letter-spacing: -0.05em;
  line-height: 1;
}
.kpi-strip small { font-size: 12px; }

.workspace-grid {
  display: block;
  border-bottom: 1px solid var(--line);
  animation: rise-in 420ms 140ms ease both;
}

.activity-panel {
  min-width: 0;
  padding: 36px 0 34px;
}
.health-rail {
  padding: 38px 0;
  border-bottom: 1px solid var(--line);
}

.health-layout {
  margin-top: 28px;
  display: grid;
  grid-template-columns: minmax(240px, 0.72fr) minmax(0, 1.8fr);
  gap: clamp(34px, 6vw, 86px);
}

.health-overview {
  padding-right: clamp(0px, 2vw, 24px);
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}
.section-heading > p {
  max-width: 400px;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}
.section-heading.compact { align-items: flex-start; }

.metric-tabs {
  display: flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.metric-tabs button { min-height: 32px; padding: 5px 10px; font-size: 12px; }

.chart-wrap {
  min-height: 380px;
  margin-top: 22px;
  display: grid;
  place-items: center;
}

#activity-chart {
  width: 100%;
  overflow: visible;
  touch-action: pan-y;
}
#activity-chart text {
  fill: var(--muted);
  font-family: inherit;
  font-size: 11px;
}
#activity-chart .grid-line {
  stroke: var(--line);
  stroke-width: 1;
  stroke-dasharray: 2 5;
}
#activity-chart .activity-line {
  fill: none;
  stroke: var(--navy);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  animation: draw-line 700ms ease both;
}
#activity-chart .activity-line.series-crf { stroke: #d52b1e; }
#activity-chart .activity-line.series-pcps { stroke: #e87524; }
#activity-chart .activity-line.series-ffss { stroke: #1b5ea7; }
#activity-chart .activity-line.series-malte { stroke: #6f2346; }
#activity-chart .activity-line.series-crf-previous {
  stroke: #85857f;
  stroke-width: 2.25;
  stroke-dasharray: 7 6;
}
#activity-chart .activity-point {
  fill: var(--paper);
  stroke: var(--navy);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}
#activity-chart .activity-point.series-crf { stroke: #d52b1e; }
#activity-chart .activity-point.series-pcps { stroke: #e87524; }
#activity-chart .activity-point.series-ffss { stroke: #1b5ea7; }
#activity-chart .activity-point.series-malte { stroke: #6f2346; }
#activity-chart .activity-point.series-crf-previous {
  fill: var(--paper);
  stroke: #85857f;
}
#activity-chart .activity-point.selected {
  fill: var(--white);
  stroke: var(--paper);
  stroke-width: 3;
}
#activity-chart .activity-point.selected.series-crf { fill: #d52b1e; }
#activity-chart .activity-point.selected.series-pcps { fill: #e87524; }
#activity-chart .activity-point.selected.series-ffss { fill: #1b5ea7; }
#activity-chart .activity-point.selected.series-malte { fill: #6f2346; }
#activity-chart .activity-point.selected.series-crf-previous { fill: #85857f; }
#activity-chart .series-label {
  font-size: 12px;
  font-weight: 750;
  paint-order: stroke;
  stroke: var(--paper);
  stroke-width: 4px;
  stroke-linejoin: round;
}
#activity-chart .series-label.series-crf { fill: #b82017; }
#activity-chart .series-label.series-pcps { fill: #a85112; }
#activity-chart .series-label.series-ffss { fill: #174f8b; }
#activity-chart .series-label.series-malte { fill: #6f2346; }
#activity-chart .series-label.series-crf-previous { fill: #686864; }
#activity-chart .series-leader {
  fill: none;
  stroke-width: 1;
  opacity: 0.55;
  vector-effect: non-scaling-stroke;
}
#activity-chart .series-leader.series-crf { stroke: #d52b1e; }
#activity-chart .series-leader.series-pcps { stroke: #e87524; }
#activity-chart .series-leader.series-ffss { stroke: #1b5ea7; }
#activity-chart .series-leader.series-malte { stroke: #6f2346; }
#activity-chart .series-leader.series-crf-previous {
  stroke: #85857f;
  stroke-dasharray: 3 3;
}
#activity-chart .selection-line {
  stroke: var(--red);
  stroke-width: 1.5;
  stroke-dasharray: 4 5;
}
#activity-chart .coverage-loaded { fill: var(--green); }
#activity-chart .coverage-missing { fill: var(--amber); }
#activity-chart .coverage-empty { fill: var(--line); }

.chart-key {
  flex-wrap: wrap;
  gap: 18px;
  color: var(--muted);
  font-size: 11px;
}
.chart-key span { display: inline-flex; align-items: center; gap: 6px; }
.chart-key i { width: 13px; height: 5px; border-radius: 2px; }
.key-loaded { background: var(--green); }
.key-missing { background: var(--amber); }
.key-empty { background: var(--line); }

.selection-readout {
  min-height: 42px;
  margin-top: 18px;
  padding-top: 14px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.selection-readout strong { font-size: 18px; }
.selection-series {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px 18px;
}
.selection-series span { min-width: 76px; text-align: right; }
.selection-series small { display: block; color: var(--muted); font-size: 10px; }
.selection-series .historical-value strong,
.selection-series .historical-value small { color: #686864; }

.health-score {
  display: grid;
  place-items: center;
  min-width: 50px;
  height: 50px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--navy);
  font-size: 12px;
  font-weight: 700;
}

.health-summary {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}
.quality-scope {
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.quality-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line);
}
.quality-item {
  min-height: 61px;
  padding: 12px 0;
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}
.quality-item:nth-child(odd) {
  padding-right: 22px;
  border-right: 1px solid var(--line);
}
.quality-item:nth-child(even) {
  padding-left: 22px;
}
.quality-mark {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
}
.quality-mark.warn { background: var(--amber); }
.quality-mark.fail { background: var(--red); }
.quality-item strong { display: block; font-size: 13px; font-weight: 570; }
.quality-item small,
.quality-item > span:last-child { color: var(--muted); font-size: 11px; }

.caveat {
  margin-top: 28px;
  padding-left: 14px;
  border-left: 3px solid var(--amber);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.operations-band,
.daily-section {
  padding: 38px 0;
  border-bottom: 1px solid var(--line);
}
.operations-grid {
  margin-top: 30px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(36px, 7vw, 110px);
}
.delay-group,
.completeness-group { display: grid; gap: 19px; }
.measure-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(120px, 2fr) auto;
  align-items: center;
  gap: 14px;
}
.measure-row span { color: var(--muted); font-size: 12px; }
.measure-row strong { min-width: 54px; text-align: right; font-size: 13px; }
.measure-track {
  width: 100%;
  height: 7px;
  overflow: hidden;
  appearance: none;
  border: 0;
  border-radius: 4px;
  background: var(--paper-deep);
}
.measure-track::-webkit-progress-bar {
  border-radius: 4px;
  background: var(--paper-deep);
}
.measure-track::-webkit-progress-value {
  border-radius: 4px;
  background: var(--navy);
}
.measure-track::-moz-progress-bar {
  border-radius: 4px;
  background: var(--navy);
}
.completeness-group .measure-track::-webkit-progress-value { background: var(--green); }
.completeness-group .measure-track::-moz-progress-bar { background: var(--green); }

.table-scroll { margin-top: 26px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
  padding: 14px 12px;
  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) { text-align: left; }
th {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
tbody tr:hover,
tbody tr:focus-within { background: rgb(255 253 248 / 55%); }
.coverage-label { display: inline-flex; align-items: center; gap: 7px; }
.coverage-label::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
}
.coverage-label.missing::before { background: var(--amber); }
.muted-value { color: var(--muted); }

.source-note {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: var(--muted);
  font-size: 11px;
}

.is-embedded body {
  background: var(--paper);
}

.is-embedded .topbar {
  min-height: 64px;
  padding-inline: clamp(16px, 3vw, 40px);
}

.is-embedded main {
  padding: 0 clamp(16px, 3vw, 40px) 20px;
}

.is-embedded .copy-button {
  display: none;
}

.is-embedded .situation-header {
  min-height: 150px;
  padding-top: 30px;
}

.is-embedded .source-note {
  min-height: 48px;
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(9px); }
}
@keyframes draw-line {
  from { stroke-dasharray: 1400; stroke-dashoffset: 1400; }
  to { stroke-dasharray: 1400; stroke-dashoffset: 0; }
}
@media (max-width: 980px) {
  .aasc-filter-band { grid-template-columns: 1fr; gap: 10px; }
  .aasc-filter-note { text-align: left; }
  .health-layout { grid-template-columns: 1fr; }
  .operations-grid { gap: 36px; }
}

@media (max-width: 720px) {
  .topbar { min-height: 68px; padding-inline: 18px; }
  .brand-copy small,
  .topbar-status > span:not(.status-dot),
  .active-filter { display: none; }
  .topbar-status { gap: 6px; }
  .text-button { margin-left: 0; }
  main { padding-inline: 18px; }
  .command-band { min-height: 58px; }
  .aasc-filter-band { padding-block: 14px 16px; }
  .aasc-toggle-group {
    grid-template-columns: repeat(4, minmax(82px, 1fr));
    overflow-x: auto;
  }
  .aasc-toggle { min-height: 58px; padding-inline: 7px; flex-direction: column; gap: 3px; }
  .aasc-logo { width: 44px; height: 26px; }
  .control-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  .period-switch button { min-height: 40px; padding-inline: 10px; font-size: 12px; }
  .copy-button {
    width: 40px;
    overflow: hidden;
    color: transparent;
    position: relative;
  }
  .copy-button::after {
    content: "↗";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--ink);
    font-size: 17px;
  }
  .situation-header {
    min-height: 0;
    padding-top: 30px;
    align-items: flex-start;
    flex-direction: column;
    gap: 22px;
  }
  .freshness-block {
    width: 100%;
    padding: 12px 0 0;
    grid-template-columns: 1fr auto;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
  .freshness-block span:last-child { grid-column: 1 / -1; }
  .kpi-strip { grid-template-columns: 1fr 1fr; }
  .kpi-strip article { min-height: 126px; padding: 18px 14px 16px 0; }
  .kpi-strip article:nth-child(2) { border-right: 0; }
  .kpi-strip article:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .kpi-strip article:nth-child(3) { padding-left: 0; }
  .kpi-strip article:nth-child(4) { padding-left: 14px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .section-heading > p { text-align: left; }
  .metric-tabs { width: 100%; }
  .metric-tabs button { flex: 1; min-height: 40px; }
  .chart-wrap {
    min-height: 270px;
    margin-top: 12px;
    justify-content: start;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
  }
  #activity-chart { min-width: 610px; }
  .selection-readout { flex-direction: column; gap: 10px; }
  .selection-series { justify-content: flex-start; }
  .selection-series span { text-align: left; }
  .operations-grid { grid-template-columns: 1fr; }
  .quality-list { grid-template-columns: 1fr; }
  .quality-item:nth-child(odd),
  .quality-item:nth-child(even) {
    padding-right: 0;
    padding-left: 0;
    border-right: 0;
  }
  .measure-row { grid-template-columns: 125px 1fr auto; }
  .source-note {
    padding: 16px 0;
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
