/* Leaf Filter — green. The Premier app is teal; these two must never be
   mistaken for each other on a home screen or in a tab strip. */
:root {
  --tile: #169e2d;
  --tile-2: #12822a;
  --tile-dark: #014f05;
  --bg: #0B1A0C;
  --text: #FFFFFF;
  --accent: #F5A623; /* amber: qualifying plans, needs-attention, live edits */
}

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

/* Screens and panels 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: 0 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;
}

.hint {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  opacity: 0.75;
}

/* ---- Screens + tabs ---- */
.screen { display: flex; flex-direction: column; gap: 12px; }

/* Seven tabs on a phone: one sticky row, abbreviated, still 56px tall. */
.screen-tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  padding: 8px 0;
  background: var(--bg);
}

.screen-tabs button {
  min-height: 56px;
  padding: 0 2px;
  border: none;
  border-radius: 12px;
  background: var(--tile-dark);
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

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

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

.input-section input,
.input-section select,
.input-section textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  min-height: 56px;
  font-family: inherit;
}

.input-section textarea {
  min-height: 92px;
  padding: 8px 0;
  font-size: 16px;
  font-weight: 600;
  resize: vertical;
}

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

.input-section select { appearance: none; -webkit-appearance: none; }

.input-section.price input {
  font-size: 34px;
  font-weight: 800;
  text-align: center;
}

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---- Toggles ---- */
.toggle-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

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

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

.toggle-block { background: var(--tile-dark); border-radius: 14px; padding: 10px 14px; }
.toggle-block .toggle-row { margin-top: 8px; }
.toggle-block .toggle-row button { background: rgba(0,0,0,0.25); }
.toggle-block .toggle-row button.active { background: var(--tile); }

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

.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; font-variant-numeric: tabular-nums; }
.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.04em;
  padding: 8px 5px;
  background: rgba(0,0,0,0.3);
  text-align: right;
}

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

.drop-table td {
  padding: 10px 5px;
  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; }

/* ---- Plan picker ---- */
.plan-picker { display: flex; flex-direction: column; gap: 10px; }

/* iOS Safari ignores CSS on <option>, so the qualifying marker is carried in
   the option text and echoed here as amber on the select itself. */
#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: 16px;
  font-weight: 700;
  padding: 0 14px;
  appearance: none;
  -webkit-appearance: none;
}

.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; }

/* A grid item's min-width is auto, so a wide stepper readout ("0.9125" at
   26px) pushes its own 1fr track out and the page scrolls sideways. */
.tile-grid > * { min-width: 0; }

.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: 48px minmax(0, 1fr) 48px;
  grid-template-rows: auto 1fr;
  align-items: center;
}

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

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

/* "0.9125" is six glyphs in a ~60px track between two 48px buttons. */
.tile.stepper[data-kind="factor"] output { font-size: 16px; }

.tile.stepper output input {
  width: 100%;
  background: rgba(0,0,0,0.3);
  border: none;
  border-radius: 8px;
  outline: 2px solid var(--accent);
  color: var(--text);
  font-size: 22px;
  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); }

.discount-grid .tile { background: var(--tile-2); }
.discount-grid .tile .small { font-size: 12px; opacity: 0.9; }

/* ---- Buttons ---- */
.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; }

.reset-btn.primary { background: var(--tile); }

/* Destructive actions read differently from the green buttons around them. */
.reset-btn.danger {
  background: transparent;
  border: 2px solid var(--accent);
  color: var(--accent);
}

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

/* ---- Accordions (measure sections, saved jobs, export) ---- */
.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 { background: var(--tile); }

.group-header .group-name {
  flex: 1;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.group-sub {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  opacity: 0.9;
}

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

.panel-toggle .group-chev { margin-left: auto; }

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

.measure-section { margin-bottom: 10px; }

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

/* ---- Measure line items ---- */
.measure-item {
  background: var(--tile);
  border-radius: 14px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-left: 5px solid transparent;
}

.measure-item.measured { border-left-color: var(--accent); }

.mi-head { display: flex; align-items: baseline; gap: 8px; }

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

.mi-rate {
  font-size: 12px;
  font-weight: 700;
  opacity: 0.8;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.mi-price {
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.mi-input {
  display: grid;
  grid-template-columns: 1fr 48px 46px 48px;
  align-items: center;
  gap: 6px;
}

.mi-input-label { font-size: 13px; font-weight: 700; opacity: 0.9; }

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

.mi-input button:active { background: var(--tile-2); }

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

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

/* Trailing room so an opened section can always scroll flush to the top. */
#measure-sections { padding-bottom: 60vh; }

/* ---- Sticky totals ---- */
.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 auto;
  align-items: center;
  gap: 12px;
  box-shadow: 0 -6px 16px rgba(0,0,0,0.45);
}

.total-bar .big { font-size: 26px; }
.tb-figure { text-align: left; }
.tb-note { font-size: 12px; font-weight: 700; opacity: 0.8; text-align: right; }

/* ---- Itemized (customer facing) ---- */
.itemized-head {
  background: var(--tile-dark);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.itemized-head .who { font-size: 18px; font-weight: 800; }
.itemized-head .when { font-size: 13px; font-weight: 600; opacity: 0.85; }

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

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

.chart-name { font-size: 15px; font-weight: 700; line-height: 1.3; }
.chart-qty { font-size: 12px; font-weight: 600; opacity: 0.8; }

.chart-price {
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chart-empty { font-size: 14px; font-weight: 600; opacity: 0.75; }

/* ---- Flex / Cost message blocks ---- */
.message-block {
  background: var(--tile-dark);
  border-radius: 14px;
  border-left: 4px solid var(--accent);
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
  white-space: pre-wrap;
}

.code-card {
  background: var(--tile);
  border-radius: 14px;
  padding: 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.code-value {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.sig-wrap { background: var(--tile-dark); border-radius: 14px; padding: 10px 14px; }

#flex-signature {
  width: 100%;
  height: 150px;
  margin-top: 8px;
  border-radius: 10px;
  background: #FFFFFF;
  touch-action: none;
  display: block;
}

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

.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; }

.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;
}

#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); }
