/* ============================================================
   Voice Agent CRM — design system
   Dark is the DEFAULT theme; light is an opt-in override that is
   persisted in localStorage. Every colour comes from these vars so a
   theme is a single attribute flip on <html>.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --accent-1: #2DD4BF;
  --accent-2: #0EA5E9;
  --accent-grad: linear-gradient(135deg, var(--accent-1), var(--accent-2));

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --ease: 200ms cubic-bezier(.4, 0, .2, 1);

  --ok: #2DD4BF;
  --info: #60A5FA;
  --danger: #FB7185;
  --warn: #FBBF24;
  --ok-tint: rgba(45, 212, 191, .12);
  --info-tint: rgba(96, 165, 250, .14);
  --danger-tint: rgba(251, 113, 133, .13);
  --warn-tint: rgba(251, 191, 36, .14);

  --font: 'Outfit', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;

  --sidebar-w: 268px;
  --topbar-h: 77px; /* the sticky filter bar parks directly under the header */
}

/* ── Dark (default) ───────────────────────────────────────────── */
html[data-theme='dark'] {
  --bg: #0B0F14;
  --surface: rgba(255, 255, 255, .03);
  --surface-2: rgba(255, 255, 255, .05);
  --surface-solid: #10161D;
  --border: rgba(255, 255, 255, .08);
  --border-strong: rgba(255, 255, 255, .16);
  --text: #E7ECEF;
  --muted: #8A94A0;
  --input-bg: rgba(255, 255, 255, .04);
  --hover: rgba(255, 255, 255, .06);
  --shimmer: rgba(255, 255, 255, .06);
  --glow-1: rgba(45, 212, 191, .12);
  --glow-2: rgba(14, 165, 233, .13);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .45);
  --shadow: 0 10px 30px -14px rgba(0, 0, 0, .7), 0 2px 8px rgba(0, 0, 0, .35);
  --shadow-lg: 0 30px 70px -26px rgba(0, 0, 0, .85), 0 12px 28px -16px rgba(0, 0, 0, .6);
  --scrim: rgba(4, 7, 10, .62);
  color-scheme: dark;
}

/* ── Light ────────────────────────────────────────────────────── */
html[data-theme='light'] {
  --bg: #F6F8FA;
  --surface: #FFFFFF;
  --surface-2: #FFFFFF;
  --surface-solid: #FFFFFF;
  --border: #E5E9F0;
  --border-strong: #D3DAE6;
  --text: #0F172A;
  --muted: #64748B;
  --input-bg: #F8FAFC;
  --hover: rgba(15, 23, 42, .045);
  --shimmer: rgba(15, 23, 42, .05);
  --glow-1: rgba(45, 212, 191, .22);
  --glow-2: rgba(14, 165, 233, .18);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 10px 26px -16px rgba(15, 23, 42, .28), 0 2px 6px rgba(15, 23, 42, .05);
  --shadow-lg: 0 34px 70px -30px rgba(15, 23, 42, .32), 0 10px 24px -16px rgba(15, 23, 42, .12);
  --scrim: rgba(15, 23, 42, .32);
  color-scheme: light;
}

/* ── Base ─────────────────────────────────────────────────────── */
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-weight: 400;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background var(--ease), color var(--ease);
}

/* Ambient gradient glow behind everything. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(58vw 44vh at 12% -6%, var(--glow-1), transparent 68%),
    radial-gradient(52vw 40vh at 96% 4%, var(--glow-2), transparent 66%);
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.015em; line-height: 1.25; }
h1 { font-size: 24px; }
h2 { font-size: 27px; font-weight: 600; }
h3 { font-size: 17px; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
::selection { background: rgba(45, 212, 191, .3); }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.eyebrow {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.mono { font-family: var(--mono); font-size: 12.5px; }
.row { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }
.hidden { display: none !important; }

:focus-visible {
  outline: 2px solid var(--accent-1);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ── Cards ────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color var(--ease), box-shadow var(--ease), transform var(--ease),
    background var(--ease);
}

/* Glassmorphism: only meaningful on the dark theme, harmless on light. */
.card.glass {
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  backdrop-filter: blur(18px) saturate(150%);
}

.card-pad { padding: 22px; }

.card-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.card-head h3 { flex: 1; min-width: 140px; }
.card-body { padding: 22px; }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: transform var(--ease), background var(--ease), border-color var(--ease),
    box-shadow var(--ease), opacity var(--ease), color var(--ease);
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 17px; height: 17px; flex: none; }

.btn.primary {
  background: var(--accent-grad);
  color: #04151d;
  font-weight: 600;
  box-shadow: 0 10px 24px -12px rgba(14, 165, 233, .85), inset 0 1px 0 rgba(255, 255, 255, .28);
}
.btn.primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 16px 34px -12px rgba(14, 165, 233, .95), inset 0 1px 0 rgba(255, 255, 255, .34);
}

.btn.ghost {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}
.btn.ghost:hover:not(:disabled) { background: var(--hover); border-color: var(--border-strong); }

.btn.danger { border-color: rgba(251, 113, 133, .4); color: var(--danger); background: transparent; }
.btn.danger:hover:not(:disabled) { background: var(--danger-tint); }

.btn.ok { border-color: rgba(45, 212, 191, .4); color: var(--ok); }
.btn.ok:hover:not(:disabled) { background: var(--ok-tint); }

.btn.small { padding: 7px 11px; font-size: 12.5px; border-radius: 10px; gap: 6px; }
.btn.small svg { width: 14px; height: 14px; }
.btn.block { width: 100%; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease), transform var(--ease);
}
.icon-btn:hover { background: var(--hover); border-color: var(--border-strong); }
.icon-btn svg { width: 18px; height: 18px; }

/* ── Forms ────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: .02em;
}
.input, .select, textarea.input {
  width: 100%;
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 14.5px;
  transition: border-color var(--ease), box-shadow var(--ease), background var(--ease);
  min-width: 0;
}
.input::placeholder { color: var(--muted); opacity: .8; }
.input:focus, .select:focus, textarea.input:focus {
  outline: none;
  border-color: rgba(45, 212, 191, .55);
  box-shadow: 0 0 0 4px rgba(45, 212, 191, .12);
}
.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238A94A0' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
}
.form-grid { display: grid; gap: 16px; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 620px) { .form-grid.two { grid-template-columns: 1fr; } }

.form-error {
  color: var(--danger);
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 7px;
}

/* ── Pills ────────────────────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .01em;
  white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.pill.confirmed { color: var(--ok); border-color: rgba(45, 212, 191, .35); background: var(--ok-tint); }
.pill.confirmed .dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(45, 212, 191, .18); }
.pill.completed { color: var(--info); border-color: rgba(96, 165, 250, .38); background: var(--info-tint); }
.pill.completed .dot { background: var(--info); box-shadow: 0 0 0 3px rgba(96, 165, 250, .18); }
.pill.cancelled { color: var(--danger); border-color: rgba(251, 113, 133, .36); background: var(--danger-tint); }
.pill.cancelled .dot { background: var(--danger); box-shadow: 0 0 0 3px rgba(251, 113, 133, .18); }
.pill.neutral { color: var(--muted); }
.pill.neutral .dot { background: var(--muted); }
.pill.warn { color: var(--warn); border-color: rgba(251, 191, 36, .38); background: var(--warn-tint); }
.pill.warn .dot { background: var(--warn); }

/* ── Layout: shell ────────────────────────────────────────────── */
.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 22px 16px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  backdrop-filter: blur(22px) saturate(150%);
  z-index: 30;
  transition: transform var(--ease);
}

.side-head { display: flex; align-items: center; gap: 12px; padding: 2px 6px 18px; }
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: var(--accent-grad);
  color: #04151d;
  box-shadow: 0 12px 26px -14px rgba(14, 165, 233, .9), inset 0 1px 0 rgba(255, 255, 255, .3);
  flex: none;
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-mark.small { width: 36px; height: 36px; border-radius: 11px; }
.brand-mark.small svg { width: 18px; height: 18px; }

.side-clinic { display: flex; flex-direction: column; overflow: hidden; }
.side-clinic strong {
  font-size: 15.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-clinic span { font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 14.5px;
  font-weight: 500;
  transition: color var(--ease), background var(--ease), transform var(--ease);
}
.nav-item svg { width: 19px; height: 19px; flex: none; }
.nav-item:hover { color: var(--text); background: var(--hover); }
.nav-item.active {
  color: var(--text);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border), 0 6px 18px -14px rgba(14, 165, 233, .9);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 22px;
  border-radius: 0 3px 3px 0;
  background: var(--accent-grad);
  box-shadow: 0 0 14px 1px rgba(45, 212, 191, .75);
}
.nav-item.active svg { color: var(--accent-1); }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 14px; border-top: 1px solid var(--border); }
.side-note { font-size: 11.5px; color: var(--muted); padding: 0 6px; word-break: break-all; }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 30px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  backdrop-filter: blur(18px) saturate(150%);
}
@supports not (background: color-mix(in srgb, red, blue)) {
  .topbar { background: var(--bg); }
}
.page-title { font-size: 20px; font-weight: 600; flex: 1; min-width: 0; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn.ghost { background: transparent; }

.hamburger { display: none; }

.content { padding: 26px 30px 34px; display: flex; flex-direction: column; gap: 22px; flex: 1; }
.stack { display: flex; flex-direction: column; gap: 18px; }

.app-footer {
  padding: 18px 30px 24px;
  text-align: center;
  font-size: 12px;
  letter-spacing: .02em;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 25;
  background: var(--scrim);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--ease);
}
.scrim.show { opacity: 1; pointer-events: auto; }

@media (max-width: 900px) {
  :root { --topbar-h: 69px; }
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, 300px);
    transform: translateX(-102%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .hamburger { display: inline-grid; }
  .topbar { padding: 14px 16px; }
  .content { padding: 18px 16px 48px; }
  .nav-item.active::before { left: -16px; }
}

/* ── Login ────────────────────────────────────────────────────── */
.login-wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 18px;
}
.login-wrap::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(currentColor 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: .12;
  color: var(--muted);
  mask-image: radial-gradient(70% 60% at 50% 45%, #000 20%, transparent 78%);
  -webkit-mask-image: radial-gradient(70% 60% at 50% 45%, #000 20%, transparent 78%);
}
.theme-corner { position: fixed; top: 20px; right: 20px; z-index: 40; }

.login-card {
  width: 100%;
  max-width: 412px;
  padding: 34px 30px 30px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.login-brand { display: flex; align-items: center; gap: 14px; }
.login-brand h1 { font-size: 20px; }
.login-brand p { font-size: 13.5px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-foot {
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

@keyframes shake {
  10%, 90% { transform: translateX(-3px); }
  20%, 80% { transform: translateX(5px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}
.shake { animation: shake 520ms cubic-bezier(.36, .07, .19, .97); }

/* ── Overview ─────────────────────────────────────────────────── */
.hello {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 26px 26px;
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.hello-text { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; }
.hello h2 { font-size: 25px; }
.hello .grad {
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hello-art {
  width: 118px;
  height: 118px;
  border-radius: 30px;
  flex: none;
  display: grid;
  place-items: center;
  background: var(--accent-grad);
  color: #04151d;
  box-shadow: 0 26px 60px -26px rgba(14, 165, 233, .95), inset 0 1px 0 rgba(255, 255, 255, .3);
}
.hello-art svg { width: 54px; height: 54px; }
@media (max-width: 700px) { .hello-art { display: none; } .hello h2 { font-size: 21px; } }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
@media (max-width: 1080px) { .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .stats-grid { grid-template-columns: 1fr; } }

.stat-card {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 18px;
}
.stat-card:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  flex: none;
  color: #04151d;
  background: var(--accent-grad);
  box-shadow: 0 12px 26px -16px rgba(14, 165, 233, .95);
}
.stat-icon svg { width: 21px; height: 21px; }
.stat-icon.blue { background: linear-gradient(135deg, #60A5FA, #6366F1); color: #06121f; }
.stat-icon.amber { background: linear-gradient(135deg, #FBBF24, #FB923C); color: #201202; }
.stat-icon.violet { background: linear-gradient(135deg, #A78BFA, #22D3EE); color: #0a0f1f; }
.stat-meta { display: flex; flex-direction: column; min-width: 0; }
.stat-value { font-size: 27px; font-weight: 600; line-height: 1.1; letter-spacing: -.02em; }
.stat-label { font-size: 12.5px; color: var(--muted); }
.stat-sub { font-size: 11.5px; color: var(--muted); opacity: .85; }

/* ── Lists / tables ───────────────────────────────────────────── */
.list { display: flex; flex-direction: column; }
.list-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, .8fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  transition: background var(--ease);
}
.list-row:first-child { border-top: none; }
.list-row:hover { background: var(--hover); }
.list-row .who { display: flex; flex-direction: column; min-width: 0; }
.list-row .who strong { font-weight: 500; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .who span { font-size: 12.5px; color: var(--muted); }
.list-row .when { display: flex; flex-direction: column; }
.list-row .when strong { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.list-row .when span { font-size: 11.5px; color: var(--muted); }
.list-row .actions { display: flex; gap: 7px; justify-content: flex-end; }
.row-avatar {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; font-weight: 600;
  color: var(--muted); flex: none;
}
.list-row .name-cell { display: flex; align-items: center; gap: 11px; min-width: 0; }

@media (max-width: 1180px) {
  .list-row { grid-template-columns: 88px minmax(0, 1.4fr) minmax(0, 1fr) auto auto; }
  .list-row .cell-phone { display: none; }
}
@media (max-width: 820px) {
  .list-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: 'time status' 'who who' 'doc actions';
    row-gap: 8px;
    padding: 15px 16px;
  }
  .list-row .when { grid-area: time; flex-direction: row; gap: 8px; align-items: baseline; }
  .list-row .name-cell { grid-area: who; }
  .list-row .cell-doctor { grid-area: doc; }
  .list-row .actions { grid-area: actions; }
  .list-row > .pill { grid-area: status; }
}

/* ── Schedule ─────────────────────────────────────────────────── */
.date-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  flex-wrap: wrap;
}
.date-bar .input[type='date'] { max-width: 190px; }
.doctor-day { position: relative; }
.doctor-day .card-head { gap: 12px; }
.day-meta { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 150px; }
.day-meta h3 { font-size: 16.5px; }
.day-meta p { font-size: 12.5px; color: var(--muted); }
.slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 9px;
  padding: 20px 22px;
}
.slot {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 11px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  text-align: left;
  transition: transform var(--ease), border-color var(--ease), box-shadow var(--ease);
}
.slot .t { font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.slot .s { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot.free { border-color: rgba(45, 212, 191, .32); background: var(--ok-tint); }
.slot.free .s { color: var(--ok); }
.slot.booked { border-color: rgba(251, 113, 133, .45); background: var(--danger-tint); }
.slot.booked .s { color: var(--danger); }
.slot.booked .s svg { width: 12px; height: 12px; flex: none; }
.slot { position: relative; }

.popover {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  min-width: 170px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 13px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface-solid);
  box-shadow: var(--shadow-lg);
  z-index: 40;
  text-align: left;
  pointer-events: none;
}
.popover[hidden] { display: none; }
.popover strong { font-size: 14px; font-weight: 600; }
.pop-row { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); }
.pop-row svg { width: 13px; height: 13px; flex: none; }

.legend {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 0 4px;
  font-size: 13px;
  color: var(--muted);
}
.legend-item { display: inline-flex; align-items: center; gap: 7px; }
.legend-sep { opacity: .4; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; }
.legend-dot.free { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-tint); }
.legend-dot.booked { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-tint); }
.legend-dot.leave { background: #3B4450; box-shadow: 0 0 0 3px rgba(138, 148, 160, .16); }

.leave-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 22px;
  border-top: 1px solid var(--border);
  background: var(--hover);
  color: var(--muted);
  font-size: 14.5px;
}
.leave-banner svg { width: 18px; height: 18px; flex: none; }
.leave-banner .leave-title { color: var(--text); font-weight: 600; }
.leave-banner .leave-reason::before { content: '\00b7 '; opacity: .6; }
.slot.past { opacity: .46; }
.slot:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }

/* ── Doctors ──────────────────────────────────────────────────── */
.doctors-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 16px; }
.doctor-card { display: flex; flex-direction: column; }
.doctor-card:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.doctor-top { display: flex; align-items: center; gap: 13px; padding: 20px 20px 16px; }
.doctor-avatar {
  width: 48px; height: 48px; border-radius: 15px; display: grid; place-items: center;
  background: var(--accent-grad); color: #04151d; font-weight: 600; font-size: 17px; flex: none;
  box-shadow: 0 12px 26px -16px rgba(14, 165, 233, .95);
}
.doctor-top .meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.doctor-top .meta strong { font-size: 16px; font-weight: 600; }
.doctor-top .meta span { font-size: 12.5px; color: var(--muted); }
.doctor-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
  padding: 0 20px 18px;
}
.fact { display: flex; flex-direction: column; gap: 2px; }
.fact span { font-size: 11.5px; color: var(--muted); }
.fact strong { font-size: 14px; font-weight: 500; font-variant-numeric: tabular-nums; }
.doctor-foot {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

/* Status switch */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  transition: color var(--ease), background var(--ease), border-color var(--ease);
}
.toggle:hover { background: var(--hover); border-color: var(--border-strong); }
.toggle-track {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--border-strong);
  transition: background var(--ease);
  flex: none;
}
.toggle-track i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .38);
  transition: transform var(--ease);
}
.toggle-track.on { background: var(--accent-grad); }
.toggle-track.on i { transform: translateX(16px); }
.toggle[aria-pressed='true'] .toggle-label { color: var(--ok); }

/* Leaves section inside a doctor card */
.leaves-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--border);
}
.leaves-head { display: flex; align-items: center; gap: 10px; }
.leaves-title {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 1;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
}
.leaves-title svg { width: 15px; height: 15px; }
.leaves-count {
  font-style: normal;
  min-width: 20px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text);
  text-align: center;
}
.leaves-head button svg { transition: transform var(--ease); }
.leaves-head button[aria-expanded='true'] svg { transform: rotate(180deg); }
.leaves-list { display: flex; flex-direction: column; gap: 8px; }
.leave-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.leave-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.leave-text strong { font-size: 13.5px; font-weight: 600; }
.leave-text span {
  font-size: 12.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.leave-del { width: 30px; height: 30px; border-radius: 9px; }
.leave-del:hover { color: var(--danger); border-color: rgba(251, 113, 133, .4); }
.leave-form { display: grid; grid-template-columns: auto 1fr auto; gap: 9px; }
@media (max-width: 560px) { .leave-form { grid-template-columns: 1fr; } }

/* ── Settings ─────────────────────────────────────────────────── */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; align-items: start; }
.kv { display: flex; flex-direction: column; gap: 3px; padding: 11px 0; border-bottom: 1px dashed var(--border); }
.kv:last-child { border-bottom: none; padding-bottom: 0; }
.kv span { font-size: 11.5px; color: var(--muted); letter-spacing: .03em; text-transform: uppercase; }
.kv strong { font-size: 14.5px; font-weight: 500; word-break: break-word; }

.theme-picker { display: flex; gap: 10px; }
.theme-opt {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: border-color var(--ease), background var(--ease), transform var(--ease);
}
.theme-opt:hover { background: var(--hover); }
.theme-opt[aria-pressed='true'] {
  border-color: rgba(45, 212, 191, .5);
  background: var(--ok-tint);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, .1);
}
.theme-opt svg { width: 18px; height: 18px; }

.status-line { display: flex; align-items: center; gap: 9px; font-size: 13.5px; }

/* ── Toasts ───────────────────────────────────────────────────── */
.toasts {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(92vw, 350px);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 15px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  font-weight: 500;
  opacity: 0;
  transform: translateX(18px) scale(.98);
  transition: opacity var(--ease), transform var(--ease);
  pointer-events: auto;
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}
.toast.in { opacity: 1; transform: none; }
.toast svg { width: 17px; height: 17px; flex: none; margin-top: 1px; }
.toast.success { border-color: rgba(45, 212, 191, .38); }
.toast.success svg { color: var(--ok); }
.toast.error { border-color: rgba(251, 113, 133, .42); }
.toast.error svg { color: var(--danger); }
.toast.info svg { color: var(--accent-2); }

/* ── Skeletons ────────────────────────────────────────────────── */
@keyframes shimmer { 100% { transform: translateX(100%); } }
.sk {
  position: relative;
  overflow: hidden;
  background: var(--shimmer);
  border-radius: 10px;
}
.sk::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, var(--hover), transparent);
  animation: shimmer 1.5s infinite;
}
.sk-line { height: 13px; }
.sk-line.sm { height: 10px; width: 55%; }
.sk-title { height: 20px; width: 45%; }
.sk-stat { height: 82px; border-radius: var(--radius); }
.sk-row { height: 62px; border-radius: 12px; }
.sk-block { height: 150px; border-radius: var(--radius); }
.sk-stack { display: flex; flex-direction: column; gap: 12px; }

/* ── Empty states ─────────────────────────────────────────────── */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 52px 24px;
  text-align: center;
}
.empty-icon {
  width: 62px;
  height: 62px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  margin-bottom: 4px;
}
.empty-icon svg { width: 27px; height: 27px; }
.empty strong { font-size: 16px; font-weight: 600; }
.empty p { font-size: 13.5px; color: var(--muted); max-width: 340px; }

/* ── Modal ────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--scrim);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: fade-in 180ms ease;
}
@keyframes fade-in { from { opacity: 0; } }
.modal {
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface-solid);
  box-shadow: var(--shadow-lg);
  animation: modal-in 220ms cubic-bezier(.2, .9, .3, 1.1);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.modal-head, .modal-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-foot { border-bottom: none; border-top: 1px solid var(--border); justify-content: flex-end; }
.modal-body { padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.modal-head h3 { flex: 1; }

/* Sticky filter shell — parks directly under the header while the table scrolls. */
.filters-shell {
  position: sticky;
  top: var(--topbar-h);
  z-index: 12;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-solid);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  backdrop-filter: blur(18px) saturate(150%);
  box-shadow: var(--shadow);
}
@supports (background: color-mix(in srgb, red, blue)) {
  .filters-shell { background: color-mix(in srgb, var(--surface-solid) 92%, transparent); }
}
.filters-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 20px 0;
}
.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 14px;
  padding: 14px 20px 20px;
}
.filters .field > span { text-transform: uppercase; letter-spacing: .08em; font-size: 11px; }

/* Date preset pills */
.presets { display: flex; gap: 8px; flex-wrap: wrap; }
.preset {
  padding: 8px 15px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--ease), background var(--ease), border-color var(--ease),
    box-shadow var(--ease), transform var(--ease);
}
.preset:hover { color: var(--text); background: var(--hover); border-color: var(--border-strong); }
.preset.active {
  color: #04151d;
  font-weight: 600;
  border-color: transparent;
  background: var(--accent-grad);
  box-shadow: 0 10px 22px -12px rgba(14, 165, 233, .9), inset 0 1px 0 rgba(255, 255, 255, .28);
}
.range-value {
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  background: var(--input-bg);
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Data table */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  min-width: 940px;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr { transition: background var(--ease); }
.data-table tbody tr:hover { background: var(--hover); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tr.is-cancelled { opacity: .5; }
.data-table tr.is-cancelled .cust { text-decoration: line-through; }
.data-table .num { font-variant-numeric: tabular-nums; }
.data-table .nowrap { white-space: nowrap; }
.data-table .cust { font-weight: 500; }
.data-table .right, .data-table td.actions { text-align: right; }
.data-table .row-actions { display: flex; gap: 7px; justify-content: flex-end; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
