:root {
  --bg: #0a0a10;
  --bg-mesh-1: #241a4a;
  --bg-mesh-2: #3a1740;
  --surface: #131319;
  --surface-raised: #17171f;
  --surface-muted: #0f0f15;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f4f4fa;
  --text-muted: #a3a3b8;
  --text-faint: #6c6c84;
  --accent-1: #8169ff;
  --accent-2: #c75fe6;
  --accent: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  --accent-solid: #8f7bff;
  --accent-hover: #9a89ff;
  --accent-soft: rgba(129, 105, 255, 0.16);
  --accent-contrast: #ffffff;
  --radius-sm: 9px;
  --radius-md: 13px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.38);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
  --glow-accent: 0 0 0 1px rgba(129, 105, 255, 0.35), 0 8px 24px rgba(129, 105, 255, 0.28);
  --green: #3ddc97; --green-soft: rgba(61, 220, 151, 0.14);
  --amber: #f5b64c; --amber-soft: rgba(245, 182, 76, 0.14);
  --red: #f3685f; --red-soft: rgba(243, 104, 95, 0.14);
  --blue: #6ea8ff; --blue-soft: rgba(110, 168, 255, 0.14);
  --purple: #c48bff; --purple-soft: rgba(196, 139, 255, 0.16);
  --gray-soft: rgba(255, 255, 255, 0.06);
  --sidebar-w: 256px;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: 'Plus Jakarta Sans', 'Inter', -apple-system, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f5fb;
    --bg-mesh-1: #e4defc;
    --bg-mesh-2: #fbe3f5;
    --surface: #ffffff;
    --surface-raised: #ffffff;
    --surface-muted: #fbfbfe;
    --border: #e7e7f2;
    --border-strong: #d7d7ea;
    --text: #15151f;
    --text-muted: #65657e;
    --text-faint: #9898ac;
    --accent-1: #6e52f5;
    --accent-2: #b24be0;
    --accent-solid: #6e52f5;
    --accent-hover: #5c3dec;
    --accent-soft: #ece8fe;
    --accent-contrast: #ffffff;
    --shadow-sm: 0 1px 2px rgba(20, 20, 43, 0.05);
    --shadow-md: 0 10px 28px rgba(20, 20, 43, 0.09);
    --shadow-lg: 0 24px 60px rgba(20, 20, 43, 0.16);
    --glow-accent: 0 0 0 1px rgba(110, 82, 245, 0.22), 0 8px 20px rgba(110, 82, 245, 0.18);
    --green: #19975a; --green-soft: #e3f8ee;
    --amber: #ad7416; --amber-soft: #fdf1dc;
    --red: #cf3b3b; --red-soft: #fce9e9;
    --blue: #2a63e0; --blue-soft: #e8eefd;
    --purple: #8140c9; --purple-soft: #f2e8fc;
    --gray-soft: #f0f0f7;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app { min-height: 100%; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; position: relative; }
.shell::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(900px 500px at 8% -8%, color-mix(in srgb, var(--bg-mesh-1) 32%, transparent), transparent 60%),
    radial-gradient(700px 480px at 96% 8%, color-mix(in srgb, var(--bg-mesh-2) 26%, transparent), transparent 60%);
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 22px 15px;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 2;
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 24px;
}
.brand-mark {
  width: 32px; height: 32px; border-radius: 10px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 800; font-size: 14px; font-family: var(--font-display);
  box-shadow: var(--glow-accent);
}
.brand-name { font-weight: 700; font-size: 15.5px; letter-spacing: -0.02em; font-family: var(--font-display); }
.brand-sub { font-size: 11px; color: var(--text-faint); margin-top: -1px; }

.clinic-switch {
  margin: 2px 2px 20px;
  padding: 12px 13px;
  border-radius: var(--radius-md);
  background: var(--gray-soft);
  border: 1px solid var(--border);
  font-size: 12.5px;
}
.clinic-switch .label { color: var(--text-faint); font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 4px; font-weight: 650; }
.clinic-switch .name { font-weight: 650; font-size: 13.5px; }
.clinic-switch button {
  margin-top: 10px; width: 100%; font-size: 11.5px; padding: 7px 8px;
}

.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-weight: 550; font-size: 13.5px;
  cursor: pointer; user-select: none; transition: background 0.16s ease, color 0.16s ease, transform 0.12s ease;
  text-decoration: none; position: relative;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.8; transition: opacity 0.16s; }
.nav-item:hover { background: var(--gray-soft); color: var(--text); transform: translateX(1px); }
.nav-item:hover svg { opacity: 1; }
.nav-item.active {
  background: var(--accent-soft); color: var(--accent-solid);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent-solid) 30%, transparent);
}
.nav-item.active svg { opacity: 1; }
.nav-badge {
  margin-left: auto; font-size: 10.5px; font-weight: 750;
  background: linear-gradient(135deg, var(--red), #ff8f7f); color: white; border-radius: 999px;
  padding: 1.5px 6.5px; min-width: 16px; text-align: center;
  box-shadow: 0 2px 8px rgba(243, 104, 95, 0.4);
}

.sidebar-footer { font-size: 11px; color: var(--text-faint); padding: 11px 8px 0; border-top: 1px solid var(--border); margin-top: 12px; display: flex; align-items: center; gap: 6px; }
.sidebar-footer .dot { width: 6px; height: 6px; border-radius: 999px; background: var(--green); box-shadow: 0 0 8px var(--green); flex-shrink: 0; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; z-index: 1; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 32px; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 70%, transparent); position: sticky; top: 0; z-index: 5;
  backdrop-filter: blur(14px);
}
.topbar h1 { font-size: 19px; margin: 0; font-weight: 700; letter-spacing: -0.02em; font-family: var(--font-display); }
.topbar .sub { font-size: 12.5px; color: var(--text-faint); margin-top: 3px; }

.content { padding: 28px 32px 64px; max-width: 1180px; width: 100%; margin: 0 auto; animation: rise 0.32s cubic-bezier(.2,.8,.2,1); }

@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- onboarding ---------- */
.onboard {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(700px 440px at 15% 10%, color-mix(in srgb, var(--bg-mesh-1) 42%, transparent), transparent 60%),
    radial-gradient(640px 420px at 88% 85%, color-mix(in srgb, var(--bg-mesh-2) 36%, transparent), transparent 60%),
    var(--bg);
  padding: 24px;
}
.onboard-card {
  width: 100%; max-width: 430px; background: color-mix(in srgb, var(--surface) 88%, transparent); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 40px 34px;
  backdrop-filter: blur(20px); animation: rise 0.4s cubic-bezier(.2,.8,.2,1);
}
.onboard-card .brand-mark { width: 46px; height: 46px; font-size: 20px; border-radius: 14px; margin-bottom: 20px; }
.onboard-card h2 { margin: 0 0 7px; font-size: 23px; letter-spacing: -0.02em; font-family: var(--font-display); font-weight: 700; }
.onboard-card p.lede { color: var(--text-muted); margin: 0 0 26px; font-size: 13.5px; line-height: 1.55; }

/* ---------- cards / grid ---------- */
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 920px) { .grid.cols-4 { grid-template-columns: repeat(2, 1fr); } }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: 20px; transition: border-color 0.18s, box-shadow 0.18s, transform 0.18s;
}
.card.pad-lg { padding: 26px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-title { font-size: 14.5px; font-weight: 700; letter-spacing: -0.01em; font-family: var(--font-display); }
.card-sub { font-size: 12px; color: var(--text-faint); margin-top: 3px; }

.stat-card { position: relative; overflow: hidden; }
.stat-card:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.stat-card .stat-label { font-size: 11.5px; color: var(--text-faint); font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; }
.stat-card .stat-value { font-size: 32px; font-weight: 750; letter-spacing: -0.03em; margin-top: 9px; font-family: var(--font-display); }
.stat-card .stat-foot { font-size: 12px; color: var(--text-muted); margin-top: 7px; }
.stat-icon {
  width: 36px; height: 36px; border-radius: 11px; display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
}
.stat-icon svg { width: 18px; height: 18px; }
.stat-spark { margin-top: 12px; display: flex; align-items: flex-end; gap: 3px; height: 26px; }
.stat-spark .bar { flex: 1; border-radius: 3px 3px 1px 1px; background: var(--accent); opacity: 0.85; min-height: 3px; transition: opacity 0.15s; }
.stat-card:hover .stat-spark .bar { opacity: 1; }

/* ---------- buttons ---------- */
button {
  font-family: var(--font-body); font-size: 13px; font-weight: 600; cursor: pointer;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  padding: 9px 15px; transition: background 0.14s, border-color 0.14s, transform 0.1s, box-shadow 0.18s, opacity 0.14s;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; white-space: nowrap;
}
button svg { width: 15px; height: 15px; flex-shrink: 0; }
button:active { transform: translateY(1px) scale(0.99); }
.btn-primary { background: var(--accent); color: var(--accent-contrast); box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.btn-primary:hover { box-shadow: var(--glow-accent); filter: brightness(1.04); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn-secondary { background: var(--surface-raised); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--gray-soft); border-color: var(--border-strong); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: transparent; padding: 7px 10px; }
.btn-ghost:hover { background: var(--gray-soft); color: var(--text); }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-danger:hover { filter: brightness(1.08); }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-block { width: 100%; }

/* ---------- forms ---------- */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
input, select {
  width: 100%; font-family: var(--font-body); font-size: 13.5px; padding: 10px 12px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface-muted); color: var(--text); outline: none;
  transition: border-color 0.14s, box-shadow 0.14s;
}
input::placeholder { color: var(--text-faint); }
input:focus, select:focus { border-color: var(--accent-solid); box-shadow: 0 0 0 3.5px var(--accent-soft); }
.field { margin-bottom: 15px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: 11.5px; color: var(--text-faint); margin-top: 6px; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-faint); font-weight: 700; padding: 0 13px 11px; border-bottom: 1px solid var(--border);
}
td { padding: 13px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.12s; position: relative; }
tbody tr:hover { background: var(--gray-soft); }
.cell-name { font-weight: 600; }
.cell-muted { color: var(--text-faint); font-size: 12.5px; }

/* ---------- badges / pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 650;
  padding: 3.5px 10px; border-radius: 999px; text-transform: capitalize; white-space: nowrap;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
}
.pill-dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; box-shadow: 0 0 5px currentColor; }
.pill.scheduled { background: var(--blue-soft); color: var(--blue); }
.pill.nudge_sent { background: var(--amber-soft); color: var(--amber); }
.pill.escalated { background: var(--red-soft); color: var(--red); }
.pill.snoozed { background: var(--purple-soft); color: var(--purple); }
.pill.booked { background: var(--green-soft); color: var(--green); }
.pill.completed { background: var(--gray-soft); color: var(--text-muted); }
.pill.opted_out { background: var(--gray-soft); color: var(--text-faint); }
.pill.pending_date { background: var(--amber-soft); color: var(--amber); }
.pill.marketing { background: var(--purple-soft); color: var(--purple); }
.pill.utility { background: var(--blue-soft); color: var(--blue); }

/* ---------- empty state ---------- */
.empty { text-align: center; padding: 56px 20px; color: var(--text-faint); }
.empty .empty-icon {
  width: 52px; height: 52px; border-radius: 16px; margin: 0 auto 14px; display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-solid);
}
.empty .empty-icon svg { width: 24px; height: 24px; }
.empty .msg { font-size: 13px; }

/* ---------- modal ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(5, 5, 10, 0.55); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
  animation: overlay-in 0.16s ease-out;
}
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 448px; background: var(--surface-raised); border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); padding: 28px;
  animation: modal-in 0.2s cubic-bezier(.2,.8,.2,1);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal h3 { margin: 0 0 5px; font-size: 17px; letter-spacing: -0.01em; font-family: var(--font-display); font-weight: 700; }
.modal p.lede { color: var(--text-muted); font-size: 12.5px; margin: 0 0 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }

/* ---------- toast ---------- */
.toast-stack { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  background: var(--surface-raised); color: var(--text); padding: 12px 17px; border-radius: var(--radius-md);
  font-size: 12.5px; font-weight: 600; box-shadow: var(--shadow-lg); animation: toast-in 0.2s cubic-bezier(.2,.8,.2,1);
  display: flex; align-items: center; gap: 9px; border: 1px solid var(--border-strong);
}
.toast.error { background: linear-gradient(135deg, var(--red), #ff8f7f); color: white; border-color: transparent; }
.toast.success { background: linear-gradient(135deg, var(--green), #58e6ad); color: #06221a; border-color: transparent; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* ---------- misc ---------- */
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.section-title { font-size: 12.5px; font-weight: 700; color: var(--text-muted); margin: 28px 0 13px; text-transform: uppercase; letter-spacing: 0.06em; }
.section-title:first-child { margin-top: 0; }
.avatar {
  width: 31px; height: 31px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-solid);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; flex-shrink: 0;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent-solid) 25%, transparent);
}
.spinner {
  width: 15px; height: 15px; border-radius: 999px; border: 2px solid currentColor; border-top-color: transparent;
  animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--gray-soft) 25%, var(--border) 37%, var(--gray-soft) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab { padding: 10px 2px; margin-right: 22px; font-size: 13px; font-weight: 620; color: var(--text-faint); cursor: pointer; border-bottom: 2px solid transparent; transition: color 0.14s, border-color 0.14s; }
.tab:hover { color: var(--text-muted); }
.tab.active { color: var(--text); border-color: var(--accent-solid); }

.bar-track { height: 6px; border-radius: 999px; background: var(--gray-soft); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--accent); }

::selection { background: var(--accent-soft); color: var(--text); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }
