:root {
  color-scheme: light dark;
  --accent: #b4232c;
  --accent-strong: #8d1820;
  --accent-soft: #fbeaec;
  --ink: #28313b;
  --heading: #12171d;
  --muted: #66717d;
  --subtle: #89939e;
  --line: #d6dce3;
  --line-strong: #bec6cf;
  --panel: #ffffff;
  --panel-alt: #f6f8fa;
  --page: #eef1f4;
  --control: #ffffff;
  --header-text: #12171d;
  --good: #176b43;
  --good-soft: #e8f4ed;
  --warn: #93550b;
  --warn-soft: #fff3da;
  --bad: #b4232c;
  --bad-soft: #fbeaec;
  --missing: #657180;
  --missing-soft: #edf0f3;
  --rig-body: #6d7d8d;
  --rig-body-dark: #475767;
  --rig-trailer: #d9dee3;
  --rig-detail: #303b45;
  --rig-window: #b9d2dd;
  --rig-glass-line: #708d99;
  --rig-wheel: #252c33;
  --rig-hub: #c9d0d7;
  --rig-ground: #b7c0c9;
  --dialog-backdrop: rgba(16, 22, 29, 0.62);
  --shadow-menu: 0 16px 44px rgba(22, 30, 38, 0.18);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --accent: #dc5962;
  --accent-strong: #ff8f96;
  --accent-soft: #3b2226;
  --ink: #e2e6ea;
  --heading: #ffffff;
  --muted: #a8b0ba;
  --subtle: #858f9a;
  --line: #343c45;
  --line-strong: #4a5561;
  --panel: #191e24;
  --panel-alt: #22282f;
  --page: #11151a;
  --control: #14191e;
  --header-text: #ffffff;
  --good: #6dcc98;
  --good-soft: #19372a;
  --warn: #f2ba58;
  --warn-soft: #3b2f1c;
  --bad: #ff858c;
  --bad-soft: #442328;
  --missing: #b4bdc7;
  --missing-soft: #2b323a;
  --rig-body: #8494a4;
  --rig-body-dark: #5e6f80;
  --rig-trailer: #697887;
  --rig-detail: #dbe2e8;
  --rig-window: #435e69;
  --rig-glass-line: #91adb8;
  --rig-wheel: #0d1013;
  --rig-hub: #9ca8b3;
  --rig-ground: #46515c;
  --dialog-backdrop: rgba(0, 0, 0, 0.72);
  --shadow-menu: 0 18px 48px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page);
}

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

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

button,
summary,
select,
input[type="checkbox"] {
  cursor: pointer;
}

button:disabled,
select:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

button,
select,
input {
  border-radius: 6px;
}

button:focus-visible,
summary:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 42%, transparent);
  outline-offset: 2px;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon,
.section-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.app-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
}

.app-header {
  position: relative;
  z-index: 20;
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px clamp(16px, 3vw, 32px);
  border-top: 4px solid var(--accent);
  border-bottom: 1px solid var(--line);
  color: var(--header-text);
  background: var(--panel);
}

.brand-block {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 6px;
  color: #ffffff;
  background: var(--accent);
  font-size: 0.84rem;
  font-weight: 900;
  letter-spacing: 0;
}

.brand-block h1,
.brand-block p {
  margin: 0;
}

.brand-block h1 {
  overflow-wrap: anywhere;
  color: var(--heading);
  font-size: 1.25rem;
  line-height: 1.15;
}

.brand-block p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

.header-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.header-button,
.icon-button,
.utility-menu-popover button,
.save-button,
.danger-text-button {
  min-height: 44px;
  border: 0;
  font-weight: 750;
}

.header-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--panel-alt);
}

.header-button:hover,
.icon-button:hover {
  background: var(--missing-soft);
}

.icon-button {
  display: inline-grid;
  width: 44px;
  padding: 0;
  place-items: center;
  color: var(--ink);
  background: transparent;
}

.utility-menu {
  position: relative;
}

.utility-menu > summary {
  list-style: none;
}

.utility-menu > summary::-webkit-details-marker {
  display: none;
}

.utility-menu[open] > summary {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.utility-menu-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  width: 240px;
  overflow: hidden;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow-menu);
}

.utility-menu-popover button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  padding: 0 11px;
  border-radius: 5px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.utility-menu-popover button:hover {
  background: var(--panel-alt);
}

main {
  display: grid;
  gap: 16px;
  padding: 20px clamp(14px, 3vw, 32px) 32px;
}

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

.panel-heading {
  display: flex;
  min-width: 0;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.panel-heading h2,
.panel-heading p,
.status-panel h2,
.status-panel p {
  margin: 0;
}

.panel-heading h2 {
  color: var(--heading);
  font-size: 1.15rem;
  line-height: 1.25;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.configuration-summary,
.estimate-note {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
  text-align: right;
}

.setup-grid {
  display: grid;
  overflow: hidden;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.setup-card {
  display: grid;
  min-width: 0;
  gap: 12px;
  padding: 15px;
  border-right: 1px solid var(--line);
}

.setup-card:last-child {
  border-right: 0;
}

.setup-card-top,
.setup-heading,
.setup-step,
.setup-state,
.setup-controls {
  display: flex;
  min-width: 0;
  align-items: center;
}

.setup-card-top {
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.setup-heading {
  display: grid;
  flex: 1 1 auto;
  gap: 8px;
}

.setup-step {
  gap: 9px;
  color: var(--heading);
}

.setup-step > span {
  display: grid;
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 850;
}

.setup-step strong {
  font-size: 0.9rem;
}

.setup-state {
  gap: 5px;
  color: var(--missing);
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.setup-state .icon {
  width: 16px;
  height: 16px;
}

.setup-state.good {
  color: var(--good);
}

.setup-state.warn {
  color: var(--warn);
}

.setup-identity {
  display: grid;
  min-height: 40px;
  align-content: start;
  gap: 2px;
}

.setup-identity strong,
.setup-identity span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.setup-identity strong {
  color: var(--heading);
  font-size: 1rem;
}

.setup-identity span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
}

.setup-controls {
  gap: 6px;
}

.setup-controls select,
.form-field input,
.form-field select,
.number-control {
  border: 1px solid var(--line);
  color: var(--heading);
  background: var(--control);
}

.setup-controls select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0 34px 0 10px;
  font-size: 0.84rem;
  font-weight: 700;
}

.secondary-icon {
  flex: 0 0 44px;
  border: 1px solid var(--line);
  color: var(--accent-strong);
  background: var(--panel-alt);
}

.status-panel,
.rig-panel,
.tool-section,
.recommendation-panel,
.fine-print {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.status-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border-left: 5px solid var(--missing);
}

.status-panel.good {
  border-left-color: var(--good);
}

.status-panel.warn {
  border-left-color: var(--warn);
  background: var(--warn-soft);
}

.status-panel.bad {
  border-color: color-mix(in srgb, var(--bad) 42%, var(--line));
  border-left-color: var(--bad);
  background: var(--bad-soft);
}

.status-symbol {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 6px;
  color: var(--missing);
  background: var(--missing-soft);
}

.status-panel.good .status-symbol {
  color: var(--good);
  background: var(--good-soft);
}

.status-panel.warn .status-symbol {
  color: var(--warn);
  background: color-mix(in srgb, var(--warn-soft) 70%, var(--panel));
}

.status-panel.bad .status-symbol {
  color: var(--bad);
  background: color-mix(in srgb, var(--bad-soft) 70%, var(--panel));
}

.status-copy {
  min-width: 0;
}

.status-panel h2 {
  margin-top: 1px;
  color: var(--heading);
  font-size: 1.3rem;
  line-height: 1.2;
}

#overallMessage {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.88rem;
}

.status-badge {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 0 11px;
  border: 1px solid currentColor;
  border-radius: 6px;
  color: var(--missing);
  font-size: 0.76rem;
  font-weight: 850;
  white-space: nowrap;
}

.status-badge.good {
  color: var(--good);
}

.status-badge.warn {
  color: var(--warn);
}

.status-badge.bad {
  color: var(--bad);
}

.rig-panel {
  overflow: hidden;
}

.rig-heading {
  align-items: center;
  padding: 15px 17px 13px;
}

.rig-key {
  display: grid;
  grid-template-columns: repeat(3, minmax(92px, 1fr));
  border: 1px solid var(--line);
  border-radius: 6px;
}

.rig-key > span {
  display: grid;
  min-width: 0;
  gap: 1px;
  padding: 6px 10px;
  border-right: 1px solid var(--line);
}

.rig-key > span:last-child {
  border-right: 0;
}

.rig-key small,
.rig-key strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rig-key small {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 750;
  text-transform: uppercase;
}

.rig-key strong {
  color: var(--heading);
  font-size: 0.75rem;
}

.rig-visual {
  position: relative;
  display: grid;
  min-height: 205px;
  overflow: hidden;
  place-items: center;
  border-top: 1px solid var(--line);
  background-color: var(--panel-alt);
}

.rig-visual::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: color-mix(in srgb, var(--panel-alt) 80%, transparent);
  content: "";
}

.rig-visual svg {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: auto;
  min-height: 190px;
}

.rig-part.is-placeholder {
  opacity: 0.24;
}

.rig-ground {
  fill: none;
  stroke: var(--rig-ground);
  stroke-linecap: round;
  stroke-width: 4;
}

.rig-body {
  fill: var(--rig-body);
  stroke: var(--rig-detail);
  stroke-linejoin: round;
  stroke-width: 4;
}

.rig-body-dark {
  fill: var(--rig-body-dark);
  stroke: var(--rig-detail);
  stroke-linejoin: round;
  stroke-width: 4;
}

.rig-trailer-body {
  fill: var(--rig-trailer);
  stroke: var(--rig-detail);
  stroke-linejoin: round;
  stroke-width: 4;
}

.rig-window {
  fill: var(--rig-window);
  stroke: var(--rig-glass-line);
  stroke-width: 3;
}

.rig-detail,
.rig-frame,
.rig-hitch-line,
.rig-load-line {
  fill: none;
  stroke: var(--rig-detail);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rig-detail,
.rig-frame {
  stroke-width: 4;
}

.rig-load-line {
  stroke-width: 3;
}

.rig-hitch-line {
  stroke-width: 7;
}

.rig-hitch-line.distributed {
  stroke-width: 5;
}

.rig-hitch-line.incompatible {
  stroke: var(--bad);
  stroke-dasharray: 10 10;
}

.rig-tire {
  fill: var(--rig-wheel);
  stroke: var(--rig-detail);
  stroke-width: 4;
}

.rig-hub {
  fill: var(--rig-hub);
  stroke: var(--rig-detail);
  stroke-width: 3;
}

.rig-accent {
  fill: var(--accent);
  stroke: var(--rig-detail);
  stroke-width: 3;
}

.rig-status-dot {
  fill: var(--missing);
  stroke: var(--panel-alt);
  stroke-width: 5;
}

.rig-visual[data-status="good"] .rig-status-dot {
  fill: var(--good);
}

.rig-visual[data-status="warn"] .rig-status-dot {
  fill: var(--warn);
}

.rig-visual[data-status="bad"] .rig-status-dot {
  fill: var(--bad);
}

.rig-status-ring {
  fill: none;
  stroke: var(--missing);
  stroke-width: 2;
}

.rig-visual[data-status="good"] .rig-status-ring {
  stroke: var(--good);
}

.rig-visual[data-status="warn"] .rig-status-ring {
  stroke: var(--warn);
}

.rig-visual[data-status="bad"] .rig-status-ring {
  stroke: var(--bad);
}

.rating-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line);
}

.rating-cell {
  display: grid;
  min-width: 0;
  gap: 8px;
  padding: 13px 15px 15px;
  border-right: 1px solid var(--line);
}

.rating-cell:last-child {
  border-right: 0;
}

.rating-label,
.rating-values {
  display: flex;
  min-width: 0;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.rating-label span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.rating-label small {
  overflow: visible;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: right;
  text-overflow: clip;
  white-space: normal;
}

.rating-values strong {
  overflow-wrap: anywhere;
  color: var(--heading);
  font-size: 1.32rem;
  line-height: 1.1;
}

.rating-values span {
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

.rating-values b {
  color: var(--ink);
}

.utilization-track {
  width: 100%;
  height: 5px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--missing-soft);
}

.utilization-track > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--missing);
  transition: width 180ms ease;
}

.rating-cell.good .utilization-track > span,
.result-card.good .utilization-track > span {
  background: var(--good);
}

.rating-cell.warn .utilization-track > span,
.result-card.warn .utilization-track > span {
  background: var(--warn);
}

.rating-cell.bad .utilization-track > span,
.result-card.bad .utilization-track > span {
  background: var(--bad);
}

.calculator-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.72fr) minmax(0, 1.28fr);
  gap: 16px;
  align-items: start;
}

.tool-section,
.recommendation-panel {
  display: grid;
  gap: 15px;
  padding: 17px;
}

.trip-section {
  position: sticky;
  top: 12px;
}

.input-grid {
  display: grid;
  gap: 12px;
}

.input-field {
  display: grid;
  min-width: 0;
  gap: 6px;
  color: var(--heading);
  font-size: 0.84rem;
  font-weight: 750;
}

.number-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  overflow: hidden;
}

.number-control input {
  width: 100%;
  min-width: 0;
  height: 52px;
  padding: 0 12px;
  border: 0;
  border-radius: 0;
  color: var(--heading);
  background: transparent;
  font-size: 1.35rem;
  font-weight: 850;
}

.number-control small {
  display: grid;
  min-width: 44px;
  align-self: stretch;
  place-items: center;
  border-left: 1px solid var(--line);
  color: var(--muted);
  background: var(--panel-alt);
  font-size: 0.75rem;
  font-weight: 800;
}

.toggle-row {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  gap: 10px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-alt);
}

.toggle-row input,
.checkbox-field input {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

.toggle-row > span {
  display: grid;
  gap: 2px;
}

.toggle-row strong {
  color: var(--heading);
  font-size: 0.82rem;
}

.toggle-row small {
  color: var(--muted);
  font-size: 0.72rem;
}

.result-counts {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

.result-counts span {
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  background: var(--panel-alt);
  font-size: 0.68rem;
  font-weight: 800;
}

.result-counts .bad {
  border-color: color-mix(in srgb, var(--bad) 45%, var(--line));
  color: var(--bad);
}

.result-counts .warn {
  border-color: color-mix(in srgb, var(--warn) 45%, var(--line));
  color: var(--warn);
}

.result-counts .good {
  border-color: color-mix(in srgb, var(--good) 45%, var(--line));
  color: var(--good);
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.result-card {
  display: grid;
  min-width: 0;
  gap: 9px;
  align-content: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--missing);
  border-radius: 6px;
  background: var(--panel-alt);
}

.result-card.good {
  border-left-color: var(--good);
}

.result-card.warn {
  border-left-color: var(--warn);
}

.result-card.bad {
  border-left-color: var(--bad);
}

.result-card-header,
.result-metrics {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.result-card-header strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--heading);
  font-size: 0.86rem;
}

.result-state {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 4px;
  color: var(--missing);
  font-size: 0.68rem;
  font-weight: 850;
}

.result-state .icon {
  width: 14px;
  height: 14px;
}

.result-card.good .result-state {
  color: var(--good);
}

.result-card.warn .result-state {
  color: var(--warn);
}

.result-card.bad .result-state {
  color: var(--bad);
}

.result-value {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--heading);
  font-size: 1.05rem;
  font-weight: 850;
  line-height: 1.2;
}

.result-percent {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  white-space: nowrap;
}

.result-card > small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
}

.result-action {
  margin: 0;
  padding-top: 8px;
  border-top: 1px solid color-mix(in srgb, var(--bad) 28%, var(--line));
  color: var(--bad);
  font-size: 0.72rem;
  font-weight: 750;
}

.result-card:not(.has-utilization) .utilization-track {
  display: none;
}

.recommendation-panel {
  grid-template-columns: minmax(170px, 0.28fr) minmax(0, 1fr);
  align-items: start;
}

.recommendation-heading {
  align-items: flex-start;
}

.recommendation-heading .section-icon {
  color: var(--accent);
}

#recommendationList {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: recommendation;
}

#recommendationList li {
  position: relative;
  min-height: 32px;
  padding: 7px 10px 7px 38px;
  border-left: 2px solid var(--line-strong);
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 650;
  counter-increment: recommendation;
}

#recommendationList li::before {
  position: absolute;
  top: 6px;
  left: 9px;
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 50%;
  color: var(--muted);
  background: var(--missing-soft);
  content: counter(recommendation);
  font-size: 0.66rem;
  font-weight: 850;
}

.fine-print {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 15px;
  color: var(--muted);
}

.fine-print .icon {
  width: 18px;
  height: 18px;
  margin-top: 1px;
}

.fine-print p {
  margin: 0;
  font-size: 0.76rem;
}

dialog {
  width: min(760px, calc(100vw - 28px));
  height: min(860px, calc(100dvh - 32px));
  max-height: calc(100dvh - 32px);
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: var(--shadow-menu);
}

dialog::backdrop {
  background: var(--dialog-backdrop);
}

.entity-form {
  display: grid;
  height: 100%;
  min-height: 0;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  background: var(--panel);
}

.dialog-bar {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  grid-row: 1;
}

.dialog-bar > div {
  min-width: 0;
}

.dialog-bar span {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 800;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.dialog-bar h2 {
  margin: 1px 0 0;
  overflow: hidden;
  color: var(--heading);
  font-size: 1.12rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog-close {
  color: var(--muted);
}

.save-button,
.danger-text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 13px;
}

.save-button {
  color: #ffffff;
  background: var(--accent);
}

.save-button:hover {
  background: var(--accent-strong);
}

.save-button .icon,
.danger-text-button .icon {
  width: 17px;
  height: 17px;
}

.form-error {
  grid-row: 2;
  margin: 12px 16px 0;
  padding: 9px 11px;
  border: 1px solid color-mix(in srgb, var(--bad) 45%, var(--line));
  border-radius: 6px;
  color: var(--bad);
  background: var(--bad-soft);
  font-size: 0.8rem;
  font-weight: 750;
}

.entity-fields {
  display: grid;
  min-height: 0;
  grid-row: 3;
  gap: 20px;
  overflow-y: auto;
  padding: 18px;
  overscroll-behavior: contain;
}

.form-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-group-heading {
  display: grid;
  grid-column: 1 / -1;
  gap: 2px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.form-group-heading strong {
  color: var(--heading);
  font-size: 0.9rem;
}

.form-group-heading small {
  color: var(--muted);
  font-size: 0.72rem;
}

.form-field {
  display: grid;
  min-width: 0;
  gap: 6px;
  align-content: start;
}

.form-field.span-full,
.checkbox-field.span-full {
  grid-column: 1 / -1;
}

.form-field > span {
  color: var(--heading);
  font-size: 0.8rem;
  font-weight: 750;
}

.form-field input,
.form-field select {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 0 11px;
  font-size: 0.95rem;
  font-weight: 700;
}

.form-field > small {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 650;
}

.form-field.invalid input,
.form-field.invalid select {
  border-color: var(--bad);
}

.checkbox-field {
  display: flex;
  min-height: 50px;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--heading);
  background: var(--panel-alt);
  font-size: 0.82rem;
  font-weight: 750;
}

.conditional-field[hidden] {
  display: none;
}

.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 15px max(11px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--panel-alt);
  grid-row: 4;
}

.dialog-footer p {
  max-width: 52ch;
  margin: 0;
  color: var(--muted);
  font-size: 0.7rem;
}

.danger-text-button {
  flex: 0 0 auto;
  color: var(--bad);
  background: transparent;
}

.danger-text-button:hover {
  background: var(--bad-soft);
}

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

@media (max-width: 1040px) {
  .rig-key {
    grid-template-columns: repeat(3, minmax(80px, 1fr));
  }

  .calculator-grid {
    grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.2fr);
  }
}

@media (max-width: 820px) {
  main {
    padding-top: 16px;
  }

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

  .setup-card {
    grid-template-columns: minmax(0, 0.9fr) minmax(190px, 1.1fr);
    align-items: center;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .setup-card:last-child {
    border-bottom: 0;
  }

  .setup-card-top {
    grid-column: 1;
  }

  .setup-controls {
    grid-column: 2;
  }

  .rig-heading {
    align-items: flex-start;
  }

  .rig-key {
    width: min(430px, 58%);
  }

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

  .rating-cell:nth-child(2) {
    border-right: 0;
  }

  .rating-cell:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }

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

  .trip-section {
    position: static;
  }

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

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

@media (max-width: 620px) {
  .app-header {
    min-height: 64px;
    padding-inline: 12px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
  }

  .brand-block h1 {
    font-size: 1.05rem;
  }

  .brand-block p {
    display: none;
  }

  .header-button {
    width: 44px;
    padding: 0;
    justify-content: center;
  }

  .header-button span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }

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

  .configuration-heading {
    align-items: flex-start;
  }

  .configuration-summary {
    display: none;
  }

  .setup-card {
    gap: 10px;
    padding: 12px;
  }

  .status-panel {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    padding: 12px;
  }

  .status-symbol {
    width: 36px;
    height: 36px;
  }

  .status-panel h2 {
    font-size: 1.12rem;
  }

  #overallMessage {
    font-size: 0.8rem;
  }

  .status-badge {
    grid-column: 2;
    justify-self: start;
  }

  .rig-heading {
    display: grid;
  }

  .rig-key {
    width: 100%;
  }

  .rig-key > span {
    padding-inline: 7px;
  }

  .rig-visual {
    min-height: 150px;
  }

  .rig-visual svg {
    min-height: 145px;
  }

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

  .rating-cell,
  .rating-cell:nth-child(2) {
    border-right: 0;
    border-top: 1px solid var(--line);
  }

  .rating-cell:first-child {
    border-top: 0;
  }

  .rating-cell {
    gap: 6px;
    padding: 10px 12px;
  }

  .rating-values strong {
    font-size: 1.12rem;
  }

  .panel-heading {
    align-items: flex-start;
  }

  .estimate-note {
    font-size: 0.7rem;
  }

  .input-grid,
  .results-grid {
    grid-template-columns: 1fr;
  }

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

  .recommendation-heading {
    align-items: center;
  }

  dialog {
    width: 100%;
    height: 96dvh;
    max-width: none;
    max-height: 96dvh;
    margin: auto 0 0;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 8px 8px 0 0;
  }

  .entity-form {
    height: 100%;
  }

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

  .form-field.span-full,
  .checkbox-field.span-full {
    grid-column: 1;
  }

  .dialog-footer p {
    display: none;
  }

  .dialog-footer {
    justify-content: flex-end;
  }
}

@media (max-width: 480px) {
  .setup-card {
    grid-template-columns: minmax(0, 1fr);
  }

  .setup-card-top,
  .setup-controls {
    grid-column: 1;
  }

  .setup-heading {
    gap: 4px;
  }

  .setup-identity {
    min-height: 19px;
  }

  .setup-identity strong {
    display: none;
  }

  .results-grid {
    gap: 7px;
  }

  .result-card {
    gap: 6px;
    padding: 10px;
  }

  .result-card > small,
  .result-action {
    line-height: 1.3;
  }
}

@media (max-width: 360px) {
  .brand-block {
    gap: 8px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    font-size: 0.72rem;
  }

  .brand-block h1 {
    font-size: 0.96rem;
  }

  .header-actions {
    gap: 2px;
  }

  #overallMessage {
    display: none;
  }

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

  .setup-card-top,
  .setup-controls {
    grid-column: 1;
  }

  .setup-heading {
    grid-template-columns: 25px minmax(0, 1fr);
    align-items: start;
    gap: 7px;
  }

  .setup-step {
    display: contents;
  }

  .setup-step strong {
    display: none;
  }

  .setup-identity {
    grid-column: 2;
    min-height: 38px;
  }

  .setup-card[data-kind="vehicle"] .setup-identity span::before {
    content: "Vehicle / ";
  }

  .setup-card[data-kind="hitch"] .setup-identity span::before {
    content: "Hitch / ";
  }

  .setup-card[data-kind="trailer"] .setup-identity span::before {
    content: "Trailer / ";
  }

  .panel-heading h2 {
    font-size: 1.05rem;
  }

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

  .rig-key strong {
    font-size: 0.67rem;
  }

  .dialog-bar {
    gap: 7px;
    padding-inline: 8px;
  }

  .save-button {
    padding-inline: 10px;
  }

  .save-button .icon {
    display: none;
  }
}
