/* Layout for the reusable calculator card: mobile-first single column,
   desktop two-column (inputs | results) via CSS grid only — DOM order
   never changes between breakpoints. */

.calculator-header h1 {
  margin-bottom: var(--space-2);
}

.calculator-purpose {
  font-size: var(--font-size-lg);
  color: var(--color-text-muted);
  max-width: 68ch;
  margin-bottom: var(--space-5);
  line-height: var(--line-height-base);
}

.calculator-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
  padding: var(--space-5);
  margin-bottom: var(--space-7);
}

@media (min-width: 960px) {
  .calculator-card {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "mode mode"
      "form results";
    column-gap: var(--space-6);
    align-items: start;
  }

  .mode-switch {
    grid-area: mode;
  }

  .calculator-form {
    grid-area: form;
  }

  .calculator-results {
    grid-area: results;
  }
}

/* Results */
.calculator-results {
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-5);
  margin-top: var(--space-5);
}

@media (min-width: 960px) {
  .calculator-results {
    border-top: 0;
    border-left: 1px solid var(--color-border);
    padding-top: 0;
    padding-left: var(--space-6);
    margin-top: 0;
  }
}

.result-method {
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-3);
  background: var(--color-accent-bg);
  display: inline-block;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(15, 118, 110, 0.15);
}

.result-summary {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

@media (min-width: 480px) {
  .result-summary {
    grid-template-columns: repeat(2, 1fr);
  }
}

.result-summary--secondary {
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-4);
}

.result-figure {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.result-figure--primary {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-sm);
}

.result-figure--primary .result-value {
  font-size: var(--font-size-h2);
  color: var(--color-primary);
}

.result-figure--primary .result-label {
  font-weight: 700;
  color: var(--color-text-muted);
}

.result-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-subtle);
}

.result-value {
  font-size: var(--font-size-xl);
  font-weight: 800;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
  overflow-wrap: break-word;
}

.result-hint {
  font-size: var(--font-size-xs);
  color: var(--color-text-subtle);
}

.result-breakdown {
  margin-bottom: var(--space-5);
}

.result-breakdown h2 {
  font-size: var(--font-size-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-subtle);
  margin: 0 0 var(--space-3);
}

.result-driver {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
  line-height: var(--line-height-base);
}

.breakdown-list {
  list-style: none;
  margin: 0 0 var(--space-4);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.breakdown-list__row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: var(--font-size-sm);
}

.breakdown-list__row-header {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  font-weight: 500;
}

.breakdown-list__bar-track {
  height: 10px;
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  overflow: hidden;
  margin-top: 2px;
  border: 1px solid var(--color-border);
}

.breakdown-list__bar-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-sm);
  transition: width 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

.breakdown-list__row--largest .breakdown-list__bar-fill {
  background: var(--color-accent);
}

.result-error {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border: 1px solid rgba(220, 38, 38, 0.2);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-top: var(--space-3);
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.result-note {
  background: var(--color-warning-bg);
  border: 1px solid rgba(217, 119, 6, 0.2);
  border-left: 4px solid var(--color-warning);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  line-height: var(--line-height-base);
}

.result-comparison-note {
  font-size: var(--font-size-sm);
  color: var(--color-text-subtle);
  margin-bottom: var(--space-4);
  line-height: var(--line-height-base);
}

/* Visual reorder-point equation: semantic HTML/CSS, not an image. Stacks
   on mobile so wide currency-style values never clip or force overflow. */
.result-equation {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

@media (min-width: 640px) {
  .result-equation {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
  }

  .result-equation .result-figure {
    flex: 1 1 auto;
    min-width: 0;
  }
}

.result-equation__operator {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--color-text-subtle);
  text-align: center;
}

.result-interpretation {
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: var(--color-text);
}

/* Turnover reduction scenarios: responsive cards, never a fixed-width
   desktop-only table, so the layout stays safe down to 360px. */
.result-scenarios {
  margin-bottom: var(--space-4);
}

.result-scenarios h2 {
  font-size: var(--font-size-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-subtle);
  margin: 0 0 var(--space-3);
}

.result-scenarios__note {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

.scenario-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}

@media (min-width: 640px) {
  .scenario-list {
    grid-template-columns: repeat(3, 1fr);
  }
}

.scenario-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  background: var(--color-bg);
  min-width: 0;
  transition: border-color var(--transition-fast);
}

.scenario-card:hover {
  border-color: var(--color-border-strong);
}

.scenario-card__heading {
  font-weight: 700;
  font-size: var(--font-size-sm);
  margin: 0 0 var(--space-3);
  color: var(--color-text);
}

.scenario-card__stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-1) 0;
  margin: 0;
}

.scenario-card__stats dt {
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: var(--color-text-subtle);
  margin-top: var(--space-2);
}

.scenario-card__stats dt:first-child {
  margin-top: 0;
}

.scenario-card__stats dd {
  margin: 0;
  font-weight: 700;
  font-size: var(--font-size-base);
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
  overflow-wrap: break-word;
}

/* Advanced mode groups multiple labeled fieldsets in one hidden wrapper. */
.field-group-set > .field-group:last-child {
  margin-bottom: 0;
}

.calculator-period-hint {
  margin-bottom: var(--space-4);
}

/* Checkbox field: native control, kept at a legible tap-target size. */
.field--checkbox {
  flex-direction: row;
  align-items: center;
  gap: var(--space-2);
  grid-column: 1 / -1;
}

.field--checkbox input[type="checkbox"] {
  width: 20px;
  height: 20px;
  min-width: 20px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-strong);
}

.field--checkbox label {
  font-weight: 600;
}

/* Optional channel analysis: dynamically added rows, mobile-first. */
.channel-analysis__section {
  grid-column: 1 / -1;
  margin-top: var(--space-2);
}

.channel-analysis__warning {
  background: var(--color-warning-bg);
  border: 1px solid rgba(217, 119, 6, 0.15);
  border-left: 4px solid var(--color-warning);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-4);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.channel-row-list {
  list-style: none;
  margin: 0 0 var(--space-4);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.channel-row {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.channel-row__fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

@media (min-width: 640px) {
  .channel-row__fields {
    grid-template-columns: repeat(3, 1fr);
  }
}

.channel-row__remove {
  width: 100%;
}

@media (min-width: 640px) {
  .channel-row__remove {
    width: auto;
  }
}

/* Channel comparison results: responsive cards, never a fixed-width table. */
.result-channels {
  margin-bottom: var(--space-4);
}

.result-channels h2 {
  font-size: var(--font-size-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-subtle);
  margin: 0 0 var(--space-3);
}

.channel-card-list {
  list-style: none;
  margin: var(--space-3) 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}

@media (min-width: 640px) {
  .channel-card-list {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

.channel-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  background: var(--color-bg);
  min-width: 0;
}

.channel-card--lowest {
  border-color: var(--color-success);
  border-left: 4px solid var(--color-success);
}

.channel-card--highest {
  border-color: var(--color-danger);
  border-left: 4px solid var(--color-danger);
}

.channel-card__heading {
  font-weight: 700;
  font-size: var(--font-size-sm);
  margin: 0 0 var(--space-1);
  overflow-wrap: break-word;
  color: var(--color-text);
}

.channel-card__cac {
  font-size: var(--font-size-lg);
  font-weight: 800;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
  margin: 0 0 var(--space-1);
  overflow-wrap: break-word;
}

.channel-card__detail {
  font-size: var(--font-size-sm);
  color: var(--color-text-subtle);
  margin: 0;
  overflow-wrap: break-word;
}

/* Redefined Comparison & Savings Layout overrides for visual excellence */
.result-highlight {
  background-color: var(--color-success-bg) !important;
  border: 1px solid rgba(22, 163, 74, 0.15) !important;
  border-left: 4px solid var(--color-success) !important;
  border-radius: var(--radius-md) !important;
  padding: var(--space-4) !important;
  margin-top: var(--space-5) !important;
  box-shadow: var(--shadow-sm);
}

.result-highlight h3 {
  margin-top: 0 !important;
  margin-bottom: var(--space-2) !important;
  color: var(--color-success) !important;
  font-size: var(--font-size-sm) !important;
  text-transform: uppercase !important;
  letter-spacing: 0.05em !important;
  font-weight: 700 !important;
}

.result-highlight p {
  color: var(--color-text-muted) !important;
  margin: 0 !important;
  line-height: var(--line-height-base) !important;
  font-size: var(--font-size-sm) !important;
}

.result-highlight--neutral {
  background-color: var(--color-bg) !important;
  border: 1px solid var(--color-border) !important;
  border-left: 4px solid var(--color-text-subtle) !important;
  border-radius: var(--radius-md) !important;
  padding: var(--space-4) !important;
  margin-top: var(--space-5) !important;
  box-shadow: var(--shadow-sm);
}

.result-highlight--neutral h3 {
  margin-top: 0 !important;
  margin-bottom: var(--space-2) !important;
  color: var(--color-text-muted) !important;
  font-size: var(--font-size-sm) !important;
  text-transform: uppercase !important;
  letter-spacing: 0.05em !important;
  font-weight: 700 !important;
}
