/* SnagKing styles.
   Idea: a site inspection sheet. A dark "title block" (like a drawing's title block) carries the
   property, builder and progress; hi-vis yellow is used only for the main action and progress.
   Below it, plain snag tickets on a cool paper background. One typeface (Archivo) at two widths. */
:root{
  --paper:#eef0ed; --surface:#ffffff; --surface-2:#f5f6f4; --ink:#15212a; --muted:#59656e; --line:#d6dbd9;
  --block:#15212a; --block-2:#22313b; --block-ink:#f3f6f5; --block-muted:#a3b2bb;
  --hi:#f5c400; --hi-ink:#15212a; --focus:#1d6fa3;
  --a:#c4361c; --a-soft:#fbe6e1; --b:#9f6400; --b-soft:#fbefd6; --c:#2c774b; --c-soft:#e0f0e6;
  --sent:#1d5f8a; --sent-soft:#e1edf5;
  --shadow:0 1px 0 rgba(21,33,42,.04),0 2px 8px rgba(21,33,42,.06);
  --f:"Archivo",system-ui,-apple-system,"Segoe UI",sans-serif;
  color-scheme:light;
}
@media (prefers-color-scheme:dark){:root:not([data-theme="light"]){
  --paper:#0e1418; --surface:#172027; --surface-2:#1d2830; --ink:#e7ecee; --muted:#96a4ad; --line:#29353d;
  --block:#1a252c; --block-2:#24323b; --block-ink:#f3f6f5; --block-muted:#93a4ae;
  --a:#ff8f78; --a-soft:#3a1e19; --b:#f0b64a; --b-soft:#36290f; --c:#7fcc9b; --c-soft:#17301f;
  --sent:#7fb8de; --sent-soft:#16293a; --focus:#7fb8de;
  --shadow:0 1px 2px rgba(0,0,0,.35); color-scheme:dark}}
:root[data-theme="dark"]{
  --paper:#0e1418; --surface:#172027; --surface-2:#1d2830; --ink:#e7ecee; --muted:#96a4ad; --line:#29353d;
  --block:#1a252c; --block-2:#24323b; --block-ink:#f3f6f5; --block-muted:#93a4ae;
  --a:#ff8f78; --a-soft:#3a1e19; --b:#f0b64a; --b-soft:#36290f; --c:#7fcc9b; --c-soft:#17301f;
  --sent:#7fb8de; --sent-soft:#16293a; --focus:#7fb8de;
  --shadow:0 1px 2px rgba(0,0,0,.35); color-scheme:dark}

*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{margin:0;background:var(--paper);color:var(--ink);font-family:var(--f);font-size:15px;line-height:1.45;
  padding-bottom:calc(96px + env(safe-area-inset-bottom,0px));font-variant-numeric:tabular-nums}
button,input,select,textarea{font:inherit;color:inherit}
button{cursor:pointer;-webkit-tap-highlight-color:transparent}
:focus-visible{outline:2px solid var(--focus);outline-offset:2px}
[hidden]{display:none!important}
img{max-width:100%}
svg{flex:none}

/* ---------- title block ---------- */
.tb{background:var(--block);color:var(--block-ink);padding:calc(14px + env(safe-area-inset-top,0px)) 16px 18px}
.tb-in{max-width:720px;margin:0 auto}
.tb-top{display:flex;align-items:center;justify-content:space-between;gap:12px}
.brand{display:flex;align-items:center;gap:8px;font-weight:700;font-size:15px;letter-spacing:.01em;font-stretch:112%}
.brand svg{width:22px;height:22px}
.tb .iconbtn{background:var(--block-2);border-color:transparent}
.tb .iconbtn svg{stroke:var(--block-ink)}
.tb h1{font-stretch:75%;font-weight:800;font-size:clamp(34px,10vw,46px);line-height:.95;letter-spacing:-.005em;margin:18px 0 6px;text-wrap:balance}
.tb-sub{margin:0;color:var(--block-muted);font-size:14px}
.tb-sub b{color:var(--block-ink);font-weight:600}

.prog{margin-top:18px}
.prog-row{display:flex;justify-content:space-between;align-items:baseline;gap:12px;margin-bottom:8px;font-size:14px}
.prog-row b{font-weight:700;font-size:15px}
.prog-row span{color:var(--block-muted)}
.prog-bar{height:8px;border-radius:4px;background:var(--block-2);overflow:hidden}
.prog-bar i{display:block;height:100%;width:0;background:var(--hi);border-radius:4px;transition:width .5s ease}

.tally{display:grid;grid-template-columns:repeat(4,1fr);margin-top:16px;border-top:1px solid var(--block-2)}
.tile{padding:12px 0 0;display:flex;flex-direction:column;gap:2px}
.tile+.tile{padding-left:12px;border-left:1px solid var(--block-2)}
.tile b{font-stretch:75%;font-weight:800;font-size:30px;line-height:1}
.tile span{font-size:12px;color:var(--block-muted)}
.tile.A b{color:#ff9c86} .tile.B b{color:#f6bf55} .tile.C b{color:#8fd3a8} .tile.F b{color:var(--block-ink)}

/* ---------- list ---------- */
.wrap{max-width:720px;margin:0 auto;padding:14px 16px 0;display:flex;flex-direction:column;gap:12px}
.filters{display:flex;gap:6px;overflow-x:auto;scrollbar-width:none;margin:0 -16px;padding:0 16px 2px}
.filters::-webkit-scrollbar{display:none}
.chip{border:1px solid var(--line);background:var(--surface);border-radius:999px;padding:7px 13px;font-size:13px;font-weight:600;white-space:nowrap;color:var(--ink)}
.chip[aria-pressed="true"]{background:var(--ink);color:var(--paper);border-color:var(--ink)}

.list{display:flex;flex-direction:column;gap:8px}
.card{display:grid;grid-template-columns:72px 1fr;gap:12px;align-items:start;background:var(--surface);border:1px solid var(--line);
  border-radius:12px;padding:10px 12px 10px 10px;text-align:left;width:100%;box-shadow:var(--shadow);position:relative;overflow:hidden}
.card::before{content:"";position:absolute;left:0;top:0;bottom:0;width:4px;background:var(--sev)}
.card.A{--sev:var(--a)} .card.B{--sev:var(--b)} .card.C{--sev:var(--c)}
.card.isfixed{--sev:var(--line)}
.card.isfixed .loc,.card.isfixed .desc{color:var(--muted)}
.card.isfixed .thumb img{filter:grayscale(.7);opacity:.75}
.thumb{width:72px;height:72px;margin-left:4px;border-radius:8px;background:var(--surface-2);display:grid;place-items:center;color:var(--muted);position:relative}
.thumb svg{width:24px;height:24px;stroke:currentColor;opacity:.6}
.thumb img{width:100%;height:100%;object-fit:cover;border-radius:8px}
.thumb .n{position:absolute;right:4px;bottom:4px;background:rgba(10,16,20,.72);color:#fff;font-size:11px;font-weight:600;border-radius:5px;padding:0 5px;line-height:17px}
.cbody{min-width:0;display:flex;flex-direction:column;gap:3px}
.ctop{display:flex;align-items:flex-start;gap:8px;min-width:0}
.loc{font-weight:700;font-size:16px;line-height:1.2;min-width:0;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}
.ref{font-size:12px;color:var(--muted);font-weight:500;margin-left:auto;flex:none;line-height:22px}
.desc{font-size:14px;color:var(--ink);overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}
.meta{display:flex;gap:8px;align-items:center;font-size:12px;color:var(--muted);margin-top:4px;white-space:nowrap}
.meta .pill{flex:none}
.meta span:last-child{overflow:hidden;text-overflow:ellipsis}
.badge{font-stretch:75%;font-weight:800;font-size:15px;width:22px;height:22px;border-radius:5px;display:inline-grid;place-items:center;flex:none}
.badge.A{background:var(--a-soft);color:var(--a)} .badge.B{background:var(--b-soft);color:var(--b)} .badge.C{background:var(--c-soft);color:var(--c)}
.pill{display:inline-flex;align-items:center;gap:4px;font-size:12px;font-weight:600;padding:2px 8px;border-radius:999px;border:1px solid var(--line);color:var(--ink)}
.pill.notified{background:var(--sent-soft);color:var(--sent);border-color:transparent}
.pill.fixed{background:var(--c-soft);color:var(--c);border-color:transparent}
.pill svg{width:12px;height:12px;stroke:currentColor}

.empty{background:var(--surface);border:1px dashed var(--line);border-radius:12px;padding:28px 22px;text-align:center;color:var(--muted)}
.empty h2{font-stretch:75%;font-weight:800;font-size:24px;color:var(--ink);margin:0 0 6px}
.empty p{margin:0 auto;max-width:34ch}
.notice{font-size:13px;color:var(--muted);background:var(--surface-2);border-radius:10px;padding:10px 12px}

/* ---------- bottom bar ---------- */
.bar{position:fixed;left:0;right:0;bottom:0;z-index:6;background:color-mix(in srgb,var(--surface) 94%,transparent);
  backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border-top:1px solid var(--line);padding:10px 16px calc(10px + env(safe-area-inset-bottom,0px))}
.bar .in{max-width:720px;margin:0 auto;display:grid;grid-template-columns:1fr 1fr;gap:10px}
.bar .btn{white-space:nowrap;padding-inline:8px;gap:6px;font-size:clamp(13px,3.9vw,15px)}
.btn{border:1px solid var(--line);background:var(--surface);color:var(--ink);border-radius:12px;padding:12px 14px;font-weight:700;font-size:15px;
  display:flex;align-items:center;justify-content:center;gap:8px;min-height:50px;text-align:center;text-decoration:none}
.btn.primary{background:var(--hi);color:var(--hi-ink);border-color:var(--hi)}
.btn.dark{background:var(--ink);color:var(--paper);border-color:var(--ink)}
.btn.danger{color:var(--a);border-color:var(--a);background:transparent}
.btn.danger.solid{background:var(--a);color:#fff}
.btn:disabled{opacity:.5;cursor:not-allowed}
.btn svg{width:20px;height:20px;stroke:currentColor}
.btn:active:not(:disabled){transform:translateY(1px)}
.iconbtn{border:1px solid var(--line);background:var(--surface);border-radius:10px;width:40px;height:40px;display:grid;place-items:center;flex:none}
.iconbtn svg{width:20px;height:20px;stroke:var(--ink)}

/* ---------- sheets ---------- */
.scrim{position:fixed;inset:0;background:rgba(8,12,15,.5);z-index:20;display:flex;align-items:flex-end;justify-content:center}
.sheet{background:var(--surface);width:100%;max-width:720px;max-height:92%;overflow-y:auto;overscroll-behavior:contain;border-radius:18px 18px 0 0;
  padding:8px 16px calc(20px + env(safe-area-inset-bottom,0px));display:flex;flex-direction:column;gap:16px}
.sheet::before{content:"";align-self:center;width:40px;height:4px;border-radius:2px;background:var(--line);flex:none}
.shead{display:flex;justify-content:space-between;align-items:center;gap:10px}
.shead h2{font-stretch:75%;font-weight:800;font-size:28px;line-height:1;margin:0}
.shead .ref{margin-left:8px;font-size:14px}
.lbl{display:block;font-size:13px;font-weight:600;color:var(--muted);margin-bottom:6px}
label.f{display:flex;flex-direction:column;gap:6px;font-size:13px;font-weight:600;color:var(--muted)}
input[type=text],input[type=email],input[type=tel],input[type=date],textarea,select{background:var(--surface-2);border:1px solid var(--line);border-radius:10px;padding:12px;font-size:16px;font-weight:400;color:var(--ink);width:100%;min-height:48px;-webkit-appearance:none;appearance:none}
input[aria-invalid="true"]{border-color:var(--a);outline:2px solid var(--a);outline-offset:-1px}
input:focus,textarea:focus{outline:2px solid var(--focus);outline-offset:-1px;border-color:transparent}
textarea{min-height:92px;resize:vertical}
.photos{display:grid;grid-template-columns:repeat(auto-fill,minmax(88px,1fr));gap:8px}
.photos:empty{display:none}
.ph{position:relative;aspect-ratio:1;border-radius:10px;overflow:hidden;background:var(--surface-2)}
.ph img{width:100%;height:100%;object-fit:cover}
.ph button{position:absolute;top:4px;right:4px;width:28px;height:28px;border-radius:50%;border:0;background:rgba(10,16,20,.7);color:#fff;font-weight:700;line-height:1}
.ph .up{position:absolute;inset:0;display:grid;place-items:center;background:rgba(10,16,20,.35);color:#fff;font-size:12px}
.pickrow{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:8px}
.photos:empty+.pickrow{margin-top:0}
/* The real file input covers the whole button (opacity 0). iPhone needs the tap to land on the input itself. */
.pickbtn{position:relative;overflow:hidden;border:1.5px dashed var(--muted);border-radius:12px;min-height:58px;display:flex;align-items:center;justify-content:center;gap:8px;
  color:var(--ink);font-weight:700;font-size:15px;background:var(--surface-2)}
.pickbtn svg{width:22px;height:22px;stroke:currentColor}
.pickbtn input{position:absolute;inset:0;width:100%;height:100%;opacity:0;cursor:pointer;font-size:200px}
.pickbtn:focus-within{outline:2px solid var(--focus);outline-offset:2px}
.seg{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}
.seg button{border:1.5px solid var(--line);background:var(--surface);border-radius:12px;padding:10px;text-align:left;display:flex;flex-direction:column;gap:4px}
.seg button b{font-stretch:75%;font-weight:800;font-size:28px;line-height:1}
.seg button small{font-size:12px;color:var(--muted);line-height:1.3}
.seg button[data-r="A"] b{color:var(--a)} .seg button[data-r="B"] b{color:var(--b)} .seg button[data-r="C"] b{color:var(--c)}
.seg button[aria-pressed="true"][data-r="A"]{border-color:var(--a);background:var(--a-soft)}
.seg button[aria-pressed="true"][data-r="B"]{border-color:var(--b);background:var(--b-soft)}
.seg button[aria-pressed="true"][data-r="C"]{border-color:var(--c);background:var(--c-soft)}
.status3{display:grid;grid-template-columns:repeat(3,1fr);gap:6px;background:var(--surface-2);padding:4px;border-radius:12px}
.status3 button{border:0;background:transparent;border-radius:9px;padding:10px 4px;font-weight:600;font-size:13.5px;white-space:nowrap;color:var(--muted)}
.status3 button[aria-pressed="true"]{background:var(--surface);color:var(--ink);box-shadow:var(--shadow)}
.row-ref{display:grid;grid-template-columns:1fr 92px;gap:10px}
.row2{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.confirm{background:var(--a-soft);border-radius:12px;padding:14px;display:flex;flex-direction:column;gap:12px;font-size:14px;color:var(--ink)}
.confirm b{color:var(--a)}
html.sheet-open{overflow:hidden}
.banner.ok{background:var(--c-soft)}
.banner{background:var(--b-soft);border-radius:12px;padding:14px;display:flex;flex-direction:column;gap:12px;font-size:14px;color:var(--ink)}
.danger-zone{border-top:1px solid var(--line);padding-top:16px;display:flex;flex-direction:column;gap:8px}
.danger-zone p{margin:0;font-size:13px;color:var(--muted)}
pre.email{white-space:pre-wrap;word-break:break-word;background:var(--surface-2);border:1px solid var(--line);border-radius:10px;padding:12px;font-family:var(--f);font-size:13px;line-height:1.5;max-height:240px;overflow:auto;margin:0}
.to{font-size:14px;color:var(--muted);display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.addr{font-weight:600;color:var(--ink);user-select:all}
.summary{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}
.summary div{background:var(--surface-2);border-radius:10px;padding:10px}
.summary b{display:block;font-stretch:75%;font-weight:800;font-size:26px;line-height:1}
.summary span{font-size:12px;color:var(--muted)}
.toast{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(86px + env(safe-area-inset-bottom,0px));background:var(--ink);color:var(--paper);
  padding:10px 16px;border-radius:999px;font-weight:600;font-size:14px;z-index:40;max-width:calc(100% - 32px);box-shadow:0 4px 18px rgba(0,0,0,.2)}
.hint{font-size:13px;color:var(--muted);margin:0}
@media (prefers-reduced-motion:no-preference){
  .sheet{animation:up .24s cubic-bezier(.2,.8,.2,1)}
  @keyframes up{from{transform:translateY(32px);opacity:.5}to{transform:none;opacity:1}}
}
@media (prefers-reduced-motion:reduce){.prog-bar i{transition:none}}
@media (max-width:360px){.tile b{font-size:26px}.tile+.tile{padding-left:8px}}

/* Netlify's free plan injects a "Powered by Netlify" badge (iframe #nl-badge-frame), fixed
   bottom-right, about 60px tall, above everything. It can't be removed on the free plan, so
   when it's present, leave a strip at the bottom for it and keep our buttons above it. */
:root:has(#nl-badge-frame){--badge:62px}
:root:has(#nl-badge-frame) body{padding-bottom:calc(96px + var(--badge))}
:root:has(#nl-badge-frame) .bar{padding-bottom:max(var(--badge), calc(10px + env(safe-area-inset-bottom,0px)))}
:root:has(#nl-badge-frame) .sheet{padding-bottom:max(calc(var(--badge) + 8px), calc(20px + env(safe-area-inset-bottom,0px)))}
:root:has(#nl-badge-frame) .toast{bottom:calc(86px + var(--badge))}
