:root{
  --navy:#0b1826;--navy-2:#13263b;--red:#c62f3b;--red-d:#a8222d;--ink:#14202c;--muted:#5b6876;
  --line:#dde3ea;--bg:#f4f6f9;--card:#ffffff;--ok:#1d7a46;--warn:#b26a00;
  --safe-top:env(safe-area-inset-top);--safe-bottom:env(safe-area-inset-bottom);
}
*{box-sizing:border-box}
html,body{margin:0;background:var(--bg);color:var(--ink);
  font:16px/1.45 system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;-webkit-text-size-adjust:100%}
button,input,select,textarea{font:inherit;color:inherit}
.top{position:sticky;top:0;z-index:5;display:flex;align-items:center;gap:10px;
  padding:calc(10px + var(--safe-top)) 16px 10px;background:var(--navy);border-bottom:3px solid var(--red)}
.top .logo{height:40px;width:auto}
.top .back{background:none;border:0;color:#fff;font-size:34px;line-height:1;padding:0 8px 4px 0;cursor:pointer}
.top .sync{margin-left:auto;color:#fff;font-size:13px;background:var(--red);border-radius:12px;padding:3px 9px}
.top .sync:empty{display:none}
main{max-width:680px;margin:0 auto;padding:16px 16px calc(32px + var(--safe-bottom))}
h1{font-size:22px;margin:4px 0 4px}
h2{font-size:17px;margin:22px 0 8px}
.muted{color:var(--muted)}
.center{text-align:center}
.small{font-size:13px}
.card{background:var(--card);border:1px solid var(--line);border-radius:14px;padding:14px 16px;margin:10px 0}
.btn{display:block;width:100%;border:0;border-radius:12px;padding:14px 16px;font-weight:600;cursor:pointer;
  background:var(--red);color:#fff;text-align:center;text-decoration:none}
.btn:active{background:var(--red-d)}
.btn.secondary{background:#fff;color:var(--navy);border:1.5px solid var(--navy)}
.btn.ghost{background:none;color:var(--navy);border:0;text-decoration:underline;font-weight:500}
.btn[disabled]{opacity:.5}
.row{display:flex;gap:10px}
.row>*{flex:1}
.grid{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin:14px 0}
.tile{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;min-height:104px;
  border-radius:16px;border:0;background:var(--navy);color:#fff;font-weight:600;cursor:pointer}
.tile:active{background:var(--navy-2)}
.tile svg{width:34px;height:34px;stroke:#fff;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.tile.red{background:var(--red)}
label{display:block;font-weight:600;font-size:14px;margin:12px 0 4px}
input[type=text],input[type=search],input[type=number],select,textarea{width:100%;padding:12px;border:1.5px solid var(--line);
  border-radius:10px;background:#fff}
input:focus,select:focus,textarea:focus{outline:2px solid var(--red);border-color:transparent}
textarea{min-height:80px;resize:vertical}
.proj{display:block;text-decoration:none;color:inherit;cursor:pointer}
.proj .num{font-weight:700;color:var(--red);letter-spacing:.02em}
.proj .name{font-weight:600}
.chips{display:flex;flex-wrap:wrap;gap:8px;margin:8px 0}
.chip{border:1.5px solid var(--line);background:#fff;border-radius:20px;padding:6px 12px;font-size:14px;cursor:pointer}
.chip:active{border-color:var(--red)}
.preview{width:100%;max-height:52vh;object-fit:contain;border-radius:12px;background:#000;display:block}
.cap{display:flex;gap:10px;align-items:flex-start;padding:10px 0;border-top:1px solid var(--line)}
.cap:first-child{border-top:0}
.cap .k{font-size:12px;font-weight:700;color:#fff;background:var(--navy);border-radius:6px;padding:2px 6px;white-space:nowrap}
.cap .t{flex:1;min-width:0}
.cap .t div{overflow-wrap:anywhere}
.badge{font-size:12px;border-radius:6px;padding:2px 6px;background:#eef2f6;color:var(--muted)}
.badge.ok{background:#e3f4ea;color:var(--ok)}
.badge.warn{background:#fff2dc;color:var(--warn)}
.rec{font-size:44px;font-weight:700;text-align:center;font-variant-numeric:tabular-nums;margin:18px 0}
.dot{display:inline-block;width:14px;height:14px;border-radius:50%;background:var(--red);margin-right:8px;
  animation:blink 1s infinite}
@keyframes blink{50%{opacity:.2}}
.number{font-size:24px;font-weight:800;letter-spacing:.03em;color:var(--navy);word-break:break-all}
.toast{position:fixed;left:50%;bottom:calc(20px + var(--safe-bottom));transform:translateX(-50%);background:var(--navy);
  color:#fff;padding:10px 16px;border-radius:10px;font-size:14px;z-index:20;max-width:90vw}
.err{color:var(--red);font-weight:600}
details summary{cursor:pointer;font-weight:600;padding:6px 0}
@media (prefers-reduced-motion:reduce){.dot{animation:none}}

.tile.wide{grid-column:1/-1;min-height:72px;flex-direction:row;gap:10px}
.btn.big{font-size:18px;padding:18px 16px;margin:10px 0}
.btn.navy{background:var(--navy)}
.btn.secondary{margin:14px 0 6px}
.status{border-radius:12px;padding:12px 14px;margin:12px 0 4px;font-size:15px}
.status.ok{background:#e3f4ea;color:var(--ok);font-weight:700;text-align:center}
.status.warn{background:#fff2dc;color:#7a4a00}
.status.busy{background:#e8eef6;color:var(--navy)}
.bar{height:8px;background:#fff;border-radius:4px;margin-top:8px;overflow:hidden}
.bar span{display:block;height:100%;background:var(--red);transition:width .2s}
.flash{position:fixed;inset:0;z-index:30;display:flex;flex-direction:column;align-items:center;justify-content:center;
  gap:10px;background:rgba(11,24,38,.82);color:#fff;font-size:20px;font-weight:700;text-align:center;padding:24px;
  animation:fadeout 1.6s forwards}
.flash .tick{width:96px;height:96px;border-radius:50%;background:var(--ok);display:flex;align-items:center;
  justify-content:center;font-size:60px;line-height:1}
@keyframes fadeout{0%,75%{opacity:1}100%{opacity:0}}
@media (prefers-reduced-motion:reduce){.flash{animation:none}}

/* First Eng Office (/office): the same app laid out for a computer */
body.office main{max-width:1120px}
body.office .top::after{content:"Office";color:#fff;font-weight:700;font-size:18px;letter-spacing:.04em;order:3;margin-left:8px}
body.office .top .sync{order:4}
.tools{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:12px;margin:10px 0 18px}
.ptable{width:100%;border-collapse:separate;border-spacing:0;background:#fff;border:1px solid var(--line);border-radius:14px;
  overflow:hidden;margin-top:12px;font-size:15px}
.ptable th{background:var(--navy);color:#fff;text-align:left;font-weight:600;padding:10px 12px}
.ptable td{padding:10px 12px;border-top:1px solid var(--line);vertical-align:top}
.ptable tr.proj{cursor:pointer}
.ptable tr.proj:hover td{background:#f0f4f9}
@media (min-width:900px){body.office .btn{width:auto;display:inline-block;padding:12px 22px}
  body.office .tools .btn,body.office .card .btn{width:100%;display:block}}

.drop{border:2px dashed var(--line,#ccc);border-radius:12px;padding:12px;margin:12px 0}
.drop.over{border-color:var(--accent,#1a6);background:rgba(0,128,96,.06)}

/* ---- backgrounds: Field = light outdoor site (readable in sun), Office = dark drafting sheet ---- */
body::before{content:"";position:fixed;inset:0;z-index:-1;pointer-events:none}
html,body{background:transparent}
html:not(.light){background:#1c2c45}
body:not(.light)::before{background:#1c2c45 url(/static/bg-office.svg) center/cover no-repeat}
body:not(.light){color:#e6edf6}
body:not(.light) main>h1,body:not(.light) main>h2,body:not(.light) main>p,body:not(.light) main>.num,body:not(.light) main>label{color:#e6edf6}
body:not(.light) .muted{color:#9fb0c6}
body:not(.light) .card,body:not(.light) .card .muted{color:var(--ink)}
body:not(.light) .card .muted{color:var(--muted)}
body:not(.light) input,body:not(.light) select,body:not(.light) textarea{color:var(--ink)}
body:not(.light) main>.btn.ghost,body:not(.light) main>a.btn.ghost{color:#e6edf6}
body:not(.light) .top{background:rgba(18,32,52,.92);backdrop-filter:blur(6px)}
/* Office buttons must stand out on the dark drafting background */
body .btn.navy,body .tile{background:var(--red);border:1px solid #e98a93;color:#fff;box-shadow:0 3px 10px rgba(0,0,0,.4)}
body .btn.navy:hover,body .tile:hover{background:#d63c48}
body .btn.navy:active{background:var(--red-d)}
body .btn:not(.ghost):not(.secondary){box-shadow:0 3px 10px rgba(0,0,0,.4)}
body .btn.secondary{background:#fff;border-color:#e98a93}
body:not(.light) main>.btn.ghost,body:not(.light) main>a.btn.ghost,body:not(.light) main>button.btn.ghost{color:#cfe0f5}
/* fee proposal tables */
table.fp{width:100%;border-collapse:collapse;font-size:14px}
table.fp th{text-align:left;font-size:12px;color:var(--muted);border-bottom:1.5px solid var(--line);padding:6px 4px}
table.fp td{border-bottom:1px solid var(--line);padding:6px 4px;vertical-align:top}
table.fp tr.grp td{background:#eef2f7;font-weight:700;font-size:12px;text-transform:uppercase;letter-spacing:.04em;color:var(--navy)}
table.fp input[type=number]{width:84px;padding:6px 8px}
table.fp input[type=checkbox]{width:20px;height:20px}
label.chk{display:flex;gap:8px;align-items:flex-start;font-weight:400;margin:6px 0}
label.chk input{margin-top:3px}
/* text and links straight on the dark Office background */
body:not(.light) .proj:not(.card),body:not(.light) .proj:not(.card) .muted,body:not(.light) .proj:not(.card) .small{color:#dbe4ef}
body:not(.light) main a:not(.btn){color:#ffd1d5;text-decoration:underline}
body:not(.light) .card a:not(.btn){color:#a8222d}

/* light mode (switch in the top bar): the light building-site background, for bright sun */
html.light{background:#f3f6fa}
body.light::before{background:#f3f6fa url(/static/bg-field.svg) center bottom/cover no-repeat}
.top .mode{margin-left:auto;order:5;background:rgba(255,255,255,.12);border:1px solid rgba(255,255,255,.35);color:#fff;
  border-radius:20px;padding:4px 12px;font-size:14px;cursor:pointer;white-space:nowrap}
.top .sync:not(:empty)~.mode{margin-left:8px}
.badge.err{background:#fde2e1;color:#a8222d}
.badge.busy{background:#e3edf9;color:#1f4f8a}

/* clear Back and Home buttons in the top bar */
.top .back,.top .home{background:rgba(255,255,255,.14);border:1px solid rgba(255,255,255,.4);color:#fff;font-size:15px;font-weight:600;
  line-height:1;padding:8px 12px;border-radius:18px;cursor:pointer;white-space:nowrap}
.top .back:hover,.top .home:hover{background:rgba(255,255,255,.26)}
.top .back[hidden],.top .home[hidden]{display:none}
body.light .top .back,body.light .top .home{color:#fff}
@media (max-width:420px){.top .logo{height:32px}.top .back,.top .home{padding:7px 9px;font-size:14px}}
@media (max-width:420px){.top #gohome:not([hidden]) ~ .logo{display:none}}

/* sketch pad and photo measuring */
canvas.sketch{width:100%;height:auto;display:block;touch-action:none;border-radius:8px;background:#fff;margin:8px 0;box-shadow:0 2px 10px rgba(0,0,0,.35)}
.sktools{display:flex;flex-wrap:wrap;gap:6px;align-items:center;margin:6px 0}
.sktools .btn{width:auto;margin:0;padding:8px 10px}
.sktools .btn.on{background:var(--red);color:#fff;border-color:#e98a93}
.swatch{width:34px;height:34px;border-radius:50%;border:2px solid rgba(255,255,255,.5);cursor:pointer;padding:0}
.swatch.on{outline:3px solid #fff;outline-offset:2px}
body.light .swatch{border-color:#999}body.light .swatch.on{outline-color:#1f3864}
/* measure screen: chosen element / measurement */
.chip.on{background:var(--red);color:#fff;border-color:#e98a93}
