:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #16191f;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --good: #15803d;
  --good-bg: #dcfce7;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --info-bg: #e0f2fe;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.05);
  --radius: 14px;
  --nav-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --card: #181b21; --ink: #f3f4f6; --muted: #9aa3b2; --line: #2a2f3a;
    --accent: #2dd4bf; --accent-ink: #062723; --good: #4ade80; --good-bg: #14301f; --warn: #fbbf24; --warn-bg: #3a2a08;
    --bad: #f87171; --bad-bg: #3b1212; --info-bg: #10283a; --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-text-size-adjust: 100%; }
body { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
a { color: var(--accent); }
button { font: inherit; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; width: 100%; }
input[type=checkbox] { width: auto; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.2; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

.topbar { position: sticky; top: 0; z-index: 5; background: var(--card); border-bottom: 1px solid var(--line); padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: calc(12px + env(safe-area-inset-top)); }
.topbar .brand { font-weight: 700; }
.topbar .who { font-size: 13px; color: var(--muted); }
.wrap { padding: 14px 14px 24px; max-width: 760px; margin: 0 auto; }
.wide { max-width: 1100px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); padding: 16px; margin-bottom: 12px; }
.card.tight { padding: 12px 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 420px) { .grid3 { grid-template-columns: 1fr 1fr; } }
.stat { text-align: center; padding: 8px 4px; }
.stat .v { font-size: 22px; font-weight: 700; }
.stat .l { font-size: 12px; color: var(--muted); }
.big { font-size: 46px; font-weight: 800; letter-spacing: -.02em; line-height: 1; margin: 6px 0; }
.twin { display: grid; grid-template-columns: 1.1fr 1fr; gap: 10px; margin-bottom: 10px; align-items: stretch; }
.twin-col { padding: 10px 12px; border-radius: 12px; background: var(--bg); min-width: 0; }
.twin-col .big { font-size: 38px; }
.twin-col:last-child .big { font-size: 28px; margin-top: 10px; }
.twin-col:last-child h3 { font-size: 12px; }
.twin-col.up { background: var(--good-bg); }
.build { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin: 4px 0 10px; font-size: 14px; }
.build-row { display: flex; justify-content: space-between; padding: 7px 10px; border-bottom: 1px solid var(--line); }
.build-row:last-child { border-bottom: 0; }
.build-row.on { color: var(--good); }
.build-row.off { color: var(--muted); }
.build-row.off b { text-decoration: line-through; opacity: .6; }
.build-row.total { background: var(--bg); font-weight: 700; color: var(--ink); }
.twin-col.up .big, .twin-col.up h3 { color: var(--good); }
.twin-col .plus { display: inline-block; margin: 2px 0 4px; padding: 2px 8px; border-radius: 999px; background: var(--good); color: #fff; font-size: 13px; font-weight: 800; }
@media (max-width: 360px) { .twin-col .big { font-size: 30px; } .twin-col:last-child .big { font-size: 24px; } }
.big small { font-size: 18px; font-weight: 600; color: var(--muted); }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--line); color: var(--ink); }
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.info { background: var(--info-bg); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; font-weight: 600; min-height: 44px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.danger { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.btn.small { padding: 8px 12px; min-height: 36px; font-size: 14px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button { flex: 1; padding: 10px 6px; border: 0; background: transparent; color: var(--ink); font-weight: 600; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }

.ladder { display: flex; gap: 4px; margin: 10px 0 4px; }
.ladder .rung { flex: 1; text-align: center; padding: 8px 2px; border-radius: 8px; background: var(--line); font-size: 12px; font-weight: 600; }
.ladder .rung.hit { background: var(--accent); color: var(--accent-ink); }
.ladder .rung.next { outline: 2px dashed var(--accent); outline-offset: -2px; }
.ladder .rung b { display: block; font-size: 14px; }
.bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 8px; }
.day { text-align: center; padding: 8px 2px; border-radius: 8px; background: var(--bg); font-size: 12px; }
.day b { display: block; font-size: 13px; }
.day.today { outline: 2px solid var(--accent); }
.day.live { background: var(--info-bg); }
.day .tip { display: block; font-size: 10px; color: var(--good); font-weight: 700; margin-top: 2px; }
.day.live span:last-child { color: var(--accent); font-weight: 700; font-size: 10px; }
.check { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--bg); margin-top: 8px; }
.check .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--line); flex: none; }
.check.ok .dot { background: var(--good); }
.check.no .dot { background: var(--bad); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.banner { background: var(--warn-bg); color: var(--warn); border: 1px solid transparent; border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.banner.bad { background: var(--bad-bg); color: var(--bad); }
.banner.info { background: var(--info-bg); color: var(--ink); }
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 50; box-shadow: var(--shadow); }

.nav { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--card); border-top: 1px solid var(--line); display: flex; z-index: 10; }
.nav button { flex: 1; border: 0; background: transparent; color: var(--muted); font-size: 11px; font-weight: 600; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.nav button .ic { font-size: 20px; line-height: 1; }
.nav button.on { color: var(--accent); }
.nav button .badge { position: absolute; margin-left: 26px; margin-top: -30px; background: var(--bad); color: #fff; border-radius: 999px; font-size: 10px; padding: 1px 6px; }
.nav.admin button { font-size: 10px; }

.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }
.sheet .handle { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 12px; }
.choice { display: flex; gap: 6px; flex-wrap: wrap; }
.choice button { flex: 1; min-width: 60px; padding: 10px 6px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-weight: 600; }
.choice button.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.jobline { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.jobline:last-child { border-bottom: 0; }
.tag { font-size: 11px; padding: 2px 6px; border-radius: 6px; background: var(--line); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 14px; }
.kv .k { color: var(--muted); }
.login { max-width: 420px; margin: 40px auto; }
.center { text-align: center; }
.person-card { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: center; }
.person-card .name { font-weight: 700; }
.person-card .sub { font-size: 13px; color: var(--muted); }
.sub-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; }
.sub-tabs button { white-space: nowrap; }
details summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.trendbars { position: relative; display: flex; gap: 8px; align-items: flex-end; height: 150px; padding-top: 22px; box-sizing: border-box; }
.tb { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; position: relative; z-index: 1; }
.tb .tbbar { width: 100%; max-width: 56px; border-radius: 8px 8px 0 0; background: var(--line); flex: none; }
.tb.hit .tbbar { background: var(--good); }
.tb.cur .tbbar { background: var(--accent); outline: 2px dashed var(--accent); outline-offset: 2px; }
.tb .tbv { font-size: 12px; font-weight: 700; margin-bottom: 4px; }
.tb .tbl { font-size: 11px; color: var(--muted); margin-top: 6px; height: 14px; line-height: 14px; flex: none; }
.tb.cur .tbl { color: var(--accent); font-weight: 700; }
.tbline { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--good); pointer-events: none; z-index: 2; }
.tbline span { position: absolute; right: 0; top: -16px; font-size: 11px; font-weight: 700; color: var(--good); background: var(--card); padding: 0 4px; }
.cur-row td { background: var(--info-bg); }
.trend { display: flex; gap: 6px; align-items: flex-end; height: 60px; }

/* owner photo gallery */
.ph-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.ph-toolbar .seg { flex: 1; min-width: 260px; }
.ph-toolbar input { flex: 1; min-width: 200px; }
.ph-job { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 14px; }
.ph-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 10px; }
.ph-title { font-size: 17px; font-weight: 700; }
.ph-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 520px) { .ph-cols { grid-template-columns: 1fr; } }
.ph-label { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.ph-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ph-cell { position: relative; aspect-ratio: 1; border: 0; padding: 0; border-radius: 10px; overflow: hidden; background: var(--bg); cursor: pointer; }
.ph-cell img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .15s; }
.ph-cell:hover img { transform: scale(1.04); }
.ph-more { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.55); color: #fff; font-weight: 800; font-size: 20px; }
.ph-empty { height: 56px; border: 2px dashed var(--line); border-radius: 10px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; }
.ph-job.upcoming { opacity: .7; }
.ph-job.upcoming .ph-cols { display: none; }
.viewer { position: fixed; inset: 0; background: #0b0d12; color: #fff; z-index: 120; display: flex; flex-direction: column; }
.v-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 14px 10px; }
.v-top .btn { background: rgba(255,255,255,.1); color: #fff; border-color: transparent; }
.v-top .btn.danger { background: rgba(185,28,28,.5); }
.v-stage { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; min-height: 0; }
.v-stage img { max-width: 100%; max-height: 100%; object-fit: contain; }
.v-arrow { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 72px; border: 0; border-radius: 12px; background: rgba(255,255,255,.12); color: #fff; font-size: 34px; }
.v-arrow.left { left: 8px; } .v-arrow.right { right: 8px; }
.v-arrow:disabled { opacity: .2; }
.v-strip { display: flex; gap: 6px; overflow-x: auto; padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); }
.v-strip img { width: 60px; height: 60px; object-fit: cover; border-radius: 8px; flex: none; opacity: .55; border: 2px solid transparent; cursor: pointer; }
.v-strip img.on { opacity: 1; border-color: #fff; }
.v-strip img.before { box-shadow: inset 0 0 0 2px #38bdf8; } .v-strip img.after { box-shadow: inset 0 0 0 2px #4ade80; }
.cmp { position: relative; flex: 1; min-height: 0; overflow: hidden; user-select: none; touch-action: none; background: #000; }
.cmp img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.cmp-after { position: absolute; inset: 0; }
.cmp-before { position: absolute; top: 0; bottom: 0; left: 0; width: 50%; overflow: hidden; }
.cmp-before img { width: 100vw; max-width: none; }
.cmp-handle { position: absolute; top: 0; bottom: 0; width: 3px; background: #fff; left: 50%; transform: translateX(-50%); }
.cmp-handle::after { content: "⇔"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 40px; height: 40px; border-radius: 50%; background: #fff; color: #000; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.cmp-tag { position: absolute; top: 10px; padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 800; background: rgba(0,0,0,.6); }
.cmp-tag.left { left: 10px; color: #38bdf8; } .cmp-tag.right { right: 10px; color: #4ade80; }

/* job photos */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; margin: 8px 0; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--bg); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-x { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 16px; line-height: 24px; padding: 0; }
.cam { position: fixed; inset: 0; background: #000; z-index: 100; display: flex; flex-direction: column; }
.cam video { flex: 1; width: 100%; object-fit: cover; background: #000; }
.cam.flash video { filter: brightness(2); }
.cam-top { position: absolute; top: 0; left: 0; right: 0; padding: calc(10px + env(safe-area-inset-top)) 12px 10px; display: flex; gap: 8px; align-items: center; justify-content: space-between; color: #fff; font-weight: 700; background: linear-gradient(rgba(0,0,0,.6), transparent); }
.cam-strip { position: absolute; left: 0; right: 0; bottom: calc(110px + env(safe-area-inset-bottom)); display: flex; gap: 6px; padding: 0 10px; overflow-x: auto; }
.cam-strip img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; border: 2px solid #fff; flex: none; }
.cam-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 20px calc(20px + env(safe-area-inset-bottom)); display: flex; align-items: center; justify-content: space-between; background: linear-gradient(transparent, rgba(0,0,0,.7)); }
#cam_shutter { width: 74px; height: 74px; border-radius: 50%; border: 5px solid #fff; background: rgba(255,255,255,.35); }
#cam_shutter:active { background: #fff; }
.cam-review { position: absolute; inset: 0; background: var(--bg); color: var(--ink); overflow: auto; }
.trend div { flex: 1; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 4px; position: relative; }
.trend div span { position: absolute; top: -18px; left: 0; right: 0; text-align: center; font-size: 11px; }
