@import "tailwindcss" source(none);
@import "tw-animate-css";
@import "../vendor/shadcn-tailwind-4.13.0.css";

@source "./";
@source "../components";
@source "../strato";

@utility scrollbar-thin {
  scrollbar-width: thin;
}

@utility scrollbar-none {
  scrollbar-width: none;

  &::-webkit-scrollbar {
    display: none;
  }
}

@utility scrollbar-gutter-stable {
  scrollbar-gutter: stable;
}

:root {
  --background: #0b0d0e;
  --foreground: #e8e8e8;
  --card: #111315;
  --card-foreground: #ededed;
  --popover: #17191b;
  --popover-foreground: #ededed;
  --primary: #f7a72d;
  --primary-foreground: #15100a;
  --secondary: #292d31;
  --secondary-foreground: #ededed;
  --muted: #23272a;
  --muted-foreground: #a9b0b8;
  --accent: #303439;
  --accent-foreground: #f4f4f5;
  --destructive: #e65d4f;
  --border: #ffffff17;
  --input: #ffffff1a;
  --ring: #f7a72d;
  --chart-1: #f7a72d;
  --chart-2: #69c5df;
  --chart-3: #74b768;
  --chart-4: #9c3db4;
  --chart-5: #e65d4f;
  --radius: 0.72rem;
  --sidebar: #111315;
  --sidebar-foreground: #ededed;
  --sidebar-primary: #f7a72d;
  --sidebar-primary-foreground: #15100a;
  --sidebar-accent: #292d31;
  --sidebar-accent-foreground: #ededed;
  --sidebar-border: #ffffff17;
  --sidebar-ring: #f7a72d;
}

@theme inline {
  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --color-card: var(--card);
  --color-card-foreground: var(--card-foreground);
  --color-popover: var(--popover);
  --color-popover-foreground: var(--popover-foreground);
  --color-primary: var(--primary);
  --color-primary-foreground: var(--primary-foreground);
  --color-secondary: var(--secondary);
  --color-secondary-foreground: var(--secondary-foreground);
  --color-muted: var(--muted);
  --color-muted-foreground: var(--muted-foreground);
  --color-accent: var(--accent);
  --color-accent-foreground: var(--accent-foreground);
  --color-destructive: var(--destructive);
  --color-border: var(--border);
  --color-input: var(--input);
  --color-ring: var(--ring);
  --color-chart-1: var(--chart-1);
  --color-chart-2: var(--chart-2);
  --color-chart-3: var(--chart-3);
  --color-chart-4: var(--chart-4);
  --color-chart-5: var(--chart-5);
  --color-sidebar: var(--sidebar);
  --color-sidebar-foreground: var(--sidebar-foreground);
  --color-sidebar-primary: var(--sidebar-primary);
  --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
  --color-sidebar-accent: var(--sidebar-accent);
  --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
  --color-sidebar-border: var(--sidebar-border);
  --color-sidebar-ring: var(--sidebar-ring);
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
}

body {
  background: var(--background);
  color: var(--foreground);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-width: 320px;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.012) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.012) 1px, transparent 1px);
  background-size: 24px 24px;
  overflow-x: clip;
}

* {
  scrollbar-color: #3d4247 #121416;
}

::selection {
  background: rgba(247, 167, 45, 0.28);
  color: #fff;
}

summary::-webkit-details-marker {
  display: none;
}

details[open] > summary .details-chevron {
  transform: rotate(180deg);
}

/* One readable hierarchy language for every calculator workspace. */
.collapsible-summary,
[data-totals-section] > summary,
[data-totals-entry] > summary {
  min-height: 4.75rem;
  box-sizing: border-box;
}

.collapsible-summary {
  display: grid !important;
  width: 100%;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center !important;
  justify-content: stretch !important;
  gap: 0.75rem !important;
  cursor: pointer;
  user-select: none;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.summary-leading {
  min-width: 0;
  grid-column: 1;
}

.summary-trailing {
  grid-column: 2;
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  justify-self: end;
  gap: 0.75rem;
}

.summary-trailing > .details-chevron,
.summary-trailing > :where(button) .details-chevron {
  flex: 0 0 auto;
}

.collapsible-summary:hover,
[data-totals-section] > summary:hover,
[data-totals-entry] > summary:hover {
  background-color: rgba(255, 255, 255, 0.022);
}

details:not([open]) {
  block-size: auto !important;
  min-block-size: 0 !important;
  align-self: stretch;
}

details:not([open]) > summary {
  margin-bottom: 0 !important;
  border-bottom-color: transparent !important;
}

.collapsible-panel {
  width: 100%;
  min-width: 0;
}

.summary-kpi,
.selected-throughput-kpi {
  --kpi-rgb: 105, 197, 223;
  display: inline-flex;
  height: 3.75rem;
  min-height: 3.75rem;
  min-width: 7rem;
  flex: 0 0 auto;
  flex-direction: column;
  justify-content: center;
  border: 2px solid rgba(var(--kpi-rgb), 0.36);
  border-radius: 0.7rem;
  background: linear-gradient(135deg, rgba(var(--kpi-rgb), 0.13), rgba(13, 15, 16, 0.94));
  padding: 0.42rem 0.72rem;
  box-shadow: inset 3px 0 0 rgba(var(--kpi-rgb), 0.48), 0 0 18px rgba(var(--kpi-rgb), 0.055);
}

.summary-kpi[data-kpi-tone="orange"],
.selected-throughput-kpi[data-kpi-tone="orange"] { --kpi-rgb: 247, 167, 45; }
.summary-kpi[data-kpi-tone="green"],
.selected-throughput-kpi[data-kpi-tone="green"] { --kpi-rgb: 116, 183, 104; }
.summary-kpi[data-kpi-tone="purple"],
.selected-throughput-kpi[data-kpi-tone="purple"] { --kpi-rgb: 193, 123, 213; }

.summary-kpi small,
.selected-throughput-kpi small {
  display: block;
  color: #aeb6bf;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.68rem;
  line-height: 0.9rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.summary-kpi strong,
.selected-throughput-kpi strong {
  display: block;
  color: rgb(var(--kpi-rgb));
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92rem;
  line-height: 1.18rem;
  font-weight: 750;
}

.summary-kpi-large {
  min-width: 9rem;
  height: 3.75rem;
  min-height: 3.75rem;
  align-items: flex-end;
}

.summary-kpi-large strong { font-size: 1.7rem; line-height: 2rem; }

.priority-kpi {
  min-width: min(19rem, 38vw);
  max-width: 23rem;
}

.selected-throughput-strip {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.selected-throughput-kpi {
  min-width: 10.5rem;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 0.6rem;
}

/* All dashboard headers reserve the same right-hand rail for KPIs and the
   disclosure affordance. Their values therefore form one vertical guide. */
.dashboard-summary .summary-trailing,
.factory-totals-summary .summary-trailing {
  width: min(23rem, 48%);
  min-width: 0;
}

.dashboard-summary .summary-kpi,
.factory-totals-summary .summary-kpi {
  margin-left: auto;
}

.dashboard-summary .priority-kpi {
  width: auto;
  min-width: 0;
  flex: 1 1 auto;
}

.factory-totals-section-summary .summary-trailing {
  display: grid;
  width: 12.75rem;
  grid-template-columns: minmax(0, 1fr) 1rem;
  gap: 0.75rem;
}

.factory-totals-section-summary .summary-kpi {
  width: 11rem;
  min-width: 0;
}

.factory-totals-section-summary .details-chevron {
  justify-self: end;
}

.selected-throughput-kpi > span { min-width: 0; }
.selected-throughput-kpi small { white-space: normal; overflow-wrap: anywhere; }

.totals-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 7rem;
  align-items: center;
  gap: 0.75rem;
}

.totals-unit-picker {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { appearance: none; margin: 0; }

.editable-control,
.workspace-settings [data-slot="select-trigger"],
.workspace-settings [role="combobox"],
.workspace-results [data-slot="select-trigger"],
.workspace-results [role="combobox"] {
  border-color: rgba(105, 197, 223, 0.34) !important;
  box-shadow: inset 0 0 0 1px rgba(105, 197, 223, 0.045);
}

.editable-control:focus-within,
.workspace-settings [data-slot="select-trigger"]:focus,
.workspace-settings [role="combobox"]:focus,
.workspace-results [data-slot="select-trigger"]:focus,
.workspace-results [role="combobox"]:focus {
  border-color: rgba(247, 167, 45, 0.72) !important;
  box-shadow: 0 0 0 2px rgba(247, 167, 45, 0.12);
}

.smart-number {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  height: 2.5rem;
  overflow: hidden;
  border: 1px solid rgba(105, 197, 223, 0.34);
  border-radius: 0.55rem;
  background: #17191b;
}

.smart-number > input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 0 0.7rem;
  color: #ededed;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  appearance: textfield;
}

.smart-number-buttons {
  display: grid;
  grid-template-rows: 1fr 1fr;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.smart-number-buttons button {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #858b91;
  background: linear-gradient(#292d31, #1c1f22);
}

.smart-number-buttons button:first-child { border-bottom: 1px solid rgba(255, 255, 255, 0.07); }
.smart-number-buttons button:hover { color: #f7a72d; background: #303439; }
.smart-number-buttons svg { width: 0.72rem; height: 0.72rem; }

.quality-output-grid {
  display: grid;
  flex: 2 1 420px;
  grid-template-columns: minmax(112px, 1.15fr) repeat(2, minmax(105px, 1fr));
  grid-template-rows: repeat(2, minmax(0, auto));
  gap: 0.45rem;
}

.quality-output-chip[data-quality="normal"] { grid-column: 1; grid-row: 1 / 3; align-self: center; margin-right: 0.35rem; }
.quality-output-chip[data-quality="uncommon"] { grid-column: 2; grid-row: 1; }
.quality-output-chip[data-quality="rare"] { grid-column: 3; grid-row: 1; }
.quality-output-chip[data-quality="epic"] { grid-column: 2; grid-row: 2; }
.quality-output-chip[data-quality="legendary"] { grid-column: 3; grid-row: 2; }

.quality-output-chip {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 105px;
  border: 1px solid;
  border-radius: 0.55rem;
  background: #0e1011;
  padding: 0.38rem 0.5rem;
}

@media (max-width: 720px) {
  .quality-output-grid { grid-template-columns: minmax(105px, 1fr) repeat(2, minmax(92px, 1fr)); }
}

.quality-output-chip span:last-child { display: grid; line-height: 1.05; }
.quality-output-chip small { font-size: 0.625rem; text-transform: uppercase; letter-spacing: 0.07em; }
.quality-output-chip strong { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.82rem; }
.quality-output-chip em { color: #959ca4; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.62rem; font-style: normal; }

.app-shell {
  display: flex;
  width: 100%;
  max-width: 100vw;
  min-height: 100vh;
  min-height: 100dvh;
  flex-direction: column;
  overflow-x: clip;
  background: #0b0d0e;
  color: #ededed;
}

.calculator-stage {
  display: grid;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.calculator-route {
  grid-area: 1 / 1;
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Secondary information remains secondary without becoming hard to read. */
.app-shell .text-\[9px\] { font-size: 0.6875rem !important; line-height: 0.96rem !important; }
.app-shell .text-\[10px\] { font-size: 0.75rem !important; line-height: 1rem !important; }
.app-shell .text-\[11px\] { font-size: 0.8125rem !important; line-height: 1.08rem !important; }
.app-shell .text-xs { font-size: 0.875rem !important; line-height: 1.22rem !important; }
.app-shell .text-zinc-700 { color: #8f969f !important; }
.app-shell .text-zinc-600 { color: #9fa7b0 !important; }
.app-shell .text-zinc-500 { color: #b3bac2 !important; }
.app-shell .text-zinc-400 { color: #c7ccd2 !important; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(17, 19, 21, 0.97);
  backdrop-filter: blur(14px);
  flex: 0 0 auto;
}

.workspace-grid {
  margin: 0 auto;
  display: grid;
  max-width: 1900px;
  gap: 1.1rem;
  padding: 1rem;
}

.workspace-settings,
.workspace-results {
  min-width: 0;
}

.workspace-settings,
.workspace-results {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.workspace-settings > *,
.workspace-results > * {
  flex-shrink: 0;
}

.panel-card {
  border: 2px solid rgba(105, 197, 223, 0.24);
  border-radius: 1rem;
  background: #111315;
  padding: 1rem;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.16);
}

/* The same four accents repeat in every calculator without changing its
   information hierarchy. This keeps long settings and result columns easy
   to scan while preserving the established dark Factorio styling. */
.workspace-settings > .panel-card:nth-child(4n + 1),
.workspace-results > .panel-card:nth-child(4n + 1) {
  border-color: rgba(247, 167, 45, 0.3);
}

.workspace-settings > .panel-card:nth-child(4n + 2),
.workspace-results > .panel-card:nth-child(4n + 2) {
  border-color: rgba(105, 197, 223, 0.3);
}

.workspace-settings > .panel-card:nth-child(4n + 3),
.workspace-results > .panel-card:nth-child(4n + 3) {
  border-color: rgba(116, 183, 104, 0.3);
}

.workspace-settings > .panel-card:nth-child(4n + 4),
.workspace-results > .panel-card:nth-child(4n + 4) {
  border-color: rgba(193, 123, 213, 0.3);
}

/* Parent, child, and detail surfaces use distinct Factorio-adjacent accents. */
.hierarchy-panel,
.module-panel,
.metric-card,
.material-panel,
.geometry-panel,
.result-hero,
.stream-split-control,
.notice-info,
.notice-warning {
  border-width: 2px;
}

.hierarchy-panel { border-color: rgba(247, 167, 45, 0.29) !important; }
.hierarchy-panel .hierarchy-panel { border-color: rgba(105, 197, 223, 0.31) !important; }
.hierarchy-panel .hierarchy-panel .hierarchy-panel { border-color: rgba(116, 183, 104, 0.32) !important; }
.hierarchy-panel .hierarchy-panel .hierarchy-panel .hierarchy-panel { border-color: rgba(193, 123, 213, 0.32) !important; }
.module-panel { border-color: rgba(105, 197, 223, 0.27) !important; }
.geometry-panel { border-color: rgba(193, 123, 213, 0.3) !important; }
.blueprint-panel[open] > summary {
  background: linear-gradient(90deg, rgba(105, 197, 223, 0.055), transparent 55%);
}
.blueprint-panel-body {
  background:
    linear-gradient(145deg, rgba(105, 197, 223, 0.025), transparent 28%),
    #0d0f10;
}
.blueprint-panel input[type="checkbox"] {
  accent-color: #69c5df;
  inline-size: 1rem;
  block-size: 1rem;
  flex: 0 0 auto;
}
.blueprint-preview svg { flex-shrink: 0; }
.material-panel { border-color: rgba(105, 197, 223, 0.24) !important; }
.metric-card:nth-child(4n + 1) { border-color: rgba(247, 167, 45, 0.3) !important; }
.metric-card:nth-child(4n + 2) { border-color: rgba(105, 197, 223, 0.3) !important; }
.metric-card:nth-child(4n + 3) { border-color: rgba(116, 183, 104, 0.3) !important; }
.metric-card:nth-child(4n + 4) { border-color: rgba(193, 123, 213, 0.3) !important; }

.app-shell :where([class*="rounded"][class*="border-white/"]):not([data-slot="select-trigger"]):not([role="combobox"]):not(.editable-control):not(.smart-number) {
  border-color: rgba(105, 197, 223, 0.24) !important;
}

.app-shell :where([class*="rounded"][class*="border-white/"]):not([data-slot="select-trigger"]):not([role="combobox"]):not(.editable-control):not(.smart-number)
  :where([class*="rounded"][class*="border-white/"]):not([data-slot="select-trigger"]):not([role="combobox"]):not(.editable-control):not(.smart-number) {
  border-color: rgba(116, 183, 104, 0.24) !important;
}

.factory-totals {
  padding: 0;
  overflow: clip;
  align-self: stretch;
}

.factory-totals-body { background: linear-gradient(145deg, rgba(105, 197, 223, 0.022), transparent 28%); }

.factory-totals-summary {
  padding: 1.25rem !important;
}

.global-chain-master {
  overflow: clip;
  padding: 0 !important;
}

/* Every global and per-product chain-wide panel owns the same responsive
   priority rail. Keeping the size container on the shared panel makes the
   behavior independent of whichever workspace wrapper contains it. */
.chain-master-panel {
  container-type: inline-size;
  overflow: clip;
}

.global-chain-master > .chain-master-panel {
  border: 0 !important;
  border-radius: 0;
  box-shadow: none;
}

.global-chain-master > .chain-master-panel > summary {
  padding: 1.25rem !important;
}

/* Size every chain-wide priority rail from its content. Its right edge remains
   on the shared KPI guide while the longer box grows only towards the left. */
.chain-master-panel .dashboard-summary .summary-trailing {
  width: max-content;
  max-width: 100%;
}

.chain-master-panel .priority-kpi {
  width: max-content;
  min-width: max-content;
  max-width: none;
  flex: 0 0 auto;
}

.chain-master-panel .priority-kpi strong {
  white-space: nowrap;
}

@container (max-width: 48rem) {
  .chain-master-panel .dashboard-summary {
    grid-template-columns: minmax(0, 1fr);
  }

  .chain-master-panel .dashboard-summary .summary-trailing {
    grid-column: 1;
    width: 100%;
  }

  .chain-master-panel .dashboard-summary .priority-kpi {
    max-width: none;
  }
}

/* At physically narrower widths the header keeps the normal typography and
   padding, but may wrap rather than clipping any priority outside its box. */
@container (max-width: 28rem) {
  .chain-master-panel .priority-kpi {
    width: auto;
    min-width: 0;
    height: auto;
    flex: 1 1 auto;
  }

  .chain-master-panel .priority-kpi strong {
    white-space: normal;
  }
}

.global-chain-master > p {
  margin: 0.75rem 1rem 1rem;
}

.stream-split-control {
  background: linear-gradient(135deg, rgba(105, 197, 223, 0.12), rgba(16, 20, 22, 0.98));
  box-shadow: inset 3px 0 0 rgba(105, 197, 223, 0.46), 0 0 20px rgba(105, 197, 223, 0.055);
}

.stream-split-control input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  flex: 0 0 auto;
  accent-color: #69c5df;
}

.product-scope,
.product-chip {
  --product-accent: #f7a72d;
  --product-accent-rgb: 247, 167, 45;
  border-color: rgba(var(--product-accent-rgb), 0.3);
}

.product-scope[data-product-tone="1"],
.product-chip[data-product-tone="1"] {
  --product-accent: #69c5df;
  --product-accent-rgb: 105, 197, 223;
}

.product-scope[data-product-tone="2"],
.product-chip[data-product-tone="2"] {
  --product-accent: #74b768;
  --product-accent-rgb: 116, 183, 104;
}

.product-scope[data-product-tone="3"],
.product-chip[data-product-tone="3"] {
  --product-accent: #c17bd5;
  --product-accent-rgb: 193, 123, 213;
}

.product-scope {
  box-shadow:
    inset 3px 0 0 rgba(var(--product-accent-rgb), 0.48),
    0 18px 60px rgba(0, 0, 0, 0.16);
}

.product-chip[data-active="true"] {
  border-color: rgba(var(--product-accent-rgb), 0.72);
  background: rgba(var(--product-accent-rgb), 0.11);
  color: var(--product-accent);
  box-shadow: 0 0 14px rgba(var(--product-accent-rgb), 0.08);
}

.target-rate-focus {
  border-color: rgba(247, 167, 45, 0.58) !important;
  background:
    linear-gradient(135deg, rgba(247, 167, 45, 0.09), transparent 48%),
    #111315 !important;
  box-shadow:
    inset 3px 0 0 rgba(247, 167, 45, 0.62),
    0 0 24px rgba(247, 167, 45, 0.07);
}

.target-rate-inline {
  border: 2px solid rgba(247, 167, 45, 0.42);
  background: rgba(247, 167, 45, 0.065);
  box-shadow: inset 3px 0 0 rgba(247, 167, 45, 0.52);
}

.chain-node {
  --chain-accent-rgb: 105, 197, 223;
  border-color: rgba(var(--chain-accent-rgb), 0.28);
  box-shadow: inset 2px 0 0 rgba(var(--chain-accent-rgb), 0.36);
}

.chain-node[data-chain-depth="1"] { --chain-accent-rgb: 116, 183, 104; }
.chain-node[data-chain-depth="2"] { --chain-accent-rgb: 193, 123, 213; }
.chain-node[data-chain-depth="3"] { --chain-accent-rgb: 229, 161, 43; }

.chain-node-body {
  border-color: rgba(var(--chain-accent-rgb), 0.2);
  background: linear-gradient(
    115deg,
    rgba(var(--chain-accent-rgb), 0.035),
    transparent 32%
  );
}

.chain-source-row {
  border-color: rgba(139, 145, 151, 0.26);
  box-shadow: inset 2px 0 0 rgba(139, 145, 151, 0.26);
}

.result-hero {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  overflow: hidden;
  border: 2px solid rgba(247, 167, 45, 0.25);
  border-radius: 0.9rem;
  background:
    radial-gradient(circle at 82% 20%, rgba(247, 167, 45, 0.12), transparent 34%),
    linear-gradient(120deg, #171a1d, #111315);
  min-height: 6.25rem;
  padding: 1.1rem;
}

.dashboard-result-header {
  min-height: 6.25rem;
  border-top: 0;
  border-right: 0;
  border-left: 0;
  border-radius: 0;
  padding: 1.25rem;
}

.eyebrow {
  margin-bottom: 0.2rem;
  color: #f7a72d;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.notice-info,
.notice-warning {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  border-radius: 0.7rem;
  padding: 0.7rem 0.8rem;
  font-size: 0.82rem;
  line-height: 1.2rem;
}

.notice-info {
  border: 2px solid rgba(105, 197, 223, 0.25);
  background: rgba(105, 197, 223, 0.055);
  color: #a7cbd5;
}

.notice-warning {
  border: 2px solid rgba(229, 161, 43, 0.27);
  background: rgba(229, 161, 43, 0.055);
  color: #d8ba84;
}

.quality-fluid-footnote {
  width: 100%;
  text-align: right;
  color: rgba(161, 161, 170, 0.52);
  font-size: 0.7rem;
  line-height: 1rem;
}

.badge-orange,
.badge-muted {
  border-radius: 0.32rem;
  padding: 0.35rem 0.55rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.badge-orange {
  border: 1px solid rgba(247, 167, 45, 0.25);
  background: rgba(247, 167, 45, 0.08);
  color: #f7a72d;
}

.badge-muted {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: #aeb5bd;
}

/* Help is a dense working manual, not a landing page. */
.help-workspace {
  min-width: 0;
  padding: 1rem 1.5rem 3rem;
}

.help-loading {
  display: flex;
  min-height: 16rem;
  align-items: center;
  justify-content: center;
  color: #f7a72d;
}

.help-layout {
  display: grid;
  width: min(100%, 1580px);
  min-width: 0;
  margin: 0 auto;
  grid-template-columns: minmax(13rem, 17rem) minmax(0, 1fr);
  align-items: start;
  gap: 1rem;
}

.help-sidebar {
  position: sticky;
  top: 1rem;
  min-width: 0;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.help-sidebar-card,
.help-hero,
.help-calculator-jump,
.help-quick-start,
.help-topic,
.help-legal-card {
  border: 1px solid rgba(105, 197, 223, 0.22);
  background: rgba(17, 19, 21, 0.96);
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.16);
}

.help-sidebar-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.15rem;
  border-radius: 0.8rem;
  padding: 0.7rem;
}

.help-sidebar-label,
.help-eyebrow {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.help-sidebar-label {
  padding: 0.35rem 0.45rem 0.55rem;
  color: #f7a72d;
}

.help-toc-link {
  display: grid;
  min-width: 0;
  grid-template-columns: 1.8rem minmax(0, 1fr);
  align-items: start;
  gap: 0.35rem;
  border-radius: 0.45rem;
  padding: 0.44rem 0.45rem;
  color: #aeb5bd;
  font-size: 0.82rem;
  line-height: 1.15rem;
  text-decoration: none;
  overflow-wrap: anywhere;
  transition: background-color 160ms ease, color 160ms ease;
}

.help-toc-link span {
  color: #65707a;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
}

.help-toc-link:hover,
.help-toc-link:focus-visible {
  background: rgba(247, 167, 45, 0.08);
  color: #f7c16e;
  outline: none;
}

.help-content {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 1rem;
}

.help-hero {
  display: grid;
  min-width: 0;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  border-color: rgba(247, 167, 45, 0.36);
  border-radius: 1rem;
  padding: 1.25rem;
  background:
    linear-gradient(125deg, rgba(247, 167, 45, 0.085), transparent 35%),
    rgba(17, 19, 21, 0.97);
}

.help-hero-mark {
  display: flex;
  width: 3.25rem;
  height: 3.25rem;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(247, 167, 45, 0.35);
  border-radius: 0.75rem;
  background: rgba(247, 167, 45, 0.1);
  color: #f7a72d;
}

.help-eyebrow {
  color: #f7a72d;
}

.help-hero h2 {
  margin-top: 0.28rem;
  color: #f5f5f5;
  font-size: clamp(1.25rem, 2.3vw, 1.85rem);
  font-weight: 720;
  line-height: 1.18;
  text-wrap: balance;
}

.help-hero p:not(.help-eyebrow) {
  max-width: 68rem;
  margin-top: 0.55rem;
  color: #aeb5bd;
  font-size: 0.95rem;
  line-height: 1.55rem;
}

.help-release-badges {
  display: flex;
  max-width: 18rem;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.45rem;
}

.help-release-badges span {
  max-width: 100%;
  white-space: normal;
  text-align: right;
  overflow-wrap: anywhere;
}

.help-calculator-jump,
.help-quick-start {
  min-width: 0;
  border-radius: 1rem;
  padding: 1rem;
}

.help-section-heading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #f7a72d;
}

.help-section-heading h3 {
  color: #e9ecef;
  font-size: 1rem;
  font-weight: 650;
}

.help-calculator-grid {
  display: grid;
  min-width: 0;
  margin-top: 0.8rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13.5rem), 1fr));
  gap: 0.55rem;
}

.help-calculator-link {
  min-width: 0;
}

.help-calculator-link:hover,
.help-calculator-link:focus-visible,
.help-inline-action:hover,
.help-inline-action:focus-visible {
  border-color: rgba(247, 167, 45, 0.45);
  background: rgba(247, 167, 45, 0.1);
}

.help-route-icon {
  display: inline-flex;
  color: #69c5df;
}

.help-route-icon > svg {
  width: 1rem;
  height: 1rem;
}

.help-quick-start > p {
  margin-top: 0.65rem;
  color: #aeb5bd;
  font-size: 0.9rem;
  line-height: 1.45rem;
}

.help-step-grid {
  display: grid;
  min-width: 0;
  margin-top: 0.85rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}

.help-step-grid li {
  display: grid;
  min-width: 0;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 0.6rem;
  border: 1px solid rgba(116, 183, 104, 0.2);
  border-radius: 0.65rem;
  background: rgba(116, 183, 104, 0.045);
  padding: 0.75rem;
}

.help-step-grid li > span,
.help-topic-number {
  display: inline-flex;
  width: 1.8rem;
  height: 1.8rem;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(116, 183, 104, 0.35);
  border-radius: 0.4rem;
  background: rgba(116, 183, 104, 0.09);
  color: #93ca89;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  font-weight: 700;
}

.help-step-grid p {
  min-width: 0;
  color: #d5d9dd;
  font-size: 0.88rem;
  line-height: 1.35rem;
  overflow-wrap: anywhere;
}

.help-guide-heading {
  padding: 0 0.25rem;
  color: #8e969e;
  font-size: 0.85rem;
  line-height: 1.3rem;
}

.help-topic-list {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.65rem;
}

.help-topic {
  min-width: 0;
  scroll-margin-top: 1rem;
  overflow: clip;
  border-radius: 0.85rem;
}

.help-topic > summary {
  padding: 0.85rem 1rem !important;
}

.help-topic .summary-leading > span:last-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.18rem;
}

.help-topic strong {
  color: #eceff1;
  font-size: 0.95rem;
  font-weight: 650;
  line-height: 1.25rem;
  overflow-wrap: anywhere;
}

.help-topic small {
  color: #8f979f;
  font-size: 0.8rem;
  line-height: 1.2rem;
  white-space: normal;
  overflow-wrap: anywhere;
}

.help-topic-body {
  border-top: 1px solid rgba(255, 255, 255, 0.055);
  padding: 0.9rem 1rem 1rem 3.8rem;
}

.help-topic-body ul {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.65rem;
}

.help-topic-body li {
  display: grid;
  min-width: 0;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 0.55rem;
  color: #c4c9ce;
  font-size: 0.9rem;
  line-height: 1.45rem;
}

.help-topic-body li svg {
  margin-top: 0.2rem;
  color: #74b768;
}

.help-topic-body li span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.help-inline-action {
  max-width: 100%;
  margin-top: 0.9rem;
}

.help-panel-details {
  display: grid;
  gap: 1rem;
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.help-panel-details dt {
  margin-bottom: 0.3rem;
  color: #f7c16e;
  font-size: 0.78rem;
  font-weight: 600;
}

.help-panel-details dd {
  max-width: 85ch;
  margin: 0;
  color: #c4c9ce;
  font-size: 0.9rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.help-legal-grid {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}

.help-legal-card {
  display: grid;
  min-width: 0;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 0.7rem;
  border-radius: 0.8rem;
  padding: 0.9rem;
}

.help-legal-card[data-tone="orange"] { border-color: rgba(247, 167, 45, 0.28); }
.help-legal-card[data-tone="blue"] { border-color: rgba(105, 197, 223, 0.28); }
.help-legal-card[data-tone="warning"] { border-color: rgba(229, 161, 43, 0.28); }
.help-legal-card[data-tone="orange"] > svg { color: #f7a72d; }
.help-legal-card[data-tone="blue"] > svg { color: #69c5df; }
.help-legal-card[data-tone="warning"] > svg { color: #e5a12b; }

.help-legal-card h3 {
  color: #e4e7e9;
  font-size: 0.9rem;
  font-weight: 650;
  line-height: 1.25rem;
}

.help-legal-card p {
  margin-top: 0.35rem;
  color: #9da5ad;
  font-size: 0.8rem;
  line-height: 1.25rem;
  overflow-wrap: anywhere;
}

.release-footer {
  display: flex;
  width: min(calc(100% - 2rem), 1900px);
  min-width: 0;
  max-width: 100%;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  flex: 0 0 auto;
  margin: 0 auto;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.5rem 0.75rem 0.65rem;
  color: #747d85;
  font-size: 0.75rem;
  line-height: 1.2rem;
  overflow-wrap: anywhere;
}

.release-footer > * {
  min-width: 0;
  max-width: 100%;
}

.release-footer a {
  color: #9da5ad;
  overflow-wrap: anywhere;
  text-decoration: underline;
  text-decoration-color: rgba(247, 167, 45, 0.35);
  text-underline-offset: 0.2em;
}

.release-footer a:hover,
.release-footer a:focus-visible {
  color: #f7c16e;
  text-decoration-color: currentColor;
}

@media (max-width: 1120px) {
  .help-layout { grid-template-columns: minmax(12rem, 14rem) minmax(0, 1fr); }
  .help-step-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .help-legal-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .help-layout { grid-template-columns: minmax(0, 1fr); }
  .help-sidebar { display: none; }
}

@media (max-width: 640px) {
  .help-workspace { padding: 0.75rem 0.75rem 2rem; }
  .help-hero { grid-template-columns: minmax(0, 1fr); }
  .help-hero-mark { width: 2.75rem; height: 2.75rem; }
  .help-release-badges { max-width: none; align-items: flex-start; }
  .help-release-badges span { text-align: left; }
  .help-step-grid { grid-template-columns: minmax(0, 1fr); }
  .help-topic-body { padding: 0.85rem 0.9rem 0.95rem; }
  .help-topic > summary { padding: 0.8rem 0.85rem !important; }
}

@media (max-width: 760px) {
  .collapsible-summary,
  [data-totals-section] > summary,
  [data-totals-entry] > summary {
    min-height: 4.35rem;
  }

  .summary-kpi { min-width: 6.2rem; }
  .priority-kpi { min-width: 0; max-width: 46%; }
  .priority-kpi strong { font-size: 0.72rem; line-height: 0.95rem; }
  .dashboard-summary {
    grid-template-columns: minmax(0, 1fr);
  }
  .dashboard-summary .summary-trailing,
  .factory-totals-summary .summary-trailing {
    grid-column: 1;
    width: 100%;
  }
  .dashboard-summary .priority-kpi { max-width: none; }
  .factory-totals-section-summary .summary-trailing {
    width: min(10rem, 43vw);
  }
  .factory-totals-section-summary .summary-kpi {
    width: 100%;
  }
  .totals-toolbar { grid-template-columns: minmax(0, 1fr); }
  .totals-unit-picker { max-width: 7rem; }
}

@media (min-width: 1024px) {
  .app-shell {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  .workspace-grid {
    grid-template-columns: 470px minmax(0, 1fr);
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    padding: 1rem 1.5rem;
  }

  .workspace-settings,
  .workspace-results {
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding-right: 0.35rem;
    padding-bottom: 2rem;
  }
}

@media (max-width: 1023px) {
  .app-shell {
    height: auto;
    overflow-y: visible;
  }

  .calculator-stage,
  .calculator-route {
    display: block;
    overflow: visible;
  }

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

  .result-hero {
    align-items: flex-start;
  }
}
