:root {
  --obsidian: #151213;
  --obsidian-2: #231e20;
  --red: #b3242b;
  --red-bright: #d6333a;
  --red-soft: #fbeaea;
  --ink: #1c1a1a;
  --muted: #6b6466;
  --line: #e4dfdf;
  --bg: #f4f2f1;
  --card: #ffffff;
  --ok: #1f7a46;
  --ok-soft: #e6f4ec;
  --warn: #9a5b00;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.06);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
a { color: var(--red); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
p { margin: 0 0 1rem; line-height: 1.5; }

/* Auth layout */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(1200px 500px at 50% -10%, #3a2427 0%, transparent 60%), var(--obsidian); }
.auth-card { width: 100%; max-width: 420px; background: var(--card); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.35); overflow: hidden; }
.auth-head { padding: 22px 24px 16px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.auth-head img { width: 40px; height: 40px; }
.brand-name { font-weight: 700; font-size: 1.05rem; }
.brand-sub { color: var(--muted); font-size: .85rem; }
.auth-body { padding: 20px 24px 24px; }
.auth-foot { padding: 0 24px 20px; font-size: .85rem; color: var(--muted); text-align: center; }

/* Tabs */
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border-radius: 8px; padding: 4px; margin-bottom: 18px; }
.tab { border: 0; background: transparent; padding: 10px; border-radius: 6px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.tab[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

/* Forms */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.field input { width: 100%; padding: 12px 12px; font: inherit; font-size: 1rem; border: 1px solid #cfc8c9; border-radius: 8px; background: #fff; }
.field input:focus { outline: 2px solid var(--red-bright); outline-offset: 1px; border-color: transparent; }
.hint { font-size: .82rem; color: var(--muted); margin-top: 6px; }
.pin-input { letter-spacing: .5em; font-size: 1.4rem !important; text-align: center; font-variant-numeric: tabular-nums; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 8px; padding: 12px 18px; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--red); color: #fff; width: 100%; }
.btn-primary:hover { background: #9b1e25; }
.btn-primary[disabled] { opacity: .6; cursor: progress; }
.btn-light { background: #fff; color: var(--ink); }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-sm { padding: 6px 12px; font-size: .85rem; }
.link-btn { background: none; border: 0; color: var(--red); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }

.alert { padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; font-size: .92rem; }
.alert-error { background: var(--red-soft); color: #7d1419; }
.alert-ok { background: var(--ok-soft); color: var(--ok); }

.qr-box { display: grid; place-items: center; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 8px; margin: 8px 0 12px; }
.qr-box img { width: 200px; height: 200px; image-rendering: pixelated; }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9rem; word-break: break-all; background: var(--bg); padding: 8px 10px; border-radius: 6px; }

/* App shell */
.topbar { background: var(--obsidian); color: #fff; display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; position: sticky; top: 0; z-index: 10; }
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.topbar .brand img { width: 28px; height: 28px; }
.topbar .who { font-size: .85rem; opacity: .85; margin-right: 10px; }
.topbar .right { display: flex; align-items: center; }
.container { max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card h3 { font-size: 1rem; }
.card p { color: var(--muted); font-size: .92rem; margin: 0; }
.pill { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 3px 8px; border-radius: 99px; background: var(--bg); color: var(--muted); margin-bottom: 8px; }
.role-badge { background: var(--red); color: #fff; font-size: .7rem; padding: 2px 8px; border-radius: 99px; text-transform: uppercase; letter-spacing: .05em; margin-left: 6px; }

/* Banners */
.update-banner, .offline-banner { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 100; border-radius: 10px; padding: 10px 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25); display: flex; gap: 12px; align-items: center; font-size: .92rem; }
.update-banner { background: var(--obsidian); color: #fff; }
.offline-banner { background: #3b3537; color: #fff; bottom: calc(70px + env(safe-area-inset-bottom)); }
[hidden] { display: none !important; }

.center-msg { min-height: 60vh; display: grid; place-items: center; color: var(--muted); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--red); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================== v0.2.0 app screens ===================== */
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.d-block { display: block; }
.pre { white-space: pre-wrap; }
.req { color: var(--red); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }

/* topbar nav */
.topbar { gap: 16px; flex-wrap: wrap; }
.topbar .brand { color: #fff; text-decoration: none; }
.mainnav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.mainnav a { color: #d9d2d3; text-decoration: none; padding: 8px 12px; border-radius: 6px; font-weight: 600; font-size: .92rem; white-space: nowrap; position: relative; }
.mainnav a:hover { background: var(--obsidian-2); color: #fff; }
.mainnav a.active { background: var(--obsidian-2); color: #fff; box-shadow: inset 0 -2px 0 var(--red-bright); }
.badge { display: inline-block; min-width: 18px; padding: 1px 6px; margin-left: 6px; border-radius: 99px; background: #555; color: #fff; font-size: .72rem; text-align: center; }
.badge-asap { background: var(--red-bright); }
@media (max-width: 720px) { .topbar .who { display: none; } .mainnav { order: 3; flex-basis: 100%; } }

/* page */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h2 { margin: 2px 0 6px; }
.page-head p { margin: 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { font-size: .88rem; text-decoration: none; color: var(--muted); }
.back:hover { color: var(--red); }
.btn-primary-inline { background: var(--red); color: #fff; }
.btn-primary-inline:hover { background: #9b1e25; }
.btn-primary-inline[disabled], .btn-danger[disabled] { opacity: .6; cursor: progress; }
.btn-danger { background: #8f1a20; color: #fff; }
.btn-ghost { background: #fff; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.card + .card, .card + section, section + .card { margin-top: 14px; }
.card h3 { margin-bottom: 10px; }
.card h4 { margin: 14px 0 6px; font-size: .9rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.card.narrow { max-width: 760px; }
.alert-warn { background: #fff4e0; color: #6b4300; }
.empty { background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--muted); }
.center-msg.small { min-height: 120px; }
.field textarea, .field select { width: 100%; padding: 11px 12px; font: inherit; border: 1px solid #cfc8c9; border-radius: 8px; background: #fff; }
.field textarea:focus, .field select:focus { outline: 2px solid var(--red-bright); outline-offset: 1px; border-color: transparent; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 0 12px; }
.grid-addr { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 12px; }
.span2 { grid-column: span 2; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } .grid-addr { grid-template-columns: 1fr 1fr; } }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; margin-bottom: 10px; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--red); flex: none; }
.input-prefix { display: flex; align-items: center; border: 1px solid #cfc8c9; border-radius: 8px; background: #fff; overflow: hidden; }
.input-prefix span { padding: 0 0 0 12px; color: var(--muted); }
.input-prefix input { border: 0 !important; }
.inline-form { display: flex; gap: 8px; }
.inline-form select { flex: 1; padding: 10px; border: 1px solid #cfc8c9; border-radius: 8px; font: inherit; }

/* chips */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-block; font-size: .74rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.st-review { background: #e8eefc; color: #23439b; }
.st-warn { background: #fff4e0; color: #8a5300; }
.st-bad { background: var(--red-soft); color: #8f1a20; }
.st-ok { background: var(--ok-soft); color: var(--ok); }
.st-live { background: #e3f5f7; color: #0d6773; }
.st-done { background: #e9e6ef; color: #4b3d6b; }
.st-muted { background: #eeeaea; color: #8a8384; }
.st-asap { background: var(--red); color: #fff; }

/* toolbar */
.toolbar { display: flex; gap: 10px; justify-content: space-between; flex-wrap: wrap; margin-bottom: 12px; }
.seg { display: inline-flex; background: #e9e5e4; border-radius: 8px; padding: 3px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 7px 12px; border-radius: 6px; font: inherit; font-size: .88rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.seg-wide { display: flex; margin-bottom: 14px; }
.seg-wide button { flex: 1; }
.search { padding: 9px 12px; border: 1px solid #cfc8c9; border-radius: 8px; font: inherit; min-width: 240px; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.stat-n { font-size: 1.8rem; font-weight: 800; }
.stat-l { color: var(--muted); font-size: .85rem; }
.stat-sub { color: var(--red); font-weight: 700; font-size: .8rem; margin-top: 2px; }

/* job rows */
.job-list { display: grid; gap: 8px; }
.job-row { display: flex; justify-content: space-between; gap: 12px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; text-decoration: none; color: inherit; border-left: 4px solid transparent; }
.job-row:hover { border-left-color: var(--red); }
.jr-top { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.jr-top .wo { font-weight: 700; margin-left: 4px; }
.jr-addr { font-weight: 600; }
.jr-meta { color: var(--muted); font-size: .86rem; margin-top: 2px; }
.jr-side { text-align: right; white-space: nowrap; }
.jr-amt { font-weight: 800; }

/* detail */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }
.detail-side .card + .card { margin-top: 14px; }
.addr { font-size: 1.05rem; font-weight: 600; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; margin: 0; font-size: .94rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.tasks { margin: 0; padding-left: 18px; line-height: 1.7; }
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.file-tile { display: flex; flex-direction: column; gap: 3px; text-decoration: none; color: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: #fff; }
.file-tile:hover { border-color: var(--red); }
.file-tile img { width: 100%; height: 90px; object-fit: cover; border-radius: 5px; background: var(--bg); }
.pdf-icon { height: 90px; display: grid; place-items: center; background: var(--red-soft); color: var(--red); font-weight: 800; border-radius: 5px; }
.fname { font-size: .82rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.est { width: 100%; border-collapse: collapse; font-size: .92rem; }
.est td { padding: 7px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.est .num { text-align: right; white-space: nowrap; padding-left: 10px; font-variant-numeric: tabular-nums; }
.est .tot td { font-weight: 800; border-bottom: 0; padding-top: 10px; font-size: 1rem; }
.timeline { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow: auto; }
.timeline li { padding: 8px 0 8px 14px; border-left: 2px solid var(--line); position: relative; font-size: .9rem; }
.timeline li::before { content: ''; position: absolute; left: -5px; top: 13px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.review-card { border: 2px solid var(--red); }

/* request form */
.req-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .req-grid { grid-template-columns: 1fr; } }
.sticky { position: sticky; top: 76px; }
.radio-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.radio-cards.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 640px) { .radio-cards { grid-template-columns: 1fr; } }
.rcard { display: flex; gap: 10px; align-items: flex-start; border: 1px solid #cfc8c9; border-radius: 8px; padding: 12px; cursor: pointer; background: #fff; }
.rcard input { accent-color: var(--red); margin-top: 3px; }
.rcard:has(input:checked) { border-color: var(--red); background: #fff7f7; box-shadow: 0 0 0 1px var(--red); }
.tasks-pick { display: grid; gap: 8px; }
.task { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px 0; background: #fff; }
.task.on { border-color: var(--red); background: #fffafa; }
.task-sub { display: none; padding: 0 0 4px 28px; }
.task.on .task-sub { display: block; }
.drop { border: 1px dashed #cfc8c9; border-radius: 8px; padding: 12px; margin-top: 10px; background: #fff; }
.drop-head { margin-bottom: 8px; }
.flist:empty { display: none; }
.flist { display: grid; gap: 4px; margin-bottom: 8px; }
.fitem { display: flex; gap: 10px; align-items: center; justify-content: space-between; background: var(--bg); padding: 6px 10px; border-radius: 6px; font-size: .88rem; }
.fitem span:first-child { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.progress { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; margin: 10px 0; }
.progress div { height: 100%; width: 0; background: var(--red); transition: width .2s; }
#rf-submit { margin-top: 10px; }

/* tables */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; background: var(--card); font-size: .92rem; }
.tbl th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.tbl tr[data-href] { cursor: pointer; }
.tbl tr[data-href]:hover td { background: #fbf8f8; }
.tbl tr.inactive td { color: #a39c9d; }
.tbl .actions { white-space: nowrap; text-align: right; }
.tbl .actions .link-btn + .link-btn { margin-left: 10px; }
.page-head + .table-wrap .tbl, section .tbl { box-shadow: none; }

/* modal + toast */
.modal-wrap { position: fixed; inset: 0; background: rgba(15,12,13,.55); display: grid; place-items: center; z-index: 200; padding: 16px; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 440px; max-height: 92vh; overflow: auto; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.modal-wide { max-width: 620px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 18px 20px; }
.icon-btn { border: 0; background: none; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted); }
.toasts { position: fixed; top: 76px; right: 16px; z-index: 300; display: grid; gap: 8px; max-width: 360px; }
.toast { padding: 12px 14px; border-radius: 8px; color: #fff; box-shadow: 0 10px 30px rgba(0,0,0,.2); font-size: .92rem; }
.toast-ok { background: #1f5f3c; }
.toast-error { background: #8f1a20; }

/* v0.3.0 photos on request page */
.tab-link { text-align: center; text-decoration: none; padding: 10px; border-radius: 6px; font-weight: 600; color: var(--muted); }
.tab-link:hover { color: var(--ink); }
.ph-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.ph-tile { display: block; text-decoration: none; color: inherit; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.ph-tile img { width: 100%; height: 150px; object-fit: cover; display: block; background: var(--bg); }
.ph-tile.urgent { border-color: var(--red-bright); border-width: 2px; }
.ph-tile.attention { border-color: #e2a400; }
.ph-cap { padding: 8px 10px; display: grid; gap: 4px; }
