:root {
  --navy: #1b2a4a;
  --navy-2: #2a3d66;
  --gold: #c9a227;
  --gold-soft: #f6edcc;
  --green: #2f7d57;
  --green-soft: #e3f2ea;
  --red: #b3392f;
  --red-soft: #fbe7e4;
  --amber: #9a6a00;
  --amber-soft: #fff3d6;
  --bg: #f5f3ee;
  --card: #ffffff;
  --ink: #1d2433;
  --muted: #5d6578;
  --line: #e2ded4;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(27, 42, 74, .06), 0 4px 16px rgba(27, 42, 74, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
.boot { padding: 40vh 0; text-align: center; color: var(--muted); }
h1, h2, h3 { color: var(--navy); line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; }
a { color: var(--navy-2); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-variant-numeric: tabular-nums; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--navy); color: #fff;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .2px; }
.brand img { width: 28px; height: 28px; }
.brand small { display: block; font-weight: 400; color: #c9cfdc; font-size: .75rem; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: .85rem; color: #d7dbe5; }
.topbar button { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.35); }
.topbar button:hover { background: rgba(255,255,255,.1); }

/* admin tabs */
.tabs { display: flex; gap: 4px; overflow-x: auto; background: var(--navy-2); padding: 0 12px; scrollbar-width: none; }
.tabs a {
  color: #d7dbe5; text-decoration: none; padding: 10px 14px; white-space: nowrap;
  border-bottom: 3px solid transparent; font-size: .9rem;
}
.tabs a.on { color: #fff; border-color: var(--gold); }
.tabs .badge { margin-left: 6px; }

main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
main.narrow { max-width: 520px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card.flat { box-shadow: none; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid { display: grid; gap: 12px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.stat { padding: 14px 16px; }
.stat .n { font-size: 1.8rem; font-weight: 700; color: var(--navy); }
.stat .l { color: var(--muted); font-size: .85rem; }
.stat.warn .n { color: var(--red); }

/* forms */
label { display: block; font-size: .85rem; font-weight: 600; color: var(--navy); margin-bottom: 4px; }
.field { margin-bottom: 12px; }
input, select, textarea {
  width: 100%; font: inherit; color: inherit; padding: 9px 11px;
  border: 1px solid #cfcabd; border-radius: 8px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: var(--gold); }
textarea { min-height: 80px; resize: vertical; }
.hint { font-size: .8rem; color: var(--muted); margin-top: 3px; }
.inline { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.inline .field { margin: 0; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: auto; }

button, .btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 8px;
  padding: 9px 14px; border: 1px solid var(--line); background: #fff; color: var(--navy);
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button:hover { background: #faf8f3; }
button:disabled { opacity: .55; cursor: not-allowed; }
.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.primary:hover { background: var(--navy-2); }
.gold { background: var(--gold); border-color: var(--gold); color: var(--navy); }
.gold:hover { background: #d8b23a; }
.success { background: var(--green); border-color: var(--green); color: #fff; }
.success:hover { background: #276b4a; }
.danger { background: #fff; color: var(--red); border-color: #e6b8b2; }
.danger:hover { background: var(--red-soft); }
.big { width: 100%; padding: 16px; font-size: 1.1rem; border-radius: 12px; }
.link { background: none; border: none; padding: 0; color: var(--navy-2); text-decoration: underline; font-weight: 500; }

/* tables */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid #f0ece3; vertical-align: top; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #faf8f3; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.b-green { background: var(--green-soft); color: var(--green); }
.b-red { background: var(--red-soft); color: var(--red); }
.b-amber { background: var(--amber-soft); color: var(--amber); }
.b-navy { background: #e6eaf3; color: var(--navy); }
.b-gray { background: #eeece6; color: var(--muted); }
.b-gold { background: var(--gold-soft); color: #7a5f00; }

/* caregiver */
.shift { border-left: 4px solid var(--gold); }
.shift.done { border-left-color: var(--green); opacity: .8; }
.shift .time { font-weight: 700; color: var(--navy); font-size: 1.05rem; }
.active-visit { background: var(--navy); color: #fff; border: none; }
.active-visit h2, .active-visit h3 { color: #fff; }
.active-visit .muted { color: #c9cfdc; }
.timer { font-size: 2.6rem; font-weight: 700; color: var(--gold); letter-spacing: 1px; margin: 8px 0; }
.gpsnote { font-size: .85rem; padding: 8px 10px; border-radius: 8px; background: var(--amber-soft); color: var(--amber); margin: 8px 0; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: 100%; max-width: 400px; }
.auth .logo { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; }
.auth .logo img { width: 44px; height: 44px; }
.error { background: var(--red-soft); color: var(--red); padding: 9px 12px; border-radius: 8px; font-size: .9rem; margin-bottom: 12px; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(20, 28, 46, .5); display: grid; place-items: start center; padding: 5vh 12px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 680px; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal .row.between { margin-bottom: 8px; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; font-size: .9rem; margin: 10px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.section { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.exc { padding: 10px 12px; border-radius: 8px; margin-bottom: 8px; background: var(--red-soft); }
.exc.ok { background: #f3f1ec; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(100px); background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 10px; transition: transform .25s; z-index: 100; max-width: 90vw; }
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--red); }

@media (max-width: 600px) {
  .kv { grid-template-columns: 1fr; gap: 0 0; }
  .kv dt { margin-top: 6px; }
  .topbar .who { display: none; }
  main { padding: 14px 12px 60px; }
}
@media print {
  .topbar, .tabs, button { display: none !important; }
}

/* utilities (no inline styles: CSP) */
.m0{margin:0}.mt8{margin-top:8px}.mt12{margin-top:12px}.mt14{margin-top:14px}.mb6{margin-bottom:6px}.mb16{margin-bottom:16px}.ml6{margin-left:6px}
.m-cname{margin:6px 0 2px}.m-svc{margin:4px 0 10px}.center-note{text-align:center;margin-top:20px}
.plainlink{text-decoration:none;color:inherit}.nowrap{white-space:nowrap}.notes-list{margin:12px 0 0;padding-left:18px}
[hidden] { display: none !important; }
#toast { opacity: 0; pointer-events: none; }
#toast.show { opacity: 1; pointer-events: auto; }
.success:disabled, .success:disabled:hover { background: #ebe8e0; border-color: #ebe8e0; color: var(--muted); font-size: .95rem; opacity: 1; }
.notice { background: #e6eaf3; color: var(--navy); padding: 10px 12px; border-radius: 8px; font-size: .9rem; margin-bottom: 12px; }

/* branding */
.brand-mark { width: 38px; height: 38px; border-radius: 50%; background: #fff; display: grid; place-items: center; flex: none; }
.brand-mark img { width: 32px; height: 32px; object-fit: contain; }
.auth { align-content: center; }
.auth-logo { text-align: center; margin: 0 0 10px; }
.auth-logo img { max-width: 220px; max-height: 210px; width: auto; height: auto; }
.auth-title { text-align: center; margin: 4px 0 2px; }
.auth-sub { text-align: center; margin-bottom: 16px; }
.auth > .center-note { margin-top: 8px; }
.money { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
th.money { text-align: right; }
.warn-box { background: var(--amber-soft); color: var(--amber); padding: 10px 12px; border-radius: 8px; font-size: .9rem; margin-bottom: 12px; }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.settings-group { margin-bottom: 8px; }
.logo-preview { width: 120px; height: 120px; object-fit: contain; border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 6px; }
.tabs-sub { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs-sub button.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.gpsnote.blocked { background: var(--red-soft); color: var(--red); font-size: .95rem; }
.inline .grow { flex: 1; min-width: 200px; }
tr.subrow td { padding-top: 4px; padding-bottom: 4px; border-bottom-color: transparent; }
tr.total td { font-weight: 700; border-top: 2px solid var(--line); background: #faf8f3; }
.link + .link { margin-left: 4px; }
