:root{
  --bg:#f4f5f7; --card:#fff; --ink:#1d2430; --muted:#5f6b7a; --line:#dde1e7;
  --brand:#1f3a5f; --accent:#e8742b; --accent-ink:#fff;
  --ok:#2e7d4f; --warn:#b7791f; --bad:#c0392b; --info:#2b6cb0;
  --r:10px; --shadow:0 1px 2px rgba(0,0,0,.06),0 4px 14px -6px rgba(0,0,0,.12);
}
*{box-sizing:border-box}
[hidden]{display:none!important}
html,body{margin:0;background:var(--bg);color:var(--ink);font:15px/1.5 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif}
a{color:var(--info);text-decoration:none} a:hover{text-decoration:underline}
h1{font-size:1.45rem;margin:0 0 4px} h2{font-size:1.1rem;margin:0 0 10px} h3{font-size:1rem;margin:0 0 6px}
.muted{color:var(--muted)} .pad{padding:16px} .small{font-size:.85rem}
.topbar{position:sticky;top:0;z-index:10;display:flex;align-items:center;gap:14px;background:var(--brand);color:#fff;padding:10px 16px;flex-wrap:wrap}
.topbar .brand{color:#fff;font-weight:700;font-size:1.05rem}
.topbar nav{display:flex;gap:4px;flex-wrap:wrap;flex:1}
.topbar nav a{color:#d6e2f0;padding:6px 10px;border-radius:8px}
.topbar nav a.on,.topbar nav a:hover{background:rgba(255,255,255,.14);color:#fff;text-decoration:none}
.linkbtn{background:none;border:0;color:#d6e2f0;cursor:pointer;font:inherit}
main{max-width:1100px;margin:0 auto;padding:18px 14px 60px}
.row{display:flex;gap:12px;align-items:center;flex-wrap:wrap}
.between{justify-content:space-between}
.grid{display:grid;gap:14px}
.g2{grid-template-columns:repeat(auto-fit,minmax(300px,1fr))}
.g4{grid-template-columns:repeat(auto-fit,minmax(150px,1fr))}
.card{background:var(--card);border:1px solid var(--line);border-radius:var(--r);padding:16px;box-shadow:var(--shadow)}
.stat .n{font-size:1.7rem;font-weight:700} .stat .l{color:var(--muted);font-size:.85rem}
.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;border:1px solid var(--line);background:#fff;color:var(--ink);border-radius:8px;padding:9px 14px;font:inherit;font-weight:600;cursor:pointer;min-height:40px}
.btn:hover{border-color:#b8c0cc;text-decoration:none}
.btn.primary{background:var(--accent);border-color:var(--accent);color:var(--accent-ink)}
.btn.dark{background:var(--brand);border-color:var(--brand);color:#fff}
.btn.danger{color:var(--bad)}
.btn.sm{min-height:32px;padding:5px 10px;font-size:.88rem}
.btn:disabled{opacity:.5;cursor:default}
form .f{display:flex;flex-direction:column;gap:4px;margin-bottom:12px}
label{font-weight:600;font-size:.88rem}
input,select,textarea{font:inherit;padding:9px 10px;border:1px solid #c5ccd6;border-radius:8px;background:#fff;color:var(--ink);width:100%}
textarea{min-height:80px;resize:vertical}
input:focus,select:focus,textarea:focus{outline:2px solid var(--info);outline-offset:0;border-color:var(--info)}
.list{list-style:none;margin:0;padding:0}
.list li{border-top:1px solid var(--line);padding:11px 2px}
.list li:first-child{border-top:0}
.item{display:flex;justify-content:space-between;gap:10px;align-items:flex-start}
.badge{display:inline-block;border-radius:999px;padding:2px 9px;font-size:.78rem;font-weight:700;text-transform:capitalize;white-space:nowrap;background:#e9edf2;color:#344}
/* Spanish capitalises only the first word ("Esperando firma", not "Esperando Firma") */
html[lang=es] .badge{text-transform:none}
html[lang=es] .badge::first-letter{text-transform:uppercase}
.langsw{margin:0 0 8px;text-align:right}
.s-new{background:#e8eefc;color:#2a4a9a}.s-scheduled{background:#e6f2fb;color:#1e5f8c}
.s-in_progress{background:#fff2dc;color:#8a5a00}.s-completed{background:#e3f4ea;color:#21613d}
.s-invoiced{background:#efe6fb;color:#5b3592}.s-cancelled{background:#f3e3e1;color:#8c2a20}
.p-high{background:#fff0e3;color:#a14a0b}.p-emergency{background:#fde2e0;color:#a31f12}
.d-draft{background:#eef0f3}.d-sent{background:#e6f2fb;color:#1e5f8c}.d-paid{background:#e3f4ea;color:#21613d}
.d-approved{background:#e3f4ea;color:#21613d}.d-declined,.d-void{background:#f3e3e1;color:#8c2a20}
.tabs{display:flex;gap:6px;flex-wrap:wrap;margin:10px 0}
.tabs a{padding:6px 12px;border-radius:999px;background:#e9edf2;color:var(--ink);font-size:.9rem}
.tabs a.on{background:var(--brand);color:#fff;text-decoration:none}
table{width:100%;border-collapse:collapse}
th,td{text-align:left;padding:8px 6px;border-bottom:1px solid var(--line);vertical-align:top}
th{font-size:.82rem;color:var(--muted);font-weight:600}
td.num,th.num{text-align:right;white-space:nowrap}
.photos{display:grid;grid-template-columns:repeat(auto-fill,minmax(110px,1fr));gap:8px}
.photos img{width:100%;aspect-ratio:1;object-fit:cover;border-radius:8px;border:1px solid var(--line)}
.auth{max-width:400px;margin:8vh auto}
.auth h1{color:var(--brand)}
.day{margin-bottom:16px}
.day h3{border-bottom:2px solid var(--line);padding-bottom:4px}
.empty{color:var(--muted);font-style:italic;padding:6px 0}
.err{color:var(--bad);font-weight:600;margin:6px 0}
#toast{position:fixed;left:50%;bottom:22px;transform:translateX(-50%);background:var(--ink);color:#fff;padding:10px 16px;border-radius:8px;opacity:0;transition:opacity .2s;pointer-events:none;max-width:90vw}
#toast.show{opacity:.95}
#offbar{position:fixed;left:0;right:0;bottom:0;z-index:30;background:#7a4b00;color:#fff;text-align:center;padding:12px 16px;font-weight:600;font-size:17px}
@media print{#offbar{display:none!important}}
.statusbar{display:flex;gap:8px;flex-wrap:wrap}
.qr{display:flex;gap:16px;align-items:center;flex-wrap:wrap;margin:6px 0 14px}
.qrbox{background:#fff;border:1px solid var(--line);border-radius:10px;padding:6px;line-height:0}
.qrbox svg{width:210px;height:210px;max-width:60vw;max-height:60vw}
/* good / better / best */
.optgrid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:12px;margin-top:12px}
.optcard{border:2px solid var(--line);border-radius:10px;padding:12px}
.optcard.chosen{border-color:var(--ok)}
label.optpick{display:flex;gap:10px;align-items:center;border:2px solid var(--line);border-radius:10px;padding:12px;margin:8px 0;cursor:pointer;font-weight:600}
label.optpick:has(input:checked){border-color:var(--accent);background:#fff7f1}
label.optpick input{width:26px;height:26px}
/* work authorization: signing page + signature */
.signpage{max-width:720px;margin:0 auto}
.sigwrap{position:relative;border:2px dashed var(--line);border-radius:10px;background:#fff;margin-top:4px}
.sigwrap canvas{display:block;width:100%;height:180px;touch-action:none;cursor:crosshair;border-radius:10px}
.sigwrap .btn{position:absolute;top:6px;right:6px}
.sigdone{margin-top:16px;border-top:1px solid var(--line);padding-top:10px}
.sigdone img{display:block;max-width:320px;width:100%;background:#fff;border-bottom:1px solid var(--ink)}
/* reports chart */
.bars{display:flex;gap:6px;align-items:flex-end;height:180px;padding:8px 0;border-bottom:1px solid var(--line);overflow-x:auto}
.bar{flex:1;min-width:34px;display:flex;flex-direction:column;align-items:center;height:100%;gap:4px}
.bar .cols{flex:1;width:100%;display:flex;gap:2px;align-items:flex-end;justify-content:center}
.bar .cols span{width:42%;border-radius:3px 3px 0 0;min-height:1px}
.b1{background:var(--brand)}.b2{background:var(--accent)}
.key{display:inline-block;width:10px;height:10px;border-radius:2px;vertical-align:middle}
/* import review */
mark{background:#fff3b0;padding:0 2px;border-radius:3px}
.imptable td{font-size:.92rem}
.imptable tr.error td{background:#fdf3f2}
.imptable tr.skipped td{opacity:.55}
.imptable tr.loaded td{background:#f2faf5}
code{background:#eef1f5;padding:0 4px;border-radius:4px}
.tablewrap{overflow-x:auto;-webkit-overflow-scrolling:touch}
@media (max-width:640px){
  main{padding:12px 10px 60px}
  /* phone: brand + sign out on one line, the menu as one swipeable row underneath */
  .topbar{gap:6px 10px;padding:8px 12px}
  .topbar .brand{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  .topbar nav{order:3;flex:0 0 100%;flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none;-webkit-overflow-scrolling:touch}
  .topbar nav::-webkit-scrollbar{display:none}
  .topbar nav a{padding:5px 9px;font-size:.92rem;white-space:nowrap}
  .hide-sm{display:none}
}
/* ---------------------------------------------------------------- phones & tablets (touch screens)
   Travis 11/20: all text and typing boxes 17px (no reading glasses; 16px+ also stops iPhone zooming in
   when a box is tapped), everything you tap is a button at least 48px tall, taller top menu.
   The office computer view (mouse, wide screen) keeps the sizes above. */
@media (max-width:640px),(pointer:coarse){
  :root{--muted:#46505d}                               /* darker grey: readable in sunlight */
  html,body{font-size:17px}
  .small,.stat .l,label,th,.badge,.tabs a,.empty,.imptable td,.err,#toast,td,p,li{font-size:17px}
  h1{font-size:1.4rem} h2{font-size:1.15rem} h3{font-size:1.05rem}
  input,select,textarea,.linkbtn{font-size:17px}
  input,select{min-height:48px}
  input[type=checkbox],input[type=radio]{width:26px!important;height:26px;min-height:0;vertical-align:middle}
  input[type=file]{padding:6px}
  input[type=file]::file-selector-button{font:inherit;font-weight:600;min-height:44px;padding:8px 14px;margin-right:10px;border:1px solid var(--line);border-radius:8px;background:#fff}
  /* every button and button-style link: 48px tall, 17px text */
  .btn,.btn.sm{min-height:48px;padding:10px 16px;font-size:17px}
  .row{gap:10px}
  /* job status: the most-used taps, so full-width and extra tall */
  .statusbar .btn{flex:1 1 140px;min-height:56px}
  /* links become buttons */
  a.back{display:inline-flex;align-items:center;min-height:48px;padding:8px 16px;margin:2px 0 6px;border:1px solid var(--line);border-radius:8px;background:#fff;font-weight:600;font-size:17px}
  a.tap{display:flex;align-items:center;gap:8px;width:100%;min-height:48px;margin:8px 0;padding:10px 14px;border:1px solid var(--line);border-radius:8px;background:#fff;font-weight:600;text-decoration:none}
  a.tap.tel::before{content:"📞";} a.tap.map::before{content:"📍";}
  /* list rows: the title link is a full-width tap target */
  .list li{padding:8px 2px}
  .list li a:not(.btn):not(.tap){display:inline-flex;align-items:center;min-height:48px;font-weight:600}
  .tabs a{display:inline-flex;align-items:center;min-height:48px;padding:8px 16px}
  /* taller top menu with 48px buttons */
  .topbar{padding:10px 12px;position:static}   /* the wrapped menu is tall: let it scroll away instead of covering the job */
  .topbar .brand{font-size:1.1rem}
  .topbar nav{gap:6px;flex-wrap:wrap;overflow-x:visible}   /* wrap to a second row: every button shows, no hidden swipe */
  .topbar nav a{display:inline-flex;align-items:center;min-height:48px;padding:8px 16px;font-size:17px;background:rgba(255,255,255,.06)}
  .linkbtn{min-height:48px;padding:8px 12px;border:1px solid rgba(255,255,255,.35);border-radius:8px}
  .sigwrap .btn{min-height:44px}
  /* estimate/invoice editor: each line stacks — description full width, then qty | price | remove */
  table:has(#rows) thead{display:none}
  #rows tr{display:grid;grid-template-columns:1fr 1fr;gap:6px 8px;align-items:end;padding:10px 0;border-bottom:1px solid var(--line)}
  #rows td{padding:0;border:0}
  #rows td:first-child{grid-column:1/-1}
  #rows td:last-child{grid-column:1/-1;justify-self:end}
  #rows td:nth-child(-n+5)::before{display:block;font-weight:600;font-size:17px;color:var(--muted);margin-bottom:2px}
  #rows td:nth-child(1)::before{content:"Description"}
  #rows td:nth-child(2)::before{content:"Qty"}
  #rows td:nth-child(3)::before{content:"Price ($)"}
  #rows td:nth-child(4)::before{content:"Type"}
  #rows td:nth-child(5)::before{content:"Option"}
  #rows .btn{min-width:48px}
}
@media print{
  .topbar,.noprint,#toast{display:none!important}
  body,main{background:#fff;padding:0}
  .card{box-shadow:none;border:0;padding:0}
}

/* Settings: how emails are sent */
label.routepick{display:flex;gap:10px;align-items:flex-start;text-align:left}
label.routepick input{width:auto;margin-top:4px}
.subcard{border:1px solid #dde3ea;border-radius:10px;padding:12px 14px;margin-top:12px;background:#fafbfc}
table.dns td,table.dns th{font-size:.85rem;vertical-align:top}
