:root {
  --bg: #F4F1EC;
  --card: #FFFFFF;
  --ink: #17252A;
  --muted: #5F6B6E;
  --line: #E4DED5;
  --brand: #0E4F54;
  --brand-ink: #FFFFFF;
  --gold: #C9962E;
  --gold-soft: #FBF1DC;
  --warn: #B4361E;
  --warn-soft: #FCE8E3;
  --ok: #2E7D4F;
  --ok-soft: #E3F2E8;
  --chip: #E9E4DC;
  --shadow: 0 1px 2px rgba(23, 37, 42, .06), 0 4px 14px rgba(23, 37, 42, .06);
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1517;
    --card: #192225;
    --ink: #EEF2F1;
    --muted: #9AA7A9;
    --line: #273235;
    --brand: #3FA7A4;
    --brand-ink: #071415;
    --gold: #E3B55A;
    --gold-soft: #3A2F18;
    --warn: #FF8A70;
    --warn-soft: #3B1F19;
    --ok: #6CCB92;
    --ok-soft: #173023;
    --chip: #243033;
    --shadow: none;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
  overscroll-behavior-y: none;
}
[hidden] { display: none !important; }
h1, h2 { margin: 0; letter-spacing: -0.02em; }
button { font: inherit; color: inherit; }
a { color: var(--brand); }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 14px; }

/* ---------- Sign in ---------- */
#login { min-height: 100vh; display: grid; place-items: center; padding: calc(var(--safe-top) + 24px) 24px calc(var(--safe-bottom) + 24px); }
.login-wrap { width: 100%; max-width: 340px; text-align: center; }
.logo { border-radius: 18px; box-shadow: var(--shadow); }
#login h1 { font-size: 26px; margin-top: 14px; }
.pin-dots { display: flex; gap: 18px; justify-content: center; margin: 32px 0 10px; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--brand); transition: background .12s; }
.pin-dots i.on { background: var(--brand); }
.pin-dots.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.login-msg { min-height: 22px; color: var(--muted); font-size: 15px; margin: 0 0 18px; }
.login-msg.err { color: var(--warn); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; justify-items: center; }
.keypad button {
  width: 76px; height: 76px; border-radius: 50%; border: 0; background: var(--card);
  font-size: 30px; font-weight: 400; box-shadow: var(--shadow); touch-action: manipulation;
}
.keypad button:active { background: var(--chip); transform: scale(.96); }
.keypad button[data-k="del"] { background: transparent; box-shadow: none; font-size: 26px; }

/* ---------- Header ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  padding: calc(var(--safe-top) + 12px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid transparent;
}
.top.scrolled { border-bottom-color: var(--line); }
.top-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.top h1 { font-size: 32px; font-weight: 700; }
.eyebrow { margin: 0 0 2px; font-size: 13px; color: var(--muted); font-weight: 500; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--chip); display: grid; place-items: center; color: var(--brand); }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--chip); border-radius: 10px; padding: 2px; margin-top: 12px; }
.seg button { border: 0; background: transparent; padding: 7px 0; border-radius: 8px; font-size: 15px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 10px -16px 0; padding: 0 16px 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 0; background: var(--chip); padding: 6px 13px; border-radius: 999px; font-size: 14px; font-weight: 600; color: var(--ink); }
.chip.on { background: var(--brand); color: var(--brand-ink); }
.chip .n { opacity: .7; font-weight: 500; margin-left: 4px; }

/* ---------- Pull to refresh ---------- */
.ptr { height: 0; overflow: hidden; display: grid; place-items: center; transition: height .2s; }
.ptr span { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--brand); }
.ptr.spin span { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- List ---------- */
.list { padding: 6px 16px calc(var(--safe-bottom) + 32px); max-width: 640px; margin: 0 auto; }
#banners { padding: 0 16px; max-width: 640px; margin: 0 auto; }
.day { margin: 18px 4px 8px; font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; }
.day.today { color: var(--brand); }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.card.unassigned { border: 1.5px dashed var(--warn); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.prop { font-size: 21px; font-weight: 700; letter-spacing: -0.01em; margin: 0; }
.time { font-size: 16px; font-weight: 600; margin: 2px 0 0; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.badge { font-size: 13px; font-weight: 700; padding: 4px 9px; border-radius: 999px; background: var(--chip); color: var(--ink); }
.badge.same { background: var(--gold-soft); color: var(--gold); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.who { font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--chip); white-space: nowrap; }
.facts { display: grid; gap: 8px; margin: 14px 0 0; padding: 12px 0 0; border-top: 1px solid var(--line); }
.fact { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; }
.fact svg { flex: none; margin-top: 2px; color: var(--brand); }
.fact b { font-weight: 600; }
.notes { margin-top: 10px; font-size: 15px; color: var(--muted); white-space: pre-line; background: var(--bg); border-radius: 12px; padding: 10px 12px; }
.actions { display: flex; gap: 10px; margin-top: 14px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 12px; padding: 11px 16px; min-height: 44px;
  background: var(--brand); color: var(--brand-ink); font-weight: 600; font-size: 16px; text-decoration: none;
}
.btn:active { opacity: .8; }
.btn.ghost { background: var(--chip); color: var(--ink); }
.btn.danger { background: var(--warn-soft); color: var(--warn); }
.btn.small { padding: 8px 14px; min-height: 36px; font-size: 15px; }
.btn.block { width: 100%; margin-top: 10px; }
.actions .btn { flex: 1; }
.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty .big { font-size: 44px; margin-bottom: 8px; }
.banner { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-top: 12px; font-size: 15px; }
.banner.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.banner .btn { margin-left: auto; flex: none; }
.past .card { opacity: .72; }
.skeleton { height: 150px; border-radius: var(--radius); background: linear-gradient(90deg, var(--card), var(--chip), var(--card)); background-size: 200% 100%; animation: sk 1.2s infinite; margin-bottom: 12px; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- Sheets ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20; animation: fade .2s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 88vh; overflow: auto;
  background: var(--bg); border-radius: 22px 22px 0 0; padding: 8px 18px calc(var(--safe-bottom) + 18px);
  animation: up .25s cubic-bezier(.2,.8,.2,1); max-width: 640px; margin: 0 auto;
}
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 14px; }
.sheet h2 { font-size: 22px; margin-bottom: 12px; }
.group { background: var(--card); border-radius: 14px; margin: 14px 0; overflow: hidden; border: 1px solid var(--line); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 14px; border-bottom: 1px solid var(--line); width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; text-decoration: none; color: var(--ink); }
.row:last-child { border-bottom: 0; }
.row p { margin: 2px 0 0; }
.row.link span { color: var(--muted); font-size: 20px; }
.steps { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 14px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; font-size: 16px; }
.step-n { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 700; font-size: 15px; }
.share { vertical-align: -4px; color: #0A84FF; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 22px); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 999px; font-size: 15px; font-weight: 600;
  z-index: 30; box-shadow: 0 6px 24px rgba(0,0,0,.2); max-width: calc(100% - 32px); text-align: center;
}
