/* 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.

   Two product lines share this stylesheet. Everything below is written against
   the custom properties, so the whole app re-skins from the `data-line`
   attribute the shell puts on <html> — there is no second stylesheet and no
   duplicated rule to drift. */
:root {
  --tile: #169e2d;
  --tile-2: #12822a;
  --tile-dark: #014f05;
  --bg: #0B1A0C;
  --text: #FFFFFF;
  --accent: #F5A623; /* amber: qualifying plans, needs-attention, live edits */
}

/* Leaf Home Water Solutions — the workbook's own colour table: dark blue
   #024b75, mid blue #155787, bright blue #0090ff, gold #ffcc00, brown #6b5934.
   A consultant switches between the two lines all day, so this has to read as a
   different app at arm's length, not a different shade. */
:root[data-line="water"] {
  --tile: #0b7ed0;
  --tile-2: #155787;
  --tile-dark: #024b75;
  --bg: #001526;
  --text: #FFFFFF;
  --accent: #ffcc00;  /* gold: live edits, codes, destructive actions */
  --brand-brown: #6b5934;
}

/* The chooser belongs to neither line, so it borrows neither palette. */
:root[data-line="none"] {
  --tile: #1f2a33;
  --tile-2: #18222a;
  --tile-dark: #131b22;
  --bg: #080d12;
  --text: #FFFFFF;
  --accent: #ffcc00;
}

* { 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; }

/* A product line is the tab strip plus its seven screens. Both lines stay
   built and live behind [hidden], which is what makes switching instant. */
.product-line { display: flex; flex-direction: column; gap: 12px; }

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

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

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

/* The way back to the chooser. It rides in the sticky strip, so it is on
   screen on every tab of both lines without costing a row of height. */
.screen-tabs .line-switch {
  background: transparent;
  border: 2px solid var(--accent);
  color: var(--accent);
  font-size: 17px;
  font-weight: 800;
}

/* ---- Chooser ---- */
.chooser { display: flex; flex-direction: column; gap: 14px; padding-top: 40px; }

.chooser-head { text-align: center; padding: 0 6px 6px; }
.chooser-title { font-size: 26px; font-weight: 800; letter-spacing: 0.02em; }
.chooser-sub { font-size: 14px; font-weight: 600; opacity: 0.8; margin-top: 6px; }
.chooser-hint { text-align: center; padding: 0 6px; }

.choose-card {
  width: 100%;
  min-height: 132px;
  border: none;
  border-radius: 18px;
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
}

.choose-name { font-size: 34px; font-weight: 800; letter-spacing: 0.06em; }
.choose-sub { font-size: 13px; font-weight: 600; opacity: 0.9; }

/* Each card wears its own line's colours, so the choice is made by sight
   before the words are read. */
.choose-water {
  background: linear-gradient(160deg, #0090ff 0%, #024b75 100%);
  outline: 3px solid #ffcc00;
}

.choose-filter {
  background: linear-gradient(160deg, #169e2d 0%, #014f05 100%);
  outline: 3px solid #F5A623;
}

/* ---- 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; the water
   side's rate reads "9.99%", which is five and needs the same treatment. */
.tile.stepper[data-kind="factor"] output,
.tile.stepper[data-key="annualRatePct"] 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,
#h2o-groups { 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,
#h2o-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); }

/* ---- Proposed Amount: a $ that sits with the typed number ---- */
.money-input {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.money-input .money-prefix {
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
}

/* The input sizes to its content so the $ hugs the number instead of
   floating at the far left of a full-width field. */
.money-input input {
  width: auto;
  flex: 0 1 auto;
  min-width: 2ch;
  field-sizing: content;
  text-align: left;
}

/* ---- Water: catalog search ---- */
/* 77 products in five groups. Typing beats scrolling, so the box is the first
   thing on the screen and filtering is live. */
.h2o-search-box .search-row {
  display: grid;
  grid-template-columns: 1fr 56px;
  align-items: center;
  gap: 8px;
}

.h2o-search-box input {
  -webkit-appearance: none;
  appearance: none;
}

.h2o-search-box input::-webkit-search-cancel-button { display: none; }

#h2o-search-clear {
  min-height: 56px;
  border: none;
  border-radius: 10px;
  background: var(--tile);
  color: var(--text);
  font-size: 26px;
  font-weight: 800;
}

/* ---- Water: catalog lines ---- */
.h2o-item .mi-name { display: flex; flex-direction: column; gap: 2px; }

/* The consultant reads names; the order desk reads codes. Both, quietly. */
.h2o-code {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

/* A catalog line is name + unit price + one stepper, so it needs no label
   column — the price sits where the filter side's input label does. */
.h2o-item .mi-input { grid-template-columns: 1fr 48px 46px 48px; }
.h2o-item .mi-input-label { font-variant-numeric: tabular-nums; opacity: 0.85; }

/* Brown is the fifth workbook colour. It earns one job: separating the
   customer-facing header from the chart under it. */
:root[data-line="water"] .itemized-head {
  border-bottom: 3px solid var(--brand-brown);
}

/* ---- Panel headings centred (Save Job / Export & Backup) ---- */
.panel-toggle { position: relative; justify-content: center; text-align: center; }
.panel-toggle .section-title { margin: 0; }
.panel-toggle .group-chev {
  position: absolute;
  right: 14px;
  margin-left: 0;
}
