/* ═══════════════════════════════════════════════════════════════
   VIORA CLIENT PORTAL — client.css v4.1
   Complete stylesheet covering:
     • Design tokens + dark/light themes
     • Login + pending screens (portable)
     • Portal shell (topbar, tabs, mobile nav)
     • Overview / KPI / charts
     • Subscriptions (cards, alerts, pills)
     • Marketplace (grid, cards, buy modal)
     • Projects, Analytics, Documents, Presentations
     • Billing, Messages, Appointments, AI chat
     • Training rows, uploads, toasts, modals
     • Responsive breakpoints
   ═══════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════
   1. RESET + TOKENS
   ═══════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  background: var(--bg-body, #0a0a0f);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  position: relative;
  line-height: 1.5;
}
h1, h2, h3, h4, h5, h6, .btn, .stat-card .number, .role-badge, .badge {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  letter-spacing: -.02em;
}
a { color: var(--accent-blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #00d4ff 0%, #7c3aed 100%);
  border-radius: 20px;
}

:root,
html[data-theme="dark"] {
  --bg-body: #0a0a0f;
  --bg-card-solid: #12121a;
  --bg-input: rgba(26, 26, 46, .65);
  --bg-table-alt: rgba(0, 212, 255, .05);
  --text-primary: #f0f4ff;
  --text-secondary: #94a3b8;
  --text-light: #64748b;
  --border-color: rgba(0, 212, 255, .14);
  --accent-blue: #00d4ff;
  --accent-green: #22e6a0;
  --accent-red: #ff5c7c;
  --accent-gold: #ffc857;
  --accent-purple: #a855f7;
  --gradient-accent: linear-gradient(135deg, #00d4ff 0%, #7c3aed 100%);
  --gradient-soft: linear-gradient(135deg, rgba(0, 212, 255, .18) 0%, rgba(124, 58, 237, .18) 100%);
  --glass-bg: rgba(18, 18, 26, .55);
  --glass-blur: blur(14px);
  --shadow-3d: 0 10px 30px -8px rgba(0, 0, 0, .75), 0 4px 12px -4px rgba(0, 212, 255, .08);
  --shadow-3d-strong: 0 20px 45px -12px rgba(0, 212, 255, .35), 0 8px 20px -6px rgba(124, 58, 237, .3);
  --radius: 16px;
  --radius-sm: 10px;
  --nav-h: 64px;
  --header-h: 58px;
  --chips-h: 52px;
}

html[data-theme="light"] {
  --bg-body: #f1f5f9;
  --bg-card-solid: #ffffff;
  --bg-input: rgba(241, 245, 249, .9);
  --bg-table-alt: rgba(0, 124, 180, .06);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-light: #64748b;
  --border-color: rgba(15, 23, 42, .12);
  --accent-blue: #0077b6;
  --accent-green: #059669;
  --accent-red: #dc2626;
  --accent-gold: #d97706;
  --accent-purple: #7c3aed;
  --glass-bg: rgba(255, 255, 255, .75);
  --shadow-3d: 0 10px 30px -8px rgba(15, 23, 42, .18);
  --shadow-3d-strong: 0 20px 45px -12px rgba(15, 23, 42, .3);
}

/* ═══════════════════════════════════════════════════════════════
   2. BACKGROUND ANIMATION
   ═══════════════════════════════════════════════════════════════ */
#bgCanvas { position: fixed; inset: 0; z-index: -3; pointer-events: none; }
.bg-aurora { position: fixed; inset: 0; z-index: -2; pointer-events: none; overflow: hidden; opacity: .55; }
.bg-aurora::before, .bg-aurora::after {
  content: ''; position: absolute;
  width: 60vw; height: 60vw; border-radius: 50%;
  filter: blur(120px); opacity: .35;
  animation: auroraFloat 24s ease-in-out infinite;
}
.bg-aurora::before {
  background: radial-gradient(circle, rgba(0, 212, 255, .55), transparent 70%);
  top: -20%; left: -15%;
}
.bg-aurora::after {
  background: radial-gradient(circle, rgba(124, 58, 237, .55), transparent 70%);
  bottom: -25%; right: -15%; animation-delay: -12s;
}
@keyframes auroraFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(8%, 6%) scale(1.08); }
  66%      { transform: translate(-6%, -4%) scale(.95); }
}
.bg-orbs { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.bg-orbs .orb {
  position: absolute; border-radius: 50%; filter: blur(60px);
  opacity: .25; animation: orbFloat 18s ease-in-out infinite;
}
.bg-orbs .orb:nth-child(1) { width: 200px; height: 200px; background: radial-gradient(circle, rgba(0,212,255,.6), transparent); top: 15%; left: 10%; }
.bg-orbs .orb:nth-child(2) { width: 250px; height: 250px; background: radial-gradient(circle, rgba(168,85,247,.5), transparent); top: 60%; right: 8%; animation-delay: -6s; }
.bg-orbs .orb:nth-child(3) { width: 180px; height: 180px; background: radial-gradient(circle, rgba(34,230,160,.5), transparent); bottom: 10%; left: 30%; animation-delay: -12s; }
.bg-orbs .orb:nth-child(4) { width: 220px; height: 220px; background: radial-gradient(circle, rgba(255,110,199,.4), transparent); top: 35%; right: 25%; animation-delay: -9s; }
@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(30px, -40px) scale(1.15); }
  66%      { transform: translate(-20px, 30px) scale(.9); }
}
.bg-grid {
  position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background-image:
    linear-gradient(rgba(0, 212, 255, .03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 212, 255, .03) 1px, transparent 1px);
  background-size: 60px 60px;
  animation: gridPulse 8s ease-in-out infinite;
}
@keyframes gridPulse { 0%, 100% { opacity: .4; } 50% { opacity: .8; } }

/* ═══════════════════════════════════════════════════════════════
   3. LOGIN + PENDING (portable)
   ═══════════════════════════════════════════════════════════════ */
#portalLogin {
  position: fixed; inset: 0; z-index: 9999;
  background: radial-gradient(circle at 20% 20%, #1E1B4B 0%, #0B1220 60%, #060913 100%);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 24px; padding-top: max(24px, 6vh);
  overflow-y: auto; pointer-events: auto !important;
}
#portalLogin.hidden { display: none; }
#portalLogin .login-card {
  width: 100%; max-width: 480px;
  background: rgba(255, 255, 255, .04);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 22px; padding: 42px 38px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
  color: #E2E8F0; margin: auto;
  animation: fadeInUp .6s ease both;
  transition: border-color .4s ease, box-shadow .4s ease;
}
#portalLogin .login-card[data-flow="signin"] {
  border-top: 3px solid #2267EE;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5), 0 -3px 24px -8px rgba(34,103,238,.45);
}
#portalLogin .login-card[data-flow="signup"] {
  border-top: 3px solid #8B5CF6;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5), 0 -3px 24px -8px rgba(139,92,246,.45);
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.login-brand .logo-img {
  width: 56px; height: 56px; border-radius: 15px;
  overflow: hidden; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: linear-gradient(135deg, #00d4ff, #7c3aed);
  box-shadow: 0 8px 24px rgba(99, 102, 241, .5);
}
.login-brand .logo-img img { width: 100%; height: 100%; object-fit: contain; padding: 6px; display: block; }
.login-brand h1 { font-size: 20px; font-weight: 800; letter-spacing: -.3px; color: #F8FAFC; }
.login-brand h1 span { color: #7de8ff; }
.login-brand p {
  font-size: 11.5px; color: #94a3b8;
  text-transform: uppercase; letter-spacing: 1.2px; margin-top: 2px;
}
.auth-mode-indicator { display: flex; justify-content: center; margin-bottom: 14px; }
.auth-mode-indicator span {
  padding: 5px 14px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  background: rgba(34,103,238,.12); color: #7de8ff;
  border: 1px solid rgba(34,103,238,.3);
  transition: all .3s;
}
.auth-mode-indicator span.signup {
  background: rgba(139,92,246,.14);
  color: #C4B5FD;
  border-color: rgba(139,92,246,.3);
}
.login-tabs {
  display: flex; gap: 6px; margin-bottom: 18px;
  background: rgba(15, 23, 42, .6);
  padding: 4px; border-radius: 12px;
}
.login-tabs button {
  flex: 1; padding: 10px 9px;
  border: none; background: transparent;
  color: #94a3b8; font-weight: 600;
  border-radius: 8px; cursor: pointer;
  font-size: .82rem; transition: .2s;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.login-tabs button:hover { color: #e2e8f0; }
.login-tabs button[data-flow="signin"].active {
  background: linear-gradient(135deg, #2267EE, #1E3A8A); color: #fff;
  box-shadow: 0 4px 14px rgba(34,103,238,.35);
}
.login-tabs button[data-flow="signup"].active {
  background: linear-gradient(135deg, #8B5CF6, #6D28D9); color: #fff;
  box-shadow: 0 4px 14px rgba(139,92,246,.35);
}
.login-field { margin-bottom: 14px; position: relative; }
.login-field label {
  display: block; font-size: 11px; font-weight: 600;
  letter-spacing: .8px; text-transform: uppercase;
  color: #94a3b8; margin-bottom: 8px;
}
.login-field input, .login-field select {
  width: 100%; padding: 12px 40px 12px 14px;
  background: rgba(15, 23, 42, .6);
  border: 1px solid rgba(148, 163, 184, .18);
  border-radius: 12px;
  color: #F1F5F9; font-size: 14px; outline: none; transition: .2s;
}
.login-field select { padding-right: 14px; }
.login-field input:focus, .login-field select:focus {
  border-color: #00d4ff; box-shadow: 0 0 0 4px rgba(0, 212, 255, .18);
}
.pw-toggle {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: #94a3b8; cursor: pointer;
  padding: 4px; font-size: 14px; display: grid; place-items: center; margin-top: 12px;
}
.pw-toggle:hover { color: #fff; }
.forgot-row { text-align: right; font-size: 12px; margin: -8px 0 12px; }
.forgot-row a { color: #94a3b8; text-decoration: none; }
.forgot-row a:hover { color: #7de8ff; text-decoration: underline; }
.login-helper {
  text-align: center; font-size: 12px; color: #94a3b8;
  margin-top: 14px; line-height: 1.6;
}
.login-helper a { color: #7de8ff; font-weight: 600; }
.btn-login {
  width: 100%; padding: 13px;
  background: linear-gradient(135deg, #2267EE 0%, #1E3A8A 100%);
  border: none; border-radius: 12px;
  color: #ffffff; font-weight: 700; font-size: 14px;
  cursor: pointer; letter-spacing: .3px;
  box-shadow: 0 6px 20px rgba(34, 103, 238, .4);
  transition: .2s; margin-top: 6px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-login:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(34, 103, 238, .55); }
.btn-login:disabled { opacity: .6; cursor: not-allowed; }
#pRegisterBtn {
  background: linear-gradient(135deg, #8B5CF6 0%, #6D28D9 100%);
  box-shadow: 0 6px 20px rgba(139, 92, 246, .4);
}
.signup-intro {
  background: rgba(139,92,246,.08);
  border: 1px solid rgba(139,92,246,.25);
  border-left: 3px solid #8B5CF6;
  border-radius: 10px; padding: 14px 16px; margin-bottom: 16px;
  font-size: 13px; color: #cbd5e1;
}
.signup-intro strong {
  display: block; font-size: 12px; text-transform: uppercase;
  letter-spacing: .06em; color: #C4B5FD; margin-bottom: 6px;
}
.signup-intro ol { padding-left: 18px; line-height: 1.7; }
.signup-terms { text-align: center; font-size: 11px; color: #64748b; margin-top: 16px; line-height: 1.6; }
.signup-terms a { color: #7de8ff; text-decoration: underline; }
.pw-meter { margin-top: 6px; display: none; }
.pw-meter.show { display: block; }
.pw-bars { display: flex; gap: 4px; height: 4px; margin-bottom: 4px; }
.pw-bars span {
  flex: 1; background: rgba(148,163,184,.25);
  border-radius: 2px; transition: background .2s;
}
.pw-meter[data-strength="1"] .pw-bars span:nth-child(1) { background: #ff5c7c; }
.pw-meter[data-strength="2"] .pw-bars span:nth-child(-n+2) { background: #ffc857; }
.pw-meter[data-strength="3"] .pw-bars span:nth-child(-n+3) { background: #22e6a0; }
.pw-meter[data-strength="4"] .pw-bars span { background: #22e6a0; }
.pw-meter small { font-size: 11px; color: #91afbd; }
.login-footer {
  margin-top: 22px; padding-top: 20px;
  border-top: 1px solid rgba(148, 163, 184, .1);
  font-size: 11px; color: #64748b; text-align: center; line-height: 1.7;
}
.login-message {
  margin-top: 14px; padding: 12px 14px;
  border-radius: 10px; font-size: .8rem; line-height: 1.5; display: none;
}
.login-message.error { display: block; background: rgba(255,92,124,.12); border-left: 3px solid #ff5c7c; color: #ff9eb1; }
.login-message.success { display: block; background: rgba(34,230,160,.12); border-left: 3px solid #22e6a0; color: #7de8c2; }
.login-message.info { display: block; background: rgba(0,212,255,.12); border-left: 3px solid #00d4ff; color: #7dd8ff; }
.noscript-warning {
  background: rgba(255,200,87,.1); border-left: 3px solid #ffc857;
  padding: 12px 16px; border-radius: 8px;
  font-size: 13px; color: #ffc857; margin-bottom: 16px; line-height: 1.55;
}

#pendingScreen {
  position: fixed; inset: 0; z-index: 9999;
  background: radial-gradient(circle at 20% 20%, #1E1B4B 0%, #0B1220 60%, #060913 100%);
  display: none; align-items: center; justify-content: center; padding: 24px;
}
#pendingScreen.active { display: flex; }
.pending-card {
  width: 100%; max-width: 480px;
  background: rgba(255, 255, 255, .04);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 22px; padding: 42px 38px;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
  color: #E2E8F0; text-align: center; margin: auto;
}
.pending-card .pending-icon {
  width: 72px; height: 72px; border-radius: 50%;
  background: linear-gradient(135deg, #F59E0B, #B45309);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.8rem; color: #fff; margin-bottom: 18px;
  animation: pendingPulse 2s ease-in-out infinite;
  box-shadow: 0 12px 32px -8px rgba(245,158,11,.5);
}
@keyframes pendingPulse {
  0%, 100% { opacity: .75; transform: scale(1); }
  50%      { opacity: 1; transform: scale(1.05); }
}
.pending-card h2 { font-size: 1.2rem; font-weight: 800; color: #F8FAFC; margin-bottom: 10px; }
.pending-card p { font-size: .85rem; color: #94a3b8; line-height: 1.6; margin-bottom: 16px; }
.pending-progress { display: flex; flex-direction: column; gap: 10px; margin: 22px 0 18px; text-align: left; }
.pending-step {
  display: flex; align-items: center; gap: 12px;
  font-size: .82rem; color: #94a3b8;
  padding: 10px 14px; background: rgba(255,255,255,.03);
  border-radius: 10px; transition: all .3s;
}
.pending-step span:first-child {
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: .7rem; font-weight: 700;
  background: rgba(148,163,184,.15); color: #64748b; flex-shrink: 0;
}
.pending-step.done { color: #7de8c2; background: rgba(34,230,160,.06); }
.pending-step.done span:first-child { background: #22e6a0; color: #0a0a0f; }
.pending-step.active { color: #ffc857; background: rgba(255,200,87,.06); }
.spinner-mini {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,200,87,.25);
  border-top-color: #ffc857; border-radius: 50%;
  animation: spinMini 1s linear infinite;
}
@keyframes spinMini { to { transform: rotate(360deg); } }
.pending-help { font-size: .78rem; color: #94a3b8; margin: 12px 0 0; line-height: 1.6; }
.pending-help a { color: #7de8ff; text-decoration: underline; }
.pending-card .check-row {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  font-size: .78rem; color: #7de8c2; padding: 10px;
  background: rgba(34,230,160,.08); border-radius: 10px; margin-top: 14px;
}
.pending-card .dot-pulse { width: 8px; height: 8px; border-radius: 50%; background: #22e6a0; animation: pendingPulse 1.5s ease-in-out infinite; }
.hidden { display: none !important; }

/* ═══════════════════════════════════════════════════════════════
   4. PORTAL SHELL
   ═══════════════════════════════════════════════════════════════ */
#portalShell { display: none; min-height: 100vh; }
#portalShell.visible { display: block; }

.portal-topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 0 24px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 1px 12px rgba(0,0,0,.15);
}
.portal-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1rem; }
.portal-brand .brand-logo {
  width: 32px; height: 32px; border-radius: 9px; overflow: hidden;
  background: linear-gradient(135deg, #00d4ff, #7c3aed);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.portal-brand .brand-logo img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.role-badge {
  font-size: .68rem; font-weight: 700; padding: 3px 9px;
  border-radius: 999px; text-transform: uppercase; letter-spacing: .5px;
  background: var(--gradient-soft); color: var(--accent-blue);
  border: 1px solid var(--border-color);
}
.portal-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.live-sync {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .72rem; color: var(--text-secondary); font-weight: 600;
  padding: 5px 10px; border-radius: 999px;
  background: rgba(34,230,160,.08); border: 1px solid rgba(34,230,160,.2);
}
.pulse-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent-green);
  animation: livePulse 1.6s ease-in-out infinite;
}
@keyframes livePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34,230,160,.6); }
  50%      { box-shadow: 0 0 0 6px rgba(34,230,160,0); }
}
.portal-userinfo {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .8rem; font-weight: 600; color: var(--text-secondary);
  max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.portal-tabs {
  position: sticky; top: var(--header-h); z-index: 45;
  display: flex; gap: 4px; padding: 8px 20px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto; scrollbar-width: none;
}
.portal-tabs::-webkit-scrollbar { display: none; }
.ptab-btn {
  padding: 8px 14px; border: none; background: transparent;
  color: var(--text-secondary); font-weight: 600; font-size: .82rem;
  border-radius: 9px; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 7px;
  transition: all .18s;
}
.ptab-btn:hover { background: var(--bg-input); color: var(--text-primary); }
.ptab-btn.active {
  background: var(--gradient-accent); color: #fff;
  box-shadow: 0 4px 14px -4px rgba(0, 212, 255, .5);
}
.ptab-btn i { font-size: .78rem; }

.portal-main {
  padding: 24px;
  max-width: 1400px; margin: 0 auto;
}
.ptab { display: none; animation: fadeTab .25s ease; }
.ptab.active { display: block; }
@keyframes fadeTab { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ═══════════════════════════════════════════════════════════════
   5. MOBILE NAV
   ═══════════════════════════════════════════════════════════════ */
#portalBottomNav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
  height: var(--nav-h);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--border-color);
  padding-bottom: env(safe-area-inset-bottom);
  overflow-x: auto; scrollbar-width: none;
}
#portalBottomNav::-webkit-scrollbar { display: none; }
.mnav-item {
  flex: 0 0 auto; min-width: 64px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 8px 6px; border: none; background: transparent;
  color: var(--text-secondary); font-size: .62rem; font-weight: 600;
  cursor: pointer; transition: .18s;
}
.mnav-item i { font-size: 1.05rem; }
.mnav-item.active { color: var(--accent-blue); }
.mnav-item.active i { transform: scale(1.1); }

#mobileSubChips {
  display: none;
  position: fixed; bottom: var(--nav-h); left: 0; right: 0; z-index: 59;
  height: var(--chips-h);
  background: var(--bg-card-solid);
  border-top: 1px solid var(--border-color);
  padding: 8px 12px; gap: 8px;
  overflow-x: auto; scrollbar-width: none;
}
#mobileSubChips::-webkit-scrollbar { display: none; }
#mobileSubChips:empty { display: none; }
#mobileSubChips .chip {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 999px;
  background: var(--bg-input); border: 1px solid var(--border-color);
  color: var(--text-secondary); font-size: .78rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
#mobileSubChips .chip.active {
  background: var(--gradient-accent); color: #fff; border-color: transparent;
}

/* ═══════════════════════════════════════════════════════════════
   6. BUTTONS + BADGES
   ═══════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 18px; border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600; font-size: .85rem; cursor: pointer;
  transition: all .18s; text-decoration: none;
  white-space: nowrap; font-family: 'Space Grotesk', sans-serif;
  letter-spacing: -.01em;
}
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none !important; }
.btn-sm { padding: 7px 12px; font-size: .78rem; }
.btn-xs { padding: 5px 10px; font-size: .72rem; }

.btn-primary {
  background: var(--gradient-accent); color: #fff;
  box-shadow: 0 4px 14px -4px rgba(0, 212, 255, .55);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 8px 22px -6px rgba(0, 212, 255, .65); }

.btn-outline {
  background: transparent; color: var(--text-primary);
  border: 1.5px solid var(--border-color);
}
.btn-outline:hover:not(:disabled) { background: var(--bg-input); border-color: var(--accent-blue); }

.btn-purple {
  background: linear-gradient(135deg, #a855f7, #7c3aed); color: #fff;
  box-shadow: 0 4px 14px -4px rgba(168, 85, 247, .55);
}
.btn-purple:hover:not(:disabled) { transform: translateY(-1px); }

.btn-mpesa {
  background: linear-gradient(135deg, #22c55e, #15803d); color: #fff;
  box-shadow: 0 4px 14px -4px rgba(34, 197, 94, .55);
}
.btn-mpesa:hover:not(:disabled) { transform: translateY(-1px); }

.btn-success {
  background: linear-gradient(135deg, #22e6a0, #059669); color: #0a0a0f;
  box-shadow: 0 4px 14px -4px rgba(34, 230, 160, .55);
}
.btn-success:hover:not(:disabled) { transform: translateY(-1px); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px;
  font-size: .68rem; font-weight: 700; letter-spacing: .3px;
  text-transform: uppercase; white-space: nowrap;
}
.badge-paid, .badge-active, .badge-completed, .badge-success {
  background: rgba(34, 230, 160, .15); color: var(--accent-green);
  border: 1px solid rgba(34, 230, 160, .35);
}
.badge-pending, .badge-sent, .badge-warning {
  background: rgba(255, 200, 87, .15); color: var(--accent-gold);
  border: 1px solid rgba(255, 200, 87, .35);
}
.badge-overdue, .badge-cancelled, .badge-danger, .badge-missed {
  background: rgba(255, 92, 124, .15); color: var(--accent-red);
  border: 1px solid rgba(255, 92, 124, .35);
}
.badge-gray, .badge-closed {
  background: rgba(148, 163, 184, .15); color: var(--text-secondary);
  border: 1px solid rgba(148, 163, 184, .35);
}
.badge-purple {
  background: rgba(168, 85, 247, .15); color: var(--accent-purple);
  border: 1px solid rgba(168, 85, 247, .35);
}

/* ═══════════════════════════════════════════════════════════════
   7. PAGE HEADER / HERO
   ═══════════════════════════════════════════════════════════════ */
.page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; flex-wrap: wrap; margin-bottom: 22px;
}
.page-header h1 {
  font-size: 1.5rem; font-weight: 800;
  color: var(--text-primary); line-height: 1.2;
}
.page-header h1 .highlight {
  background: var(--gradient-accent);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.page-header .page-desc {
  font-size: .82rem; color: var(--text-secondary);
  margin-top: 4px; line-height: 1.5;
}
.page-header .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.client-360-hero {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; flex-wrap: wrap;
  padding: 22px 24px; border-radius: var(--radius);
  background: var(--gradient-soft);
  border: 1px solid var(--border-color);
  margin-bottom: 22px;
  box-shadow: var(--shadow-3d);
}
.client-360-hero .hero-info h3 {
  font-size: 1.25rem; font-weight: 800; color: var(--text-primary);
  margin-bottom: 4px;
}
.client-360-hero .hero-info .subtitle {
  font-size: .78rem; color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════════════
   8. KPI GRID + STAT CARDS
   ═══════════════════════════════════════════════════════════════ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px; margin-bottom: 22px;
}
.stat-card {
  padding: 16px 18px; border-radius: var(--radius);
  background: var(--bg-card-solid);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-3d);
  position: relative; overflow: hidden;
  transition: transform .2s, box-shadow .2s;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--gradient-accent);
  opacity: .7;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-3d-strong); }
.stat-card .stat-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--gradient-soft);
  color: var(--accent-blue); font-size: 1rem;
  margin-bottom: 10px;
}
.stat-card .number {
  font-size: 1.5rem; font-weight: 800;
  color: var(--text-primary); line-height: 1.15;
}
.stat-card .label {
  font-size: .7rem; font-weight: 600; letter-spacing: .5px;
  text-transform: uppercase; color: var(--text-secondary);
  margin-top: 4px;
}
.stat-card .kpi-sub {
  font-size: .7rem; color: var(--text-light); margin-top: 2px;
}

/* ═══════════════════════════════════════════════════════════════
   9. CHART CONTAINERS
   ═══════════════════════════════════════════════════════════════ */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}
.chart-box {
  padding: 18px 20px; border-radius: var(--radius);
  background: var(--bg-card-solid);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-3d);
  margin-bottom: 18px;
}
.chart-box.chart-full { grid-column: 1 / -1; }
.chart-box h4 {
  font-size: .92rem; font-weight: 700; margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
  color: var(--text-primary);
}
.chart-box h4 i { color: var(--accent-blue); font-size: .9rem; }
.chart-container {
  position: relative; width: 100%;
  height: 240px; min-height: 180px;
}

.empty-state {
  padding: 24px 12px; text-align: center;
  color: var(--text-secondary); font-size: .82rem;
}

/* ═══════════════════════════════════════════════════════════════
   10. TIMELINE (overview)
   ═══════════════════════════════════════════════════════════════ */
.p-timeline { display: flex; flex-direction: column; gap: 8px; }
.p-tl-item {
  padding: 10px 14px; border-radius: 10px;
  background: var(--bg-input);
  border-left: 3px solid var(--accent-blue);
  font-size: .8rem;
}
.p-tl-item.success { border-left-color: var(--accent-green); }
.p-tl-item.warning { border-left-color: var(--accent-gold); }
.p-tl-item.danger  { border-left-color: var(--accent-red); }
.p-tl-item.purple  { border-left-color: var(--accent-purple); }
.p-tl-title { font-weight: 700; font-size: .85rem; }
.p-tl-desc { color: var(--text-secondary); font-size: .74rem; margin-top: 2px; }
.p-tl-time { color: var(--text-light); font-size: .68rem; margin-top: 3px; }

/* ═══════════════════════════════════════════════════════════════
   11. PROGRESS BAR (3D)
   ═══════════════════════════════════════════════════════════════ */
.progress-3d {
  height: 10px; border-radius: 999px;
  background: rgba(148,163,184,.14);
  overflow: hidden; margin-top: 6px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.25);
}
.progress-3d-bar {
  height: 100%; border-radius: 999px;
  background: var(--gradient-accent);
  transition: width .5s ease;
  box-shadow: 0 1px 6px rgba(0, 212, 255, .4);
}
.progress-3d-bar.green { background: linear-gradient(135deg, #22e6a0, #059669); }
.progress-3d-bar.gold  { background: linear-gradient(135deg, #ffc857, #d97706); }
.progress-3d-label {
  display: flex; justify-content: space-between;
  font-size: .7rem; color: var(--text-secondary);
  margin-top: 4px; font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════════
   12. ALERT BANNERS
   ═══════════════════════════════════════════════════════════════ */
.alert-banner {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; border-radius: 12px;
  font-size: .82rem; line-height: 1.5;
  border-left: 3px solid var(--accent-blue);
  background: rgba(0, 212, 255, .08);
  color: var(--text-primary);
}
.alert-banner.success { border-left-color: var(--accent-green); background: rgba(34, 230, 160, .08); }
.alert-banner.warning { border-left-color: var(--accent-gold); background: rgba(255, 200, 87, .08); }
.alert-banner.danger  { border-left-color: var(--accent-red);  background: rgba(255, 92, 124, .08); }
.alert-banner i { color: inherit; flex-shrink: 0; margin-top: 2px; }

/* ═══════════════════════════════════════════════════════════════
   13. SUBSCRIPTION CARDS
   ═══════════════════════════════════════════════════════════════ */
.subs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}
.subs-card {
  padding: 16px 18px; border-radius: var(--radius);
  background: var(--bg-card-solid);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-3d);
  position: relative;
  display: flex; flex-direction: column; gap: 10px;
}
.subs-card-success { border-top: 3px solid var(--accent-green); }
.subs-card-warning { border-top: 3px solid var(--accent-gold); }
.subs-card-danger  { border-top: 3px solid var(--accent-red); }

.subs-card-head {
  display: flex; align-items: center; gap: 10px;
}
.subs-card-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--gradient-soft);
  color: var(--accent-purple); font-size: 1rem;
  flex-shrink: 0;
}
.subs-card-title-block { flex: 1; min-width: 0; }
.subs-card-title {
  font-weight: 800; font-size: .92rem;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.subs-card-sub {
  font-size: .72rem; color: var(--text-secondary); margin-top: 2px;
}
.subs-card-meta {
  display: flex; flex-direction: column; gap: 4px;
  padding-top: 8px; border-top: 1px dashed var(--border-color);
}
.subs-card-meta-row {
  display: flex; justify-content: space-between;
  font-size: .76rem; color: var(--text-secondary);
}
.subs-card-meta-row strong { color: var(--text-primary); font-weight: 700; }
.subs-card-actions {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px;
}

/* ═══════════════════════════════════════════════════════════════
   14. MARKETPLACE
   ═══════════════════════════════════════════════════════════════ */
.market-tabs {
  display: flex; gap: 8px; margin-bottom: 16px;
  overflow-x: auto; scrollbar-width: none; padding-bottom: 4px;
}
.market-tabs::-webkit-scrollbar { display: none; }
.market-tab {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 12px;
  background: var(--bg-card-solid);
  border: 1px solid var(--border-color);
  color: var(--text-secondary); font-weight: 600; font-size: .82rem;
  cursor: pointer; transition: all .18s;
  white-space: nowrap;
}
.market-tab:hover { border-color: var(--accent-blue); color: var(--text-primary); }
.market-tab.active {
  background: var(--gradient-accent); color: #fff; border-color: transparent;
  box-shadow: 0 4px 14px -4px rgba(0, 212, 255, .5);
}
.market-tab .count {
  font-size: .68rem; font-weight: 800;
  padding: 1px 7px; border-radius: 999px;
  background: rgba(255,255,255,.2); min-width: 18px; text-align: center;
}
.market-tab.active .count { background: rgba(255,255,255,.35); }

.market-search {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 12px;
  background: var(--bg-card-solid);
  border: 1px solid var(--border-color);
  margin-bottom: 16px;
}
.market-search i { color: var(--text-secondary); }
.market-search input {
  flex: 1; border: none; background: transparent;
  color: var(--text-primary); font-size: .88rem; outline: none;
}

.market-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.market-card {
  display: flex; flex-direction: column;
  border-radius: var(--radius);
  background: var(--bg-card-solid);
  border: 1px solid var(--border-color);
  overflow: hidden; cursor: pointer;
  box-shadow: var(--shadow-3d);
  transition: transform .2s, box-shadow .2s, border-color .2s;
  position: relative;
}
.market-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-3d-strong);
  border-color: var(--accent-blue);
}
.market-card-preview {
  width: 100%; aspect-ratio: 16 / 9;
  background: var(--gradient-soft);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.market-card-body {
  padding: 12px 14px 6px; flex: 1;
  display: flex; flex-direction: column; gap: 6px;
}
.market-card-title {
  font-weight: 800; font-size: .9rem;
  color: var(--text-primary);
  line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.market-card-desc {
  font-size: .74rem; color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.market-card-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.market-card-tags .tag {
  font-size: .66rem; font-weight: 600;
  padding: 2px 7px; border-radius: 6px;
  background: var(--bg-input); color: var(--text-secondary);
}
.market-card-price {
  display: flex; align-items: baseline; gap: 6px;
  margin-top: auto; padding-top: 6px;
}
.market-card-price .price {
  font-size: 1rem; font-weight: 800; color: var(--accent-green);
}
.market-card-price .period {
  font-size: .7rem; color: var(--text-light);
}
.market-card-actions {
  display: flex; gap: 6px; padding: 10px 14px 14px;
  border-top: 1px dashed var(--border-color);
  margin-top: 8px;
}
.market-card-actions .btn { flex: 1; padding: 6px 8px; font-size: .72rem; }
.market-card-badge {
  position: absolute; top: 10px; right: 10px;
  font-size: .62rem; font-weight: 700; letter-spacing: .3px;
  padding: 3px 8px; border-radius: 999px;
  background: var(--accent-purple); color: #fff;
  text-transform: uppercase;
}

/* ═══════════════════════════════════════════════════════════════
   15. TABLES
   ═══════════════════════════════════════════════════════════════ */
.table-wrapper {
  background: var(--bg-card-solid);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-3d);
  margin-bottom: 18px;
}
.table-wrapper table {
  width: 100%; border-collapse: collapse;
  font-size: .82rem; min-width: 560px;
}
.table-wrapper thead th {
  background: var(--bg-table-alt);
  text-align: left; padding: 11px 14px;
  font-size: .7rem; text-transform: uppercase; letter-spacing: .5px;
  font-weight: 700; color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}
.table-wrapper tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  vertical-align: middle;
}
.table-wrapper tbody tr:hover { background: var(--bg-table-alt); }
.table-wrapper tbody tr:last-child td { border-bottom: none; }
.table-wrapper tbody td.empty-state { padding: 40px 20px; text-align: center; color: var(--text-secondary); }

/* ═══════════════════════════════════════════════════════════════
   16. DOCUMENTS
   ═══════════════════════════════════════════════════════════════ */
.p-chips {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.p-chips button {
  padding: 6px 14px; border-radius: 999px;
  background: var(--bg-card-solid);
  border: 1px solid var(--border-color);
  color: var(--text-secondary); font-size: .76rem; font-weight: 600;
  cursor: pointer; transition: all .18s; white-space: nowrap;
}
.p-chips button:hover { border-color: var(--accent-blue); color: var(--text-primary); }
.p-chips button.active {
  background: var(--gradient-accent); color: #fff; border-color: transparent;
}

.p-doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.p-doc-card {
  padding: 12px 14px; border-radius: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  display: flex; flex-direction: column; gap: 8px;
  transition: border-color .2s;
}
.p-doc-card:hover { border-color: var(--accent-blue); }
.dc-head { display: flex; align-items: flex-start; gap: 10px; }
.dc-icon {
  width: 36px; height: 36px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--gradient-soft);
  color: var(--accent-blue); font-size: 1rem;
  flex-shrink: 0;
}
.dc-title-block { flex: 1; min-width: 0; }
.dc-title {
  font-weight: 700; font-size: .84rem; line-height: 1.3;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dc-meta { font-size: .7rem; color: var(--text-secondary); margin-top: 2px; }
.dc-tag {
  display: inline-block; margin-top: 5px;
  font-size: .62rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .3px; padding: 2px 7px; border-radius: 6px;
  background: var(--bg-table-alt); color: var(--accent-blue);
}
.dc-tag.pres { background: rgba(168, 85, 247, .15); color: var(--accent-purple); }
.dc-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.doc-upload-zone {
  padding: 32px 20px; text-align: center;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius);
  background: var(--bg-input);
  cursor: pointer; transition: all .2s;
}
.doc-upload-zone:hover {
  border-color: var(--accent-blue);
  background: rgba(0, 212, 255, .05);
}

/* ═══════════════════════════════════════════════════════════════
   17. PRESENTATIONS
   ═══════════════════════════════════════════════════════════════ */
.p-pres-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}
.p-pres-card {
  padding: 16px 18px; border-radius: var(--radius);
  background: var(--bg-card-solid);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-3d);
  display: flex; flex-direction: column; gap: 10px;
  position: relative;
}
.p-pres-card.accepted { border-top: 3px solid var(--accent-green); }
.p-pres-card.rejected { border-top: 3px solid var(--accent-red); }
.p-pres-card.delivered { border-top: 3px solid var(--accent-blue); }

.pc-head { display: flex; align-items: flex-start; gap: 10px; }
.pc-icon {
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--gradient-soft);
  color: var(--accent-purple); font-size: 1rem;
  flex-shrink: 0;
}
.pc-title-block { flex: 1; min-width: 0; }
.pc-title {
  font-weight: 800; font-size: .92rem;
  color: var(--text-primary); line-height: 1.3;
}
.pc-sub { font-size: .74rem; color: var(--text-secondary); margin-top: 2px; }
.pc-meta {
  display: flex; gap: 14px; flex-wrap: wrap;
  font-size: .74rem; color: var(--text-secondary);
  padding-top: 8px; border-top: 1px dashed var(--border-color);
}
.pc-meta i { margin-right: 4px; color: var(--accent-blue); }
.pc-summary { font-size: .8rem; color: var(--text-secondary); line-height: 1.5; }
.pc-att-list { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.pc-att {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 9px;
  background: var(--bg-input);
  font-size: .78rem;
}
.pc-att .pa-icon { font-size: 1rem; flex-shrink: 0; }
.pc-att .pa-name {
  flex: 1; min-width: 0; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pc-att .pa-size { color: var(--text-secondary); font-size: .7rem; }
.pc-att .pa-btns { display: inline-flex; gap: 4px; }
.pc-att .pa-btns button {
  padding: 3px 8px; border-radius: 6px;
  border: 1px solid var(--border-color);
  background: transparent; color: var(--text-primary);
  font-size: .68rem; font-weight: 600; cursor: pointer;
}
.pc-att .pa-btns button:hover { background: var(--bg-card-solid); border-color: var(--accent-blue); }

/* ═══════════════════════════════════════════════════════════════
   18. TRAINING
   ═══════════════════════════════════════════════════════════════ */
.training-row {
  padding: 12px 14px; border-radius: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  margin-bottom: 8px;
  display: flex; flex-direction: column; gap: 8px;
}

/* ═══════════════════════════════════════════════════════════════
   19. APPOINTMENTS
   ═══════════════════════════════════════════════════════════════ */
.appt-card {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px; border-radius: var(--radius);
  background: var(--bg-card-solid);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-3d);
}
.appt-date-box {
  width: 56px; height: 56px; border-radius: 12px;
  background: var(--gradient-accent);
  color: #fff; flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.appt-date-box .day { font-size: 1.15rem; font-weight: 800; line-height: 1; }
.appt-date-box .mon { font-size: .65rem; text-transform: uppercase; letter-spacing: .5px; }
.appt-info { flex: 1; min-width: 0; }
.appt-info .title { font-weight: 700; font-size: .9rem; }
.appt-info .meta {
  font-size: .74rem; color: var(--text-secondary); margin-top: 3px;
  display: flex; align-items: center; gap: 5px;
}
.appt-info .meta i { color: var(--accent-blue); font-size: .72rem; }

/* ═══════════════════════════════════════════════════════════════
   20. MESSAGES / TICKETS
   ═══════════════════════════════════════════════════════════════ */
.ticket-row {
  padding: 10px 12px; border-radius: 10px;
  background: var(--bg-input);
  border: 1px solid transparent;
  cursor: pointer; transition: all .18s;
  margin-bottom: 6px;
  display: flex; align-items: center; gap: 10px;
}
.ticket-row:hover { border-color: var(--accent-blue); }
.ticket-row.unread { border-left: 3px solid var(--accent-gold); }
.ticket-row.closed { opacity: .65; }
.tk-status {
  display: inline-block; padding: 1px 7px; border-radius: 6px;
  font-size: .62rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .3px;
  background: var(--bg-table-alt); color: var(--accent-blue);
}
.tk-status.open { background: rgba(255,200,87,.15); color: var(--accent-gold); }
.tk-status.closed { background: rgba(148,163,184,.15); color: var(--text-secondary); }

.msg-bubble {
  padding: 10px 14px; border-radius: 14px;
  font-size: .84rem; line-height: 1.45;
  margin-bottom: 8px; max-width: 82%;
  word-wrap: break-word;
}
.msg-bubble.client {
  margin-left: auto;
  background: var(--gradient-accent); color: #fff;
  border-bottom-right-radius: 4px;
}
.msg-bubble.admin {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 4px;
}
.msg-bubble .who {
  font-size: .66rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .3px;
  opacity: .85; margin-bottom: 4px;
}

/* ═══════════════════════════════════════════════════════════════
   21. AI CHAT
   ═══════════════════════════════════════════════════════════════ */
.ai-quick-prompts {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px;
}
.ai-quick-prompts button {
  padding: 7px 12px; border-radius: 999px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-secondary); font-size: .76rem; font-weight: 600;
  cursor: pointer; transition: all .18s;
}
.ai-quick-prompts button:hover {
  border-color: var(--accent-purple); color: var(--accent-purple);
}
.ai-chat-wrap { display: flex; flex-direction: column; gap: 10px; }
.ai-chat-history {
  min-height: 260px; max-height: 460px;
  overflow-y: auto;
  padding: 14px; border-radius: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  display: flex; flex-direction: column; gap: 8px;
}
.ai-msg {
  padding: 10px 14px; border-radius: 12px;
  font-size: .85rem; line-height: 1.5;
  max-width: 88%;
  word-wrap: break-word;
}
.ai-msg.user {
  align-self: flex-end;
  background: var(--gradient-accent); color: #fff;
  border-bottom-right-radius: 4px;
}
.ai-msg.assistant {
  align-self: flex-start;
  background: var(--bg-card-solid);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}
.ai-chat-input {
  display: flex; gap: 8px;
}
.ai-chat-input input {
  flex: 1; padding: 11px 14px; border-radius: 12px;
  border: 1.5px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: .88rem; outline: none;
}
.ai-chat-input input:focus { border-color: var(--accent-blue); }
.ai-thinking { display: inline-flex; gap: 4px; align-items: center; }
.ai-thinking span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-secondary);
  animation: thinking 1.2s ease-in-out infinite;
}
.ai-thinking span:nth-child(2) { animation-delay: .15s; }
.ai-thinking span:nth-child(3) { animation-delay: .3s; }
@keyframes thinking {
  0%, 100% { opacity: .3; transform: translateY(0); }
  50%      { opacity: 1; transform: translateY(-4px); }
}

/* ═══════════════════════════════════════════════════════════════
   22. MODALS
   ═══════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(0, 0, 0, .65);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: none;
  align-items: flex-start; justify-content: center;
  padding: 24px; overflow-y: auto;
}
.modal-overlay.active { display: flex; }
.modal-box {
  width: 100%; max-width: 560px;
  background: var(--bg-card-solid);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .7);
  margin: auto;
  display: flex; flex-direction: column;
  max-height: 92vh; overflow: hidden;
  animation: modalIn .25s ease both;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}
.modal-head h3 {
  font-size: 1rem; font-weight: 800;
  color: var(--text-primary);
  display: flex; align-items: center; gap: 8px;
}
.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  color: var(--text-primary);
  line-height: 1.55;
  font-size: .88rem;
}
.modal-body p + p { margin-top: 8px; }
.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap;
}

/* Input styling inside modals (buy / request / ticket modals) */
.modal-body input[type="text"],
.modal-body input[type="tel"],
.modal-body input[type="number"],
.modal-body input[type="email"],
.modal-body textarea,
.modal-body select {
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: .88rem;
  outline: none;
  margin-top: 6px;
}
.modal-body input:focus,
.modal-body textarea:focus,
.modal-body select:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(0, 212, 255, .15);
}
.modal-body label {
  display: block; font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .4px;
  color: var(--text-secondary); margin-bottom: 2px;
}

/* ═══════════════════════════════════════════════════════════════
   23. TOASTS
   ═══════════════════════════════════════════════════════════════ */
#pToastContainer {
  position: fixed; bottom: 24px; right: 24px; z-index: 9500;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
  max-width: calc(100vw - 48px);
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: 12px;
  min-width: 240px; max-width: 380px;
  background: var(--bg-card-solid);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-blue);
  box-shadow: 0 12px 32px -8px rgba(0, 0, 0, .5);
  font-size: .82rem; line-height: 1.4;
  animation: toastIn .3s ease both;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
.toast span { flex: 1; }
.toast.success { border-left-color: var(--accent-green); }
.toast.error   { border-left-color: var(--accent-red); }
.toast.warning { border-left-color: var(--accent-gold); }
.toast.info    { border-left-color: var(--accent-blue); }
.toast-close {
  border: none; background: transparent;
  color: var(--text-secondary); font-size: 1.1rem;
  cursor: pointer; padding: 0 4px; line-height: 1;
}
.toast-close:hover { color: var(--text-primary); }

/* ═══════════════════════════════════════════════════════════════
   24. LOCK MODAL (subscription expired)
   ═══════════════════════════════════════════════════════════════ */
#pLockModal .modal-box { max-width: 480px; }
#pLockModal .modal-body { text-align: left; }

/* ═══════════════════════════════════════════════════════════════
   25. SUBSCRIPTION REQUEST MODAL
   ═══════════════════════════════════════════════════════════════ */
#pSubRequestModal .modal-box { max-width: 520px; }
#pSubRequestModal .modal-body > div { margin-bottom: 12px; }

/* ═══════════════════════════════════════════════════════════════
   26. INVOICE / REPORT PRINT STYLES
   ═══════════════════════════════════════════════════════════════ */
#pInvoiceModal .modal-box,
#pReportModal  .modal-box,
#pFilePreviewModal .modal-box {
  max-width: 820px;
}

@media print {
  body * { visibility: hidden; }
  #pInvoiceModal, #pInvoiceModal *,
  #pReportModal, #pReportModal * {
    visibility: visible;
  }
  #pInvoiceModal, #pReportModal {
    position: absolute; inset: 0;
    background: #fff !important;
    display: block !important;
    backdrop-filter: none !important;
  }
  #pInvoiceModal .modal-box, #pReportModal .modal-box {
    box-shadow: none; border: none; max-width: 100%;
  }
  .modal-head, .modal-foot { display: none !important; }
}

/* ═══════════════════════════════════════════════════════════════
   27. RESPONSIVE — MOBILE (< 900px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 899px) {
  .portal-topbar {
    padding: 0 14px; height: 54px;
  }
  .portal-brand span:not(.role-badge):last-child { display: none; }
  .role-badge { font-size: .6rem; }
  .live-sync { display: none; }
  .portal-userinfo { max-width: 110px; font-size: .7rem; }

  .portal-tabs { display: none; }
  .portal-main { padding: 14px 12px calc(var(--nav-h) + var(--chips-h) + 20px); }
  #portalBottomNav { display: flex; }
  #mobileSubChips { display: flex; }

  .page-header h1 { font-size: 1.2rem; }
  .client-360-hero { flex-direction: column; align-items: stretch; padding: 16px; }
  .client-360-hero .hero-info h3 { font-size: 1.05rem; }

  .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
  .stat-card { padding: 12px 14px; }
  .stat-card .number { font-size: 1.15rem; }

  .chart-grid { grid-template-columns: 1fr; gap: 12px; }
  .chart-box { padding: 14px 16px; margin-bottom: 14px; }
  .chart-container { height: 200px; }

  .subs-grid { grid-template-columns: 1fr; }
  .market-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
  .market-card-actions .btn { font-size: .68rem; }

  .p-doc-grid, .p-pres-grid { grid-template-columns: 1fr; }

  .appt-card { padding: 10px 12px; gap: 10px; }
  .appt-date-box { width: 48px; height: 48px; }
  .appt-date-box .day { font-size: 1rem; }

  .modal-overlay { padding: 12px; }
  .modal-box { max-height: 94vh; }
  .modal-head, .modal-body, .modal-foot { padding: 14px 16px; }

  #pToastContainer { bottom: calc(var(--nav-h) + var(--chips-h) + 16px); right: 12px; left: 12px; max-width: none; }
  .toast { max-width: none; }

  #ptab-messages > div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
}

@media (min-width: 900px) {
  #portalBottomNav, #mobileSubChips { display: none !important; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .market-grid { grid-template-columns: 1fr; }
  .login-card, .pending-card { padding: 28px 22px; }
}

/* ═══════════════════════════════════════════════════════════════
   28. LIGHT THEME OVERRIDES
   ═══════════════════════════════════════════════════════════════ */
html[data-theme="light"] body { background: var(--bg-body); color: var(--text-primary); }
html[data-theme="light"] .bg-aurora,
html[data-theme="light"] .bg-orbs,
html[data-theme="light"] .bg-grid { opacity: .18; }
html[data-theme="light"] .portal-topbar,
html[data-theme="light"] .portal-tabs,
html[data-theme="light"] #portalBottomNav {
  background: rgba(255, 255, 255, .85);
}
html[data-theme="light"] .stat-card,
html[data-theme="light"] .chart-box,
html[data-theme="light"] .subs-card,
html[data-theme="light"] .market-card,
html[data-theme="light"] .table-wrapper,
html[data-theme="light"] .modal-box,
html[data-theme="light"] .appt-card,
html[data-theme="light"] .toast {
  background: #ffffff;
}
html[data-theme="light"] .msg-bubble.admin,
html[data-theme="light"] .ai-msg.assistant,
html[data-theme="light"] .p-doc-card,
html[data-theme="light"] .p-pres-card,
html[data-theme="light"] .training-row,
html[data-theme="light"] .p-tl-item {
  background: #f8fafc;
}
html[data-theme="light"] .p-doc-card,
html[data-theme="light"] .ai-chat-history {
  border-color: rgba(15, 23, 42, .1);
}
html[data-theme="light"] .ai-chat-input input,
html[data-theme="light"] .modal-body input,
html[data-theme="light"] .modal-body textarea,
html[data-theme="light"] .modal-body select,
html[data-theme="light"] .market-search input {
  background: #f8fafc;
  color: var(--text-primary);
}

/* ═══════════════════════════════════════════════════════════════
   29. REDUCED MOTION
   ═══════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
/* ═══════════════════════════════════════════════════════════════
   MOBILE TOPBAR — FIX
   Replaces the fragile sticky+wrap layout on phones.
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 899px) {

  /* ── Topbar: single row, no wrap, compact height ── */
  .portal-topbar {
    position: sticky;
    top: 0;
    height: 52px;
    padding: 0 10px;
    gap: 8px;
    flex-wrap: nowrap;
    overflow: hidden;
  }

  /* Brand: logo + "VIORA" only. Hide the role badge on mobile. */
  .portal-brand {
    flex: 1 1 auto;
    min-width: 0;
    gap: 8px;
    font-size: .92rem;
  }
  .portal-brand .brand-logo {
    width: 28px;
    height: 28px;
    border-radius: 8px;
  }
  .portal-brand .role-badge { display: none; }

  /* Actions: only the icon buttons + compact user chip. */
  .portal-actions {
    flex: 0 0 auto;
    gap: 6px;
    flex-wrap: nowrap;
  }

  /* Hide the "Live sync" pill — no room, and it duplicates the pulse dot. */
  .portal-actions .live-sync { display: none; }

  /* User chip: avatar + first name only (max 80px), hides on very small screens. */
  .portal-userinfo {
    max-width: 84px;
    font-size: .72rem;
    padding: 4px 6px;
    border-radius: 8px;
    background: var(--bg-input);
  }
  .portal-userinfo span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Buttons: icon-only, 32×32 tap target. */
  .portal-actions .btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 8px;
    font-size: .82rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  .portal-actions .btn i { font-size: .82rem; }

  /* The "Marketplace" text button — turn into an icon-only square. */
  .portal-actions .btn-purple {
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 0;
  }
  .portal-actions .btn-purple i { font-size: .85rem; }

  /* The theme-toggle + logout buttons share the same square shape. */
  .portal-actions #pThemeToggle,
  .portal-actions #pLogout {
    width: 32px;
    height: 32px;
    padding: 0;
  }

  /* ── Hide the tab strip entirely on mobile ──
     Bottom nav + subchips are the navigation surface. */
  .portal-tabs { display: none; }

  /* ── Main content padding must clear topbar + bottom nav + chips ── */
  .portal-main {
    padding: 14px 12px calc(var(--nav-h) + var(--chips-h) + 24px + env(safe-area-inset-bottom));
    max-width: none;
    margin: 0;
  }

  /* ── Bottom nav: fixed, flex row, equal buttons ── */
  #portalBottomNav {
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    height: var(--nav-h);
    padding: 0 env(safe-area-inset-left) 0 env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
  }
  #portalBottomNav .mnav-item {
    flex: 1 1 0;
    min-width: 0;
    max-width: 88px;
    padding: 6px 4px;
    font-size: .58rem;
    gap: 2px;
  }
  #portalBottomNav .mnav-item i { font-size: 1.05rem; }
  #portalBottomNav .mnav-label {
    display: block;
    font-size: .58rem;
    letter-spacing: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  /* ── Sub-chips strip sits above the bottom nav ── */
  #mobileSubChips {
    display: flex;
    align-items: center;
    height: var(--chips-h);
    padding: 6px 10px;
    gap: 6px;
    background: var(--bg-card-solid);
    border-top: 1px solid var(--border-color);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #mobileSubChips::-webkit-scrollbar { display: none; }
  #mobileSubChips .chip {
    flex: 0 0 auto;
    padding: 6px 12px;
    font-size: .74rem;
    border-radius: 999px;
    gap: 5px;
  }
  #mobileSubChips .chip i { font-size: .72rem; }

  /* ── Grace banner must not collide with the sticky topbar ── */
  #pGraceBanner {
    position: sticky;
    top: 52px;               /* topbar height */
    z-index: 44;
    margin: 0 12px 12px;
    padding: 10px 14px;
    font-size: .78rem;
  }

  /* ── Toasts float above bottom nav + chips ── */
  #pToastContainer {
    bottom: calc(var(--nav-h) + var(--chips-h) + 16px + env(safe-area-inset-bottom));
    left: 12px;
    right: 12px;
    max-width: none;
  }
  .toast { max-width: none; min-width: 0; width: 100%; }

  /* ── Modals: full-screen-ish on phones ── */
  .modal-overlay { padding: 10px; }
  .modal-box {
    max-height: calc(100vh - 20px);
    border-radius: 16px;
  }
  .modal-head, .modal-body, .modal-foot { padding: 14px 16px; }
}

/* ═══════════════════════════════════════════════════════════════
   EXTRA-SMALL PHONES (< 380px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 379px) {
  .portal-topbar { padding: 0 8px; gap: 6px; }
  .portal-brand { font-size: .85rem; gap: 6px; }
  .portal-brand .brand-logo { width: 26px; height: 26px; }
  .portal-userinfo { display: none; }
  .portal-actions { gap: 4px; }
  .portal-actions .btn,
  .portal-actions #pThemeToggle,
  .portal-actions #pLogout { width: 30px; height: 30px; }
}
