:root {
  --bg: #f6f7fb;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-solid: #ffffff;
  --border: rgba(15, 23, 42, 0.08);
  --text: #0f172a;
  --muted: #64748b;
  --primary: #6366f1;
  --primary-2: #a855f7;
  --primary-soft: rgba(99, 102, 241, 0.12);
  --success: #10b981;
  --wa: #22c55e;
  --danger: #ef4444;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 20px 60px rgba(15, 23, 42, 0.18);
  --radius: 18px;
  --grad: linear-gradient(135deg, var(--primary), var(--primary-2));
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0b0b14;
  --surface: rgba(24, 24, 38, 0.72);
  --surface-solid: #161624;
  --border: rgba(255, 255, 255, 0.08);
  --text: #eef0ff;
  --muted: #9aa0b8;
  --primary-soft: rgba(129, 140, 248, 0.16);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
[hidden] { display: none !important; }

/* Background glow blobs */
.bg-blobs { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg-blobs span { position: absolute; border-radius: 50%; filter: blur(80px); opacity: .35; }
.bg-blobs span:nth-child(1) { width: 380px; height: 380px; background: #818cf8; top: -120px; left: -100px; }
.bg-blobs span:nth-child(2) { width: 320px; height: 320px; background: #c084fc; top: 30%; right: -140px; }
.bg-blobs span:nth-child(3) { width: 280px; height: 280px; background: #38bdf8; bottom: -120px; left: 20%; opacity: .2; }
:root[data-theme="dark"] .bg-blobs span { opacity: .22; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { border-radius: 10px; box-shadow: 0 4px 14px rgba(99, 102, 241, .35); }
.brand h1 { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -.02em; }
.brand p { margin: 0; font-size: 12px; color: var(--muted); }
.top-actions { display: flex; gap: 6px; position: relative; }

.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  transition: transform .15s, background .2s;
}
.icon-btn:active { transform: scale(.94); }
.icon-btn.small { width: 34px; height: 34px; border-radius: 10px; }
.icon-btn.small svg { width: 18px; height: 18px; }
#menuBtn svg circle { fill: currentColor; stroke: none; }

.menu {
  position: absolute; right: 0; top: 48px; min-width: 220px;
  background: var(--surface-solid); border: 1px solid var(--border);
  border-radius: 14px; padding: 6px; box-shadow: var(--shadow-lg);
  animation: pop .16s ease-out;
}
.menu button {
  display: block; width: 100%; text-align: left; padding: 11px 12px;
  border: 0; background: none; border-radius: 10px; font-size: 14px;
}
.menu button:hover { background: var(--primary-soft); }

/* Layout */
.container { max-width: 960px; margin: 0 auto; padding: 16px 16px calc(110px + var(--safe-b)); }

/* Install card */
.install-card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; margin-bottom: 16px; border-radius: var(--radius);
  background: var(--grad); color: #fff;
  box-shadow: 0 12px 30px rgba(99, 102, 241, .35);
  animation: slideDown .35s ease-out;
}
.install-icon img { border-radius: 12px; background: rgba(255,255,255,.2); padding: 4px; display: block; }
.install-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.install-text strong { font-size: 15px; }
.install-text span { font-size: 12.5px; opacity: .9; }
.install-actions { display: flex; align-items: center; gap: 6px; }
.install-card .btn-primary { background: #fff; color: var(--primary); box-shadow: none; }
.install-card .icon-btn { background: rgba(255,255,255,.18); border-color: transparent; color: #fff; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat {
  padding: 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.stat-label { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-value { font-size: 26px; font-weight: 800; letter-spacing: -.03em; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* Toolbar */
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; }
.search {
  flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0;
  padding: 0 14px; height: 48px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  color: var(--muted); transition: border-color .2s, box-shadow .2s;
}
.search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--text); height: 100%; }
.toolbar select {
  height: 48px; padding: 0 12px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  outline: 0;
}

/* List */
.list { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 700px) { .list { grid-template-columns: 1fr 1fr; } }

.card {
  padding: 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  display: flex; flex-direction: column; gap: 12px; min-width: 0;
  animation: fadeUp .28s ease-out both;
  transition: transform .2s, box-shadow .2s;
}
@media (hover: hover) { .card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); } }
.card-head { display: flex; gap: 12px; align-items: center; min-width: 0; }
.avatar {
  width: 46px; height: 46px; border-radius: 14px; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 800; font-size: 16px; color: #fff;
}
.card-title { min-width: 0; flex: 1; }
.card-title h3 { margin: 0; font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.biz {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 3px; max-width: 100%;
  font-size: 12px; font-weight: 600; color: var(--primary);
  background: var(--primary-soft); padding: 2px 8px; border-radius: 999px;
}
.biz span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-menu { display: flex; gap: 4px; }
.card-menu .icon-btn { background: transparent; border-color: transparent; color: var(--muted); }
.card-menu .icon-btn:hover { background: var(--primary-soft); color: var(--primary); }
.card-menu .icon-btn.del:hover { background: rgba(239,68,68,.12); color: var(--danger); }

.info { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.info-row { display: flex; gap: 8px; align-items: flex-start; color: var(--muted); min-width: 0; }
.info-row svg { width: 16px; height: 16px; margin-top: 2px; }
.info-row span { color: var(--text); word-break: break-word; }

.card-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.act {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; border-radius: 12px; text-decoration: none;
  font-size: 13px; font-weight: 600; border: 1px solid var(--border);
  background: var(--surface-solid); color: var(--text); transition: transform .12s;
}
.act:active { transform: scale(.96); }
.act svg { width: 17px; height: 17px; }
.act.call { color: var(--primary); }
.act.wa { color: var(--wa); }
.act.map { color: #f59e0b; }
.act.disabled { opacity: .4; pointer-events: none; }

mark { background: rgba(250, 204, 21, .45); color: inherit; border-radius: 3px; padding: 0 1px; }

/* Empty */
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty-art { font-size: 54px; margin-bottom: 8px; }
.empty h2 { color: var(--text); margin: 0 0 6px; font-size: 19px; }
.empty p { margin: 0 0 18px; }

/* Buttons */
.btn {
  height: 46px; padding: 0 20px; border-radius: 14px; border: 1px solid transparent;
  font-weight: 700; font-size: 15px; transition: transform .12s, filter .2s;
}
.btn:active { transform: scale(.97); }
.btn-sm { height: 36px; padding: 0 14px; font-size: 13px; border-radius: 11px; }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 8px 20px rgba(99, 102, 241, .35); }
.btn-primary:hover { filter: brightness(1.07); }
.btn-ghost { background: var(--primary-soft); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }

/* FAB */
.fab {
  position: fixed; right: 18px; bottom: calc(20px + var(--safe-b)); z-index: 15;
  display: flex; align-items: center; gap: 8px;
  height: 56px; padding: 0 22px 0 18px; border: 0; border-radius: 18px;
  background: var(--grad); color: #fff; font-weight: 700; font-size: 15px;
  box-shadow: 0 14px 34px rgba(99, 102, 241, .5);
  transition: transform .15s;
}
.fab svg { width: 24px; height: 24px; stroke-width: 2.6; }
.fab:active { transform: scale(.94); }

/* Dialogs */
dialog { border: 0; padding: 0; color: var(--text); background: transparent; max-width: 100vw; }
dialog::backdrop { background: rgba(8, 8, 20, .5); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }

.sheet > :is(form, .sheet-body), .modal .confirm {
  background: var(--surface-solid); box-shadow: var(--shadow-lg);
}
.sheet {
  width: 100%; margin: auto auto 0; max-height: 92dvh;
}
.sheet > :is(form, .sheet-body) {
  border-radius: 24px 24px 0 0; padding: 8px 18px calc(18px + var(--safe-b));
  animation: sheetUp .28s cubic-bezier(.2,.9,.3,1.1);
  max-height: 92dvh; overflow-y: auto;
}
.sheet-handle { width: 40px; height: 5px; border-radius: 9px; background: var(--border); margin: 4px auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-head h2 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
@media (min-width: 640px) {
  .sheet { width: 520px; margin: auto; }
  .sheet > :is(form, .sheet-body) { border-radius: 24px; padding: 18px 24px 24px; animation: pop .22s ease-out; }
  .sheet-handle { display: none; }
}

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field label em { color: var(--danger); font-style: normal; }
.field input, .field textarea {
  width: 100%; padding: 13px 14px; border-radius: 13px; font-size: 16px; /* 16px stops iOS zoom */
  background: var(--bg); border: 1.5px solid var(--border); outline: 0; resize: vertical;
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.phone-wrap { display: flex; gap: 8px; }
.phone-wrap input { flex: 1; min-width: 0; }
.quick {
  width: 50px; flex-shrink: 0; display: grid; place-items: center; border-radius: 13px;
  color: #fff; text-decoration: none; transition: transform .12s, opacity .2s;
}
.quick:active { transform: scale(.94); }
.quick.call { background: var(--grad); box-shadow: 0 6px 16px rgba(99,102,241,.35); }
.quick.wa { background: var(--wa); box-shadow: 0 6px 16px rgba(34,197,94,.35); }
.quick.disabled { opacity: .3; pointer-events: none; box-shadow: none; }
a.info-row { text-decoration: none; }
a.info-row span { color: var(--primary); font-weight: 600; }
.field .err { display: none; color: var(--danger); font-size: 12px; }
.field.invalid input { border-color: var(--danger); }
.field.invalid .err { display: block; }

.sheet-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; margin-top: 6px; }

.modal { margin: auto; width: min(380px, calc(100vw - 32px)); }
.confirm { border-radius: 22px; padding: 22px; text-align: center; animation: pop .2s ease-out; }
.confirm-icon { font-size: 40px; }
.confirm h3 { margin: 8px 0 4px; font-size: 18px; }
.confirm p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.confirm .sheet-actions { grid-template-columns: 1fr 1fr; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(92px + var(--safe-b)); z-index: 50;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #111827; color: #fff; padding: 11px 18px; border-radius: 12px;
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); white-space: nowrap;
  transition: opacity .25s, transform .25s; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Animations */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

@media (max-width: 420px) {
  .stat { padding: 12px; }
  .stat-value { font-size: 22px; }
  .toolbar select { width: 104px; }
  .fab span { display: none; }
  .fab { width: 60px; padding: 0; justify-content: center; border-radius: 20px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- Tabs ---------- */
.tabs {
  position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  padding: 4px; margin-bottom: 14px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.tab {
  position: relative; z-index: 1; height: 42px; border: 0; background: none; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 700; font-size: 14px; color: var(--muted); transition: color .2s;
}
.tab svg { width: 18px; height: 18px; }
.tab.active { color: #fff; }
.tab-pill {
  position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 6px);
  border-radius: 12px; background: var(--grad); box-shadow: 0 6px 16px rgba(99,102,241,.35);
  transition: transform .28s cubic-bezier(.2,.9,.3,1.1);
}
.tabs[data-active="reminders"] .tab-pill { transform: translateX(calc(100% + 4px)); }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 800;
  display: inline-grid; place-items: center;
}

.stat-btn { text-align: left; font: inherit; color: inherit; cursor: pointer; }
.stat-btn.alert { border-color: rgba(239,68,68,.35); }
.stat-btn.alert .stat-value { background: linear-gradient(135deg, #ef4444, #f97316); -webkit-background-clip: text; background-clip: text; }

/* ---------- Reminder chip on client card ---------- */
.rem-chip {
  display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0;
  padding: 9px 12px; border-radius: 12px; font-size: 13px; text-align: left;
  background: var(--primary-soft); color: var(--primary); border: 1px solid transparent;
}
.rem-chip svg { width: 16px; height: 16px; }
.rem-chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rem-chip.add { background: transparent; border: 1.5px dashed var(--border); color: var(--muted); font-weight: 600; }
.rem-chip.add:hover { border-color: var(--primary); color: var(--primary); }
.rem-chip.overdue { background: rgba(239,68,68,.12); color: var(--danger); }

/* ---------- Reminders view ---------- */
.rem-group { margin-bottom: 20px; }
.group-title {
  display: flex; align-items: center; gap: 8px; margin: 0 4px 10px;
  font-size: 13px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
}
.group-title span {
  font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--primary-soft); color: var(--primary);
}
.group-title.bad { color: var(--danger); }
.group-title.bad span { background: rgba(239,68,68,.12); color: var(--danger); }
.group-title.ok { color: var(--success); }
.group-title.ok span { background: rgba(16,185,129,.12); color: var(--success); }

.rem-card {
  padding: 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  display: flex; flex-direction: column; gap: 12px; min-width: 0;
  border-left: 4px solid var(--primary);
  animation: fadeUp .28s ease-out both;
}
.rem-card.overdue { border-left-color: var(--danger); }
.rem-card.done { border-left-color: var(--success); opacity: .7; }
.rem-card.done h3 { text-decoration: line-through; }
.avatar.sm { width: 40px; height: 40px; border-radius: 12px; font-size: 14px; }
.rem-meta { display: flex; align-items: center; gap: 8px; margin-top: 3px; min-width: 0; font-size: 12px; }
.rem-meta .muted { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.type-badge { flex-shrink: 0; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.type-badge.call { background: var(--primary-soft); color: var(--primary); }
.type-badge.meeting { background: rgba(245,158,11,.14); color: #d97706; }
.rem-when { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.rem-when svg { width: 16px; height: 16px; color: var(--muted); }
.pill { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); }
.pill.bad { background: rgba(239,68,68,.12); color: var(--danger); }
.pill.ok { background: rgba(16,185,129,.12); color: var(--success); }
.rem-note {
  margin: 0; padding: 10px 12px; border-radius: 12px; font-size: 14px;
  background: var(--bg); color: var(--text); white-space: pre-wrap; word-break: break-word;
}
.act.done { color: var(--success); }
button.act { font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }

.notify-card {
  display: flex; align-items: center; gap: 12px; padding: 14px; margin-bottom: 16px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.notify-icon { font-size: 28px; }
.notify-card .install-text span { color: var(--muted); opacity: 1; }

/* ---------- Reminder form ---------- */
.field select {
  width: 100%; padding: 13px 14px; border-radius: 13px; font-size: 16px;
  background: var(--bg); border: 1.5px solid var(--border); outline: 0;
}
.field select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.field.invalid select, .field.invalid .dt-row input { border-color: var(--danger); }
.rem-for {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 14px;
  border-radius: 14px; background: var(--primary-soft);
}
.rem-for div:last-child { display: flex; flex-direction: column; min-width: 0; }
.rem-for span { font-size: 12px; color: var(--muted); }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: flex; align-items: center; justify-content: center; height: 46px; border-radius: 13px;
  border: 1.5px solid var(--border); background: var(--bg); font-weight: 700; font-size: 14px; color: var(--text);
  cursor: pointer; transition: all .15s;
}
.seg input:checked + span { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.seg input:focus-visible + span { box-shadow: 0 0 0 4px var(--primary-soft); }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button {
  flex-shrink: 0; height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1.5px solid var(--border); background: var(--bg); font-size: 13px; font-weight: 700; color: var(--text);
}
.chips button.on { background: var(--grad); color: #fff; border-color: transparent; }
.dt-row { display: grid; grid-template-columns: 1.4fr 1fr; gap: 8px; margin-top: 8px; }
.dt-row input { min-width: 0; }
:root[data-theme="dark"] .toast { background: #f1f2ff; color: #0f172a; }

/* ---------- Auth / boot ---------- */
.login { display: none; }
body.signed-out .login {
  display: grid; place-items: center; min-height: 100dvh; padding: 24px 16px;
}
body.signed-out .topbar, body.signed-out main, body.signed-out .fab,
body.booting .topbar, body.booting main, body.booting .fab { display: none; }
.login-card {
  width: min(400px, 100%); padding: 28px 22px; border-radius: 24px; text-align: center;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  animation: pop .3s ease-out;
}
.login-card img { border-radius: 18px; box-shadow: 0 10px 26px rgba(99,102,241,.4); }
.login-card h1 { margin: 14px 0 2px; font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.login-card > p { margin: 0 0 20px; color: var(--muted); }
.login-card .field { text-align: left; }
.login-card .btn { width: 100%; margin-top: 4px; }
.login-err { margin: 0 0 12px; color: var(--danger); font-size: 13px; font-weight: 600; text-align: left; }
.btn:disabled { opacity: .6; pointer-events: none; }
.hint { color: var(--muted); font-size: 12px; }

/* ---------- Menu extras ---------- */
.menu-user { padding: 10px 12px 8px; display: flex; flex-direction: column; }
.menu-user b { font-size: 14px; }
.menu-user span { font-size: 12px; color: var(--muted); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 6px; }
.menu button.danger { color: var(--danger); }

/* ---------- Users dialog ---------- */
.user-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.user-row {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px;
  background: var(--bg); border: 1px solid var(--border);
}
.user-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.user-info b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info span { font-size: 12px; color: var(--muted); }
.sub-head { margin: 0 0 12px; font-size: 15px; font-weight: 800; }
.by { font-size: 12px; color: var(--muted); }

/* ---------- Client card: open details + last note ---------- */
.card-open { display: flex; gap: 12px; align-items: center; flex: 1; min-width: 0; cursor: pointer; border-radius: 12px; outline: 0; }
.card-open:focus-visible { box-shadow: 0 0 0 3px var(--primary-soft); }
.last-note {
  display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; text-align: left;
  padding: 8px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg);
  font-size: 13px; color: var(--muted);
}
.last-note b { flex-shrink: 0; color: var(--text); font-weight: 700; }
.last-note .ln-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Details sheet ---------- */
.sheet.tall > .sheet-body { min-height: min(80dvh, 720px); }
.dh { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.avatar.lg { width: 56px; height: 56px; border-radius: 16px; font-size: 19px; }
.dh-info { flex: 1; min-width: 0; }
.dh-info h3 { margin: 0; font-size: 19px; font-weight: 800; letter-spacing: -.01em; }
#detailHead .info { margin-bottom: 12px; }
.card-actions.four { grid-template-columns: repeat(4, 1fr); margin-bottom: 18px; }
.card-actions.four .act { flex-direction: column; gap: 2px; height: 56px; font-size: 12px; }
.act.rem { color: var(--primary-2); }

.up-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.up-row { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border-radius: 14px; background: var(--primary-soft); }
.up-row.overdue { background: rgba(239,68,68,.12); }
.up-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; border: 0; background: none; text-align: left; padding: 4px 0; }
.up-text { min-width: 0; display: flex; flex-direction: column; font-size: 13px; }
.up-text b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-text small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-row.overdue .up-text b { color: var(--danger); }
.icon-btn.ok { color: var(--success); background: var(--surface-solid); }

.composer {
  padding: 12px; border-radius: 16px; margin-bottom: 18px;
  background: var(--bg); border: 1.5px solid var(--border); transition: border-color .2s, box-shadow .2s;
}
.composer:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.composer textarea {
  width: 100%; border: 0; outline: 0; background: none; resize: none; font-size: 16px;
  padding: 8px 2px; min-height: 56px;
}
.kind-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.kind-chips::-webkit-scrollbar { display: none; }
.kind-chips label { position: relative; flex-shrink: 0; }
.kind-chips input { position: absolute; opacity: 0; pointer-events: none; }
.kind-chips span {
  display: block; padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; cursor: pointer;
  background: var(--surface-solid); border: 1px solid var(--border); color: var(--muted); transition: all .15s;
}
.kind-chips input:checked + span { background: var(--grad); color: #fff; border-color: transparent; }
.kind-chips input:focus-visible + span { box-shadow: 0 0 0 3px var(--primary-soft); }
.composer-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Timeline */
#timeline { padding-bottom: 8px; }
.tl-day { margin: 14px 0 8px; font-size: 12px; font-weight: 800; color: var(--muted); }
.tl-item { position: relative; display: flex; gap: 12px; padding-bottom: 14px; }
.tl-item::before {
  content: ''; position: absolute; left: 17px; top: 38px; bottom: 0; width: 2px; background: var(--border);
}
.tl-dot {
  width: 36px; height: 36px; flex-shrink: 0; border-radius: 12px; display: grid; place-items: center;
  font-size: 16px; background: var(--primary-soft);
}
.tl-dot.k-call { background: rgba(99,102,241,.14); }
.tl-dot.k-meeting { background: rgba(245,158,11,.16); }
.tl-dot.k-whatsapp { background: rgba(34,197,94,.16); }
.tl-dot.k-done { background: rgba(16,185,129,.16); }
.tl-dot.k-added { background: rgba(168,85,247,.14); }
.tl-body { flex: 1; min-width: 0; padding-top: 2px; }
.tl-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl-top b { font-size: 14px; }
.tl-meta { font-size: 12px; color: var(--muted); }
.tl-tools { margin-left: auto; display: flex; gap: 2px; }
.icon-btn.tiny { width: 28px; height: 28px; border-radius: 8px; border-color: transparent; background: transparent; color: var(--muted); }
.icon-btn.tiny svg { width: 15px; height: 15px; }
.icon-btn.tiny.del:hover { color: var(--danger); }
.tl-body p {
  margin: 6px 0 0; padding: 10px 12px; border-radius: 12px; font-size: 14px;
  background: var(--surface-solid); border: 1px solid var(--border); white-space: pre-wrap; word-break: break-word;
}
.opt { font-weight: 500; color: var(--muted); }
.kind-chips { flex-wrap: wrap; overflow: visible; }

/* =========================================================
   Polish pass — cleaner cards & controls on small phones
   ========================================================= */
.card { gap: 10px; padding: 14px; }
.card-head.card-open { cursor: pointer; border-radius: 14px; margin: -4px; padding: 4px; }
.card-head.card-open:active { background: var(--primary-soft); }
.chev { margin-left: auto; color: var(--muted); opacity: .6; display: grid; place-items: center; }
.chev svg { width: 18px; height: 18px; }
.card-title h3 { font-size: 16px; line-height: 1.25; }
.info { gap: 4px; }
.info-row { font-size: 14px; line-height: 1.35; }
a.info-row.addr span { color: var(--text); font-weight: 400; }
a.info-row.addr:active span { color: var(--primary); }

.last-note {
  padding: 0; border: 0; background: none; gap: 6px; font-size: 13px;
}
.last-note .ln-kind { flex-shrink: 0; }
.last-note .ln-text { flex: 1; min-width: 0; color: var(--muted); }
.last-note .ln-ago { flex-shrink: 0; font-size: 12px; color: var(--muted); opacity: .8; }

.rem-chip { padding: 8px 12px; font-size: 13px; }
.card-actions { gap: 8px; }
.act { height: 42px; border-radius: 12px; }
.act.rem { color: var(--primary-2); }

/* Reminder cards */
.rem-card { padding: 14px; gap: 10px; border-left-width: 3px; }
.rem-meta .muted { min-width: 0; }
.by { font-size: 12px; color: var(--muted); margin-top: -4px; }
.rem-when { font-size: 14px; }

/* Choice chips → tidy grid (no hidden overflow) */
.chips.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; overflow: visible; }
.chips.grid3 button { width: 100%; padding: 0 6px; height: 40px; border-radius: 12px; }

/* Note type: 4 equal segments */
.kind-chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.kind-chips label { min-width: 0; }
.kind-chips span {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 2px; border-radius: 12px; font-size: 11.5px; text-align: center;
}
.kind-chips span i { font-style: normal; font-size: 17px; line-height: 1; }

/* Reminder edit extras */
.rem-extra { display: flex; justify-content: space-between; gap: 8px; margin: -2px 0 12px; }
.link-btn { border: 0; background: none; padding: 8px 0; font-size: 14px; font-weight: 700; color: var(--primary); }
.link-btn.danger { color: var(--danger); }

/* Quick call buttons: neutral until a full number is typed */
.quick.disabled { background: var(--border); color: var(--muted); opacity: 1; }

/* Details header buttons */
.dh .icon-btn + .icon-btn { margin-left: -4px; }
.dh .icon-btn.del:hover { color: var(--danger); }

/* Small phones */
@media (max-width: 380px) {
  .container { padding-left: 12px; padding-right: 12px; }
  .stats { gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat-label { font-size: 11.5px; }
  .tab { font-size: 13.5px; gap: 6px; }
  .act { font-size: 12.5px; gap: 4px; }
  .act svg { width: 16px; height: 16px; }
  .sheet > :is(form, .sheet-body) { padding-left: 14px; padding-right: 14px; }
  .card-actions.four .act { font-size: 11.5px; }
}
/* Keep title + close visible while scrolling the details sheet */
.sheet.tall .sheet-head {
  position: sticky; top: -8px; z-index: 3; margin: -8px -18px 8px; padding: 12px 18px 10px;
  background: var(--surface-solid); border-bottom: 1px solid transparent; transition: border-color .2s;
}
@media (max-width: 380px) { .sheet.tall .sheet-head { margin-left: -14px; margin-right: -14px; padding-left: 14px; padding-right: 14px; } }
@media (min-width: 640px) { .sheet.tall .sheet-head { top: -18px; margin: -18px -24px 8px; padding: 18px 24px 10px; } }
