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

:root {
  --bg:         #F6F5F1;
  --surface:    #FFFFFF;
  --surface-2:  #F1F0EC;
  --border:     #EAE8E3;
  --border-mid: #D7D5CF;
  --text-1:     #19181A;
  --text-2:     #65645F;
  --text-3:     #A6A49E;
  --accent:     #2563EB;
  --accent-weak:#F0F5FF;
  --accent-bg:  #EAF1FE;
  --accent-text:#1A4FB8;
  --green:      #18794E;
  --green-bg:   #EDFAF3;
  --red:        #C03535;
  --red-bg:     #FEF3F3;
  --amber:      #B45309;
  --amber-bg:   #FFF8EC;
  --r-sm:  7px;
  --r-md:  11px;
  --r-lg:  15px;
  --r-xl:  20px;
  --font:  'DM Sans', sans-serif;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ring: 0 0 0 3px rgba(37,99,235,0.20);
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px;
  --shadow-sm: 0 1px 2px rgba(20,18,16,0.05), 0 1px 1px rgba(20,18,16,0.03);
  --shadow-md: 0 2px 4px rgba(20,18,16,0.04), 0 6px 16px rgba(20,18,16,0.07);
  --shadow-lg: 0 4px 8px rgba(20,18,16,0.05), 0 16px 36px rgba(20,18,16,0.10);
  --scroll-shadow: rgba(20,18,16,0.16);   /* 7.14 — edge cue on scrollable tables */
}

html, body { height: 100%; background: var(--bg); font-family: var(--font); color: var(--text-1); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
#app { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }

/* ── FOCUS RING (accessibility) ── */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; box-shadow: var(--ring);
}

/* ── VIEWS ── */
.view { display: none; flex-direction: column; flex: 1; overflow: hidden; }
.view.active { display: flex; animation: view-in 140ms ease; }
@keyframes view-in { from { opacity: 0; } to { opacity: 1; } }

/* ── APP LOADING SCREEN ── */
#view-loading { justify-content: center; align-items: center; }
.app-loading { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.app-loading-spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border-mid);
  border-top-color: var(--text-1);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ════════════════════════════
   LOGIN
════════════════════════════ */
#view-login,
#view-register,
#view-forgot,
#view-reset,
#view-email-verification {
  justify-content: center; align-items: center;
  padding: 24px; min-height: 100dvh;
}
.login-wrap { width: 100%; max-width: 360px; }

.login-logo { display: flex; align-items: center; gap: 9px; margin-bottom: 32px; }
.logo-mark {
  width: 30px; height: 30px; background: var(--text-1); border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
}
.logo-mark svg { width: 14px; height: 14px; fill: none; stroke: white; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.logo-name { font-size: 14px; font-weight: 500; letter-spacing: -0.01em; }

.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: 34px 30px;
  box-shadow: var(--shadow-lg);
}
.login-card h1 { font-size: 19px; font-weight: 500; letter-spacing: -0.02em; margin-bottom: 5px; }
.login-card .sub { font-size: 13px; color: var(--text-2); margin-bottom: 20px; }

.login-tabs { display: flex; gap: 4px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-md); padding: 3px; margin-bottom: 20px; }
.login-tab { flex: 1; padding: 7px; font-size: 13px; font-weight: 500; font-family: var(--font); background: none; border: none; border-radius: calc(var(--r-md) - 2px); cursor: pointer; color: var(--text-2); transition: background 120ms, color 120ms; }
.login-tab.active { background: var(--surface); color: var(--text-1); box-shadow: var(--shadow-sm); }

.login-signup-link { font-size: 13px; color: var(--text-2); text-align: center; margin-top: 14px; margin-bottom: 0; }
.login-signup-link a { color: var(--text-1); font-weight: 500; text-decoration: none; }
.login-signup-link a:hover { text-decoration: underline; }

.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12px; font-weight: 500; color: var(--text-2); margin-bottom: 5px; letter-spacing: 0.01em; }
.field input {
  width: 100%; padding: 10px 13px; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  font-size: 14px; font-family: var(--font); color: var(--text-1);
  outline: none; transition: border-color 150ms, background 150ms;
}
.field input:focus { border-color: var(--accent); background: var(--surface); box-shadow: var(--ring); }
.field input::placeholder { color: var(--text-3); }

.btn-primary {
  width: 100%; margin-top: 6px; padding: 11px 16px;
  background: var(--text-1); color: white;
  border: none; border-radius: var(--r-sm);
  font-size: 14px; font-weight: 500; font-family: var(--font);
  cursor: pointer; transition: opacity 150ms;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary:hover { opacity: 0.88; }
.btn-primary:active { opacity: 0.78; }

.error-msg {
  display: none; margin-top: 12px;
  padding: 10px 12px; background: var(--red-bg); border: 1px solid #FCCACA;
  border-radius: var(--r-sm); font-size: 13px; color: var(--red);
}
.error-msg.show { display: block; }

.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.3); border-top-color: white; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }


/* ════════════════════════════
   SHELL (authenticated)
════════════════════════════ */
#view-shell { flex-direction: row; }

/* SIDEBAR — desktop only */
.sidebar {
  display: none;
  width: 220px; flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
  flex-direction: column;
  padding: 0;
}
@media (min-width: 768px) { .sidebar { display: flex; } }

.sidebar-top {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 9px;
}
.sidebar-top .logo-name { font-size: 13px; }

.sidebar-section-label {
  padding: 18px 16px 6px;
  font-size: 11px; font-weight: 500; color: var(--text-3);
  letter-spacing: 0.06em; text-transform: uppercase;
}
.sidebar-nav { padding: 4px 8px; flex: 1; }
.sidebar-nav a, .sidebar-nav button {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 10px; border-radius: var(--r-sm);
  font-size: 13px; color: var(--text-2); font-family: var(--font);
  background: none; border: none; cursor: pointer; text-decoration: none;
  transition: background 120ms, color 120ms;
}
.sidebar-nav a, .sidebar-nav button { position: relative; transition: background 140ms var(--ease), color 140ms var(--ease); }
.sidebar-nav a:hover, .sidebar-nav button:hover { background: var(--surface-2); color: var(--text-1); }
.sidebar-nav a.active { background: var(--accent-weak); color: var(--accent-text); font-weight: 500; }
.sidebar-nav a.active::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.55; }
.sidebar-nav a:hover .nav-icon { opacity: 0.85; }

.nav-skeleton-wrap { padding: 4px 2px; display: flex; flex-direction: column; gap: 4px; }
.nav-skeleton-item {
  height: 34px; width: 75%; border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: nav-shimmer 1.4s ease infinite;
}
@keyframes nav-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.sidebar-nav a.active .nav-icon { opacity: 1; }

.sidebar-footer {
  padding: 12px 12px 16px;
  border-top: 1px solid var(--border);
}
.user-row {
  display: flex; align-items: center; gap: 9px;
  padding: 8px; border-radius: var(--r-sm); cursor: pointer;
  transition: background 120ms;
}
.user-row:hover { background: var(--surface-2); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 500; color: var(--text-2); flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-company { font-size: 11px; color: var(--text-3); }

/* MAIN AREA */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* TOPBAR — mobile */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
@media (min-width: 768px) { .topbar { display: none; } }
.topbar-logo { display: flex; align-items: center; gap: 8px; }
.topbar-logo .logo-name { font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* ── Notification centre (10.3) ── */
.notif-bell {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0; border-radius: 10px;
  background: transparent; border: 1px solid var(--border); color: var(--text-2);
  cursor: pointer; transition: background .15s ease, color .15s ease;
}
.notif-bell:hover { background: var(--accent-weak, rgba(0,0,0,0.04)); color: var(--text-1); }
.notif-bell .icon { width: 18px; height: 18px; }
.notif-badge {
  position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px;
  padding: 0 4px; border-radius: 999px; background: var(--danger, #ef4444); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 17px; text-align: center;
}
.notif-backdrop { position: fixed; inset: 0; z-index: 1200; background: transparent; }
.notif-panel {
  position: fixed; z-index: 1201; top: 64px; right: 16px;
  width: min(360px, calc(100vw - 32px)); max-height: min(70vh, 520px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md, 12px);
  box-shadow: var(--shadow-lg, 0 12px 32px rgba(0,0,0,0.18));
}
.notif-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 600; color: var(--text-1);
}
.notif-dismiss-all { background: none; border: none; cursor: pointer; font-size: 12px; color: var(--accent); padding: 0; }
.notif-list { padding: 6px; }
.notif-empty { padding: 28px 14px; text-align: center; font-size: 13px; color: var(--text-3); }
.notif-item {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 10px 10px 10px 12px; border-radius: 10px;
  border-left: 3px solid var(--text-3); margin-bottom: 4px;
}
.notif-item.sev-error   { border-left-color: var(--danger, #ef4444); }
.notif-item.sev-warning { border-left-color: var(--warning, #f59e0b); }
.notif-item.sev-info    { border-left-color: var(--accent, #3b82f6); }
.notif-item:hover { background: var(--accent-weak, rgba(0,0,0,0.03)); }
.notif-item-main { flex: 1; min-width: 0; }
.notif-item-title { font-size: 13px; font-weight: 600; color: var(--text-1); }
.notif-item-body { font-size: 12px; color: var(--text-2); margin-top: 2px; line-height: 1.45; }
.notif-item-x { background: none; border: none; cursor: pointer; color: var(--text-3); font-size: 18px; line-height: 1; padding: 0 2px; flex-shrink: 0; }
.notif-item-x:hover { color: var(--text-1); }

/* ── Settings sub-sections (7.5) ── */
.rc-set-section + .rc-set-section { border-top: 1px solid var(--border); margin-top: 20px; padding-top: 18px; }
.rc-set-section-title { font-size: 13px; font-weight: 600; color: var(--text-1); margin-bottom: 4px; }
.rc-set-section-sub { font-size: 12px; color: var(--text-3); margin: 0 0 14px; }

/* ── Mobile: horizontal-scroll data tables + swipe affordance (7.3 / 7.14) ── */
@media (max-width: 767px) {
  .an-table, .rc-clients-table, .mc-leads-table, .analytics-table {
    display: block; overflow-x: auto; -webkit-overflow-scrolling: touch;
    /* 7.14 — CSS-only scroll-shadow swipe hint (Lea Verou technique). The two
       solid `--surface` cover layers scroll WITH the content (background-
       attachment: local) so they mask the shadow at the very start/end; the two
       soft radial shadow layers are fixed to the viewport edges (scroll) so a
       shadow only shows on the side where more content exists. Net effect: a
       right-edge shadow appears when there's more to swipe to, and fades out
       once you reach the end — no JS, updates live as you scroll. */
    background:
      linear-gradient(to right, var(--surface), rgba(0,0,0,0)) 0 0 / 28px 100% no-repeat,
      linear-gradient(to left,  var(--surface), rgba(0,0,0,0)) 100% 0 / 28px 100% no-repeat,
      radial-gradient(farthest-side at 0 50%, var(--scroll-shadow), rgba(0,0,0,0)) 0 0 / 12px 100% no-repeat,
      radial-gradient(farthest-side at 100% 50%, var(--scroll-shadow), rgba(0,0,0,0)) 100% 0 / 12px 100% no-repeat;
    background-attachment: local, local, scroll, scroll;
  }
  /* Keep the scrollbar visible so the horizontal overflow is discoverable. */
  .an-table::-webkit-scrollbar, .rc-clients-table::-webkit-scrollbar,
  .mc-leads-table::-webkit-scrollbar, .analytics-table::-webkit-scrollbar { height: 6px; }
  .an-table::-webkit-scrollbar-thumb, .rc-clients-table::-webkit-scrollbar-thumb,
  .mc-leads-table::-webkit-scrollbar-thumb, .analytics-table::-webkit-scrollbar-thumb {
    background: var(--border); border-radius: 3px;
  }
}

/* ── Touch tooltips (7.4) ── */
.touch-tip {
  position: absolute; z-index: 1300; max-width: 240px;
  padding: 7px 10px; border-radius: 8px;
  background: var(--text-1); color: var(--surface);
  font-size: 12px; line-height: 1.4; box-shadow: var(--shadow-lg, 0 8px 24px rgba(0,0,0,0.2));
  pointer-events: none;
}

/* PAGE HEADER — shown on desktop inside main, above scroll */
.page-header {
  display: none; padding: 22px 28px 0;
  flex-shrink: 0;
}
@media (min-width: 768px) { .page-header { display: block; } }
.page-header h2 { font-size: 18px; font-weight: 500; letter-spacing: -0.02em; }
.page-header p { font-size: 13px; color: var(--text-2); margin-top: 2px; }

/* SCROLL AREA */
.scroll { flex: 1; overflow-y: auto; padding: 16px; }
@media (min-width: 768px) { .scroll { padding: 20px 28px 28px; } }

/* BOTTOM NAV — mobile */
.bottom-nav {
  display: flex; background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0; padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (min-width: 768px) { .bottom-nav { display: none; } }
.bottom-nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 3px; padding: 10px 4px 8px;
  background: none; border: none; cursor: pointer; font-family: var(--font);
  color: var(--text-3); font-size: 10px; font-weight: 500;
  transition: color 150ms;
}
.bottom-nav-item.active { color: var(--text-1); }
.bottom-nav-item svg { width: 20px; height: 20px; }

/* ════════════════════════════
   PAGE SECTIONS
════════════════════════════ */
.section { display: none; }
.section.active { display: block; animation: view-in 120ms ease; }

/* ── HOME ── */
.greeting { margin-bottom: 20px; }
.greeting h3 { font-size: 17px; font-weight: 500; letter-spacing: -0.02em; }
.greeting p { font-size: 13px; color: var(--text-2); margin-top: 2px; }

.metrics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
@media (min-width: 640px) { .metrics-grid { grid-template-columns: repeat(4, 1fr); } }

.metric-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease), transform 140ms var(--ease);
}
.metric-card:hover { border-color: var(--border-mid); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.metric-label { font-size: 11px; color: var(--text-2); font-weight: 500; letter-spacing: 0.02em; margin-bottom: 8px; }
.metric-value { font-size: 24px; font-weight: 300; letter-spacing: -0.03em; line-height: 1; }
.metric-value.accent { color: var(--accent); }
.metric-value.green { color: var(--green); }

.section-title {
  font-size: 12px; font-weight: 500; color: var(--text-2);
  letter-spacing: 0.04em; text-transform: uppercase;
  margin-bottom: 10px;
}

/* ── APPS / SERVICES GRID ── */
.apps-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 20px; }
@media (min-width: 480px) { .apps-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1024px) { .apps-grid { grid-template-columns: repeat(3, 1fr); } }

.app-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 18px;
  cursor: pointer; box-shadow: var(--shadow-sm);
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease), transform 160ms var(--ease);
  text-decoration: none; color: inherit; display: block;
}
.app-card:hover { border-color: var(--border-mid); box-shadow: var(--shadow-md); transform: translateY(-2px); }

.app-card-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }
.app-icon {
  width: 38px; height: 38px; background: var(--accent-weak); border: 1px solid var(--accent-bg);
  border-radius: var(--r-md); display: flex; align-items: center; justify-content: center;
  color: var(--accent);
}
.app-icon svg { width: 19px; height: 19px; }

.status-badge {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 500; padding: 3px 8px;
  border-radius: 20px;
}
.status-badge.live { background: var(--green-bg); color: var(--green); }
.status-badge.live::before { content: ''; display: block; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status-badge.inactive { background: var(--surface-2); color: var(--text-3); }
.status-badge.inactive::before { content: ''; display: block; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.app-card h4 { font-size: 14px; font-weight: 500; letter-spacing: -0.01em; margin-bottom: 3px; }
.app-card p { font-size: 12px; color: var(--text-2); line-height: 1.4; }
.app-card-stat { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-2); }
.app-card-stat strong { color: var(--text-1); font-weight: 500; }

/* ── CONVERSATIONS LIST ── */
.conv-filters {
  display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap;
}
.filter-pill {
  padding: 5px 12px; border-radius: 20px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer;
  color: var(--text-2); font-family: var(--font);
  transition: background 130ms var(--ease), border-color 130ms var(--ease), color 130ms var(--ease);
}
.filter-pill:hover { border-color: var(--border-mid); color: var(--text-1); }
.filter-pill.active { background: var(--text-1); border-color: var(--text-1); color: white; }
.filter-pill.active:hover { color: white; }

.conv-list { display: flex; flex-direction: column; gap: 6px; }
.conv-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 14px 16px;
  cursor: pointer; box-shadow: var(--shadow-sm);
  transition: border-color 130ms var(--ease), box-shadow 130ms var(--ease);
  display: flex; align-items: center; gap: 12px;
}
.conv-item:hover { border-color: var(--border-mid); box-shadow: var(--shadow-md); }
.conv-item.unread { border-left: 3px solid var(--accent); }

.conv-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2);
  border: 1px solid var(--border); display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 500; color: var(--text-2); flex-shrink: 0;
}
.conv-body { flex: 1; min-width: 0; }
.conv-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 2px; }
.conv-name { font-size: 13px; font-weight: 500; }
.conv-time { font-size: 11px; color: var(--text-3); }
.conv-preview { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-meta { display: flex; align-items: center; gap: 6px; margin-top: 5px; flex-wrap: wrap; }
.conv-item.selected { border-color: var(--accent); background: var(--accent-bg); }
.conv-check { width: 18px; height: 18px; border-radius: 5px; border: 2px solid var(--border-mid);
  flex-shrink: 0; display: none; align-items: center; justify-content: center;
  transition: background 100ms, border-color 100ms; }
.conv-list.select-mode .conv-check { display: flex; }
.conv-item.selected .conv-check { background: var(--accent); border-color: var(--accent); }
.conv-item.selected .conv-check::after { content: ''; display: block; width: 10px; height: 6px;
  border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg) translateY(-1px); }
.res-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; display: inline-block; vertical-align: middle; }
.res-dot.resolved { background: #22c55e; }
.res-dot.partially_resolved { background: #f59e0b; }
.res-dot.unresolved { background: #ef4444; }
.topic-pill { font-size: 10px; font-weight: 500; padding: 2px 6px; border-radius: 20px;
  background: var(--surface-2); color: var(--text-2); }
.select-toggle { font-size: 12px; font-weight: 500; color: var(--accent); background: none;
  border: none; cursor: pointer; padding: 4px 8px; font-family: var(--font); margin-left: auto; }
.analyze-bar { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text-1); color: #fff; border-radius: 40px; padding: 10px 12px 10px 20px;
  display: none; align-items: center; gap: 10px; font-size: 13px;
  box-shadow: 0 4px 20px rgba(0,0,0,.3); z-index: 200; white-space: nowrap; }
.analyze-bar.visible { display: flex; }
.analyze-bar-btn { background: #fff; color: var(--text-1); border: none; border-radius: 20px;
  padding: 6px 14px; font-size: 12px; font-weight: 600; cursor: pointer; font-family: var(--font); }
.analyze-bar-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.analyze-bar-cancel { background: none; border: none; color: rgba(255,255,255,.65);
  font-size: 12px; cursor: pointer; padding: 4px; font-family: var(--font); }

.tag {
  font-size: 10px; font-weight: 500; padding: 2px 7px;
  border-radius: 4px; letter-spacing: 0.02em;
}
.tag-blue { background: var(--accent-bg); color: var(--accent-text); }
.tag-green { background: var(--green-bg); color: var(--green); }
.tag-amber { background: var(--amber-bg); color: var(--amber); }
.tag-gray { background: var(--surface-2); color: var(--text-2); }
.feat-chip {
  display: inline-block; font-size: 11px; font-weight: 500;
  padding: 3px 8px; border-radius: 20px;
  background: var(--accent-bg); color: var(--accent-text);
  white-space: nowrap;
}

/* ── VIEWER BADGE ── */
.viewer-badge {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 14px; background: var(--amber-bg);
  border: 1px solid #F6DFA0; border-radius: var(--r-sm);
  font-size: 13px; color: var(--amber); margin-bottom: 6px;
}
.viewer-badge svg { flex-shrink: 0; }

/* ── CONVERSATION DETAIL ── */
#view-conv-detail { background: var(--bg); }
.conv-detail-header {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; background: var(--surface);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
@media (min-width: 768px) { .conv-detail-header { padding: 16px 24px; } }
.back-btn {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  background: none; border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; transition: background 120ms;
}
.back-btn:hover { background: var(--surface-2); }
.back-btn svg { width: 14px; height: 14px; }
.conv-detail-info { flex: 1; min-width: 0; }
.conv-detail-name { font-size: 14px; font-weight: 500; }
.conv-detail-sub { font-size: 12px; color: var(--text-2); }

.handover-toggle {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--surface); font-size: 12px; font-weight: 500;
  cursor: pointer; font-family: var(--font); transition: all 150ms;
  white-space: nowrap;
}
.handover-toggle.human { background: var(--amber-bg); border-color: #F6D860; color: var(--amber); }
.handover-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); transition: background 150ms; }
.handover-toggle.human .handover-dot { background: var(--amber); }

.messages-scroll { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
@media (min-width: 768px) { .messages-scroll { padding: 20px 24px; } }

.msg { display: flex; gap: 10px; max-width: 80%; }
.msg.visitor { align-self: flex-start; }
.msg.bot { align-self: flex-end; flex-direction: row-reverse; }
.msg.agent { align-self: flex-end; flex-direction: row-reverse; }

.msg-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2);
  border: 1px solid var(--border); display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 500; color: var(--text-2); flex-shrink: 0; align-self: flex-end;
}
.msg-bubble {
  padding: 10px 13px; border-radius: 14px; font-size: 14px; line-height: 1.5;
  max-width: 100%;
}
.msg.visitor .msg-bubble { background: var(--surface); border: 1px solid var(--border); color: var(--text-1); border-bottom-left-radius: 4px; }
.msg.bot .msg-bubble { background: var(--surface-2); color: var(--text-1); border-bottom-right-radius: 4px; }
.msg.agent .msg-bubble { background: var(--amber-bg); border: 1px solid #F6D860; color: var(--text-1); border-bottom-right-radius: 4px; }

.msg-meta { font-size: 10px; color: var(--text-3); margin-top: 3px; }
.msg.bot .msg-meta, .msg.agent .msg-meta { text-align: right; }

.reply-bar {
  padding: 12px 16px; background: var(--surface); border-top: 1px solid var(--border);
  flex-shrink: 0;
}
@media (min-width: 768px) { .reply-bar { padding: 14px 24px; } }
.reply-inner { display: flex; gap: 8px; align-items: flex-end; }
.reply-input {
  flex: 1; padding: 10px 13px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r-md); font-size: 14px; font-family: var(--font); color: var(--text-1);
  outline: none; resize: none; transition: border-color 150ms; min-height: 42px; max-height: 120px;
  line-height: 1.45;
}
.reply-input:focus { border-color: var(--border-mid); }
.reply-input::placeholder { color: var(--text-3); }
.reply-input:disabled { opacity: 0.5; cursor: not-allowed; }
.send-btn {
  width: 38px; height: 38px; background: var(--text-1); border: none; border-radius: var(--r-sm);
  cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: opacity 150ms;
}
.send-btn:hover { opacity: 0.82; }
.send-btn svg { width: 16px; height: 16px; }
.reply-ai-note { font-size: 11px; color: var(--text-3); margin-top: 7px; text-align: center; }

/* ── CHATBOTS LIST ── */
.chatbot-list { display: flex; flex-direction: column; gap: 8px; }
.chatbot-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 14px 16px;
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color 130ms var(--ease), box-shadow 130ms var(--ease);
}
.chatbot-item:hover { border-color: var(--border-mid); box-shadow: var(--shadow-md); }
.chatbot-item:hover .chatbot-arrow { transform: translateX(2px); }
.chatbot-arrow { color: var(--text-3); transition: transform 130ms var(--ease); }
.bot-logo {
  position: relative; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; font-weight: 600; color: white; letter-spacing: 0;
}
.bot-logo img { width: 100%; height: 100%; object-fit: cover; }
.bot-status {
  position: absolute; bottom: -1px; right: -1px;
  width: 9px; height: 9px; border-radius: 50%;
  border: 2px solid var(--surface);
}
.bot-status.live { background: var(--green); }
.bot-status.off  { background: var(--border-mid); }
.chatbot-body { flex: 1; min-width: 0; }
.chatbot-name { font-size: 14px; font-weight: 500; }
.chatbot-stats { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.chatbot-arrow { color: var(--text-3); }
.conv-avatar { overflow: hidden; padding: 0; background: none; border: none; }

/* ── ACCOUNT ── */
.account-section { margin-bottom: 20px; }
.account-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden;
}
.account-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border); gap: 12px;
}
.account-row:last-child { border-bottom: none; }
.account-row-label { font-size: 13px; color: var(--text-2); flex-shrink: 0; }
.account-row-value { font-size: 13px; font-weight: 500; text-align: right; }
.account-row-value.muted { color: var(--text-2); font-weight: 400; }

.btn-secondary {
  width: 100%; padding: 11px 16px;
  background: var(--surface); color: var(--text-1);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  font-size: 14px; font-weight: 500; font-family: var(--font);
  cursor: pointer; transition: background 120ms;
}
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger {
  width: 100%; padding: 11px 16px;
  background: var(--surface); color: var(--red);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  font-size: 14px; font-weight: 500; font-family: var(--font);
  cursor: pointer; transition: background 120ms;
}
.btn-danger:hover { background: var(--red-bg); border-color: #FCCACA; }

/* ── LANGUAGE SWITCHER ── */
.lang-btn {
  padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer;
  color: var(--text-2); font-family: var(--font); transition: all 120ms;
}
.lang-btn.active { background: var(--text-1); border-color: var(--text-1); color: white; }

/* ── EMPTY / LOADING ── */
.empty-state {
  text-align: center; padding: 48px 24px;
  color: var(--text-2); font-size: 14px; line-height: 1.6;
}
.empty-state p { color: var(--text-3); font-size: 13px; margin-top: 4px; }

/* 7.9 — Illustrated empty state. Opt-in via the emptyStateHtml() helper:
   a soft line-art SVG (strokes use currentColor at low opacity so it adapts
   to light/dark automatically), a title, optional body text, optional actions. */
.empty-illus-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 40px 24px; text-align: center; }
.empty-illus {
  width: 64px; height: 64px; margin-bottom: 10px;
  color: var(--text-3); opacity: 0.7;
}
.empty-illus svg { width: 100%; height: 100%; display: block; }
.empty-illus-title { font-size: 14px; font-weight: 500; color: var(--text-1); }
.empty-illus-text  { font-size: 13px; color: var(--text-2); max-width: 440px; margin: 2px auto 0; line-height: 1.55; }
.empty-illus-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
@media (prefers-reduced-motion: no-preference) {
  .empty-illus-wrap { animation: empty-fade 240ms var(--ease); }
}
@keyframes empty-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; background: var(--surface-2); } .spinner { animation: none; } .view.active { animation: none; } .section.active { animation: none; } .app-loading-spinner { animation: none; } }

/* Stale-while-revalidate: thin indeterminate progress bar shown at the top of
   an analytics panel while it refetches, with its old content kept visible. */
.an-refreshing-bar {
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  overflow: hidden; z-index: 5; pointer-events: none; border-radius: 2px;
}
.an-refreshing-bar::before {
  content: ''; position: absolute; top: 0; height: 100%; width: 35%;
  background: var(--accent); border-radius: 2px;
  animation: an-refreshing-slide 1s ease-in-out infinite;
}
@keyframes an-refreshing-slide { 0% { left: -35%; } 100% { left: 100%; } }
@media (prefers-reduced-motion: reduce) {
  .an-refreshing-bar::before { animation: none; left: 0; width: 100%; opacity: 0.5; }
}
/* Optimistic recall send — targeted row buttons while the SMS is in flight. */
.btn-sm.is-sending { opacity: 0.7; cursor: progress; }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(12px);
  background: var(--text-1); color: white; padding: 10px 16px;
  border-radius: var(--r-md); font-size: 13px; font-weight: 500;
  opacity: 0; transition: opacity 200ms, transform 200ms;
  z-index: 400; white-space: nowrap; pointer-events: none;
}
@media (min-width: 768px) { .toast { bottom: 24px; } }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── ANALYTICS ── */
.analytics-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 20px; }
.analytics-form label { font-size: 12px; font-weight: 500; color: var(--text-2); display: block; margin-bottom: 4px; }
.analytics-form input[type="date"] {
  padding: 9px 11px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); font-size: 13px; font-family: var(--font); color: var(--text-1);
  outline: none; transition: border-color 150ms;
}
.analytics-form input[type="date"]:focus { border-color: var(--border-mid); }
.analytics-report { display: none; }
.analytics-report.visible { display: block; }
.analytics-metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 20px; }
@media (min-width: 640px) { .analytics-metrics { grid-template-columns: repeat(4, 1fr); } }
.analytics-section-title {
  font-size: 12px; font-weight: 500; color: var(--text-2); letter-spacing: 0.04em;
  text-transform: uppercase; margin-bottom: 10px; margin-top: 20px;
}
.analytics-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  overflow: hidden;
}
.analytics-table th {
  padding: 9px 14px; text-align: left; font-size: 11px; font-weight: 500;
  color: var(--text-3); letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.analytics-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.analytics-table tr:last-child td { border-bottom: none; }
.analytics-bar-bg {
  height: 6px; background: var(--surface-2); border-radius: 3px; min-width: 60px; flex: 1;
}
.analytics-bar-fill { height: 100%; border-radius: 3px; background: var(--accent); }
.rec-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 14px 16px; margin-bottom: 8px;
}
.rec-card-top { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.rec-card h4 { font-size: 13px; font-weight: 500; }
.rec-card p { font-size: 12px; color: var(--text-2); line-height: 1.5; }
.priority-pill {
  font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 20px;
  letter-spacing: 0.04em; text-transform: uppercase; flex-shrink: 0;
}
.priority-high   { background: var(--red-bg);   color: var(--red); }
.priority-medium { background: var(--amber-bg); color: var(--amber); }
.priority-low    { background: var(--surface-2); color: var(--text-2); }

/* ── ICON UTIL ── */
.icon { fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ── SIDEBAR GROUP ── */
.sidebar-group-label {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; margin: 6px 0 0;
  font-size: 11px; font-weight: 500; color: var(--text-3);
  letter-spacing: 0.05em; text-transform: uppercase; user-select: none;
}
.sidebar-group-label .nav-icon { opacity: 0.45; }
.sidebar-sub { padding-left: 28px !important; }

/* ── CONV VIEW TOGGLE ── */
.conv-view-toggle {
  display: flex; margin-bottom: 14px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  overflow: hidden; background: var(--surface-2); flex-shrink: 0;
}
.conv-view-btn {
  flex: 1; padding: 7px 10px; font-size: 12px; font-weight: 500;
  border: none; background: none; cursor: pointer; font-family: var(--font);
  color: var(--text-2); transition: all 120ms;
}
.conv-view-btn.active { background: var(--surface); color: var(--text-1); box-shadow: var(--shadow-sm); }

/* ── CHATBOT CONV CARDS (conversations view) ── */
.chatbot-conv-grid { display: flex; flex-direction: column; gap: 8px; }
.chatbot-conv-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 14px 16px;
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  transition: border-color 120ms;
}
.chatbot-conv-card:hover { border-color: var(--border-mid); }

/* scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 2px; }

/* ── CHATBOT DETAIL VIEW ── */
#view-chatbot-detail { background: var(--bg); }
.bot-detail-header {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; background: var(--surface);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
@media (min-width: 768px) { .bot-detail-header { padding: 16px 24px; } }
.bot-detail-info { flex: 1; min-width: 0; }
.bot-detail-name { font-size: 14px; font-weight: 500; }
.bot-detail-sub  { font-size: 12px; color: var(--text-2); margin-top: 1px; }

.bot-tabs {
  display: flex; border-bottom: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0; overflow-x: auto;
}
.bot-tab {
  padding: 11px 18px; font-size: 13px; font-weight: 500;
  border: none; background: none; cursor: pointer; font-family: var(--font);
  color: var(--text-2); border-bottom: 2px solid transparent;
  transition: color 120ms, border-color 120ms; white-space: nowrap;
}
.bot-tab.active { color: var(--text-1); border-bottom-color: var(--text-1); }
.bot-tab-content { flex: 1; overflow-y: auto; padding: 20px 16px; }
@media (min-width: 768px) { .bot-tab-content { padding: 24px 28px; } }
.bot-tab-panel { display: none; }
.bot-tab-panel.active { display: block; }

/* KB sub-tabs */
.kb-tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.kb-tab {
  padding: 5px 13px; border-radius: 20px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer;
  color: var(--text-2); font-family: var(--font); transition: all 120ms;
}
.kb-tab.active { background: var(--text-1); border-color: var(--text-1); color: white; }
.kb-tab-panel { display: none; }
.kb-tab-panel.active { display: block; }

/* Info grid for overview */
.info-grid { display: grid; gap: 6px; margin-bottom: 20px; }
.info-row {
  display: flex; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); overflow: hidden;
}
.info-label {
  padding: 9px 13px; font-size: 12px; color: var(--text-2); font-weight: 500;
  min-width: 140px; border-right: 1px solid var(--border); background: var(--surface-2);
  flex-shrink: 0;
}
.info-value {
  padding: 9px 13px; font-size: 13px; color: var(--text-1); flex: 1;
  word-break: break-word; white-space: pre-wrap;
}

/* KB list items */
.kb-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); margin-bottom: 6px;
}
.kb-item-body { flex: 1; min-width: 0; }
.kb-item-q { font-size: 13px; font-weight: 500; margin-bottom: 2px; word-break: break-word; }
.kb-item-a { font-size: 12px; color: var(--text-2); word-break: break-word; }
.kb-item-meta { font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* Custom function cards */
.fn-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 6px;
  display: flex; align-items: center; gap: 10px;
}
.fn-method {
  font-size: 10px; font-weight: 700; padding: 3px 7px; border-radius: 4px;
  letter-spacing: 0.05em; flex-shrink: 0; background: var(--accent-bg); color: var(--accent-text);
}
.fn-method.POST   { background: var(--green-bg);  color: var(--green);  }
.fn-method.DELETE { background: var(--red-bg);    color: var(--red);    }
.fn-method.PUT, .fn-method.PATCH { background: var(--amber-bg); color: var(--amber); }
.fn-body { flex: 1; min-width: 0; }
.fn-alias { font-size: 13px; font-weight: 500; }
.fn-url   { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Inline add forms */
.add-form {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 14px 16px; margin-bottom: 14px;
}
.add-form .form-title { font-size: 12px; font-weight: 500; color: var(--text-2); margin-bottom: 10px; letter-spacing: 0.02em; }
.add-form textarea, .add-form input[type="text"] {
  width: 100%; padding: 8px 11px; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  font-size: 13px; font-family: var(--font); color: var(--text-1);
  outline: none; resize: vertical; transition: border-color 150ms; margin-bottom: 8px;
}
.add-form textarea:focus, .add-form input[type="text"]:focus { border-color: var(--border-mid); }

.action-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.form-toggle { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

/* Small buttons */
.btn-sm {
  padding: 6px 13px; background: var(--surface-2); color: var(--text-1);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  font-size: 12px; font-weight: 500; cursor: pointer; font-family: var(--font);
  transition: background 120ms; white-space: nowrap;
}
.btn-sm:hover { background: var(--border); }
.btn-sm.primary { background: var(--text-1); color: white; border-color: var(--text-1); }
.btn-sm.primary:hover { opacity: 0.85; }
.btn-sm.danger { background: var(--red-bg); color: var(--red); border-color: #FCCACA; }
.btn-sm.danger:hover { opacity: 0.85; }

/* Sub-accounts */
.subaccount-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 13px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 6px;
}
.subaccount-name  { font-size: 13px; font-weight: 500; }
.subaccount-email { font-size: 12px; color: var(--text-2); margin-top: 1px; }

/* ── SEO GHOST WRITER ── */
.seo-sub-view { display: none; flex-direction: column; gap: 16px; }
.seo-sub-view.active { display: flex; }

.seo-projects-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .seo-projects-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .seo-projects-grid { grid-template-columns: repeat(3, 1fr); } }
.seo-project-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 16px; cursor: pointer; transition: border-color 120ms, box-shadow 120ms;
  display: flex; flex-direction: column; gap: 8px;
}
.seo-project-card:hover { border-color: var(--border-mid); box-shadow: var(--shadow-sm); }
.seo-project-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.seo-project-card h4 { font-size: 14px; font-weight: 500; }
.seo-project-card p { font-size: 12px; color: var(--text-2); line-height: 1.5; }
.seo-project-stats { display: flex; gap: 12px; font-size: 12px; color: var(--text-2); margin-top: 4px; }
.seo-project-stats span strong { color: var(--text-1); font-weight: 500; }
.seo-source-badge {
  font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 20px;
  letter-spacing: 0.03em; text-transform: uppercase; flex-shrink: 0;
}
.seo-source-badge.chatbot { background: var(--accent-bg); color: var(--accent-text); }
.seo-source-badge.url     { background: var(--surface-2); color: var(--text-2); }
.seo-new-card {
  background: var(--surface); border: 1px dashed var(--border-mid); border-radius: var(--r-lg);
  padding: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  gap: 8px; color: var(--text-2); font-size: 14px; transition: all 120ms; min-height: 90px;
}
.seo-new-card:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }

.seo-form { display: flex; flex-direction: column; gap: 14px; max-width: 560px; }
.seo-form label { font-size: 12px; font-weight: 500; color: var(--text-2); display: block; margin-bottom: 4px; }
.seo-form input[type="text"], .seo-form input[type="url"], .seo-form textarea, .seo-form select {
  width: 100%; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); font-size: 14px; font-family: var(--font); color: var(--text-1);
  outline: none; transition: border-color 150ms;
}
.seo-form input:focus, .seo-form textarea:focus, .seo-form select:focus { border-color: var(--border-mid); }
.seo-form textarea { resize: vertical; min-height: 72px; line-height: 1.5; }
.seo-radio-group { display: flex; gap: 8px; }
.seo-radio-btn {
  flex: 1; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-sm);
  cursor: pointer; text-align: center; font-size: 13px; font-weight: 500; color: var(--text-2);
  transition: all 120ms; background: var(--surface); user-select: none;
}
.seo-radio-btn.active { border-color: var(--accent); background: var(--accent-bg); color: var(--accent-text); }
.seo-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.seo-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.seo-tab {
  padding: 9px 14px; font-size: 13px; font-weight: 500; color: var(--text-2);
  border: none; background: none; cursor: pointer; border-bottom: 2px solid transparent;
  font-family: var(--font); transition: color 120ms; margin-bottom: -1px;
}
.seo-tab:hover { color: var(--text-1); }
.seo-tab.active { color: var(--accent-text); border-bottom-color: var(--accent); }

.seo-topics-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 640px) { .seo-topics-grid { grid-template-columns: repeat(2, 1fr); } }
.seo-topic-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 14px 16px; cursor: pointer; transition: border-color 120ms;
  display: flex; flex-direction: column; gap: 5px;
}
.seo-topic-card:hover { border-color: var(--accent); background: var(--accent-bg); }
.seo-topic-card h5 { font-size: 13px; font-weight: 500; }
.seo-topic-card p  { font-size: 12px; color: var(--text-2); line-height: 1.4; }
.seo-topic-meta    { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.seo-pill {
  font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 20px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.seo-pill-blue   { background: var(--accent-bg); color: var(--accent-text); }
.seo-pill-green  { background: var(--green-bg); color: var(--green); }
.seo-pill-amber  { background: var(--amber-bg); color: var(--amber); }
.seo-pill-grey   { background: var(--surface-2); color: var(--text-2); }

.seo-drafts-list { display: flex; flex-direction: column; gap: 8px; }
.seo-draft-row {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 13px 16px; display: flex; align-items: center; gap: 12px; cursor: pointer;
  transition: border-color 120ms;
}
.seo-draft-row:hover { border-color: var(--border-mid); }
.seo-draft-info { flex: 1; min-width: 0; }
.seo-draft-kw   { font-size: 13px; font-weight: 500; }
.seo-draft-meta { font-size: 12px; color: var(--text-2); margin-top: 2px; }

.seo-wizard-steps {
  display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto;
}
.seo-wizard-step {
  flex: 1; min-width: 80px; padding: 10px 8px; text-align: center;
  font-size: 12px; font-weight: 500; color: var(--text-3); border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.seo-wizard-step.done    { color: var(--green); }
.seo-wizard-step.current { color: var(--accent-text); border-bottom-color: var(--accent); }
.seo-wizard-body { display: flex; flex-direction: column; gap: 16px; }

.seo-brief-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 16px; display: flex; flex-direction: column; gap: 10px;
}
.seo-brief-row { display: flex; gap: 12px; flex-wrap: wrap; }
.seo-brief-field { flex: 1; min-width: 140px; }
.seo-brief-field .label { font-size: 11px; font-weight: 500; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }
.seo-brief-field .value { font-size: 13px; color: var(--text-1); margin-top: 2px; }

.seo-md-preview {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 20px 24px; font-size: 14px; line-height: 1.75; max-width: 800px;
  white-space: pre-wrap; font-family: 'DM Sans', sans-serif;
  overflow: auto; max-height: 60vh;
}
.seo-md-raw {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 16px; font-size: 12px; line-height: 1.6; font-family: monospace;
  white-space: pre-wrap; overflow: auto; max-height: 60vh;
}
.seo-content-tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.seo-content-tab {
  padding: 5px 12px; border-radius: var(--r-sm); font-size: 12px; font-weight: 500;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer;
  font-family: var(--font); color: var(--text-2); transition: all 120ms;
}
.seo-content-tab.active { background: var(--text-1); color: white; border-color: var(--text-1); }

.seo-stream-indicator {
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2);
  padding: 10px 0;
}
.seo-stream-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  animation: seo-pulse 1s ease-in-out infinite;
}
@keyframes seo-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.seo-checklist { display: flex; flex-direction: column; gap: 6px; }
.seo-check-item { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.seo-check-icon { width: 18px; height: 18px; flex-shrink: 0; }
.seo-check-pass { color: var(--green); }
.seo-check-fail { color: var(--red); }
.seo-score-bar {
  height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin: 8px 0;
}
.seo-score-fill { height: 100%; border-radius: 4px; transition: width 400ms ease; }
.seo-score-good { background: var(--green); }
.seo-score-mid  { background: var(--amber); }
.seo-score-bad  { background: var(--red); }

.seo-meta-block {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 12px 14px; font-size: 12px; font-family: monospace; line-height: 1.6;
  white-space: pre-wrap; overflow: auto;
}
.seo-meta-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }

.seo-wizard-actions {
  display: flex; align-items: center; gap: 10px; padding-top: 16px;
  border-top: 1px solid var(--border); flex-wrap: wrap;
}
.seo-status-badge {
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.seo-status-brief     { background: var(--surface-2); color: var(--text-2); }
.seo-status-outline   { background: var(--accent-bg); color: var(--accent-text); }
.seo-status-draft     { background: var(--amber-bg); color: var(--amber); }
.seo-status-review    { background: #EEF4FF; color: #1251B8; }
.seo-status-published { background: var(--green-bg); color: var(--green); }

.seo-job-banner {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  font-size: 13px; margin-bottom: 14px;
}
.seo-job-banner.running { border-color: var(--accent); background: var(--accent-bg); color: var(--accent-text); }
.seo-job-banner.done    { border-color: var(--green); background: var(--green-bg); color: var(--green); }
.seo-job-banner.error   { border-color: var(--red); background: #FEF2F2; color: var(--red); }
.seo-job-spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; flex-shrink: 0; }
.seo-job-banner-btn { background: none; border: 1px solid currentColor; border-radius: 4px; cursor: pointer; font-size: 11px; padding: 2px 10px; font-family: var(--font); color: inherit; }
.seo-job-dismiss { margin-left: auto; background: none; border: none; cursor: pointer; color: inherit; opacity: 0.6; padding: 0; font-size: 16px; line-height: 1; }

.seo-wizard-loading {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 48px 24px; text-align: center;
}
.seo-wizard-loading-spinner {
  width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
.seo-wizard-loading-text { font-size: 14px; font-weight: 500; color: var(--text-1); }
.seo-wizard-loading-sub  { font-size: 12px; color: var(--text-3); }
.seo-wizard-loading-progress { font-size: 13px; color: var(--accent-text); font-weight: 500; }

.seo-platforms-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 640px) { .seo-platforms-grid { grid-template-columns: repeat(3, 1fr); } }
.seo-platform-card { border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px; background: var(--surface); transition: border-color 0.15s; }
.seo-platform-card.connected { border-color: var(--green); background: var(--green-bg); }
.seo-platform-card-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.seo-platform-icon { width: 28px; height: 28px; border-radius: 6px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 10px; font-weight: 700; letter-spacing: -0.5px; }
.seo-platform-name { font-size: 12px; font-weight: 600; color: var(--text-1); }
.seo-platform-theme-info { font-size: 11px; color: var(--text-2); line-height: 1.4; margin-bottom: 6px; }
.seo-platform-swatches { display: flex; gap: 3px; flex-wrap: wrap; margin-top: 3px; }
.seo-platform-swatch { width: 12px; height: 12px; border-radius: 2px; border: 1px solid rgba(0,0,0,0.08); display: inline-block; }
.seo-platform-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.seo-platform-btn { font-size: 11px; padding: 4px 9px; border-radius: 4px; cursor: pointer; font-family: var(--font); border: 1px solid var(--border); background: var(--surface); color: var(--text-1); }
.seo-platform-btn.primary { background: var(--accent); color: white; border-color: var(--accent); }
.seo-platform-btn.danger { color: var(--red); border-color: var(--red-bg); background: var(--red-bg); }
.seo-publish-platform-btn { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--r-sm); cursor: pointer; background: var(--surface); font-family: var(--font); font-size: 13px; color: var(--text-1); transition: border-color 0.15s; width: 100%; text-align: left; }
.seo-publish-platform-btn:hover { border-color: var(--accent); background: var(--accent-bg); }
.seo-publish-platform-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.seo-kb-status {
  display: flex; align-items: center; gap: 6px; font-size: 12px;
  padding: 8px 12px; border-radius: var(--r-sm); margin-bottom: 12px;
}
.seo-kb-status.synced  { background: var(--green-bg); color: var(--green); }
.seo-kb-status.pending { background: var(--surface-2); color: var(--text-2); }
.seo-kb-status.error   { background: var(--red-bg); color: var(--red); }
.seo-kb-status.syncing { background: var(--amber-bg); color: var(--amber); }

/* ════════════════════════════
   MISSED CALL RECOVERY
════════════════════════════ */

.mc-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 500; letter-spacing: 0.02em;
  padding: 2px 8px; border-radius: 20px; white-space: nowrap;
}
.mc-badge.new      { background: var(--amber-bg);  color: var(--amber); }
.mc-badge.replied  { background: var(--green-bg);  color: var(--green); }
.mc-badge.opted-out{ background: var(--surface-2); color: var(--text-3); }

.mc-activate-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 32px 28px; max-width: 520px;
}
.mc-activate-card h2 { font-size: 17px; font-weight: 500; letter-spacing: -0.01em; margin-bottom: 6px; }
.mc-activate-card p  { font-size: 13px; color: var(--text-2); margin-bottom: 20px; line-height: 1.6; }

.mc-instructions { margin-top: 24px; padding: 16px; background: var(--surface-2); border-radius: var(--r-md); }
.mc-instructions h4 { font-size: 12px; font-weight: 500; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 12px; }
.mc-instr-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.mc-instr-row code { font-family: monospace; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 3px 8px; font-size: 13px; color: var(--accent-text); }
.mc-instr-row span { color: var(--text-2); }
.mc-instr-note { font-size: 12px; color: var(--text-3); margin-top: 8px; }

.mc-leads-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mc-leads-table th { text-align: left; font-size: 11px; font-weight: 500; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.06em; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.mc-leads-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.mc-leads-table tr:last-child td { border-bottom: none; }
.mc-leads-table tr:hover td { background: var(--surface-2); cursor: pointer; }

.mc-conv-panel {
  display: none; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); height: 480px; max-width: 520px; margin-top: 24px;
}
.mc-conv-panel.open { display: flex; }
.mc-conv-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.mc-conv-header h4 { font-size: 14px; font-weight: 500; letter-spacing: -0.01em; }
.mc-conv-header button { background: none; border: none; cursor: pointer; color: var(--text-3); font-size: 18px; line-height: 1; padding: 0 2px; }
.mc-conv-header button:hover { color: var(--text-1); }
.mc-conv-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.mc-bubble {
  max-width: 72%; padding: 9px 13px; border-radius: var(--r-md);
  font-size: 13px; line-height: 1.5; word-break: break-word;
}
.mc-bubble.out { align-self: flex-end; background: var(--text-1); color: #fff; border-bottom-right-radius: 3px; }
.mc-bubble.in  { align-self: flex-start; background: var(--surface-2); color: var(--text-1); border-bottom-left-radius: 3px; }
.mc-bubble-time { font-size: 10px; opacity: 0.55; margin-top: 3px; display: block; }

/* ════════════════════════════
   WEBHOOK SYSTEM
════════════════════════════ */

.wh-sub-view { display: none; flex-direction: column; gap: 14px; }
.wh-sub-view.active { display: flex; }

.wh-ep-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 14px 16px;
}
.wh-ep-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.wh-ep-name { font-size: 14px; font-weight: 500; }
.wh-ep-desc { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.wh-ep-url {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 7px 10px; margin-bottom: 8px; overflow: hidden;
}
.wh-ep-url code { flex: 1; font-size: 11px; font-family: monospace; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wh-ep-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.wh-event-row {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 12px 14px;
  cursor: pointer; transition: border-color 120ms;
  display: flex; align-items: flex-start; gap: 12px;
}
.wh-event-row:hover { border-color: var(--border-mid); }
.wh-event-icon {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.wh-event-body { flex: 1; min-width: 0; }
.wh-event-source { font-size: 13px; font-weight: 500; }
.wh-event-summary { font-size: 12px; color: var(--text-2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wh-event-meta { display: flex; gap: 6px; align-items: center; margin-top: 5px; flex-wrap: wrap; }
.wh-status-badge { font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 20px; letter-spacing: 0.03em; text-transform: uppercase; }
.wh-status-done    { background: var(--green-bg);  color: var(--green); }
.wh-status-pending { background: var(--amber-bg);  color: var(--amber); }
.wh-status-failed  { background: var(--red-bg);    color: var(--red); }
.wh-status-skipped { background: var(--surface-2); color: var(--text-3); }
.wh-type-badge { font-size: 10px; font-weight: 500; padding: 2px 7px; border-radius: 20px; background: var(--accent-bg); color: var(--accent-text); }
.wh-type-badge.voice { background: var(--surface-2); color: var(--text-2); }

.wh-detail-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px; margin-bottom: 12px; }
.wh-detail-section-title { font-size: 11px; font-weight: 500; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px; }
.wh-payload-block { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 12px 14px; font-size: 11px; font-family: monospace; line-height: 1.6; white-space: pre-wrap; overflow: auto; max-height: 360px; }
.wh-fields-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.wh-fields-table th { padding: 6px 10px; text-align: left; font-size: 10px; font-weight: 500; color: var(--text-3); letter-spacing: 0.04em; text-transform: uppercase; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.wh-fields-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); }
.wh-fields-table tr:last-child td { border-bottom: none; }
.wh-field-path  { font-family: monospace; color: var(--accent-text); font-size: 11px; }
.wh-field-type  { font-size: 10px; color: var(--text-3); }
.wh-field-value { font-family: monospace; font-size: 11px; word-break: break-word; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.conv-source-toggle { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.wh-conv-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 13px 16px; cursor: pointer; transition: border-color 120ms; display: flex; align-items: center; gap: 12px; }
.wh-conv-item:hover { border-color: var(--border-mid); }
.wh-conv-item-body { flex: 1; min-width: 0; }
.wh-conv-item-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 2px; }
.wh-conv-item-name { font-size: 13px; font-weight: 500; }
.wh-conv-item-time { font-size: 11px; color: var(--text-3); }
.wh-conv-item-preview { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wh-conv-item-meta { display: flex; gap: 6px; align-items: center; margin-top: 5px; flex-wrap: wrap; }

/* ── RECALLS ──────────────────────────────────────────────────────────────── */
.rc-sub-view { display: none; }
.rc-sub-view.active { display: block; }

#rc-dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--r-lg);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--surface);
}
#rc-dropzone:hover, #rc-dropzone.dropzone-active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}

.import-history-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-2);
}
.import-history-row:last-child { margin-bottom: 0; }
.import-history-name { font-weight: 500; color: var(--text-1); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-history-meta { color: var(--text-3); white-space: nowrap; }
.btn-undo { font-size: 11px; padding: 3px 9px; border-radius: var(--r-sm); border: 1px solid var(--red); color: var(--red); background: transparent; cursor: pointer; white-space: nowrap; }
.btn-undo:hover { background: color-mix(in srgb,#ef4444 10%,transparent); }

.rc-preview-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.rc-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  text-align: center;
}
.rc-stat-value { font-size: 22px; font-weight: 600; color: var(--text-1); }
.rc-stat-label { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.rc-sample-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 16px; }
.rc-sample-table th { text-align: left; padding: 6px 8px; background: var(--surface-2, var(--surface)); color: var(--text-3); font-weight: 500; border-bottom: 1px solid var(--border); }
.rc-sample-table td { padding: 6px 8px; color: var(--text-2); border-bottom: 1px solid var(--border); }

.rc-clients-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rc-clients-table th { text-align: left; padding: 8px 10px; background: var(--surface); color: var(--text-3); font-weight: 500; border-bottom: 1px solid var(--border); }
.rc-clients-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); color: var(--text-1); }
.rc-clients-table tr:last-child td { border-bottom: none; }
.rc-client-row:hover td { background: var(--surface); }
#rc-client-drawer {
  /* Slide-in from the right. visibility transitions at the start (open) and
     end (close) so the element is never in tab order when fully hidden. */
  transform: translateX(100%);
  visibility: hidden;
  transition:
    transform 280ms cubic-bezier(0.32, 0, 0.15, 1),
    visibility 0s linear 280ms;
}
#rc-client-drawer.drawer-open {
  transform: translateX(0);
  visibility: visible;
  transition:
    transform 280ms cubic-bezier(0.32, 0, 0.15, 1),
    visibility 0s linear 0s;
}
#rc-client-overlay {
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}
#rc-client-overlay.drawer-open {
  opacity: 1;
  pointer-events: auto;
}

/* ── HOME SETUP BANNER ────────────────────────────────────────────────────── */
.home-setup-banner {
  display: flex; align-items: center; gap: 12px;
  background: var(--accent-bg); border: 1px solid #BFDBFE;
  border-radius: var(--r-lg); padding: 14px 16px;
  margin-bottom: 20px;
}
.hsb-icon { font-size: 18px; flex-shrink: 0; color: var(--accent); }
.hsb-body { flex: 1; min-width: 0; }
.hsb-title { font-size: 13px; font-weight: 600; color: var(--text-1); margin-bottom: 5px; }
.hsb-sub { display: flex; align-items: center; gap: 8px; }
.hsb-dots { display: flex; gap: 4px; }
.hsb-dot { width: 8px; height: 8px; border-radius: 50%; background: #BFDBFE; flex-shrink: 0; }
.hsb-dot.done { background: var(--accent); }
.hsb-progress { font-size: 12px; color: var(--accent-text); }
.hsb-cta { flex-shrink: 0; }
.hsb-close {
  flex-shrink: 0; background: none; border: none; cursor: pointer;
  font-size: 20px; line-height: 1; color: var(--text-3); padding: 0 2px;
}
.hsb-close:hover { color: var(--text-2); }

/* ── TRIAL / SUSPENSION BANNER ────────────────────────────────────────────── */
.clinic-sub-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; margin-bottom: 14px;
  border-radius: var(--r-md);
  font-size: 13px; line-height: 1.35;
  border: 1px solid var(--border);
  background: var(--surface);
}
.clinic-sub-banner.amber {
  border-color: #f59e0b;
  background: color-mix(in srgb, #f59e0b 10%, var(--surface));
  color: var(--text-1);
}
.clinic-sub-banner.red {
  border-color: #ef4444;
  background: color-mix(in srgb, #ef4444 10%, var(--surface));
  color: var(--text-1);
}
.clinic-sub-banner-icon {
  font-size: 15px; flex-shrink: 0;
}
.clinic-sub-banner-msg {
  flex: 1; min-width: 0;
}
.clinic-sub-banner-cta {
  background: var(--text-1); color: var(--bg);
  border: none; cursor: pointer;
  padding: 6px 12px; border-radius: var(--r-md);
  font-size: 12px; font-weight: 500;
  white-space: nowrap; flex-shrink: 0;
}
.clinic-sub-banner-cta:hover { opacity: 0.9; }

/* ── ONBOARDING CARD ──────────────────────────────────────────────────────── */
.rc-onboard-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 18px 20px;
}
.rc-onboard-head {
  display: flex; align-items: flex-start; gap: 14px; margin-bottom: 14px;
}
.rc-onboard-emoji { font-size: 28px; line-height: 1; flex-shrink: 0; }
.rc-onboard-close {
  margin-left: auto; background: none; border: none; cursor: pointer;
  font-size: 22px; line-height: 1; color: var(--text-3); padding: 0;
}
.rc-onboard-steps {
  margin: 0 0 14px; padding-left: 22px; font-size: 13px; color: var(--text-2);
  display: flex; flex-direction: column; gap: 6px; line-height: 1.5;
}
.rc-onboard-steps strong { color: var(--text-1); font-weight: 500; }

/* ── SETUP CHECKLIST (interactive, live state) ────────────────────────────── */
.rc-check-list { display: flex; flex-direction: column; gap: 8px; }
.rc-check-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--r-md); background: var(--surface);
}
.rc-check-item.done   { opacity: 0.7; }
.rc-check-item.locked { opacity: 0.55; }
.rc-check-item .rc-step-body { flex: 1; }
.rc-check-item.done .rc-step-marker { background: #22c55e; color: #fff; }
.rc-check-cta { flex-shrink: 0; }

/* ── SETUP CHECKLIST — shared step primitives ─────────────────────────────── */
.rc-step-marker {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--border); color: var(--text-2);
  font-size: 13px; font-weight: 600; flex-shrink: 0;
}
.rc-step-body { min-width: 0; }
.rc-step-label { font-size: 13px; font-weight: 500; color: var(--text-1); }
.rc-step-hint  { font-size: 11px; color: var(--text-3); margin-top: 1px; }

.upgrade-prompt {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 200px; gap: 8px; text-align: center; padding: 40px 24px;
}
.upgrade-icon { font-size: 32px; }
.upgrade-title { font-size: 15px; font-weight: 500; color: var(--text-1); }
.upgrade-sub   { font-size: 13px; color: var(--text-2); }

/* ── COOKIE BANNER ────────────────────────────────────────────────────────── */
.cookie-banner {
  position: fixed; left: 16px; right: 16px; bottom: 16px;
  z-index: 9999;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-2);
}
.cookie-banner[hidden] { display: none; }
.cookie-banner-msg { flex: 1; min-width: 220px; line-height: 1.5; }
.cookie-banner-msg a { color: var(--accent); }
.cookie-banner-actions { display: flex; gap: 8px; flex-shrink: 0; }
.cookie-btn-primary {
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--r-sm);
  padding: 8px 16px; font-size: 13px; font-weight: 500; cursor: pointer;
}
.cookie-btn-primary:hover { opacity: .9; }
@media (max-width: 480px) {
  .cookie-banner { left: 8px; right: 8px; bottom: 8px; padding: 12px; }
}

/* ── LEGAL FOOTER on login/register cards ─────────────────────────────────── */
.login-legal-footer {
  margin-top: 16px;
  font-size: 11px;
  color: var(--text-3);
  text-align: center;
}
.login-legal-footer a { color: var(--text-3); text-decoration: none; }
.login-legal-footer a:hover { color: var(--accent); }

.reg-consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 12px 0 16px;
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.5;
  cursor: pointer;
}
.reg-consent input { margin-top: 3px; flex-shrink: 0; cursor: pointer; }
.reg-consent a { color: var(--accent); }

.pw-strength { display: flex; align-items: center; gap: 7px; margin-top: 7px; min-height: 14px; }
.pw-strength-bars { display: flex; gap: 3px; flex: 1; }
.pw-bar { height: 3px; flex: 1; border-radius: 2px; background: var(--border); transition: background 180ms var(--ease); }
.pw-strength[data-score="1"] .pw-bar:nth-child(1) { background: var(--red); }
.pw-strength[data-score="2"] .pw-bar:nth-child(1),
.pw-strength[data-score="2"] .pw-bar:nth-child(2) { background: var(--amber); }
.pw-strength[data-score="3"] .pw-bar { background: var(--green); }
.pw-strength-label { font-size: 11px; color: var(--text-3); min-width: 36px; text-align: right; transition: color 180ms var(--ease); }
.pw-strength[data-score="1"] .pw-strength-label { color: var(--red); }
.pw-strength[data-score="2"] .pw-strength-label { color: var(--amber); }
.pw-strength[data-score="3"] .pw-strength-label { color: var(--green); }

/* ── SUBSCRIPTION PLAN GRID ───────────────────────────────────────────────── */
.rc-plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.rc-plan-card {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
}
.rc-plan-current {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.rc-plan-name {
  font-size: 14px; font-weight: 600; color: var(--text-1);
  margin-bottom: 6px;
}
.rc-plan-price { margin-bottom: 4px; }
.rc-plan-price-amt  { font-size: 20px; font-weight: 700; color: var(--text-1); }
.rc-plan-price-note { font-size: 12px; color: var(--text-3); margin-left: 2px; }
.rc-plan-tagline    { font-size: 12px; color: var(--text-2); margin-bottom: 10px; line-height: 1.4; }
.rc-plan-bullets {
  list-style: none; padding: 0; margin: 0 0 14px;
  font-size: 12px; color: var(--text-2);
  display: flex; flex-direction: column; gap: 4px;
}
.rc-plan-bullets li::before { content: "✓ "; color: var(--accent); font-weight: 600; }
.rc-plan-cta { margin-top: auto; }
.rc-plan-cta .btn-primary,
.rc-plan-cta .btn-secondary { font-size: 13px; padding: 8px 14px; }

/* Feature comparison matrix (3.6) */
.rc-fm-wrap {
  margin-top: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
}
.rc-fm-title {
  font-size: 13px; font-weight: 600; color: var(--text-1);
  margin-bottom: 12px;
}
.rc-fm-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.rc-feature-matrix {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
  min-width: 480px;
}
.rc-feature-matrix th,
.rc-feature-matrix td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: center;
  vertical-align: middle;
}
.rc-feature-matrix thead th {
  font-weight: 600;
  color: var(--text-3);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.rc-fm-feat-h,
.rc-fm-feat {
  text-align: left !important;
  color: var(--text-1) !important;
  font-weight: 500;
  width: 40%;
}
.rc-fm-current {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent) !important;
}
.rc-feature-matrix thead th.rc-fm-current {
  color: var(--accent) !important;
}
.rc-fm-group td {
  background: var(--surface-2, transparent);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: left !important;
  padding-top: 12px;
}
.rc-fm-yes { color: var(--accent); font-weight: 600; }
.rc-fm-no  { color: var(--text-3); }
.rc-fm-text { color: var(--text-1); font-size: 12px; }
.rc-feature-matrix tbody tr:last-child td,
.rc-feature-matrix tbody tr:last-child th { border-bottom: none; }

/* ── ANALYTICS ────────────────────────────────────────────────────────────── */
.an-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.an-tabs::-webkit-scrollbar { display: none; }
.an-tab {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.12s, border-color 0.12s;
  margin-bottom: -1px;
}
.an-tab:hover { color: var(--text-1); }
.an-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.an-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.an-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 16px;
}
.an-card-label { font-size: 11px; color: var(--text-3); margin-bottom: 4px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.an-card-value { font-size: 22px; font-weight: 600; color: var(--text-1); line-height: 1.2; }
.an-card-sub   { font-size: 11px; color: var(--text-3); margin-top: 3px; }
.an-card-trend { font-size: 12px; margin-top: 4px; font-weight: 500; }
.an-card-trend.up   { color: #22c55e; }
.an-card-trend.down { color: var(--red, #ef4444); }
.an-card-trend.flat { color: var(--text-3); }

/* traffic lights */
.tl { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.tl-green  { background: #22c55e; }
.tl-yellow { background: #f59e0b; }
.tl-red    { background: #ef4444; }

.an-section-title { font-size: 13px; font-weight: 600; color: var(--text-1); margin: 0 0 12px; }

/* Leaderboard table */
.an-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.an-table th { text-align: left; padding: 7px 10px; color: var(--text-3); font-weight: 500; border-bottom: 1px solid var(--border); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
.an-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); color: var(--text-1); }
.an-table tr:last-child td { border-bottom: none; }
.an-table tr.an-row-clickable { cursor: pointer; }
.an-table tr.an-row-clickable:hover td { background: color-mix(in srgb, var(--accent) 5%, transparent); }

/* Inline SVG bar chart */
.an-sparkbar { display: flex; align-items: flex-end; gap: 2px; height: 28px; }
.an-sparkbar rect { rx: 2; }

/* Chart wrapper */
.an-chart-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
  margin-bottom: 16px;
}
.an-chart-title { font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 10px; }

/* WooCommerce-style overview hero */
.an-hero {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.an-hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 18px 20px 14px;
  position: relative;
  overflow: hidden;
}
.an-hero-card-accent { border-top: 3px solid var(--accent); }
.an-hero-card-green  { border-top: 3px solid #22c55e; }
.an-hero-card-amber  { border-top: 3px solid #f59e0b; }
.an-hero-card-red    { border-top: 3px solid #ef4444; }
.an-hero-label { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.an-hero-value { font-size: 32px; font-weight: 700; color: var(--text-1); line-height: 1.1; margin-bottom: 4px; }
.an-hero-sub   { font-size: 12px; color: var(--text-2); margin-top: 2px; display: flex; align-items: center; gap: 5px; }
.an-hero-spark { margin-top: 12px; opacity: 0.6; }

/* Two-column chart row */
.an-chart-row { display: grid; grid-template-columns: 1fr; gap: 12px; margin-bottom: 16px; }
@media (min-width: 680px) { .an-chart-row { grid-template-columns: 1fr 1fr; } }

/* Insights strip */
.an-insights { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 18px; }
.an-insights-title { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.an-ai-badge {
  display: inline-flex; align-items: center; padding: 1px 6px;
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--accent); border-radius: 10px;
  font-size: 9px; font-weight: 700; letter-spacing: .04em;
  text-transform: none;
}
.an-insight {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; border-radius: var(--r-md); margin-bottom: 8px;
  border: 1px solid transparent;
}
.an-insight.positive { background: color-mix(in srgb,#22c55e 8%,var(--surface)); border-color: color-mix(in srgb,#22c55e 30%,transparent); }
.an-insight.warning  { background: color-mix(in srgb,#f59e0b 8%,var(--surface)); border-color: color-mix(in srgb,#f59e0b 30%,transparent); }
.an-insight.info     { background: color-mix(in srgb,var(--accent) 7%,var(--surface)); border-color: color-mix(in srgb,var(--accent) 25%,transparent); }
.an-insight-icon { font-size: 14px; flex-shrink: 0; margin-top: 1px; }
.an-insight-text { font-size: 13px; color: var(--text-1); line-height: 1.5; flex: 1; }

/* 7.11 — visually mark busy buttons so the user knows the action is in flight */
button[aria-busy="true"], [data-busy="1"] { opacity: .65; cursor: progress !important; }

/* 5.2 — threshold cog + panel */
.an-insights-title { justify-content: space-between; }
.an-thresh-btn { background: transparent; border: 0; color: var(--text-3); cursor: pointer; font-size: 14px; padding: 0 4px; }
.an-thresh-btn:hover { color: var(--text-1); }
.an-thresh-panel { margin: 6px 0 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.an-thresh-grid { display: grid; grid-template-columns: 1fr; gap: 6px; }
@media (min-width: 600px) { .an-thresh-grid { grid-template-columns: 1fr 1fr; } }
.an-thresh-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); }
.an-thresh-row > span:first-child { flex: 1; }
.an-thresh-row input { width: 64px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface-2, var(--surface)); color: var(--text-1); font-size: 12px; }
.an-thresh-hint { font-size: 11px; color: var(--text-3); flex-shrink: 0; }
.an-thresh-actions { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.an-thresh-help { font-size: 11px; color: var(--text-3); flex: 1; min-width: 200px; }
.an-insight-dismiss {
  background: transparent; border: 0; color: var(--text-3); cursor: pointer;
  font-size: 16px; line-height: 1; padding: 0 4px; opacity: 0; transition: opacity .15s;
  flex-shrink: 0; align-self: flex-start;
}
.an-insight:hover .an-insight-dismiss { opacity: 1; }
.an-insight-dismiss:hover { color: var(--text-1); }
@media (hover: none) { .an-insight-dismiss { opacity: .7; } }

/* Alert cards */
.an-alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 8px;
}
.an-alert.critical { border-color: #ef4444; background: color-mix(in srgb, #ef4444 8%, var(--surface)); }
.an-alert.warning  { border-color: #f59e0b; background: color-mix(in srgb, #f59e0b 8%, var(--surface)); }
.an-alert-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.an-alert-msg  { font-size: 13px; color: var(--text-1); line-height: 1.4; }

/* Scorecard grid */
.an-scorecard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.an-scorecard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
}
.an-scorecard-name  { font-size: 14px; font-weight: 600; color: var(--text-1); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.an-scorecard-score { font-size: 32px; font-weight: 700; }
.an-scorecard-score.high { color: #22c55e; }
.an-scorecard-score.mid  { color: #f59e0b; }
.an-scorecard-score.low  { color: #ef4444; }
.an-scorecard-rows { margin-top: 10px; display: flex; flex-direction: column; gap: 5px; }
.an-scorecard-row  { display: flex; justify-content: space-between; font-size: 12px; }
.an-scorecard-row-label { color: var(--text-3); }
.an-scorecard-row-val   { color: var(--text-1); font-weight: 500; }

/* Date range bar */
.an-daterange {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.an-daterange label { font-size: 12px; color: var(--text-3); }
.an-daterange input[type=date] {
  padding: 5px 8px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-1);
  font-size: 12px;
}
.an-daterange select {
  padding: 5px 8px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-1);
  font-size: 12px;
}

/* Practitioner detail panel */
.an-detail-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  margin-top: 16px;
}
.an-detail-header { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.an-detail-name { font-size: 15px; font-weight: 600; color: var(--text-1); }
.an-back-btn { font-size: 12px; color: var(--accent); cursor: pointer; background: none; border: none; padding: 0; }

/* Progress bar for contribution % */
.an-bar-wrap { background: var(--border); border-radius: 4px; height: 6px; overflow: hidden; margin-top: 4px; }
.an-bar-fill { height: 100%; border-radius: 4px; background: var(--accent); transition: width 0.4s; }

/* Bar chart interactive hover */
.an-bar-col { cursor: default; }
.an-bar-col:hover .an-bar-rect { opacity: 1 !important; filter: brightness(1.18); }

/* 4.10 — Time-to-return horizontal distribution chart */
.an-ttr-chart { display: flex; flex-direction: column; gap: 7px; }
.an-ttr-row { display: grid; grid-template-columns: 92px 1fr auto; align-items: center; gap: 10px; }
.an-ttr-label { font-size: 12px; color: var(--text-2); white-space: nowrap; }
.an-ttr-track { background: var(--border); border-radius: 4px; height: 16px; overflow: hidden; }
.an-ttr-bar { height: 100%; border-radius: 4px; background: var(--accent); transition: width 0.4s; min-width: 2px; }
.an-ttr-count { font-size: 12px; color: var(--text-1); white-space: nowrap; min-width: 56px; text-align: right; }

/* Floating chart tooltip */
#an-tooltip {
  display: none;
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border-mid, var(--border));
  border-radius: var(--r-md);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-1);
  pointer-events: none;
  z-index: 9000;
  box-shadow: 0 2px 12px rgba(0,0,0,.14);
  white-space: nowrap;
}

/* Preset period buttons */
.an-presets {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 8px;
}
.an-preset-btn {
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s;
  font-family: var(--font);
}
.an-preset-btn:hover { background: var(--surface-2); color: var(--text-1); border-color: var(--border-mid, var(--border)); }
.an-preset-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Period comparison */
.an-cmp-daterange {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  padding: 7px 12px;
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.an-cmp-wrapper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 8px;
}
@media (max-width: 700px) { .an-cmp-wrapper { grid-template-columns: 1fr; } }
.an-cmp-pane-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: .04em;
  margin-bottom: 12px;
  padding: 5px 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
}
.an-cmp-pane-label.pane-a { border-left: 3px solid var(--accent); }
.an-cmp-pane-label.pane-b { border-left: 3px solid #a78bfa; }
.an-cmp-delta {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 16px;
  margin-bottom: 24px;
}
.an-cmp-delta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 2px;
}
.an-cmp-delta-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 3px;
}
.an-cmp-delta-val { font-size: 18px; font-weight: 700; }
.an-cmp-delta-val.up   { color: #22c55e; }
.an-cmp-delta-val.down { color: #ef4444; }
.an-cmp-delta-val.flat { color: var(--text-3); }


/* ════════════════════════════
   ADMIN USERS
════════════════════════════ */

.admin-sub-view              { display: none; flex-direction: column; gap: 16px; }
.admin-sub-view.active       { display: flex; }

/* Toolbar */
.admin-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
}
.admin-search-wrap {
  position: relative; flex: 1; min-width: 200px;
}
.admin-search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; opacity: 0.4; pointer-events: none;
}
.admin-search-input {
  width: 100%; padding: 9px 12px 9px 32px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); font-size: 13px; font-family: var(--font);
  color: var(--text-1); outline: none; transition: border-color 120ms;
}
.admin-search-input:focus { border-color: var(--border-mid); }
.admin-filter-row { display: flex; flex-wrap: wrap; gap: 5px; }
.admin-toolbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.admin-users-count { font-size: 12px; color: var(--text-3); }

/* Table */
.admin-table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden;
}
.admin-table { width: 100%; border-collapse: collapse; }
.admin-th {
  padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 500;
  color: var(--text-3); letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  white-space: nowrap; cursor: pointer; user-select: none;
  transition: color 120ms;
}
.admin-th:hover { color: var(--text-1); }
.sort-ind { color: var(--accent); }
.admin-user-row { cursor: pointer; transition: background 100ms; }
.admin-user-row:hover { background: var(--surface-2); }
.admin-user-row:not(:last-child) td { border-bottom: 1px solid var(--border); }
.admin-td { padding: 11px 14px; font-size: 13px; color: var(--text-1); vertical-align: middle; }
.admin-td-id    { font-family: monospace; font-size: 11px; color: var(--text-3); }
.admin-td-name  { font-weight: 500; }
.admin-td-email { color: var(--text-2); }
.admin-td-date  { color: var(--text-3); font-size: 12px; white-space: nowrap; }
.admin-td-actions { text-align: right; }
.admin-td-empty { padding: 36px; text-align: center; color: var(--text-3); font-size: 13px; }

/* Action button in table */
.admin-action-btn {
  padding: 5px 10px; background: none; border: 1px solid var(--border);
  border-radius: var(--r-sm); font-size: 12px; font-family: var(--font);
  color: var(--text-2); cursor: pointer; transition: background 120ms, border-color 120ms;
}
.admin-action-btn:hover { background: var(--surface-2); border-color: var(--border-mid); color: var(--text-1); }

/* Role tags */
.admin-role-tag {
  display: inline-flex; align-items: center; padding: 3px 8px;
  border-radius: 20px; font-size: 11px; font-weight: 500; letter-spacing: 0.02em;
}
.admin-role-tag.admin  { background: #EEF4FF; color: var(--accent-text); }
.admin-role-tag.agent  { background: var(--green-bg); color: var(--green); }
.admin-role-tag.viewer { background: var(--amber-bg); color: var(--amber); }
.admin-role-tag.user   { background: var(--surface-2); color: var(--text-2); }

/* Status badges */
.admin-status-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 500;
}
.admin-status-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }
.admin-status-badge.active   { background: var(--green-bg); color: var(--green); }
.admin-status-badge.active::before   { background: var(--green); }
.admin-status-badge.inactive { background: var(--surface-2); color: var(--text-3); }
.admin-status-badge.inactive::before { background: var(--text-3); }

/* Pagination */
.admin-pagination {
  display: flex; align-items: center; gap: 5px; padding: 4px 0; flex-wrap: wrap;
}
.admin-page-btn {
  padding: 5px 10px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); font-size: 13px; font-family: var(--font);
  color: var(--text-2); cursor: pointer; transition: background 100ms, border-color 100ms;
  min-width: 34px;
}
.admin-page-btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border-mid); color: var(--text-1); }
.admin-page-btn.active { background: var(--text-1); color: white; border-color: var(--text-1); }
.admin-page-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.admin-page-info { font-size: 12px; color: var(--text-3); margin-left: 6px; }

/* Back button */
.admin-back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none; cursor: pointer; font-size: 13px;
  color: var(--text-2); font-family: var(--font); padding: 0;
  transition: color 120ms;
}
.admin-back-btn:hover { color: var(--text-1); }

/* Detail card */
.admin-detail-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden;
}
.admin-detail-header-row {
  display: flex; align-items: center; gap: 16px; padding: 20px 20px 18px;
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}

/* User avatar */
.admin-user-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--accent-bg); color: var(--accent-text);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 600; flex-shrink: 0;
}
.admin-user-meta        { flex: 1; min-width: 0; }
.admin-user-fullname    { font-size: 15px; font-weight: 600; color: var(--text-1); }
.admin-user-email       { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.admin-detail-actions   { margin-left: auto; }

/* Detail tabs */
.admin-detail-tabs {
  display: flex; border-bottom: 1px solid var(--border);
  padding: 0 16px;
}
.admin-detail-tab {
  padding: 12px 14px; background: none; border: none; border-bottom: 2px solid transparent;
  font-size: 13px; font-family: var(--font); color: var(--text-2); cursor: pointer;
  transition: color 120ms, border-color 120ms; margin-bottom: -1px;
}
.admin-detail-tab:hover { color: var(--text-1); }
.admin-detail-tab.active { color: var(--text-1); font-weight: 500; border-bottom-color: var(--text-1); }

/* Tab body */
#admin-detail-body { padding: 18px 20px; }

/* Permission toggles */
.admin-perms-form { display: flex; flex-direction: column; gap: 20px; }
.admin-perm-group-title {
  font-size: 11px; font-weight: 500; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-3); margin-bottom: 10px;
}
.admin-perm-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 8px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.admin-perm-row:last-child { border-bottom: none; }
.admin-perm-label { font-size: 13px; color: var(--text-1); }

/* Toggle switch */
.admin-toggle {
  width: 36px; height: 20px; border-radius: 10px;
  background: var(--border-mid); flex-shrink: 0; position: relative;
  cursor: pointer; transition: background 180ms;
}
.admin-toggle.on { background: var(--green); }
.admin-toggle-knob {
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: white; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 180ms;
}
.admin-toggle.on .admin-toggle-knob { transform: translateX(16px); }

/* Audit log */
.admin-audit-list { display: flex; flex-direction: column; gap: 2px; }
.admin-audit-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.admin-audit-item:last-child { border-bottom: none; }
.admin-audit-icon {
  width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  color: var(--text-2);
}
.admin-audit-content  { flex: 1; min-width: 0; }
.admin-audit-label    { font-size: 13px; color: var(--text-1); }
.admin-audit-meta     { font-size: 11px; color: var(--text-3); margin-top: 3px; }

/* Confirmation dialog */
.admin-confirm-box {
  background: var(--surface); border-radius: var(--r-xl); padding: 28px;
  max-width: 400px; width: 100%; box-shadow: var(--shadow-md);
}
.admin-confirm-title   { font-size: 16px; font-weight: 600; margin-bottom: 10px; }
.admin-confirm-message { font-size: 14px; color: var(--text-2); margin-bottom: 22px; line-height: 1.5; }
.admin-confirm-actions { display: flex; gap: 8px; }

/* btn-secondary (referenced in admin) */
.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 11px 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  font-size: 14px; font-weight: 500; font-family: var(--font);
  color: var(--text-1); cursor: pointer; transition: background 120ms, border-color 120ms;
  width: 100%; text-align: center;
}
.btn-secondary:hover { background: var(--surface-2); border-color: var(--border-mid); }

/* Responsive adjustments */
@media (max-width: 640px) {
  .admin-td-id, .admin-td-date { display: none; }
  .admin-td { padding: 9px 10px; }
  .admin-th { padding: 8px 10px; }
  .admin-detail-header-row { padding: 16px; }
}

/* ── Impersonation banner ──────────────────────────────────────────────────── */
.impersonation-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--amber-bg); border-bottom: 1px solid #F1D5A1;
  color: var(--amber); font-size: 13px; font-weight: 500;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.impersonation-banner .icon { width: 18px; height: 18px; flex-shrink: 0; stroke: var(--amber); fill: none; stroke-width: 1.5; }
.impersonation-banner strong { font-weight: 600; }
.impersonation-banner .impersonation-exit {
  margin-left: auto;
  background: var(--amber); color: #fff;
  border: none; border-radius: var(--r-sm);
  padding: 6px 12px; font-size: 12px; font-weight: 500; cursor: pointer;
}
.impersonation-banner .impersonation-exit:hover { filter: brightness(0.92); }
body.impersonating #view-shell { padding-top: 42px; }

/* ── Widgets ──────────────────────────────────────────────────────────────── */
.home-widgets-header {
  display: flex; align-items: center; justify-content: space-between;
  margin: 24px 0 12px;
}
.home-section-label {
  font-size: 13px; font-weight: 600; color: var(--text-2);
  text-transform: uppercase; letter-spacing: .04em;
}
.customize-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--surface);
  font-size: 12px; font-weight: 500; color: var(--text-2);
  cursor: pointer; transition: background 120ms, border-color 120ms;
}
.customize-btn:hover  { background: var(--surface-2); border-color: var(--border-mid); }
.customize-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.widget-grid {
  display: flex; flex-direction: column; gap: 14px;
}
@media (min-width: 600px) {
  .widget-grid { display: grid; grid-template-columns: 1fr 1fr; }
}

.widget {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden;
}
.widget-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px 10px; border-bottom: 1px solid var(--border);
}
.widget-title {
  font-size: 13px; font-weight: 600; color: var(--text-1);
}
.widget-link {
  font-size: 12px; color: var(--accent); text-decoration: none; white-space: nowrap;
}
.widget-link:hover { text-decoration: underline; }

.widget-body { padding: 6px 0; min-height: 60px; }

.widget-empty {
  padding: 20px 16px; font-size: 13px; color: var(--text-3); text-align: center;
}
.widget-empty-ok {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--green);
}
.widget-empty-ok .icon { stroke: var(--green); fill: none; stroke-width: 1.8; }

.widget-loading { padding: 8px 0; }

.widget-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; cursor: pointer;
  transition: background 100ms;
}
.widget-row:hover { background: var(--surface-2); }
.widget-row[style*="cursor:default"] { cursor: default; }
.widget-row[style*="cursor:default"]:hover { background: transparent; }

.widget-row-body { flex: 1; min-width: 0; }
.widget-row-title {
  font-size: 13px; font-weight: 500; color: var(--text-1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.widget-row-sub {
  font-size: 11px; color: var(--text-3); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.widget-row-meta  { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.widget-row-time  { font-size: 11px; color: var(--text-3); white-space: nowrap; }

.widget-dot-amber {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--amber); flex-shrink: 0;
}

.widget-bar-track {
  height: 5px; border-radius: 3px; background: var(--surface-2); overflow: hidden;
}
.widget-bar-fill {
  height: 100%; border-radius: 3px; background: var(--accent);
  transition: width 300ms ease;
}

.widget-stat-row { display: flex; gap: 16px; padding: 16px; }
.widget-stat { flex: 1; }
.widget-stat-value { font-size: 28px; font-weight: 700; color: var(--text-1); line-height: 1; }
.widget-stat-label { font-size: 12px; color: var(--text-3); margin-top: 4px; }

.widget-skel-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px;
}

/* Customiser panel */
.wc-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px; border-bottom: 1px solid var(--border);
  font-size: 14px; font-weight: 600;
}
.wc-desc {
  padding: 10px 16px 6px; font-size: 13px; color: var(--text-2); margin: 0;
}
.wc-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; cursor: pointer;
}
.wc-row:hover { background: var(--surface-2); }
.wc-row-title { font-size: 13px; font-weight: 500; }

.wc-toggle {
  position: relative; width: 36px; height: 20px;
  border-radius: 10px; background: var(--border-mid);
  transition: background 180ms; cursor: pointer; flex-shrink: 0;
}
.wc-toggle.on { background: var(--accent); }
.wc-toggle-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; transition: left 180ms;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.wc-toggle.on .wc-toggle-thumb { left: 19px; }

#widget-customizer {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); margin-bottom: 14px; overflow: hidden;
}

/* ── Export buttons ─────────────────────────────────────────────────────── */
.an-export-btn {
  color: var(--text-2);
  border-color: var(--border);
}
.an-export-btn:hover { color: var(--text-1); }

/* ── Print / PDF stylesheet ─────────────────────────────────────────────── */
@media print {
  /* Hide everything except the active analytics view */
  body > *:not(#app) { display: none !important; }
  #sidebar, #bottom-nav, .an-presets, .an-daterange,
  .an-export-btn, #an-cmp-toggle, #an-cmp-daterange,
  .an-toolbar, .rc-tabs, .rc-sub-nav,
  #home-section, #nav-skeleton { display: none !important; }

  #app { margin: 0; padding: 0; }
  .rc-sub-view { display: block !important; padding: 0; }

  /* Let charts and tables flow naturally on paper */
  .an-grid { grid-template-columns: repeat(3, 1fr); }
  .an-chart-row { flex-direction: column; }
  .an-chart-wrap { break-inside: avoid; page-break-inside: avoid; }
  .an-table { width: 100%; font-size: 11px; }
  .an-insights { page-break-before: auto; }

  /* Show clinic name as page header */
  body.an-printing::before {
    content: attr(data-clinic-name);
    display: block;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 16px;
    border-bottom: 1px solid #ccc;
    padding-bottom: 8px;
  }
}

/* ════════════════════════════
   DARK MODE
   Overrides :root palette only — all component rules use var(--…) and
   adapt automatically. Hardcoded hex colors get explicit overrides below.
════════════════════════════ */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #0F0F0E;
    --surface:     #1A1A19;
    --surface-2:   #252523;
    --border:      #2E2D2B;
    --border-mid:  #3D3C39;
    --text-1:      #F0EFEB;
    --text-2:      #9B9A95;
    --text-3:      #6B6A65;
    --accent:      #3B82F6;
    --accent-weak: #1E2D4A;
    --accent-bg:   #1A2A47;
    --accent-text: #93C5FD;
    --green:       #4ADE80;
    --green-bg:    #0D2B1E;
    --red:         #F87171;
    --red-bg:      #2B0F0F;
    --amber:       #FCD34D;
    --amber-bg:    #2B1F0A;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.35), 0 1px 1px rgba(0,0,0,0.25);
    --shadow-md: 0 2px 4px rgba(0,0,0,0.30), 0 6px 16px rgba(0,0,0,0.40);
    --shadow-lg: 0 4px 8px rgba(0,0,0,0.35), 0 16px 36px rgba(0,0,0,0.50);
    --ring: 0 0 0 3px rgba(59,130,246,0.30);
    --scroll-shadow: rgba(0,0,0,0.55);   /* darker so the table swipe cue stays visible on dark surfaces */
  }

  /* Hardcoded hex colors that can't be addressed via variable override */

  /* Status dots (resolved/partial/unresolved) */
  .res-dot.resolved          { background: #4ade80; }
  .res-dot.partially_resolved{ background: #fbbf24; }
  .res-dot.unresolved        { background: #f87171; }

  /* Timeline bars */
  .tl-green  { background: #4ade80; }
  .tl-yellow { background: #fbbf24; }
  .tl-red    { background: #f87171; }

  /* Hero card top-border accents */
  .an-hero-card-green { border-top-color: #4ade80; }
  .an-hero-card-amber { border-top-color: #fbbf24; }
  .an-hero-card-red   { border-top-color: #f87171; }

  /* Scorecard score colours */
  .an-scorecard-score.high { color: #4ade80; }
  .an-scorecard-score.mid  { color: #fbbf24; }
  .an-scorecard-score.low  { color: #f87171; }

  /* Analytics trend / delta */
  .an-card-trend.up   { color: #4ade80; }
  .an-cmp-delta-val.up   { color: #4ade80; }
  .an-cmp-delta-val.down { color: #f87171; }

  /* Onboarding progress dots */
  .rc-check-item.done .rc-step-marker { background: #4ade80; color: #0D2B1E; }

  /* Setup-banner dots (uses light-blue hardcoded) */
  .hsb-dot { background: #1E3A5F; }
  .hsb-dot.done { background: var(--accent); }

  /* Sub-banner amber / red (color-mix uses #surface which changed) */
  .clinic-sub-banner.amber {
    border-color: #fbbf24;
    background: color-mix(in srgb, #fbbf24 12%, var(--surface));
  }
  .clinic-sub-banner.red {
    border-color: #f87171;
    background: color-mix(in srgb, #f87171 12%, var(--surface));
  }

  /* SEO review badge — hardcoded light blue bg + text */
  .seo-status-review { background: #1A2A47; color: #93C5FD; }

  /* Toggle thumb — stays white for visibility */
  .wc-toggle-thumb { background: #E5E4E0; }

  /* Comparison panel B accent (violet) — lighten for dark bg */
  .an-cmp-pane-label.pane-b { border-left-color: #c4b5fd; }

  /* Logo mark invert on dark */
  .logo-mark { background: var(--surface-2); border: 1px solid var(--border); }
  .logo-mark svg { stroke: var(--text-1); }
}
