:root {
  --brand: #04aeef;
  --brand-deep: #0093b5;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --soft: #f8fafc;
  --ok: #10b981;
  --warn: #f59e0b;
  --bad: #ef4444;
  --hero: #0b0f14;
  --hero-ink: #ffffff;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
  --r: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e8eef5; --muted: #8b9bb0; --line: #223041; --bg: #0b0f14; --card: #131b25; --soft: #17212d;
    --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #e8eef5; --muted: #8b9bb0; --line: #223041; --bg: #0b0f14; --card: #131b25; --soft: #17212d;
  --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.45 Inter, system-ui, -apple-system, sans-serif; -webkit-font-smoothing: antialiased; min-height: 100dvh; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
.wrap { max-width: 560px; margin: 0 auto; padding: 0 16px; }
.h-font { font-family: Oswald, Inter, sans-serif; letter-spacing: .01em; text-transform: uppercase; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- Hero header ---------- */
.hero {
  background: radial-gradient(120% 140% at 100% 0%, rgba(4,174,239,.35), transparent 55%), var(--hero);
  color: var(--hero-ink);
  padding: calc(var(--safe-t) + 14px) 0 64px;
  position: relative;
}
.hero .row { display: flex; align-items: center; gap: 12px; }
.brandmark { width: 40px; height: 40px; border-radius: 12px; background: #000 url(/img/icon.jpg) center/130% no-repeat; flex: none; }
.hero .who { flex: 1; min-width: 0; }
.hero .hello { font-size: 13px; opacity: .7; }
.hero .name { font: 600 22px/1.1 Oswald, sans-serif; text-transform: uppercase; letter-spacing: .02em; }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: #1e293b; border: 2px solid rgba(255,255,255,.2); display: grid; place-items: center; font-weight: 700; flex: none; }
.iconbtn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: rgba(255,255,255,.08); color: #fff; flex: none; }
.iconbtn svg { width: 20px; height: 20px; }

.days { display: flex; gap: 8px; margin-top: 18px; overflow-x: auto; scrollbar-width: none; }
.days::-webkit-scrollbar { display: none; }
.day { flex: none; padding: 9px 14px; border-radius: 999px; background: rgba(255,255,255,.08); color: rgba(255,255,255,.8); font-weight: 600; font-size: 14px; }
.day.on { background: var(--brand); color: #001018; }
.day input { position: absolute; opacity: 0; pointer-events: none; }

.summary { display: flex; gap: 10px; margin-top: 16px; }
.stat { flex: 1; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08); border-radius: 14px; padding: 10px 12px; }
.stat b { display: block; font: 600 24px/1 Oswald, sans-serif; }
.stat span { font-size: 12px; opacity: .65; }

.lift { margin-top: -44px; position: relative; }

/* ---------- Cards ---------- */
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); border: 1px solid var(--line); }
.pad { padding: 16px; }
.stack > * + * { margin-top: 12px; }
.label { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

.job { display: block; padding: 16px; position: relative; overflow: hidden; }
.job .top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.job .time { font: 600 26px/1 Oswald, sans-serif; }
.job .addr { font-weight: 700; margin-top: 6px; font-size: 17px; }
.job .city { color: var(--muted); font-size: 14px; }
.job .chips { margin-top: 12px; }
.job.next { border: 2px solid var(--brand); }
.job .bar { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--brand); transition: width .4s; }
.badge { font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 999px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.badge.go { background: rgba(4,174,239,.14); color: var(--brand-deep); }
.badge.done { background: rgba(16,185,129,.15); color: #059669; }
.badge.next { background: var(--brand); color: #001018; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--soft); border: 1px solid var(--line); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip.toggle { opacity: .5; }
.chip.toggle.on { opacity: 1; border-color: currentColor; }
.chip.warn { background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.4); color: #b45309; }
.chip.office { opacity: .65; font-weight: 500; }

.empty { text-align: center; padding: 40px 20px; }
.empty .big { font-size: 44px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 18px; border-radius: 14px; font-weight: 700; background: var(--soft); border: 1px solid var(--line); min-height: 50px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #001018; }
.btn.dark { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.btn svg { width: 18px; height: 18px; }
.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.act { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px; border-radius: 14px; background: var(--soft); border: 1px solid var(--line); font-size: 12px; font-weight: 600; }
.act svg { width: 22px; height: 22px; color: var(--brand); }
.act[aria-disabled="true"] { opacity: .35; pointer-events: none; }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; background: radial-gradient(100% 70% at 50% 0%, rgba(4,174,239,.3), transparent 60%), var(--hero); color: #fff; padding: calc(var(--safe-t) + 24px) 0 calc(var(--safe-b) + 24px); }
.login .logo { width: 160px; height: 160px; display: block; margin: 0 auto; border-radius: 36px; box-shadow: 0 0 0 1px rgba(255,255,255,.08), 0 20px 60px rgba(4,174,239,.25); }
.login h1 { text-align: center; font: 600 13px/1 Inter, sans-serif; text-transform: uppercase; margin: 18px auto 10px; letter-spacing: .2em; color: var(--brand); }
.login p { text-align: center; opacity: .7; margin: 0 0 24px; }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 13px; font-weight: 600; opacity: .8; margin-bottom: 6px; }
.field input, .textarea { width: 100%; padding: 15px 16px; border-radius: 14px; border: 1px solid rgba(255,255,255,.15); background: rgba(255,255,255,.06); color: inherit; font-size: 18px; outline: none; }
.field input:focus { border-color: var(--brand); }
.err { background: rgba(239,68,68,.15); color: #fecaca; padding: 12px 14px; border-radius: 12px; font-size: 14px; margin-bottom: 12px; }
.textarea { background: var(--soft); border-color: var(--line); font-size: 16px; min-height: 90px; resize: vertical; }

/* ---------- Job screen ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--hero); color: #fff; padding-top: var(--safe-t); }
.topbar .row { display: flex; align-items: center; gap: 10px; height: 56px; }
.topbar .t { flex: 1; min-width: 0; }
.topbar .t b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
.topbar .t small { opacity: .65; font-size: 12px; }
.ring { width: 44px; height: 44px; flex: none; position: relative; display: grid; place-items: center; font-size: 11px; font-weight: 800; }
.ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.progress { height: 4px; background: rgba(255,255,255,.1); }
.progress i { display: block; height: 100%; background: var(--brand); transition: width .35s; }

.jobhead { padding: 18px 0 8px; }
.jobhead .time { font: 600 15px Oswald, sans-serif; color: var(--brand); text-transform: uppercase; letter-spacing: .05em; }
.jobhead h1 { margin: 4px 0 2px; font-size: 24px; line-height: 1.2; }

.info { display: grid; gap: 10px; }
.kv { display: flex; gap: 12px; align-items: flex-start; }
.kv .ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--soft); flex: none; font-size: 17px; }
.kv .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.kv .v { white-space: pre-wrap; word-break: break-word; font-weight: 500; }
.code { font: 700 22px/1.1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; }
.copy { margin-left: 8px; font-size: 12px; font-weight: 700; color: var(--brand-deep); }

.section { overflow: hidden; }
.shead { display: flex; align-items: center; gap: 12px; padding: 16px; width: 100%; text-align: left; }
.shead .si { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; flex: none; background: var(--soft); }
.shead .st { flex: 1; }
.shead .st b { display: block; font-size: 17px; }
.shead .st small { color: var(--muted); font-size: 13px; }
.shead .chev { transition: transform .2s; color: var(--muted); }
.section.open .chev { transform: rotate(180deg); }
.section.complete .si { background: var(--ok); color: #fff; }
.sbody { display: none; padding: 0 8px 10px; }
.section.open .sbody { display: block; }
.gtitle { padding: 10px 10px 4px; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

.item { display: flex; gap: 12px; padding: 12px 10px; border-radius: 14px; width: 100%; text-align: left; align-items: flex-start; transition: background .15s; }
.item:active { background: var(--soft); }
.box { width: 28px; height: 28px; border-radius: 9px; border: 2px solid var(--line); flex: none; display: grid; place-items: center; transition: all .15s; margin-top: 1px; }
.box svg { width: 16px; height: 16px; color: #fff; opacity: 0; transform: scale(.5); transition: all .15s; }
.item.on .box { background: var(--ok); border-color: var(--ok); }
.item.on .box svg { opacity: 1; transform: none; }
.item .tx { flex: 1; min-width: 0; }
.item .tx b { font-weight: 600; display: block; }
.item.on .tx b { color: var(--muted); }
.item .tip { font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.flag { display: inline-block; font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; padding: 2px 7px; border-radius: 6px; margin-top: 6px; margin-right: 6px; }
.flag.common { background: rgba(245,158,11,.15); color: #b45309; }
.flag.critical { background: rgba(239,68,68,.14); color: #dc2626; }
.mini { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding: 7px 11px; border-radius: 10px; background: rgba(4,174,239,.12); color: var(--brand-deep); font-size: 13px; font-weight: 700; }
.item.skip .tx b { text-decoration: line-through; }

.settings { margin: 8px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13.5px; background: var(--soft); border-radius: 12px; padding: 10px 12px; }
.settings dt { color: var(--muted); font-weight: 600; }
.settings dd { margin: 0; font-weight: 600; }

.photos { display: flex; gap: 8px; flex-wrap: wrap; padding: 6px 10px 4px; }
.thumb { width: 72px; height: 72px; border-radius: 12px; object-fit: cover; background: var(--soft); position: relative; }
.thumb.wait { opacity: .5; }
.addphoto { width: 72px; height: 72px; border-radius: 12px; border: 2px dashed var(--line); display: grid; place-items: center; color: var(--muted); font-size: 26px; }
.uplabel { padding: 10px 10px 0; font-size: 14px; font-weight: 600; }

.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--soft); border-radius: 12px; padding: 4px; gap: 4px; margin: 4px 10px 8px; }
.seg button { padding: 10px; border-radius: 9px; font-weight: 700; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding: 12px 0 calc(var(--safe-b) + 12px); background: linear-gradient(transparent, var(--bg) 30%); }
.spacer { height: 110px; }

/* ---------- Sheet ---------- */
.scrim { position: fixed; inset: 0; background: rgba(2,6,23,.55); z-index: 50; display: flex; align-items: flex-end; animation: fade .2s; }
.sheet { background: var(--card); width: 100%; max-height: 88dvh; overflow: auto; border-radius: 22px 22px 0 0; padding: 10px 0 calc(var(--safe-b) + 16px); animation: up .25s ease-out; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 10px; }
.sheet h2 { margin: 6px 0 4px; font-size: 22px; }
.missed { list-style: none; margin: 10px 0; padding: 0; }
.missed li { padding: 10px 12px; border-radius: 12px; background: rgba(245,158,11,.1); margin-bottom: 6px; font-size: 14.5px; }
.missed li small { display: block; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- Done ---------- */
.donepage { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; text-align: center; background: radial-gradient(100% 70% at 50% 20%, rgba(16,185,129,.3), transparent 60%), var(--hero); color: #fff; }
.donepage .tick { width: 96px; height: 96px; border-radius: 50%; background: var(--ok); margin: 0 auto 18px; display: grid; place-items: center; animation: pop .5s cubic-bezier(.2,1.6,.4,1); }
.donepage .tick svg { width: 50px; height: 50px; }
.donepage h1 { font: 600 32px Oswald, sans-serif; text-transform: uppercase; margin: 0 0 6px; }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

#toast { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 96px); transform: translateX(-50%) translateY(20px); background: #0f172a; color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: 14px; opacity: 0; transition: all .25s; z-index: 60; max-width: calc(100% - 32px); pointer-events: none; }
#toast.show { opacity: 1; transform: translateX(-50%); }

.offline { background: #f59e0b; color: #1f1300; text-align: center; font-size: 13px; font-weight: 700; padding: 6px; }
.spin { width: 22px; height: 22px; border: 3px solid rgba(255,255,255,.25); border-top-color: currentColor; border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.skel { height: 120px; border-radius: var(--r); background: linear-gradient(90deg, var(--card), var(--soft), var(--card)); background-size: 200% 100%; animation: sh 1.2s infinite; }
@keyframes sh { to { background-position: -200% 0; } }
