/* CareBloom carer app — mobile-first, high contrast, big tap targets (min 44px). */
:root {
  --brand: #0f766e; --brand-d: #0b5c56; --brand-l: #ccfbf1;
  --ink: #0f172a; --ink-2: #334155; --muted: #52606d; --bg: #f1f5f9; --card: #fff; --line: #cbd5e1;
  --green: #15803d; --green-l: #dcfce7; --amber: #b45309; --amber-l: #fef3c7;
  --red: #b91c1c; --red-l: #fee2e2; --blue: #075985; --blue-l: #e0f2fe;
  --r: 14px; --safe-top: env(safe-area-inset-top, 0px); --safe-bot: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--ink); -webkit-tap-highlight-color: transparent; overscroll-behavior-y: contain; }
#app { max-width: 560px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(24px + var(--safe-bot)); }
a { color: var(--brand-d); }
h1, h2, h3, h4 { margin: 0 0 8px; line-height: 1.2; }
h2 { font-size: 1.25rem; } h3 { font-size: 1.08rem; } h4 { font-size: .98rem; margin-top: 12px; }
h3 small, h2 small { font-weight: 500; color: var(--muted); font-size: .8rem; margin-left: 6px; }
p { margin: 0 0 10px; }
small, .small { color: var(--muted); font-size: .85rem; }
.center { text-align: center; }
:focus-visible { outline: 3px solid #f59e0b; outline-offset: 2px; }
#view:focus { outline: none; }

/* splash / auth */
.splash { display: grid; place-items: center; min-height: 80vh; color: var(--brand); text-align: center; }
.splash-logo, .auth-logo { font-size: 3rem; color: var(--brand); }
.auth { padding: calc(28px + var(--safe-top)) 16px 24px; text-align: center; }
.auth h1 { font-size: 1.5rem; margin-bottom: 16px; }
.auth .card { background: var(--card); border-radius: var(--r); padding: 18px; text-align: left; box-shadow: 0 1px 3px rgba(15,23,42,.1); }
.auth .alt { margin-top: 16px; }
.pin { font-size: 1.6rem; letter-spacing: .6em; text-align: center; }
.err { color: var(--red); font-weight: 600; min-height: 1em; margin-top: 8px; }

/* header + banners */
header.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; background: var(--brand); color: #fff; padding: calc(10px + var(--safe-top)) 12px 10px; min-height: 56px; }
header.top .logo { font-size: 1.5rem; width: 36px; text-align: center; }
header.top .back { color: #fff; font-size: 2rem; line-height: 1; text-decoration: none; min-width: 44px; min-height: 44px; display: grid; place-items: center; margin-left: -8px; }
header.top .ttl { flex: 1; min-width: 0; display: flex; flex-direction: column; }
header.top .ttl strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1.05rem; }
header.top .ttl small { color: #d1fae5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
header.top .menu { color: #fff; font-size: 1.4rem; text-decoration: none; min-width: 44px; min-height: 44px; display: grid; place-items: center; }
.sync { border: 0; border-radius: 999px; padding: 6px 10px; font-size: .75rem; font-weight: 700; min-height: 32px; background: rgba(255,255,255,.18); color: #fff; max-width: 42vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sync.off { background: #fde68a; color: #78350f; }
.sync.wait { background: #fff; color: var(--amber); }
.sync.sync { background: #fff; color: var(--brand-d); }
.banner { display: block; margin: 0; padding: 10px 14px; font-size: .92rem; font-weight: 600; text-decoration: none; }
.banner.offline { background: #fde68a; color: #78350f; }
.banner.problem { background: var(--red-l); color: var(--red); border-radius: 0; }
.banner.problem p { margin: 0 0 4px; }
.banner.inprog { background: var(--blue-l); color: var(--blue); }
.banner.inprog summary { cursor: pointer; min-height: 28px; }
.banner.inprog ul { margin: 6px 0 0; padding-left: 18px; }
.banner.inprog a { color: var(--blue); display: inline-block; padding: 6px 0; }
main { padding: 12px 12px 0; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 10px 18px; border-radius: 12px; border: 2px solid var(--brand); background: var(--brand); color: #fff; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.big { width: 100%; min-height: 56px; font-size: 1.08rem; margin-top: 8px; }
.btn.wide { width: 100%; margin-top: 8px; }
.btn.ghost { background: #fff; color: var(--brand-d); }
.btn.sm { min-height: 40px; padding: 6px 12px; font-size: .9rem; }
.btn.light { background: #fff; color: var(--ink); border-color: #fff; }
.btn.danger { background: var(--red); border-color: var(--red); }
.btn.danger-o { background: #fff; color: var(--red); border-color: var(--red); }
.btn.muted { background: #94a3b8; border-color: #94a3b8; }
.btnrow { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.btnrow.split { justify-content: space-between; }
.btnrow .btn { flex: 1 1 auto; }
.link { background: none; border: 0; padding: 8px 0; color: var(--brand-d); font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; min-height: 40px; display: inline-block; }
.link.danger { color: var(--red); }

/* forms */
label { display: block; font-weight: 600; margin: 12px 0 4px; }
input, select, textarea { width: 100%; font: inherit; font-size: 1rem; padding: 12px; border: 2px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); min-height: 48px; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-l); }
textarea { resize: vertical; }
fieldset { border: 0; padding: 0; margin: 12px 0 0; }
legend { font-weight: 700; margin-bottom: 6px; padding: 0; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; margin: 6px 0; padding: 10px 12px; min-height: 48px; background: #fff; border: 2px solid var(--line); border-radius: 10px; }
.check input { width: 22px; height: 22px; min-height: 0; flex: none; accent-color: var(--brand); }
.check.big { font-weight: 600; }
.check:has(input:checked) { border-color: var(--brand); background: var(--brand-l); }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice { margin: 0; display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 10px; border: 2px solid var(--line); border-radius: 12px; background: #fff; font-weight: 700; }
.choice input { width: 20px; height: 20px; min-height: 0; accent-color: var(--brand); }
.choice.on { border-color: var(--brand); background: var(--brand-l); }
.choice.o-given.on { border-color: var(--green); background: var(--green-l); }
.choice.o-partial.on { border-color: var(--amber); background: var(--amber-l); }
.choice.o-not_taken.on { border-color: var(--red); background: var(--red-l); }
.hint { color: var(--muted); font-size: .88rem; margin-top: 6px; }
.notice { background: var(--amber-l); color: #78350f; border-radius: 10px; padding: 10px 12px; font-size: .9rem; margin-top: 12px; }
.warn-t { color: var(--amber); font-weight: 700; }

/* rota */
.days { display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 10px; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; }
.day { flex: 0 0 auto; scroll-snap-align: start; display: flex; flex-direction: column; align-items: center; width: 56px; min-height: 64px; padding: 6px 0; border-radius: 12px; border: 2px solid var(--line); background: #fff; color: var(--ink); font: inherit; cursor: pointer; }
.day span { font-size: .72rem; text-transform: uppercase; color: var(--muted); }
.day b { font-size: 1.15rem; }
.day i { font-style: normal; font-size: .7rem; color: var(--brand-d); min-height: 1em; font-weight: 700; }
.day.today { border-color: var(--brand); }
.day.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.day.on span, .day.on i { color: #d1fae5; }
.dayh { margin: 6px 2px 10px; }
.visits, .items, .log { list-style: none; margin: 0; padding: 0; }
.vcard { display: flex; gap: 12px; background: var(--card); border-radius: var(--r); padding: 14px; margin-bottom: 10px; text-decoration: none; color: var(--ink); border-left: 6px solid var(--blue); box-shadow: 0 1px 2px rgba(15,23,42,.08); min-height: 72px; }
.vcard.st-in_progress { border-left-color: var(--amber); }
.vcard.st-completed { border-left-color: var(--green); opacity: .85; }
.vcard.st-cancelled, .vcard.st-missed { border-left-color: var(--red); opacity: .7; }
.vtime { display: flex; flex-direction: column; min-width: 52px; }
.vtime b { font-size: 1.15rem; color: var(--brand-d); }
.vbody { flex: 1; min-width: 0; }
.vname { font-weight: 700; font-size: 1.05rem; }
.vaddr { color: var(--muted); font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vmeta { font-size: .85rem; margin-top: 4px; color: var(--ink-2); }
.dbl { font-size: 1rem; }
.pill { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: .74rem; font-weight: 700; background: #e2e8f0; color: var(--ink-2); }
.pill.scheduled { background: var(--blue-l); color: var(--blue); }
.pill.in_progress { background: var(--amber-l); color: #92400e; }
.pill.completed { background: var(--green-l); color: var(--green); }
.pill.cancelled, .pill.missed { background: var(--red-l); color: var(--red); }
.pill.risk-high { background: var(--red-l); color: var(--red); } .pill.risk-medium { background: var(--amber-l); color: #92400e; } .pill.risk-low { background: var(--green-l); color: var(--green); }
.empty, .empty-s { color: var(--muted); }
.empty { text-align: center; padding: 28px 12px; }
.ptr { height: 0; overflow: hidden; text-align: center; color: var(--brand-d); font-weight: 700; transition: height .15s; }
.ptr.show { height: 36px; line-height: 36px; }

/* visit */
.chead { background: var(--card); border-radius: var(--r); padding: 14px; margin-bottom: 10px; }
.crow { display: flex; gap: 12px; align-items: center; }
.avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--brand-l); color: var(--brand-d); display: grid; place-items: center; font-weight: 800; font-size: 1.2rem; object-fit: cover; flex: none; }
.vwhen { font-size: .9rem; color: var(--ink-2); margin-top: 2px; }
.addr { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; padding: 12px; min-height: 48px; background: var(--blue-l); color: var(--blue); border-radius: 10px; text-decoration: none; font-weight: 600; }
.addr span { white-space: nowrap; }
.access { margin: 8px 0 0; padding: 8px 10px; background: #f8fafc; border-radius: 8px; }
.hl { margin: 8px 0 0; color: var(--ink-2); }
.onote { margin: 8px 0 0; padding: 8px 10px; border-left: 4px solid var(--blue); background: var(--blue-l); }
.flags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.flag { font-size: .8rem; font-weight: 700; padding: 4px 8px; border-radius: 8px; background: #e2e8f0; }
.flag.red { background: var(--red); color: #fff; } .flag.amber { background: var(--amber-l); color: #78350f; }
.tabs { display: flex; gap: 4px; margin: 0 0 10px; background: #e2e8f0; border-radius: 12px; padding: 4px; }
.tabs a { flex: 1; text-align: center; padding: 10px 6px; border-radius: 9px; text-decoration: none; color: var(--ink-2); font-weight: 700; font-size: .92rem; min-height: 44px; }
.tabs a.on { background: #fff; color: var(--brand-d); box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.sec { background: var(--card); border-radius: var(--r); padding: 14px; margin-bottom: 10px; }
details.sec summary { cursor: pointer; list-style: none; display: flex; align-items: center; min-height: 32px; }
details.sec summary::-webkit-details-marker { display: none; }
details.sec summary h3 { margin: 0; flex: 1; }
details.sec summary::after { content: "▾"; color: var(--muted); }
details.sec[open] summary { margin-bottom: 8px; }
.cta { margin: 6px 0 14px; }
.done-box { background: var(--green-l); color: var(--green); font-weight: 700; padding: 12px; border-radius: 10px; margin-bottom: 10px; }
.item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px; margin: 6px 0; min-height: 56px; border-radius: 10px; border: 2px solid var(--line); text-decoration: none; color: var(--ink); background: #fff; }
.iname { font-weight: 600; min-width: 0; }
.iname small { display: block; font-weight: 400; }
.istate { font-size: .82rem; font-weight: 700; color: var(--muted); text-align: right; flex: none; max-width: 40%; }
.item.need { border-color: var(--red); } .item.need .istate { color: var(--red); }
.item.rec.o-given { border-color: #86efac; background: #f0fdf4; } .item.rec.o-given .istate { color: var(--green); }
.item.rec.o-partial, .item.rec.o-not_observed { border-color: #fcd34d; background: #fffbeb; } .item.rec.o-partial .istate { color: var(--amber); }
.item.rec.o-not_taken, .item.rec.o-refused { border-color: #fca5a5; background: #fef2f2; } .item.rec.o-not_taken .istate { color: var(--red); }
.item.prn { border-style: dashed; }
.ess { display: inline-block; font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; color: #fff; background: var(--red); border-radius: 6px; padding: 1px 6px; vertical-align: middle; }
.log li { padding: 10px 0; border-bottom: 1px solid #e2e8f0; }
.log li:last-child { border-bottom: 0; }
.thumb { display: block; max-width: 140px; max-height: 140px; border-radius: 8px; margin-bottom: 6px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; margin: 8px 0; }
.kv dt { font-weight: 700; color: var(--ink-2); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.instr { background: #f8fafc; border-left: 4px solid var(--brand); padding: 10px 12px; border-radius: 6px; white-space: pre-line; }
.medcard h2 small { font-size: .75rem; }
.photo-prev img { max-width: 100%; border-radius: 10px; margin-top: 8px; }
.prob { color: var(--red); }
.today h4 small { font-weight: 400; }
.hist { border-bottom: 1px solid #e2e8f0; padding: 8px 0; }

/* geo */
.geo { border-radius: 12px; padding: 12px; margin: 10px 0; }
.geo.ok { background: var(--green-l); color: #14532d; }
.geo.bad { background: var(--amber-l); color: #78350f; }
.radar { position: relative; height: 90px; margin: 8px 0; background: rgba(255,255,255,.6); border-radius: 10px; overflow: hidden; }
.radar .home { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); font-size: 1.5rem; }
.radar .ring { position: absolute; left: 50%; top: 50%; width: 60px; height: 60px; transform: translate(-50%,-50%); border: 2px dashed currentColor; border-radius: 50%; opacity: .5; }
.radar .me { position: absolute; top: 50%; left: calc(50% + var(--d) * 45%); transform: translate(-50%,-50%); color: #2563eb; font-size: 1.3rem; }

/* scanner */
.scanner { position: fixed; inset: 0; z-index: 100; background: #000; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding: 20px 20px calc(24px + var(--safe-bot)); gap: 12px; text-align: center; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scanner .scan-frame { position: absolute; left: 50%; top: 42%; width: 64vw; max-width: 280px; aspect-ratio: 1; transform: translate(-50%,-50%); border: 4px solid #fff; border-radius: 16px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); }
.scanner p, .scanner button { position: relative; }

/* wizard + body map */
.steps { height: 8px; background: #e2e8f0; border-radius: 99px; overflow: hidden; }
.steps span { display: block; height: 100%; background: var(--brand); }
.sev-high:has(input:checked) { border-color: var(--red); background: var(--red-l); }
.seg { display: flex; gap: 4px; background: #e2e8f0; padding: 4px; border-radius: 12px; margin: 10px 0 4px; }
.seg button { flex: 1; min-height: 44px; border: 0; border-radius: 9px; background: none; font: inherit; font-weight: 700; color: var(--ink-2); }
.seg button.on { background: #fff; color: var(--brand-d); }
.bm-wrap { display: flex; justify-content: center; }
.bm-svg { width: 100%; max-width: 260px; height: auto; touch-action: manipulation; }
.bm-part { fill: #e2e8f0; stroke: #64748b; stroke-width: 1.2; cursor: pointer; }
.bm-part:hover, .bm-part:focus { fill: #bae6fd; outline: none; }
.bm-part.on { fill: #fca5a5; }
.bm-mark { fill: var(--red); stroke: #fff; stroke-width: 1.5; pointer-events: none; }
.bm-num { fill: #fff; font-size: 9px; font-weight: 800; pointer-events: none; }
.bm-add { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: end; }
.bm-add label { grid-column: 1 / -1; margin-bottom: 0; }
.bm-list { padding-left: 22px; }
.bm-list li { margin: 10px 0; }
.bm-li-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.bm-viewer { display: flex; gap: 12px; flex-wrap: wrap; }
.bm-viewer figure { margin: 0; flex: 1 1 140px; text-align: center; }
.bm-viewer .bm-svg { max-width: 150px; }
.bm-viewer .bm-part { cursor: default; }
.bm-viewer figcaption { font-size: .85rem; }
.review dd { white-space: pre-line; }

.big-done .tick { font-size: 3rem; color: #fff; background: var(--green); width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; margin: 10px auto 12px; }

.toast { position: fixed; left: 50%; bottom: calc(18px + var(--safe-bot)); transform: translate(-50%, 150%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; max-width: calc(100% - 32px); z-index: 90; transition: transform .2s; }
.toast.show { transform: translate(-50%, 0); }
.toast.warn { background: #92400e; }

@media (min-width: 600px) { main { padding: 16px 0 0; } }
@media (max-width: 370px) { body { font-size: 16px; } .choices { grid-template-columns: 1fr; } .kv { grid-template-columns: 1fr; } .kv dt { margin-top: 4px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* one phone, many agencies (CT-1507) + agency branding (CT-1508) */
header.top .agency-sw { position: relative; display: flex; align-items: center; gap: 2px; color: #fff; text-decoration: none; min-width: 44px; min-height: 44px; margin-left: -4px; font-size: .9rem; }
header.top .logo .ag-mark, header.top .agency-sw .ag-mark { width: 32px; height: 32px; border-radius: 8px; object-fit: contain; background: #fff; }
header.top .agency-sw .ag-initial, header.top .logo .ag-initial { display: grid; place-items: center; color: #fff; font-weight: 800; border: 2px solid rgba(255,255,255,.7); }
.ag-badge { position: absolute; top: 0; right: -4px; min-width: 18px; height: 18px; border-radius: 9px; background: #fde68a; color: #78350f; font: 700 .7rem/18px sans-serif; text-align: center; font-style: normal; padding: 0 4px; }
.agencies { list-style: none; margin: 12px 0; padding: 0; }
.agencies li + li { margin-top: 10px; }
.agency-pick { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-left: 6px solid var(--brand); border-radius: var(--r); font: inherit; color: var(--ink); text-align: left; cursor: pointer; }
.agency-pick.on { box-shadow: 0 0 0 2px var(--brand) inset; }
.agency-pick .ag-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.agency-pick .ag-txt b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-logo { width: 40px; height: 40px; border-radius: 10px; object-fit: contain; flex: none; background: #fff; }
.ag-logo.ag-initial { display: inline-grid; place-items: center; color: #fff; font-weight: 800; font-size: 1.1rem; }
.ag-row { display: inline-flex; align-items: center; gap: 8px; }
.ag-row .ag-logo { width: 28px; height: 28px; border-radius: 7px; font-size: .9rem; }
.ag-h { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.ag-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.log.across li { padding: 6px 0; }
