:root {
  --page: #f5f7fb;
  --page-top: #ffffff;
  --ink: #151827;
  --muted: #6b7280;
  --panel: #ffffff;
  --line: #e3e7ef;
  --field: #ffffff;
  --subtle: #f8fafc;
  --soft-panel: #fbfcff;
  --chart: #ffffff;
  --chart-wash: rgba(234, 242, 251, 0.46);
  --grid-line: #e7ecf4;
  --grid-label: #7b8494;
  --legend: #4b5563;
  --brand-blue-rgb: 0, 80, 179;
  --brand-blue-dark-rgb: 0, 53, 128;
  --brand-blue: #0050b3;
  --brand-blue-dark: #003580;
  --brand-blue-soft: #eaf3ff;
  --brand-red: #ea0101;
  --brand-gray: #9d9d9b;
  --green: #15803d;
  --red: #b91c1c;
  --amber: #b45309;
  --shadow: 0 10px 28px rgba(0, 80, 179, 0.08);
}

:root[data-theme="dark"] {
  --page: #071427;
  --page-top: #0b1f3d;
  --ink: #f8fafc;
  --muted: #9fb0c7;
  --panel: #0f213d;
  --line: rgba(148, 163, 184, 0.22);
  --field: #0a1830;
  --subtle: #0a1830;
  --soft-panel: #102744;
  --chart: #0b1b33;
  --chart-wash: rgba(0, 80, 179, 0.16);
  --grid-line: rgba(148, 163, 184, 0.18);
  --grid-label: #9fb0c7;
  --legend: #c5d2e5;
  --brand-blue-soft: rgba(0, 80, 179, 0.18);
  --green: #4ade80;
  --red: #f87171;
  --amber: #fbbf24;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.26);
}

:root[data-theme="dark"] .secondary-button,
:root[data-theme="dark"] button:not(.primary):not(.theme-toggle),
:root[data-theme="dark"] select,
:root[data-theme="dark"] input {
  color: var(--ink);
}

:root[data-theme="dark"] button:not(.primary):not(.theme-toggle):not(.active) {
  color: var(--brand-blue);
}

:root[data-theme="dark"] .ghost-button {
  color: #ffffff;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--page);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: "Space Grotesk", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  min-width: 320px;
}

a {
  color: inherit;
  text-decoration: none;
}

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

h1,
h2,
.metric strong,
.mini-metric strong {
  font-family: "Plus Jakarta Sans", "Space Grotesk", sans-serif;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 68px;
  padding: 14px clamp(16px, 3vw, 40px);
  background: rgba(0, 30, 90, 0.88);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 14px 34px rgba(0, 13, 42, 0.18);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  min-width: 116px;
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.brand img {
  display: block;
  width: 112px;
  height: auto;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.34));
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 18px;
  overflow-x: auto;
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.76);
  font-size: 14px;
  font-weight: 800;
}

.header-nav a {
  padding: 8px 0;
  border-radius: 8px;
  transition: color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.header-nav a:hover {
  color: #ffffff;
}

.header-nav a.active {
  padding-inline: 12px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  box-shadow: inset 0 -2px 0 var(--brand-red);
}

.theme-toggle {
  position: relative;
  flex: 0 0 auto;
  width: 54px;
  min-height: 30px;
  padding: 0;
  border-color: rgba(255, 255, 255, 0.26);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  box-shadow: none;
}

.theme-toggle::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.22);
  transition: transform 160ms ease;
}

.theme-toggle[aria-pressed="true"]::before {
  transform: translateX(24px);
}

.theme-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
  font-size: 10px;
  line-height: 1;
}

.theme-icon.sun {
  left: 9px;
  color: var(--brand-blue-dark);
}

.theme-icon.moon {
  right: 10px;
  color: rgba(255, 255, 255, 0.78);
}

.theme-toggle[aria-pressed="true"] .theme-icon.sun {
  color: rgba(255, 255, 255, 0.66);
}

.theme-toggle[aria-pressed="true"] .theme-icon.moon {
  color: var(--brand-blue-dark);
}

main {
  display: grid;
  gap: 16px;
  max-width: 1360px;
  margin: 0 auto;
  padding: 18px clamp(16px, 3vw, 40px) 44px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: clamp(20px, 3vw, 32px);
  border-radius: 8px;
  color: #ffffff;
  background:
    linear-gradient(135deg, rgba(0, 53, 128, 0.96), rgba(0, 80, 179, 0.94)),
    var(--brand-blue-dark);
  box-shadow: 0 22px 60px rgba(0, 80, 179, 0.22);
}

.hero-copy {
  max-width: 840px;
}

.eyebrow {
  margin-bottom: 8px;
  color: #dceafe;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  max-width: 900px;
  font-size: clamp(30px, 4vw, 52px);
  line-height: 1;
}

.hero-text {
  max-width: 760px;
  margin-top: 10px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 16px;
  line-height: 1.5;
}

.hero-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 260px;
}

.status {
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
  text-align: right;
}

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

button,
.ghost-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 13px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--brand-blue);
  font-weight: 800;
  cursor: pointer;
}

button.primary {
  min-width: 134px;
  background: #ffffff;
  border-color: #ffffff;
  color: var(--brand-blue-dark);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
}

.ghost-button {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.32);
  color: #ffffff;
}

.secondary-button {
  background: var(--brand-blue-soft);
  border-color: rgba(var(--brand-blue-rgb), 0.22);
}

button:disabled {
  cursor: wait;
  opacity: 0.64;
}

input,
select {
  width: 100%;
  padding: 0 12px;
}

button,
a,
input,
select {
  -webkit-tap-highlight-color: transparent;
}

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

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-areas:
    "current daily weekly"
    "reference net average";
  gap: 12px;
}

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

.metric {
  display: grid;
  align-content: space-between;
  gap: 8px;
  min-height: 116px;
  padding: 16px;
}

.metric-current {
  grid-area: current;
}

.metric-reference {
  grid-area: reference;
}

.metric-daily {
  grid-area: daily;
}

.metric-net {
  grid-area: net;
}

.metric-weekly {
  grid-area: weekly;
}

.metric-average {
  grid-area: average;
}

.metric span,
.metric small,
.panel-title p,
.mini-metric span,
.mini-metric small {
  color: var(--muted);
}

.metric span,
.mini-metric span {
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.metric strong {
  font-size: clamp(24px, 2.6vw, 38px);
  line-height: 1;
  overflow-wrap: anywhere;
}

.panel {
  padding: 16px;
}

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

.page-section[hidden] {
  display: none !important;
}

.mode-panel {
  box-shadow: none;
  background: transparent;
  border: 0;
  padding: 0;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(92px, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--subtle);
}

.segmented.two {
  grid-template-columns: repeat(2, minmax(118px, 1fr));
}

.segmented button {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

.segmented button.active {
  background: var(--field);
  color: var(--brand-blue);
  box-shadow: 0 6px 18px rgba(0, 80, 179, 0.1);
}

h2 {
  font-size: 20px;
}

.inline-form,
.comparison-form,
.campaign-form,
.marketing-form,
.manual-form {
  display: grid;
  gap: 10px;
}

.inline-form {
  grid-template-columns: repeat(2, minmax(160px, 1fr)) auto auto;
  align-items: end;
}

.comparison-form {
  grid-template-columns: repeat(4, minmax(150px, 1fr)) auto;
  align-items: end;
}

.campaign-form {
  grid-template-columns: 1.2fr repeat(2, 145px) 0.9fr 120px 1fr auto;
}

.marketing-panel {
  margin-top: 16px;
}

.marketing-form {
  grid-template-columns: 1.1fr repeat(2, minmax(140px, 0.8fr)) repeat(3, minmax(130px, 0.7fr)) auto;
  align-items: end;
}

.marketing-result {
  margin-top: 12px;
}

.econometric-note {
  grid-column: 1 / -1;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid rgba(var(--brand-blue-rgb), 0.18);
  border-radius: 8px;
  background: var(--brand-blue-soft);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

.manual-form {
  grid-template-columns: repeat(3, minmax(150px, 1fr)) auto;
  align-items: end;
}

.chart-panel {
  display: grid;
  gap: 12px;
}

.chart-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.chart-controls select {
  width: 132px;
}

.prediction-controls select {
  width: 174px;
}

.chart {
  width: 100%;
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, var(--chart-wash), rgba(255, 255, 255, 0) 150px),
    var(--chart);
  overflow: hidden;
  padding: 16px;
}

.tall-chart {
  min-height: 330px;
}

.chart-meta {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 10px;
}

.chart-meta > div:first-child {
  display: grid;
  gap: 3px;
}

.chart-meta strong {
  color: var(--ink);
  font-size: 16px;
  line-height: 1.2;
}

.chart-meta small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.chart-kpis {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.chart-kpis span {
  display: grid;
  gap: 2px;
  min-width: 96px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--field) 76%, transparent);
}

.chart-kpis strong {
  font-size: 18px;
}

.chart svg {
  display: block;
  width: 100%;
  height: 260px;
  border-radius: 8px;
}

.tall-chart svg {
  height: 330px;
}

.axis {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.campaign-label {
  fill: var(--brand-blue-dark);
  font-weight: 700;
}

.grid-line {
  stroke: var(--grid-line);
  stroke-width: 1;
}

.grid-label {
  fill: var(--grid-label);
}

.date-tick {
  fill: var(--muted);
  font-size: 11px;
  text-anchor: middle;
  dominant-baseline: central;
}

.date-tick-line {
  stroke: var(--grid-line);
  stroke-width: 1;
}

.zero-line {
  stroke: var(--brand-gray);
  stroke-dasharray: 4 5;
  stroke-width: 1.4;
}

.zero-label {
  fill: var(--brand-gray);
}

.chart-value-tag rect {
  fill: var(--brand-blue-dark);
  filter: drop-shadow(0 6px 10px rgba(var(--brand-blue-dark-rgb), 0.16));
}

.chart-value-tag text {
  fill: #ffffff;
  font-size: 13px;
  font-weight: 800;
  text-anchor: middle;
}

.chart-hit-area,
.chart-hit-band {
  fill: transparent;
  pointer-events: all;
}

.chart-hover-dot,
.chart-hover-line,
.chart-tooltip {
  opacity: 0;
  transition: opacity 120ms ease;
  pointer-events: none;
}

.chart-hover-dot {
  fill: #ffffff;
  stroke: var(--hover-color, var(--brand-blue));
  stroke-width: 3;
}

.chart-hover-line {
  stroke: var(--brand-gray);
  stroke-dasharray: 4 5;
  stroke-width: 1.2;
}

.chart-tooltip rect {
  fill: var(--brand-blue-dark);
  filter: drop-shadow(0 9px 16px rgba(var(--brand-blue-dark-rgb), 0.18));
}

.chart-tooltip-text {
  fill: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.chart-tooltip-text.label {
  opacity: 0.76;
}

.chart-tooltip-text.value {
  font-size: 13px;
}

.chart-hover-point:hover .chart-hover-dot,
.chart-hover-point:hover .chart-tooltip,
.chart-hover-band:hover .chart-hover-line,
.chart-hover-band:hover .chart-tooltip {
  opacity: 1;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 10px;
  color: var(--legend);
  font-size: 12px;
  font-weight: 700;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.chart-legend i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--legend-color);
  box-shadow: 0 0 0 3px rgba(var(--brand-blue-rgb), 0.08);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

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

.prediction-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.prediction-details {
  margin-top: 12px;
}

.prediction-diagnostics-panel {
  margin-top: 12px;
}

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

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

.small-table {
  max-height: 340px;
}

.mini-metric {
  display: grid;
  gap: 8px;
  min-height: 112px;
  padding: 16px;
  box-shadow: none;
}

.mini-metric strong {
  font-size: 26px;
  line-height: 1;
}

.prediction-summary {
  grid-column: 1 / -1;
  min-height: auto;
}

.prediction-summary strong {
  max-width: 980px;
  font-size: clamp(18px, 1.55vw, 24px);
  line-height: 1.35;
}

.scenario-warning {
  grid-column: 1 / -1;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid rgba(180, 83, 9, 0.24);
  border-radius: 8px;
  background: rgba(180, 83, 9, 0.1);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

.expert-details {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.expert-details summary {
  cursor: pointer;
  padding: 14px 16px;
  color: var(--brand-blue);
  font-weight: 900;
}

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

.expert-grid div {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--subtle);
}

.expert-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.expert-grid strong {
  font-size: 14px;
  line-height: 1.35;
}

.table-wrap {
  max-height: min(520px, 62vh);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--panel);
}

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

th:first-child,
td:first-child {
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--subtle);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

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

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

.neutral {
  color: var(--muted);
}

.campaign-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.campaign-item {
  display: grid;
  grid-template-columns: 1.2fr 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft-panel);
}

.campaign-item strong {
  display: flex;
  align-items: center;
  gap: 8px;
}

.campaign-item small {
  color: var(--muted);
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--brand-blue-soft);
  color: var(--brand-blue);
  font-size: 12px;
  font-weight: 800;
}

.pill.error {
  background: rgba(234, 1, 1, 0.14);
  color: var(--red);
}

.pill.manual {
  background: rgba(180, 83, 9, 0.14);
  color: var(--amber);
}

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

.muted-panel {
  background: var(--subtle);
  box-shadow: none;
}

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

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

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

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

  .hero {
    grid-template-columns: 1fr;
  }

  .hero-actions {
    justify-content: flex-start;
    min-width: 0;
  }

  .comparison-form,
  .campaign-form,
  .marketing-form,
  .manual-form,
  .inline-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .site-header,
  .split,
  .panel-title {
    align-items: flex-start;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .hero-actions {
    justify-items: start;
  }

  .status {
    text-align: left;
  }

  .chart-meta {
    display: grid;
  }

  .chart-kpis {
    justify-content: flex-start;
  }

  .chart-controls {
    justify-content: flex-start;
  }

  .header-nav {
    width: 100%;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "current reference"
      "daily net"
      "weekly average";
  }

  .prediction-grid,
  .diagnostic-grid,
  .compact-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  body {
    font-size: 14px;
  }

  .site-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-height: 0;
    padding: 10px 12px 9px;
    background: rgba(0, 30, 90, 0.94);
  }

  .brand {
    min-width: 0;
  }

  .brand img {
    width: 94px;
  }

  .theme-toggle {
    justify-self: end;
    width: 52px;
    min-height: 30px;
  }

  .header-nav {
    grid-column: 1 / -1;
    width: calc(100% + 24px);
    margin-inline: -12px;
    padding: 2px 12px 3px;
    gap: 7px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
    font-size: 13px;
  }

  .header-nav::-webkit-scrollbar {
    display: none;
  }

  .header-nav a {
    flex: 0 0 auto;
    min-height: 34px;
    padding: 8px 11px;
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    scroll-snap-align: start;
  }

  .header-nav a.active {
    padding-inline: 12px;
    background: #ffffff;
    color: var(--brand-blue-dark);
    box-shadow: none;
  }

  main {
    gap: 12px;
    padding: 12px 10px 28px;
  }

  .comparison-grid,
  .prediction-grid,
  .diagnostic-grid,
  .compact-grid,
  .comparison-form,
  .campaign-form,
  .marketing-form,
  .manual-form,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .expert-grid {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "current current"
      "reference daily"
      "net weekly"
      "average average";
    gap: 10px;
  }

  h1 {
    font-size: 30px;
    line-height: 1.04;
  }

  .hero {
    gap: 14px;
    padding: 18px 15px;
    box-shadow: 0 16px 34px rgba(0, 80, 179, 0.18);
  }

  .eyebrow {
    margin-bottom: 7px;
    font-size: 11px;
  }

  .hero-text {
    margin-top: 9px;
    font-size: 14px;
    line-height: 1.45;
  }

  .hero-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 8px;
  }

  .hero-actions .status {
    grid-column: 1 / -1;
    padding-top: 2px;
    font-size: 12px;
  }

  .hero-actions button,
  .hero-actions .ghost-button {
    width: 100%;
    min-width: 0;
  }

  button,
  .ghost-button,
  .secondary-button,
  input,
  select {
    min-height: 44px;
  }

  input,
  select {
    font-size: 16px;
  }

  .panel {
    padding: 14px;
  }

  .panel-title {
    gap: 8px;
    margin-bottom: 12px;
  }

  .panel-title h2,
  h2 {
    font-size: 18px;
    line-height: 1.2;
  }

  .panel-title p {
    margin-top: 3px;
    font-size: 13px;
    line-height: 1.4;
  }

  .metric {
    min-height: 96px;
    padding: 13px;
    gap: 7px;
  }

  .metric span,
  .mini-metric span {
    font-size: 10px;
    line-height: 1.25;
  }

  .metric strong {
    font-size: 25px;
  }

  .metric-current strong {
    font-size: 34px;
  }

  .metric small,
  .mini-metric small {
    font-size: 12px;
    line-height: 1.32;
  }

  .segmented {
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .segmented button {
    min-height: 38px;
    padding-inline: 8px;
    font-size: 13px;
  }

  .chart-controls,
  .chart-controls select {
    width: 100%;
  }

  .chart-controls {
    gap: 8px;
  }

  .chart {
    min-height: 0;
    padding: 12px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
  }

  .chart-meta {
    gap: 10px;
    min-width: 720px;
  }

  .chart-meta strong {
    font-size: 15px;
  }

  .chart-kpis {
    display: grid;
    grid-template-columns: repeat(3, minmax(88px, 1fr));
    gap: 6px;
  }

  .chart-kpis span {
    min-width: 0;
    padding: 7px 8px;
  }

  .chart-kpis strong {
    font-size: 15px;
  }

  .chart svg {
    min-width: 720px;
    height: 250px;
  }

  .tall-chart svg {
    height: 310px;
  }

  .chart-legend {
    min-width: 720px;
    gap: 8px 12px;
    font-size: 11px;
  }

  .mini-metric {
    min-height: 94px;
    padding: 13px;
  }

  .mini-metric strong {
    font-size: 23px;
  }

  .campaign-item {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 9px;
  }

  .campaign-item button {
    width: 100%;
  }

  .table-wrap {
    max-height: 420px;
    margin-inline: -2px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 620px;
    font-size: 13px;
  }

  th,
  td {
    padding: 9px 8px;
  }

  th:first-child,
  td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--panel);
    box-shadow: 1px 0 0 var(--line);
  }

  th:first-child {
    z-index: 3;
    background: var(--subtle);
  }
}

@media (max-width: 380px) {
  .metric-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "current"
      "reference"
      "daily"
      "net"
      "weekly"
      "average";
  }

  .hero-actions {
    grid-template-columns: 1fr;
  }

  .hero-actions .status {
    grid-column: auto;
  }

  .chart-meta,
  .chart svg,
  .chart-legend {
    min-width: 660px;
  }
}

/* Responsive layout refinement: sizing and spacing only. */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

img,
svg,
canvas {
  max-width: 100%;
}

main,
.site-header,
.hero,
.panel,
.metric,
.mini-metric,
.chart,
.table-wrap,
.split > *,
.panel-title > *,
.chart-meta > *,
.chart-kpis > *,
label,
input,
select,
button,
.ghost-button,
.secondary-button {
  min-width: 0;
}

main {
  width: 100%;
  padding-inline: clamp(16px, 3vw, 32px);
  gap: clamp(16px, 2vw, 28px);
}

h1 {
  font-size: clamp(28px, 5vw, 44px);
}

h2 {
  font-size: clamp(20px, 2.4vw, 28px);
  line-height: 1.18;
}

button,
.ghost-button,
.secondary-button,
input,
select {
  max-width: 100%;
}

input,
select {
  min-width: 0;
  height: 44px;
}

.panel {
  padding: clamp(16px, 2vw, 28px);
}

.metric strong {
  font-size: clamp(24px, 5vw, 34px);
}

.metric-current strong {
  font-size: clamp(30px, 6vw, 40px);
}

.chart {
  display: grid;
  min-height: 0;
}

.chart svg {
  min-width: 0;
}

.chart-legend {
  min-width: 0;
  max-width: 100%;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

table {
  min-width: 560px;
}

@media (min-width: 1025px) {
  .site-header {
    padding-inline: clamp(20px, 3vw, 32px);
  }
}

@media (min-width: 768px) and (max-width: 1024px) {
  .site-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    min-height: 58px;
    padding: 10px 20px;
    gap: 12px;
  }

  .brand img {
    width: clamp(120px, 14vw, 140px);
  }

  .header-nav {
    gap: 10px;
    font-size: 13px;
  }

  .header-nav a {
    min-height: 40px;
    padding: 10px 8px;
  }

  .header-nav a.active {
    padding-inline: 10px;
  }

  .theme-toggle {
    width: 50px;
    min-height: 30px;
  }

  main {
    padding-block: 16px 34px;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 22px;
  }

  .hero-actions {
    justify-content: flex-start;
    min-width: 0;
  }

  .panel {
    padding: 20px;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "current reference"
      "daily net"
      "weekly average";
  }

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

  .inline-form,
  .comparison-form,
  .campaign-form,
  .marketing-form,
  .manual-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
  }

  .inline-form button,
  .inline-form .secondary-button,
  .comparison-form button,
  .campaign-form button,
  .marketing-form button,
  .manual-form button {
    width: 100%;
  }

  .chart {
    padding: 16px;
  }

  .chart svg {
    height: 320px;
  }

  .tall-chart svg {
    height: 370px;
  }

  .chart-meta {
    gap: 14px;
  }

  .chart-kpis span {
    min-width: 88px;
  }
}

@media (max-width: 767px) {
  body {
    font-size: 14px;
  }

  .site-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px 10px;
    min-height: 0;
    padding: 9px 16px 8px;
  }

  .brand img {
    width: clamp(92px, 27vw, 110px);
  }

  .theme-toggle {
    justify-self: end;
    width: 50px;
    min-height: 30px;
  }

  .header-nav {
    grid-column: 1 / -1;
    width: calc(100% + 32px);
    margin-inline: -16px;
    padding: 2px 16px 4px;
    gap: 7px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
    font-size: 13px;
  }

  .header-nav::-webkit-scrollbar {
    display: none;
  }

  .header-nav a {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 10px 12px;
    border-radius: 999px;
    scroll-snap-align: start;
  }

  .header-nav a.active {
    padding-inline: 13px;
  }

  main {
    gap: 16px;
    padding: 14px 16px 28px;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 16px;
  }

  .eyebrow {
    margin-bottom: 6px;
    font-size: 11px;
  }

  .hero-text {
    margin-top: 8px;
    font-size: 15px;
    line-height: 1.45;
  }

  .hero-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 8px;
  }

  .hero-actions button,
  .hero-actions .ghost-button {
    width: 100%;
    min-height: 44px;
  }

  .hero-actions .status {
    grid-column: 1 / -1;
    text-align: left;
    font-size: 12px;
  }

  .panel,
  .metric,
  .mini-metric {
    border-radius: 8px;
  }

  .panel {
    padding: 16px;
  }

  .panel-title {
    display: grid;
    gap: 10px;
    margin-bottom: 12px;
  }

  .panel-title p {
    margin-top: 4px;
    font-size: 13px;
    line-height: 1.45;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "current reference"
      "daily net"
      "weekly average";
    gap: 10px;
  }

  .metric {
    min-height: auto;
    padding: 14px;
    gap: 7px;
  }

  .metric span,
  .mini-metric span {
    font-size: 11px;
    line-height: 1.25;
  }

  .metric small,
  .mini-metric small {
    font-size: 12px;
    line-height: 1.35;
  }

  .inline-form,
  .comparison-form,
  .campaign-form,
  .marketing-form,
  .manual-form {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .inline-form button,
  .inline-form .secondary-button,
  .comparison-form button,
  .campaign-form button,
  .marketing-form button,
  .manual-form button {
    width: 100%;
    min-height: 44px;
  }

  label {
    gap: 6px;
    font-size: 12px;
  }

  input,
  select {
    width: 100%;
    height: 44px;
    font-size: 16px;
  }

  .segmented {
    width: 100%;
  }

  .segmented button {
    min-height: 40px;
    padding-inline: 8px;
    font-size: 13px;
  }

  .split,
  .comparison-grid,
  .prediction-grid,
  .diagnostic-grid,
  .compact-grid {
    grid-template-columns: 1fr;
  }

  .chart-controls,
  .chart-controls select,
  .prediction-controls select {
    width: 100%;
  }

  .chart-controls {
    gap: 8px;
  }

  .chart {
    padding: 12px;
    overflow: hidden;
  }

  .chart-meta {
    display: grid;
    min-width: 0;
    gap: 10px;
  }

  .chart-meta strong {
    font-size: 15px;
  }

  .chart-meta small {
    font-size: 11px;
    line-height: 1.35;
  }

  .chart-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
    justify-content: stretch;
    gap: 6px;
  }

  .chart-kpis span {
    min-width: 0;
    padding: 7px 8px;
  }

  .chart-kpis strong {
    font-size: 15px;
  }

  .chart svg {
    min-width: 0;
    width: 100%;
    height: 280px;
  }

  .tall-chart svg {
    height: 320px;
  }

  .axis {
    font-size: 10px;
  }

  .date-tick {
    font-size: 9px !important;
  }

  .chart-tooltip-text {
    font-size: 10px;
  }

  .chart-tooltip-text.value {
    font-size: 11px;
  }

  .chart-legend {
    min-width: 0;
    gap: 8px 12px;
    font-size: 11px;
    line-height: 1.25;
  }

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

  .mini-metric strong {
    font-size: clamp(21px, 5vw, 25px);
  }

  .campaign-item {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 9px;
  }

  .campaign-item button {
    width: 100%;
  }

  .table-wrap {
    margin-inline: 0;
    max-height: 420px;
  }

  table {
    min-width: 560px;
    font-size: 13px;
  }

  th,
  td {
    padding: 8px;
  }

  .expert-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 481px) and (max-width: 767px) {
  .comparison-grid,
  .prediction-grid,
  .diagnostic-grid,
  .compact-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  main {
    gap: 14px;
    padding: 12px 16px 26px;
  }

  .hero-actions {
    grid-template-columns: 1fr;
  }

  .hero-actions .status {
    grid-column: auto;
  }

  .metric-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "current"
      "reference"
      "daily"
      "net"
      "weekly"
      "average";
  }

  .chart svg {
    height: 260px;
  }

  .tall-chart svg {
    height: 300px;
  }

  .chart-kpis {
    grid-template-columns: 1fr;
  }

  table {
    min-width: 540px;
  }
}

.runtime-status {
  padding: 6px 9px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  white-space: nowrap;
}

.runtime-status.warning {
  border-color: rgba(180, 83, 9, 0.35);
  background: rgba(180, 83, 9, 0.12);
}

.scenario-grid {
  margin-bottom: 12px;
}

.scenario-recommendation {
  grid-column: 1 / -1;
  min-height: auto;
}

.scenario-card.recommended {
  border-color: rgba(var(--brand-blue-rgb), 0.42);
  background: var(--brand-blue-soft);
}

.prediction-expert-model {
  margin-top: 12px;
  padding: 0;
}

.prediction-expert-model .prediction-controls,
.prediction-expert-model .prediction-grid,
.prediction-expert-model .table-wrap {
  margin: 0 16px 16px;
}

.prediction-expert-model .prediction-controls {
  padding-top: 4px;
}

.prediction-page {
  display: grid;
  gap: 18px;
}

.prediction-page-header {
  display: grid;
  gap: 8px;
  max-width: 980px;
}

.prediction-page-header h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.08;
}

.prediction-page-header p,
.prediction-page-header small {
  margin: 0;
  max-width: 860px;
  color: var(--muted);
  line-height: 1.45;
}

.prediction-page-header p {
  font-size: clamp(15px, 1.8vw, 17px);
}

.prediction-toolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--subtle);
}

.prediction-toolbar label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.prediction-toolbar select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.prediction-scenario-layout {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.recommended-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 14px;
  min-width: 0;
}

.recommended-scenario-card,
.recommendation-reasons,
.diagnostic-verdict,
.diagnostic-reasons {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--subtle);
}

.recommended-scenario-card {
  display: grid;
  gap: 18px;
  padding: clamp(18px, 2.2vw, 26px);
}

.recommended-scenario-copy {
  display: grid;
  gap: 8px;
  max-width: 860px;
}

.recommended-scenario-copy span,
.scenario-card-head span,
.diagnostic-verdict span,
.diagnostic-reasons h3,
.recommended-metrics dt,
.diagnostic-verdict dt,
.diagnostic-compact-metrics dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.recommended-scenario-copy h2 {
  margin: 0;
  color: var(--text);
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.12;
}

.recommended-scenario-copy p,
.recommended-reason,
.recommendation-reasons li,
.scenario-card p,
.diagnostic-verdict p,
.diagnostic-reasons span {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.recommended-scenario-copy p {
  max-width: 820px;
  color: var(--text);
  font-size: clamp(16px, 1.8vw, 18px);
}

.recommended-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.recommended-metrics div {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.recommended-metrics dd {
  margin: 0;
  color: var(--text);
  font-size: clamp(24px, 3.4vw, 38px);
  font-weight: 950;
  line-height: 1;
}

.recommended-metrics span {
  color: var(--legend);
  font-size: 12px;
  font-weight: 700;
}

.recommended-reason {
  max-width: 880px;
}

.recommendation-reasons {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 18px;
}

.recommendation-reasons h3,
.diagnostic-reasons h3 {
  margin: 0;
  color: var(--text);
}

.recommendation-reasons ul {
  display: grid;
  gap: 9px;
  margin: 0;
  padding-left: 18px;
}

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

.scenario-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.scenario-card.recommended {
  border-color: rgba(var(--brand-blue-rgb), 0.42);
  background: var(--brand-blue-soft);
}

.scenario-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.scenario-card-head em {
  flex: none;
  color: var(--brand-blue);
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

.scenario-card > strong {
  color: var(--text);
  font-size: clamp(26px, 3vw, 34px);
  line-height: 1;
}

.scenario-card > b {
  font-size: 16px;
}

.scenario-card dl {
  display: grid;
  gap: 6px;
  margin: 0;
}

.scenario-card dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.scenario-card dt,
.scenario-card dd {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.scenario-card dd {
  color: var(--text);
  font-weight: 800;
  text-align: right;
}

.prediction-chart {
  min-height: 360px;
}

.prediction-diagnostics {
  display: grid;
  gap: 14px;
}

.diagnostic-verdict {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.diagnostic-verdict > div:first-child {
  display: grid;
  gap: 8px;
}

.diagnostic-verdict strong {
  max-width: 920px;
  color: var(--text);
  font-size: clamp(18px, 2vw, 23px);
  line-height: 1.35;
}

.diagnostic-verdict-grid,
.diagnostic-compact-metrics {
  display: grid;
  gap: 10px;
  margin: 0;
}

.diagnostic-verdict-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.diagnostic-verdict-grid div,
.diagnostic-compact-metrics div {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.diagnostic-verdict dd,
.diagnostic-compact-metrics dd {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  font-weight: 900;
  line-height: 1.2;
}

.diagnostic-reasons {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.diagnostic-reasons div {
  display: grid;
  gap: 3px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.diagnostic-reasons div:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.diagnostic-reasons strong {
  color: var(--text);
  font-size: 14px;
}

.diagnostic-compact-metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.diagnostic-expert-tests {
  background: var(--subtle);
}

.prediction-summary-table {
  margin-top: 0;
}

.expert-model-summary strong {
  font-size: clamp(17px, 1.6vw, 22px);
}

.compact-warning {
  display: block;
  margin-top: 4px;
}

.prediction-expert-model {
  margin-top: 0;
}

.prediction-expert-model .prediction-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 767px) {
  .runtime-status {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .prediction-page {
    gap: 14px;
  }

  .prediction-toolbar,
  .recommended-layout,
  .scenario-card-grid,
  .recommended-metrics,
  .diagnostic-verdict-grid,
  .diagnostic-compact-metrics,
  .prediction-expert-model .prediction-grid {
    grid-template-columns: 1fr;
  }

  .prediction-toolbar,
  .recommended-scenario-card,
  .recommendation-reasons,
  .diagnostic-verdict,
  .diagnostic-reasons {
    padding: 14px;
  }

  .prediction-chart {
    min-height: 280px;
  }

  .scenario-grid,
  .prediction-grid,
  .diagnostic-grid {
    grid-template-columns: 1fr;
  }

  .prediction-expert-model .prediction-controls,
  .prediction-expert-model .prediction-grid,
  .prediction-expert-model .table-wrap {
    margin-inline: 12px;
  }
}

@media (min-width: 768px) and (max-width: 1024px) {
  .prediction-toolbar,
  .scenario-card-grid,
  .recommended-metrics,
  .diagnostic-verdict-grid,
  .diagnostic-compact-metrics,
  .prediction-expert-model .prediction-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .recommended-layout {
    grid-template-columns: 1fr;
  }

  .prediction-chart {
    min-height: 340px;
  }

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

/* Dashboard overview refinement: layout and density only. */
.hero-compact {
  grid-template-columns: minmax(0, 1fr) minmax(260px, auto);
  gap: clamp(14px, 2vw, 22px);
  padding: clamp(16px, 2.1vw, 24px);
}

.hero-compact h1 {
  font-size: clamp(28px, 3.2vw, 40px);
  line-height: 1.04;
}

.hero-compact .hero-text {
  max-width: 660px;
  margin-top: 8px;
  font-size: clamp(15px, 1.3vw, 16px);
  line-height: 1.42;
}

.hero-side {
  display: grid;
  gap: 10px;
  justify-items: end;
  min-width: 0;
}

.hero-side .hero-actions {
  min-width: 0;
}

.action-status {
  flex-basis: 100%;
  font-size: 12px;
}

.hero-tech-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  max-width: 360px;
  color: rgba(255, 255, 255, 0.74);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  text-align: right;
}

.hero-tech-status span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  min-width: 0;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  white-space: nowrap;
}

.hero-tech-status span.warning {
  border-color: rgba(251, 191, 36, 0.34);
  background: rgba(251, 191, 36, 0.13);
  color: #fff7d6;
}

.hero-tech-status .runtime-status {
  padding: 5px 8px;
  color: rgba(255, 255, 255, 0.8);
  text-align: inherit;
}

.dashboard-summary-panel {
  display: grid;
  gap: 14px;
}

.dashboard-summary-title {
  margin-bottom: 0;
}

.dashboard-summary-panel .metric {
  min-height: 102px;
  padding: 14px;
  box-shadow: none;
}

.dashboard-summary-panel .metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.25;
  text-transform: none;
}

.dashboard-summary-panel .metric strong {
  font-size: clamp(23px, 2.4vw, 32px);
}

.dashboard-summary-panel .metric small {
  line-height: 1.32;
}

.period-form {
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) auto auto;
  align-items: end;
}

.period-notice {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(180, 83, 9, 0.24);
  border-radius: 8px;
  background: rgba(180, 83, 9, 0.1);
  color: var(--amber);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.4;
}

.period-notice.error {
  border-color: rgba(185, 28, 28, 0.28);
  background: rgba(185, 28, 28, 0.1);
  color: var(--red);
}

.chart-panel {
  gap: 14px;
}

.chart-panel .panel-title {
  align-items: flex-start;
}

.chart-panel .chart-controls {
  margin-left: auto;
}

.chart {
  padding: 14px;
}

.chart svg {
  height: 290px;
}

.tall-chart svg {
  height: 330px;
}

.chart-meta {
  margin-bottom: 8px;
}

.chart-kpis span {
  min-width: 88px;
  padding: 7px 9px;
}

.chart-legend {
  margin-top: 8px;
}

@media (min-width: 1025px) {
  .dashboard-summary-panel {
    padding: 18px;
  }
}

@media (min-width: 768px) and (max-width: 1024px) {
  .hero-compact {
    grid-template-columns: 1fr;
    padding: 20px;
  }

  .hero-side,
  .hero-side .hero-actions,
  .hero-tech-status {
    justify-items: start;
    justify-content: flex-start;
    text-align: left;
  }

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

  .period-form button,
  .period-form .secondary-button {
    width: 100%;
  }

  .chart svg {
    height: 310px;
  }

  .tall-chart svg {
    height: 340px;
  }
}

@media (max-width: 767px) {
  .hero-compact {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .hero-side {
    justify-items: stretch;
    gap: 9px;
  }

  .hero-side .hero-actions {
    justify-content: stretch;
  }

  .action-status {
    text-align: left;
  }

  .hero-tech-status {
    justify-content: flex-start;
    max-width: none;
    text-align: left;
  }

  .hero-tech-status span {
    max-width: 100%;
    white-space: normal;
  }

  .hero-tech-status .runtime-status {
    width: auto;
    justify-content: flex-start;
    text-align: left;
  }

  .dashboard-summary-panel {
    padding: 16px;
  }

  .dashboard-summary-title {
    gap: 12px;
  }

  .dashboard-summary-title .segmented {
    width: 100%;
  }

  .dashboard-summary-panel .metric {
    min-height: auto;
    padding: 14px;
  }

  .period-form {
    grid-template-columns: 1fr;
  }

  .period-form button,
  .period-form .secondary-button {
    width: 100%;
  }

  .chart-panel .chart-controls {
    display: grid;
    grid-template-columns: 1fr;
    margin-left: 0;
  }

  .chart-panel .segmented.two,
  .chart-panel .chart-controls select {
    width: 100%;
  }

  .chart {
    padding: 12px;
  }

  .chart svg {
    height: 260px;
  }

  .tall-chart svg {
    height: 300px;
  }

  .chart-kpis {
    grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  }
}

/* Main statistics: compact symmetric KPI grid. */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: 12px;
  min-width: 0;
}

.stats-grid .stat-card {
  grid-area: auto;
  min-width: 0;
  min-height: 112px;
  height: auto;
  padding: 15px;
}

.stats-grid .metric-current {
  border-color: rgba(var(--brand-blue-rgb), 0.3);
  background:
    linear-gradient(180deg, var(--brand-blue-soft), transparent 125px),
    var(--panel);
}

.stats-grid .metric-current strong {
  font-size: clamp(28px, 3vw, 42px) !important;
}

@media (max-width: 900px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid .stat-card {
    min-height: auto;
  }
}
