:root {
  --tile: #437D8D;
  --tile-2: #57808B;
  --tile-dark: #2E5561;
  --bg: #1C2B30;
  --text: #FFFFFF;
  --accent: #F5A623; /* amber: qualified-plan markers, blocked/needs-attention */
  --flag: #4EA72E;   /* green: items highlighted on the price sheet — never amber */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* Screens, panels and the modal are display:flex/grid, which beats the UA's
   [hidden] rule — without this, hiding them by attribute does nothing. */
[hidden] { display: none !important; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 10px 40px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.85;
}

.label-sub {
  text-transform: none;
  font-weight: 400;
  opacity: 0.8;
}

.section-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 8px;
  opacity: 0.9;
}

/* ---- Screens ---- */
/* Each screen reproduces main's column layout so the pricing sections keep
   the exact spacing they had before they were wrapped. */
.screen {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.screen-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.screen-tabs button {
  min-height: 56px;
  border: none;
  border-radius: 14px;
  background: var(--tile-dark);
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.screen-tabs button.active {
  background: var(--tile);
  outline: 2px solid var(--accent);
}

/* ---- Price inputs ---- */
.input-section {
  background: var(--tile-dark);
  border-radius: 14px;
  padding: 10px 14px;
}

.input-section input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 34px;
  font-weight: 800;
  text-align: center;
  min-height: 56px;
}

.input-section input::placeholder { color: rgba(255,255,255,0.4); }

/* Proposed price sits beside the payment-to-price solver; two 34px inputs will
   not fit an iPhone side by side, so this row runs a size down. */
.price-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: start;
}

.price-row .input-section input { font-size: 26px; min-height: 48px; }

.solved-price {
  font-size: 20px;
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding-bottom: 4px;
  color: var(--accent);
}

/* ---- Cards ---- */
.headline-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.card {
  background: var(--tile);
  border-radius: 14px;
  padding: 10px 12px;
  min-height: 84px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 2px;
}

.big {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
}

.small {
  font-size: 13px;
  font-weight: 600;
  opacity: 0.85;
}

/* ---- Drop table ---- */
.drop-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--tile-dark);
  border-radius: 14px;
  overflow: hidden;
  font-size: 15px;
}

.drop-table th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 6px;
  background: rgba(0,0,0,0.25);
  text-align: right;
}

.drop-table th:first-child { text-align: left; }

.drop-table td {
  padding: 10px 6px;
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.drop-table td:first-child {
  text-align: left;
  font-weight: 700;
}

/* ---- Lender toggle + plan select ---- */
.plan-picker {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lender-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.lender-toggle button {
  min-height: 56px;
  border: none;
  border-radius: 14px;
  background: var(--tile-dark);
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.lender-toggle button.active {
  background: var(--tile);
  outline: 2px solid var(--accent);
}

/* iOS Safari ignores CSS on <option>, so mark a qualified selection on the
   select itself: amber text whenever the chosen plan qualifies. */
#plan-select.qualified { color: var(--accent); }

#plan-select {
  width: 100%;
  min-height: 56px;
  border: none;
  border-radius: 14px;
  background: var(--tile-2);
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  padding: 0 14px;
  appearance: none;
  -webkit-appearance: none;
}

/* ---- Effect cards ---- */
.effect-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 10px;
}

.effect-card {
  align-items: flex-start;
  text-align: left;
}

.effect-lines {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
}

.effect-lines .hl { color: var(--accent); }

/* ---- Tiles / steppers ---- */
.tile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.tile {
  background: var(--tile);
  border-radius: 14px;
  min-height: 84px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 2px;
}

.tile .label { font-size: 12px; }

.tile.stepper {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  grid-template-rows: auto 1fr;
  align-items: center;
}

.tile.stepper .label {
  grid-column: 1 / -1;
  padding-top: 2px;
}

.tile.stepper output {
  font-size: 28px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tile.stepper output input {
  width: 100%;
  background: rgba(0,0,0,0.25);
  border: none;
  border-radius: 8px;
  outline: 2px solid var(--accent);
  color: var(--text);
  font-size: 24px;
  font-weight: 800;
  text-align: center;
  min-height: 48px;
}

.tile.stepper .minus,
.tile.stepper .plus {
  min-height: 56px;
  border: none;
  border-radius: 10px;
  background: var(--tile-dark);
  color: var(--text);
  font-size: 26px;
  font-weight: 800;
}

.tile.stepper .minus:active,
.tile.stepper .plus:active { background: var(--tile-2); }

/* ---- Quick grid ---- */
.quick-grid .tile { background: var(--tile-2); }

.quick-grid .tile .small {
  font-size: 12px;
  opacity: 0.9;
}

/* ---- Reset ---- */
.reset-btn {
  width: 100%;
  min-height: 56px;
  border: none;
  border-radius: 14px;
  background: var(--tile-dark);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.reset-btn:disabled { opacity: 0.4; }

/* ==================== Quote screen ==================== */

/* ---- Collapsible headers (groups + saved jobs) ---- */
.panel-toggle,
.group-header {
  width: 100%;
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border: none;
  border-radius: 14px;
  background: var(--tile-dark);
  color: var(--text);
  text-align: left;
}

.panel-toggle .section-title,
.group-header .group-name { margin-bottom: 0; }

.group-header .group-name {
  flex: 1;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.group-count {
  min-width: 26px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--bg);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.group-chev {
  display: inline-block;
  margin-left: auto;
  font-size: 22px;
  font-weight: 800;
  opacity: 0.7;
  transition: transform 0.12s ease-out;
}

.group-header .group-chev { margin-left: 0; }

[aria-expanded="true"] > .group-chev { transform: rotate(90deg); }

/* ---- Sections > subsections > items ---- */
.quote-section { margin-bottom: 10px; }

/* The section band outranks its subsections visually so the two accordion
   levels never read as one flat list. */
.section-header {
  background: var(--tile);
  min-height: 60px;
}

.section-header .group-name {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.section-groups {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0 0 10px;      /* indent marks the nesting */
  border-left: 2px solid rgba(255,255,255,0.12);
  margin-left: 6px;
}

.quote-group { margin-bottom: 0; }

.group-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
}

.quote-item {
  background: var(--tile);
  border-radius: 14px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 6px 8px;
  /* Always reserve the stripe so flagging an item never shifts the layout. */
  border-left: 5px solid transparent;
}

/* Green-highlighted on the price sheet. Amber is taken — it means blocked. */
.quote-item.flagged { border-left-color: var(--flag); }

.qi-name {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
}

.qi-price {
  font-size: 13px;
  font-weight: 600;
  opacity: 0.75;
  white-space: nowrap;
}

.qi-note {
  grid-column: 1;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--accent);
}

.qi-details {
  grid-column: 1 / -1;
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  line-height: 1.4;
  opacity: 0.8;
}

.qi-stepper {
  grid-row: 1 / span 2;
  grid-column: 2;
  display: grid;
  grid-template-columns: 48px 46px 48px;
  align-items: center;
}

.qi-stepper button {
  min-height: 56px;
  border: none;
  border-radius: 10px;
  background: var(--tile-dark);
  color: var(--text);
  font-size: 26px;
  font-weight: 800;
}

.qi-stepper button:active { background: var(--tile-2); }

.qi-stepper output {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.qi-stepper output input {
  width: 100%;
  min-height: 48px;
  background: rgba(0,0,0,0.25);
  border: none;
  border-radius: 8px;
  outline: 2px solid var(--accent);
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
  text-align: center;
}

.quote-item.selected { outline: 2px solid var(--accent); }

.quote-item.blocked { opacity: 0.5; }
.quote-item.blocked .qi-stepper { pointer-events: none; }

/* ---- Bundle inclusion checklist ---- */
.qi-inclusions {
  grid-column: 1 / -1;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 2px;
}

.qi-inclusions label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}

.qi-inclusions input {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}

/* ---- Cascade-removal notice ---- */
.quote-notice {
  background: var(--tile-dark);
  border-radius: 14px;
  border-left: 4px solid var(--accent);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--accent);
}

/* ---- Total bar ---- */
/* Trailing room so an opened subsection can always scroll flush to the top,
   even when it's short and near the end of the list. */
#quote-groups { padding-bottom: 75vh; }

.quote-total-bar {
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: var(--tile-dark);
  border-radius: 14px;
  padding: 10px 14px;
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  align-items: center;
  gap: 12px;
  box-shadow: 0 -6px 16px rgba(0,0,0,0.35);
}

.qt-figure { text-align: left; }
.qt-figure .big { font-size: 26px; }

/* ---- Saved jobs ---- */
.jobs-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
}

#job-name {
  width: 100%;
  min-height: 56px;
  padding: 0 14px;
  border: none;
  border-radius: 14px;
  background: var(--tile-2);
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
}

#job-name::placeholder { color: rgba(255,255,255,0.5); }

.jobs-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.job-row {
  background: var(--tile);
  border-radius: 14px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
}

.job-meta { min-width: 0; }

.job-name {
  font-size: 15px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-date { font-size: 12px; font-weight: 600; opacity: 0.75; }

.job-row button {
  min-height: 56px;
  padding: 0 14px;
  border: none;
  border-radius: 10px;
  background: var(--tile-dark);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.jobs-empty { font-size: 13px; font-weight: 600; opacity: 0.7; }

/* Destructive actions read differently from the teal buttons around them, but
   stay inside the collapsed panel so colour is the second line of defence. */
.reset-btn.danger {
  background: transparent;
  border: 2px solid var(--accent);
  color: var(--accent);
}

.reset-btn.danger:disabled { opacity: 0.35; }

/* ---- Export & backup ---- */
.restore-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.85;
  margin-top: 4px;
}

#restore-input {
  width: 100%;
  min-height: 56px;
  padding: 14px;
  border: none;
  border-radius: 14px;
  background: var(--tile-2);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
}

/* The file button is the tap target, so it gets the 56px, not the input box. */
#restore-input::-webkit-file-upload-button {
  min-height: 44px;
  margin-right: 12px;
  padding: 0 14px;
  border: none;
  border-radius: 10px;
  background: var(--tile-dark);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.export-status {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--tile);
}

.export-status.error { color: var(--accent); }

/* ---- Scope modal ---- */
.scope-modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  /* Fully opaque on purpose: at 95% the pricing screen's dollar figures read
     straight through the sheet the customer is being shown. */
  background: var(--bg);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px 10px;
}

.scope-sheet {
  width: 100%;
  max-width: 480px;
  max-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--tile-dark);
  border-radius: 14px;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.scope-sheet h2 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.scope-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.scope-item {
  background: var(--tile);
  border-radius: 14px;
  padding: 10px 12px;
  border-left: 5px solid transparent;
}

.scope-item.flagged { border-left-color: var(--flag); }

.scope-name {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.scope-qty { font-weight: 800; opacity: 0.85; }

.scope-bullets {
  margin: 6px 0 0;
  padding-left: 20px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
  opacity: 0.9;
}
