/* ==========================================================================
   Royal Dental Cloud AI — Design System
   royal.css — tokens, primitives, layout shell, components
   ========================================================================== */

/* ---------------------------------- Reset ------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html {
  /* Safety net: any single element that's even a little wider than the
     viewport (an unwrapped table, a fixed-width row, a wide image) used to
     drag the whole page into horizontal scroll on mobile — the page would
     visibly shift/pan sideways on a swipe ("the screen moves around").
     Wide content should scroll inside its own container (see .table-wrap),
     never the page itself. */
  overflow-x: hidden;
}
body {
  margin: 0;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
ul, ol { list-style: none; margin: 0; padding: 0; }
h1, h2, h3, h4, h5, h6, p, figure { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
button { cursor: pointer; }
::selection { background: rgba(124, 47, 224, .25); }

/* ------------------------------- Design Tokens --------------------------- */
:root {
  /* Brand — Royal Purple (primary) + Electric Blue (accent) */
  --rc-primary-50:  #f6f1ff;
  --rc-primary-100: #ebe0ff;
  --rc-primary-200: #d6c0ff;
  --rc-primary-300: #b892ff;
  --rc-primary-400: #9c62f7;
  --rc-primary-500: #8b3fef;
  --rc-primary-600: #7c2fe0;
  --rc-primary-700: #6721bf;
  --rc-primary-800: #521a99;
  --rc-primary-900: #3d1372;

  --rc-accent-300: #8fc7ff;
  --rc-accent-400: #5aa5ff;
  --rc-accent-500: #2f7ff5;
  --rc-accent-600: #1d63e0;

  --rc-gold-300: #f2d888;
  --rc-gold-400: #e6c35e;
  --rc-gold-500: #d4af37;
  --rc-gold-600: #b8912a;

  --rc-violet-500: #2f7ff5; /* alias kept for legacy gradient stops → now points to Electric Blue */
  --rc-cyan-500: #2f7ff5;

  --rc-success-500: #10b981;
  --rc-success-100: #d1fae5;
  --rc-warning-500: #f59e0b;
  --rc-warning-100: #fef3c7;
  --rc-danger-500:  #ff5c5c;
  --rc-danger-100:  #ffe3e0;
  --rc-info-500:    #2f7ff5;
  --rc-info-100:    #e2edfe;
  --rc-teal-500:    #0ea5a5;
  --rc-teal-100:    #d7f5f3;

  /* Odontogram anatomy */
  --rc-cavity-fill: rgba(20, 20, 43, .35);
  --tooth-enamel-top: #ffffff;
  --tooth-enamel-bottom: #eef0fa;
  --tooth-stroke: #c7cadd;
  --tooth-root-fill: #f1e6c8;
  --tooth-root-stroke: #b8a267;

  /* Gradients */
  --rc-gradient-brand: linear-gradient(135deg, var(--rc-primary-600) 0%, var(--rc-accent-500) 100%);
  --rc-gradient-gold:  linear-gradient(135deg, #f2d888 0%, #d4af37 60%, #b8912a 100%);
  --rc-gradient-mesh: radial-gradient(at 0% 0%, rgba(124,47,224,.14) 0, transparent 50%),
                       radial-gradient(at 100% 0%, rgba(47,127,245,.14) 0, transparent 50%),
                       radial-gradient(at 100% 100%, rgba(16,185,129,.08) 0, transparent 50%);

  /* Light surface system */
  --bg: #f5f6fb;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-2: #fafbff;
  --surface-glass: rgba(255, 255, 255, .68);
  --surface-glass-strong: rgba(255, 255, 255, .86);
  --border: #e7e9f3;
  --border-strong: #d9dcec;
  --text-primary: #12131a;
  --text-secondary: #5a5e72;
  --text-tertiary: #8a8ea3;
  --text-on-brand: #ffffff;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(20, 20, 43, .05);
  --shadow-sm: 0 2px 6px rgba(20, 20, 43, .06), 0 1px 2px rgba(20,20,43,.05);
  --shadow-md: 0 8px 24px rgba(20, 20, 43, .08), 0 2px 6px rgba(20,20,43,.04);
  --shadow-lg: 0 16px 40px rgba(20, 20, 43, .12), 0 4px 12px rgba(20,20,43,.06);
  --shadow-xl: 0 24px 64px rgba(20, 20, 43, .16);
  --shadow-brand-glow: 0 0 0 1px rgba(124,47,224,.08), 0 12px 32px rgba(124,47,224,.28);
  --shadow-gold-glow: 0 0 0 1px rgba(212,175,55,.15), 0 8px 24px rgba(212,175,55,.28);

  /* Radii */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --radius-full: 999px;

  /* Spacing */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-7: 32px; --sp-8: 40px;
  --sp-9: 48px; --sp-10: 64px;

  /* Type */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --text-xs: .75rem;   --text-sm: .8125rem; --text-base: .9375rem;
  --text-md: 1.0625rem; --text-lg: 1.25rem; --text-xl: 1.5rem;
  --text-2xl: 1.875rem; --text-3xl: 2.25rem;

  /* Layout */
  --sidebar-w: 264px;
  --sidebar-w-collapsed: 84px;
  --topbar-h: 72px;
  --bottom-nav-h: 68px;

  /* Motion */
  --ease: cubic-bezier(.22, 1, .36, 1);
  --dur-fast: .15s;
  --dur-med: .28s;
  --dur-slow: .5s;

  color-scheme: light;
}

/* ------------------------------- Dark theme ------------------------------ */
:root[data-theme="dark"] {
  --bg: #0a0b10;
  --bg-elevated: #101219;
  --surface: #12141c;
  --surface-2: #16192280;
  --surface-glass: rgba(22, 24, 33, .62);
  --surface-glass-strong: rgba(22, 24, 33, .86);
  --border: rgba(255,255,255,.08);
  --border-strong: rgba(255,255,255,.14);
  --text-primary: #f4f5f8;
  --text-secondary: #a4a8ba;
  --text-tertiary: #6b7085;

  --rc-cavity-fill: rgba(0,0,0,.45);
  --tooth-enamel-top: #e9ebf5;
  --tooth-enamel-bottom: #c9cce0;
  --tooth-stroke: rgba(255,255,255,.28);
  --tooth-root-fill: #cbb989;
  --tooth-root-stroke: #8f7c46;

  --shadow-xs: 0 1px 2px rgba(0,0,0,.3);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.35);
  --shadow-md: 0 8px 28px rgba(0,0,0,.45);
  --shadow-lg: 0 20px 48px rgba(0,0,0,.55);
  --shadow-xl: 0 28px 72px rgba(0,0,0,.6);

  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0b10;
    --bg-elevated: #101219;
    --surface: #12141c;
    --surface-2: #16192280;
    --surface-glass: rgba(22, 24, 33, .62);
    --surface-glass-strong: rgba(22, 24, 33, .86);
    --border: rgba(255,255,255,.08);
    --border-strong: rgba(255,255,255,.14);
    --text-primary: #f4f5f8;
    --text-secondary: #a4a8ba;
    --text-tertiary: #6b7085;
    --rc-cavity-fill: rgba(0,0,0,.45);
    --tooth-enamel-top: #e9ebf5;
    --tooth-enamel-bottom: #c9cce0;
    --tooth-stroke: rgba(255,255,255,.28);
    --tooth-root-fill: #cbb989;
    --tooth-root-stroke: #8f7c46;
    color-scheme: dark;
  }
}

/* ---------------------------------- Base --------------------------------- */
body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  transition: background var(--dur-med) var(--ease), color var(--dur-med) var(--ease);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: var(--rc-gradient-mesh);
  pointer-events: none;
  z-index: 0;
}
.container { max-width: 1360px; margin-inline: auto; padding-inline: var(--sp-5); }

/* Scrollbar */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--radius-full); }
*::-webkit-scrollbar-track { background: transparent; }

/* Focus ring */
:focus-visible {
  outline: 2px solid var(--rc-primary-500);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------------------------------- Type --------------------------------- */
.eyebrow {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--rc-primary-600);
}
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.h1 { font-size: var(--text-3xl); font-weight: 800; letter-spacing: -.02em; }
.h2 { font-size: var(--text-2xl); font-weight: 800; letter-spacing: -.02em; }
.h3 { font-size: var(--text-xl); font-weight: 700; letter-spacing: -.01em; }
.h4 { font-size: var(--text-md); font-weight: 700; }
.gradient-text {
  background: var(--rc-gradient-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* =========================================================================
   APP SHELL LAYOUT
   ========================================================================= */
.app-shell {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100vh;
}

/* -------------------------------- Sidebar -------------------------------- */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: min(84vw, var(--sidebar-w));
  display: flex;
  flex-direction: column;
  background: var(--surface-glass-strong);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-right: 1px solid var(--border);
  padding: var(--sp-5) var(--sp-4);
  z-index: 50;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform var(--dur-med) var(--ease);
}
.sidebar.is-mobile-open { transform: translateX(0); box-shadow: var(--shadow-xl); }
.sidebar-scrim {
  position: fixed; inset: 0;
  background: rgba(10,10,20,.45);
  backdrop-filter: blur(2px);
  z-index: 45;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-med) var(--ease);
}
.sidebar-scrim.is-visible { opacity: 1; pointer-events: auto; }
@media (min-width: 1024px) {
  .sidebar { display: flex; width: var(--sidebar-w); transform: none; }
  .sidebar-scrim { display: none; }
  .main-wrap { margin-left: var(--sidebar-w); }
  .app-shell.is-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
  .app-shell.is-collapsed .main-wrap { margin-left: var(--sidebar-w-collapsed); }
  /* Collapsing only ever hides labels on desktop — a collapsed preference
     saved from a previous desktop session must never hide labels in the
     mobile drawer, since .app-shell.is-collapsed persists across viewports. */
  .app-shell.is-collapsed .brand-name,
  .app-shell.is-collapsed .nav-label,
  .app-shell.is-collapsed .sidebar-footer-text { display: none; }
  .app-shell.is-collapsed .nav-link .external-link-icon { display: none; }
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-2) var(--sp-6);
}
.brand-mark {
  width: 40px; height: 40px;
  flex: none;
  border-radius: 12px;
  background: var(--rc-gradient-brand);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-brand-glow);
  color: #fff;
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-name { font-weight: 800; font-size: var(--text-md); letter-spacing: -.01em; line-height: 1.1; min-width: 0; overflow: hidden; }
.brand-title { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-name small { display: block; font-weight: 600; font-size: 10px; color: var(--rc-gold-600); letter-spacing: .1em; text-transform: uppercase; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: var(--sp-4) var(--sp-3) var(--sp-2);
}
.nav-list { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 11px var(--sp-3);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: var(--text-sm);
  position: relative;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.nav-link svg { width: 19px; height: 19px; flex: none; }
.nav-link:hover { background: var(--surface-2); color: var(--text-primary); }
.nav-link.is-active {
  background: var(--rc-gradient-brand);
  color: #fff;
  box-shadow: var(--shadow-brand-glow);
}
.nav-link .badge-count {
  margin-left: auto;
  background: var(--rc-danger-500);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-full);
}
.nav-link.is-active .badge-count { background: rgba(255,255,255,.25); }
.nav-link .external-link-icon { margin-left: auto; width: 13px; height: 13px; opacity: .6; flex: none; }
.nav-link.is-active .external-link-icon { opacity: .9; }

.nav-link-form { margin: 0; }
.nav-link-form .nav-link-btn {
  all: unset;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: 11px var(--sp-3);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: var(--text-sm);
  cursor: pointer;
}
.nav-link-form .nav-link-btn:hover { background: var(--surface-2); color: var(--rc-danger-500); }
.nav-link-form .nav-link-btn svg { width: 19px; height: 19px; flex: none; }

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.ai-mini-cta {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border-radius: var(--radius-md);
  background: linear-gradient(160deg, rgba(124,47,224,.12), rgba(47,127,245,.10));
  border: 1px solid rgba(47,127,245,.18);
  margin-bottom: var(--sp-2);
}
.ai-mini-cta .pulse-dot { background: var(--rc-gradient-brand); }
.ai-mini-cta strong { font-size: var(--text-sm); display: block; }
.ai-mini-cta span { font-size: 11px; color: var(--text-tertiary); }

.user-chip {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
}
.user-chip .avatar { width: 36px; height: 36px; }
.user-chip .who { line-height: 1.2; overflow: hidden; }
.user-chip .who strong { display: block; font-size: var(--text-sm); white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.user-chip .who span { font-size: 11px; color: var(--text-tertiary); }
.user-chip .icon-btn { margin-left: auto; }

/* ------------------------------- Main / Topbar ---------------------------- */
.main-wrap { flex: 1; min-width: 0; position: relative; z-index: 1; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-2) var(--sp-5);
  background: var(--surface-glass);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border-bottom: 1px solid var(--border);
}
/* min-height (not height): a long title/breadcrumb that can't fit on one
   line even after truncation (e.g. a very narrow phone, or the browser's
   text-size setting bumped up) grows the bar instead of getting vertically
   centered past its fixed bounds — which used to clip the top and bottom
   of the text right off, not just look cramped. */
.topbar-title { display: flex; flex-direction: column; gap: 3px; min-width: 0; overflow: hidden; }
.topbar-title h1 { font-size: var(--text-lg); font-weight: 800; letter-spacing: -.01em; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title .breadcrumb { font-size: 12px; color: var(--text-tertiary); line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.topbar-search {
  flex: 1;
  max-width: 420px;
  display: none;
}
@media (min-width: 768px) { .topbar-search { display: flex; } }
.topbar-actions { display: flex; align-items: center; gap: var(--sp-2); margin-left: auto; }
.hamburger-btn { display: inline-flex; }
@media (min-width: 1024px) { .hamburger-btn { display: none; } }
.sidebar-collapse-btn { display: none; }
@media (min-width: 1024px) { .sidebar-collapse-btn { display: inline-flex; } }

.content {
  padding: var(--sp-5) var(--sp-5) calc(var(--bottom-nav-h) + var(--sp-7));
  max-width: 1360px;
  margin: 0 auto;
}
@media (min-width: 1024px) {
  .content { padding: var(--sp-7) var(--sp-7) var(--sp-9); }
}

/* -------------------------------- Bottom nav ------------------------------ */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: var(--bottom-nav-h);
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  background: var(--surface-glass-strong);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-top: 1px solid var(--border);
  z-index: 40;
  padding-bottom: env(safe-area-inset-bottom);
}
@media (min-width: 1024px) { .bottom-nav { display: none; } }
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-tertiary);
  position: relative;
}
.bottom-nav a svg { width: 21px; height: 21px; }
.bottom-nav a.is-active { color: var(--rc-primary-600); }
.bottom-nav a.is-active .bn-icon-wrap {
  background: var(--rc-primary-50);
}
:root[data-theme="dark"] .bottom-nav a.is-active .bn-icon-wrap { background: rgba(124,47,224,.18); }
.bn-icon-wrap { width: 34px; height: 26px; border-radius: 10px; display: flex; align-items: center; justify-content: center; transition: background var(--dur-fast) var(--ease); }
.bottom-nav .bn-fab {
  width: 52px; height: 52px;
  border-radius: var(--radius-full);
  background: var(--rc-gradient-brand);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  margin-top: -22px;
  box-shadow: var(--shadow-brand-glow);
  flex: none;
  align-self: center;
}
.bottom-nav .bn-fab svg { width: 24px; height: 24px; }

/* =========================================================================
   PRIMITIVES
   ========================================================================= */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 42px;
  padding: 0 var(--sp-5);
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: var(--text-sm);
  border: 1px solid transparent;
  white-space: nowrap;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.btn svg { width: 17px; height: 17px; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn-sm { height: 34px; padding: 0 var(--sp-4); font-size: var(--text-xs); border-radius: 9px; }
.btn-lg { height: 50px; padding: 0 var(--sp-7); font-size: var(--text-base); border-radius: var(--radius-md); }
.btn-block { width: 100%; }

.btn-primary {
  background: var(--rc-gradient-brand);
  color: #fff;
  box-shadow: var(--shadow-brand-glow);
}
.btn-primary:hover { box-shadow: 0 0 0 1px rgba(124,47,224,.1), 0 16px 40px rgba(124,47,224,.36); }

.btn-gold {
  background: var(--rc-gradient-gold);
  color: #3a2c02;
  box-shadow: var(--shadow-gold-glow);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { background: var(--surface-2); border-color: var(--rc-primary-300); }

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text-primary); }

.btn-danger-ghost { background: transparent; color: var(--rc-danger-500); }
.btn-danger-ghost:hover { background: var(--rc-danger-100); }

.icon-btn {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  position: relative;
  flex: none;
}
.icon-btn:hover { color: var(--text-primary); border-color: var(--border-strong); background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .dot-flag {
  position: absolute; top: 7px; right: 7px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--rc-danger-500);
  border: 2px solid var(--surface);
}

/* Inputs */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: var(--text-xs); font-weight: 700; color: var(--text-secondary); }
.input, .select, textarea.input {
  height: 44px;
  padding: 0 var(--sp-4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-primary);
  font-size: var(--text-sm);
  width: 100%;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
textarea.input { height: auto; padding: var(--sp-3) var(--sp-4); resize: vertical; min-height: 90px; }
.input::placeholder { color: var(--text-tertiary); }
.input:focus, .select:focus, textarea.input:focus {
  outline: none;
  border-color: var(--rc-primary-400);
  box-shadow: 0 0 0 4px var(--rc-primary-100);
}
.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-left: 42px; }
.input-group .input-icon {
  position: absolute; left: 14px; width: 18px; height: 18px; color: var(--text-tertiary); pointer-events: none;
}
.search-bar { position: relative; width: 100%; }
.search-bar input { border-radius: var(--radius-full); background: var(--surface-2); border-color: var(--border); }
.search-bar .input-icon {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--text-tertiary); pointer-events: none;
}
.search-bar .input { padding-left: 44px; height: 42px; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: var(--sp-5); }
.card-glass {
  background: var(--surface-glass);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.card-hover { transition: transform var(--dur-med) var(--ease), box-shadow var(--dur-med) var(--ease); }
.card-hover:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

/* Grid helpers */
.grid { display: grid; gap: var(--sp-5); }
.grid-2 { grid-template-columns: repeat(1, 1fr); }
.grid-3 { grid-template-columns: repeat(1, 1fr); }
.grid-4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 768px) { .grid-2 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .grid-4 { grid-template-columns: repeat(4, 1fr); } }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--sp-1);} .gap-2 { gap: var(--sp-2);} .gap-3 { gap: var(--sp-3);} .gap-4 { gap: var(--sp-4);} .gap-5 { gap: var(--sp-5);}
.section { margin-bottom: var(--sp-7); }
@media (min-width: 1100px) { .dash-grid { grid-template-columns: minmax(0,1fr) 460px !important; align-items: start; } }
@media (min-width: 1500px) { .dash-grid { grid-template-columns: minmax(0,1fr) 520px !important; } }
@media (min-width: 1100px) { .charting-grid { grid-template-columns: minmax(0,1fr) 340px !important; align-items: start; } }
@media (min-width: 1024px) { .ai-grid { grid-template-columns: 300px minmax(0,1fr) !important; } }
.dash-grid > div > .section:last-child, .dash-grid > div > .card:last-child { margin-bottom: 0; }

/* KPI cards */
.kpi-card {
  padding: var(--sp-5);
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform var(--dur-med) var(--ease), box-shadow var(--dur-med) var(--ease);
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.kpi-card::after {
  content: "";
  position: absolute; inset: 0;
  background: var(--kpi-accent, var(--rc-gradient-brand));
  opacity: .06;
  pointer-events: none;
}
.kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-4); position: relative; }
.kpi-icon {
  width: 42px; height: 42px;
  border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  background: var(--kpi-accent, var(--rc-gradient-brand));
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.kpi-icon svg { width: 21px; height: 21px; }
.kpi-value { font-size: var(--text-2xl); font-weight: 800; letter-spacing: -.02em; position: relative; overflow-wrap: break-word; }
.kpi-label { font-size: var(--text-xs); font-weight: 700; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .04em; margin-top: 2px; position: relative; }
.kpi-delta { display: inline-flex; align-items: center; gap: 4px; font-size: var(--text-xs); font-weight: 700; padding: 3px 8px; border-radius: var(--radius-full); margin-top: var(--sp-3); }
.kpi-delta.up { color: var(--rc-success-500); background: var(--rc-success-100); }
.kpi-delta.down { color: var(--rc-danger-500); background: var(--rc-danger-100); }
.kpi-delta svg { width: 12px; height: 12px; }

/* Badges / pills */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  white-space: nowrap;
  line-height: 1.4;
}
.badge svg { width: 11px; height: 11px; }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--rc-success-100); color: #067a55; }
.badge-warning { background: var(--rc-warning-100); color: #9a6400; }
.badge-danger  { background: var(--rc-danger-100); color: #c0272e; }
.badge-info    { background: var(--rc-info-100); color: #0369a1; }
.badge-neutral { background: var(--surface-2); color: var(--text-secondary); border: 1px solid var(--border); }
.badge-gold    { background: linear-gradient(135deg, #fdf3d8, #f2e0a8); color: #7a5c05; }
.badge-brand   { background: var(--rc-primary-50); color: var(--rc-primary-700); }
:root[data-theme="dark"] .badge-success { background: rgba(16,185,129,.15); color: #34d399; }
:root[data-theme="dark"] .badge-warning { background: rgba(245,158,11,.15); color: #fbbf24; }
:root[data-theme="dark"] .badge-danger  { background: rgba(255,92,92,.18); color: #ff8f8f; }
:root[data-theme="dark"] .badge-info    { background: rgba(47,127,245,.18); color: #8fc7ff; }
:root[data-theme="dark"] .badge-brand   { background: rgba(124,47,224,.18); color: #d6c0ff; }
:root[data-theme="dark"] .badge-gold    { background: rgba(212,175,55,.15); color: #e6c35e; }

/* Avatars */
.avatar {
  width: 44px; height: 44px;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: var(--text-sm);
  color: #fff;
  background: var(--rc-gradient-brand);
  flex: none;
  position: relative;
}
.avatar-photo { padding: 0; overflow: hidden; }
.avatar-photo img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.avatar-sm { width: 34px; height: 34px; font-size: var(--text-xs); }
.avatar-lg { width: 72px; height: 72px; font-size: var(--text-lg); }
.avatar-xl { width: 96px; height: 96px; font-size: var(--text-2xl); border: 4px solid var(--surface); box-shadow: var(--shadow-md); }
.avatar-status {
  position: absolute; right: -2px; bottom: -2px;
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--surface);
  background: var(--rc-success-500);
}

/* Pulse dot (AI / live indicators) */
.pulse-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--rc-success-500);
  position: relative; flex: none;
}
.pulse-dot::after {
  content: ""; position: absolute; inset: -4px;
  border-radius: 50%; background: inherit; opacity: .4;
  animation: pulse-ring 2s var(--ease) infinite;
}
@keyframes pulse-ring { 0% { transform: scale(.7); opacity: .5; } 100% { transform: scale(2.1); opacity: 0; } }

/* Tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--surface); }
table.rc-table { width: 100%; border-collapse: collapse; min-width: 640px; }
table.rc-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-tertiary); font-weight: 700; padding: var(--sp-4) var(--sp-4);
  border-bottom: 1px solid var(--border); background: var(--surface-2);
  position: sticky; top: 0;
}
table.rc-table td { padding: var(--sp-4); border-bottom: 1px solid var(--border); font-size: var(--text-sm); vertical-align: middle; }
table.rc-table tbody tr { transition: background var(--dur-fast) var(--ease); }
table.rc-table tbody tr:hover { background: var(--surface-2); }
table.rc-table tbody tr:last-child td { border-bottom: none; }

/* In-app User Guide content (aihelper/guides.py, rendered via |safe) */
.guide-body p { color: var(--text-secondary); line-height: 1.7; margin-bottom: var(--sp-3); }
.guide-body p:last-child { margin-bottom: 0; }
.guide-body ul, .guide-body ol { color: var(--text-secondary); line-height: 1.7; padding-left: 1.3em; margin-bottom: var(--sp-3); }
.guide-body ul { list-style: disc; }
.guide-body ol { list-style: decimal; }
.guide-body li { margin-bottom: var(--sp-2); }
.guide-body li:last-child { margin-bottom: 0; }
.guide-body .table-wrap { margin: var(--sp-3) 0; }
.guide-body strong { color: var(--text-primary); }

/* Tabs */
.tabs { display: flex; gap: var(--sp-2); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab-btn {
  padding: var(--sp-3) var(--sp-2);
  font-weight: 700; font-size: var(--text-sm);
  color: var(--text-tertiary);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  margin-bottom: -1px;
}
.tab-btn.is-active { color: var(--rc-primary-600); border-color: var(--rc-primary-600); }
.tab-btn:hover:not(.is-active) { color: var(--text-primary); }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; animation: fade-in var(--dur-med) var(--ease); }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Segmented control */
.segmented { display: inline-flex; padding: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); gap: 2px; }
.segmented button { padding: 7px 14px; font-size: var(--text-xs); font-weight: 700; border-radius: 8px; color: var(--text-secondary); }
.segmented button.is-active { background: var(--surface); color: var(--rc-primary-700); box-shadow: var(--shadow-xs); }

/* Progress bar */
.progress { height: 8px; border-radius: var(--radius-full); background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--rc-gradient-brand); }

/* Divider */
.divider { height: 1px; background: var(--border); border: none; margin: var(--sp-5) 0; }

/* Empty state */
.empty-state { text-align: center; padding: var(--sp-9) var(--sp-5); color: var(--text-tertiary); }
.empty-state .icon-wrap { width: 64px; height: 64px; margin: 0 auto var(--sp-4); border-radius: var(--radius-lg); background: var(--surface-2); display: flex; align-items: center; justify-content: center; color: var(--text-tertiary); }

/* Tooltip-ish helper text */
.hint { font-size: 12px; color: var(--text-tertiary); }

/* =========================================================================
   PATIENT / APPOINTMENT / CHARTING / BILLING / AI SPECIFIC COMPONENTS
   ========================================================================= */

/* Patient card */
.patient-card {
  display: flex; flex-direction: column; gap: var(--sp-4);
  padding: var(--sp-5);
}
.patient-card-head { display: flex; align-items: center; gap: var(--sp-3); }
.patient-card-head .info { min-width: 0; }
.patient-card-head .info strong { display: block; font-size: var(--text-base); font-weight: 700; }
.patient-card-head .info span { font-size: 12px; color: var(--text-tertiary); }
.patient-meta-row { display: flex; flex-wrap: wrap; gap: var(--sp-4); font-size: 12px; color: var(--text-secondary); }
.patient-meta-row div { display: flex; align-items: center; gap: 6px; }
.patient-meta-row svg { width: 14px; height: 14px; color: var(--text-tertiary); }

/* Appointment timeline */
.timeline { display: flex; flex-direction: column; }
.timeline-item {
  display: flex; gap: var(--sp-4);
  padding: var(--sp-4) 0;
  border-bottom: 1px solid var(--border);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-time { width: 68px; flex: none; text-align: right; padding-top: 2px; }
.timeline-time strong { display: block; font-size: var(--text-sm); font-weight: 800; }
.timeline-time span { font-size: 11px; color: var(--text-tertiary); }
.timeline-rail { display: flex; flex-direction: column; align-items: center; flex: none; }
.timeline-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--rc-primary-500); border: 3px solid var(--rc-primary-100); margin-top: 4px; }
.timeline-line { flex: 1; width: 2px; background: var(--border); margin: 4px 0; }
.timeline-item:last-child .timeline-line { display: none; }
.timeline-card { flex: 1; padding: var(--sp-4); border-radius: var(--radius-md); background: var(--surface-2); border: 1px solid var(--border); }
.timeline-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); }
.timeline-card strong { font-size: var(--text-sm); font-weight: 700; }
.timeline-card .meta { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }
.timeline-card .chip-row { display: flex; gap: var(--sp-2); margin-top: var(--sp-3); flex-wrap: wrap; }

/* Calendar (week view) */
.calendar {
  display: grid;
  grid-template-columns: 56px repeat(7, minmax(120px, 1fr));
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.calendar-head { display: contents; }
.calendar-head-cell {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2);
  padding: var(--sp-3) var(--sp-2);
  text-align: center;
  border-bottom: 1px solid var(--border);
  border-left: 1px solid var(--border);
}
.calendar-head-cell:first-child { border-left: none; }
.calendar-head-cell strong { display: block; font-size: var(--text-sm); font-weight: 800; }
.calendar-head-cell span { font-size: 11px; color: var(--text-tertiary); }
.calendar-head-cell.is-today strong { color: var(--rc-primary-600); }
.calendar-time-col { display: flex; flex-direction: column; }
.calendar-time-cell { height: 64px; font-size: 10px; color: var(--text-tertiary); text-align: right; padding-right: 6px; padding-top: 2px; border-top: 1px solid var(--border); }
.calendar-day-col { position: relative; border-left: 1px solid var(--border); display: flex; flex-direction: column; }
.calendar-slot { height: 64px; border-top: 1px solid var(--border); }
.calendar-event {
  position: absolute;
  left: 4px; right: 4px;
  border-radius: 10px;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--rc-gradient-brand);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  border: 1px solid rgba(255,255,255,.2);
}
.calendar-event span { display: block; font-weight: 500; opacity: .85; font-size: 10px; }
.calendar-event.tone-gold { background: var(--rc-gradient-gold); color: #4a3400; }
.calendar-event.tone-cyan { background: linear-gradient(135deg,#5aa5ff,#2f7ff5); }
.calendar-event.tone-danger { background: linear-gradient(135deg,#ff8f8f,#ff5c5c); }
.calendar-event.tone-neutral { background: var(--surface); color: var(--text-primary); border: 1px dashed var(--border-strong); box-shadow: none; }

/* Odontogram preview widget (compact box-tooth version — used by patient-profile
   and design-system pages; the full Charting page uses the SVG odontogram below) */
.odontogram-arch { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.tooth {
  width: 34px; height: 44px;
  border-radius: 8px 8px 14px 14px;
  border: 2px solid var(--border-strong);
  background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  font-size: 9px; font-weight: 700; color: var(--text-tertiary);
  position: relative;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  padding-bottom: 3px;
}
.tooth:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); cursor: pointer; }
.tooth.upper { border-radius: 14px 14px 8px 8px; justify-content: flex-start; padding-bottom: 0; padding-top: 3px; }
.tooth.missing { opacity: .3; border-style: dashed; }
.tooth.condition-caries { background: var(--rc-danger-100); border-color: var(--rc-danger-500); color: #b91c1c; }
.tooth.condition-filled { background: var(--rc-info-100); border-color: var(--rc-info-500); color: #0369a1; }
.tooth.condition-crown { background: linear-gradient(160deg,#fdf3d8,#f2e0a8); border-color: var(--rc-gold-500); color: #7a5c05; }
.tooth.condition-watch { background: var(--rc-warning-100); border-color: var(--rc-warning-500); color: #9a6400; }
.tooth.condition-healthy { background: var(--rc-success-100); border-color: var(--rc-success-500); color: #067a55; }
.tooth.is-selected { outline: 3px solid var(--rc-primary-500); outline-offset: 2px; }

/* Odontogram (Charting page) — the reference odontogram artwork
   (static/img/odontogram_target.png) is the visible chart, with
   transparent hotspot buttons layered on top at percentage positions (see
   royal.js's HOTSPOT_POSITIONS/buildHotspot) so hit areas track the image
   at any rendered size, plus a 2D List View toggle (tap-sized rows, small
   per-tooth SVG icons) for accessibility/quick access. No external CDN
   assets, no canvas/WebGL/Three.js. */
.odontogram-layout { display: grid; grid-template-columns: minmax(0,1fr) 240px; gap: var(--sp-5); align-items: start; }
.odontogram { display: flex; flex-direction: column; gap: var(--sp-4); min-width: 0; }

.odontogram-full { display: flex; flex-direction: column; gap: var(--sp-4); min-width: 0; }
.odontogram-3d-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }

.odontogram-chart-holder {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  padding: var(--sp-4) var(--sp-3);
}
.odontogram-chart-holder-zoom { max-height: 80vh; overflow-y: auto; }

/* The frame is the positioning context for the hotspot layer — it scales
   to the holder's width, and the layer/hotspots scale with it via
   percentage left/top/width/height (see HOTSPOT_POSITIONS), so hit areas
   never drift off the art at any container size. */
.odontogram-image-frame { position: relative; width: 100%; max-width: 900px; margin: 0 auto; }
.odontogram-target-img {
  display: block; width: 100%; height: auto;
  border-radius: var(--radius-sm);
  -webkit-user-select: none; user-select: none;
}
.odontogram-hotspot-layer { position: absolute; inset: 0; }

.odontogram-hotspot {
  position: absolute;
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 0;
  margin: 0;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.odontogram-hotspot:hover { background: rgba(139,63,239,.12); }
.odontogram-hotspot:focus-visible { box-shadow: inset 0 0 0 2px var(--rc-primary-500); }
.odontogram-hotspot.is-selected {
  background: rgba(139,63,239,.16);
  box-shadow: inset 0 0 0 2px var(--rc-primary-500), 0 0 0 3px rgba(139,63,239,.25);
}
/* Missing tooth: dashed outline instead of a condition badge — nothing to
   annotate on an absent tooth beyond "not there". */
.odontogram-hotspot.state-missing { border: 2px dashed var(--border-strong); opacity: .8; }

.odontogram-hotspot-badge.badge {
  position: absolute;
  top: -6px; right: -6px;
  min-width: 18px; height: 18px;
  padding: 0 4px;
  font-size: 9px;
  line-height: 18px;
  display: block;
  text-align: center;
  border-radius: var(--radius-full);
  box-shadow: 0 0 0 2px var(--surface);
  pointer-events: none;
}

.tooth-shape {
  stroke: var(--tooth-stroke);
  stroke-width: 1.5;
  filter: drop-shadow(0 1.5px 2px rgba(20,20,43,.22));
  transition: stroke-width var(--dur-fast) var(--ease), filter var(--dur-fast) var(--ease);
}
/* Root always keeps its own natural dentin/ivory tone, regardless of the
   crown's condition colour (a decayed tooth's root shouldn't turn red) —
   see royal.js's buildCompactChip. */
.tooth-root-shape { fill: var(--tooth-root-fill); stroke: var(--tooth-root-stroke); stroke-width: 1.2; }

.tooth-shape.state-healthy    { fill: var(--tooth-enamel-top); stroke: var(--tooth-stroke); }
.tooth-shape.state-filled     { fill: var(--rc-info-100); stroke: var(--rc-info-500); }
.tooth-shape.state-crown      { fill: var(--rc-gold-400); stroke: var(--rc-gold-500); }
.tooth-shape.state-caries     { fill: var(--rc-danger-100); stroke: var(--rc-danger-500); }
.tooth-shape.state-watch      { fill: var(--rc-warning-100); stroke: var(--rc-warning-500); }
.tooth-shape.state-existing   { fill: var(--rc-teal-100); stroke: var(--rc-teal-500); }
.tooth-shape.state-planned    { fill: var(--rc-primary-100); stroke: var(--rc-primary-500); stroke-dasharray: 3 2; }
.tooth-shape.state-missing    { fill: transparent; stroke: var(--border-strong); stroke-dasharray: 3 3; opacity: .4; }
.tooth-shape.state-bridge     { fill: var(--rc-gold-300); stroke: var(--rc-gold-600); }
.tooth-shape.state-root_canal { fill: var(--rc-primary-100); stroke: var(--rc-primary-500); }
.tooth-shape.state-implant    { fill: #eef0f5; stroke: #b8bcc8; }
.tooth-shape.state-extraction { fill: var(--rc-danger-100); stroke: #b91c1c; stroke-dasharray: 2 2; }
.tooth-shape.state-fractured  { fill: var(--rc-danger-100); stroke: #c2410c; }
.tooth-shape.state-wear       { fill: #ece3cd; stroke: #b8a06a; }
.tooth-shape.state-sealant    { fill: var(--rc-teal-100); stroke: var(--rc-teal-500); }
.tooth-shape.state-perio      { fill: var(--rc-warning-100); stroke: #92400e; }

/* List View toggle: swaps which of the two views is visible, at every
   viewport width (see the data-view-toggle segmented control + royal.js). */
.odontogram-view-list .odontogram-full { display: none; }
.odontogram-view-list .odontogram-compact { display: flex !important; }

.odontogram-legend { display: flex; gap: var(--sp-4); flex-wrap: wrap; justify-content: center; font-size: 12px; color: var(--text-secondary); }
.odontogram-legend div { display: flex; align-items: center; gap: 6px; }
.legend-swatch { width: 12px; height: 12px; border-radius: 4px; border: 1.5px solid; }
.odontogram-legend-compact { justify-content: flex-start; gap: var(--sp-3) var(--sp-4); }

/* Compact odontogram: List View only (see .odontogram-view-list below).
   Tap-sized teeth in two horizontal-scroll rows instead of one large mouth
   graphic — each tooth is its own small inline SVG so it stays lightweight
   at any zoom level. Hidden by default at every viewport width so it never
   doubles up with the full chart underneath it. */
.odontogram-compact { display: none; flex-direction: column; gap: var(--sp-3); min-width: 0; }

.odontogram-compact-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }

.compact-arch-row { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.compact-arch-label {
  flex-shrink: 0; writing-mode: horizontal-tb;
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-tertiary); width: 44px;
}
.compact-scroll {
  display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity;
  padding: 6px 4px 10px; min-width: 0; flex: 1;
  -webkit-overflow-scrolling: touch;
}
.tooth-chip {
  scroll-snap-align: start;
  flex-shrink: 0;
  width: 56px; height: 92px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  outline: none;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.tooth-chip svg { width: 34px; height: 68px; overflow: visible; }
.tooth-chip .tooth-root-shape { stroke-width: 1; }
.tooth-chip-bg { fill: var(--rc-cavity-fill); }
.tooth-chip .tooth-chip-number { font-size: 10px; font-weight: 700; color: var(--text-secondary); }
.tooth-chip:hover,
.tooth-chip:focus-visible { border-color: var(--rc-primary-400); }
.tooth-chip.is-selected {
  border-color: var(--rc-primary-500);
  box-shadow: 0 0 0 2px rgba(139,63,239,.25);
}

/* Zoom Chart modal: the chart <svg> is re-parented here at a larger size
   (see royal.js's wireZoomChart) rather than duplicating a second render. */
.modal-zoom { max-width: 720px; }

/* Tooth bottom sheet (mobile tap target) */
/* Condition button grid — replaces a plain <select>/text-button list with
   large, touch-friendly, colour-coded + icon buttons (shared markup between
   the desktop tooth-detail panel and the mobile tooth sheet). */
.condition-button-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: var(--sp-2); }
.condition-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 56px;
  padding: var(--sp-2) 6px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 11px; font-weight: 600; line-height: 1.15; text-align: center;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
              background var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.condition-btn svg { flex-shrink: 0; }
.condition-btn:hover { transform: translateY(-1px); border-color: var(--accent, var(--rc-primary-400)); box-shadow: var(--shadow-xs); color: var(--accent, var(--text-primary)); }
.condition-btn:focus-visible { outline: 2px solid var(--rc-primary-500); outline-offset: 2px; }
.condition-btn.is-active { background: var(--accent, var(--rc-primary-600)); border-color: var(--accent, var(--rc-primary-600)); color: #fff; box-shadow: var(--shadow-sm); }

.condition-btn[data-condition="healthy"]             { --accent: var(--rc-success-500); }
.condition-btn[data-condition="watch"]               { --accent: var(--rc-warning-500); }
.condition-btn[data-condition="decay"]               { --accent: var(--rc-danger-500); }
.condition-btn[data-condition="filled"]              { --accent: var(--rc-info-500); }
.condition-btn[data-condition="crown"]               { --accent: var(--rc-gold-600); }
.condition-btn[data-condition="bridge"]              { --accent: var(--rc-gold-600); }
.condition-btn[data-condition="root_canal"]          { --accent: var(--rc-primary-500); }
.condition-btn[data-condition="sealant"]             { --accent: var(--rc-teal-500); }
.condition-btn[data-condition="implant"]             { --accent: #6b7386; }
.condition-btn[data-condition="missing"]             { --accent: var(--text-tertiary); }
.condition-btn[data-condition="extraction_required"] { --accent: #b91c1c; }
.condition-btn[data-condition="fractured"]           { --accent: #c2410c; }
.condition-btn[data-condition="wear"]                { --accent: #96813f; }
.condition-btn[data-condition="perio"]               { --accent: #92400e; }

/* Tooth surface picker — a 5-region cross layout (Buccal/Facial top,
   Lingual bottom, Mesial/Distal sides, Occlusal/Incisal centre) wired to
   ToothCondition.surface (see royal.js's buildSurfaceMap). Clicking the
   already-active region clears it back to "whole tooth". */
.surface-map {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  grid-template-areas: ".    top    ." "left center right" ".    bottom .";
  gap: 3px;
  width: 132px; height: 132px;
  margin: 0 auto;
}
.surface-btn {
  display: flex; align-items: center; justify-content: center;
  font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .02em;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text-tertiary);
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.surface-btn:hover { border-color: var(--rc-primary-400); color: var(--rc-primary-600); background: var(--rc-primary-50); }
.surface-btn:focus-visible { outline: 2px solid var(--rc-primary-500); outline-offset: 1px; }
.surface-btn.is-active { background: var(--rc-primary-600); border-color: var(--rc-primary-600); color: #fff; }

/* Tooth detail side panel */
.tooth-detail-panel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  min-height: 240px;
}
.tooth-detail-empty { flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; min-height: 200px; }
.tooth-detail-head { display: flex; align-items: center; gap: var(--sp-3); }
.tooth-detail-number {
  width: 44px; height: 44px; flex-shrink: 0;
  border-radius: var(--radius-md);
  background: var(--rc-gradient-brand);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: var(--text-lg);
}
.tooth-detail-name { font-weight: 700; font-size: var(--text-sm); margin-bottom: 4px; }
.tooth-detail-section h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-tertiary); margin-bottom: var(--sp-2); }
.tooth-detail-section ul { display: flex; flex-direction: column; gap: 6px; }
.tooth-detail-section li { font-size: var(--text-sm); color: var(--text-secondary); padding-left: var(--sp-3); position: relative; }
.tooth-detail-section li::before { content: ""; position: absolute; left: 0; top: 7px; width: 5px; height: 5px; border-radius: 50%; background: var(--rc-primary-400); }
.tooth-detail-planned { font-size: var(--text-sm); color: var(--text-secondary); }

@media (max-width: 860px) {
  .odontogram-layout { grid-template-columns: 1fr; }
  .tooth-detail-panel { min-height: 0; }
}
/* Below 768px, tapping a tooth opens the bottom sheet (see royal.js's
   openToothSheet) instead of the desktop side panel, so hide the panel to
   avoid two competing tooth-detail UIs. */
@media (max-width: 767px) {
  .tooth-detail-panel { display: none; }
}

/* Narrow-phone tightening (390-430px target widths) — smaller condition/
   surface controls so the button grid and legend never force horizontal
   scroll next to the card's own padding. */
@media (max-width: 430px) {
  .condition-button-grid { grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 6px; }
  .condition-btn { min-height: 50px; font-size: 10px; padding: 6px 4px; }
  .surface-map { width: 116px; height: 116px; }
  .odontogram-legend { gap: var(--sp-3); font-size: 11px; }
}

/* High-contrast preference: swap the colour-only "is-active" fill for a
   thicker, always-legible border + underline instead of relying on the
   --accent background colour alone to signal selection (WCAG 1.4.1). */
@media (prefers-contrast: more) {
  .condition-btn { border-width: 2px; }
  .condition-btn.is-active { background: var(--surface); color: var(--text-primary); border-color: var(--accent, var(--rc-primary-600)); border-width: 3px; text-decoration: underline; }
  .surface-btn.is-active { background: var(--surface); color: var(--rc-primary-700); border-color: var(--rc-primary-600); border-width: 3px; }
  .tooth-shape { stroke-width: 2.2; }
}

/* Billing / invoice card */
.invoice-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
}
@media (min-width: 768px) {
  .invoice-row { grid-template-columns: 2fr 1fr 1fr 1fr auto; align-items: center; gap: var(--sp-4); }
}

/* AI panel */
.ai-panel {
  border-radius: var(--radius-lg);
  background: linear-gradient(165deg, rgba(124,47,224,.06), rgba(47,127,245,.03));
  border: 1px solid rgba(47,127,245,.16);
  box-shadow: var(--shadow-md);
  padding: var(--sp-5);
  position: relative;
  overflow: hidden;
}
.ai-panel::before {
  content: "";
  position: absolute; top: -60px; right: -60px;
  width: 200px; height: 200px; border-radius: 50%;
  background: var(--rc-gradient-brand); opacity: .12; filter: blur(10px);
}
.ai-panel-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); position: relative; }
.ai-avatar {
  width: 42px; height: 42px; border-radius: 14px;
  background: var(--rc-gradient-brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-brand-glow);
  flex: none;
}
.ai-avatar svg { width: 22px; height: 22px; }
.ai-insight-item {
  display: flex; gap: var(--sp-3);
  padding: var(--sp-3);
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: var(--sp-3);
  position: relative;
}
.ai-insight-item:last-child { margin-bottom: 0; }
.ai-insight-item .ai-ico { width: 32px; height: 32px; border-radius: 10px; flex: none; display: flex; align-items: center; justify-content: center; }
.ai-insight-item .ai-ico svg { width: 16px; height: 16px; }

/* Chat */
.chat-scroll { display: flex; flex-direction: column; gap: var(--sp-4); }
.chat-msg { display: flex; gap: var(--sp-3); max-width: 78%; }
.chat-msg.from-user { margin-left: auto; flex-direction: row-reverse; }
.chat-bubble {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  line-height: 1.55;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.chat-msg.from-user .chat-bubble { background: var(--rc-gradient-brand); color: #fff; border: none; }
.chat-msg.from-ai .chat-bubble { border-top-left-radius: 4px; }
.chat-msg.from-user .chat-bubble { border-top-right-radius: 4px; }
.chat-avatar { width: 32px; height: 32px; border-radius: 10px; flex: none; }
.chat-suggestions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chip-suggestion {
  font-size: 12.5px; font-weight: 600; padding: 8px 14px; border-radius: var(--radius-full);
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text-secondary);
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.chip-suggestion:hover { background: var(--rc-primary-50); border-color: var(--rc-primary-300); color: var(--rc-primary-700); }
.typing-dots { display: inline-flex; gap: 3px; align-items: center; padding: 4px 0; }
.typing-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-tertiary); animation: typing-bounce 1.2s infinite ease-in-out; }
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes typing-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

.chat-input-bar {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2);
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.chat-input-bar input { flex: 1; border: none; background: transparent; height: 40px; padding: 0 var(--sp-3); font-size: var(--text-sm); }
.chat-input-bar input:focus { outline: none; }
.chat-input-bar .btn { border-radius: var(--radius-full); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(10,10,20,.45);
  backdrop-filter: blur(3px);
  display: none; align-items: flex-end; justify-content: center;
  z-index: 100; padding: 0;
}
.modal-overlay.is-open { display: flex; animation: fade-in var(--dur-fast) var(--ease); }
@media (min-width: 768px) { .modal-overlay { align-items: center; padding: var(--sp-5); } }
.modal {
  background: var(--surface); width: 100%; max-width: 520px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  max-height: 88vh; overflow-y: auto;
  padding: var(--sp-6);
}
@media (min-width: 768px) { .modal { border-radius: var(--radius-lg); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-5); }

/* Toast */
.toast-stack { position: fixed; bottom: calc(var(--bottom-nav-h) + var(--sp-4)); left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: var(--sp-2); width: min(92vw, 380px); }
@media (min-width: 1024px) { .toast-stack { bottom: var(--sp-5); left: auto; right: var(--sp-5); transform: none; } }
.toast {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  background: var(--surface-glass-strong);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm); font-weight: 600;
  animation: toast-in var(--dur-med) var(--ease);
}
.toast-error { border-color: var(--rc-danger-500); background: var(--rc-danger-100); color: var(--rc-danger-500); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: center; gap: var(--sp-4); padding: var(--sp-4) 0; }
.pagination .is-disabled { opacity: .45; pointer-events: none; }
.pagination-status { white-space: nowrap; }

/* Utility visibility */
.hide-mobile { display: none; }
@media (min-width: 768px) { .hide-mobile { display: revert; } }
.hide-desktop { }
@media (min-width: 1024px) { .hide-desktop { display: none !important; } }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.mt-1{margin-top:var(--sp-1)} .mt-2{margin-top:var(--sp-2)} .mt-3{margin-top:var(--sp-3)} .mt-4{margin-top:var(--sp-4)} .mt-5{margin-top:var(--sp-5)} .mt-6{margin-top:var(--sp-6)} .mt-7{margin-top:var(--sp-7)}
.mb-1{margin-bottom:var(--sp-1)} .mb-2{margin-bottom:var(--sp-2)} .mb-3{margin-bottom:var(--sp-3)} .mb-4{margin-bottom:var(--sp-4)} .mb-5{margin-bottom:var(--sp-5)} .mb-6{margin-bottom:var(--sp-6)}
.w-full { width: 100%; }
.rounded-full { border-radius: var(--radius-full); }
.text-center { text-align: center; }

/* =========================================================================
   v2 — AI-FIRST COMPONENTS (Copilot centerpiece, NL search, activity feed,
   dental procedure strip, chair utilisation, skeletons, floating AI widget)
   ========================================================================= */

/* ---------------------------- Greeting hero ------------------------------ */
.greeting-hero { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: var(--sp-4); }
.greeting-hero h1 { font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 800; letter-spacing: -.02em; }
.greeting-hero .sub { color: var(--text-secondary); font-size: var(--text-sm); margin-top: 4px; }
.greeting-status { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: var(--rc-success-500); background: var(--rc-success-100); padding: 6px 12px; border-radius: var(--radius-full); }

/* ------------------------------- KPI row ---------------------------------- */
.kpi-row { display: grid; grid-template-columns: repeat(1, 1fr); gap: var(--sp-4); }
@media (min-width: 420px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 640px) { .kpi-row { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1200px) { .kpi-row { grid-template-columns: repeat(5, 1fr); } }
.kpi-card.is-compact { padding: var(--sp-4); }
.kpi-mini-progress { margin-top: var(--sp-3); position: relative; }
.kpi-mini-progress .progress { height: 6px; }
.kpi-mini-progress span.pct { font-size: 11px; font-weight: 700; color: var(--text-tertiary); float: right; margin-top: 4px; }

/* --------------------------- Natural-language search ---------------------- */
.nl-search-band {
  border-radius: var(--radius-xl);
  background: linear-gradient(160deg, rgba(124,47,224,.07), rgba(47,127,245,.05));
  border: 1px solid rgba(124,47,224,.14);
  padding: var(--sp-6);
  position: relative;
  overflow: hidden;
}
.nl-search-band::before {
  content: "";
  position: absolute; top: -80px; left: 50%; transform: translateX(-50%);
  width: 340px; height: 200px; border-radius: 50%;
  background: var(--rc-gradient-brand); opacity: .10; filter: blur(30px);
}
.nl-search-head { text-align: center; margin-bottom: var(--sp-5); position: relative; }
.nl-search-head .eyebrow { justify-content: center; display: flex; align-items: center; gap: 6px; }
.nl-search-head h2 { margin-top: 6px; }
.nl-input-wrap {
  position: relative;
  max-width: 720px;
  margin: 0 auto;
}
.nl-input-wrap .input {
  height: 58px;
  padding: 0 60px 0 54px;
  border-radius: var(--radius-full);
  font-size: var(--text-md);
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  box-shadow: var(--shadow-md);
}
.nl-input-wrap .input:focus {
  border-color: var(--rc-primary-400);
  box-shadow: 0 0 0 5px var(--rc-primary-100), var(--shadow-md);
}
.nl-input-wrap .nl-icon-left {
  position: absolute; left: 20px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; color: var(--rc-primary-500);
}
.nl-input-wrap .nl-submit {
  position: absolute; right: 8px; top: 8px;
  width: 42px; height: 42px; border-radius: var(--radius-full);
  background: var(--rc-gradient-brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-brand-glow);
  border: none;
}
.nl-submit svg { width: 18px; height: 18px; }
.nl-examples { display: flex; flex-wrap: wrap; gap: var(--sp-2); justify-content: center; margin-top: var(--sp-4); }

/* ------------------------------- AI Copilot -------------------------------- */
.ai-copilot { padding: var(--sp-7); border-width: 1.5px; }
.ai-copilot .ai-panel-head { margin-bottom: var(--sp-6); }
.ai-copilot .ai-avatar { width: 56px; height: 56px; border-radius: 18px; }
.ai-copilot .ai-avatar svg { width: 28px; height: 28px; }
.ai-copilot-title { font-size: var(--text-xl); font-weight: 800; letter-spacing: -.01em; }
.ai-briefing-btn {
  width: 100%;
  justify-content: center;
  margin-bottom: var(--sp-6);
  position: relative;
  height: 52px;
  font-size: var(--text-base);
}
.ai-group-title {
  font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-tertiary); margin: var(--sp-6) 0 var(--sp-3);
}
.ai-group-title:first-of-type { margin-top: 0; }
.ai-copilot-scroll { max-height: 720px; overflow-y: auto; padding-right: 6px; margin-right: -6px; }
.ai-copilot .ai-insight-item { padding: var(--sp-4); }
.ai-copilot .ai-insight-item strong { font-size: 14px !important; }
.ai-copilot .ai-insight-item p { font-size: 12.5px !important; }
.ai-briefing-result {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-4);
  margin-bottom: var(--sp-5);
  font-size: var(--text-sm);
  line-height: 1.6;
  color: var(--text-secondary);
}
.ai-briefing-result.is-visible { display: block; animation: fade-in var(--dur-med) var(--ease); }
.ai-briefing-result ul { margin-top: var(--sp-2); padding-left: 0; }
.ai-briefing-result li { display: flex; gap: 8px; padding: 4px 0; }
.ai-briefing-result li::before { content: "✓"; color: var(--rc-success-500); font-weight: 800; flex: none; }

/* ------------------------------ AI Activity feed --------------------------- */
.ai-activity-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-4); }
.live-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  color: var(--rc-success-500); background: var(--rc-success-100);
  padding: 4px 10px; border-radius: var(--radius-full);
}
.ai-activity-list { display: flex; flex-direction: column; max-height: 320px; overflow-y: auto; }
.ai-activity-item {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px dashed var(--border);
  animation: activity-in .4s var(--ease);
}
.ai-activity-item:last-child { border-bottom: none; }
.ai-activity-time { width: 48px; flex: none; font-size: 11px; font-weight: 700; color: var(--text-tertiary); padding-top: 2px; }
.ai-activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--rc-primary-500); margin-top: 6px; flex: none; box-shadow: 0 0 0 3px var(--rc-primary-100); }
.ai-activity-item.tone-success .ai-activity-dot { background: var(--rc-success-500); box-shadow: 0 0 0 3px var(--rc-success-100); }
.ai-activity-item.tone-info .ai-activity-dot { background: var(--rc-accent-500); box-shadow: 0 0 0 3px var(--rc-info-100); }
.ai-activity-item.tone-gold .ai-activity-dot { background: var(--rc-gold-500); box-shadow: 0 0 0 3px #f6ecc9; }
.ai-activity-text { font-size: 13px; font-weight: 600; }
.ai-activity-text span { display: block; font-size: 11px; font-weight: 500; color: var(--text-tertiary); margin-top: 1px; }
@keyframes activity-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* --------------------------- Dental procedure strip ------------------------ */
.procedure-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); }
@media (min-width: 640px) { .procedure-strip { grid-template-columns: repeat(6, 1fr); } }
.procedure-tile {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px;
  padding: var(--sp-4) var(--sp-2);
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.procedure-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.procedure-tile .p-ico {
  width: 40px; height: 40px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}
.procedure-tile .p-ico svg { width: 20px; height: 20px; }
.procedure-tile .p-count { font-size: var(--text-lg); font-weight: 800; }
.procedure-tile .p-label { font-size: 11px; color: var(--text-tertiary); font-weight: 700; }

/* -------------------------------- Skeletons -------------------------------- */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: 8px;
  color: transparent !important;
}
.skeleton::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent);
  transform: translateX(-100%);
  animation: skeleton-sweep 1.3s infinite;
}
:root[data-theme="dark"] .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.08), transparent); }
@keyframes skeleton-sweep { to { transform: translateX(100%); } }

/* ---------------------------- Floating AI widget --------------------------- */
.ai-fab {
  position: fixed;
  right: var(--sp-5);
  bottom: calc(var(--bottom-nav-h) + var(--sp-4));
  width: 58px; height: 58px;
  border-radius: 50%;
  background: var(--rc-gradient-brand);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-brand-glow);
  border: none;
  z-index: 90;
  transition: transform var(--dur-fast) var(--ease);
}
@media (min-width: 1024px) { .ai-fab { bottom: var(--sp-6); } }
.ai-fab:hover { transform: scale(1.06); }
.ai-fab svg { width: 26px; height: 26px; }
.ai-fab .ai-fab-ping {
  position: absolute; inset: 0; border-radius: 50%;
  background: var(--rc-gradient-brand); opacity: .5;
  animation: pulse-ring 2.2s var(--ease) infinite;
}
.ai-fab-panel {
  position: fixed;
  right: var(--sp-5);
  bottom: calc(var(--bottom-nav-h) + var(--sp-4) + 70px);
  width: min(380px, calc(100vw - 2 * var(--sp-5)));
  height: min(520px, calc(100vh - 220px));
  background: var(--surface-glass-strong);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  display: flex; flex-direction: column;
  overflow: hidden;
  z-index: 91;
  transform: scale(.92) translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: transform var(--dur-med) var(--ease), opacity var(--dur-med) var(--ease);
}
@media (min-width: 1024px) { .ai-fab-panel { bottom: calc(var(--sp-6) + 74px); } }
.ai-fab-panel.is-open { transform: scale(1) translateY(0); opacity: 1; pointer-events: auto; }
.ai-fab-panel .chat-scroll { flex: 1; overflow-y: auto; padding: var(--sp-4); }
.ai-fab-panel-head {
  padding: var(--sp-4); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--sp-3);
}
.ai-fab-panel-head strong { font-size: var(--text-sm); display: block; }
.ai-fab-panel-head span { font-size: 11px; color: var(--text-tertiary); }
.ai-fab-close { margin-left: auto; }

/* ---------------------------- Grouped sidebar nav --------------------------- */
.nav-list .nav-section-title { padding-top: var(--sp-4); }
.nav-list .nav-section-title:first-child { padding-top: 0; }

/* ---------------------------- Coming soon (stub pages) ---------------------- */
.coming-soon {
  text-align: center;
  padding: var(--sp-10) var(--sp-5);
}
.coming-soon .icon-wrap {
  width: 84px; height: 84px; margin: 0 auto var(--sp-5);
  border-radius: var(--radius-lg);
  background: var(--rc-gradient-brand);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-brand-glow);
}
.coming-soon .icon-wrap svg { width: 38px; height: 38px; }
.coming-soon h2 { margin-bottom: var(--sp-2); }
.coming-soon p { max-width: 440px; margin-inline: auto; color: var(--text-secondary); }

/* =========================================================================
   PATIENT PROFILE — FLAGSHIP COMPONENTS
   ========================================================================= */

/* ------------------------------- Two-pane layout --------------------------- */
.profile-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-5); }
@media (min-width: 1100px) { .profile-layout { grid-template-columns: 348px minmax(0,1fr); align-items: start; } }

/* --------------------------------- Hero / cover ----------------------------- */
.patient-hero {
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}
.patient-hero-cover {
  height: 108px;
  background: var(--rc-gradient-brand);
  position: relative;
}
.patient-hero-cover::after {
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,.28) 1.5px, transparent 1.5px);
  background-size: 18px 18px;
  opacity: .55;
}
.patient-hero-body {
  padding: 0 var(--sp-6) var(--sp-6);
  display: flex; align-items: flex-end; gap: var(--sp-5);
  margin-top: -44px;
  flex-wrap: wrap;
  position: relative;
}
.patient-hero .avatar-xl { border: 5px solid var(--surface); box-shadow: var(--shadow-md); flex: none; }
.patient-hero-info { flex: 1; min-width: 220px; padding-bottom: 6px; }
.patient-hero-actions { display: flex; gap: var(--sp-2); padding-bottom: 6px; flex-wrap: wrap; }

/* ------------------------------ Medical alert ------------------------------- */
.medical-alert {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--radius-md);
  background: var(--rc-danger-100);
  border: 1px solid rgba(255,92,92,.35);
  color: #9c2b2b;
}
:root[data-theme="dark"] .medical-alert { background: rgba(255,92,92,.12); color: #ff9d9d; border-color: rgba(255,92,92,.3); }
.medical-alert .m-ico {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--rc-danger-500); color: #fff;
  display: flex; align-items: center; justify-content: center; flex: none;
}
.medical-alert strong { font-size: 13.5px; display: block; }
.medical-alert .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.medical-alert .tags span { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: var(--radius-full); background: rgba(255,255,255,.55); }
:root[data-theme="dark"] .medical-alert .tags span { background: rgba(255,255,255,.08); }

/* ----------------------------- Patient snapshot ----------------------------- */
.patient-snapshot { }
@media (min-width: 1100px) {
  .patient-snapshot { position: sticky; top: calc(var(--topbar-h) + var(--sp-5)); }
}
.snapshot-section { padding: var(--sp-5); border-bottom: 1px solid var(--border); }
.snapshot-section:last-child { border-bottom: none; }
.snapshot-label {
  font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-tertiary); margin-bottom: var(--sp-3);
}

/* Quick action circles */
.quick-actions-row { display: flex; justify-content: space-between; gap: var(--sp-2); }
.quick-action { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; }
.quick-action .qa-circle {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--rc-primary-600);
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.quick-action .qa-circle svg { width: 19px; height: 19px; }
.quick-action:hover .qa-circle { background: var(--rc-gradient-brand); color: #fff; border-color: transparent; box-shadow: var(--shadow-brand-glow); transform: translateY(-2px); }
.quick-action span { font-size: 10.5px; font-weight: 700; color: var(--text-secondary); }

/* Contact info rows */
.info-row { display: flex; align-items: center; gap: 10px; font-size: 13px; padding: 6px 0; color: var(--text-secondary); }
.info-row svg { width: 16px; height: 16px; color: var(--text-tertiary); flex: none; }
.info-row strong { color: var(--text-primary); font-weight: 600; }

/* Tag pills */
.tag-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 700; padding: 5px 12px;
  border-radius: var(--radius-full);
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-secondary);
}
.tag-pill.tone-gold { background: linear-gradient(135deg, #fdf3d8, #f2e0a8); color: #7a5c05; border-color: transparent; }
.tag-pill.tone-primary { background: var(--rc-primary-50); color: var(--rc-primary-700); border-color: transparent; }
.tag-pill.tone-info { background: var(--rc-info-100); color: #0369a1; border-color: transparent; }
.tag-pill-add { border-style: dashed; }

/* AI risk ring + stat rows */
.risk-ring {
  --pct: 50;
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  position: relative; flex: none;
}
.risk-ring::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(var(--rc-success-500) calc(var(--pct) * 1%), var(--border) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 5px));
}
.risk-ring.tone-danger::before { background: conic-gradient(var(--rc-danger-500) calc(var(--pct) * 1%), var(--border) 0); }
.risk-ring.tone-gold::before { background: conic-gradient(var(--rc-gold-500) calc(var(--pct) * 1%), var(--border) 0); }
.risk-ring span { position: relative; font-size: 12px; font-weight: 800; }
.risk-stat-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) 0; }
.risk-stat-row .rs-info strong { display: block; font-size: 13px; }
.risk-stat-row .rs-info span { font-size: 11px; color: var(--text-tertiary); }

/* --------------------------- Unified activity feed -------------------------- */
.activity-feed { display: flex; flex-direction: column; }
.activity-feed-item { display: flex; gap: var(--sp-4); padding: var(--sp-4) 0; border-bottom: 1px solid var(--border); }
.activity-feed-item:last-child { border-bottom: none; }
.af-icon { width: 38px; height: 38px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex: none; color: #fff; }
.af-icon svg { width: 18px; height: 18px; }
.af-icon.tone-visit { background: var(--rc-gradient-brand); }
.af-icon.tone-payment { background: linear-gradient(135deg, #10b981, #5ce0b5); }
.af-icon.tone-note { background: linear-gradient(135deg, #2f7ff5, #5aa5ff); }
.af-icon.tone-comm { background: var(--rc-gradient-gold); color: #4a3400; }
.af-icon.tone-ai { background: var(--rc-gradient-brand); }
.af-body { flex: 1; min-width: 0; }
.af-body .af-top { display: flex; justify-content: space-between; gap: var(--sp-3); align-items: flex-start; }
.af-body strong { font-size: 13.5px; font-weight: 700; }
.af-body .af-meta { font-size: 11.5px; color: var(--text-tertiary); margin-top: 2px; }
.af-time { font-size: 11px; color: var(--text-tertiary); white-space: nowrap; flex: none; padding-top: 2px; }
.af-detail { margin-top: 8px; font-size: 12.5px; color: var(--text-secondary); background: var(--surface-2); border-radius: var(--radius-sm); padding: var(--sp-2) var(--sp-3); line-height: 1.6; }

/* ----------------------------- Treatment stepper ---------------------------- */
.tx-stepper { display: flex; gap: 0; margin-bottom: var(--sp-6); overflow-x: auto; }
.tx-step { flex: 1; min-width: 110px; text-align: center; position: relative; padding-bottom: var(--sp-2); }
.tx-step::before { content: ""; position: absolute; top: 14px; left: -50%; width: 100%; height: 2px; background: var(--border); z-index: 0; }
.tx-step:first-child::before { display: none; }
.tx-step.is-done::before { background: var(--rc-success-500); }
.tx-step .step-dot {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 8px; position: relative; z-index: 1;
  font-size: 12px; font-weight: 800; color: var(--text-tertiary);
}
.tx-step.is-done .step-dot { background: var(--rc-success-500); border-color: var(--rc-success-500); color: #fff; }
.tx-step.is-active .step-dot { background: var(--rc-gradient-brand); border-color: transparent; color: #fff; box-shadow: var(--shadow-brand-glow); }
.tx-step .step-label { font-size: 11.5px; font-weight: 700; color: var(--text-secondary); }
.tx-step.is-active .step-label { color: var(--rc-primary-700); }

/* -------------------------------- Document gallery -------------------------- */
.doc-gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-3); }
@media (min-width: 640px) { .doc-gallery { grid-template-columns: repeat(3, 1fr); } }
.doc-card { border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--border); background: var(--surface); transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease); }
.doc-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.doc-thumb { height: 88px; display: flex; align-items: center; justify-content: center; color: #fff; }
.doc-thumb svg { width: 28px; height: 28px; }
.doc-card-body { padding: var(--sp-3); }
.doc-card-body strong { font-size: 12px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-card-body span { font-size: 10.5px; color: var(--text-tertiary); }

/* -------------------------------- Print -------------------------------- */
@media print {
  .sidebar, .topbar, .sidebar-scrim, .bottom-nav, [data-theme-toggle], .btn, #server-messages { display: none !important; }
  .app-shell { display: block; }
  .content { padding: 0; margin: 0; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

/* -------------------------------- Public onboarding pages (join / refer) -------------------------------- */
.rdc-public { min-height: 100vh; display: flex; flex-direction: column; }
.rdc-public-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-5) var(--sp-6);
}
.rdc-public-main { flex: 1; padding: var(--sp-4) var(--sp-6) var(--sp-9); }
.rdc-public-footer {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--sp-2);
  padding: var(--sp-5) var(--sp-6); font-size: var(--text-xs); color: var(--text-tertiary);
}
.rdc-public-footer-links { display: flex; gap: var(--sp-4); }
.rdc-public-footer-links a { color: var(--text-tertiary); }

.rdc-public-hero {
  max-width: 1120px; margin: 0 auto;
  display: grid; grid-template-columns: 1fr; gap: var(--sp-8);
}
@media (min-width: 900px) {
  .rdc-public-hero { grid-template-columns: 1fr 480px; align-items: start; gap: var(--sp-9); }
}
.rdc-public-single { max-width: 560px; margin: var(--sp-8) auto 0; }

.rdc-public-copy { padding-top: var(--sp-4); }
.rdc-public-copy .h1 { margin: var(--sp-4) 0 var(--sp-3); }
.rdc-public-lede { color: var(--text-secondary); font-size: var(--text-base); line-height: 1.6; margin-bottom: var(--sp-5); }
.rdc-public-benefits { list-style: none; display: flex; flex-direction: column; gap: var(--sp-3); margin-bottom: var(--sp-5); }
.rdc-public-benefits li {
  position: relative; padding-left: 28px; font-size: var(--text-sm); color: var(--text-secondary); font-weight: 600;
}
.rdc-public-benefits li::before {
  content: "✓"; position: absolute; left: 0; top: -1px;
  width: 20px; height: 20px; border-radius: 50%; background: var(--rc-success-100); color: #067a55;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800;
}
.rdc-public-trust { font-size: var(--text-xs); color: var(--text-tertiary); }
.rdc-public-pricing-notice {
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  border-radius: var(--radius-md); padding: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-5);
  background: var(--rc-primary-50); border: 1px solid var(--rc-primary-200);
}
.rdc-public-pricing-notice strong { color: var(--rc-primary-700); font-size: var(--text-base); }
.rdc-public-pricing-notice span { color: var(--text-secondary); font-size: var(--text-sm); }
.rdc-public-section-label { font-size: var(--text-xs); font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--text-tertiary); margin-top: var(--sp-2); }

.rdc-public-card { width: 100%; }
.rdc-public-grid-2 { display: grid; grid-template-columns: 1fr; gap: var(--sp-4); }
@media (min-width: 520px) { .rdc-public-grid-2 { grid-template-columns: 1fr 1fr; } }

.rdc-public-checkbox { display: flex; align-items: flex-start; gap: var(--sp-2); font-size: var(--text-sm); color: var(--text-secondary); cursor: pointer; }
.rdc-public-checkbox input { margin-top: 3px; }

/* -------------------------------- Trial banner -------------------------------- */
.rdc-trial-banner {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5); margin-bottom: var(--sp-5);
  border-radius: var(--radius-md); border: 1px solid var(--rc-info-100); background: var(--rc-info-100); color: #0369a1;
  font-size: var(--text-sm); font-weight: 600;
}
:root[data-theme="dark"] .rdc-trial-banner { background: rgba(47,127,245,.12); border-color: rgba(47,127,245,.3); color: #8fc7ff; }
.rdc-trial-banner.is-ending-soon { border-color: var(--rc-danger-100); background: var(--rc-danger-100); color: #c0272e; }
:root[data-theme="dark"] .rdc-trial-banner.is-ending-soon { background: rgba(255,92,92,.15); border-color: rgba(255,92,92,.3); color: #ff8f8f; }

/* ==========================================================================
   Public landing page (/)
   ========================================================================= */

/* -------- Header nav (landing only — join/refer keep the plain header) -- */
.rdc-landing-nav { display: none; align-items: center; gap: var(--sp-6); }
@media (min-width: 860px) {
  .rdc-landing-nav { display: flex; }
}
.rdc-landing-nav a { font-size: var(--text-sm); font-weight: 600; color: var(--text-secondary); }
.rdc-landing-nav a:hover { color: var(--rc-primary-600); }

/* -------------------------------- Hero ----------------------------------- */
.rdc-landing-hero {
  max-width: 1160px; margin: var(--sp-4) auto var(--sp-10);
  display: grid; grid-template-columns: 1fr; gap: var(--sp-8);
  text-align: center;
  justify-items: center;
}
@media (min-width: 960px) {
  .rdc-landing-hero { grid-template-columns: 1fr 1fr; text-align: left; justify-items: stretch; }
}
.rdc-landing-hero-copy { max-width: 640px; }
.rdc-landing-hero-copy .h1 { font-size: clamp(2rem, 4.4vw, 3rem); margin: var(--sp-4) 0 var(--sp-4); }
.rdc-landing-lede { color: var(--text-secondary); font-size: var(--text-lg); line-height: 1.6; margin-bottom: var(--sp-6); }
.rdc-landing-hero-price { font-size: var(--text-base); color: var(--text-secondary); margin: 0 0 var(--sp-5); }
.rdc-landing-hero-price strong { color: var(--rc-primary-600); }
.rdc-landing-cta-row { display: flex; flex-wrap: wrap; gap: var(--sp-3); justify-content: center; }
@media (min-width: 960px) { .rdc-landing-cta-row { justify-content: flex-start; } }
.rdc-landing-cta-row .btn { min-height: 48px; padding-inline: var(--sp-6); font-size: var(--text-base); }

/* Hero visual — real screenshot inside a browser-style frame */
.rdc-landing-hero-visual { width: 100%; max-width: 480px; }
.rdc-landing-mock-window {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl); overflow: hidden;
}
.rdc-landing-mock-bar { display: flex; align-items: center; gap: 6px; padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); background: var(--surface-2); }
.rdc-landing-mock-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong); }
.rdc-landing-mock-dot:nth-child(1) { background: var(--rc-danger-500); }
.rdc-landing-mock-dot:nth-child(2) { background: var(--rc-warning-500); }
.rdc-landing-mock-dot:nth-child(3) { background: var(--rc-success-500); }
.rdc-landing-hero-shot { display: block; width: 100%; height: auto; object-fit: cover; object-position: top; max-height: 340px; }

/* ------------------------------ Section shell ---------------------------- */
.rdc-landing-section { max-width: 1160px; margin: 0 auto; padding: var(--sp-9) 0; scroll-margin-top: var(--sp-9); }
.rdc-landing-section-head { max-width: 640px; margin: 0 auto var(--sp-8); text-align: center; }
.rdc-landing-section-head .h2 { margin: var(--sp-2) 0 var(--sp-3); }
.rdc-landing-section-head p { color: var(--text-secondary); line-height: 1.6; }

/* --------------------------- Software preview grid ------------------------ */
.rdc-landing-preview-grid { display: grid; grid-template-columns: 1fr; gap: var(--sp-5); }
@media (min-width: 640px) { .rdc-landing-preview-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1020px) { .rdc-landing-preview-grid { grid-template-columns: repeat(3, 1fr); } }
.rdc-landing-preview-card { overflow: hidden; padding: 0; display: flex; flex-direction: column; }
.rdc-landing-preview-body { aspect-ratio: 16 / 9; overflow: hidden; background: var(--surface-2); position: relative; }
.rdc-landing-preview-body img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.rdc-landing-preview-label { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-4) var(--sp-5) 0; }
.rdc-landing-preview-label strong { font-size: var(--text-sm); }
.rdc-landing-preview-desc { padding: var(--sp-2) var(--sp-5) var(--sp-5); margin: 0; color: var(--text-secondary); font-size: var(--text-sm); line-height: 1.5; }

/* -------------------------------- Benefits -------------------------------- */
.rdc-landing-benefits-grid {
  display: grid; grid-template-columns: 1fr; gap: var(--sp-3);
}
@media (min-width: 640px) { .rdc-landing-benefits-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1020px) { .rdc-landing-benefits-grid { grid-template-columns: 1fr 1fr 1fr; } }
.rdc-landing-benefit-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4); border-radius: var(--radius-md); background: var(--surface); border: 1px solid var(--border);
  font-weight: 600; font-size: var(--text-sm);
}
.rdc-landing-benefit-item .benefit-check {
  width: 24px; height: 24px; border-radius: 50%; background: var(--rc-success-100); color: #067a55; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800;
}

/* --------------------------------- Promo bands ---------------------------- */
.rdc-landing-promo {
  border-radius: var(--radius-xl); padding: var(--sp-8); color: #fff;
  background: var(--rc-gradient-brand); box-shadow: var(--shadow-brand-glow);
  display: grid; grid-template-columns: 1fr; gap: var(--sp-6); align-items: center;
}
@media (min-width: 780px) { .rdc-landing-promo { grid-template-columns: 1.4fr 1fr; } }
.rdc-landing-promo.is-refer { background: linear-gradient(135deg, var(--rc-gold-500) 0%, var(--rc-gold-600) 100%); box-shadow: var(--shadow-gold-glow); }
.rdc-landing-promo h3 { font-size: var(--text-2xl); font-weight: 800; letter-spacing: -.01em; margin-bottom: var(--sp-3); }
.rdc-landing-promo ul { list-style: none; display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-5); }
.rdc-landing-promo ul li { position: relative; padding-left: 26px; font-weight: 600; opacity: .95; font-size: var(--text-sm); }
.rdc-landing-promo ul li::before { content: "✓"; position: absolute; left: 0; top: 0; opacity: .9; }
.rdc-landing-promo-actions { display: flex; justify-content: center; }
.rdc-landing-promo .btn-primary { background: #fff; color: var(--rc-primary-700); }
.rdc-landing-promo .btn-primary:hover { background: #fff; opacity: .92; }
.rdc-landing-promo.is-refer .btn-primary { color: var(--rc-gold-700, #8a6a1a); }

/* -------------------------------- Pricing card ------------------------------ */
.rdc-pricing-card-wrap { display: flex; justify-content: center; flex-wrap: wrap; gap: var(--sp-6); }
.rdc-pricing-card.is-recommended::before { background: var(--rc-gradient-gold); }
.rdc-pricing-card {
  width: 100%; max-width: 420px; padding: var(--sp-8); text-align: center;
  border: 1px solid var(--border); position: relative; overflow: hidden;
}
.rdc-pricing-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 6px; background: var(--rc-gradient-brand);
}
.rdc-pricing-card-head { margin-bottom: var(--sp-6); }
.rdc-pricing-price {
  font-size: clamp(2.4rem, 6vw, 3rem); font-weight: 800; letter-spacing: -.02em;
  margin: var(--sp-4) 0 var(--sp-1); background: var(--rc-gradient-brand);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.rdc-pricing-price span { font-size: var(--text-base); font-weight: 600; color: var(--text-secondary); -webkit-text-fill-color: var(--text-secondary); }
.rdc-pricing-sub { color: var(--text-tertiary); font-size: var(--text-sm); }
.rdc-pricing-features { list-style: none; text-align: left; display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-6); }
.rdc-pricing-features li { position: relative; padding-left: 26px; font-weight: 600; font-size: var(--text-sm); color: var(--text-secondary); }
.rdc-pricing-features li::before {
  content: "✓"; position: absolute; left: 0; top: 0; width: 18px; height: 18px; border-radius: 50%;
  background: var(--rc-success-100); color: #067a55; font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.rdc-pricing-signin { display: block; margin-top: var(--sp-4); font-size: var(--text-sm); font-weight: 600; color: var(--rc-primary-600); }
.rdc-pricing-signin:hover { color: var(--rc-primary-700); }

/* --------------------------------- FAQ -------------------------------------- */
.rdc-landing-faq { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--sp-3); }
.rdc-faq-item { border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--sp-4) var(--sp-5); background: var(--surface); }
.rdc-faq-item summary { font-weight: 700; cursor: pointer; list-style: none; }
.rdc-faq-item summary::-webkit-details-marker { display: none; }
.rdc-faq-item summary::before { content: "+"; display: inline-block; width: 1.2em; color: var(--rc-primary-600); font-weight: 800; }
.rdc-faq-item[open] summary::before { content: "–"; }
.rdc-faq-item p { margin: var(--sp-3) 0 0; color: var(--text-secondary); font-size: var(--text-sm); line-height: 1.6; }

/* ------------------------------- Feature cards ----------------------------- */
.rdc-landing-feature-grid { display: grid; grid-template-columns: 1fr; gap: var(--sp-4); }
@media (min-width: 640px) { .rdc-landing-feature-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1020px) { .rdc-landing-feature-grid { grid-template-columns: repeat(4, 1fr); } }
.rdc-landing-feature-card { display: flex; flex-direction: column; gap: var(--sp-3); }
.rdc-landing-feature-icon {
  width: 44px; height: 44px; border-radius: var(--radius-md); background: var(--rc-gradient-brand);
  display: flex; align-items: center; justify-content: center; color: #fff; flex: none;
}
.rdc-landing-feature-icon svg { width: 22px; height: 22px; }
.rdc-landing-feature-card h4 { font-size: var(--text-md); }
.rdc-landing-feature-card p { color: var(--text-secondary); font-size: var(--text-sm); line-height: 1.5; }

/* --------------------------------- Final CTA -------------------------------- */
.rdc-landing-final-cta {
  text-align: center; border-radius: var(--radius-xl); padding: var(--sp-9) var(--sp-6); color: #fff;
  background: var(--rc-gradient-brand); box-shadow: var(--shadow-brand-glow);
}
.rdc-landing-final-cta h2 { font-size: clamp(1.5rem, 3.4vw, var(--text-3xl)); font-weight: 800; margin-bottom: var(--sp-3); letter-spacing: -.02em; }
.rdc-landing-final-cta p { opacity: .92; margin-bottom: var(--sp-6); font-size: var(--text-base); }
.rdc-landing-final-cta .btn-primary { background: #fff; color: var(--rc-primary-700); min-height: 48px; padding-inline: var(--sp-7); font-size: var(--text-base); }
.rdc-landing-final-cta .btn-primary:hover { background: #fff; opacity: .92; }

/* Mobile: generous tap targets, no overflow */
@media (max-width: 480px) {
  .rdc-public-main { padding-inline: var(--sp-4); }
  .rdc-landing-cta-row .btn, .rdc-landing-promo-actions .btn { width: 100%; }
  .rdc-landing-promo { padding: var(--sp-6); }
  .rdc-pricing-card { max-width: 100%; padding: var(--sp-6) var(--sp-5); }
}
