:root {
  --bg: #f6f7f4; --card: #ffffff; --ink: #1d2320; --quiet: #5d6762; --line: #d9ddd8;
  --brand: #2f6b3a; --brand-ink: #ffffff; --brand-soft: #e3efe5;
  --warn: #9a5b00; --warn-soft: #fff3dc; --bad: #a32020; --bad-soft: #fde8e8;
  --ok: #2f6b3a; --ok-soft: #e3efe5; --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816; --card: #1d2320; --ink: #e9ece9; --quiet: #a3aca7; --line: #343c38;
    --brand: #5fae6c; --brand-ink: #0d140f; --brand-soft: #233428;
    --warn: #f0b45a; --warn-soft: #3a2d17; --bad: #f08a8a; --bad-soft: #3d1f1f;
    --ok: #7fcf8b; --ok-soft: #233428;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); }
header.top { background: var(--brand); color: var(--brand-ink); padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
header.top .brand { font-weight: 700; color: var(--brand-ink); text-decoration: none; font-size: 17px; }
nav.main { display: flex; gap: 4px; flex-wrap: wrap; }
nav.main a { color: var(--brand-ink); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: 15px; }
nav.main a.on, nav.main a:hover { background: rgba(255,255,255,.18); }
.mode { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: rgba(0,0,0,.2); }
main { max-width: 860px; margin: 0 auto; padding: 16px; }
h1 { font-size: 22px; margin: 4px 0 12px; }
h2 { font-size: 18px; margin: 20px 0 8px; }
h3 { font-size: 16px; margin: 0 0 6px; }
.quiet { color: var(--quiet); }
.small { font-size: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0 0 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.spread { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }

/* forms */
label { display: block; font-size: 14px; color: var(--quiet); margin: 0 0 4px; }
input[type=text], input[type=number], input[type=date], input[type=time], input[type=file], input[type=password], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-height: 44px; }
textarea { min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.field { margin: 0 0 12px; }
.check { display: flex; gap: 10px; align-items: center; color: var(--ink); font-size: 16px; margin: 6px 0; }
.check input { width: 22px; height: 22px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink);
  border-radius: 8px; padding: 10px 16px; min-height: 44px; cursor: pointer; text-decoration: none; }
.btn.secondary { background: transparent; color: var(--brand); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn.big { width: 100%; font-size: 18px; min-height: 56px; }
.btn:disabled { opacity: .5; cursor: default; }
form.inline { display: inline; }

/* tables */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--quiet); font-weight: 600; font-size: 13px; }
td.num, th.num { text-align: right; white-space: nowrap; }

/* flashes, badges */
.flash { border-radius: 8px; padding: 10px 12px; margin: 0 0 12px; }
.flash.ok { background: var(--ok-soft); }
.flash.error { background: var(--bad-soft); color: var(--bad); }
.flash.info { background: var(--warn-soft); color: var(--warn); }
.warn { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 8px 12px; margin: 0 0 8px; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--brand-soft); color: var(--ok); white-space: nowrap; }
.badge.flag { background: var(--warn-soft); color: var(--warn); }
.badge.grey { background: var(--line); color: var(--quiet); }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin: 0 0 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 13px; color: var(--quiet); }

/* batch steps */
ol.steps { list-style: none; padding: 0; margin: 0; counter-reset: s; }
ol.steps > li { counter-increment: s; position: relative; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px 12px 52px; margin: 0 0 8px; }
ol.steps > li::before { content: counter(s); position: absolute; left: 12px; top: 12px; width: 28px; height: 28px;
  border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px;
  background: var(--line); color: var(--quiet); }
ol.steps > li.done::before { content: "\2713"; background: var(--brand-soft); color: var(--ok); }
ol.steps > li.current { border: 2px solid var(--brand); }
ol.steps > li.current::before { background: var(--brand); color: var(--brand-ink); }
ol.steps > li.later { opacity: .6; }
.target { font-size: 20px; font-weight: 700; }
.progress { height: 14px; border-radius: 999px; background: var(--line); overflow: hidden; margin: 8px 0; }
.progress > div { height: 100%; width: 0; background: var(--brand); transition: width .2s; }
.hidden { display: none !important; }
details summary { cursor: pointer; color: var(--brand); margin: 8px 0; }

/* work order product rows */
.prow { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 8px; align-items: end; margin: 0 0 8px; }
@media (max-width: 560px) { .prow { grid-template-columns: 1fr 1fr 1fr auto; }
  .prow .pname { grid-column: 1 / -1; } }
.xbtn { min-height: 44px; min-width: 44px; border-radius: 8px; border: 1px solid var(--line);
  background: transparent; color: var(--quiet); font-size: 20px; cursor: pointer; }
.list a.item { display: block; text-decoration: none; color: inherit; }

/* mixing plan: table on wide screens, a card per batch on phones */
.plan-cards { display: none; }
@media (max-width: 600px) { .plan-table { display: none; } .plan-cards { display: block; } }

/* rig page meters */
.meter { margin-top: 4px; }
.meter-bar { position: relative; height: 26px; border-radius: 6px; background: var(--brand-soft);
  border: 1px solid var(--line); overflow: hidden; }
.meter-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--brand); width: 0; transition: width .2s; }
.meter-mark { position: absolute; top: -2px; bottom: -2px; width: 3px; background: var(--warn); left: 0; transition: left .2s; }
.meter-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; color: var(--quiet); }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; }
.sw.fill { background: var(--brand); } .sw.mark { background: var(--warn); }
.sw.room { background: var(--brand-soft); border: 1px solid var(--line); }
.bulk-tanks { display: flex; gap: 6px; }
.bulk-tanks div { flex: 1; height: 26px; border-radius: 6px; background: var(--brand); opacity: .85;
  color: var(--brand-ink); font-size: 12px; display: grid; place-items: center; }

/* completion report */
.report { background: #fff; color: #111; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.report a { color: #111; }
.rhead { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-bottom: 2px solid #2f6b3a;
  padding-bottom: 10px; margin-bottom: 12px; }
.rbiz { font-weight: 700; font-size: 18px; }
.rtitle { text-align: right; } .rh1 { font-weight: 700; font-size: 18px; color: #2f6b3a; }
.report table { font-size: 13.5px; }
.report th, .report td { border-bottom: 1px solid #ddd; color: #111; padding: 6px; }
.kv th { color: #555; font-weight: 600; width: 16%; white-space: nowrap; }
.rsec { color: #2f6b3a; margin: 18px 0 6px; font-size: 14px; text-transform: uppercase; letter-spacing: .03em; }
.rtable th { color: #555; }
.tot td { font-weight: 700; } .tot.big td { font-size: 15px; border-top: 2px solid #111; }
.sign { display: flex; gap: 32px; margin-top: 40px; font-size: 12px; color: #555; }
.sign > div { flex: 1; } .sign .line { border-bottom: 1px solid #111; height: 28px; margin-bottom: 4px; }
.printonly { display: none; }
@media (max-width: 560px) { .kv th, .kv td { display: block; width: auto; border: 0; padding: 2px 0; }
  .kv tr { display: block; border-bottom: 1px solid #ddd; padding: 6px 0; } .rtitle { text-align: left; } }
@media print {
  header.top, .noprint, .flash { display: none !important; }
  .printonly { display: block; }
  body { background: #fff; color: #000; font-size: 12px; }
  main { max-width: none; padding: 0; }
  .report { border: 0; padding: 0; }
  .card, .stat { border: 0; padding: 0; background: #fff; }
  a { color: #000; text-decoration: none; }
  .badge { background: none !important; color: #000 !important; padding: 0; }
}

/* business logo */
.brand { display: inline-flex; align-items: center; gap: 8px; }
.brand .logo { height: 30px; max-width: 120px; object-fit: contain; background: #fff; border-radius: 4px; padding: 2px; }
.logo-preview { max-height: 90px; max-width: 100%; display: block; margin: 4px 0 12px; background: #fff; padding: 6px; border-radius: 6px; border: 1px solid var(--line); }
.rlogo { max-height: 90px; max-width: 300px; object-fit: contain; }
.rhead { align-items: center; } .rbizinfo { flex: 1; min-width: 160px; }
img.printonly { display: none; }
@media print { img.printonly { display: block; margin-bottom: 6px; } }

/* rate sheet */
.tiers { width: 100%; margin-bottom: 8px; }
.tiers th { font-size: 13px; text-align: left; }
.tiers td { padding: 4px 6px 4px 0; border: 0; }
.tiers td:last-child { width: 44px; }
.small-btn { padding: 8px 12px; font-size: 14px; min-height: 0; }
.pricebox { background: var(--soft, #eef4ee); border-radius: 8px; padding: 10px 12px; margin: 4px 0 12px; font-size: 14px; }
.pricebox:empty { display: none; }
.pricebox.warn { background: #fdf0d8; }

/* required fields on close-out */
.req { color: #b3261e; font-weight: 700; }
.reqbox { border-left: 4px solid #2f6b3a; }
.formerror { background: #fde7e5; color: #8c1d18; border: 1px solid #f1b8b3; border-radius: 8px; padding: 10px 12px; margin: 8px 0 12px; font-weight: 600; }
.formerror[hidden] { display: none; }
.field.invalid input, .field.invalid select { border-color: #b3261e; box-shadow: 0 0 0 2px #f6c9c5; }

/* pre-checks */
.loadout { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
@media (max-width: 560px) { .loadout { grid-template-columns: 1fr; } }
.ltank { border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.lname { font-size: 13px; font-weight: 600; } .lgal { font-size: 26px; font-weight: 700; margin: 2px 0 4px; }
.ok { color: #2f6b3a; font-weight: 600; }
.wx { width: 100%; }
.wx td, .wx th { font-size: 12.5px; padding: 5px 4px; white-space: nowrap; }
.wx th { font-size: 11px; }
.wxwhy td { white-space: normal; font-size: 12px; color: var(--muted, #666); padding-top: 0; border-top: 0; }
.wxrow.caution td, .wxrow.no td { border-bottom: 0; }
.wxwhy.no td { color: #8c1d18; }
.wxrow { cursor: pointer; } .wxrow.picked td { background: #e3efe4; }
.wxrow.no td { color: #8c1d18; }
.badge.bad { background: #fde7e5; color: #8c1d18; }
.pcsec { margin: 14px 0 4px; font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: #2f6b3a; }

/* spray monitor */
.condbox { border-radius: 12px; padding: 18px; margin: 8px 0; color: #fff; }
.condbox .condlevel { font-size: 26px; font-weight: 800; letter-spacing: .02em; }
.condbox .condnow { font-size: 15px; margin-top: 4px; }
.condbox .condwhy { margin-top: 6px; opacity: .95; }
:is(.condbox,.condstrip).go { background: #2f6b3a; } :is(.condbox,.condstrip).caution { background: #b06d00; }
:is(.condbox,.condstrip).stop { background: #b3261e; } :is(.condbox,.condstrip).unknown { background: #5b625e; }
.condbox.stop { animation: pulse 1s infinite alternate; }
@keyframes pulse { from { box-shadow: 0 0 0 0 rgba(179,38,30,.7); } to { box-shadow: 0 0 0 10px rgba(179,38,30,0); } }
.condstrip { display: block; border-radius: 10px; padding: 10px 12px; margin: 0 0 12px; color: #fff; text-decoration: none; }
.condstrip .condlevel { font-weight: 800; } .condstrip .condwhy { display: block; opacity: .95; }
.condstrip.stop { animation: pulse 1s infinite alternate; }
.wwins { display: grid; gap: 6px; margin-bottom: 8px; }
.wwin { border-left: 4px solid #2f6b3a; background: #eef4ee; border-radius: 6px; padding: 6px 10px; font-size: 14px; color: #111; }
.wwin.none { border-color: #b3261e; background: #fde7e5; }
.wxbar { display: flex; gap: 2px; margin: 4px 0 8px; }
.wxbar span { flex: 1; text-align: center; font-size: 10px; padding: 4px 0; border-radius: 3px; color: #fff; background: #2f6b3a; }
.wxbar span.caution { background: #d08a12; } .wxbar span.no { background: #b3261e; }

/* invoice */
.invoice .ihead { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start;
  border-bottom: 3px solid #0d3b1e; padding-bottom: 12px; margin-bottom: 14px; }
.ibrand { display: flex; flex-direction: column; gap: 6px; min-width: 220px; flex: 1; }
.ilogo { width: 300px; max-width: 100%; height: auto; border-radius: 4px; }
.ititle { text-align: right; } .ih1 { font-size: 30px; font-weight: 800; letter-spacing: .08em; color: #0d3b1e; }
.imeta { margin-left: auto; font-size: 13px; } .imeta th { text-align: right; color: #555; padding: 2px 8px 2px 0; border: 0; }
.imeta td { text-align: right; padding: 2px 0; border: 0; font-weight: 600; }
.ibill { margin: 6px 0 14px; } .ilabel { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #555; }
.iname { font-size: 17px; font-weight: 700; }
.iitems .ijob td { background: #f1f5f1; font-size: 13px; }
.ipaid { display: inline-block; border: 3px solid #2f6b3a; color: #2f6b3a; font-weight: 800; font-size: 20px;
  letter-spacing: .1em; padding: 4px 14px; transform: rotate(-4deg); margin: 10px 0; }
.inote { margin-top: 16px; }
@media (max-width: 560px) { .ititle { text-align: left; } .imeta { margin-left: 0; } .imeta th, .imeta td { text-align: left; } }
@media print { .iitems .ijob td { background: #f1f5f1 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .ilogo { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

/* sign-in */
.authbox { max-width: 420px; margin: 24px auto; }
.authlogo { display: block; max-width: 280px; width: 100%; margin: 0 auto 12px; }
.who { font-size: 13px; margin-left: auto; white-space: nowrap; }
.who a { color: inherit; }
.linkbtn { background: none; border: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }
form.inline { display: inline; }
@media print { .who { display: none; } }
