/* ============================================================
   UNtouchED – Medical Practice Management App
   Design System: Luxury Aesthetic Medical
   Theme: Warm Cream × Champagne Gold × Deep Charcoal
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;0,600;1,300;1,400;1,500&family=Inter:wght@300;400;500;600;700&family=Dancing+Script:wght@400;500;600&display=swap');

/* ─── CSS Variables ─────────────────────────────────────────── */
:root {
  --cream:          #F9F6F2;
  --cream-dark:     #F0EBE3;
  --cream-deeper:   #E8DDD0;
  --surface:        #FFFFFF;
  --surface-warm:   #FAFAF8;
  --surface-raised: #FDFDFC;
  --surface-2:      #F8F9FA;
  --gold:           #C9A96E;
  --gold-light:     #DFC495;
  --gold-pale:      #EDD9B0;
  --gold-dark:      #B8935A;
  --gold-darker:    #9A7A45;
  --gold-glow:      rgba(201,169,110,0.28);
  --gold-bg:        rgba(201,169,110,0.08);
  --gold-bg-mid:    rgba(201,169,110,0.15);
  --charcoal:       #1A1A1A;
  --charcoal-soft:  #2C2C2C;
  --charcoal-mid:   #3D3D3D;
  --text-primary:   #1A1A1A;
  --text-secondary: #5A5A5A;
  --text-muted:     #9A9A9A;
  --text-placeholder:#B8B8B8;
  --border:         #E8E2D9;
  --border-mid:     #D8D0C4;
  --border-dark:    #C4BAB0;
  --danger:         #B03A2E;
  --danger-pale:    rgba(176,58,46,0.09);
  --danger-light:   #E74C3C;
  --success:        #27AE60;
  --success-pale:   rgba(39,174,96,0.09);
  --warn:           #D68910;
  --warn-pale:      rgba(214,137,16,0.09);
  --info:           #2471A3;
  --info-pale:      rgba(36,113,163,0.09);

  /* Layout */
  --sidebar-w:        240px;
  --sidebar-collapsed: 68px;
  --radius-xs:        4px;
  --radius-sm:        8px;
  --radius-md:        12px;
  --radius-lg:        16px;
  --radius-xl:        24px;
  --radius-pill:      999px;

  /* Typography */
  --font-serif:     'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --font-sans:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, sans-serif;
  --font-script:    'Dancing Script', cursive;
  --font:           var(--font-sans);

  /* Shadows */
  --shadow-xs:      0 1px 3px rgba(26,26,26,0.05), 0 1px 2px rgba(26,26,26,0.04);
  --shadow-sm:      0 2px 8px rgba(26,26,26,0.07), 0 1px 3px rgba(26,26,26,0.05);
  --shadow-md:      0 4px 20px rgba(26,26,26,0.09), 0 2px 8px rgba(26,26,26,0.06);
  --shadow-lg:      0 8px 40px rgba(26,26,26,0.12), 0 4px 16px rgba(26,26,26,0.08);
  --shadow-xl:      0 16px 64px rgba(26,26,26,0.16), 0 8px 32px rgba(26,26,26,0.10);
  --shadow-gold:    0 4px 24px rgba(201,169,110,0.22);
  --shadow-inset:   inset 0 1px 3px rgba(26,26,26,0.08);

  /* Transitions */
  --ease:           cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out:       cubic-bezier(0, 0, 0.2, 1);
  --ease-spring:    cubic-bezier(0.34, 1.56, 0.64, 1);
  --fast:           150ms;
  --mid:            280ms;
  --slow:           450ms;
}

/* ══════════════════════════════════════════════════════════════
   THEMES  (override :root variables via html[data-theme="X"])
   ══════════════════════════════════════════════════════════════ */

/* ─── Dark ─────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --cream:          #16213E;
  --cream-dark:     #0F3460;
  --cream-deeper:   #0D2137;
  --surface:        #1A1A2E;
  --surface-warm:   #1E2040;
  --surface-raised: #232348;
  --surface-2:      #252550;
  --charcoal:       #EAE6E0;
  --charcoal-soft:  #D5CFC5;
  --charcoal-mid:   #B8B0A0;
  --text-primary:   #EAE6E0;
  --text-secondary: #A8A098;
  --text-muted:     #706860;
  --text-placeholder:#4A4640;
  --border:         #262645;
  --border-mid:     #343458;
  --border-dark:    #42426A;
  --shadow-xs:      0 1px 3px rgba(0,0,0,0.4);
  --shadow-sm:      0 2px 8px rgba(0,0,0,0.5);
  --shadow-md:      0 4px 20px rgba(0,0,0,0.55);
  --shadow-lg:      0 8px 40px rgba(0,0,0,0.65);
  --shadow-xl:      0 16px 64px rgba(0,0,0,0.75);
}

/* ─── Rose / Blush ─────────────────────────────────────────────── */
[data-theme="rose"] {
  --cream:          #FFF0F4;
  --cream-dark:     #FFE0EA;
  --cream-deeper:   #FFC8D8;
  --surface:        #FFFFFF;
  --surface-warm:   #FFF8FA;
  --surface-raised: #FFF2F5;
  --surface-2:      #FFF0F4;
  --gold:           #C2185B;
  --gold-light:     #E91E63;
  --gold-pale:      #FCE4EC;
  --gold-dark:      #AD1457;
  --gold-darker:    #880E4F;
  --gold-glow:      rgba(194,24,91,0.22);
  --gold-bg:        rgba(194,24,91,0.07);
  --gold-bg-mid:    rgba(194,24,91,0.14);
  --charcoal:       #2D0A1E;
  --charcoal-soft:  #4A1A30;
  --charcoal-mid:   #6B2A45;
  --text-primary:   #2D0A1E;
  --text-secondary: #7B2C47;
  --text-muted:     #A86080;
  --text-placeholder:#D4A0B5;
  --border:         #F5D0DC;
  --border-mid:     #E8BAC8;
  --border-dark:    #DBA0B0;
  --shadow-gold:    0 4px 24px rgba(194,24,91,0.18);
}

/* ─── Ocean / Teal ─────────────────────────────────────────────── */
[data-theme="ocean"] {
  --cream:          #E8F4FD;
  --cream-dark:     #D0E8FA;
  --cream-deeper:   #B8DCF8;
  --surface:        #FFFFFF;
  --surface-warm:   #F2FAFF;
  --surface-raised: #EAF6FD;
  --surface-2:      #E8F4FD;
  --gold:           #0077B6;
  --gold-light:     #0096C7;
  --gold-pale:      #CAE9FF;
  --gold-dark:      #005A8A;
  --gold-darker:    #003E63;
  --gold-glow:      rgba(0,119,182,0.25);
  --gold-bg:        rgba(0,119,182,0.07);
  --gold-bg-mid:    rgba(0,119,182,0.15);
  --charcoal:       #002040;
  --charcoal-soft:  #003465;
  --charcoal-mid:   #004A8A;
  --text-primary:   #002040;
  --text-secondary: #004280;
  --text-muted:     #4E90BC;
  --text-placeholder:#90BBD8;
  --border:         #B8D8F0;
  --border-mid:     #98C4E8;
  --border-dark:    #78AEDC;
  --shadow-gold:    0 4px 24px rgba(0,119,182,0.18);
}

/* ─── Sage / Forest ────────────────────────────────────────────── */
[data-theme="sage"] {
  --cream:          #EEF5EC;
  --cream-dark:     #DDEADB;
  --cream-deeper:   #C8DCC6;
  --surface:        #FFFFFF;
  --surface-warm:   #F5FBF4;
  --surface-raised: #EFF6EE;
  --surface-2:      #EEF5EC;
  --gold:           #2D6A4F;
  --gold-light:     #40916C;
  --gold-pale:      #B7E4C7;
  --gold-dark:      #1B4332;
  --gold-darker:    #0D2B1E;
  --gold-glow:      rgba(45,106,79,0.25);
  --gold-bg:        rgba(45,106,79,0.07);
  --gold-bg-mid:    rgba(45,106,79,0.15);
  --charcoal:       #0D2B1E;
  --charcoal-soft:  #1B4332;
  --charcoal-mid:   #2D6A4F;
  --text-primary:   #0D2B1E;
  --text-secondary: #1B5240;
  --text-muted:     #52796F;
  --text-placeholder:#95C4B8;
  --border:         #C0DEC8;
  --border-mid:     #A0C8B0;
  --border-dark:    #80B298;
  --shadow-gold:    0 4px 24px rgba(45,106,79,0.18);
}

/* ─── Midnight Violet ─────────────────────────────────────────── */
[data-theme="violet"] {
  --cream:          #12091E;
  --cream-dark:     #1A1028;
  --cream-deeper:   #0E0616;
  --surface:        #1C1230;
  --surface-warm:   #221840;
  --surface-raised: #281E48;
  --surface-2:      #20163A;
  --gold:           #9B59B6;
  --gold-light:     #BB7FD4;
  --gold-pale:      #3D1C5E;
  --gold-dark:      #7D3EA0;
  --gold-darker:    #5E2E80;
  --gold-glow:      rgba(155,89,182,0.35);
  --gold-bg:        rgba(155,89,182,0.12);
  --gold-bg-mid:    rgba(155,89,182,0.22);
  --charcoal:       #F0E8FF;
  --charcoal-soft:  #DDD0F8;
  --charcoal-mid:   #C0A8E8;
  --text-primary:   #F0E8FF;
  --text-secondary: #C0A8E8;
  --text-muted:     #8870A8;
  --text-placeholder:#5C4878;
  --border:         #3A2858;
  --border-mid:     #4A3068;
  --border-dark:    #5A3878;
  --shadow-xs:      0 1px 3px rgba(0,0,0,0.5);
  --shadow-sm:      0 2px 8px rgba(0,0,0,0.55);
  --shadow-md:      0 4px 20px rgba(0,0,0,0.6);
  --shadow-lg:      0 8px 40px rgba(0,0,0,0.7);
  --shadow-xl:      0 16px 64px rgba(0,0,0,0.8);
  --shadow-gold:    0 4px 24px rgba(155,89,182,0.35);
}

/* ─── Black & White (Dark Mono) ───────────────────────────── */
[data-theme="bw"] {
  --cream:          #181818;
  --cream-dark:     #101010;
  --cream-deeper:   #080808;
  --surface:        #202020;
  --surface-warm:   #282828;
  --surface-raised: #303030;
  --surface-2:      #252525;
  --gold:           #E8E8E8;
  --gold-light:     #F5F5F5;
  --gold-pale:      #404040;
  --gold-dark:      #CCCCCC;
  --gold-darker:    #AAAAAA;
  --gold-glow:      rgba(255,255,255,0.18);
  --gold-bg:        rgba(255,255,255,0.06);
  --gold-bg-mid:    rgba(255,255,255,0.12);
  --charcoal:       #FFFFFF;
  --charcoal-soft:  #EEEEEE;
  --charcoal-mid:   #CCCCCC;
  --text-primary:   #FFFFFF;
  --text-secondary: #BBBBBB;
  --text-muted:     #777777;
  --text-placeholder:#484848;
  --border:         #2E2E2E;
  --border-mid:     #3C3C3C;
  --border-dark:    #4A4A4A;
  --shadow-xs:      0 1px 3px rgba(0,0,0,0.5);
  --shadow-sm:      0 2px 8px rgba(0,0,0,0.55);
  --shadow-md:      0 4px 20px rgba(0,0,0,0.6);
  --shadow-lg:      0 8px 40px rgba(0,0,0,0.7);
  --shadow-xl:      0 16px 64px rgba(0,0,0,0.8);
  --shadow-gold:    0 4px 24px rgba(255,255,255,0.10);
}

/* ─── Dark-theme input overrides (browsers default inputs to white) ─ */
[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]),
[data-theme="dark"] select,
[data-theme="dark"] textarea,
[data-theme="violet"] input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]),
[data-theme="violet"] select,
[data-theme="violet"] textarea,
[data-theme="bw"] input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]),
[data-theme="bw"] select,
[data-theme="bw"] textarea {
  background: var(--surface-warm);
  color: var(--text-primary);
  border-color: var(--border-mid);
}

/* ─── Adjust login gradient for dark themes ───────────────────── */
[data-theme="dark"] #login-screen,
[data-theme="violet"] #login-screen,
[data-theme="bw"] #login-screen {
  background-image:
    radial-gradient(ellipse 80% 60% at 20% 80%, rgba(255,255,255,0.02) 0%, transparent 60%),
    radial-gradient(ellipse 60% 80% at 80% 20%, rgba(255,255,255,0.02) 0%, transparent 60%);
}

/* ─── btn-primary fix for themes where --charcoal flips light ─── */
/* dark/violet/bw flip --charcoal to a near-white text colour, making */
/* the default .btn-primary (bg=--charcoal, color=#FFF) invisible.    */
/* Use !important to definitively beat .btn.btn-primary.btn-lg (0,3,0) */
[data-theme="dark"] .btn-primary,
[data-theme="dark"] .btn-primary:hover {
  background:    var(--gold)        !important;
  border-color:  var(--gold-dark)   !important;
  color:         var(--cream-deeper)!important;
}
[data-theme="violet"] .btn-primary,
[data-theme="violet"] .btn-primary:hover {
  background:    var(--gold)        !important;
  border-color:  var(--gold-dark)   !important;
  color:         var(--cream-deeper)!important;
}
[data-theme="bw"] .btn-primary,
[data-theme="bw"] .btn-primary:hover {
  background:    var(--gold)        !important;
  border-color:  var(--gold-dark)   !important;
  color:         #000000            !important;
}
[data-theme="dark"] .btn-primary:hover   { background: var(--gold-dark) !important; }
[data-theme="violet"] .btn-primary:hover { background: var(--gold-dark) !important; }
[data-theme="bw"] .btn-primary:hover     { background: var(--gold-dark) !important; }

/* ─── .btn-login (Sign In button on login screen) ─────────────── */
/* Same root cause: uses var(--charcoal) as background             */
[data-theme="dark"] .btn-login,
[data-theme="violet"] .btn-login {
  background: var(--gold) !important;
  color:      var(--cream-deeper) !important;
}
[data-theme="bw"] .btn-login {
  background: var(--gold) !important;
  color:      #000000 !important;
}
[data-theme="dark"] .btn-login:hover,
[data-theme="violet"] .btn-login:hover,
[data-theme="bw"] .btn-login:hover {
  background: var(--gold-dark) !important;
}

/* ─── .btn-gold dark theme fix ─────────────────────────────────── */
/* .btn-gold uses background:var(--gold);color:#FFFFFF             */
/* In BW theme --gold=#E8E8E8 (near-white) + white text = invisible */
[data-theme="dark"] .btn-gold,
[data-theme="violet"] .btn-gold {
  color: var(--cream-deeper) !important;
}
[data-theme="bw"] .btn-gold {
  color: #000000 !important;
}

/* ─── Intake signed badge ──────────────────────────────────────── */
/* Uses the gold accent but needs dark text in BW/dark themes      */
.intake-signed-badge {
  font-weight: 700;
  font-size: 14px;
  color: var(--gold-dark);
}
[data-theme="dark"] .intake-signed-badge,
[data-theme="violet"] .intake-signed-badge { color: var(--gold-light); }
[data-theme="bw"] .intake-signed-badge     { color: var(--text-primary); }

/* ─── Toast notifications ──────────────────────────────────────── */
/* .toast uses background: var(--charcoal) — near-white in dark    */
/* themes. Switch to surface-raised (dark card bg) + text-primary  */
[data-theme="dark"] .toast,
[data-theme="violet"] .toast,
[data-theme="bw"] .toast {
  background: var(--surface-raised) !important;
  color:      var(--text-primary)   !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.05) !important;
  border-left-color: var(--gold)    !important;
}
/* keep type-specific left-border colours */
[data-theme="dark"] .toast.toast-success,
[data-theme="violet"] .toast.toast-success,
[data-theme="bw"] .toast.toast-success { border-left-color: var(--success) !important; }
[data-theme="dark"] .toast.toast-error,
[data-theme="violet"] .toast.toast-error,
[data-theme="bw"] .toast.toast-error   { border-left-color: var(--danger)  !important; }
[data-theme="dark"] .toast.toast-warn,
[data-theme="violet"] .toast.toast-warn,
[data-theme="bw"] .toast.toast-warn    { border-left-color: var(--warn)    !important; }

/* ─── Theme Switcher Widget ────────────────────────────────────── */
.sidebar-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  gap: 8px;
  overflow: hidden;
  transition: opacity var(--mid);
}

.theme-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.theme-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2.5px solid transparent;
  cursor: pointer;
  transition: transform 0.18s var(--ease), border-color 0.18s, box-shadow 0.18s;
  padding: 0;
  flex-shrink: 0;
  outline: none;
}

.theme-dot:hover  { transform: scale(1.3); }
.theme-dot.active {
  border-color: var(--charcoal);
  box-shadow: 0 0 0 2.5px var(--gold-glow);
  transform: scale(1.2);
}

.sidebar.collapsed .sidebar-actions { padding: 8px 6px; justify-content: center; }
.sidebar.collapsed .theme-picker     { gap: 3px; }
.sidebar.collapsed .theme-dot        { width: 13px; height: 13px; }



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

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-weight: 400;
  color: var(--text-primary);
  background: var(--cream);
  line-height: 1.6;
  min-height: 100vh;
  overflow: hidden;
}

img { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }
a { color: var(--gold-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { list-style: none; }

/* ─── Scrollbars ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: var(--radius-pill); }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* ─── Selection ─────────────────────────────────────────────── */
::selection { background: var(--gold-bg-mid); color: var(--charcoal); }

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
#login-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  background-image:
    radial-gradient(ellipse 80% 60% at 20% 80%, rgba(201,169,110,0.10) 0%, transparent 60%),
    radial-gradient(ellipse 60% 80% at 80% 20%, rgba(201,169,110,0.07) 0%, transparent 60%);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 52px 44px 44px;
  width: 400px;
  max-width: 92vw;
  box-shadow: var(--shadow-lg), var(--shadow-gold);
  animation: loginFadeIn var(--slow) var(--ease-out) both;
}

@keyframes loginFadeIn {
  from { opacity: 0; transform: translateY(24px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-logo-area {
  text-align: center;
  margin-bottom: 36px;
}

.login-logo-img {
  width: 80px;
  height: 80px;
  margin: 0 auto 16px;
  object-fit: contain;
  display: block;
}

.login-logo-animated {
  width: 120px;
  height: 80px;
  margin: 0 auto 16px;
  object-fit: contain;
  display: block;
}

.login-brand-name {
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 300;
  letter-spacing: 0.04em;
  color: var(--charcoal);
  line-height: 1.2;
}

.login-brand-name .script-part {
  font-family: var(--font-script);
  font-size: 34px;
  font-weight: 400;
  letter-spacing: 0;
}

.login-brand-sub {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  margin-top: 4px;
  font-style: italic;
}

.login-divider {
  width: 48px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  margin: 20px auto;
}

.login-fields { display: flex; flex-direction: column; gap: 16px; }

.login-field-group { position: relative; }

.login-field-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.login-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-warm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease), background var(--fast);
  outline: none;
}

.login-input:focus {
  border-color: var(--gold);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--gold-bg);
}

.login-input::placeholder { color: var(--text-placeholder); }

.btn-login {
  width: 100%;
  padding: 14px;
  background: var(--charcoal);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  margin-top: 8px;
  transition: background var(--fast) var(--ease), transform var(--fast) var(--ease), box-shadow var(--fast);
  position: relative;
  overflow: hidden;
}

.btn-login::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.06) 0%, transparent 100%);
}

.btn-login:hover {
  background: var(--charcoal-soft);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-login:active { transform: translateY(0); }

.login-forgot {
  text-align: center;
  margin-top: 14px;
}

.login-forgot a {
  font-size: 12px;
  color: var(--gold-dark);
  letter-spacing: 0.02em;
  transition: color var(--fast);
}

.login-forgot a:hover { color: var(--gold-darker); }

.login-error {
  background: var(--danger-pale);
  border: 1px solid rgba(176,58,46,0.18);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 13px;
  padding: 10px 14px;
  text-align: center;
  display: none;
}

.login-footer {
  text-align: center;
  margin-top: 32px;
  font-size: 10px;
  color: var(--text-placeholder);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ============================================================
   APP SHELL
   ============================================================ */
#app-shell {
  display: none;
  height: 100vh;
  overflow: hidden;
}

.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
  transition: none;
}

/* ============================================================
   TOP-NAV LAYOUT MODE  (body[data-layout="topnav"])
   ============================================================ */
body[data-layout="topnav"] .app-layout {
  flex-direction: column;
}

/* Hide sidebar elements in top-nav mode */
body[data-layout="topnav"] .sidebar,
body[data-layout="topnav"] .sidebar-overlay,
body[data-layout="topnav"] .sidebar-toggle {
  display: none !important;
}

/* Hide the old top bar hamburger + page title (replaced by topnav bar) */
body[data-layout="topnav"] .top-bar {
  display: none;
}

/* The top-nav bar itself */
.topnav-bar {
  display: none; /* hidden by default (sidebar mode) */
  width: 100%;
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  align-items: stretch;
  padding: 0 16px;
  gap: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
  position: relative;
}

body[data-layout="topnav"] .topnav-bar {
  display: flex;
}

/* Logo section inside topnav */
.topnav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px 0 4px;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  cursor: pointer;
  min-width: 180px;
  text-decoration: none;
}
.topnav-logo:hover { text-decoration: none; background: var(--cream); }
.topnav-logo-img {
  height: 32px;
  width: auto;
  max-width: 100px;
  object-fit: contain;
}
.topnav-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.topnav-brand {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 400;
  color: var(--charcoal);
  letter-spacing: 0.02em;
}
.topnav-brand .sc { font-family: var(--font-script); font-size: 19px; }
.topnav-brand-sub {
  font-size: 8px;
  color: var(--text-muted);
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

/* Nav scrollable area */
.topnav-nav {
  display: flex;
  align-items: stretch;
  flex: 1;
  overflow-x: auto;
  gap: 0;
  scrollbar-width: none;
}
.topnav-nav::-webkit-scrollbar { display: none; }

/* Individual top-nav buttons */
.topnav-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  height: 100%;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  transition: color var(--fast), border-color var(--fast), background var(--fast);
  position: relative;
  min-height: 60px;
}
.topnav-btn:hover {
  color: var(--charcoal);
  background: var(--cream);
}
.topnav-btn.active {
  color: var(--gold-dark);
  font-weight: 700;
  border-bottom-color: var(--gold);
  background: var(--gold-bg);
}
.topnav-btn .nav-icon { font-size: 15px; }

/* Section divider inside topnav */
.topnav-divider {
  width: 1px;
  background: var(--border);
  margin: 12px 4px;
  flex-shrink: 0;
}

/* User / logout section */
.topnav-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-left: 1px solid var(--border);
  flex-shrink: 0;
}
.topnav-user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--gold-bg-mid);
  border: 1.5px solid var(--gold-pale);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--gold-dark);
  flex-shrink: 0;
}
.topnav-username {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--charcoal);
  white-space: nowrap;
}
.topnav-role {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: capitalize;
  white-space: nowrap;
}

/* In top-nav mode, main content fills remaining height */
body[data-layout="topnav"] .main-content {
  height: calc(100vh - 60px);
}

/* In top-nav mode show a minimal title bar above tab content */
body[data-layout="topnav"] .topnav-sub-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 44px;
  background: var(--cream);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}
.topnav-sub-bar { display: none; }
body[data-layout="topnav"] .topnav-sub-bar { display: flex; }
.topnav-sub-title {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 400;
  color: var(--charcoal);
  letter-spacing: 0.02em;
}
.topnav-sub-right { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-muted); }

/* Adjust tab-content in top-nav mode (less vertical space) */
body[data-layout="topnav"] .tab-content {
  height: calc(100vh - 60px - 44px);
  overflow-y: auto;
}

/* ── Layout Picker (Settings UI) ───────────────────────────── */
.layout-picker {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.layout-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.layout-option input[type="radio"] { display: none; }
.layout-preview {
  width: 140px;
  height: 90px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: var(--cream);
  position: relative;
}
.layout-option input:checked + .layout-preview {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-bg);
}
.layout-option:hover .layout-preview {
  border-color: var(--gold-pale);
}
/* Sidebar preview art */
.lp-sidebar {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 32px;
  background: var(--surface);
  border-right: 1.5px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding-top: 8px;
}
.lp-sb-dot { width: 18px; height: 6px; border-radius: 3px; background: var(--border-mid); }
.lp-sb-dot.active { background: var(--gold-pale); }
.lp-content {
  position: absolute;
  left: 34px; right: 4px; top: 6px; bottom: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.lp-top-bar { height: 10px; background: var(--surface); border-radius: 3px; border: 1px solid var(--border); }
.lp-body { flex: 1; background: var(--border); border-radius: 3px; opacity: 0.25; }
/* Topnav preview art */
.lp-topnav-bar {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 18px;
  background: var(--surface);
  border-bottom: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
}
.lp-tn-dot { width: 14px; height: 5px; border-radius: 3px; background: var(--border-mid); }
.lp-tn-dot.active { background: var(--gold-pale); }
.lp-tn-body {
  position: absolute;
  left: 4px; right: 4px; top: 22px; bottom: 4px;
  background: var(--border);
  border-radius: 3px;
  opacity: 0.25;
}
.layout-option-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}
.layout-option input:checked ~ .layout-option-label {
  color: var(--gold-dark);
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: visible;    /* must be visible so the toggle button (right:-12px) isn't clipped */
  transition: width var(--mid) var(--ease), min-width var(--mid) var(--ease);
  z-index: 100;
  position: relative;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
  min-width: var(--sidebar-collapsed);
}

/* Logo */
.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  flex-shrink: 0;
  min-height: 80px;
  overflow: hidden;   /* clip logo text during collapse, not the whole sidebar */
}

.sidebar-logo-img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: var(--radius-xs);
}

.sidebar-logo-text {
  overflow: hidden;
  white-space: nowrap;
  transition: opacity var(--mid) var(--ease), width var(--mid) var(--ease);
}

.sidebar-brand {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--charcoal);
  line-height: 1.1;
  display: block;
}

.sidebar-brand .sc { font-family: var(--font-script); font-size: 22px; }

.sidebar-brand-sub {
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  display: block;
  margin-top: 2px;
}

.sidebar.collapsed .sidebar-logo-text { opacity: 0; width: 0; pointer-events: none; }

/* Nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;   /* clip nav labels during collapse */
  padding: 12px 8px;
}

.nav-section-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-placeholder);
  padding: 12px 12px 4px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--mid);
}

.sidebar.collapsed .nav-section-label { opacity: 0; }

.nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  transition: background var(--fast), color var(--fast), box-shadow var(--fast);
  white-space: nowrap;
  overflow: hidden;
  text-align: left;
  position: relative;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}

.nav-btn:hover {
  background: var(--cream);
  color: var(--charcoal);
}

.nav-btn.active {
  background: var(--gold-bg);
  color: var(--gold-dark);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--gold);
}

.nav-btn .nav-icon {
  font-size: 17px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-btn .nav-label {
  transition: opacity var(--mid);
  flex: 1;
}

.sidebar.collapsed .nav-btn .nav-label { opacity: 0; }

.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 12px;
}

/* Sidebar Footer */
.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 14px 12px;
  /* Push up from bottom to stay visible above browser chrome on tablets/phones */
  padding-bottom: max(20px, calc(env(safe-area-inset-bottom, 0px) + 20px));
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  overflow: hidden;   /* clip user info during collapse */
}

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  background: var(--gold-bg-mid);
  border: 1px solid var(--gold-pale);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--gold-dark);
  flex-shrink: 0;
}

.sidebar-user-info { overflow: hidden; flex: 1; transition: opacity var(--mid); }
.sidebar-username { font-size: 12.5px; font-weight: 600; color: var(--charcoal); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-role { font-size: 10px; color: var(--text-muted); white-space: nowrap; text-transform: capitalize; }
.sidebar.collapsed .sidebar-user-info { opacity: 0; }

.btn-logout {
  padding: 6px 8px;
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  font-size: 13px;
  transition: color var(--fast), background var(--fast);
  flex-shrink: 0;
}

.btn-logout:hover { color: var(--danger); background: var(--danger-pale); }

/* Sidebar Toggle */
.sidebar-toggle {
  position: absolute;
  top: 50%;
  right: -13px;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 10px;
  color: var(--text-muted);
  box-shadow: var(--shadow-sm);
  transition: background var(--fast), color var(--fast), transform var(--fast);
  z-index: 200;   /* above main content so it's always clickable */
}

.sidebar-toggle:hover { background: var(--gold-bg); color: var(--gold-dark); }
.sidebar.collapsed .sidebar-toggle { transform: translateY(-50%) scaleX(-1); }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--cream);
  min-width: 0;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 16px;
}

.top-bar-left { display: flex; align-items: center; gap: 12px; }
.top-bar-right { display: flex; align-items: center; gap: 12px; }

.hamburger-btn {
  padding: 8px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: background var(--fast), color var(--fast);
  /* shown by default on mobile, hidden on desktop */
}

.hamburger-btn:hover { background: var(--cream); color: var(--charcoal); }

.top-bar-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 400;
  color: var(--charcoal);
  letter-spacing: 0.02em;
}

.tab-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 28px;
}

/* Tab Panels */
.tab-panel { display: none; animation: panelFadeIn var(--mid) var(--ease) both; }
.tab-panel.active { display: block; }

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

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 400;
  color: var(--charcoal);
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.page-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 400;
}

.page-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Section Title */
.section-title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 400;
  color: var(--charcoal);
  letter-spacing: 0.02em;
  margin-bottom: 16px;
}

/* ============================================================
   STAT CARDS (Dashboard)
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  transition: transform var(--mid) var(--ease), box-shadow var(--mid) var(--ease);
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
}

.stat-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.stat-value {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 400;
  color: var(--charcoal);
  line-height: 1;
  letter-spacing: -0.01em;
}

.stat-change {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

.stat-icon {
  position: absolute;
  top: 18px;
  right: 18px;
  font-size: 24px;
  opacity: 0.25;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 500;
  color: var(--charcoal);
}

.card-body { padding: 24px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--fast), color var(--fast), border-color var(--fast),
              transform var(--fast), box-shadow var(--fast);
  white-space: nowrap;
  text-decoration: none;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn:active { transform: scale(0.98); }

/* Primary – Charcoal */
.btn-primary {
  background: var(--charcoal);
  color: #FFFFFF;
  border-color: var(--charcoal);
}
.btn-primary:hover { background: var(--charcoal-soft); box-shadow: var(--shadow-sm); }

/* Gold */
.btn-gold {
  background: var(--gold);
  color: #FFFFFF;
  border-color: var(--gold);
}
.btn-gold:hover { background: var(--gold-dark); box-shadow: var(--shadow-gold); }

/* Outline Gold */
.btn-outline-gold {
  background: transparent;
  color: var(--gold-dark);
  border-color: var(--gold);
}
.btn-outline-gold:hover { background: var(--gold-bg); }

/* Outline */
.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-mid);
}
.btn-outline:hover { background: var(--cream); color: var(--charcoal); border-color: var(--border-dark); }

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--cream); color: var(--charcoal); }

/* Danger */
.btn-danger {
  background: var(--danger-pale);
  color: var(--danger);
  border-color: rgba(176,58,46,0.18);
}
.btn-danger:hover { background: var(--danger); color: #FFF; }

/* Success */
.btn-success {
  background: var(--success);
  color: #FFF;
  border-color: var(--success);
}
.btn-success:hover { background: #229954; }

/* Small */
.btn-sm {
  padding: 7px 14px;
  font-size: 12.5px;
  min-height: 36px;
}

/* Large */
.btn-lg {
  padding: 14px 28px;
  font-size: 15px;
  min-height: 52px;
}

/* Icon button */
.btn-icon {
  padding: 8px;
  min-height: 36px;
  min-width: 36px;
  border-radius: var(--radius-sm);
}

/* ============================================================
   SEARCH BAR
   ============================================================ */
.search-bar {
  position: relative;
  flex: 1;
  max-width: 400px;
}

.search-bar input {
  width: 100%;
  padding: 10px 16px 10px 46px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color var(--fast), box-shadow var(--fast);
  min-height: 44px;
}

.search-bar input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-bg);
}

.search-bar::before {
  content: '\1F50D';
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  pointer-events: none;
  opacity: 0.45;
  line-height: 1;
}

/* ============================================================
   TABLES
   ============================================================ */
.table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  overflow-y: hidden;
  box-shadow: var(--shadow-xs);
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table thead th {
  padding: 13px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-warm);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}

.data-table thead th:first-child { padding-left: 20px; }
.data-table thead th:last-child { padding-right: 20px; }

.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--fast);
}

.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: var(--cream); }

.data-table tbody td {
  padding: 13px 16px;
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table tbody td:first-child { padding-left: 20px; }
.data-table tbody td:last-child { padding-right: 20px; }

.data-table .td-muted { color: var(--text-muted); font-size: 12px; }
.data-table .td-mono { font-family: 'Courier New', monospace; font-size: 12.5px; }
.data-table .td-actions { display: flex; gap: 6px; align-items: center; white-space: nowrap; }

/* Compact layout on smaller screens */
@media (max-width: 1200px) {
  .data-table { font-size: 12px; }
  .data-table thead th { padding: 10px 8px; font-size: 11px; letter-spacing: 0.08em; }
  .data-table tbody td { padding: 10px 8px; }
  .data-table thead th:first-child,
  .data-table tbody td:first-child { padding-left: 12px; }
  .data-table thead th:last-child,
  .data-table tbody td:last-child  { padding-right: 12px; }
}

/* Empty state */
.table-empty {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

.table-empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }
.table-empty-text { font-size: 14px; }

/* ============================================================
   BADGES / PILLS
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.badge-gold { background: var(--gold-bg-mid); color: var(--gold-dark); }
.badge-success { background: var(--success-pale); color: var(--success); }
.badge-danger { background: var(--danger-pale); color: var(--danger); }
.badge-warn { background: var(--warn-pale); color: var(--warn); }
.badge-info { background: var(--info-pale); color: var(--info); }
.badge-muted { background: var(--cream); color: var(--text-muted); border: 1px solid var(--border); }

/* ============================================================
   FORMS
   ============================================================ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.form-grid-2 { grid-template-columns: repeat(2, 1fr); }
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }

.form-row { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 200px;
}

.form-group.full { flex-basis: 100%; }

.form-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.form-label.required::after { content: ' *'; color: var(--gold); }

.form-control {
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 13.5px;
  font-family: var(--font-sans);
  transition: border-color var(--fast), box-shadow var(--fast), background var(--fast);
  outline: none;
  width: 100%;
  min-height: 44px;
}

.form-control:focus {
  border-color: var(--gold);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--gold-bg);
}

.form-control::placeholder { color: var(--text-placeholder); }

.form-control:disabled {
  background: var(--cream);
  color: var(--text-muted);
  cursor: not-allowed;
}

.form-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239A9A9A' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.6;
}

/* Rich-text notes editor (contenteditable) — styled identical to .form-textarea */
.proc-notes-editor {
  overflow-y: auto;
  word-wrap: break-word;
  white-space: pre-wrap;
  outline: none;          /* focus ring comes from .form-control:focus */
  line-height: 1.6;
  font-size: 13.5px;
}
/* Placeholder via data-placeholder attribute */
.proc-notes-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-placeholder);
  pointer-events: none;
}
/* Inline color spans written by execCommand */
.proc-notes-editor span { font-size: inherit; line-height: inherit; }


.form-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 11.5px; color: var(--danger); margin-top: 4px; display: none; }
.form-error.show { display: block; }

.form-control.error { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-pale); }

/* Toggle / Checkbox styled */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.toggle-row:last-child { border-bottom: none; }

.toggle-label { font-size: 13.5px; color: var(--text-primary); font-weight: 500; }
.toggle-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border-mid);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--mid);
}

.toggle-track::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform var(--mid) var(--ease-spring);
  box-shadow: var(--shadow-xs);
}

.toggle-switch input:checked + .toggle-track { background: var(--gold); }
.toggle-switch input:checked + .toggle-track::before { transform: translateX(20px); }

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,26,26,0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: overlayFadeIn var(--fast) var(--ease);
}

@keyframes overlayFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  animation: modalSlideIn var(--mid) var(--ease-spring) both;
  overflow: hidden;
}

.modal-lg { max-width: 760px; }
.modal-xl { max-width: 1000px; }
.modal-sm { max-width: 400px; }
.modal-full { max-width: 100%; max-height: 100%; margin: 0; border-radius: 0; height: 100vh; }

@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(32px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 500;
  color: var(--charcoal);
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  background: var(--cream);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  transition: background var(--fast), color var(--fast);
  flex-shrink: 0;
}

.modal-close:hover { background: var(--danger-pale); color: var(--danger); }

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--charcoal);
  color: #FFFFFF;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 500;
  max-width: 340px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  animation: toastIn var(--mid) var(--ease-spring) both;
  border-left: 3px solid var(--gold);
}

.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error { border-left-color: var(--danger); }
.toast.toast-warn { border-left-color: var(--warn); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px) scale(0.95); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to   { opacity: 0; transform: translateX(20px) scale(0.95); }
}

.toast.out { animation: toastOut var(--mid) var(--ease) forwards; }

.toast-icon { font-size: 16px; flex-shrink: 0; }
.toast-message { flex: 1; }

/* ============================================================
   LOADING STATES
   ============================================================ */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(249,246,242,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  backdrop-filter: blur(2px);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-mid);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, var(--cream) 25%, var(--cream-dark) 50%, var(--cream) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer { to { background-position: -200% 0; } }

/* ============================================================
   PATIENT LIST
   ============================================================ */
.patient-list { display: flex; flex-direction: column; gap: 0; }

.patient-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--fast);
  -webkit-tap-highlight-color: transparent;
}

.patient-row:last-child { border-bottom: none; }
.patient-row:hover { background: var(--cream); }
.patient-row:active { background: var(--cream-dark); }

.patient-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-pill);
  background: var(--gold-bg-mid);
  border: 1px solid var(--gold-pale);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 500;
  color: var(--gold-dark);
  flex-shrink: 0;
  overflow: hidden;
}

.patient-avatar img { width: 100%; height: 100%; object-fit: cover; }

.patient-info { flex: 1; min-width: 0; }
.patient-name { font-size: 14px; font-weight: 600; color: var(--charcoal); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.patient-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.patient-num { font-size: 11.5px; font-family: 'Courier New', monospace; color: var(--text-muted); }

.patient-arrow { color: var(--text-placeholder); font-size: 16px; }

/* Alphabetical index sidebar */
.alpha-index {
  position: sticky;
  top: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 4px 2px;
  font-size: 10px;
  color: var(--gold-dark);
  font-weight: 600;
  cursor: pointer;
  z-index: 5;
}

.alpha-letter { padding: 2px 4px; border-radius: 2px; -webkit-tap-highlight-color: transparent; }
.alpha-letter:hover { background: var(--gold-bg); }

/* ============================================================
   PATIENT FOLDER VIEW
   ============================================================ */
.patient-folder {
  display: none;
  animation: panelFadeIn var(--mid) var(--ease) both;
}

.patient-folder.active { display: block; }

.patient-folder-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
}

.patient-folder-photo {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-pill);
  background: var(--gold-bg-mid);
  border: 2px solid var(--gold-pale);
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 28px;
  color: var(--gold-dark);
}

.patient-folder-photo img { width: 100%; height: 100%; object-fit: cover; }

.patient-folder-details { flex: 1; min-width: 0; }
.patient-folder-name {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 400;
  color: var(--charcoal);
  letter-spacing: 0.02em;
}

.patient-folder-meta { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 8px; }
.patient-folder-meta-item { font-size: 13px; color: var(--text-muted); }
.patient-folder-meta-item strong { color: var(--text-primary); font-weight: 600; }

/* ── Treatment History Timeline ─────────────────────────────────────────── */
.tx-history-timeline {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-left: 36px;
}
.tx-history-timeline::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: linear-gradient(to bottom, var(--gold), transparent);
  border-radius: 2px;
}
.tx-history-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  transition: box-shadow .18s, border-color .18s;
}
.tx-history-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.10);
  border-color: var(--gold-pale);
}
.tx-history-card::before {
  content: '';
  position: absolute;
  left: -30px;
  top: 20px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 2px var(--gold);
}
.tx-history-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.tx-history-date {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--gold);
  color: #1a1a1a;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: .3px;
}
.tx-history-practitioner {
  font-size: 12.5px;
  color: var(--text-muted);
  font-style: italic;
}
.tx-history-notes {
  font-size: 13.5px;
  color: #1a1a1a;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.tx-history-notes:empty::after {
  content: 'No notes recorded.';
  color: var(--text-muted);
  font-style: italic;
}
.tx-history-products {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tx-history-product-chip {
  background: var(--surface-warm);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11.5px;
  color: var(--text-primary);
  font-weight: 500;
}
.tx-history-empty {
  font-size: 13px;
  color: var(--text-muted);
  padding: 8px 0;
  font-style: italic;
}

.procedure-timeline { display: flex; flex-direction: column; gap: 16px; }

.procedure-entry {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow var(--mid);
}

.procedure-entry:hover { box-shadow: var(--shadow-sm); }

.procedure-entry-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  -webkit-tap-highlight-color: transparent;
}

.procedure-entry-date { font-size: 12.5px; color: var(--text-muted); }
.procedure-entry-num { font-size: 13px; font-weight: 600; color: var(--charcoal); }
.procedure-entry-practitioner { font-size: 12.5px; color: var(--gold-dark); }
.procedure-entry-body { padding: 16px 20px; display: none; }
.procedure-entry.open .procedure-entry-body { display: block; }

/* ============================================================
   PROCEDURE FORM
   ============================================================ */
.procedure-form-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.face-annotation-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  min-height: 400px;
}

.face-canvas-wrapper {
  position: relative;
  cursor: crosshair;
  user-select: none;
  -webkit-user-select: none;
}

.face-canvas-wrapper canvas {
  display: block;
  max-width: 100%;
  touch-action: none;
}

.face-canvas-wrapper .annotation-dot {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid white;
  box-shadow: 0 0 0 1px var(--danger), 0 2px 4px rgba(0,0,0,0.3);
  transform: translate(-50%, -50%);
  cursor: pointer;
  transition: transform var(--fast);
  pointer-events: all;
}

.face-canvas-wrapper .annotation-dot:hover { transform: translate(-50%, -50%) scale(1.3); }

.face-canvas-controls {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Procedure line items */
.procedure-lines-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.procedure-lines-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.line-item {
  display: block;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
}

.line-item:last-child { border-bottom: none; }

.line-item-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.line-item-product { flex: 1; min-width: 0; }
.line-item-name { font-size: 13.5px; font-weight: 500; color: var(--charcoal); }
.line-item-sku { font-size: 11.5px; color: var(--text-muted); font-family: monospace; }
.line-item-qty { width: 65px; }
.line-item-price { font-size: 13px; font-weight: 600; color: var(--charcoal); white-space: nowrap; min-width: 90px; text-align: right; }
.line-item-remove { color: var(--text-muted); cursor: pointer; padding: 4px; border-radius: var(--radius-xs); transition: color var(--fast), background var(--fast); }
.line-item-remove:hover { color: var(--danger); background: var(--danger-pale); }

/* ── Wide procedure line items (full-screen procedure modal) ── */
.proc-lines-header-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px;
  background: var(--surface-2, #f8f9fa);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.proc-line {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.proc-line:last-of-type { border-bottom: none; }
.proc-line-top {
  display: flex;
  align-items: center;
  gap: 10px;
}
.proc-line-desc { flex: 1; min-width: 0; }
.proc-line-qty  { width: 70px;  flex-shrink: 0; }
.proc-line-price { width: 113px; flex-shrink: 0; }
.proc-line-total {
  width: 110px;
  flex-shrink: 0;
  text-align: right;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--charcoal);
}
.proc-line-remove {
  width: 28px;
  flex-shrink: 0;
  text-align: center;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: var(--radius-xs);
  padding: 4px;
  transition: color var(--fast), background var(--fast);
}
.proc-line-remove:hover { color: var(--danger); background: var(--danger-pale); }
.proc-line-comment { margin-top: 6px; }

/* Product search dropdown */
.product-search-dropdown {
  position: relative;
}

.product-dropdown-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 500;
  max-height: 240px;
  overflow-y: auto;
  display: none;
}

.product-dropdown-results.open { display: block; }

.product-dropdown-item {
  padding: 11px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background var(--fast);
  border-bottom: 1px solid var(--border);
}

.product-dropdown-item:last-child { border-bottom: none; }
.product-dropdown-item:hover { background: var(--cream); }
.product-dropdown-item .pi-sku { font-size: 11px; font-family: monospace; color: var(--text-muted); }
.product-dropdown-item .pi-name { font-size: 13px; font-weight: 500; color: var(--charcoal); }
.product-dropdown-item .pi-price { font-size: 12px; color: var(--gold-dark); margin-left: auto; }

/* Invoice / quote totals */
.invoice-totals {
  padding: 16px 20px;
  border-top: 2px solid var(--border);
  background: var(--surface-warm);
}

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 13.5px;
  color: var(--charcoal);
}

.total-row.grand-total {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
  color: var(--charcoal);
  border-top: 1px solid var(--border-mid);
  margin-top: 8px;
  padding-top: 12px;
}
/* Force invoice total rows to always show as dark text on white card */
.invoice-doc-body .total-row,
.invoice-doc-body .total-row.grand-total {
  color: #1a1a1a !important;
}


/* Photo grid */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.photo-thumb {
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  background: var(--cream);
  border: 1px solid var(--border);
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--mid);
}

.photo-thumb:hover img { transform: scale(1.05); }

.photo-thumb .photo-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  background: rgba(26,26,26,0.7);
  color: white;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  opacity: 0;
  transition: opacity var(--fast);
  cursor: pointer;
}

.photo-thumb:hover .photo-delete { opacity: 1; }

.photo-add-btn {
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  border: 2px dashed var(--border-mid);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 12px;
  gap: 6px;
  transition: border-color var(--fast), color var(--fast), background var(--fast);
  background: var(--cream);
}

.photo-add-btn:hover { border-color: var(--gold); color: var(--gold-dark); background: var(--gold-bg); }
.photo-add-btn-icon { font-size: 24px; }

/* Camera overlay */
.camera-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(26,26,26,0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
}

.camera-video {
  max-width: min(480px, 90vw);
  max-height: 60vh;
  border-radius: var(--radius-lg);
  background: #000;
  object-fit: cover;
  display: block;
}

.camera-preview {
  max-width: min(480px, 90vw);
  max-height: 60vh;
  border-radius: var(--radius-lg);
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.15);
  display: block;
}

.camera-controls { display: flex; gap: 12px; align-items: center; }

.camera-capture-btn {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-pill);
  background: white;
  border: 4px solid rgba(255,255,255,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  cursor: pointer;
  transition: transform var(--fast), background var(--fast);
}

.camera-capture-btn:hover { transform: scale(1.08); background: var(--gold-pale); }

.camera-count { color: rgba(255,255,255,0.7); font-size: 13px; }

/* ============================================================
   SIGNATURE PAD
   ============================================================ */
.signature-pad-wrapper {
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow: hidden;
  position: relative;
}

.signature-pad-canvas {
  display: block;
  width: 100%;
  touch-action: none;
  cursor: crosshair;
}

.signature-pad-footer {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-warm);
}

.signature-pad-stamp { font-size: 10px; color: var(--text-muted); font-style: italic; }

/* ============================================================
   CONFIG TAB (Superuser)
   ============================================================ */
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.config-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.config-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-warm);
}

.config-card-title { font-weight: 600; font-size: 14px; color: var(--charcoal); }
.config-card-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.config-card-body { padding: 4px 0; }

/* ============================================================
   SETTINGS TAB
   ============================================================ */
.settings-nav {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
  overflow-x: auto;
  flex-wrap: nowrap;
}

.settings-nav-btn {
  padding: 10px 20px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color var(--fast), border-color var(--fast);
  min-height: 44px;
}

.settings-nav-btn:hover { color: var(--charcoal); }
.settings-nav-btn.active { color: var(--gold-dark); border-bottom-color: var(--gold); }

.settings-section { display: none; }
.settings-section.active { display: block; }

/* Logo upload */
.logo-upload-area {
  border: 2px dashed var(--border-mid);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--fast), background var(--fast);
  position: relative;
  overflow: hidden;
}

.logo-upload-area:hover { border-color: var(--gold); background: var(--gold-bg); }
.logo-upload-area input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.logo-preview {
  max-width: 200px;
  max-height: 80px;
  object-fit: contain;
  margin: 0 auto 16px;
  display: block;
}

/* ============================================================
   PRACTITIONER REPORT
   ============================================================ */
.practitioner-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
}

.practitioner-card-header {
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--surface-warm);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.prac-name { font-family: var(--font-serif); font-size: 18px; font-weight: 500; color: var(--charcoal); }
.prac-total { font-size: 22px; font-weight: 700; color: var(--gold-dark); font-family: var(--font-serif); }
.prac-total-label { font-size: 11px; color: var(--text-muted); letter-spacing: 0.06em; text-transform: uppercase; }

/* ============================================================
   INVOICE / QUOTE DOCUMENT
   ============================================================ */
.invoice-doc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.invoice-doc-header {
  padding: 36px 40px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 24px;
}

.invoice-practice-logo {
  max-width: 160px;
  max-height: 60px;
  object-fit: contain;
}

.invoice-doc-number {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 300;
  color: var(--charcoal);
  text-align: right;
}

.invoice-doc-number span { color: var(--gold-dark); }

.invoice-doc-body { padding: 28px 40px; color: #1a1a1a; }
.invoice-doc-footer { padding: 24px 40px; border-top: 1px solid var(--border); background: var(--surface-warm); }

/* ============================================================
   DASHBOARD – GOOGLE CALENDAR
   ============================================================ */
.calendar-embed-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.calendar-embed-container iframe {
  display: block;
  width: 100%;
  border: none;
  border-radius: var(--radius-lg);
}

.calendar-placeholder {
  padding: 48px;
  text-align: center;
  color: var(--text-muted);
}

/* ============================================================
   STATEMENT
   ============================================================ */
.statement-doc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 40px;
}

.statement-balance-due {
  background: var(--gold-bg);
  border: 1px solid var(--gold-pale);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.balance-label { font-size: 12px; font-weight: 700; letter-spacing: 0.10em; text-transform: uppercase; color: var(--gold-dark); }
.balance-amount { font-family: var(--font-serif); font-size: 32px; font-weight: 500; color: var(--charcoal); }

/* ============================================================
   YOCO PAYMENT MODAL
   ============================================================ */
.yoco-modal-amount {
  font-family: var(--font-serif);
  font-size: 48px;
  font-weight: 300;
  color: var(--charcoal);
  text-align: center;
  margin: 16px 0;
  letter-spacing: -0.02em;
}

.yoco-qr-container {
  text-align: center;
  padding: 20px;
}

.yoco-qr-container img { max-width: 200px; margin: 0 auto; }

/* ============================================================
   RESPONSIVE – iPad & Mobile
   ============================================================ */
@media (max-width: 1024px) {
  :root { --sidebar-w: 220px; }

  .hamburger-btn { display: flex; }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    transform: translateX(0);
    transition: transform var(--mid) var(--ease), width var(--mid) var(--ease);
    box-shadow: var(--shadow-xl);
  }

  .sidebar.hidden-mobile {
    transform: translateX(-100%);
    box-shadow: none;
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26,26,26,0.4);
    z-index: 190;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--mid);
  }

  .sidebar-overlay.visible { opacity: 1; pointer-events: auto; }

  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }

  .procedure-form-layout { grid-template-columns: 1fr; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  .sidebar-toggle { display: none; }

  .tab-content { padding: 20px; }
}

@media (max-width: 768px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .photo-grid { grid-template-columns: repeat(2, 1fr); }
  .page-header { flex-direction: column; }
  .tab-content { padding: 16px; }
  .invoice-doc-header { flex-direction: column; }
  .form-row { flex-direction: column; }
  .form-group { min-width: 0; }
  .modal { max-height: 100vh; border-radius: var(--radius-lg); }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .login-card { padding: 36px 24px 28px; }
  .page-title { font-size: 22px; }
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal { border-radius: var(--radius-xl) var(--radius-xl) 0 0; max-height: 95vh; }
}

/* iPad-specific touch optimizations */
@media (hover: none) and (pointer: coarse) {
  .nav-btn { min-height: 52px; }
  .btn { min-height: 52px; }
  .form-control { min-height: 52px; font-size: 16px; } /* prevent iOS zoom */
  .btn-sm { min-height: 44px; }
}

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {
  body { background: white; overflow: auto; }
  .sidebar, .top-bar, .toast-container, .btn, .nav-btn,
  .modal-footer, .page-actions { display: none !important; }
  .app-layout { display: block; }
  .main-content { overflow: visible; }
  .tab-content { padding: 0; overflow: visible; }
  .invoice-doc, .statement-doc { box-shadow: none; border: none; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.text-gold { color: var(--gold-dark); }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-serif { font-family: var(--font-serif); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-600 { font-weight: 600; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* Gold accent line (used in various sections) */
.gold-line {
  width: 40px;
  height: 2px;
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
  border-radius: var(--radius-pill);
  margin: 8px 0 16px;
}

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

/* Focus ring for accessibility */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════
   PATIENT LIST & FOLDER
═══════════════════════════════════════════════════════════ */
.patient-list { display: flex; flex-direction: column; gap: 0; }

.patient-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  background: var(--surface);
}
.patient-row:hover { background: var(--gold-bg); }
.patient-row:last-child { border-bottom: none; }

.patient-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--gold-bg-mid);
  border: 1.5px solid var(--gold-pale);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 600;
  color: var(--gold-dark);
  flex-shrink: 0;
  overflow: hidden;
}
.patient-avatar img { width: 100%; height: 100%; object-fit: cover; }

.patient-info { flex: 1; min-width: 0; }
.patient-name { font-weight: 600; font-size: 14.5px; color: var(--charcoal); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.patient-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.patient-num  { font-size: 12px; color: var(--text-muted); font-family: monospace; white-space: nowrap; }
.patient-arrow { color: var(--gold); font-size: 18px; flex-shrink: 0; }

/* Patient Folder */
.patient-folder { display: none; }

.patient-folder-header {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.patient-folder-photo {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px solid var(--gold-pale);
  background: var(--gold-bg-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 600;
  color: var(--gold-dark);
  flex-shrink: 0;
  overflow: hidden;
}

.patient-folder-details { flex: 1; min-width: 200px; }
.patient-folder-name { font-family: var(--font-serif); font-size: 26px; font-weight: 500; color: var(--charcoal); margin-bottom: 12px; }
.patient-folder-meta { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.patient-folder-meta-item { font-size: 13px; color: var(--text-secondary); }
.patient-folder-meta-item strong { color: var(--charcoal); font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; display: block; margin-bottom: 2px; }

/* Procedure Timeline */
.procedure-timeline { display: flex; flex-direction: column; gap: 0; }

.procedure-entry {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  background: var(--surface);
  overflow: hidden;
  transition: box-shadow 0.2s;
}
.procedure-entry:hover { box-shadow: var(--shadow-md); }

.procedure-entry-header {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 16px 20px;
  cursor: pointer;
  justify-content: space-between;
  flex-wrap: wrap;
}
.procedure-entry-header:hover { background: var(--gold-bg); }

.procedure-entry-num { font-family: monospace; font-weight: 700; font-size: 14px; color: var(--charcoal); }
.procedure-entry-date { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.procedure-entry-practitioner { font-size: 13.5px; font-weight: 600; color: var(--charcoal); }

.procedure-entry-body {
  display: none;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--cream);
}
.procedure-entry.open .procedure-entry-body { display: block; }
.procedure-entry.open .procedure-entry-header { border-bottom: none; }

/* ═══════════════════════════════════════════════════════════
   PROCEDURE FORM (MODAL)
═══════════════════════════════════════════════════════════ */
.procedure-form-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 768px) { .procedure-form-layout { grid-template-columns: 1fr; } }

/* Face Annotation */
.face-annotation-container { display: flex; flex-direction: column; gap: 12px; }
.face-canvas-wrapper { position: relative; border: 1.5px solid var(--border); border-radius: var(--radius-md); overflow: hidden; background: var(--surface); }
.face-canvas-wrapper img { width: 100%; display: block; max-width: 280px; user-select: none; -webkit-user-drag: none; }

.annotation-dot {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid white;
  box-shadow: 0 1px 6px rgba(0,0,0,0.3);
  transform: translate(-50%, -50%);
  cursor: pointer;
  transition: transform 0.15s;
  pointer-events: all;
  z-index: 2;
}
.annotation-dot:hover { transform: translate(-50%,-50%) scale(1.35); background: var(--danger); }

.face-canvas-controls { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

/* Procedure Lines Panel */
.procedure-lines-panel {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.procedure-lines-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-warm);
}

/* Product search dropdown */
.product-search-dropdown { position: relative; }
.product-dropdown-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1.5px solid var(--gold-pale);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  z-index: 200;
  max-height: 280px;
  overflow-y: auto;
  display: none;
}
.product-dropdown-results.open { display: block; }

.product-dropdown-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.product-dropdown-item:last-child { border-bottom: none; }
.product-dropdown-item:hover { background: var(--gold-bg); }
.product-dropdown-item .pi-sku { font-size: 11px; font-family: monospace; color: var(--gold-dark); font-weight: 700; }
.product-dropdown-item .pi-name { font-size: 13.5px; font-weight: 500; margin-top: 2px; color: var(--charcoal); }
.product-dropdown-item .pi-price { font-size: 13px; font-weight: 600; color: var(--text-secondary); white-space: nowrap; }

/* Line Items */
.line-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.line-item:last-child { border-bottom: none; }
.line-item-product { flex: 1; min-width: 0; }
.line-item-name { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.line-item-sku  { font-size: 11px; font-family: monospace; color: var(--gold-dark); }
.line-item-qty  { flex-shrink: 0; }
.line-item-price{ font-weight: 700; font-size: 14px; white-space: nowrap; color: var(--charcoal); min-width: 80px; text-align: right; }
.line-item-remove { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-muted); font-size: 11px; flex-shrink: 0; transition: all 0.15s; }
.line-item-remove:hover { background: var(--danger-pale); color: var(--danger); }

/* Invoice Totals */
.invoice-totals { border-top: 1.5px solid var(--border); padding: 14px 16px; background: var(--surface-warm); }
.total-row { display: flex; justify-content: space-between; font-size: 13.5px; padding: 4px 0; color: var(--text-secondary); }
.total-row.grand-total { font-size: 16px; font-weight: 700; color: var(--charcoal); border-top: 1px solid var(--border); margin-top: 6px; padding-top: 8px; }

/* ═══════════════════════════════════════════════════════════
   PHOTO GRID
═══════════════════════════════════════════════════════════ */
.photo-grid { display: flex; gap: 8px; flex-wrap: wrap; }

.photo-thumb {
  position: relative;
  width: 100px;
  height: 100px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1.5px solid var(--border);
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; }
.photo-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(176,58,46,0.85);
  color: white;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.15s;
}

.photo-add-btn {
  width: 100px;
  height: 100px;
  border-radius: var(--radius-md);
  border: 1.5px dashed var(--border-mid);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  transition: border-color 0.15s, background 0.15s;
}
.photo-add-btn:hover { border-color: var(--gold); background: var(--gold-bg); color: var(--gold-dark); }
.photo-add-btn-icon { font-size: 20px; }

/* ═══════════════════════════════════════════════════════════
   CAMERA OVERLAY
═══════════════════════════════════════════════════════════ */
.camera-overlay {
  position: fixed;
  inset: 0;
  z-index: 4000;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px;
}

.camera-video {
  width: min(90vw, 600px);
  height: auto;
  border-radius: var(--radius-lg);
  object-fit: cover;
  border: 2px solid var(--gold-pale);
}

.camera-preview {
  width: min(90vw, 600px);
  height: auto;
  border-radius: var(--radius-lg);
  border: 2px solid var(--gold);
}

.camera-controls {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: center;
}

.camera-capture-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--gold);
  border: 4px solid rgba(255,255,255,0.3);
  font-size: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background 0.15s;
  box-shadow: 0 0 0 4px var(--gold-glow);
}
.camera-capture-btn:hover { transform: scale(1.05); background: var(--gold-dark); }
.camera-capture-btn:active { transform: scale(0.95); }

/* ═══════════════════════════════════════════════════════════
   INVOICE DOCUMENT VIEW
═══════════════════════════════════════════════════════════ */
.invoice-doc {
  max-width: 700px;
  margin: 0 auto;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.invoice-doc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 32px;
  background: var(--cream);
  gap: 24px;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--gold-pale);
}

.invoice-practice-logo { max-height: 70px; max-width: 200px; object-fit: contain; }

.invoice-doc-number {
  font-family: var(--font-serif);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.invoice-doc-number span { font-size: 22px; font-weight: 700; color: var(--charcoal); letter-spacing: 0; display: block; }

/* Invoice body is always on white paper — force dark text regardless of app theme */
.invoice-doc-body {
  padding: 28px 32px;
  color: #1A1A1A;
}

.invoice-doc-footer {
  padding: 20px 32px;
  border-top: 1px solid var(--border);
  background: var(--surface-warm);
  color: #1A1A1A;
}

/* ═══════════════════════════════════════════════════════════
   CONFIG GRID
═══════════════════════════════════════════════════════════ */
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.config-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: box-shadow 0.2s;
}
.config-card:hover { box-shadow: var(--shadow-md); }

.config-card-header { padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--surface-warm); }
.config-card-title { font-weight: 700; font-size: 14px; color: var(--charcoal); }
.config-card-desc { font-size: 12px; color: var(--text-muted); margin-top: 4px; line-height: 1.5; }
.config-card-body { padding: 12px 16px; }

/* ═══════════════════════════════════════════════════════════
   TOGGLE SWITCH
═══════════════════════════════════════════════════════════ */
.toggle-switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.toggle-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  display: inline-block;
  width: 46px;
  height: 26px;
  background: var(--border-mid);
  border-radius: var(--radius-pill);
  position: relative;
  transition: background 0.25s;
}
.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  transition: transform 0.25s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-track { background: var(--gold); }
.toggle-switch input:checked + .toggle-track::after { transform: translateX(20px); }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-label { font-weight: 600; font-size: 13.5px; color: var(--charcoal); }
.toggle-desc { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* ═══════════════════════════════════════════════════════════
   PRACTITIONER CARDS
═══════════════════════════════════════════════════════════ */
.practitioner-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  overflow: hidden;
}
.practitioner-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  cursor: pointer;
  gap: 16px;
  flex-wrap: wrap;
}
.practitioner-card-header:hover { background: var(--gold-bg); }
.prac-name { font-weight: 700; font-size: 15px; color: var(--charcoal); }
.prac-total-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 2px; }
.prac-total { font-size: 20px; font-weight: 700; color: var(--gold-dark); font-family: var(--font-serif); }

/* ═══════════════════════════════════════════════════════════
   LOGO UPLOAD
═══════════════════════════════════════════════════════════ */
.logo-upload-area {
  border: 2px dashed var(--border-mid);
  border-radius: var(--radius-md);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  gap: 8px;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
  min-height: 120px;
}
.logo-upload-area:hover { border-color: var(--gold); background: var(--gold-bg); }
.logo-preview { max-height: 60px; max-width: 200px; object-fit: contain; border-radius: var(--radius-sm); }

/* ═══════════════════════════════════════════════════════════
   SETTINGS NAV
═══════════════════════════════════════════════════════════ */
.settings-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  background: var(--cream);
  padding: 6px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.settings-nav-btn {
  padding: 8px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s;
  white-space: nowrap;
}
.settings-nav-btn:hover { background: var(--surface); color: var(--charcoal); }
.settings-nav-btn.active { background: var(--surface); color: var(--gold-dark); font-weight: 700; box-shadow: var(--shadow-sm); }

.settings-section { display: none; }
.settings-section.active { display: block; }

/* ═══════════════════════════════════════════════════════════
   YOCO MODAL
═══════════════════════════════════════════════════════════ */
.yoco-modal-amount {
  font-family: var(--font-serif);
  font-size: 40px;
  font-weight: 500;
  color: var(--charcoal);
  margin: 16px 0 24px;
}
.yoco-qr-container {
  display: flex;
  justify-content: center;
  padding: 16px;
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  margin-bottom: 8px;
}

/* ═══════════════════════════════════════════════════════════
   CALENDAR EMBED
═══════════════════════════════════════════════════════════ */
.calendar-embed-container {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1.5px solid var(--border);
}
.calendar-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  background: var(--surface-warm);
  min-height: 260px;
}

/* ═══════════════════════════════════════════════════════════
   SEARCH BAR
═══════════════════════════════════════════════════════════ */
.search-bar input {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 9px 16px 9px 46px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--charcoal);
  width: 100%;
  min-height: 40px;
  transition: border-color 0.2s;
}
.search-bar input:focus { border-color: var(--gold); outline: none; }
.search-bar input::placeholder { color: var(--text-placeholder); }

/* ═══════════════════════════════════════════════════════════
   EXTRA BUTTON VARIANTS
═══════════════════════════════════════════════════════════ */
.btn-outline-gold {
  background: transparent;
  border: 1.5px solid var(--gold);
  color: var(--gold-dark);
  padding: 9px 20px;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-outline-gold:hover { background: var(--gold); color: white; }
.btn-gold {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  border: none;
  color: white;
  padding: 9px 20px;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-gold:hover { opacity: 0.88; }

.btn-success {
  background: var(--success);
  border: none;
  color: white;
  padding: 9px 20px;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-success:hover { opacity: 0.88; }

/* ═══════════════════════════════════════════════════════════
   TABLE HELPERS
═══════════════════════════════════════════════════════════ */
.td-mono { font-family: monospace; font-size: 13px; font-weight: 600; letter-spacing: 0.02em; }
.td-muted { color: var(--text-muted); font-size: 13px; }
.td-actions { white-space: nowrap; display: flex; gap: 6px; }

/* ═══════════════════════════════════════════════════════════
   FORM HINTS, ERRORS
═══════════════════════════════════════════════════════════ */
.form-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; line-height: 1.5; }
.form-error { font-size: 12.5px; color: var(--danger); margin-top: 6px; background: var(--danger-pale); border: 1px solid rgba(176,58,46,0.2); border-radius: var(--radius-sm); padding: 8px 12px; }

/* ═══════════════════════════════════════════════════════════
   LOGIN SCREEN EXTRAS
═══════════════════════════════════════════════════════════ */
.login-brand-name {
  font-family: var(--font-serif);
  font-size: 38px;
  font-weight: 300;
  letter-spacing: 0.08em;
  color: var(--charcoal);
}
.login-brand-name .script-part {
  font-style: italic;
  font-weight: 400;
}
.login-brand-sub {
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 4px;
}
.login-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-pale), transparent);
  margin: 24px 0;
}
.login-forgot {
  text-align: center;
  margin-top: 12px;
}
.login-forgot a {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}
.login-forgot a:hover { color: var(--gold-dark); }
.login-footer {
  text-align: center;
  font-size: 11px;
  color: var(--text-placeholder);
  margin-top: 24px;
  letter-spacing: 0.05em;
}
.login-error {
  background: var(--danger-pale);
  border: 1px solid rgba(176,58,46,0.2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--danger);
  display: none;
  margin-bottom: 12px;
}

/* ═══════════════════════════════════════════════════════════
   SPINNER
═══════════════════════════════════════════════════════════ */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ═══════════════════════════════════════════════════════════
   STATEMENTS
═══════════════════════════════════════════════════════════ */
#statement-preview .invoice-doc { margin-top: 0; }

/* ═══════════════════════════════════════════════════════════
   MOBILE TOUCH IMPROVEMENTS
═══════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-actions { width: 100%; flex-wrap: wrap; }
  .modal { max-height: 95vh; margin: 12px; }
  .modal-xl { width: calc(100vw - 24px); }
  .patient-folder-header { flex-direction: column; }
  .procedure-form-layout { grid-template-columns: 1fr; }
  .config-grid { grid-template-columns: 1fr; }
  .invoice-doc-header { flex-direction: column; }
  .settings-nav { gap: 2px; }
  .settings-nav-btn { font-size: 12px; padding: 7px 10px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .login-brand-name { font-size: 28px; }
  .procedure-lines-header { flex-direction: column; align-items: flex-start; gap: 8px; }
}
/* ═══════════════════════════════════════════════════════════
   NATIVE APPOINTMENT CALENDAR
═══════════════════════════════════════════════════════════ */
.cal-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 0 12px;
}
.cal-topbar-left, .cal-topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.cal-period-label {
  font-size: 16px;
  font-weight: 600;
  color: var(--charcoal);
  min-width: 180px;
}
.cal-view-tabs {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.cal-tab {
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}
.cal-tab.active {
  background: var(--gold);
  color: var(--cream-deeper);
  font-weight: 700;
}
.cal-tab:hover:not(.active) { background: var(--surface-warm); }

/* Legend */
.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  min-height: 28px;
}
.cal-legend-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px 4px 8px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--charcoal);
  transition: all .15s;
}
.cal-legend-pill.active { border-color: var(--pc, #2DD4BF); background: color-mix(in srgb, var(--pc, #2DD4BF) 15%, transparent); }
.cal-legend-pill:hover { border-color: var(--pc, #2DD4BF); }
.cal-legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.cal-legend-clear { padding: 4px 12px; border-radius: 20px; border: 1.5px solid var(--border); background: transparent; font-size: 12px; cursor: pointer; color: var(--text-secondary); }

/* Container */
.cal-container { width: 100%; overflow-x: auto; }

/* ─── Month Grid ─────────────────────────── */
.cal-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--border);
  gap: 1px;
}
.cal-dow {
  background: var(--surface-warm);
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-secondary);
  padding: 8px 4px;
}
.cal-cell {
  background: var(--surface);
  min-height: 100px;
  padding: 6px 4px;
  cursor: pointer;
  transition: background .1s;
  position: relative;
}
.cal-cell:hover { background: var(--surface-warm); }
.cal-cell-other { background: var(--surface-raised); opacity: .55; }
.cal-cell-other:hover { opacity: .75; }
.cal-cell-today { background: color-mix(in srgb, var(--gold) 8%, var(--surface)); }
.cal-dn {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  color: var(--charcoal);
  margin-bottom: 4px;
  line-height: 1;
}
.cal-today-badge {
  background: var(--gold);
  color: var(--cream-deeper) !important;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}
.cal-chip {
  display: block;
  border-radius: 4px;
  padding: 2px 5px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: filter .1s;
}
.cal-chip:hover { filter: brightness(1.15); }
.cal-more { font-size: 10px; color: var(--text-secondary); padding: 1px 4px; }

/* ─── Week Grid ──────────────────────────── */
.cal-week-grid {
  display: grid;
  grid-template-columns: 52px repeat(var(--wk-cols, 7), 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--border);
  gap: 1px;
  min-width: 520px;
}
.cal-wk-gutter { background: var(--surface-warm); }
.cal-wk-hdr {
  background: var(--surface-warm);
  text-align: center;
  padding: 8px 4px;
  cursor: pointer;
  font-size: 12px;
}
.cal-wk-hdr:hover { background: var(--surface); }
.cal-wk-today { background: color-mix(in srgb, var(--gold) 12%, var(--surface-warm)); }
.cal-wk-dow { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-secondary); }
.cal-wk-date { font-size: 18px; font-weight: 700; color: var(--charcoal); }
.cal-wk-time {
  background: var(--surface-warm);
  font-size: 11px;
  color: var(--text-secondary);
  padding: 6px 4px;
  text-align: right;
  white-space: nowrap;
  vertical-align: top;
}
.cal-wk-slot {
  background: var(--surface);
  min-height: 48px;
  padding: 2px;
  cursor: pointer;
  position: relative;
  transition: background .1s;
}
.cal-wk-slot:hover { background: var(--surface-warm); }
.cal-block {
  border-radius: 4px;
  padding: 3px 6px;
  margin-bottom: 2px;
  color: #fff;
  font-size: 11px;
  cursor: pointer;
  transition: filter .1s;
}
.cal-block:hover { filter: brightness(1.12); }

/* ─── Day View — Practitioner Grid ──────── */
.cal-dv-wrap {
  display: flex;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  min-width: 0;
}
.cal-dv-today { border-color: var(--gold); }

.cal-dv-times {
  width: 56px;
  flex-shrink: 0;
  background: var(--surface-warm);
  border-right: 1px solid var(--border);
  position: sticky;
  left: 0;
  z-index: 5;
}
.cal-dv-time-label {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 2px 6px 0 0;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-secondary);
  box-sizing: border-box;
}
.cal-dv-time-label.on-hour { border-top: 1px solid var(--border); }
.cal-dv-time-label.off-hour { border-top: 1px dashed rgba(0,0,0,.08); }

.cal-dv-col {
  flex: 1;
  min-width: 150px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.cal-dv-col:last-child { border-right: none; }

.cal-dv-col-hdr {
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border);
  background: var(--surface-warm);
  padding: 0 8px;
  text-align: center;
  gap: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-dv-times .cal-dv-col-hdr { border-bottom: 2px solid var(--border); }

.cal-dv-col-body {
  position: relative;
  flex: 1;
}

/* Slot zones — stacked vertically, create grid background */
.cal-dv-slot-zone {
  box-sizing: border-box;
  cursor: pointer;
  transition: background .1s;
}
.cal-dv-slot-zone.on-hour  { border-top: 1px solid var(--border); }
.cal-dv-slot-zone.off-hour { border-top: 1px dashed rgba(0,0,0,.07); }
.cal-dv-slot-zone:hover    { background: rgba(0,0,0,.03); }

/* Appointment blocks — absolutely positioned */
.cal-dv-appt {
  position: absolute;
  left: 3px;
  right: 3px;
  border-radius: 6px;
  padding: 4px 7px;
  overflow: hidden;
  cursor: pointer;
  color: #fff;
  box-sizing: border-box;
  z-index: 2;
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
  transition: filter .12s, box-shadow .12s;
}
.cal-dv-appt:hover { filter: brightness(1.12); box-shadow: 0 2px 8px rgba(0,0,0,.25); z-index: 3; }
.cal-dv-appt-cancelled { opacity: .42; text-decoration: line-through; }
.cal-dv-appt-time    { font-size: 10px; opacity: .9; margin-bottom: 2px; font-weight: 500; }
.cal-dv-appt-title   { font-weight: 700; font-size: 12px; line-height: 1.25; }
.cal-dv-appt-patient { font-size: 10px; opacity: .82; margin-top: 2px; }
.cal-card {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  cursor: pointer;
  transition: box-shadow .15s, transform .1s;
  border-left: 4px solid #ccc;
}
.cal-card:hover { box-shadow: var(--shadow-sm); transform: translateX(2px); }

/* Day picker in modal */
.appt-day-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.appt-day-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  color: var(--charcoal);
  transition: all .15s;
}
.appt-day-pill:has(input:checked) {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--cream-deeper);
  font-weight: 700;
}
.appt-day-pill input { display: none; }

/* ─── Mobile ─────────────────────────────── */
@media (max-width: 640px) {
  .cal-topbar { flex-direction: column; align-items: flex-start; }
  .cal-period-label { font-size: 14px; min-width: 0; }
  .cal-cell { min-height: 64px; }
  .cal-chip { font-size: 10px; }
  .cal-card { padding: 8px 10px; }
  .cal-day-time { width: 44px; font-size: 11px; }
}
/* Appointment modal — patient search dropdown */
.appt-patient-results {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 9999;
  max-height: 200px;
  overflow-y: auto;
}
.appt-patient-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  gap: 10px;
  transition: background .12s;
}
.appt-patient-row:last-child { border-bottom: none; }
.appt-patient-row:hover { background: var(--surface-warm); }
.appt-patient-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--charcoal);
}
.appt-patient-num {
  font-size: 11px;
  font-family: monospace;
  color: var(--text-muted);
  white-space: nowrap;
}
/* Auto-refresh indicator in calendar topbar */
.cal-refresh-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.75;
  white-space: nowrap;
}
.cal-refresh-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  display: inline-block;
  animation: cal-pulse 2.5s ease-in-out infinite;
}
@keyframes cal-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.35; transform: scale(0.75); }
}
/* ── Invoice Summary Cards ──────────────────────────────────── */
.inv-summary-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 24px;
  border-radius: var(--radius-lg);
  min-width: 220px;
  flex: 1;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: transform .15s, box-shadow .15s;
}
.inv-summary-card:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(0,0,0,.12); }
.inv-summary-icon { font-size: 32px; line-height: 1; }
.inv-summary-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.inv-summary-amount {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.5px;
  line-height: 1.1;
}
.inv-summary-count {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}
.inv-summary-paid   { border-left: 4px solid #22c55e; }
.inv-summary-unpaid { border-left: 4px solid #f59e0b; }
.inv-summary-paid   .inv-summary-amount { color: #16a34a; }
.inv-summary-unpaid .inv-summary-amount { color: #d97706; }
[data-theme="dark"] .inv-summary-paid   .inv-summary-amount { color: #4ade80; }
[data-theme="dark"] .inv-summary-unpaid .inv-summary-amount { color: #fbbf24; }
/* --- Suppress browser's built-in password reveal icon ------------------- */
input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear { display: none !important; }
input[type="password"]::-webkit-credentials-auto-fill-button { display: none !important; }
