/* Scenario Demand Forecast - design tokens and layout.
 *
 * Layout is the three-pane arrangement from the spec: scenario rail on the
 * left, the baseline-vs-simulated forecast in the centre, filters on the right.
 * Both rails collapse below 1180px, where a three-column layout stops being
 * readable and starts being three columns of nothing.
 *
 * Colour never carries meaning on its own. Every variance badge pairs a colour
 * with an arrow glyph and a word; every chart series pairs its colour with a
 * distinct dash pattern; every verdict chip is labelled. The palette below is
 * chosen so the whole thing still reads correctly in greyscale.
 */

:root {
  color-scheme: light;

  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-sunken: #f8fafc;
  --surface-raised: #ffffff;
  --border: #dfe4ec;
  --border-strong: #c3cbd8;

  --text: #16202f;
  --text-muted: #5b6779;
  --text-faint: #8a95a6;

  --accent: #2563eb;
  --accent-soft: #e8effd;
  --accent-strong: #1d4ed8;

  --baseline: #7c8899;
  --plan: #b45309;
  --band: rgba(124, 136, 153, 0.16);

  --good: #0f7b4f;
  --good-soft: #e2f4ec;
  --bad: #c2410c;
  --bad-soft: #fdeee6;
  --warn: #a16207;
  --warn-soft: #fdf4e3;
  --info: #4338ca;
  --info-soft: #eceafc;
  --neutral: #64748b;
  --neutral-soft: #eef1f5;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 12px rgba(16, 24, 40, 0.05);
  --shadow-lg: 0 8px 28px rgba(16, 24, 40, 0.12);

  --rail-left: 310px;
  --rail-right: 260px;

  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, monospace;
  --sans: "Segoe UI", -apple-system, BlinkMacSystemFont, Inter, Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --bg: #0e131b;
    --surface: #161d28;
    --surface-sunken: #111823;
    --surface-raised: #1b2431;
    --border: #263141;
    --border-strong: #37455a;

    --text: #e6ecf5;
    --text-muted: #97a4b8;
    --text-faint: #6d7b90;

    --accent: #5b91f5;
    --accent-soft: #16243d;
    --accent-strong: #7aa8ff;

    --baseline: #8593a6;
    --plan: #e0932f;
    --band: rgba(133, 147, 166, 0.2);

    --good: #3fbb85;
    --good-soft: #12281f;
    --bad: #f47b52;
    --bad-soft: #2d1a14;
    --warn: #d9a441;
    --warn-soft: #2a2113;
    --info: #8b83f0;
    --info-soft: #1e1b34;
    --neutral: #8b98ab;
    --neutral-soft: #1c2431;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.5);
  }
}

* {
  box-sizing: border-box;
}

html,
body,
#root {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------------ shell */

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex: none;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 9px;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand small {
  font-weight: 500;
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.topbar-scenario {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex: 1;
}

.topbar-scenario .name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex: none;
}

.tabs {
  display: flex;
  gap: 2px;
  padding: 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex: none;
}

.tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 9px 14px;
  margin-bottom: -1px;
  color: var(--text-muted);
  font-weight: 550;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
}

.tab:hover {
  color: var(--text);
}

.tab[aria-selected="true"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab .tab-state {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--neutral-soft);
  color: var(--text-faint);
}

.workspace {
  display: grid;
  grid-template-columns: var(--rail-left) minmax(0, 1fr) var(--rail-right);
  gap: 14px;
  padding: 14px 18px 22px;
  flex: 1;
  min-height: 0;
  overflow: auto;
  align-items: start;
}

@media (max-width: 1420px) {
  :root {
    --rail-left: 280px;
    --rail-right: 232px;
  }
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }
  .rail {
    order: 2;
  }
  .center {
    order: 1;
  }
}

/* ------------------------------------------------------------------ rails */

.rail {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.center {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
}

.card > header h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.card-body {
  padding: 13px 14px;
}

.card-body.tight {
  padding: 8px;
}

.card-note {
  padding: 9px 14px 12px;
  font-size: 12px;
  color: var(--text-faint);
  border-top: 1px solid var(--border);
  line-height: 1.5;
}

/* ---------------------------------------------------------------- buttons */

.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 6px 11px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.12s, border-color 0.12s;
}

.btn:hover:not(:disabled) {
  background: var(--surface-sunken);
  border-color: var(--text-faint);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.primary:hover:not(:disabled) {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.btn.ghost {
  border-color: transparent;
  background: none;
  color: var(--text-muted);
  padding: 4px 7px;
}

.btn.ghost:hover:not(:disabled) {
  background: var(--neutral-soft);
  color: var(--text);
}

.btn.tiny {
  padding: 3px 7px;
  font-size: 12px;
}

/* ------------------------------------------------------------- segmented */

.segmented {
  display: inline-flex;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}

.segmented button {
  appearance: none;
  border: none;
  background: none;
  border-radius: 4px;
  padding: 5px 11px;
  font-weight: 550;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

.segmented button:hover {
  color: var(--text);
}

.segmented button[aria-pressed="true"] {
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: var(--shadow);
}

.segmented.measure button[aria-pressed="true"] {
  color: var(--accent);
}

/* ------------------------------------------------------------------ chips */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.chip.neutral { background: var(--neutral-soft); color: var(--text-muted); }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip.accent { background: var(--accent-soft); color: var(--accent-strong); }

/* --------------------------------------------------------------- controls */

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 11px 14px;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 7px;
}

.control-group > label,
.control-label {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.control-group select,
.filter-search {
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
}

.spacer {
  flex: 1;
}

/* ------------------------------------------------------------------- kpis */

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

/* The five-measure financial strip is a fixed set, so it gets a tighter track
 * than the general KPI row: at four-per-row the fifth wraps alone and the
 * leftover grid cell reads as a rendering fault rather than empty space. */
.kpi-strip.financial {
  grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
  border: none;
  border-radius: 0;
}

/* Six tiles, for the same reason the financial strip has its own track: at
 * five-per-row the sixth wraps alone and the empty cell reads as a fault. */
.kpi-strip.orders {
  grid-template-columns: repeat(auto-fit, minmax(126px, 1fr));
}

.kpi {
  background: var(--surface);
  padding: 11px 13px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.kpi.is-active {
  background: var(--accent-soft);
}

.kpi .kpi-label {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 5px;
}

.kpi .kpi-value {
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.kpi .kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.delta .arrow {
  font-size: 11px;
  line-height: 1;
}

.delta .word {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  opacity: 0.85;
}

.delta.good { color: var(--good); }
.delta.bad { color: var(--bad); }
.delta.flat { color: var(--text-faint); }

/* ------------------------------------------------------------------ chart */

.chart-wrap {
  position: relative;
  padding: 6px 6px 0;
}

.chart-wrap svg {
  display: block;
  width: 100%;
  overflow: visible;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  padding: 4px 14px 12px;
  font-size: 12px;
  color: var(--text-muted);
}

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

.legend-item button {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend-item[data-off="true"] {
  opacity: 0.42;
  text-decoration: line-through;
}

.legend-swatch {
  width: 22px;
  height: 0;
  border-top-width: 2.5px;
  border-top-style: solid;
  flex: none;
}

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 5;
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 9px 11px;
  min-width: 208px;
  font-size: 12px;
}

.chart-tooltip h4 {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 650;
}

.chart-tooltip dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 12px;
}

.chart-tooltip dt {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.chart-tooltip dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.chart-tooltip .tooltip-note {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid var(--border);
  color: var(--warn);
  line-height: 1.45;
}

.chart-tooltip .tooltip-hint {
  margin-top: 6px;
  color: var(--text-faint);
  font-size: 11px;
}

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

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

.now-line {
  stroke: var(--text-faint);
  stroke-width: 1.5;
  stroke-dasharray: 3 3;
}

.now-flag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  fill: var(--text-muted);
}

.period-hit {
  fill: transparent;
  cursor: pointer;
}

.period-hit:hover,
.period-hit:focus-visible {
  fill: var(--accent);
  fill-opacity: 0.07;
}

.affected-marker {
  fill: var(--warn);
}

/* ------------------------------------------------------------------ table */

table.data {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

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

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

table.data thead th {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
  border-bottom-color: var(--border-strong);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

table.data tbody tr:last-child td {
  border-bottom: none;
}

table.data tbody tr.is-active {
  background: var(--accent-soft);
}

table.data tbody tr.is-reference td {
  color: var(--text-muted);
}

table.data th[role="columnheader"] button {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-transform: inherit;
  letter-spacing: inherit;
}

.table-scroll {
  max-height: 340px;
  overflow: auto;
}

/* ---------------------------------------------------------------- drivers */

.driver {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}

.driver:last-child {
  border-bottom: none;
}

.driver-head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  min-width: 0;
}

.driver-head .label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.driver-value {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  text-align: right;
}

.driver-bar {
  grid-column: 1 / -1;
  height: 6px;
  border-radius: 3px;
  background: var(--neutral-soft);
  overflow: hidden;
  margin-top: 3px;
}

.driver-bar span {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
}

.driver-bar.is-negative span {
  background: var(--bad);
}

.driver-note {
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.45;
  margin-top: 3px;
}

/* -------------------------------------------------------------------- nba */

.nba {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.nba-verdict {
  display: flex;
  align-items: center;
  gap: 10px;
}

.verdict-chip {
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.07em;
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  border: 1.5px solid currentColor;
  white-space: nowrap;
}

.verdict-GO { color: var(--good); background: var(--good-soft); }
.verdict-REVIEW { color: var(--neutral); background: var(--neutral-soft); }
.verdict-DEFEND { color: var(--warn); background: var(--warn-soft); }
.verdict-MITIGATE { color: var(--bad); background: var(--bad-soft); }
.verdict-PLAN.verdict-CAPACITY,
.verdict-PLANCAPACITY { color: var(--info); background: var(--info-soft); }

.nba-headline {
  font-weight: 600;
  line-height: 1.45;
}

.nba ul {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--text-muted);
  line-height: 1.5;
}

.nba ul.actions {
  color: var(--text);
}

/* ---------------------------------------------------------- scenario rail */

.scenario-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 11px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  background: none;
  border-left: 3px solid transparent;
  width: 100%;
  text-align: left;
  appearance: none;
  border-top: none;
  border-right: none;
  color: inherit;
}

.scenario-item:last-of-type {
  border-bottom: none;
}

/* Room for the delete affordance, which sits at the right of the row. */
.scenario-row {
  position: relative;
}

.scenario-row .scenario-delete {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
}

.scenario-row:hover .scenario-delete,
.scenario-row:focus-within .scenario-delete {
  opacity: 1;
}

.scenario-row:hover .scenario-item,
.scenario-row:focus-within .scenario-item {
  padding-right: 34px;
}

.scenario-item:hover {
  background: var(--surface-sunken);
}

.scenario-item[aria-current="true"] {
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

.scenario-item .meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.scenario-item .title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scenario-item .sub {
  font-size: 11px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assumption {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
}

.assumption[data-off="true"] {
  opacity: 0.55;
}

.assumption .body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.assumption .label {
  font-weight: 600;
  font-size: 13px;
}

.assumption .desc {
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1.45;
}

.assumption-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.composer textarea {
  width: 100%;
  min-height: 62px;
  resize: vertical;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 9px;
  line-height: 1.45;
}

.composer textarea:disabled {
  opacity: 0.6;
}

.suggestions {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.suggestion {
  appearance: none;
  text-align: left;
  background: none;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1.4;
}

.suggestion:hover {
  border-style: solid;
  color: var(--text);
  background: var(--surface-sunken);
}

.narrative {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-muted);
  border-left: 2px solid var(--accent);
  padding-left: 10px;
}

/* ------------------------------------------------------------ filter rail */

.filter-group + .filter-group {
  margin-top: 13px;
  padding-top: 13px;
  border-top: 1px solid var(--border);
}

.filter-group h3 {
  margin: 0 0 7px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  cursor: pointer;
  line-height: 1.35;
}

.filter-option input {
  accent-color: var(--accent);
  flex: none;
}

.filter-option > span:not(.count) {
  white-space: nowrap;
}

.filter-option .count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  text-align: right;
}

.filter-search {
  width: 100%;
  margin-bottom: 7px;
}

.filter-scroll {
  max-height: 176px;
  overflow-y: auto;
}

/* ----------------------------------------------------------------- states */

.banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 13px;
  border-radius: var(--radius);
  border: 1px solid;
  line-height: 1.5;
}

.banner .banner-body {
  flex: 1;
}

.banner.warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.banner.bad { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.banner.info { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }
.banner.neutral { background: var(--neutral-soft); border-color: var(--border-strong); color: var(--text-muted); }

.banner strong {
  display: block;
  color: inherit;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  padding: 34px 20px;
  text-align: center;
  color: var(--text-muted);
  line-height: 1.55;
}

.empty-state h3 {
  margin: 0;
  color: var(--text);
  font-size: 15px;
}

.empty-state p {
  margin: 0;
  max-width: 46ch;
}

/* skeletons */

@keyframes shimmer {
  0% { opacity: 0.55; }
  50% { opacity: 0.9; }
  100% { opacity: 0.55; }
}

.skeleton {
  background: var(--neutral-soft);
  border-radius: var(--radius-sm);
  animation: shimmer 1.4s ease-in-out infinite;
}

.skeleton-chart {
  height: 268px;
  margin: 12px 14px;
}

.skeleton-row {
  height: 13px;
  margin: 8px 0;
}

/* ---------------------------------------------------------------- utility */

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.mono { font-family: var(--mono); font-size: 12px; }
.nowrap { white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }

.hint {
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.5;
}

.formula {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
}

/* --------------------------------------------------------- planned orders */

.axis-line {
  stroke: var(--border-strong);
  stroke-width: 1;
}

.bar {
  rx: 2;
}
.bar.production { fill: var(--accent); }
.bar.purchase { fill: var(--info); }
.bar.demand { fill: var(--baseline); opacity: 0.55; }
.bar.scheduled { fill: var(--info); opacity: 0.42; }

.line {
  fill: none;
  stroke-width: 2;
}
.line.stock { stroke: var(--good); }
.line.safety {
  stroke: var(--bad);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
}

.chart-readout {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
  padding: 6px 8px 2px;
  font-size: 12px;
  color: var(--text-muted);
  min-height: 26px;
}

.legend,
.swatch-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.legend { gap: 14px; }

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
  flex: none;
}
.swatch.production { background: var(--accent); }
.swatch.purchase { background: var(--info); }
.swatch.demand { background: var(--baseline); opacity: 0.55; }

.dash {
  width: 14px;
  height: 0;
  display: inline-block;
  flex: none;
  border-top: 2px solid var(--good);
}
.dash.safety { border-top: 2px dashed var(--bad); }

.chip-row {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}

.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-muted);
}

.inline-field select {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  padding: 4px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  max-width: 260px;
}

table.data tbody tr.row-flagged td,
table.data tbody tr.row-flagged th {
  background: var(--bad-soft);
}

table.data td.left,
table.data th.left {
  text-align: left;
}

.cell-stack {
  display: inline-flex;
  flex-direction: column;
  line-height: 1.3;
}

.btn.link {
  background: none;
  border: none;
  color: var(--accent);
  padding: 8px 10px;
  font-size: 12px;
  cursor: pointer;
}
.btn.link:hover:not(:disabled) {
  background: none;
  text-decoration: underline;
}

.kpi.is-bad .kpi-value { color: var(--bad); }
.kpi.is-warn .kpi-value { color: var(--warn); }

.tab .tab-state.alert {
  background: var(--bad-soft);
  color: var(--bad);
  font-weight: 700;
}
