/* ===== Home Visit — mobile-first styles ===== */
:root {
  --bg: #f3f4fb;
  --card: #ffffff;
  --ink: #1c1940;
  --ink-2: #4b4a6b;
  --muted: #8a89a6;
  --line: #e8e8f3;
  --primary: #7c3aed;
  --primary-soft: #efe9ff;
  --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 45%, #ec4899 100%);
  --r: 18px;
  --shadow: 0 1px 2px rgba(28, 25, 64, .04), 0 6px 20px rgba(28, 25, 64, .06);
  --nav-h: 66px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; }
body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 28px);
  overflow-x: hidden;
}
body.no-nav { padding-bottom: calc(28px + env(safe-area-inset-bottom)); }
body.has-savebar { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
p { margin: 0 0 10px; }
.ic { width: 20px; height: 20px; flex: none; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; margin-top: 10px; }
.pre { white-space: pre-wrap; }

/* ----- App bar ----- */
.appbar {
  background:
    radial-gradient(circle at calc(100% + 10px) -20px, rgba(255,255,255,.12) 0 90px, transparent 91px),
    radial-gradient(circle at -10px calc(100% + 10px), rgba(255,255,255,.10) 0 55px, transparent 56px),
    var(--grad);
  color: #fff;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 20px;
  border-radius: 0 0 28px 28px;
  position: relative;
}
.appbar-in { display: flex; align-items: center; gap: 12px; max-width: 720px; margin: 0 auto; position: relative; z-index: 2; }
.appbar-title { flex: 1; min-width: 0; }
.appbar-title small { display: block; opacity: .85; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar-title h1 { font-size: 21px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; flex: none;
  background: rgba(255,255,255,.2); color: #fff; border: 0; cursor: pointer;
}
.icon-btn.light { background: #fff; color: var(--primary); border: 1.5px solid var(--line); width: 48px; height: 48px; }
.hero { max-width: 720px; margin: 16px auto 0; position: relative; z-index: 1; }

.hero-stats { display: flex; gap: 8px; }
.hs { flex: 1; background: rgba(255,255,255,.17); border-radius: 16px; padding: 10px 12px; backdrop-filter: blur(4px); }
.hs b { display: block; font-size: 24px; font-weight: 800; line-height: 1.1; }
.hs span { font-size: 12px; opacity: .9; font-weight: 600; }

.hero-progress { display: flex; align-items: center; gap: 16px; }
.ring {
  --p: 0; width: 76px; height: 76px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(#fff calc(var(--p) * 1%), rgba(255,255,255,.22) 0);
}
.ring b { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; background: rgba(76, 29, 149, .55); font-size: 17px; }
.hero-big { font-size: 17px; font-weight: 800; }
.hero-small { opacity: .9; font-size: 13px; }

/* account menu */
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--c, #7c3aed); color: #fff; font-weight: 800; font-size: 14px;
  border: 2px solid rgba(255,255,255,.75);
}
.avatar.lg { width: 48px; height: 48px; border: 0; font-size: 16px; }
.menu-pop {
  position: absolute; right: 0; top: 52px; background: #fff; color: var(--ink); border-radius: 16px;
  box-shadow: 0 12px 40px rgba(28,25,64,.2); min-width: 220px; padding: 8px; z-index: 50;
}
.menu-who { padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu-who b { display: block; }
.menu-who span { font-size: 13px; color: var(--muted); }
.menu-item { display: flex; gap: 10px; align-items: center; padding: 12px; border-radius: 10px; color: #dc2626; font-weight: 700; }
.menu-item:active { background: #fef2f2; }

/* ----- Layout ----- */
.wrap { max-width: 720px; margin: 0 auto; padding: 16px; }
.list { display: grid; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
@media (min-width: 520px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.list > .card { margin-bottom: 0; }
.card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-h h2 { font-size: 16px; font-weight: 800; flex: 1; min-width: 0; }
.ibub {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: #f1effc; background: color-mix(in srgb, var(--c, #7c3aed) 14%, #fff); color: var(--c, #7c3aed);
}
.sec-label { font-size: 12px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin: 24px 4px 10px; }

/* ----- Buttons ----- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 14px; border: 0; cursor: pointer;
  font: inherit; font-weight: 700; font-size: 15px; text-align: center;
  background: var(--grad); color: #fff; box-shadow: 0 6px 16px rgba(124,58,237,.25);
  transition: transform .1s ease, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .6; }
.btn-block { width: 100%; }
.btn-soft { background: var(--primary-soft); color: var(--primary); box-shadow: none; }
.btn-ghost { background: #fff; color: var(--ink); border: 1.5px solid var(--line); box-shadow: none; }
.btn-danger { background: #fee2e2; color: #b91c1c; box-shadow: none; }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: 13px; border-radius: 11px; }
.btn-sm .ic { width: 16px; height: 16px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > * { flex: 1 1 140px; }
.link-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-top: 12px; background: none; border: 0; font: inherit; font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer; padding: 6px; }
.link-btn .ic { width: 16px; height: 16px; }

/* ----- Forms ----- */
.field { margin-bottom: 14px; }
.lbl { display: block; font-weight: 700; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.input {
  width: 100%; min-height: 48px; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 14px;
  background: #fff; font: inherit; font-size: 16px; color: var(--ink); outline: none;
  transition: border-color .15s, box-shadow .15s; -webkit-appearance: none; appearance: none;
}
.input:focus { border-color: #a78bfa; box-shadow: 0 0 0 4px rgba(139,92,246,.15); }
textarea.input { min-height: 90px; resize: vertical; line-height: 1.45; }
select.input {
  padding-right: 40px; background-repeat: no-repeat; background-position: right 14px center; background-size: 18px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a89a6' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
input[type=date].input { min-height: 48px; }
.pin-field { letter-spacing: .3em; font-weight: 700; }
.hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.field-err { font-size: 13px; color: #dc2626; font-weight: 600; margin-top: 5px; }
.inline { display: flex; gap: 8px; }
.inline .input { flex: 1; }

.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.seg-2 { grid-template-columns: 1fr 1fr; }
.seg-3 { grid-template-columns: repeat(3, 1fr); }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.seg span {
  display: flex; align-items: center; justify-content: center; min-height: 46px; padding: 0 6px; text-align: center;
  border-radius: 12px; border: 1.5px solid var(--line); background: #fff; font-weight: 700; font-size: 13px; color: var(--ink-2);
  transition: all .15s; cursor: pointer;
}
.seg input:checked + span { background: var(--c, var(--primary)); border-color: var(--c, var(--primary)); color: #fff; box-shadow: 0 4px 12px color-mix(in srgb, var(--c, #7c3aed) 35%, transparent); }
.seg input:focus-visible + span { outline: 3px solid #c4b5fd; }

.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatches label { position: relative; cursor: pointer; }
.swatches input { position: absolute; opacity: 0; }
.swatches span { display: block; width: 34px; height: 34px; border-radius: 50%; background: var(--c); border: 3px solid #fff; box-shadow: 0 0 0 1.5px var(--line); }
.swatches input:checked + span { box-shadow: 0 0 0 3px var(--c); }

.toggle { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 14px; color: var(--ink-2); margin: 4px 2px 14px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; }
.tg { width: 46px; height: 28px; border-radius: 999px; background: #dcdbea; position: relative; flex: none; transition: background .2s; }
.tg::after { content: ''; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.15); transition: transform .2s; }
.toggle input:checked + .tg { background: var(--primary); }
.toggle input:checked + .tg::after { transform: translateX(18px); }

/* ----- Chips & badges ----- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: #f1effc; color: var(--ink-2);
  background: color-mix(in srgb, var(--c, #7c3aed) 13%, #fff); color: color-mix(in srgb, var(--c, #7c3aed) 75%, #000);
  white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.chip-sm { padding: 3px 8px; font-size: 11px; }
.chip-warn { --c: #f59e0b; }
.badge { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; background: var(--c); color: #fff; }

/* ----- Search & filters ----- */
.searchbar { display: flex; gap: 8px; margin-bottom: 12px; }
.search { flex: 1; position: relative; }
.search .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 44px; }
.chips-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; margin: 0 -16px 8px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.chips-row::-webkit-scrollbar { display: none; }
.chips-sep { flex: none; width: 1px; background: var(--line); margin: 4px 2px; }
.fchip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; background: #fff;
  border: 1.5px solid var(--line); font-weight: 700; font-size: 13px; color: var(--ink-2); white-space: nowrap;
}
.fchip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.fchip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.fchip.pri.on { background: var(--c); border-color: var(--c); }
.fchip.pri.on .dot { background: #fff; }
.filters { margin-bottom: 14px; }
.filters summary { list-style: none; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer; padding: 4px 2px; }
.filters summary::-webkit-details-marker { display: none; }
.filters summary .ic { width: 15px; height: 15px; }
.filters-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.filters-grid .btn { grid-column: 1 / -1; }

/* ----- House cards ----- */
.house-item { position: relative; }
.house-card {
  display: block; background: #fff; border-radius: var(--r); padding: 14px 16px 14px 22px; box-shadow: var(--shadow);
  color: var(--ink); position: relative; overflow: hidden; transition: transform .1s;
}
.house-card:active { transform: scale(.985); }
.house-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--c); }
.hc-top { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.house-card h3 { font-size: 16.5px; font-weight: 800; }
.hc-meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.hc-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; }
.hc-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.has-remark { color: #d97706; display: grid; }
.has-remark .ic { width: 18px; height: 18px; }
.status { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.status .ic { width: 16px; height: 16px; }
.status.done { color: #059669; }
.status.todo { color: #d97706; }

.pick { display: none; position: absolute; right: 12px; top: 12px; z-index: 3; background: #fff; border-radius: 8px; padding: 4px; box-shadow: var(--shadow); }
.pick input { width: 24px; height: 24px; margin: 0; accent-color: var(--primary); display: block; }
.selecting .pick { display: block; }
.selecting .house-card { padding-right: 52px; }
.house-item.picked .house-card { box-shadow: 0 0 0 3px #a78bfa, var(--shadow); }

.bulkbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px);
  max-width: 696px; margin: 0 auto; background: var(--ink); color: #fff; border-radius: 18px; padding: 10px;
  display: none; gap: 8px; align-items: center; z-index: 30; box-shadow: 0 12px 30px rgba(28,25,64,.35);
}
.bulkbar.show { display: flex; }
.bulk-n { font-size: 13px; white-space: nowrap; padding-left: 4px; }
.bulkbar select { flex: 1; min-width: 0; min-height: 40px; border-radius: 10px; border: 0; padding: 0 10px; font: inherit; font-size: 15px; }

.fab {
  position: fixed; right: max(18px, calc(50% - 342px)); bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
  width: 60px; height: 60px; border-radius: 20px; background: var(--grad); color: #fff; display: grid; place-items: center;
  box-shadow: 0 10px 26px rgba(124,58,237,.45); z-index: 20;
}
.fab .ic { width: 28px; height: 28px; }
.selecting ~ .fab, body:has(.bulkbar.show) .fab { display: none; }

/* ----- Bottom nav ----- */
.bnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: flex; justify-content: space-around;
  background: rgba(255,255,255,.96); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.bnav a { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 0; font-size: 11px; font-weight: 700; color: var(--muted); }
.bnav .ib { width: 52px; height: 30px; border-radius: 999px; display: grid; place-items: center; transition: background .2s; }
.bnav a.on { color: var(--primary); }
.bnav a.on .ib { background: var(--primary-soft); }

/* ----- Flash ----- */
.flash { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 14px; font-weight: 600; font-size: 14px; margin-bottom: 14px; transition: opacity .4s, transform .4s; }
.flash.hide { opacity: 0; transform: translateY(-6px); }
.flash-success { background: #dcfce7; color: #166534; }
.flash-error { background: #fee2e2; color: #991b1b; }
.flash-info { background: #e0f2fe; color: #075985; }
.flash-pin { background: var(--grad); color: #fff; box-shadow: 0 10px 24px rgba(124,58,237,.3); }
.flash-pin small { opacity: .85; font-weight: 500; }
.pin-big { font-size: 34px; font-weight: 800; letter-spacing: .25em; margin: 4px 0; font-variant-numeric: tabular-nums; }

/* ----- Empty ----- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .ic { width: 56px; height: 56px; color: #c4b5fd; margin-bottom: 10px; }
.empty h3 { color: var(--ink); margin-bottom: 6px; }

/* ----- Progress ----- */
.progress { --p: 0%; height: 10px; background: #eeedf8; border-radius: 999px; overflow: hidden; flex: 1; }
.progress > i { display: block; height: 100%; width: var(--p); background: var(--grad); border-radius: inherit; transition: width .3s; }
.progress.solid > i { background: var(--c, var(--primary)); }
.progress-line { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.progress-line b { font-size: 13px; white-space: nowrap; }

/* ----- Dashboard ----- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.stat { border-radius: var(--r); padding: 14px; color: #fff; background: var(--g); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; position: relative; overflow: hidden; }
.stat .ic { position: absolute; right: 12px; top: 12px; opacity: .55; width: 26px; height: 26px; }
.stat b { font-size: 30px; font-weight: 800; line-height: 1.1; }
.stat span { font-size: 12.5px; font-weight: 600; opacity: .95; }
.quick-row { display: flex; gap: 10px; }
.qbtn { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; border-radius: 14px; background: #fff; box-shadow: var(--shadow); font-weight: 700; font-size: 14px; color: var(--c); }
.qbtn .ic { width: 18px; height: 18px; }
.team-row { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.team-row .progress-line { margin: 6px 0 0; }
.team-row-main { flex: 1; min-width: 0; }
.team-row-top { display: flex; justify-content: space-between; gap: 8px; }
.team-row-top small { color: var(--muted); font-weight: 600; }
.team-dot { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; flex: none; background: var(--c); color: #fff; font-weight: 800; }
.list-card { padding: 6px; }
.lrow { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px; color: var(--ink); }
.lrow + .lrow { border-top: 1px solid var(--line); }
.lrow-main { flex: 1; min-width: 0; }
.lrow-main b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lrow-main small { color: var(--muted); font-size: 12px; }
.lrow-end { font-size: 12px; font-weight: 800; color: var(--primary); }

/* ----- House detail ----- */
.house-hero { border-top: 6px solid var(--c); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 10px 12px; margin: 4px 0 14px; font-size: 14.5px; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.kv dt .ic { width: 18px; height: 18px; margin-top: 1px; }
.kv-text { grid-template-columns: 96px 1fr; font-size: 14px; }
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); gap: 8px; }
.qa { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; border-radius: 14px; font-size: 12px; font-weight: 700; color: var(--c); background: color-mix(in srgb, var(--c) 11%, #fff); }
.remark { background: linear-gradient(135deg, #fff7ed, #fef9c3); border: 1.5px solid #fde68a; }
.remark .input { background: rgba(255,255,255,.85); }
.remark-text { white-space: pre-wrap; font-size: 15px; margin: 0; }

/* ----- Teams / people ----- */
.add-card summary { list-style: none; display: flex; align-items: center; gap: 12px; cursor: pointer; }
.add-card summary::-webkit-details-marker { display: none; }
.add-form { margin-top: 16px; }
.member-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mchip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 3px; border-radius: 999px; background: #f4f3fb; font-size: 13px; font-weight: 600; }
.mchip i { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--c); color: #fff; font-style: normal; font-size: 10px; font-weight: 800; }
.mchip.off { opacity: .5; }
.edit-box { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 10px; }
.edit-box > summary { list-style: none; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer; }
.edit-box > summary::-webkit-details-marker { display: none; }
.edit-box > summary .ic { width: 15px; height: 15px; }
.edit-box form { margin-top: 12px; }
.edit-box form + form { padding-top: 12px; border-top: 1px solid var(--line); }
.person-row { display: flex; gap: 12px; align-items: flex-start; }
.person-main { flex: 1; min-width: 0; }
.person-main h3 { font-size: 16px; margin-bottom: 6px; }
.person-main .hc-top { margin-bottom: 4px; }
.person.inactive { opacity: .7; }
.cat-card .card-h { margin-bottom: 0; }

/* ----- Checklist ----- */
.draft-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: #fef3c7; color: #92400e; border-radius: 14px; padding: 12px; margin-bottom: 14px; font-weight: 600; font-size: 14px; }
.draft-banner span { flex: 1 1 180px; }
.hi { display: inline-block; background: #ef4444; color: #fff; font-weight: 800; font-size: 11px; line-height: 1.4; border-radius: 6px; padding: 0 6px; margin-right: 6px; vertical-align: 1px; }
.cl-sec { background: #fff; border-radius: var(--r); box-shadow: var(--shadow); margin-bottom: 12px; overflow: hidden; }
.cl-sec > summary { list-style: none; display: flex; align-items: center; gap: 12px; padding: 14px; cursor: pointer; user-select: none; }
.cl-sec > summary::-webkit-details-marker { display: none; }
.cl-num { width: 42px; height: 42px; border-radius: 13px; background: var(--c); color: #fff; display: grid; place-items: center; flex: none; box-shadow: 0 4px 12px color-mix(in srgb, var(--c) 40%, transparent); }
.cl-title { flex: 1; font-weight: 800; font-size: 15px; min-width: 0; }
.cl-title small { color: var(--muted); }
.cl-count { font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 999px; background: color-mix(in srgb, var(--c) 14%, #fff); color: var(--c); white-space: nowrap; }
.cl-count.full { background: var(--c); color: #fff; }
.chev { color: var(--muted); transition: transform .2s; }
.cl-sec[open] .chev { transform: rotate(90deg); }
.cl-body { padding: 2px 12px 12px; border-top: 1px solid var(--line); }
.cl-sub { display: flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: var(--c); margin: 16px 4px 8px; }
.cl-sub .ic { width: 15px; height: 15px; }
.ci { border-radius: 14px; background: #f7f7fc; margin-bottom: 8px; transition: background .15s; }
.ci.on { background: color-mix(in srgb, var(--c) 10%, #fff); }
.ci-row { display: flex; align-items: flex-start; gap: 6px; padding: 4px 4px 4px 0; }
.ci-row label { flex: 1; display: flex; gap: 12px; align-items: flex-start; cursor: pointer; font-size: 14.5px; font-weight: 500; padding: 10px 0 10px 12px; min-width: 0; }
.ci-row input[type=checkbox] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.box { flex: none; width: 26px; height: 26px; border-radius: 8px; border: 2px solid #cfcde6; background: #fff; display: grid; place-items: center; transition: all .15s; }
.box .ic { width: 16px; height: 16px; stroke-width: 3.2; color: #fff; opacity: 0; transform: scale(.5); transition: all .15s; }
.ci input:checked + .box, .ri.on .box { background: var(--c); border-color: var(--c); }
.ci input:checked + .box .ic, .ri.on .box .ic { opacity: 1; transform: none; }
.ci input:focus-visible + .box { outline: 3px solid color-mix(in srgb, var(--c) 40%, transparent); outline-offset: 2px; }
.ci-t { padding-top: 2px; overflow-wrap: anywhere; }
.note-btn { flex: none; width: 42px; height: 42px; margin-top: 4px; border-radius: 12px; border: 0; background: transparent; color: #b5b3cc; display: grid; place-items: center; cursor: pointer; }
.note-btn .ic { width: 19px; height: 19px; }
.note-btn.has { color: var(--c); background: #fff; }
.ci-note { padding: 0 12px 12px 50px; }
.ci-note .input { min-height: 64px; font-size: 15px; padding: 10px 12px; }
.sec-note { margin: 14px 0 0; }
.sec-note .input { min-height: 70px; }

.savebar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(255,255,255,.97); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
.savebar-in { max-width: 720px; margin: 0 auto; display: flex; align-items: center; gap: 14px; }
.savebar-prog { flex: 1; min-width: 0; }
.savebar-prog small { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.savebar-prog b { color: var(--ink); }
.savebar .btn { min-width: 120px; }

/* ----- Report (screen) ----- */
.rep-sec .card-h { margin-bottom: 4px; }
.rep-sec .cl-sub { margin-top: 12px; }
.ri { display: flex; gap: 10px; padding: 8px 2px; font-size: 14px; border-bottom: 1px dashed var(--line); }
.ri:last-of-type { border-bottom: 0; }
.ri.off { color: var(--muted); }
.box.sm { width: 22px; height: 22px; border-radius: 7px; }
.box.sm .ic { width: 14px; height: 14px; }
.ri-note { margin-top: 6px; padding: 8px 10px; border-radius: 10px; background: color-mix(in srgb, var(--c) 8%, #fff); color: var(--ink); font-size: 13.5px; white-space: pre-wrap; border-left: 3px solid var(--c); }
.ri-secnote { margin-top: 10px; padding: 10px 12px; background: #f7f7fc; border-radius: 12px; font-size: 13.5px; white-space: pre-wrap; }
.only-ticked .ri.off:not(.has-note) { display: none; }

/* ----- Login ----- */
body.login { background: var(--grad); min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { background: #fff; border-radius: 30px; padding: 30px 22px 24px; width: 100%; max-width: 380px; text-align: center; box-shadow: 0 30px 60px rgba(49, 18, 99, .35); }
.login-card h1 { font-size: 24px; font-weight: 800; margin-bottom: 4px; }
.logo { width: 68px; height: 68px; border-radius: 20px; display: block; margin: 0 auto 14px; box-shadow: 0 10px 24px rgba(124,58,237,.35); }
.setup-form { text-align: left; margin-top: 18px; }
.pin-input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 24px 0 8px; min-height: 18px; }
.pin-dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #d6d1f5; transition: all .15s; }
.pin-dots i.f { background: #7c3aed; border-color: #7c3aed; transform: scale(1.1); }
.login-err { color: #dc2626; font-weight: 700; font-size: 14px; min-height: 20px; margin: 4px 0 12px; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.key { height: 64px; border-radius: 20px; border: 0; background: #f4f2ff; font: inherit; font-size: 26px; font-weight: 700; color: var(--ink); cursor: pointer; transition: transform .08s, background .15s; touch-action: manipulation; }
.key:active { transform: scale(.94); background: #e6e0ff; }
.key.fn { background: transparent; font-size: 22px; color: var(--muted); }
.key.go { background: var(--grad); color: #fff; display: grid; place-items: center; }
.key.go .ic { width: 28px; height: 28px; stroke-width: 3; }
.shake { animation: shake .45s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* ----- PDF / print layout (fixed A4 width, off-screen) ----- */
.pdf-stage { position: fixed; left: -10000px; top: 0; width: 730px; }
#pdf-doc { width: 100%; background: #fff; color: #1f2937; font-family: Arial, Helvetica, sans-serif; font-size: 11px; line-height: 1.35; padding: 4px; }
#pdf-doc .pre { white-space: pre-wrap; }
.pd-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid #1f5c4a; padding-bottom: 6px; margin-bottom: 10px; }
.pd-title { color: #1f5c4a; font-size: 22px; font-weight: 700; }
.pd-sub { color: #555; font-size: 10px; }
.pd-score { text-align: right; color: #1f5c4a; }
.pd-score b { display: block; font-size: 18px; }
.pd-score span { font-size: 9px; color: #666; }
.pd-info { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.pd-info td { border: 1px solid #d1d5db; padding: 4px 6px; vertical-align: top; }
.pd-info td.k { background: #f1f5f3; font-weight: 700; width: 15%; white-space: nowrap; }
.pd-box { border: 1px solid #c9cfd6; padding: 6px 8px; margin-bottom: 10px; }
.pd-box h4 { margin: 0 0 4px; font-size: 11.5px; color: #1f5c4a; }
.pdf-sec { border: 1px solid #c9cfd6; margin-bottom: 10px; }
.pdf-sec-head { background: #1f5c4a; color: #fff; font-weight: 700; padding: 5px 8px; font-size: 11.5px; }
.pdf-cols { display: flex; }
.pdf-col { flex: 1; padding: 6px 8px 2px; }
.pdf-col + .pdf-col { border-left: 1px solid #c9cfd6; }
.pdf-row { display: flex; gap: 6px; margin-bottom: 5px; }
.pdf-cb { flex: none; width: 12px; height: 12px; border: 1px solid #555; font-size: 10px; line-height: 11px; text-align: center; margin-top: 1px; font-weight: 700; }
.pdf-cb.on { background: #1f5c4a; border-color: #1f5c4a; color: #fff; }
.pdf-hi { color: #dc2626; font-weight: 700; }
.pdf-note { font-style: italic; color: #374151; background: #eef4f1; padding: 2px 5px; margin-top: 2px; white-space: pre-wrap; }
.pdf-secnote { border-top: 1px solid #c9cfd6; padding: 5px 8px; background: #fafafa; }
.pdf-foot { font-size: 9px; color: #888; margin-top: 8px; display: flex; justify-content: space-between; }

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; padding: 0 !important; }
  .appbar, .bnav, .no-print, .flash, .fab { display: none !important; }
  .wrap { padding: 0; max-width: none; }
  .pdf-stage { position: static; width: auto; }
  #pdf-doc { width: auto; padding: 0; }
  .pdf-sec, .pd-box, .pdf-row { break-inside: avoid; }
}

/* ----- Reports ----- */
.seg-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: #e9e8f5; border-radius: 14px; padding: 4px; margin-bottom: 14px; }
.seg-tabs a { text-align: center; padding: 10px; border-radius: 11px; font-weight: 700; font-size: 14px; color: var(--ink-2); }
.seg-tabs a.on { background: #fff; color: var(--primary); box-shadow: var(--shadow); }
.filter-card > summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; flex-wrap: wrap; }
.filter-card > summary::-webkit-details-marker { display: none; }
.filter-card > summary .ic { width: 18px; height: 18px; color: var(--primary); }
.rep-filters { margin-top: 14px; }
.rep-filters .btn { grid-column: auto; }
.date-f { display: block; }
.date-f span { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.stat b small { font-size: 16px; opacity: .8; }
.btn-excel { background: linear-gradient(135deg, #059669, #10b981); box-shadow: 0 6px 16px rgba(16,185,129,.3); }
.center { text-align: center; margin-top: 8px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-size: 14px; margin: 6px 0 12px; }
.back-link .ic { width: 18px; height: 18px; }
.pad { padding: 10px; margin: 0; }
.item-stat { display: block; padding: 10px 8px; border-radius: 12px; color: var(--ink); border-bottom: 1px dashed var(--line); }
.item-stat:active { background: #f7f7fc; }
.is-text { display: block; font-size: 14px; margin-bottom: 6px; }
.is-bar { display: flex; align-items: center; gap: 10px; }
.is-bar .progress { height: 8px; --c: inherit; }
.is-bar b { font-size: 12px; min-width: 44px; text-align: right; }
.is-bar em { display: inline-flex; align-items: center; gap: 3px; font-style: normal; font-size: 12px; font-weight: 700; color: var(--c); }
.is-bar em .ic { width: 14px; height: 14px; }
.box.on-box { background: var(--c); border-color: var(--c); }
.box.on-box .ic { opacity: 1; transform: none; }
.mini-secs { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 6px; margin-top: 10px; }
.mini-secs span { position: relative; overflow: hidden; border-radius: 8px; background: #f3f2fa; font-size: 11px; font-weight: 700; color: var(--ink-2); padding: 4px 6px; display: flex; gap: 4px; align-items: center; }
.mini-secs i { position: absolute; left: 0; top: 0; bottom: 0; width: var(--p); background: color-mix(in srgb, var(--c) 22%, transparent); }
.mini-secs b { position: relative; color: var(--c); }
