/* Sổ Xây Nhà – mobile-first, chữ to, nút lớn để dùng một tay ngoài công trường. Cùng khung với Sổ Công Trình, accent xanh dương. */
:root {
  --bg: #F8FAFC;
  --card: #FFFFFF;
  --text: #111827;
  --muted: #6B7280;
  --line: #E5E7EB;
  --accent: #2563EB;
  --accent-ink: #FFFFFF;
  --accent-soft: #DBEAFE;
  --ok: #16A34A;
  --ok-soft: #DCFCE7;
  --warn: #DC2626;
  --warn-soft: #FEE2E2;
  --amber: #B45309;
  --amber-soft: #FEF3C7;
  --info: #2563EB;
  --info-soft: #DBEAFE;
  --top: #1E3A8A;
  --top-ink: #F9FAFB;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.05);
  --radius: 14px;
  --tap: 48px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B1220; --card: #151D2E; --text: #F3F4F6; --muted: #9CA3AF; --line: #273246;
    --accent: #60A5FA; --accent-ink: #0B1220; --accent-soft: #14284A;
    --ok: #4ADE80; --ok-soft: #10351F; --warn: #F87171; --warn-soft: #3F1414; --amber: #FBBF24; --amber-soft: #3B2F0B;
    --info: #60A5FA; --info-soft: #14284A; --top: #172554; --top-ink: #F9FAFB;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0B1220; --card: #151D2E; --text: #F3F4F6; --muted: #9CA3AF; --line: #273246;
  --accent: #60A5FA; --accent-ink: #0B1220; --accent-soft: #14284A;
  --ok: #4ADE80; --ok-soft: #10351F; --warn: #F87171; --warn-soft: #3F1414; --amber: #FBBF24; --amber-soft: #3B2F0B;
  --info: #60A5FA; --info-soft: #14284A; --top: #172554; --top-ink: #F9FAFB;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--info); }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--top); color: var(--top-ink);
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
}
.proj-btn {
  flex: 1; min-width: 0; text-align: left; background: transparent; border: 0; color: inherit; padding: 6px 4px;
  display: flex; flex-direction: column; gap: 1px; min-height: var(--tap);
}
.proj-name { font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj-name::after { content: " ▾"; font-size: 12px; opacity: .7; }
.proj-sub { font-size: 12px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { background: transparent; border: 0; color: inherit; width: var(--tap); height: var(--tap); display: grid; place-items: center; border-radius: 12px; }
.icon-btn:active { background: rgba(255,255,255,.12); }

/* Main view */
.view { max-width: 560px; margin: 0 auto; padding: 12px 16px 24px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; scroll-margin-top: 76px; }
.card h2 { font-size: 15px; margin: 0 0 10px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card h2 > span.muted { font-size: 12px; font-weight: 500; text-align: right; text-transform: none; letter-spacing: 0; }
.card h2 .link { text-transform: none; letter-spacing: 0; font-weight: 600; font-size: 14px; min-height: 44px; }
.big { font-size: 20px; font-weight: 700; line-height: 1.25; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.num { font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }
.hint { font-size: 13px; color: var(--muted); margin-top: 8px; }
.sub-h { font-size: 13px; font-weight: 700; color: var(--muted); margin: 12px 0 4px; }
.bad-t { color: var(--warn); }
.warn-t { color: var(--amber); }

/* Buttons */
.btn {
  min-height: var(--tap); padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-align: center;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.dark { background: var(--top); border-color: var(--top); color: var(--top-ink); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--warn); border-color: var(--warn); }
.btn.block { width: 100%; }
.btn.sm { min-height: 48px; padding: 6px 12px; font-size: 15px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; color: var(--info); padding: 4px 0; font-weight: 600; min-height: 48px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions .btn { width: 100%; }
.actions.three { grid-template-columns: 1fr 1fr 1fr; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.quick .btn { min-height: 64px; flex-direction: column; gap: 2px; font-size: 15px; }
.x { background: transparent; border: 0; color: var(--muted); min-width: 44px; height: 48px; border-radius: 8px; font-size: 18px; }
.x:disabled { opacity: .3; }

/* Boxes */
.warnbox, .okbox, .tipbox { border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-top: 8px; }
.warnbox { background: var(--amber-soft); color: var(--text); border-left: 4px solid var(--amber); }
.warnbox.bad { background: var(--warn-soft); border-left-color: var(--warn); }
.okbox { background: var(--ok-soft); color: var(--text); }
.tipbox { background: var(--info-soft); color: var(--text); }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--info-soft); color: var(--text); border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }
.sched { margin-top: 12px; border-radius: 12px; padding: 10px 12px; background: var(--bg); font-size: 15px; }
.sched.ok { background: var(--ok-soft); }
.sched.warn { background: var(--amber-soft); }
.sched.bad { background: var(--warn-soft); }

/* Progress bar */
.bar { height: 12px; background: var(--line); border-radius: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 6px; transition: width .3s; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat { background: var(--bg); border-radius: 12px; padding: 10px; min-width: 0; }
.stat.wide { grid-column: 1 / -1; }
.stat .l { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 17px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat.wide .v { font-size: 20px; }
.stat .v.ok { color: var(--ok); }
.stat .v.warn { color: var(--amber); }
.stat .v.bad { color: var(--warn); }

/* Lists */
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); min-height: 52px; }
.item:first-child { border-top: 0; }
.item .t { flex: 1; min-width: 0; }
.item .t .d { font-size: 13px; color: var(--muted); }
.item .t .amt-in { color: var(--text); font-size: 15px; }
.item .amt { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.item .col { display: flex; flex-direction: column; }
.amt.out { color: var(--warn); }
button.item { width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; }
.item.sr .ic { font-size: 20px; }
.badge { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; white-space: nowrap; background: var(--line); color: var(--muted); border: 0; display: inline-block; }
button.badge { min-height: 44px; padding: 6px 14px; cursor: pointer; }
.badge.doing, .badge.pending, .badge.due, .badge.conditional { background: var(--amber-soft); color: var(--amber); }
.badge.passed, .badge.approved, .badge.paid { background: var(--ok-soft); color: var(--ok); }
.badge.failed, .badge.rejected { background: var(--warn-soft); color: var(--warn); }
.badge.owner { background: var(--info-soft); color: var(--info); }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; flex: 0 0 auto; background: var(--line); cursor: pointer; }

/* Todo */
.todo-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: 0; border-top: 1px solid var(--line); padding: 12px 2px; min-height: 52px; font-size: 15px; }
.todo-item:first-child { border-top: 0; }
.todo-item .ic { font-size: 20px; width: 28px; text-align: center; flex: 0 0 auto; }
.todo-item .chev { color: var(--muted); font-size: 20px; }
.todo-item.warn { color: var(--text); font-weight: 600; }

/* Fields */
.field { margin-bottom: 12px; min-width: 0; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.field input, .field select, .field textarea, .prow input, .prow select, .arow input, .wrow input, .chk-note {
  width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; background: var(--bg); min-width: 0;
}
.field textarea { min-height: 80px; resize: vertical; }
.field .hint { margin-top: 4px; }
.inl2, .inl3 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.inl3 { grid-template-columns: 1fr 1fr 1fr; align-items: start; }
.check { display: flex; align-items: center; gap: 10px; min-height: 48px; font-size: 15px; cursor: pointer; }
.check input { width: 22px; height: 22px; flex: 0 0 auto; accent-color: var(--accent); }
.radios { display: flex; flex-direction: column; gap: 6px; }
.radio { display: flex; align-items: center; gap: 10px; min-height: 48px; border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px; cursor: pointer; }
.radio input { width: 20px; height: 20px; accent-color: var(--accent); }
.radio:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio:has(input:disabled) { opacity: .5; }
.field .radio, .field .check { display: flex; font-size: 15px; color: var(--text); font-weight: 500; margin-bottom: 0; }
.checks-pick { display: flex; flex-direction: column; max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; padding: 0 10px; }
.checks-pick .check { border-top: 1px solid var(--line); }
.checks-pick .check:first-child { border-top: 0; }

/* Contract: area table, payments, warranty */
.areas { display: flex; flex-direction: column; gap: 6px; }
.arow { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr) minmax(0, 1fr) 56px 36px; gap: 6px; align-items: center; }
.arow input { min-height: 44px; padding: 6px 8px; }
.arow.head { font-size: 12px; color: var(--muted); font-weight: 600; }
.area-foot { font-weight: 700; padding-top: 8px; border-top: 1px solid var(--line); }
.arow .num { text-align: right; font-size: 14px; }
.arow .x { min-width: 36px; }
.prow { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.prow .seq { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); display: grid; place-items: center; flex: 0 0 auto; }
.mini-f { display: block; font-size: 12px; color: var(--muted); }
.mini-f input { margin-top: 2px; font-size: 16px; color: var(--text); }
.pgrid { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 8px; }
.wrow { display: grid; grid-template-columns: minmax(0, 1fr) 80px auto 36px; gap: 6px; align-items: center; margin-bottom: 6px; }

/* Sub tabs & segmented */
.subtabs { display: flex; gap: 6px; margin-bottom: 12px; overflow-x: auto; }
.subtabs button, .seg button { flex: 1; min-height: 48px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-size: 14px; font-weight: 600; white-space: nowrap; padding: 6px 10px; }
.subtabs button.on, .seg button.on { background: var(--top); color: var(--top-ink); border-color: var(--top); }
.seg { display: flex; gap: 6px; }
.seg.wrap { flex-wrap: wrap; }
.seg.wrap button { flex: 1 1 30%; }
textarea.note { width: 100%; min-height: 90px; border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: var(--bg); resize: vertical; }

/* Milestones */
.ms-row { padding: 6px 0; }
.ms-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; background: none; border: 0; text-align: left; padding: 6px 0; min-height: 52px; }
.ms-open .t { display: block; }
.ms-open .nm { display: block; font-weight: 600; }
.ms-open .d { display: block; }
.msnum { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-weight: 700; flex: 0 0 auto; color: var(--muted); font-size: 14px; }
.msnum.doing { border-color: var(--amber); background: var(--amber-soft); color: var(--text); }
.msnum.passed, .msnum.conditional { border-color: var(--ok); background: var(--ok); color: #fff; }
.msnum.failed { border-color: var(--warn); background: var(--warn); color: #fff; }
.checks { display: flex; flex-direction: column; gap: 10px; }
.chk { border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px 10px; border-left-width: 4px; }
.chk.ok { border-left-color: var(--ok); }
.chk.bad { border-left-color: var(--warn); }
.chk.skip { border-left-color: var(--muted); }
.chk-h { display: flex; align-items: flex-start; gap: 8px; width: 100%; background: none; border: 0; text-align: left; padding: 4px 0; font-weight: 600; font-size: 15px; min-height: 44px; }
.chk-h .chev { color: var(--muted); }
.pri { font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 6px; white-space: nowrap; margin-top: 2px; }
.pri.high { background: var(--warn-soft); color: var(--warn); }
.pri.mid { background: var(--line); color: var(--muted); }
.need-ph { font-size: 12px; color: var(--amber); font-weight: 600; }
.chk-b { font-size: 14px; background: var(--bg); border-radius: 10px; padding: 4px 10px; margin: 4px 0 8px; }
.chk-b p { margin: 6px 0; }
.rbtns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.rbtn { min-height: 48px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-weight: 600; font-size: 14px; }
.rbtn.ok.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.rbtn.bad.on { background: var(--warn); border-color: var(--warn); color: #fff; }
.rbtn.skip.on { background: var(--muted); border-color: var(--muted); color: #fff; }
.chk-f { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.chk-note { flex: 1; min-height: 44px; }
.chk-note.need { border-color: var(--warn); }
.ph-add { min-width: 48px; flex: 0 0 auto; }

/* Deliveries & tricks */
.mat { border-top: 1px solid var(--line); padding: 10px 0; }
.mat:first-of-type { border-top: 0; }
.dlv { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; padding: 8px 10px; border-radius: 10px; font-size: 14px; }
.dlv > .grow { flex: 1 1 100%; }
.dlv.ok { background: var(--ok-soft); }
.dlv.bad { background: var(--warn-soft); }
details.tip { border-top: 1px solid var(--line); padding: 4px 0; }
details.tip:first-of-type { border-top: 0; }
details.tip summary { min-height: 44px; display: flex; align-items: center; font-weight: 600; cursor: pointer; }
details.tip p { margin: 0 0 8px; font-size: 14px; }
.trick p { margin: 8px 0; font-size: 15px; }

/* Payments */
.pay { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-top: 10px; display: flex; flex-direction: column; gap: 4px; border-left-width: 4px; scroll-margin-top: 76px; }
.pay.due { border-left-color: var(--amber); }
.pay.paid { border-left-color: var(--ok); }
.pay-acts { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 6px; flex-wrap: wrap; }
.groups { background: var(--bg); border-radius: 10px; padding: 8px 10px; margin-bottom: 6px; display: flex; flex-direction: column; gap: 4px; }

/* Photos */
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photos .ph { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--line); border: 0; padding: 0; }
.photos .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photos .ph .cap { position: absolute; left: 0; right: 0; bottom: 0; font-size: 11px; background: rgba(0,0,0,.55); color: #fff; padding: 2px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.photos .add { aspect-ratio: 1; border: 2px dashed var(--line); border-radius: 10px; background: transparent; display: grid; place-items: center; color: var(--muted); font-size: 13px; cursor: pointer; text-align: center; }
.photos .add span { font-size: 26px; display: block; text-align: center; }
.mini { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0; }
.mini img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; flex: 0 0 auto; background: var(--line); cursor: pointer; }

/* Date nav & calendar */
.datenav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.datenav .btn { min-width: var(--tap); padding: 0 12px; font-size: 20px; }
.datenav .date { flex: 1; text-align: center; font-weight: 700; font-size: 18px; position: relative; cursor: pointer; }
.datenav .date small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.datenav input[type="date"] { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.today-chip { font-size: 12px; background: var(--accent-soft); color: var(--text); padding: 2px 8px; border-radius: 999px; margin-left: 6px; }
.cal-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-h .btn { min-width: 48px; font-size: 18px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal > b { font-size: 12px; color: var(--muted); padding: 4px 0; }
.cd { position: relative; min-height: 44px; border: 1px solid transparent; border-radius: 10px; background: var(--bg); font-size: 15px; padding: 2px 0 10px; }
.cd.today { font-weight: 800; color: var(--accent); }
.cd.sel { border-color: var(--accent); background: var(--accent-soft); }
.cd .dot { position: absolute; left: 50%; bottom: 5px; transform: translateX(-50%); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.yes { background: var(--ok); }
.dot.off { background: #9CA3AF; }
.dot.stop_contractor { background: var(--warn); }
.dot.stop_owner { background: #A855F7; }
.dot.stop_rain { background: #0EA5E9; }
.dot.note { background: var(--amber); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.search { width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; background: var(--bg); margin-top: 10px; }
.budget { margin-top: 6px; }

/* Tab bar */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  background: var(--card); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button { background: transparent; border: 0; min-height: 62px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; padding: 0 2px; color: var(--muted); font-weight: 600; }
.tabbar button .ic { font-size: 22px; line-height: 1; }
.tabbar button.active { color: var(--text); }
.tabbar button.active::after { content: ""; width: 24px; height: 3px; background: var(--accent); border-radius: 3px; margin-top: 2px; }

/* Dialog */
.dlg { border: 0; border-radius: 18px 18px 0 0; padding: 0; width: 100%; max-width: 560px; margin: auto auto 0; background: var(--card); color: var(--text); max-height: 92vh; }
@media (min-width: 600px) { .dlg { border-radius: 18px; margin: auto; } }
.dlg::backdrop { background: rgba(0,0,0,.45); }
.dlg form, .dlg .pane { padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
.dlg h3 { margin: 0 0 12px; font-size: 18px; }
.dlg .actions { margin-top: 8px; }
.menu { display: flex; flex-direction: column; }
.menu button, .menu .menu-link { text-align: left; background: transparent; border: 0; border-top: 1px solid var(--line); min-height: 52px; padding: 10px 4px; font-size: 16px; display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.menu button:first-child { border-top: 0; }
.menu .ic { width: 28px; text-align: center; flex: 0 0 auto; }
.menu button.on { font-weight: 700; }
.menu button.danger { color: var(--warn); }
.menu .menu-link { color: var(--info); font-weight: 600; }
.steps { padding-left: 18px; line-height: 1.7; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--top); color: var(--top-ink); padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Lightbox */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 60; display: flex; flex-direction: column; }
.lightbox img { flex: 1; min-height: 0; object-fit: contain; width: 100%; }
.lightbox .lb-bar { display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: #000; }
.lightbox .lb-bar input { flex: 1; min-width: 0; min-height: 44px; border-radius: 10px; border: 1px solid #333; background: #111; color: #fff; padding: 6px 10px; }
.lightbox .lb-bar .btn { background: #222; color: #fff; border-color: #333; padding: 6px 12px; }

/* Onboarding */
.hero { text-align: center; padding: 28px 8px 16px; }
.hero .logo { width: 88px; height: 88px; border-radius: 22px; margin: 0 auto 12px; display: block; }
.hero h1 { font-size: 26px; margin: 0 0 6px; }
.hero p { color: var(--muted); margin: 0 auto; max-width: 400px; font-size: 16px; }
.feat { display: grid; gap: 10px; margin: 6px 0 16px; }
.feat div { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; }
.feat .ic { font-size: 22px; width: 30px; text-align: center; flex: 0 0 auto; }

/* So sánh báo giá */
.ok-t { color: var(--ok); }
.qitem { align-items: flex-start; }
.qitem .t > span { display: block; }
.qitem .nm { font-weight: 700; font-size: 16px; }
.qitem .d b { color: var(--text); }
.qitem .chev { color: var(--muted); font-size: 22px; align-self: center; }
.qbadges { display: inline-flex; flex-wrap: wrap; gap: 4px; vertical-align: middle; font-weight: 400; }
.badge.best { background: var(--info-soft); color: var(--info); }
.flags { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.flags li { padding: 6px 8px; border-radius: 8px; background: var(--amber-soft); color: var(--text); }
.flags li.bad { background: var(--warn-soft); }
.flags.plain { margin-top: 6px; }
.flags.plain li { background: transparent; padding: 0; }
.sc-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.sub-h + .sc-row { border-top: 0; }
.sc-row .lbl { flex: 1; min-width: 0; font-size: 15px; }
.sc3 { display: grid; grid-template-columns: 50px 62px 66px; gap: 4px; flex: 0 0 auto; }
.sc3 .rbtn { font-size: 13px; padding: 0 2px; }
.rbtn.unk.on { background: var(--amber); border-color: var(--amber); }
.sc3 .rbtn.on { color: var(--card); }
.field input.vague { border-color: var(--amber); background: var(--amber-soft); }
.cmp-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 12px; max-width: 100%; }
.cmp { border-collapse: separate; border-spacing: 0; font-size: 14px; width: max-content; min-width: 100%; }
.cmp th, .cmp td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; background: var(--card); color: var(--text); }
.cmp td { width: 136px; min-width: 136px; max-width: 200px; font-variant-numeric: tabular-nums; }
.cmp th:first-child { position: sticky; left: 0; z-index: 2; width: 112px; min-width: 112px; max-width: 112px; font-size: 13px; font-weight: 600; box-shadow: 1px 0 0 var(--line); }
.cmp thead th { font-size: 14px; font-weight: 700; vertical-align: bottom; }
.cmp thead th .qbadges { display: flex; margin-top: 4px; }
.cmp .ref { color: var(--muted); font-size: 13px; width: 108px; min-width: 108px; }
.cmp .ref input { width: 92px; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; background: var(--bg); color: var(--text); }
.cmp tr.grp th, .cmp tr.grp td { background: var(--bg); color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; text-align: left; }
.cmp tr.grp td { text-transform: none; letter-spacing: 0; font-weight: 500; }
.cmp tr.r-cmp td { font-size: 15px; }
.cmp td.c-bad { background: var(--warn-soft); }
.cmp td.c-warn { background: var(--amber-soft); }
.cmp td.c-best { background: var(--ok-soft); }
.cmp td .flags { font-size: 12.5px; min-width: 180px; }
.cmp .sc-yes { color: var(--ok); font-weight: 700; }
.cmp .sc-no { color: var(--warn); font-weight: 700; }
.cmp .sc-unk { color: var(--amber); font-weight: 700; }
.cmp tr.acts .btn { width: 100%; margin-bottom: 6px; }
.cmp tr:last-child th, .cmp tr:last-child td { border-bottom: 0; }

@media (max-width: 360px) {
  .tabbar button span:not(.ic) { font-size: 10px; }
  .arow { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr) 48px 32px; }
}
@media print {
  body { background: #fff; color: #000; padding: 0; }
  .topbar, .tabbar, .toast, .dlg, .actions, .quick { display: none !important; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
}
