/* Material Calculator — WayMaker brand (#a8231f) */
.calc-app {
  max-width: 1240px;
  margin: 0 auto;
  min-width: 0;
}

.calc-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: auto auto auto;
  gap: 20px;
  align-items: stretch;
}

.calc-panel-shape { grid-column: 1; grid-row: 1; }
.calc-panel-preview { grid-column: 2; grid-row: 1; }
.calc-panel-material { grid-column: 1; grid-row: 2; }
.calc-panel-estimate { grid-column: 2; grid-row: 2; }
.calc-panel-compaction { grid-column: 1 / -1; grid-row: 3; }

@media (max-width: 920px) {
  .calc-grid {
    grid-template-columns: 1fr;
    grid-template-rows: none;
  }
  .calc-panel-shape,
  .calc-panel-preview,
  .calc-panel-material,
  .calc-panel-estimate,
  .calc-panel-compaction {
    grid-column: 1;
    grid-row: auto;
  }
}

.calc-panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100%;
  overflow: hidden;
}

.calc-panel-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.calc-panel-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--stone);
  padding-bottom: 14px;
  margin-bottom: 20px;
  border-bottom: 1px solid #e7e5e4;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  flex-shrink: 0;
}
.calc-step {
  background: var(--red);
  color: white;
  padding: 3px 8px;
  font-size: 9px;
  border-radius: 2px;
  letter-spacing: .1em;
}

.shape-tabs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 18px;
}
@media (max-width: 600px) { .shape-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.shape-tab {
  background: var(--sand);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 12px 4px 10px;
  cursor: pointer;
  text-align: center;
  transition: all .15s ease;
  font-family: var(--font-body);
  min-width: 0;
}
.shape-tab svg {
  width: 28px; height: 28px; margin: 0 auto 6px; display: block;
  stroke: var(--slate); stroke-width: 1.6; fill: none;
}
.shape-tab .label {
  font-size: 10px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--slate); line-height: 1.2;
}
.shape-tab .sublabel {
  font-size: 9px; color: var(--stone); margin-top: 3px;
  font-family: var(--font-mono); letter-spacing: .04em;
}
.shape-tab:hover:not(.active) { border-color: var(--slate); background: var(--white); }
.shape-tab.active { background: var(--red); border-color: var(--red); }
.shape-tab.active svg { stroke: white; }
.shape-tab.active .label { color: white; }
.shape-tab.active .sublabel { color: white; opacity: .78; }

.calc-field-group {
  display: grid;
  gap: 12px;
  min-width: 0;
}
.calc-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.calc-field label {
  font-family: var(--font-mono);
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--stone); font-weight: 600;
}
.calc-input-wrap {
  display: flex;
  align-items: stretch;
  min-width: 0;
  max-width: 100%;
}
.calc-input-wrap input[type="number"] {
  flex: 1 1 0;
  min-width: 0;
  width: 100%;
  font-family: var(--font-mono);
  font-size: 16px; font-weight: 500;
  padding: 10px 12px;
  border: 1px solid var(--line); border-right: 0;
  border-radius: 3px 0 0 3px;
  background: var(--white); color: var(--charcoal);
  -moz-appearance: textfield;
}
.calc-input-wrap input::-webkit-outer-spin-button,
.calc-input-wrap input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.calc-input-wrap select.unit-select {
  flex: 0 0 auto;
  width: auto; min-width: 3.2rem; max-width: 4rem;
  font-family: var(--font-mono); font-size: 12px;
  padding: 10px 8px;
  border: 1px solid var(--line); border-radius: 0 3px 3px 0;
  background: var(--sand); color: var(--charcoal); cursor: pointer;
}
.calc-field > select {
  width: 100%; font-size: 14px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 3px;
  background: var(--white); font-family: var(--font-body);
  min-width: 0;
}
.calc-field input:focus, .calc-field select:focus {
  outline: none; border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(168, 35, 31, 0.14);
}

.berm-type-row {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin-bottom: 14px;
}
.berm-type-btn {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 3px;
  background: var(--sand); cursor: pointer; text-align: left;
  font-family: var(--font-body); font-size: 13px; color: var(--slate);
  transition: all .15s ease; min-width: 0;
}
.berm-type-btn strong { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--charcoal); }
.berm-type-btn span { font-size: 11px; color: var(--stone); }
.berm-type-btn.active { border-color: var(--red); background: var(--red-soft); }
.berm-type-btn.active strong { color: var(--red-dark); }

.material-card {
  margin-top: 16px; background: var(--sand);
  border: 1px solid var(--line); border-radius: 3px; overflow: hidden;
}
.material-card.editing { background: var(--white); border-color: var(--red); box-shadow: 0 0 0 3px rgba(168,35,31,.1); }
.material-card-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--stone); font-weight: 600;
}
.gear-btn {
  background: transparent; border: 1px solid var(--line); border-radius: 3px;
  padding: 4px; cursor: pointer; color: var(--stone);
  width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
}
.gear-btn.active { background: var(--red); border-color: var(--red); color: white; }
.gear-btn svg { width: 14px; height: 14px; }
.material-card-body { padding: 12px 14px; display: grid; gap: 8px; }
.prop-row { display: grid; grid-template-columns: 70px 1fr; align-items: center; font-size: 13px; gap: 8px; min-height: 24px; }
.prop-key { font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--stone); font-weight: 600; }
.prop-value-display { font-family: var(--font-mono); font-size: 14px; font-weight: 600; }
.prop-value-input { display: none; width: 90px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 3px; font-family: var(--font-mono); font-size: 14px; font-weight: 600; }
.material-card.editing .prop-value-display { display: none; }
.material-card.editing .prop-value-input { display: inline-block; }
.prop-value-unit { font-family: var(--font-mono); font-size: 11px; color: var(--stone); }
.reset-btn { display: none; background: transparent; border: 1px solid var(--line); padding: 4px 10px; font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; border-radius: 3px; cursor: pointer; }
.material-card.editing .reset-btn { display: inline-flex; }
.custom-badge { display: none; background: var(--red-tint); color: var(--red-dark); padding: 2px 6px; border-radius: 2px; font-family: var(--font-mono); font-size: 9px; margin-left: 4px; }
.material-card.has-custom .custom-badge { display: inline-block; }
.prop-note { font-size: 12px; color: var(--slate); line-height: 1.5; }

.calc-panel-compaction .calc-panel-body {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.calc-panel-compaction .compaction-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}
.slider-wrap { position: relative; padding: 14px 0 4px; min-width: 0; }
input[type="range"] { -webkit-appearance: none; width: 100%; height: 4px; background: var(--line); border-radius: 2px; cursor: pointer; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; background: var(--charcoal);
  border: 3px solid var(--white); border-radius: 50%; box-shadow: 0 0 0 1px var(--charcoal);
}
input[type="range"]:disabled { opacity: .35; cursor: not-allowed; }
.slider-ticks {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; padding: 0 2px;
  font-family: var(--font-mono); font-size: 9px; color: var(--stone);
}
.compaction-input-wrap {
  display: flex; align-items: center; border: 1px solid var(--line); border-radius: 3px; background: var(--white);
  flex-shrink: 0;
}
.compaction-input-wrap input {
  width: 56px; text-align: right; padding: 10px 4px 10px 10px; border: 0;
  font-family: var(--font-mono); font-size: 18px; font-weight: 600; background: transparent;
}
.compaction-input-wrap .pct { padding: 0 12px 0 2px; font-family: var(--font-mono); font-size: 14px; color: var(--stone); }
.compaction-note {
  display: none; font-size: 12px; color: var(--red-dark); padding: 10px 12px;
  background: var(--red-soft); border-left: 3px solid var(--red);
  margin-top: 12px; border-radius: 0 3px 3px 0; line-height: 1.5;
  width: 100%;
  max-width: 520px;
}
.compaction-note.show { display: block; }

.calc-panel-preview { padding: 0; }
.calc-viz-header {
  padding: 20px 24px 14px; border-bottom: 1px solid #e7e5e4;
  display: flex; justify-content: space-between; align-items: center;
  flex-shrink: 0;
}
.calc-viz-stage {
  background: #f4f0e8;
  position: relative; overflow: hidden;
  flex: 1;
  min-height: 220px;
  aspect-ratio: 16 / 9;
  display: flex; align-items: center; justify-content: center;
}
.calc-viz-stage::before { display: none; }
.calc-viz-stage svg { width: 100%; height: 100%; position: relative; z-index: 1; }
.calc-viz-stage .cad-grid { stroke: #eae4d8; stroke-width: 0.5; vector-effect: non-scaling-stroke; }
.calc-viz-stage .cad-grid.major { stroke: #ddd5c5; stroke-width: 0.75; }
.calc-viz-stage .cad-crosshair { stroke: #d9d1c0; stroke-width: 0.5; vector-effect: non-scaling-stroke; }
.calc-viz-stage .cad-border {
  fill: none; stroke: #c9c1b0; stroke-width: 0.75; vector-effect: non-scaling-stroke;
}
.calc-viz-stage .shape-fill {
  fill: rgba(168, 35, 31, 0.08);
  stroke: #a8231f;
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}
.calc-viz-stage .dim-line {
  stroke: #7a1a17;
  stroke-width: 0.65;
  opacity: 1;
  vector-effect: non-scaling-stroke;
  marker-end: url(#cad-arrow);
  marker-start: url(#cad-arrow);
}
.calc-viz-stage .dim-cap {
  stroke: #7a1a17;
  stroke-width: 0.65;
  opacity: 1;
  vector-effect: non-scaling-stroke;
}
.calc-viz-stage .dim-label {
  fill: #7a1a17;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 11px;
  text-anchor: middle;
  dominant-baseline: middle;
}
.calc-viz-stage .dim-label-bg {
  fill: #fdfcf9;
  stroke: #d9d1c0;
  stroke-width: 0.5;
}
.calc-viz-stage .center-mark { fill: #7a1a17; stroke: #7a1a17; stroke-width: 0.5; }
.calc-viz-stage .ground-line {
  stroke: #a8a29e;
  stroke-width: 0.75;
  opacity: 0.85;
  stroke-dasharray: 8 5;
  vector-effect: non-scaling-stroke;
}
.calc-viz-stage .placeholder-text {
  fill: #78716c;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 12px;
  text-anchor: middle;
  text-transform: uppercase;
  letter-spacing: .12em;
}

.calc-panel-estimate { padding: 0; }
.calc-results-header { padding: 20px 24px 14px; border-bottom: 1px solid #e7e5e4; flex-shrink: 0; }
.calc-results-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: #e7e5e4;
  flex: 1;
}
.calc-result-cell {
  background: var(--white); padding: 18px 20px; min-height: 88px;
  display: flex; flex-direction: column; justify-content: center;
}
.calc-result-cell .key {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--stone); margin-bottom: 8px; font-weight: 600;
}
.calc-result-cell .value {
  font-family: var(--font-head); font-size: clamp(24px, 3vw, 32px); font-weight: 600; color: var(--charcoal); line-height: 1;
}
.calc-result-cell .value-unit {
  font-family: var(--font-mono); font-size: 11px; color: var(--stone); margin-left: 5px;
}
.calc-result-cell.primary {
  background: var(--red); grid-column: span 2; padding: 22px 24px; min-height: 110px; position: relative;
}
.calc-result-cell.primary .key { color: white; opacity: .78; }
.calc-result-cell.primary .value { color: white; font-size: clamp(32px, 4vw, 44px); }
.calc-result-cell.primary .value-unit { color: white; opacity: .85; }
.primary-tag {
  position: absolute; top: 16px; right: 20px;
  font-family: var(--font-mono); font-size: 9px; font-weight: 600; letter-spacing: .14em;
  text-transform: uppercase; color: white; background: rgba(0,0,0,.22);
  padding: 4px 8px; border-radius: 2px;
}

.calc-footer {
  margin-top: 28px;
  padding: 28px 24px 8px;
  border-top: 1px solid var(--line);
  background: var(--white);
  border-radius: 4px;
  text-align: center;
}
.calc-footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  align-items: center;
}
.calc-disclaimer {
  font-size: 12px;
  color: var(--stone);
  margin-top: 18px;
  line-height: 1.5;
  font-family: var(--font-mono);
  letter-spacing: .02em;
  max-width: 56ch;
  margin-inline: auto;
}
