/* ── DESIGN TOKENS ─────────────────────────────────────────── */
:root {
  --navy:   #132d44;
  --navy2:  #1b3a4b;
  --navy3:  #234359;
  --orange: #F78F1E;
  --orange2:#e07c10;
  --bg:     #f0f3f7;
  --bg2:    #e8ecf2;
  --white:  #ffffff;
  --text:   #0e1c26;
  --text2:  #2d4a5c;
  --muted:  #6b8496;
  --border: #d8e2eb;
  --green:  #0fa968;
  --red:    #e03434;
  --yellow: #f59e0b;
  --purple: #6d3bcc;
  --blue:   #0369a1;

  --card:     #ffffff;
  --fg:       #0e1c26;
  --input-bg: #ffffff;
  --bg-alt:   #f8fafc;
  --surface2: #e8ecf2;

  --font-body:    'Poppins', sans-serif;
  --font-display: 'Poppins', sans-serif;
  --font-num:     'Poppins', sans-serif;
  --font-kpi:     'Poppins', sans-serif;

  --sidebar-w: 228px;
  --topbar-h:  56px;
  --radius:    10px;
  --radius-lg: 16px;
  --shadow:    0 1px 3px rgba(19,45,68,.07), 0 4px 16px rgba(19,45,68,.05);
  --shadow-md: 0 4px 24px rgba(19,45,68,.12);
}

/* ── RESET ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; font-family: var(--font-body); font-size: 16px; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
button { font-family: var(--font-body); cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: var(--font-body); }
a { color: inherit; text-decoration: none; }

/* ── LOGIN ─────────────────────────────────────────────────── */
#login-screen {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--navy);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  overflow: hidden;
}
.login-bg {
  position: absolute; inset: 0; overflow: hidden; pointer-events: none;
}
.login-bg::before {
  content: '';
  position: absolute; top: -40%; right: -20%; width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(247,143,30,.15) 0%, transparent 70%);
  border-radius: 50%;
}
.login-bg::after {
  content: '';
  position: absolute; bottom: -30%; left: -10%; width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(247,143,30,.08) 0%, transparent 70%);
  border-radius: 50%;
}
.login-card {
  position: relative; z-index: 1;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius-lg);
  padding: 44px 40px;
  width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.login-logo {
  display: flex; align-items: center; gap: 10px; margin-bottom: 32px; justify-content: center;
}
.login-logo img {
  height: 48px; width: 48px; object-fit: contain; border-radius: 8px;
}
.login-logo-text {
  font-family: var(--font-display); font-size: 29px; font-weight: 700; color: white; letter-spacing: -0.5px;
}
.login-logo-text span { color: var(--orange); }
.login-sub { text-align: center; color: rgba(255,255,255,.5); font-size: 13px; letter-spacing: 0.5px; text-transform: uppercase; margin-bottom: 28px; }
.login-field { margin-bottom: 14px; }
.login-field label { display: block; font-size: 12px; font-weight: 600; color: rgba(255,255,255,.5); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 6px; }
.login-field input {
  width: 100%; padding: 11px 14px; border-radius: 8px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.15);
  color: white; font-size: 14px; outline: none; transition: border-color .2s;
}
.login-field input::placeholder { color: rgba(255,255,255,.3); }
.login-field input:focus { border-color: var(--orange); background: rgba(255,255,255,.12); }
.login-btn {
  width: 100%; padding: 13px; border-radius: 8px;
  background: var(--orange); color: white; font-size: 15px; font-weight: 700;
  margin-top: 8px; transition: background .2s, transform .1s;
  letter-spacing: 0.3px;
}
.login-btn:hover { background: var(--orange2); }
.login-btn:active { transform: scale(.99); }
.login-btn.success { background: #0fa968 !important; transform: scale(1.01); }

/* ── APP SHELL ─────────────────────────────────────────────── */
#app { display: none; visibility: hidden; height: 100%; }
#app.visible { display: flex; flex-direction: column; visibility: visible; position: relative; z-index: 1; }

/* ── TOPBAR ─────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h); background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 20px;
  flex-shrink: 0;
  z-index: 100;
  box-shadow: 0 1px 0 var(--border);
}
.topbar-hamburger {
  display: none; padding: 8px; border-radius: 8px; color: var(--navy);
  background: none; border: none; cursor: pointer; font-size: 20px;
  transition: background .15s;
}
html.dark .topbar-hamburger { color: white; }
.topbar-hamburger:hover { background: var(--bg); }
.topbar-brand { display: flex; align-items: center; justify-content: center; gap: 8px; }

.topbar-brand-name { font-family: var(--font-display); font-size: 17px; font-weight: 700; color: var(--navy); }
.topbar-brand-name span { color: var(--orange); }
.topbar-divider { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
#topbar-page { font-size: 14px; font-weight: 600; color: var(--text2); }
.topbar-spacer { flex: 1; }
.topbar-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 12px; width: 220px; transition: border-color .2s;
}
.topbar-search:focus-within { border-color: var(--orange); }
.topbar-search input {
  border: none; background: none; outline: none; font-size: 13px;
  color: var(--text); flex: 1;
}
.topbar-search input::placeholder { color: var(--muted); }

/* Avatar dropdown */
.avatar-wrap { position: relative; }
.topbar-avatar { cursor: pointer; user-select: none; }
.avatar-menu {
  display: none; position: absolute; top: calc(100% + 10px); right: 0;
  background: var(--white); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.12); min-width: 200px; z-index: 999;
  overflow: hidden;
}
.avatar-menu.open { display: block; }
.avatar-menu-header {
  padding: 14px 16px 10px; border-bottom: 1px solid var(--border);
}
.avatar-menu-header .am-name { font-size: 14px; font-weight: 700; color: var(--text); }
.avatar-menu-header .am-role { font-size: 12px; color: var(--muted); margin-top: 2px; }
.avatar-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; font-size: 14px; color: var(--text2);
  cursor: pointer; transition: background .15s;
}
.avatar-menu-item:hover { background: var(--bg); color: var(--navy); }
.avatar-menu-item svg { opacity: .6; flex-shrink: 0; }
.avatar-menu-item.danger { color: var(--red); }
.avatar-menu-item.danger:hover { background: rgba(224,52,52,.06); }
.avatar-menu-divider { height: 1px; background: var(--border); margin: 4px 0; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
/* ── AI Token Counter ── */
#ai-usage-btn { position:relative; display:flex; align-items:center; gap:6px; height:34px; padding:0 12px; border-radius:8px; border:1px solid rgba(52,211,153,0.3); background:rgba(52,211,153,0.07); color:var(--text); font-size:12px; font-weight:700; cursor:pointer; transition:all .2s; flex-shrink:0; font-family:var(--font-num); }
#ai-usage-btn:hover { border-color:rgba(52,211,153,0.55); background:rgba(52,211,153,0.13); }
#ai-usage-btn .ai-cost { color:#34d399; }
#ai-usage-popover { position:fixed; top:58px; right:16px; width:340px; background:var(--card); border:1px solid var(--border); border-radius:14px; box-shadow:0 8px 40px rgba(0,0,0,.18); z-index:500; display:none; overflow:hidden; }
#ai-usage-popover.open { display:block; }
.ai-pop-head { background:var(--navy); padding:16px 18px; display:flex; align-items:center; justify-content:space-between; }
.ai-pop-title { font-size:13px; font-weight:700; color:#fff; }
.ai-pop-close { background:none; border:none; color:rgba(255,255,255,.5); font-size:18px; cursor:pointer; line-height:1; }
.ai-pop-body { padding:16px 18px; }
.ai-stat-row { display:flex; align-items:center; justify-content:space-between; padding:8px 0; border-bottom:1px solid var(--border); font-size:13px; }
.ai-stat-row:last-child { border-bottom:none; }
.ai-stat-label { color:var(--text2); }
.ai-stat-val { font-weight:700; color:var(--text); font-family:var(--font-num); }
.ai-model-row { display:flex; align-items:center; justify-content:space-between; padding:6px 10px; border-radius:8px; background:var(--bg); margin-bottom:6px; font-size:12px; }
.ai-model-name { color:var(--text); font-weight:600; }
.ai-model-cost { color:#34d399; font-weight:700; font-family:var(--font-num); }
.ai-budget-bar { height:6px; border-radius:3px; background:var(--border); margin:10px 0 4px; overflow:hidden; }
.ai-budget-fill { height:100%; border-radius:3px; background:linear-gradient(90deg,#34d399,#f78f1e); transition:width .6s ease; }
.topbar-avatar {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--navy); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; letter-spacing: 0.5px;
  overflow: hidden; cursor: pointer; flex-shrink: 0;
}
.role-tag {
  padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.role-tag.superadmin { background: rgba(109,59,204,.12); color: var(--purple); }
.role-tag.admin { background: rgba(19,45,68,.1); color: var(--navy); }
.role-tag.sales { background: rgba(247,143,30,.12); color: var(--orange2); }
.role-tag.support { background: rgba(15,169,104,.12); color: var(--green); }

/* ── BODY LAYOUT ───────────────────────────────────────────── */
.body-wrap { display: flex; flex: 1; overflow: hidden; height: calc(100vh - var(--topbar-h)); touch-action: pan-y; }

/* ── SIDEBAR ────────────────────────────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4);
  z-index: 199; -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.sidebar {
  width: var(--sidebar-w); min-width: 0; background: var(--navy); color: white;
  display: flex; flex-direction: column; overflow: hidden;
  flex-shrink: 0; position: relative; z-index: 200; isolation: isolate;
}

.sidebar-logo {
  padding: 16px 16px 14px; border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.sidebar-logo img { height: 80px; width: auto; object-fit: contain; }
.sidebar-logo-text { font-family: var(--font-display); font-size: 19px; font-weight: 700; color: white; }
.sidebar-logo-text span { color: var(--orange); }
.sidebar-logo-badge { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: rgba(255,255,255,.35); }

.sidebar-body {
  flex: 1; padding: 12px 10px; overflow-y: auto; overflow-x: hidden;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.1) transparent;
  min-height: 0;
}
.sidebar-body::-webkit-scrollbar { width: 4px; }
.sidebar-body::-webkit-scrollbar-track { background: transparent; }
.sidebar-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 4px; }
.sidebar-section {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.4px;
  color: rgba(255,255,255,.28); padding: 18px 10px 5px; margin-top: 2px;
  display: flex; align-items: center; gap: 8px;
}
.sidebar-section::after {
  content: ''; flex: 1; height: 1px; background: rgba(255,255,255,.07);
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 8px 12px; border-radius: 7px; width: 100%;
  color: rgba(255,255,255,.58); font-size: 12.5px; font-weight: 500;
  transition: all .15s; margin-bottom: 2px; text-align: start;
  border-inline-start: 2px solid transparent;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .6; transition: opacity .15s; }
.nav-item:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.9); border-left-color: rgba(255,255,255,.2); }
.nav-item:hover svg { opacity: .9; }
.nav-item.active { background: rgba(247,143,30,.13); color: var(--orange); font-weight: 600; border-left-color: var(--orange); }
.nav-item.active svg { opacity: 1; stroke: var(--orange); }
.nav-badge {
  margin-inline-start: auto; background: var(--orange); color: white;
  font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 20px;
  min-width: 18px; text-align: center;
}
.nav-item.active .nav-badge { background: rgba(247,143,30,.3); color: var(--orange); }

:root { --pg-accent: var(--orange); }
/* Section color coding — data-sc set by initSidebarColors() */
[data-sc="0"]                { background:rgba(96,165,250,.22); color:#fff; border-left-color:rgba(96,165,250,.4); }
[data-sc="0"]:hover          { background:rgba(96,165,250,.38); color:#fff; border-left-color:#60a5fa; }
[data-sc="0"].active         { background:#3b82f6; color:#fff; border-left-color:#93c5fd; font-weight:700; }
[data-sc="0"].active svg     { stroke:#fff; opacity:1; }
[data-sc="1"]                { background:rgba(247,143,30,.22); color:#fff; border-left-color:rgba(247,143,30,.4); }
[data-sc="1"]:hover          { background:rgba(247,143,30,.38); color:#fff; border-left-color:var(--orange); }
[data-sc="1"].active         { background:var(--orange); color:#fff; border-left-color:#fde68a; font-weight:700; }
[data-sc="1"].active svg     { stroke:#fff; opacity:1; }
[data-sc="2"]                { background:rgba(52,211,153,.22); color:#fff; border-left-color:rgba(52,211,153,.4); }
[data-sc="2"]:hover          { background:rgba(52,211,153,.38); color:#fff; border-left-color:#34d399; }
[data-sc="2"].active         { background:#059669; color:#fff; border-left-color:#6ee7b7; font-weight:700; }
[data-sc="2"].active svg     { stroke:#fff; opacity:1; }
[data-sc="3"]                { background:rgba(192,132,252,.22); color:#fff; border-left-color:rgba(192,132,252,.4); }
[data-sc="3"]:hover          { background:rgba(192,132,252,.38); color:#fff; border-left-color:#c084fc; }
[data-sc="3"].active         { background:#7c3aed; color:#fff; border-left-color:#d8b4fe; font-weight:700; }
[data-sc="3"].active svg     { stroke:#fff; opacity:1; }
[data-sc="4"]                { background:rgba(34,211,238,.22); color:#fff; border-left-color:rgba(34,211,238,.4); }
[data-sc="4"]:hover          { background:rgba(34,211,238,.38); color:#fff; border-left-color:#22d3ee; }
[data-sc="4"].active         { background:#0891b2; color:#fff; border-left-color:#67e8f9; font-weight:700; }
[data-sc="4"].active svg     { stroke:#fff; opacity:1; }
[data-sc="5"]                { background:rgba(148,163,184,.22); color:#fff; border-left-color:rgba(148,163,184,.4); }
[data-sc="5"]:hover          { background:rgba(148,163,184,.38); color:#fff; border-left-color:#94a3b8; }
[data-sc="5"].active         { background:#475569; color:#fff; border-left-color:#cbd5e1; font-weight:700; }
[data-sc="5"].active svg     { stroke:#fff; opacity:1; }
[data-sc="6"]                { background:rgba(248,113,113,.22); color:#fff; border-left-color:rgba(248,113,113,.4); }
[data-sc="6"]:hover          { background:rgba(248,113,113,.38); color:#fff; border-left-color:#f87171; }
[data-sc="6"].active         { background:#dc2626; color:#fff; border-left-color:#fca5a5; font-weight:700; }
[data-sc="6"].active svg     { stroke:#fff; opacity:1; }
[data-sc="7"]                { background:rgba(45,212,191,.22); color:#fff; border-left-color:rgba(45,212,191,.4); }
[data-sc="7"]:hover          { background:rgba(45,212,191,.38); color:#fff; border-left-color:#2dd4bf; }
[data-sc="7"].active         { background:#0f766e; color:#fff; border-left-color:#99f6e4; font-weight:700; }
[data-sc="7"].active svg     { stroke:#fff; opacity:1; }
[data-sc="8"]                { background:rgba(129,140,248,.22); color:#fff; border-left-color:rgba(129,140,248,.4); }
[data-sc="8"]:hover          { background:rgba(129,140,248,.38); color:#fff; border-left-color:#818cf8; }
[data-sc="8"].active         { background:#4f46e5; color:#fff; border-left-color:#c7d2fe; font-weight:700; }
[data-sc="8"].active svg     { stroke:#fff; opacity:1; }
/* Section label colors */
.sidebar-body > div:nth-of-type(1)         { color:#60a5fa; }
.sidebar-body > div:nth-of-type(1)::after  { background:rgba(96,165,250,.25); }
.sidebar-body > div:nth-of-type(2)         { color:#fb923c; }
.sidebar-body > div:nth-of-type(2)::after  { background:rgba(251,146,60,.25); }
.sidebar-body > div:nth-of-type(3)         { color:#34d399; }
.sidebar-body > div:nth-of-type(3)::after  { background:rgba(52,211,153,.25); }
.sidebar-body > div:nth-of-type(4)         { color:#22d3ee; }
.sidebar-body > div:nth-of-type(4)::after  { background:rgba(34,211,238,.25); }
.sidebar-body > div:nth-of-type(5)         { color:#c084fc; }
.sidebar-body > div:nth-of-type(5)::after  { background:rgba(192,132,252,.25); }
.sidebar-body > div:nth-of-type(6)         { color:#94a3b8; }
.sidebar-body > div:nth-of-type(6)::after  { background:rgba(148,163,184,.25); }
.sidebar-body > div:nth-of-type(7)         { color:#f87171; }
.sidebar-body > div:nth-of-type(7)::after  { background:rgba(248,113,113,.25); }
.sidebar-body > div:nth-of-type(8)         { color:#2dd4bf; }
.sidebar-body > div:nth-of-type(8)::after  { background:rgba(45,212,191,.25); }
.sidebar-body > div:nth-of-type(9)         { color:#818cf8; }
.sidebar-body > div:nth-of-type(9)::after  { background:rgba(129,140,248,.25); }

.sidebar-user {
  padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.15); position: relative;
  flex-shrink: 0;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}
.sidebar-avatar-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--orange); color: white;
  font-size: 13px; font-weight: 700; letter-spacing: 0.5px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; border: 2px solid rgba(255,255,255,.2);
  overflow: hidden; transition: border-color .15s;
  flex-shrink: 0;
}
.sidebar-avatar-btn:hover { border-color: var(--orange); }
.sidebar-dropup {
  position: absolute; bottom: 64px; left: 12px; right: 12px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 -4px 20px rgba(0,0,0,.12);
  display: none; z-index: 200; overflow: hidden;
}
.sidebar-dropup.open { display: block; }
.sidebar-dropup-header {
  padding: 12px 14px 8px; border-bottom: 1px solid var(--border);
}
.sidebar-dropup-header .sd-name { font-size: 13px; font-weight: 700; color: var(--text); }
.sidebar-dropup-header .sd-role { font-size: 11px; color: var(--muted); margin-top: 2px; }
html.dark .sidebar-dropup-header .sd-name { color: white; }
.sidebar-dropup-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; font-size: 13px; font-weight: 500;
  color: var(--text2); cursor: pointer; transition: background .1s;
}
.sidebar-dropup-item:hover { background: var(--bg); color: var(--navy); }
html.dark .sidebar-dropup-item:hover { background: rgba(255,255,255,.06); color: var(--text); }
.sidebar-dropup-item svg { opacity: .6; flex-shrink: 0; }
.sidebar-dropup-item.danger { color: var(--red); }
.sidebar-dropup-item.danger:hover { background: rgba(224,52,52,.06); }
.sidebar-dropup-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ── MAIN ───────────────────────────────────────────────────── */
.main {
  flex: 1; overflow-y: scroll; overflow-x: hidden; padding: 24px;
  background: var(--bg);
  -webkit-overflow-scrolling: touch;
  min-width: 0;
  min-height: 0;
  width: 0;
  touch-action: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0) transparent;
  isolation: isolate;
}
.main:hover {
  scrollbar-color: rgba(100,120,140,0.35) transparent;
}
.main::-webkit-scrollbar { width: 5px; }
.main::-webkit-scrollbar-track { background: transparent; }
.main::-webkit-scrollbar-thumb { background: rgba(0,0,0,0); border-radius: 3px; transition: background .2s; }
.main:hover::-webkit-scrollbar-thumb { background: rgba(100,120,140,0.35); }
.page { display: none; }
.page.active { display: block; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

/* ── PAGE HEADERS ─────────────────────────────────────────── */
.page-hdr {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px; flex-wrap: wrap; gap: 12px;
}
.page-title {
  font-family: var(--font-display); font-size: 23px; font-weight: 700;
  color: var(--navy); letter-spacing: -0.5px; line-height: 1.2;
}
.page-sub { font-size: 13px; color: var(--muted); margin-top: 3px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.page-hdr { border-inline-start: 4px solid var(--pg-accent, var(--orange)); padding-inline-start: 14px; transition: border-left-color .3s; }
.kpi { border-top-color: var(--kc, var(--pg-accent, var(--orange))); }

/* ── BUTTONS ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px; font-size: 13px; font-weight: 600;
  transition: all .15s; white-space: nowrap; letter-spacing: 0.2px;
}
.btn-primary { background: var(--orange); color: white; box-shadow: 0 3px 12px rgba(247,143,30,.38); }
.btn-primary:hover { background: var(--orange2); box-shadow: 0 5px 18px rgba(247,143,30,.55); }
.btn-secondary { background: rgba(19,45,68,.1); color: var(--navy); border: 1px solid rgba(19,45,68,.22); box-shadow: 0 2px 8px rgba(19,45,68,.08); }
.btn-secondary:hover { background: rgba(19,45,68,.18); box-shadow: 0 3px 12px rgba(19,45,68,.18); }
.btn-ghost { background: transparent; color: var(--text2); border: 1px solid var(--border); box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.btn-ghost:hover { background: var(--bg2); box-shadow: 0 2px 8px rgba(0,0,0,.1); }
.btn-danger { background: var(--red); color: white; box-shadow: 0 3px 12px rgba(224,52,52,.38); }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 6px; }

/* ── CARDS ─────────────────────────────────────────────────── */
.card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  box-shadow: var(--shadow); min-width: 0;
}
.card-title {
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--muted); margin-bottom: 16px;
}
.card-title-lg {
  font-family: var(--font-display); font-size: 17px; font-weight: 700;
  color: var(--navy); margin-bottom: 4px;
}

/* ── KPI CARDS ─────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi {
  background: var(--white); border-radius: var(--radius-lg);
  padding: 20px; border: 1px solid var(--border);
  box-shadow: var(--shadow); position: relative; overflow: hidden;
  border-top: 3px solid var(--kc, var(--orange)); min-width: 0;
}
.kpi::after {
  content: ''; position: absolute; top: -20px; right: -20px;
  width: 80px; height: 80px; border-radius: 50%;
  background: var(--kc, var(--orange)); opacity: .05;
}
.kpi-lbl { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); margin-bottom: 8px; }
.kpi-val { font-family: var(--font-kpi); font-size: 37px; color: var(--navy); letter-spacing: 1px; line-height: 1; margin-bottom: 8px; }
.kpi-delta { font-size: 12px; font-weight: 600; }
.kpi-delta.up { color: var(--green); }
.kpi-delta.down { color: var(--red); }
.kpi-delta::before { content: ''; }

/* ── GRID LAYOUTS ─────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }

/* ── BAR CHART ─────────────────────────────────────────────── */
.bar-chart {
  display: flex; align-items: flex-end; gap: 8px;
  height: 120px; padding-top: 10px;
}
.bar-g { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; }
.bar { width: 100%; border-radius: 4px 4px 0 0; min-height: 4px; transition: opacity .2s; }
.bar:hover { opacity: .8; }
.bar-lbl { font-size: 10px; color: var(--muted); font-weight: 600; }

/* ── DONUT ─────────────────────────────────────────────────── */
.donut-wrap { display: flex; align-items: center; gap: 16px; }
.dl { flex: 1; }
.dl-item { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text2); margin-bottom: 8px; }
.dl-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }

/* ── TABLES ─────────────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--white); box-shadow: var(--shadow); }
.tbl { width: 100%; border-collapse: collapse; }
.tbl thead tr { background: var(--navy); }
.tbl thead th {
  padding: 11px 16px; text-align: start; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.8px; color: rgba(255,255,255,.7);
  white-space: nowrap;
}
.tbl tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
.tbl tbody tr:last-child { border-bottom: none; }
.tbl tbody tr:hover { background: rgba(19,45,68,.02); }
.tbl td { padding: 12px 16px; font-size: 13px; color: var(--text); vertical-align: middle; }
.tbl td.num { font-family: var(--font-num); font-size: 13px; font-weight: 600; }

/* ── BADGES ─────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
  white-space: nowrap;
}
.badge-green  { background: rgba(15,169,104,.12); color: #0b8c56; }
.badge-orange { background: rgba(247,143,30,.15); color: #c47010; }
.badge-navy   { background: rgba(19,45,68,.1);    color: var(--navy2); }
.badge-red    { background: rgba(224,52,52,.12);  color: #b02020; }
.badge-yellow { background: rgba(245,158,11,.12); color: #946b00; }
.badge-blue   { background: rgba(3,105,161,.12);  color: var(--blue); }
.badge-purple { background: rgba(109,59,204,.12); color: var(--purple); }

/* ── SEARCH BAR ─────────────────────────────────────────────── */
.search-bar {
  display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap;
}
.search-input {
  flex: 1; min-width: 180px; padding: 9px 14px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--white); font-size: 13px; color: var(--text);
  outline: none; transition: border-color .2s;
}
.search-input:focus { border-color: var(--orange); }
.search-filter {
  padding: 9px 14px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--white); font-size: 13px; color: var(--text);
  outline: none; cursor: pointer;
}

/* ── ROW ACTIONS ────────────────────────────────────────────── */
.row-actions { display: flex; gap: 6px; }
.btn-xs {
  padding: 4px 10px; border-radius: 5px; font-size: 11px; font-weight: 600;
  transition: all .15s;
}
.btn-xs.edit { background: rgba(19,45,68,.08); color: var(--navy); border: 1px solid rgba(19,45,68,.18); box-shadow: 0 1px 4px rgba(19,45,68,.07); }
.btn-xs.edit:hover { background: var(--navy); color: white; box-shadow: 0 2px 8px rgba(19,45,68,.3); }
.btn-xs.del { background: rgba(224,52,52,.08); color: var(--red); border: 1px solid rgba(224,52,52,.2); box-shadow: 0 1px 4px rgba(224,52,52,.08); }
.btn-xs.del:hover { background: var(--red); color: white; box-shadow: 0 2px 8px rgba(224,52,52,.35); }
.btn-xs.deal { background: rgba(19,45,68,.12); color: var(--navy); border: 1px solid rgba(19,45,68,.25); box-shadow: 0 2px 6px rgba(19,45,68,.08); }
.btn-xs.deal:hover { background: var(--navy); color: white; box-shadow: 0 2px 8px rgba(19,45,68,.3); }
.btn-xs.match { background: rgba(15,169,104,.15); color: #0fa968; border: 1px solid rgba(15,169,104,.25); box-shadow: 0 1px 4px rgba(15,169,104,.08); }
.btn-xs.match:hover { background: #0fa968; color: white; box-shadow: 0 2px 8px rgba(15,169,104,.3); }

/* ── PIPELINE ────────────────────────────────────────────────── */
.pipeline-wrap { overflow-x: auto; padding-bottom: 8px; }
.pipeline {
  display: flex;
  flex-direction: row;
  gap: 8px;
  min-width: max-content;
  align-items: flex-start;
}
.pipeline-col {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 10px 8px; min-height: 200px;
  box-shadow: var(--shadow); flex: 0 0 170px; width: 170px;
}
.pipeline-col.drag-over { background: rgba(247,143,30,0.08) !important; border-color: var(--orange) !important; }
.pipeline-hdr {
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted); margin-bottom: 12px;
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: 10px; border-bottom: 2px solid var(--stage-color, var(--border));
}
.pipeline-hdr .count {
  background: var(--stage-color, var(--border)); color: white;
  border-radius: 20px; padding: 2px 8px; font-size: 10px; font-weight: 800;
}
.lead-card {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 11px; margin-bottom: 8px; transition: box-shadow .15s, transform .15s;
  cursor: default; border-inline-start: 3px solid var(--stage-color, var(--border));
}
.lead-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.lead-name { font-size: 13px; font-weight: 700; color: var(--navy); margin-bottom: 3px; }
.lead-co { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.lead-val { font-family: var(--font-num); font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.lead-owner { font-size: 11px; color: var(--muted); }

/* ── ACTIVITY ────────────────────────────────────────────────── */
.activity-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-icon {
  width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.activity-body { flex: 1; }
.activity-text { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 2px; }
.activity-meta { font-size: 11px; color: var(--muted); }

/* ── CLIENTS ─────────────────────────────────────────────────── */
.clients-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.client-card {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 22px; text-align: center; box-shadow: var(--shadow); transition: box-shadow .2s;
}
.client-card:hover { box-shadow: var(--shadow-md); }
.client-avatar {
  width: 56px; height: 56px; border-radius: 14px;
  background: var(--navy); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 800; margin: 0 auto 12px; letter-spacing: 0.5px;
}
.client-name { font-weight: 700; font-size: 15px; color: var(--navy); margin-bottom: 3px; }
.client-industry { font-size: 12px; color: var(--muted); margin-bottom: 16px; }
.client-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cs-stat { text-align: center; }
.cs-val { font-family: var(--font-num); font-size: 15px; font-weight: 700; color: var(--navy); }
.cs-lbl { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }

/* ── ANALYTICS PLATFORM CARDS ─────────────────────────────── */
.analytics-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.platform-card {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px; box-shadow: var(--shadow);
}
.platform-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.platform-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.platform-name { font-size: 14px; font-weight: 700; color: var(--navy); }
.platform-handle { font-size: 12px; color: var(--muted); }
.platform-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.pm-stat { text-align: center; }
.pm-val { font-family: var(--font-kpi); font-size: 23px; color: var(--navy); letter-spacing: 0.5px; }
.pm-lbl { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.pm-delta { font-size: 11px; font-weight: 600; color: var(--green); }

/* ── SOCIAL POSTS ────────────────────────────────────────────── */
.posts-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.post-card {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px; box-shadow: var(--shadow);
}
.post-card.dragging { opacity: .4; transform: scale(.97); border: 2px dashed var(--orange); }
.post-card.drag-over { border: 2px dashed var(--navy); background: rgba(19,45,68,.04); }
.post-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap;
}
.post-platform-badge {
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.post-title { font-size: 14px; font-weight: 700; color: var(--navy); flex: 1; }
.post-body { font-size: 13px; color: var(--text2); line-height: 1.6; margin-bottom: 12px; }
.post-metrics { display: flex; gap: 16px; }
.pm-mini { display: flex; align-items: center; gap: 5px; font-family: var(--font-num); font-size: 12px; color: var(--muted); }

/* ── AI QUEUE ─────────────────────────────────────────────────── */
.queue-list { display: flex; flex-direction: column; gap: 10px; }
.queue-item {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow);
}
.q-thumb {
  width: 36px; height: 36px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.q-info { flex: 1; min-width: 0; }
.q-title { font-size: 14px; font-weight: 600; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.q-status { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; padding: 3px 9px; border-radius: 20px; }
.q-status.ready { background: rgba(15,169,104,.12); color: #0b8c56; }
.q-status.review { background: rgba(245,158,11,.12); color: #946b00; }
.q-status.draft { background: rgba(19,45,68,.08); color: var(--muted); }
.q-actions { display: flex; gap: 6px; }
.q-btn { padding: 5px 12px; border-radius: 6px; font-size: 12px; font-weight: 600; transition: all .15s; }
.q-btn.approve { background: var(--orange); color: white; }
.q-btn.approve:hover { background: var(--orange2); }
.q-btn.edit { background: rgba(19,45,68,.08); color: var(--navy); }
.q-btn.edit:hover { background: var(--navy); color: white; }

/* ── EMAIL CAMPAIGNS ─────────────────────────────────────────── */
.email-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.email-list { display: flex; flex-direction: column; gap: 10px; }
.email-card {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px 20px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow);
}
.email-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.email-info { flex: 1; min-width: 0; }
.email-subject { font-size: 14px; font-weight: 600; color: var(--navy); }
.email-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.email-metrics { display: flex; gap: 20px; }
.em-stat { text-align: end; }
.em-val { font-family: var(--font-num); font-size: 16px; font-weight: 700; color: var(--navy); }
.em-lbl { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }

/* ── WORKFLOWS ────────────────────────────────────────────────── */
.wf-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.workflow-card {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px; box-shadow: var(--shadow);
}
.wf-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.wf-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: rgba(247,143,30,.1); display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.wf-info { flex: 1; }
.wf-name { font-size: 15px; font-weight: 700; color: var(--navy); margin-bottom: 3px; }
.wf-trigger { font-size: 12px; color: var(--muted); line-height: 1.5; }
.wf-stats { display: flex; gap: 20px; padding: 10px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.stat-val { font-family: var(--font-num); font-size: 14px; font-weight: 700; color: var(--navy); }
.stat-lbl { font-size: 12px; color: var(--muted); }
.wf-actions { display: flex; gap: 8px; }
.wf-cat-btn { padding:6px 14px;border-radius:20px;border:1px solid var(--border);background:var(--input-bg);color:var(--text2);font-size:12px;font-weight:600;font-family:var(--font);cursor:pointer;transition:all .15s }
.wf-cat-btn.active,.wf-cat-btn:hover { background:rgba(247,143,30,.12);color:var(--orange);border-color:rgba(247,143,30,.3) }

/* ── AI AGENT ─────────────────────────────────────────────────── */
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 200px); }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px;
  background: var(--bg); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border: 1px solid var(--border); border-bottom: none;
}
.chat-msg { max-width: 70%; }
.chat-msg.user { align-self: flex-end; }
.chat-msg.bot { align-self: flex-start; }
.chat-bubble {
  padding: 11px 15px; border-radius: 12px; font-size: 14px; line-height: 1.6;
}
.chat-msg.user .chat-bubble { background: var(--navy); color: white; border-bottom-right-radius: 4px; }
.chat-msg.bot .chat-bubble { background: var(--white); border: 1px solid var(--border); color: var(--text); border-bottom-left-radius: 4px; }
.chat-msg-meta { font-size: 11px; color: var(--muted); margin-top: 4px; }
.chat-msg.user .chat-msg-meta { text-align: end; }
.chat-input-bar {
  display: flex; gap: 8px; padding: 14px;
  background: var(--white); border: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.chat-input {
  flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; outline: none; background: var(--bg); transition: border-color .2s;
}
.chat-input:focus { border-color: var(--orange); }

/* ── CONTENT STUDIO v2 ───────────────────────────────────────── */
.cs-workspace { display:grid; grid-template-columns:220px 1fr 320px; gap:14px; height:calc(100vh - var(--topbar-h) - 110px); }
.cs-col { background:var(--card-bg); border-radius:12px; border:1px solid var(--border); display:flex; flex-direction:column; overflow:hidden; }
.cs-col-hdr { padding:14px 16px 10px; border-bottom:1px solid var(--border); display:flex; align-items:center; justify-content:space-between; flex-shrink:0; }
.cs-col-hdr h4 { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.8px; color:var(--muted); margin:0; }
.cs-col-body { flex:1; overflow-y:auto; padding:12px; display:flex; flex-direction:column; gap:8px; }
.cs-project-item { padding:9px 12px; border-radius:8px; cursor:pointer; font-size:13px; font-weight:500; color:var(--text); border:1px solid transparent; transition:all .15s; }
.cs-project-item:hover { background:var(--bg); border-color:var(--border); }
.cs-project-item.active { background:rgba(247,143,30,.12); border-color:rgba(247,143,30,.4); color:var(--orange); }
.cs-project-item .cs-proj-meta { font-size:11px; color:var(--muted); margin-top:2px; }
.cs-source-item { padding:8px 10px; border-radius:8px; background:var(--bg); border:1px solid var(--border); font-size:12px; display:flex; align-items:flex-start; justify-content:space-between; gap:8px; }
.cs-source-item .cs-src-info { flex:1; min-width:0; }
.cs-source-item .cs-src-title { font-weight:600; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.cs-source-item .cs-src-meta { font-size:10px; color:var(--muted); margin-top:2px; line-height:1.4; }
.cs-source-item .cs-src-summary { font-size:11px; color:var(--muted); margin-top:4px; line-height:1.5; }
.cs-badge { display:inline-block; font-size:9px; font-weight:700; text-transform:uppercase; letter-spacing:.5px; padding:2px 6px; border-radius:10px; }
.cs-badge-ready { background:#d4f4e6; color:#0a7a4e; }
.cs-badge-processing { background:#fff3e0; color:#d4700a; }
.cs-badge-error { background:#ffe5e5; color:#c0392b; }
.cs-piece-item { padding:9px 12px; border-radius:8px; background:var(--bg); border:1px solid var(--border); cursor:pointer; transition:all .15s; }
.cs-piece-item:hover { border-color:var(--orange); }
.cs-piece-item .cs-piece-type { font-size:10px; font-weight:700; text-transform:uppercase; color:var(--orange); }
.cs-piece-item .cs-piece-title { font-size:12px; font-weight:600; color:var(--text); margin-top:2px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.cs-piece-item .cs-piece-date { font-size:10px; color:var(--muted); margin-top:2px; }
.cs-fmt-btn { padding:6px 12px; border-radius:8px; font-size:12px; font-weight:600; border:1px solid var(--border); background:var(--bg); color:var(--muted); cursor:pointer; transition:all .15s; white-space:nowrap; }
.cs-fmt-btn:hover { border-color:var(--orange); color:var(--orange); }
.cs-fmt-btn.active { background:rgba(247,143,30,.14); border-color:rgba(247,143,30,.5); color:var(--orange); font-weight:700; }
.cs-src-check { display:flex; align-items:flex-start; gap:8px; padding:7px 10px; border-radius:8px; background:var(--bg); border:1px solid var(--border); font-size:12px; cursor:pointer; }
.cs-src-check input[type=checkbox] { margin-top:1px; flex-shrink:0; accent-color:var(--orange); }
.cs-output-area { flex:1; overflow-y:auto; padding:12px; }
.cs-output-text { white-space:pre-wrap; font-size:13px; line-height:1.7; color:var(--text); background:var(--bg); border-radius:8px; padding:14px; border:1px solid var(--border); min-height:120px; }
.cs-output-img { width:100%; border-radius:10px; margin-bottom:10px; }
.cs-empty { color:var(--muted); font-size:12px; text-align:center; padding:30px 0; }
.cs-section-label { font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:.8px; color:var(--muted); padding:4px 12px 6px; }
@media(max-width:900px){ .cs-workspace{grid-template-columns:1fr;height:auto;} .cs-col{height:auto;min-height:300px;} }

/* ── REPORTS ─────────────────────────────────────────────────── */
.report-tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.report-tab {
  padding: 8px 18px; border-radius: 8px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--border); color: var(--muted); background: var(--white);
  transition: all .15s;
}
.report-tab:hover { border-color: rgba(247,143,30,.4); color: var(--orange); }
.report-tab.active { background: rgba(19,45,68,.12); color: var(--navy); border-color: rgba(19,45,68,.35); box-shadow: 0 2px 8px rgba(19,45,68,.1); font-weight: 700; }
html.dark .report-tab { background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.1); color: var(--text2); }
html.dark .report-tab:hover { border-color: rgba(247,143,30,.4); color: var(--orange); }
html.dark .report-tab.active { background: rgba(96,165,250,.18); color: #93c5fd; border-color: rgba(96,165,250,.35); box-shadow: 0 2px 8px rgba(96,165,250,.15); }
.report-stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }

/* ── FOLLOW-UP QUEUE ─────────────────────────────────────────── */
.fu-card{background:var(--white);border:1px solid var(--border);border-radius:10px;padding:14px 16px;margin-bottom:8px;transition:.15s}
.fu-card:hover{border-color:var(--navy2)}
.fu-card-top{display:flex;align-items:center;gap:12px}
.fu-avatar{width:36px;height:36px;border-radius:50%;background:var(--navy2);display:flex;align-items:center;justify-content:center;font-size:13px;font-weight:700;color:white;flex-shrink:0}
.fu-name{font-size:14px;font-weight:600;color:var(--text)}
.fu-company{font-size:12px;color:var(--muted)}
.fu-priority-overdue{font-size:10px;font-weight:800;padding:2px 8px;border-radius:6px;background:rgba(239,83,80,.12);color:#ef5350;border:1px solid rgba(239,83,80,.25)}
.fu-priority-today{font-size:10px;font-weight:800;padding:2px 8px;border-radius:6px;background:rgba(247,143,30,.12);color:var(--orange);border:1px solid rgba(247,143,30,.25)}
.fu-priority-week{font-size:10px;font-weight:800;padding:2px 8px;border-radius:6px;background:rgba(30,136,229,.12);color:#1e88e5;border:1px solid rgba(30,136,229,.25)}
.fu-method{font-size:10px;padding:2px 8px;border-radius:6px;background:var(--bg);color:var(--muted);border:1px solid var(--border)}
.fu-hist{background:var(--bg);border-radius:8px;padding:8px 12px;margin-top:10px;display:none}
.fu-hist-row{display:flex;gap:8px;padding:4px 0;border-bottom:1px solid var(--border);font-size:12px;color:var(--muted)}
.fu-hist-row:last-child{border-bottom:none}
.fu-note-form{margin-top:10px;display:none}
.fu-note-form textarea{width:100%;background:var(--bg);border:1px solid var(--border);border-radius:8px;padding:8px 12px;color:var(--text);font-size:13px;resize:vertical;box-sizing:border-box}

/* ── LEAD REMINDER NOTIFICATIONS ────────────────────────────── */
.reminder-overlay{position:fixed;bottom:88px;right:24px;z-index:9998;display:none;flex-direction:column;gap:10px;max-width:340px}
.reminder-card{background:#ffffff;color:#132d44;border:1px solid var(--border);border-radius:14px;padding:18px 20px;box-shadow:0 8px 40px rgba(0,0,0,.45);border-inline-start:4px solid var(--orange);animation:remSlide .3s ease}
html.dark .reminder-card{background:var(--navy2) !important;color:var(--text) !important;border-color:rgba(255,255,255,.12) !important}
@keyframes remSlide{from{opacity:0;transform:translateX(30px)}to{opacity:1;transform:translateX(0)}}
.reminder-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:10px}
.reminder-title{font-size:11px;font-weight:800;text-transform:uppercase;letter-spacing:1px;color:var(--orange)}
.reminder-badge{font-size:10px;font-weight:700;background:rgba(247,143,30,.15);color:var(--orange);border:1px solid rgba(247,143,30,.3);padding:2px 8px;border-radius:10px}
.reminder-lead{font-size:15px;font-weight:700;color:var(--text);margin-bottom:3px}
.reminder-meta{font-size:12px;color:var(--muted);margin-bottom:14px}
.reminder-actions{display:flex;gap:8px}

/* ── NOTIFICATION PANEL ──────────────────────────────────────── */
#notif-panel{position:fixed;top:0;right:-380px;width:360px;height:100dvh;background:var(--card);border-inline-start:1px solid var(--border);z-index:10000;transition:right .3s cubic-bezier(.4,0,.2,1);display:flex;flex-direction:column;box-shadow:-8px 0 40px rgba(0,0,0,.18)}
/* --card handles notif-panel dark background */
#notif-panel.np-open{right:0}
#notif-panel-overlay{display:none;position:fixed;inset:0;z-index:9999;background:rgba(0,0,0,.35)}
#notif-panel-overlay.np-open{display:block}
#notif-bell-btn{position:relative;width:34px;height:34px;border-radius:50%;border:1px solid rgba(19,45,68,.2);background:none;color:var(--navy);display:flex;align-items:center;justify-content:center;cursor:pointer;transition:all .2s;flex-shrink:0}
html.dark #notif-bell-btn{border-color:rgba(255,255,255,.15);color:#e2e8f0}
#notif-bell-btn:hover{background:rgba(247,143,30,.1);border-color:var(--orange);color:var(--orange)}
#notif-bell-badge{display:none;position:absolute;top:-3px;right:-3px;background:#ef4444;color:#fff;font-size:9px;font-weight:700;min-width:17px;height:17px;border-radius:9px;padding:0 3px;line-height:17px;text-align:center;border:2px solid #fff;pointer-events:none}
html.dark #notif-bell-badge{border-color:var(--navy)}
.np-item{padding:14px 20px;cursor:pointer;border-bottom:1px solid var(--border);display:flex;gap:12px;align-items:flex-start;transition:background .15s}
.np-item:hover{background:var(--bg2)}
.np-item.np-unread{background:rgba(247,143,30,.05)}
.np-item.np-unread:hover{background:rgba(247,143,30,.1)}

/* ── REPORT LEVEL SWITCHER ───────────────────────────────────── */
.rpt-lvl{flex:1;padding:8px 14px;border-radius:7px;font-size:12px;font-weight:700;cursor:pointer;border:1px solid transparent;background:none;color:var(--text2);transition:all .15s}
.rpt-lvl:hover{background:rgba(247,143,30,.08);color:var(--orange);border-color:rgba(247,143,30,.25)}
.rpt-lvl.active{background:rgba(247,143,30,.15);color:var(--orange);border-color:rgba(247,143,30,.4);box-shadow:0 2px 8px rgba(247,143,30,.18);font-weight:700}
html.dark .rpt-lvl.active{background:rgba(247,143,30,.2);color:#fbbf24;border-color:rgba(247,143,30,.45)}
.report-chart {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px;
}

/* ── SCHEDULER ────────────────────────────────────────────────── */
.scheduler-list { display: flex; flex-direction: column; gap: 10px; }
.schedule-card {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px 20px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow);
}
.schedule-icon {
  width: 40px; height: 40px; border-radius: 10px; background: rgba(19,45,68,.08);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.schedule-info { flex: 1; }
.schedule-name { font-size: 14px; font-weight: 700; color: var(--navy); }
.schedule-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.schedule-actions { display: flex; gap: 8px; }

/* ── USERS TABLE ─────────────────────────────────────────────── */
.users-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.user-card {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow);
}
.user-avatar {
  width: 44px; height: 44px; border-radius: 10px; background: var(--navy);
  color: white; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800; flex-shrink: 0; letter-spacing: 0.5px;
}
.user-info { flex: 1; }
.user-name { font-size: 15px; font-weight: 700; color: var(--navy); }
.user-email { font-size: 12px; color: var(--muted); margin-top: 2px; }
.user-actions { display: flex; gap: 6px; }

/* ── SECURITY ─────────────────────────────────────────────────── */
.security-alerts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.alert-row {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow);
}
.alert-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.alert-info { flex: 1; }
.alert-type { font-size: 13px; font-weight: 700; color: var(--navy); }
.alert-detail { font-size: 12px; color: var(--muted); margin-top: 2px; }
.alert-time { font-size: 11px; color: var(--muted); white-space: nowrap; font-family: var(--font-num); }
.mfa-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.mfa-card {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px; box-shadow: var(--shadow); text-align: center;
}
.mfa-indicator { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 10px; }
.mfa-dot { width: 8px; height: 8px; border-radius: 50%; }

/* ── AUDIT ─────────────────────────────────────────────────────── */
.audit-list { display: flex; flex-direction: column; gap: 2px; }
.audit-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 14px; border-radius: 8px; transition: background .1s;
}
.audit-item:hover { background: var(--bg); }
.audit-icon {
  width: 30px; height: 30px; border-radius: 7px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.audit-body { flex: 1; }
.audit-action { font-size: 13px; font-weight: 500; color: var(--text); }
.audit-meta { font-size: 11px; color: var(--muted); margin-top: 2px; font-family: var(--font-num); }

/* ── EMPTY STATE ──────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 40px 20px; color: var(--muted);
}
.empty-state p { font-size: 13px; margin-top: 10px; }

/* ── MODALS ─────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1000;
  display: none; align-items: center; justify-content: center; padding: 20px;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white); border-radius: var(--radius-lg); padding: 28px;
  width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2); animation: modalIn .2s ease;
}
@keyframes modalIn { from { opacity:0; transform:scale(.96) translateY(8px); } to { opacity:1; transform:scale(1) translateY(0); } }
.modal-hdr { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.modal-title { font-family: var(--font-display); font-size: 19px; font-weight: 700; color: var(--navy); }
.modal-close {
  width: 32px; height: 32px; border-radius: 8px; background: var(--bg);
  display: flex; align-items: center; justify-content: center; color: var(--muted);
  transition: all .15s;
}
.modal-close:hover { background: var(--red); color: white; }
.d-doc-group { background: var(--surface2,rgba(255,255,255,0.03)); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.d-doc-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 8px; }
.d-doc-row { display: flex; align-items: center; justify-content: space-between; padding: 4px 0; }
.d-doc-row + .d-doc-row { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 8px; }
.d-doc-name { font-size: 12px; color: var(--text); }
.d-doc-links { display: flex; gap: 6px; }
.d-doc-btn { font-size: 10px; font-weight: 700; padding: 3px 10px; border-radius: 5px; text-decoration: none; background: rgba(247,143,30,0.12); color: var(--orange); border: 1px solid rgba(247,143,30,0.3); transition: background 0.15s; }
.d-doc-btn:hover { background: rgba(247,143,30,0.25); }
.d-doc-btn-ar { background: rgba(16,185,129,0.1); color: #10b981; border-color: rgba(16,185,129,0.3); }
.d-doc-btn-ar:hover { background: rgba(16,185,129,0.22); }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); margin-bottom: 6px; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; color: var(--text); outline: none; transition: border-color .2s;
  background: var(--bg);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--orange); background: var(--white); }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ── JOURNEY CHECKLIST ─────────────────────────────────────────── */
.jc-item { display:flex; align-items:flex-start; gap:8px; padding:6px 0; border-bottom:0.5px solid var(--border); font-size:12px; }
.jc-item:last-child { border-bottom:none; }
.jc-check { width:16px; height:16px; min-width:16px; border-radius:4px; border:1.5px solid var(--border); cursor:pointer; margin-top:1px; display:flex; align-items:center; justify-content:center; transition:all .15s; }
.jc-check.done { background:var(--green,#0fa968); border-color:var(--green,#0fa968); }
.jc-check.done::after { content:'✓'; color:#fff; font-size:10px; font-weight:700; }
.jc-label { color:var(--text); line-height:1.5; cursor:pointer; user-select:none; }
.jc-label.done { text-decoration:line-through; color:var(--muted); }

/* ── TOAST ─────────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  background: #132d44; color: #ffffff;
  padding: 12px 20px; border-radius: 10px;
  font-size: 14px; font-weight: 500;
  box-shadow: 0 4px 24px rgba(0,0,0,0.55);
  transform: translateY(100px); opacity: 0; transition: transform .25s ease, opacity .25s ease;
  border-inline-start: 4px solid #f78f1e; max-width: 320px; pointer-events: none;
}
#toast.show { transform: translateY(0); opacity: 1; pointer-events: auto; }
html.dark #toast { background: var(--navy2) !important; color: var(--text) !important; border-left-color: var(--orange) !important; box-shadow: 0 4px 24px rgba(0,0,0,0.7) !important; }

/* ── HEATMAP ─────────────────────────────────────────────────── */
.heatmap-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 4px; margin-top: 12px;
}
.hm-cell {
  aspect-ratio: 1; border-radius: 4px;
  background: rgba(247,143,30, var(--intensity, .05));
  transition: transform .1s;
}
.hm-cell:hover { transform: scale(1.15); }
.hm-days {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 4px; margin-bottom: 4px;
}
.hm-day { font-size: 10px; color: var(--muted); text-align: center; font-weight: 600; }

/* ── CONTENT CALENDAR ────────────────────────────────────────── */
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.cal-hdr { text-align: center; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); padding: 6px 0; }
.cal-day {
  background: var(--white); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px; min-height: 80px; transition: border-color .15s;
}
.cal-day:hover { border-color: var(--orange); }
.cal-day.cal-drag-over { border: 2px dashed var(--orange); background: rgba(247,143,30,.07); }
.cal-day-num { font-family: var(--font-num); font-size: 14px; font-weight: 700; color: var(--navy); margin-bottom: 4px; }
.cal-day.today { border-color: var(--orange); background: rgba(247,143,30,.04); }
.cal-event {
  font-size: 10px; font-weight: 600; padding: 2px 5px; border-radius: 3px;
  margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: grab;
}
.cal-event.cal-ev-dragging { opacity: .35; }

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .kpi-grid, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .analytics-grid, .clients-grid { grid-template-columns: repeat(2, 1fr); }
  .mfa-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1024px) {
  :root { --sidebar-w: 0px; }
  .topbar-hamburger { display: flex; }
  .topbar-brand { display: flex; }
  .topbar-search { width: 180px; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 240px;
    transform: translateX(-100%);
    transition: transform .25s ease; z-index: 300;
    overflow: hidden;
    display: flex; flex-direction: column;
  }
  /* Shrink logo in sidebar so nav items + footer are visible */
  .sidebar-logo { padding: 10px 14px !important; flex-shrink: 0 !important; }
  .sidebar-logo img { height: 60px !important; }
  .sidebar-user { flex-shrink: 0 !important; }
  .sidebar-body {
    flex: 1 1 0 !important; min-height: 0 !important;
    overflow-y: scroll !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-y !important;
    overscroll-behavior-y: contain !important;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay { display: none; }
  .sidebar-overlay.open { display: block; }
  .body-wrap { height: calc(100vh - var(--topbar-h)); }
  .wf-grid { grid-template-columns: 1fr; }
  .posts-grid { grid-template-columns: 1fr; }
  .users-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .analytics-grid, .clients-grid { grid-template-columns: 1fr; }
  .email-metrics { flex-direction: column; gap: 8px; }
}

@media (max-width: 600px) {
  .main { padding: 14px; }
  .page-hdr { flex-direction: column; align-items: flex-start; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi-val { font-size: 29px; }
  .page-title { font-size: 19px; }
  .topbar-search { display: none; }
  .role-tag { display: none; }
  .email-card { flex-direction: column; align-items: flex-start; }
  .modal { padding: 20px; }
  .modal { max-width: 100%; }
  #toast { bottom: 16px; right: 16px; left: 16px; max-width: none; }
  .wf-grid { grid-template-columns: 1fr; }
  .schedule-card { flex-direction: column; align-items: flex-start; }
  .alert-row { flex-wrap: wrap; }
  .mfa-grid { grid-template-columns: 1fr 1fr; }
  .report-stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 400px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .q-actions { flex-direction: column; }
}

/* ── TOPBAR MOBILE OVERRIDES ─────────────────────────────────── */
@media (max-width: 1024px) {
  .topbar {
    height: 72px;
    padding: 0 14px;
    gap: 10px;
    background: var(--navy) !important;
    border-bottom: 1px solid rgba(255,255,255,.07) !important;
  }
  .topbar-divider { display: none; }
  #topbar-page { display: none; }
  .topbar-search { display: none; }
  .topbar-brand-name { display: none; }
  .topbar-brand-logo { display: block !important; }
  /* Hamburger removed — "More" in bottom nav handles sidebar */
  .topbar-hamburger { display: none !important; }
  /* Website button — compact icon+text pill */
  .topbar-website-link {
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
    padding: 0 10px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid rgba(247,143,30,.35) !important;
    background: rgba(247,143,30,.12) !important;
    color: white !important;
    font-size: 11px;
    font-weight: 700;
    text-decoration: none;
    flex-shrink: 0;
    white-space: nowrap;
  }
  #theme-toggle-btn { color: white !important; border-color: rgba(255,255,255,.2) !important; }
  .topbar-avatar { background: var(--orange) !important; }
}

/* ── MOBILE BOTTOM NAV ───────────────────────────────────────── */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 62px;
  background: var(--navy);
  border-top: 1px solid var(--border);
  z-index: 400;
  padding-bottom: env(safe-area-inset-bottom);
}
.mobile-bottom-nav-inner {
  display: flex;
  height: 62px;
  align-items: stretch;
}
.mbn-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .3px;
  transition: color .15s;
  padding: 0;
  position: relative;
}
.mbn-item svg { width: 22px; height: 22px; stroke: currentColor; }
.mbn-item.active { color: var(--orange); }
.mbn-item.active svg { stroke: var(--orange); }
.mbn-badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 18px);
  background: var(--orange);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}
@media (max-width: 1024px) {
  .mobile-bottom-nav { display: block; }
  .body-wrap { height: calc(100vh - 72px - 62px - env(safe-area-inset-bottom)); }
  .main { padding: 14px 14px 24px; }
}

/* ── COMPREHENSIVE MOBILE RESPONSIVE FIXES ──────────────────────── */
@media (max-width: 1024px) {

  /* ── TOPBAR: prevent overflow, contain logo ── */
  .topbar { overflow: hidden; max-width: 100%; flex-wrap: nowrap; }
  /* Logo: fits inside 72px topbar */
  .topbar-brand-logo { height: 72px !important; max-height: 72px !important; width: auto !important; flex-shrink: 0; }
  /* Topbar actions: swipeable row on mobile */
  .topbar-user {
    gap: 6px; flex-shrink: 0;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; max-width: calc(100vw - 90px);
    padding-bottom: 2px;
  }
  .topbar-user::-webkit-scrollbar { display: none; }
  /* Topbar spacer shrinks but keeps avatar visible */
  .topbar-spacer { flex: 0; min-width: 0; }
  /* Avatar stays compact */
  .topbar-avatar { width: 30px !important; height: 30px !important; font-size: 11px !important; }
  /* Theme toggle compact */
  #theme-toggle-btn { width: 30px !important; height: 30px !important; font-size: 14px !important; flex-shrink: 0; }
  /* Install btn compact */
  #topbar-install-btn { padding: 4px !important; flex-shrink: 0; }

  /* ── HIDE SYSTEM SECTION from mobile sidebar ── */
  .wh-grid-2 { grid-template-columns: 1fr !important; }
  #nav-infra-section,
  #nav-settings,
  #nav-infra-settings,
  #nav-users,
  #nav-security,
  #nav-audit,
  #nav-infra-vps,
  #nav-infra-financial,
  #nav-deploy,
  #nav-overview,
  #nav-demos { display: none !important; }

  /* ── PAGE HEADERS: stack vertically ── */
  .page-hdr {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
    margin-bottom: 14px !important;
  }
  .page-title { font-size: 19px !important; }
  .page-sub { font-size: 12px !important; }

  /* Page action buttons: row, wrap, full-width on very small */
  .page-actions {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    width: 100% !important;
  }
  .page-actions .btn {
    flex: 1 1 auto !important;
    min-width: 120px !important;
    justify-content: center !important;
  }

  /* ── BUTTONS: minimum 44px tap target (Apple HIG) ── */
  .btn { min-height: 40px !important; box-sizing: border-box; }
  .btn-sm { min-height: 36px !important; font-size: 12px !important; }

  /* ── KPI GRID: 2 columns ── */
  .kpi-grid { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  .kpi-val { font-size: 26px !important; }
  .kpi-card { padding: 14px !important; }

  /* ── PIPELINE: horizontal scroll with momentum ── */
  .pipeline-wrap {
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-x: contain !important;
    padding-bottom: 8px !important;
    /* bleed to screen edge for full-width feel */
    margin-inline-start: -14px !important;
    margin-inline-end: -14px !important;
    padding-inline-start: 14px !important;
    padding-inline-end: 14px !important;
    touch-action: pan-x !important;
  }
  .pipeline { min-width: max-content !important; padding-inline-end: 14px; }
  .pipeline-col {
    flex: 0 0 240px !important;
    width: 240px !important;
  }

  /* ── TABLES: horizontal scroll, no-shrink ── */
  .tbl-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-x: contain !important;
    border-radius: 10px !important;
  }
  .tbl { min-width: 560px !important; } /* force scroll before cramping */
  .tbl th { font-size: 11px !important; padding: 8px 10px !important; white-space: nowrap !important; }
  .tbl td { font-size: 13px !important; padding: 10px !important; white-space: nowrap !important; }

  /* ── SEARCH BAR ── */
  .search-bar { margin-bottom: 10px !important; }
  .search-input {
    font-size: 16px !important; /* iOS: prevents auto-zoom on focus */
    height: 42px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .search-filter, select.search-filter {
    font-size: 16px !important; /* iOS zoom fix */
    width: 100% !important;
    max-width: 100% !important;
    height: 42px !important;
    box-sizing: border-box !important;
  }

  /* ── REPORT TABS: horizontal scroll row ── */
  .report-tabs {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    gap: 6px !important;
    padding-bottom: 6px !important;
    /* hide scrollbar visually */
    scrollbar-width: none !important;
  }
  .report-tabs::-webkit-scrollbar { display: none; }
  .report-tab { white-space: nowrap !important; flex-shrink: 0 !important; }
  .report-stats-grid { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  .report-chart { padding: 14px !important; }

  /* ── GRIDS ── */
  .grid-2, .grid-3, .analytics-grid { grid-template-columns: 1fr !important; }
  .grid-4 { grid-template-columns: 1fr 1fr !important; }
  .form-row { grid-template-columns: 1fr !important; }
  .wf-grid, .posts-grid, .users-grid { grid-template-columns: 1fr !important; }

  /* ── AI AGENT CHAT: give chat-messages an explicit max-height so the input bar
     is always visible above the bottom nav — no flex chain magic needed ── */
  .chat-wrap {
    display: flex !important;
    flex-direction: column !important;
  }
  .chat-messages {
    /* 72px topbar + 62px bottom nav + 94px input bar + 80px page header = 308px */
    max-height: calc(100vh - 308px - env(safe-area-inset-bottom)) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  .chat-input-bar {
    flex-shrink: 0 !important;
    padding: 10px !important;
    gap: 6px !important;
    background: var(--white) !important;
    border-top: 1px solid var(--border) !important;
  }
  /* iOS zoom fix + taller input bar (+8mm) */
  .chat-input { font-size: 16px !important; padding: 25px 14px !important; }
  .chat-msg { max-width: 85% !important; }

  /* ── MODALS ── */
  .modal {
    max-width: calc(100vw - 24px) !important;
    width: calc(100vw - 24px) !important;
    padding: 18px 14px !important;
    max-height: calc(100dvh - 130px) !important;
    overflow-y: auto !important;
  }

  /* ── TOAST: lift above bottom nav ── */
  #toast { bottom: 74px !important; right: 12px !important; left: 12px !important; max-width: none !important; }

  /* ── EMAIL CARDS ── */
  .email-card { flex-direction: column !important; align-items: flex-start !important; }
  .email-metrics { flex-direction: column !important; gap: 6px !important; }

  /* ── MISC layout fixes ── */
  .schedule-card { flex-direction: column !important; align-items: flex-start !important; }
  .alert-row { flex-wrap: wrap !important; }
  .clients-grid { grid-template-columns: 1fr !important; }
}

/* ── INSTALL PROMPT BANNER ───────────────────────────────────── */
.install-banner {
  position: fixed;
  bottom: calc(62px + 8px + env(safe-area-inset-bottom));
  left: 12px; right: 12px;
  background: var(--navy2);
  border: 1px solid rgba(247,143,30,.3);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 500;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
  transform: translateY(20px);
  opacity: 0;
  transition: transform .3s ease, opacity .3s ease;
  pointer-events: none;
}
.install-banner.show {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.install-banner-icon { font-size: 28px; flex-shrink: 0; }
.install-banner-text { flex: 1; }
.install-banner-text strong { display: block; font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.install-banner-text span  { font-size: 11px; color: var(--muted); }
.install-banner-actions { display: flex; gap: 8px; flex-shrink: 0; }
.install-btn {
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s;
}
.install-btn:hover { background: var(--orange2); }
.install-dismiss {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  cursor: pointer;
}

/* ── FOOTER ─────────────────────────────────────────────────── */
.app-footer {
  text-align: center; padding: 20px; font-size: 12px; color: var(--muted);
  border-top: 1px solid var(--border); background: var(--white); margin-top: 40px;
}
.app-footer a { color: var(--orange); font-weight: 600; }
.app-footer a:hover { text-decoration: underline; }

/* ── PHASE 5: MOBILE AUDIT FIXES ──────────────────────────────── */

/* Deploy modal + any modal with 2-col form grids → single col on mobile */
@media (max-width: 600px) {
  .mob-grid-2 {
    grid-template-columns: 1fr !important;
  }
  /* Wizard credential grid + any forced-1-col grid */
  .mob-grid-1 {
    grid-template-columns: 1fr !important;
  }
  /* Import modal: Step 2 mapping grid → single col */
  #import-map-grid {
    grid-template-columns: 1fr !important;
  }
  /* Import modal: Step 3 result KPIs → 2×2 */
  .import-result-kpis {
    grid-template-columns: 1fr 1fr !important;
  }
  /* Modal footer: stack buttons on narrow screens */
  .modal-footer {
    flex-direction: column-reverse;
  }
  .modal-footer .btn {
    width: 100%;
    justify-content: center;
  }
}

/* Settings tab strip: horizontal scroll on narrow screens */
.settings-tab-strip {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 22px;
  max-width: 460px;
}
@media (max-width: 480px) {
  .settings-tab-strip {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
  }
  .settings-tab-strip::-webkit-scrollbar { display: none; }
  .settings-tab-strip .rpt-lvl {
    flex-shrink: 0;
    white-space: nowrap;
  }
}

/* Deploy instance cards: full width on small screens */
@media (max-width: 600px) {
  #deploy-list {
    grid-template-columns: 1fr !important;
  }
}

/* Settings scoring grid: single col on small screens */
@media (max-width: 600px) {
  #stab-pane-scoring > div {
    grid-template-columns: 1fr !important;
  }
}

/* rpt-lvl buttons (used as tabs): adequate touch target */
.rpt-lvl {
  min-height: 36px;
}

/* Notif panel + chat panel: cap width on mobile so they don't overflow */
@media (max-width: 480px) {
  #notif-panel {
    width: min(360px, calc(100vw - 16px)) !important;
    right: -100vw !important;
  }
  #notif-panel.open {
    right: 0 !important;
  }
  #chat-panel {
    width: min(360px, 100vw) !important;
  }
}

/* Knowledge base cards: single col on small screens */
@media (max-width: 600px) {
  #knowledge-list {
    grid-template-columns: 1fr !important;
  }
}

/* ── MOBILE FIXES ─────────────────────────────────────────────── */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
@media (prefers-color-scheme: dark) {
  html:not(.light) {
    /* JS handles dark mode via .dark class */
  }
}

/* ── DARK MODE TOKENS ──────────────────────────────────────── */
html.dark {
  --bg:       #0f1923;
  --bg2:      #162230;
  --white:    #1a2d3e;
  --text:     #ddeeff;
  --text2:    #8ab0c8;
  --muted:    #4e6d82;
  --border:   #1e3448;
  --card:     #162230;
  --fg:       #ddeeff;
  --input-bg: #1a2d3e;
  --bg-alt:   #0f1923;
  --surface2: #1e3448;
  --shadow:    0 1px 3px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  --shadow-md: 0 4px 24px rgba(0,0,0,.4);
}
html.dark button { color: var(--text); }
html.dark .topbar {
  background: var(--navy2);
  border-bottom-color: rgba(255,255,255,.08);
}
html.dark .topbar-search {
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.18);
}
html.dark .topbar-search input { color: var(--text); background: transparent !important; }
html.dark .topbar-brand-name { color: white; }
html.dark #topbar-page { color: rgba(255,255,255,.7); }
html.dark .topbar-avatar { background: var(--navy3); }
html.dark input, html.dark select, html.dark textarea {
  background: var(--bg2);
  border-color: var(--border);
  color: var(--text);
}
html.dark .modal { background: var(--navy2); }
html.dark .modal-hdr { border-bottom-color: rgba(255,255,255,.08); }
html.dark .modal-title { color: white; }
html.dark label { color: var(--text2); }
html.dark .search-input, html.dark .search-filter {
  background: var(--bg2);
  border-color: var(--border);
  color: var(--text);
}
html.dark .tbl th { background: var(--bg2); color: var(--text2); }
html.dark .tbl td { border-color: var(--border); color: var(--text); }
html.dark .tbl tr:hover td { background: rgba(255,255,255,.03); }
html.dark .tbl-wrap { border-color: var(--border); }
html.dark .page-title { color: white; }
html.dark .page-sub { color: var(--text2); }
html.dark .card-title { color: var(--text); }
html.dark .card { background: var(--white); border-color: var(--border); }
html.dark .kpi { background: var(--white); border-color: var(--border); }
html.dark .kpi-lbl { color: var(--text2); }
html.dark .kpi-val { color: white; }
html.dark .btn-ghost { color: var(--text2); border-color: var(--border); }
html.dark .btn-ghost:hover { background: rgba(255,255,255,.05); }
html.dark .btn-secondary { background: rgba(255,255,255,.1); color: var(--text); border: 1px solid rgba(255,255,255,.15); box-shadow: 0 2px 8px rgba(0,0,0,.2); }
html.dark .btn-secondary:hover { background: rgba(255,255,255,.13); }
html.dark .audit-item { border-color: var(--border); }
html.dark .schedule-card { background: var(--white); border-color: var(--border); }
html.dark .user-card { background: var(--white); border-color: var(--border); }
html.dark .user-name { color: var(--text); }
html.dark .user-email { color: var(--text2); }
html.dark .post-card { background: var(--white); border-color: var(--border); }
html.dark .post-title { color: var(--text); }
html.dark .post-body { color: var(--text2); }
html.dark .workflow-card { background: var(--white); border-color: var(--border); }
html.dark .wf-name { color: var(--text); }
html.dark .wf-trigger { color: var(--text2); }
html.dark .chat-wrap { background: var(--white); }
html.dark .chat-messages { background: var(--bg); }
html.dark .chat-bubble { background: var(--bg2); color: var(--text); }
html.dark .chat-msg.user .chat-bubble { background: var(--navy2); color: white; }
html.dark .chat-msg.mine .chat-bubble { background: var(--orange) !important; color: #fff !important; }
/* --card handles chat-panel dark background */
html.dark .chat-header { background: var(--white); border-color: var(--border); }
html.dark .chat-tab:not(.active) { color: var(--muted); }
html.dark .chat-input-row { border-color: var(--border); }
html.dark .chat-input-bar { background: var(--white); border-top-color: var(--border); }
html.dark .chat-input { background: var(--bg2); border-color: var(--border); color: var(--text); }
html.dark .email-card { background: var(--white); border-color: var(--border); }
html.dark .email-subject { color: var(--text); }
html.dark .email-meta { color: var(--text2); }
html.dark .platform-card { background: var(--white); border-color: var(--border); }
html.dark .platform-name { color: var(--text); }
html.dark .platform-handle { color: var(--text2); }
html.dark .queue-item { background: var(--white); border-color: var(--border); }
html.dark .q-title { color: var(--text); }
html.dark .q-meta { color: var(--text2); }
html.dark .client-card { background: var(--white); border-color: var(--border); }
html.dark .client-name { color: var(--text); }
/* html.dark .main handled in canvas section above */

html.dark .bar { background: var(--orange) !important; }
html.dark .avatar-menu { background: var(--navy2); border-color: var(--border); }
html.dark .avatar-menu-header { border-color: var(--border); }
html.dark .avatar-menu-header .am-name { color: var(--text); }
html.dark .avatar-menu-header .am-role { color: var(--text2); }
html.dark .avatar-menu-item { color: var(--text2); }
html.dark .avatar-menu-item:hover { background: rgba(255,255,255,.06); color: var(--text); }
html.dark .avatar-menu-divider { background: var(--border); }
html.dark .topbar-search { background: var(--bg2); }

/* ── FONT SIZE SCALE +1 ───────────────────────────────────────── */
.nav-item          { font-size: 14px !important; }
.nav-badge         { font-size: 12px !important; }
.page-title        { font-size: 26px !important; }
.page-sub          { font-size: 15px !important; }
.card-title        { font-size: 16px !important; }
.card-title-lg     { font-size: 20px !important; }
.kpi-val           { font-size: 42px !important; }
.kpi-lbl           { font-size: 13px !important; }
.kpi-delta         { font-size: 13px !important; }
.tbl th            { font-size: 13px !important; }
.tbl td            { font-size: 15px !important; }
.btn               { font-size: 15px !important; }
.btn-sm            { font-size: 14px !important; }
.btn-xs            { font-size: 13px !important; }
.badge             { font-size: 13px !important; }
.lead-name         { font-size: 15px !important; }
.lead-co           { font-size: 14px !important; }
.lead-val          { font-size: 15px !important; }
.lead-owner        { font-size: 13px !important; }
.client-name       { font-size: 17px !important; }
.client-industry   { font-size: 14px !important; }
.cs-val            { font-size: 17px !important; }
.cs-lbl            { font-size: 12px !important; }
.platform-name     { font-size: 16px !important; }
.platform-handle   { font-size: 13px !important; }
.pm-val            { font-size: 26px !important; }
.pm-lbl            { font-size: 13px !important; }
.pm-delta          { font-size: 13px !important; }
.post-title        { font-size: 16px !important; }
.post-body         { font-size: 14px !important; }
.q-title           { font-size: 16px !important; }
.q-meta            { font-size: 13px !important; }
.email-subject     { font-size: 16px !important; }
.email-meta        { font-size: 14px !important; }
.em-val            { font-size: 18px !important; }
.em-lbl            { font-size: 13px !important; }
.wf-name           { font-size: 17px !important; }
.wf-trigger        { font-size: 14px !important; }
.stat-val          { font-size: 16px !important; }
.stat-lbl          { font-size: 13px !important; }
.schedule-name     { font-size: 16px !important; }
.schedule-meta     { font-size: 14px !important; }
.user-name         { font-size: 17px !important; }
.user-email        { font-size: 13px !important; }
.user-role         { font-size: 13px !important; }
.alert-type        { font-size: 15px !important; }
.alert-detail      { font-size: 14px !important; }
.alert-time        { font-size: 13px !important; }
.modal-title       { font-size: 21px !important; }
label              { font-size: 14px !important; }
input, select, textarea { font-size: 15px !important; }
.search-input,
.search-filter     { font-size: 14px !important; }
.cal-day-num       { font-size: 16px !important; }
.cal-hdr           { font-size: 13px !important; }
.cal-event         { font-size: 13px !important; }
.pipeline-hdr      { font-size: 12px !important; }
.chat-bubble       { font-size: 15px !important; }
.chat-input        { font-size: 15px !important; }
.su-name           { font-size: 16px !important; }
.su-role           { font-size: 13px !important; }
#topbar-page       { font-size: 16px !important; }
.topbar-brand-name { font-size: 19px !important; }
.audit-action      { font-size: 14px !important; }
.audit-detail      { font-size: 14px !important; }
.audit-time        { font-size: 13px !important; }

/* ── DARK MODE: COMPREHENSIVE TEXT FIXES ─────────────────────── */
/* All elements that use color: var(--navy) need light override  */
html.dark .page-title,
html.dark .card-title,
html.dark .card-title-lg,
html.dark .modal-title,
html.dark .kpi-val,
html.dark .lead-name,
html.dark .client-name,
html.dark .client-industry,
html.dark .cs-val,
html.dark .cs-lbl,
html.dark .platform-name,
html.dark .pm-val,
html.dark .post-title,
html.dark .q-title,
html.dark .email-subject,
html.dark .em-val,
html.dark .wf-name,
html.dark .stat-val,
html.dark .schedule-name,
html.dark .schedule-meta,
html.dark .user-name,
html.dark .alert-type,
html.dark .alert-detail,
html.dark .cal-day-num,
html.dark .topbar-brand-name,
html.dark .section-title,
html.dark .form-group label,
html.dark .tbl th,
html.dark .tbl td,
html.dark .nav-label,
html.dark .sidebar-section-label,
html.dark strong,
html.dark b { color: var(--text) !important; }

/* Muted/secondary text */
html.dark .page-sub,
html.dark .kpi-lbl,
html.dark .lead-co,
html.dark .lead-owner,
html.dark .client-industry,
html.dark .post-body,
html.dark .q-meta,
html.dark .wf-trigger,
html.dark .email-meta,
html.dark .platform-handle,
html.dark .pm-lbl,
html.dark .pm-delta,
html.dark .cs-lbl,
html.dark .alert-time,
html.dark .user-email,
html.dark .user-role,
html.dark .schedule-meta,
html.dark .audit-detail,
html.dark .audit-time { color: var(--text2) !important; }

/* Cards and containers */
html.dark .client-card,
html.dark .lead-card,
html.dark .contact-card,
html.dark .pipeline-col,
html.dark .queue-item,
html.dark .workflow-card,
html.dark .post-card,
html.dark .email-card,
html.dark .platform-card,
html.dark .schedule-card,
html.dark .user-card,
html.dark .mfa-card,
html.dark .alert-row,
html.dark .audit-item { background: var(--white) !important; border-color: var(--border) !important; }

/* Pipeline header text */
html.dark .pipeline-hdr { color: var(--text2) !important; }

/* KPI cards */
html.dark .kpi { background: var(--white) !important; border-color: var(--border) !important; }
html.dark .kpi-lbl { color: var(--text2) !important; }

/* Table */
html.dark .tbl th { background: var(--bg2) !important; color: var(--text2) !important; }
html.dark .tbl td { color: var(--text) !important; border-color: var(--border) !important; }

/* Calendar */
html.dark .cal-day { color: var(--text); }
html.dark .cal-day-num { color: var(--text) !important; }
html.dark .cal-hdr { color: var(--text2); }
html.dark .cal-day.today .cal-day-num { color: var(--orange) !important; }

/* Modals */
html.dark .modal { background: var(--navy2) !important; }
html.dark .modal-title { color: white !important; }
html.dark .modal-hdr { border-bottom-color: rgba(255,255,255,.08) !important; }
html.dark input, html.dark select, html.dark textarea {
  background: var(--bg2) !important; border-color: var(--border) !important; color: var(--text) !important;
}
html.dark input::placeholder, html.dark textarea::placeholder { color: var(--muted) !important; }

/* Sidebar stays dark — no override needed */

/* Badges — keep their colors */
html.dark .badge { opacity: 1; }

/* Inline bold text in cards */
html.dark .row-actions .btn-xs { color: var(--text2); }
html.dark .btn-xs.edit { background:rgba(96,165,250,.2); color:#60a5fa !important; border-color:rgba(96,165,250,.3) !important; }
html.dark .btn-xs.edit:hover { background:rgba(96,165,250,.38) !important; color:#fff !important; }
html.dark .btn-xs.del { background:rgba(248,113,113,.2); color:#f87171 !important; border-color:rgba(248,113,113,.3) !important; }
html.dark .btn-xs.del:hover { background:rgba(248,113,113,.38) !important; color:#fff !important; }
html.dark .btn-xs.deal { background:rgba(96,165,250,.18) !important; color:#93c5fd !important; border-color:rgba(96,165,250,.3) !important; }
html.dark .btn-xs.deal:hover { background:rgba(96,165,250,.32) !important; color:#fff !important; }
html.dark .btn-xs.match { background:rgba(52,211,153,.18) !important; color:#6ee7b7 !important; border-color:rgba(52,211,153,.3) !important; }
html.dark .btn-xs.match:hover { background:rgba(52,211,153,.32) !important; color:#fff !important; }
html.dark .btn-primary { background:rgba(247,143,30,.22); color:#fbbf24; border:1px solid rgba(247,143,30,.4); box-shadow:0 2px 8px rgba(247,143,30,.2); }
html.dark .btn-primary:hover { background:rgba(247,143,30,.35); box-shadow:0 4px 14px rgba(247,143,30,.3); }
html.dark .btn-danger { background:rgba(224,52,52,.2); color:#fca5a5; border:1px solid rgba(224,52,52,.38); box-shadow:0 2px 8px rgba(224,52,52,.18); }
html.dark .btn-danger:hover { background:rgba(224,52,52,.32); box-shadow:0 4px 14px rgba(224,52,52,.28); }
html.dark .btn-ghost { background:rgba(255,255,255,.07); color:var(--text); border-color:rgba(255,255,255,.15); }
html.dark .btn-ghost:hover { background:rgba(255,255,255,.13); }
html.dark .v-filter-btn.active { background:rgba(247,143,30,.22) !important; border-color:rgba(247,143,30,.45) !important; color:#fbbf24 !important; box-shadow:0 2px 8px rgba(247,143,30,.2) !important; }
html.dark .page-title { color:var(--pg-accent,var(--text)) !important; transition:color .3s; }

/* Comprehensive catch-all for inline color:var(--navy) — both in static HTML and JS-generated */
html.dark [style*="color: var(--navy)"],
html.dark [style*="color:var(--navy)"] { color: var(--text) !important; }
html.dark [style*="color: var(--text)"],
html.dark [style*="color:var(--text)"] { color: var(--text) !important; }
html.dark [style*="color: var(--text2)"],
html.dark [style*="color:var(--text2)"] { color: var(--text2) !important; }
html.dark [style*="color: var(--muted)"],
html.dark [style*="color:var(--muted)"] { color: var(--text2) !important; }
/* Catch hardcoded navy hex */
html.dark [style*="color:#132d44"],
html.dark [style*="color: #132d44"],
html.dark [style*="color:#1b3a4b"],
html.dark [style*="color: #1b3a4b"] { color: var(--text) !important; }
/* Catch hardcoded dark text hex */
html.dark [style*="color:#0e1c26"],
html.dark [style*="color: #0e1c26"],
html.dark [style*="color:#2d4a5c"],
html.dark [style*="color: #2d4a5c"] { color: var(--text2) !important; }
/* Generic: any div/span/p with no explicit color in dark mode gets text color */
html.dark .card > div:not([class]),
html.dark .card p { color: var(--text); }
/* ── CREATIVE MICRO-TYPOGRAPHY & LABEL SYSTEM ──────────────────── */
/* Section labels get an accent dot */
.kpi-lbl::before, .pipeline-hdr::before, .bar-lbl::before {
  content: '';
  display: inline-block;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--pg-accent, var(--orange));
  margin-inline-end: 5px;
  vertical-align: middle;
  margin-bottom: 1px;
  opacity: .7;
}
/* Timestamps and meta text get frosted pill treatment */
.activity-meta, .tl-time, .reminder-meta, .st-out-meta, .hub-file-meta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 10px !important;
  color: var(--muted);
  white-space: nowrap;
}
.fu-hist-row { display: flex !important; gap: 8px; padding: 5px 8px; border-radius: 6px; font-size: 12px; background: var(--bg2); margin-bottom: 3px; border: none !important; }
/* Lead meta text — subtle italic treatment */
.lead-co { font-style: italic; font-size: 11px; opacity: .85; }
.lead-owner { font-size: 11px; }
.lead-owner::before { content: '◉ '; font-size: 8px; opacity: .5; }
/* KPI delta text */
.kpi-delta { font-size: 10px; }
/* Section label caps */
[style*="text-transform:uppercase"][style*="font-size:10px"],
[style*="text-transform: uppercase"][style*="font-size:10px"],
[style*="text-transform:uppercase"][style*="font-size:11px"],
[style*="text-transform: uppercase"][style*="font-size:11px"] {
  letter-spacing: .07em;
}

/* ── ST-FMT-BTN DARK MODE ───────────────────────────────────── */
html.dark .st-fmt-btn { background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.12); color: var(--text2); }
html.dark .st-fmt-btn:hover { border-color: rgba(247,143,30,.5); color: var(--orange); }
html.dark .st-fmt-btn.active { background: rgba(247,143,30,.2); border-color: rgba(247,143,30,.5); color: #fbbf24; box-shadow: 0 2px 8px rgba(247,143,30,.2); }

/* ── V-FILTER-BTN BASE (light mode) ─────────────────────────── */
.v-filter-btn { transition: all .15s; }
.v-filter-btn:not(.active):hover { border-color: rgba(247,143,30,.4); color: var(--orange); }

/* ── NAV-ITEM DARK MODE REFINEMENT ──────────────────────────── */
html.dark .nav-item.active { background: rgba(247,143,30,.18); color: #fbbf24; border-left-color: #fbbf24; }

/* ── PIPELINE KANBAN CARD REFINEMENT ────────────────────────── */
.lead-card { transition: transform .12s, box-shadow .12s; }
.lead-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.12); }

/* ── WEBSITE LAYOUT EDITOR ───────────────────────────────────── */
.layout-row { display:flex;align-items:center;gap:12px;padding:12px 16px;background:var(--white);border:1px solid var(--border);border-radius:8px;margin-bottom:6px;cursor:default;transition:background .15s;user-select:none; }
.layout-row.dragging { opacity:.4;background:var(--bg2); }
.layout-row.drag-over { border-color:var(--orange);background:rgba(247,143,30,.06); }
.layout-row--hidden { opacity:.45; }
.layout-row--hidden .layout-label { text-decoration:line-through; }
.layout-handle { cursor:grab;font-size:18px;color:var(--muted);padding:0 4px;line-height:1; }
.layout-handle:active { cursor:grabbing; }
.layout-label { flex:1;font-size:14px;font-weight:500;color:var(--text); }
.layout-toggle { background:none;border:none;cursor:pointer;font-size:16px;padding:4px;color:var(--muted);transition:color .15s; }
.layout-toggle:hover { color:var(--orange); }
.layout-locked { display:flex;align-items:center;gap:12px;padding:12px 16px;background:var(--bg);border:1px solid var(--border);border-radius:8px;margin-bottom:6px;opacity:.5; }
.layout-locked-icon { font-size:14px;color:var(--muted);padding:0 4px; }
.layout-locked-label { flex:1;font-size:14px;font-weight:500;color:var(--muted); }
.layout-locked-badge { font-size:11px;color:var(--muted);background:var(--bg2);padding:2px 8px;border-radius:10px; }
html.dark .layout-row { background:var(--white);border-color:var(--border); }
html.dark .layout-row.drag-over { background:rgba(247,143,30,.08); }
html.dark .layout-locked { background:var(--bg2); }
/* Hub tabs and info labels — use --muted which is too dark in dark mode */
html.dark .hub-tab:not(.active) { color: var(--text2) !important; }
html.dark .hub-tab.active { color:var(--orange) !important;background:rgba(247,143,30,.1);border-bottom-color:var(--orange); }
html.dark .hub-tab:hover { color: var(--text) !important; }
html.dark .hub-info-lbl { color: var(--text2) !important; }
html.dark .hub-info-val { color: var(--text) !important; }
/* Bar chart labels */
html.dark .bar-lbl { color: var(--text2) !important; }
/* DL items */
html.dark .dl-item { color: var(--text2) !important; }
/* Role tags — fix dark mode contrast */
html.dark .role-tag.admin { background: rgba(99,179,237,.12) !important; color: #63b3ed !important; }
html.dark .role-tag.superadmin { background: rgba(167,139,250,.12) !important; color: #a78bfa !important; }
html.dark .role-tag.sales { background: rgba(247,143,30,.15) !important; color: var(--orange) !important; }
html.dark .role-tag.support { background: rgba(52,211,153,.12) !important; color: #34d399 !important; }
/* Checklist items and inline-styled headings */
html.dark [style*="font-weight:600"][style*="color"],
html.dark [style*="font-weight: 600"][style*="color"] { }  /* handled by specific rules above */
/* Hub tabs */
.hub-tab { padding:10px 18px;font-size:13px;font-weight:600;color:var(--muted);background:none;border:none;border-bottom:3px solid transparent;cursor:pointer;transition:color .15s,border-color .15s;margin-bottom:-2px; }
.hub-tab:hover { color:var(--text); }
.hub-tab.active { color:var(--orange);border-bottom-color:var(--orange);background:rgba(247,143,30,.08);border-radius:8px 8px 0 0;font-weight:700; }
/* Hub info rows */
.hub-info-row { display:flex;justify-content:space-between;align-items:flex-start;padding:7px 0;border-bottom:1px solid var(--border);font-size:13px; }
.hub-info-row:last-child { border-bottom:none; }
.hub-info-lbl { color:var(--muted);font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.5px;flex-shrink:0;width:110px; }
.hub-info-val { color:var(--text);text-align:right;word-break:break-word; }
/* Hub intake sections */
.hub-section { margin-bottom:16px; }
.hub-section-title { font-size:12px;font-weight:700;color:var(--orange);text-transform:uppercase;letter-spacing:.8px;margin-bottom:10px;padding:6px 12px;background:rgba(247,143,30,.07);border-radius:6px; }
/* Strategy cards */
.strategy-card { background:var(--white);border:1px solid var(--border);border-radius:12px;padding:20px;margin-bottom:16px; }
.strategy-card-title { font-size:14px;font-weight:700;color:var(--text);margin-bottom:12px;display:flex;align-items:center;gap:8px; }
.strategy-body { font-size:13px;line-height:1.8;color:var(--text2);white-space:pre-wrap; }
html.dark .strategy-card { background:var(--white);border-color:var(--border); }
html.dark .strategy-body { color:var(--text2) !important; }
/* File item */
.hub-file-item { display:flex;align-items:center;gap:12px;padding:12px 16px;border-radius:10px;border:1px solid var(--border);background:var(--white);margin-bottom:8px; }
.hub-file-icon { width:36px;height:36px;border-radius:8px;display:flex;align-items:center;justify-content:center;font-size:11px;font-weight:700;flex-shrink:0; }
.hub-file-name { font-size:13px;font-weight:600;color:var(--text);flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; }
.hub-file-meta { font-size:11px;color:var(--muted); }
html.dark .hub-file-item { background:var(--white);border-color:var(--border); }
html.dark .hub-file-name { color:var(--text) !important; }
/* Hub grid responsive */
@media(max-width:900px) { .hub-grid-3 { grid-template-columns:1fr !important; } }
/* Star button */
.star-btn { background:none;border:none;cursor:pointer;padding:4px 6px;font-size:15px;line-height:1;border-radius:6px;transition:transform .15s,color .15s; }
.star-btn:hover { transform:scale(1.2); }
.star-btn.starred { color:var(--orange); }
.star-btn.unstarred { color:var(--border); }
html.dark .star-btn.unstarred { color:var(--border); }
/* Trash page */
.trash-item { display:flex;align-items:center;gap:14px;padding:12px 16px;border-radius:10px;border:1px solid var(--border);background:var(--white);margin-bottom:10px; }
.trash-icon { width:36px;height:36px;border-radius:8px;background:rgba(224,52,52,.1);display:flex;align-items:center;justify-content:center;flex-shrink:0; }
.trash-info { flex:1;min-width:0; }
.trash-name { font-size:14px;font-weight:600;color:var(--text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis; }
.trash-meta { font-size:11px;color:var(--muted);margin-top:2px; }
.trash-expires { font-size:11px;font-weight:600;color:var(--orange); }
html.dark .trash-item { background:var(--white);border-color:var(--border); }
html.dark .trash-name { color:var(--text) !important; }
/* Timeline / history */
.timeline { display:flex;flex-direction:column;gap:0; }
.tl-item { display:flex;gap:14px;padding:12px 0;border-bottom:1px solid var(--border);position:relative; }
.tl-item:last-child { border-bottom:none; }
.tl-dot { width:32px;height:32px;border-radius:50%;display:flex;align-items:center;justify-content:center;flex-shrink:0;font-size:13px; }
.tl-body { flex:1;min-width:0; }
.tl-title { font-size:13px;font-weight:600;color:var(--text); }
.tl-sub { font-size:11px;color:var(--muted);margin-top:2px; }
.tl-time { font-size:10px;color:var(--muted);white-space:nowrap;margin-top:4px; }
html.dark .tl-title { color:var(--text) !important; }
html.dark .tl-sub,html.dark .tl-time { color:var(--text2) !important; }
/* Visitor analytics */
.geo-row { display:flex;align-items:center;gap:10px;padding:6px 0;border-bottom:1px solid var(--border); }
.geo-row:last-child { border-bottom:none; }
.geo-flag { font-size:18px;width:28px;text-align:center; }
.geo-name { flex:1;font-size:13px;color:var(--text); }
.geo-bar { width:80px;height:6px;border-radius:3px;background:var(--bg2);overflow:hidden; }
.geo-bar-fill { height:100%;border-radius:3px;background:var(--orange); }
.geo-count { font-size:12px;font-weight:700;color:var(--text);min-width:32px;text-align:right; }
html.dark .geo-name,html.dark .geo-count { color:var(--text) !important; }

/* Cards with inline background styles (VPS, onboarding, etc) */
html.dark .card { background: var(--white) !important; border-color: var(--border) !important; }
html.dark .card-title { color: var(--text) !important; }

/* PWA Install Banner */
#pwa-banner {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #132d44;
  border-top: 2px solid #F78F1E;
  padding: 16px 20px;
  z-index: 9999;
  align-items: center;
  gap: 14px;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
}
#pwa-banner .pwa-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: #F78F1E;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: 20px;
  flex-shrink: 0;
}
#pwa-banner .pwa-text {
  flex: 1;
}
#pwa-banner .pwa-text strong {
  display: block;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}
#pwa-banner .pwa-text span {
  color: #8a9db0;
  font-size: 12px;
}
#pwa-banner .pwa-install-btn {
  background: #F78F1E;
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}
#pwa-banner .pwa-close {
  background: none;
  border: none;
  color: #4a6478;
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

/* iOS install instructions */
#ios-instructions {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #132d44;
  border-top: 2px solid #F78F1E;
  padding: 20px;
  z-index: 9999;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
}
#ios-instructions h3 {
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 14px;
  text-align: center;
}
.ios-step {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #c8d4e0;
}
.ios-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #F78F1E;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
#ios-instructions .close-ios {
  width: 100%;
  margin-top: 14px;
  background: rgba(255,255,255,0.08);
  border: none;
  color: #8a9db0;
  padding: 10px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}


/* Mobile touch fix — do NOT set touch-action on * (breaks scroll containers) */
button, a, label, [role="button"] {
  -webkit-tap-highlight-color: rgba(247,143,30,0.2);
  touch-action: manipulation;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  height: -webkit-fill-available;
}
body {
  min-height: 100vh;
  min-height: -webkit-fill-available;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
}
button, a, input, select, textarea {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
img {
  -webkit-user-drag: none;
  user-select: none;
}
@media (max-width: 768px) {
  /* Removed backface-visibility:hidden from * — causes full-page blur on mobile */
}


/* ===== CRM ANIMATED BACKGROUND ===== */
#crm-canvas {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  width: 100%;
  height: 100%;
}
#crm-grid {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(247,143,30,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(247,143,30,0.035) 1px, transparent 1px);
  background-size: 60px 60px;
  opacity: 1;
  transition: opacity 0.4s;
}
html.light #crm-grid {
  background-image:
    linear-gradient(rgba(247,143,30,0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(247,143,30,0.07) 1px, transparent 1px);
}
/* Main background — solid, canvas paints above it so opacity tricks don't help */
html.dark .main {
  background: #0f1923 !important;
}
html.light .main {
  background: #f0f3f7 !important;
}
/* Keep sidebar and topbar opaque with their own backgrounds */
/* z-index: 250 keeps dropdown above sidebar-overlay (199) but below mobile sidebar (300) */
.topbar   { position: relative; z-index: 250; }
@media (min-width: 1025px) {
  .sidebar { position: relative; z-index: 200; }
}
.modal { position: relative; z-index: 10; }
/* Cards — solid backgrounds, no backdrop-filter (backdrop-filter composites with canvas through stacking context boundary) */
html.dark .card,
html.dark .kpi-card,
html.dark .tbl-wrap,
html.dark .pipeline-col,
html.dark .page-hdr {
  background: #162230 !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
html.light .card,
html.light .kpi-card,
html.light .tbl-wrap,
html.light .pipeline-col,
html.light .page-hdr {
  background: #ffffff !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
/* Body itself stays transparent so canvas fills it */
body { background: transparent !important; }
html { background: var(--bg); }
html.dark { background: #0f1923; }
html.light { background: #f0f3f7; }


/* ===== MOBILE PERFORMANCE — no canvas blur on small screens ===== */
@media (max-width: 768px) {
  /* No animated background on mobile — plain dark/light solid */
  #crm-canvas, #crm-grid { display: none !important; }
  body { background: var(--bg) !important; }
  html.dark body { background: #0f1923 !important; }
  html.light body { background: #f0f3f7 !important; }
  /* Remove backdrop-filter — single biggest cause of GPU blur on Android */
  * {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
  /* Make cards solid so they look good without the glass effect */
  html.dark .card,
  html.dark .kpi-card,
  html.dark .tbl-wrap,
  html.dark .pipeline-col,
  html.dark .page-hdr {
    background: rgba(15, 25, 35, 0.98) !important;
  }
  html.light .card,
  html.light .kpi-card,
  html.light .tbl-wrap,
  html.light .pipeline-col {
    background: rgba(255,255,255,0.99) !important;
  }
  .main {
    background: var(--bg) !important;
  }
}

/* Tasks type column fix */
#tasks-tbody .badge.badge-navy {
  display: inline-block !important;
  visibility: visible !important;
  opacity: 1 !important;
  font-size: 11px !important;
  padding: 3px 8px !important;
  border-radius: 8px !important;
  background: rgba(247,143,30,0.15) !important;
  color: #c47010 !important;
  font-weight: 600 !important;
  white-space: nowrap !important;
}
/* All badge colors — dark mode (light text on translucent bg) */
html.dark .badge-navy   { background: rgba(99,179,237,.15) !important; color: #63b3ed !important; }
html.dark .badge-green  { background: rgba(52,211,153,.15) !important; color: #34d399 !important; }
html.dark .badge-orange { background: rgba(247,143,30,.18) !important; color: #f78f1e !important; }
html.dark .badge-red    { background: rgba(248,113,113,.15) !important; color: #f87171 !important; }
html.dark .badge-yellow { background: rgba(251,191,36,.15) !important; color: #fbbf24 !important; }
html.dark .badge-blue   { background: rgba(96,165,250,.15) !important; color: #60a5fa !important; }
html.dark .badge-purple { background: rgba(167,139,250,.15) !important; color: #a78bfa !important; }
html.dark #tasks-tbody .badge.badge-navy {
  background: rgba(247,143,30,0.2) !important;
  color: #F78F1E !important;
}

/* ── EMAIL CLIENT ───────────────────────────────────────────────────── */
.email-layout{display:grid;grid-template-columns:200px 320px 1fr;height:calc(100dvh - 130px);overflow:hidden;border:1px solid var(--border);border-radius:var(--radius-lg);background:var(--white);box-shadow:0 4px 24px rgba(0,0,0,.06)}
.email-folders-panel{border-inline-end:1px solid var(--border);overflow-y:auto;display:flex;flex-direction:column;background:var(--bg)}
.email-folders-panel .ef-compose{margin:12px;padding:8px 14px;background:var(--navy);color:#fff;border:none;border-radius:8px;font-size:13px;font-weight:600;cursor:pointer;text-align:left;transition:.15s}
.email-folders-panel .ef-compose:hover{background:var(--orange)}
.ef-folder{padding:9px 14px;font-size:13px;cursor:pointer;display:flex;align-items:center;gap:8px;border-radius:6px;margin:1px 6px;color:var(--text2);transition:background .12s}
.ef-folder:hover{background:rgba(19,45,68,.07);color:var(--text)}
.ef-folder.active{background:rgba(247,143,30,.12);color:var(--orange);font-weight:600}
.ef-folder svg{width:14px;height:14px;flex-shrink:0;opacity:.6}
.ef-folder.active svg{opacity:1;stroke:var(--orange)}
.ef-badge{margin-inline-start:auto;background:var(--orange);color:#fff;font-size:10px;font-weight:700;padding:1px 7px;border-radius:10px;min-width:18px;text-align:center}
.email-list-panel{border-inline-end:1px solid var(--border);display:flex;flex-direction:column;overflow:hidden}
.el-search{padding:10px 12px;border-bottom:1px solid var(--border);display:flex;gap:6px;align-items:center}
.el-search input{flex:1;background:var(--bg);border:1px solid var(--border);border-radius:8px;padding:7px 10px;font-size:13px;color:var(--text)}
.el-search input:focus{outline:none;border-color:var(--orange)}
.el-search .btn-icon{padding:7px 9px;border-radius:8px;border:1px solid var(--border);background:var(--bg);color:var(--muted);cursor:pointer;font-size:13px;white-space:nowrap;font-weight:600;transition:.12s}
.el-search .btn-icon:hover{border-color:var(--navy);color:var(--navy)}
.email-message-list{flex:1;overflow-y:auto}
.em-row{padding:12px 14px;border-bottom:1px solid var(--border);cursor:pointer;transition:background .1s;display:flex;gap:10px;align-items:flex-start}
.em-row:hover{background:rgba(19,45,68,.04)}
.em-row.active{background:rgba(247,143,30,.08);border-inline-start:3px solid var(--orange)}
.em-row.unread .em-subject{font-weight:700;color:var(--text)}
.em-row.unread .em-from{font-weight:700}
.em-dot{width:8px;height:8px;border-radius:50%;background:var(--orange);flex-shrink:0;margin-top:5px}
.em-dot.read{background:transparent}
.em-body{flex:1;min-width:0}
.em-from{font-size:13px;font-weight:500;color:var(--text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.em-subject{font-size:12px;color:var(--text2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin:2px 0}
.em-snippet{font-size:11px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.em-meta{display:flex;flex-direction:column;align-items:flex-end;gap:4px;flex-shrink:0}
.em-time{font-size:11px;color:var(--muted)}
.em-star{font-size:14px;cursor:pointer;opacity:.4;transition:opacity .15s;background:none;border:none;padding:0;line-height:1}
.em-star:hover,.em-star.on{opacity:1;color:var(--orange)}
.el-empty{padding:40px;text-align:center;color:var(--muted);font-size:13px}
.el-pagination{padding:10px 12px;border-top:1px solid var(--border);display:flex;justify-content:center;gap:6px}
.el-page-btn{padding:5px 11px;border:1px solid var(--border);border-radius:6px;background:var(--bg);color:var(--text2);cursor:pointer;font-size:12px;font-weight:600}
.el-page-btn.active{background:var(--navy);color:#fff;border-color:var(--navy)}
.email-preview-panel{display:flex;flex-direction:column;overflow:hidden}
.ep-empty{flex:1;display:flex;align-items:center;justify-content:center;color:var(--muted);font-size:14px}
.ep-header{padding:16px 20px 12px;border-bottom:1px solid var(--border)}
.ep-subject{font-size:17px;font-weight:700;color:var(--text);margin-bottom:10px;line-height:1.3}
.ep-meta{font-size:12px;color:var(--muted);display:flex;flex-direction:column;gap:3px}
.ep-meta span{display:flex;gap:6px}
.ep-meta b{color:var(--text2);font-weight:600;min-width:30px}
.ep-actions{padding:10px 20px;border-bottom:1px solid var(--border);display:flex;gap:8px;flex-wrap:wrap}
.ep-body{flex:1;overflow-y:auto;padding:16px 20px}
.ep-body-text{font-size:13px;line-height:1.7;color:var(--text);white-space:pre-wrap;word-break:break-word}
.ep-body-frame{width:100%;border:none;min-height:300px;flex:1}
.compose-overlay{position:fixed;bottom:0;right:24px;width:540px;max-width:calc(100vw - 32px);background:var(--white);border-radius:12px 12px 0 0;box-shadow:0 -4px 40px rgba(0,0,0,.18);border:1px solid var(--border);border-bottom:none;z-index:9000;display:none;flex-direction:column}
.compose-overlay.open{display:flex}
.compose-head{padding:12px 16px;background:var(--navy);color:#fff;border-radius:12px 12px 0 0;display:flex;align-items:center;justify-content:space-between;cursor:pointer}
.compose-head span{font-size:14px;font-weight:600}
.compose-head button{background:none;border:none;color:rgba(255,255,255,.7);font-size:18px;cursor:pointer;line-height:1;padding:0}
.compose-head button:hover{color:#fff}
.compose-body{padding:10px 14px;display:flex;flex-direction:column;gap:8px}
.compose-field{display:flex;align-items:center;gap:8px;border-bottom:1px solid var(--border);padding-bottom:6px}
.compose-field label{font-size:12px;font-weight:600;color:var(--muted);min-width:30px}
.compose-field input{flex:1;border:none;background:transparent;font-size:13px;color:var(--text);padding:4px 0}
.compose-field input:focus{outline:none}
.compose-subject-row{border-bottom:1px solid var(--border);padding-bottom:6px;display:flex;align-items:center;gap:8px}
.compose-subject-row input{flex:1;border:none;background:transparent;font-size:14px;font-weight:600;color:var(--text);padding:4px 0}
.compose-subject-row input:focus{outline:none}
#compose-body-text{width:100%;height:160px;border:none;background:transparent;font-size:13px;color:var(--text);resize:none;line-height:1.6;box-sizing:border-box}
#compose-body-text:focus{outline:none}
.compose-footer{padding:8px 14px 12px;display:flex;justify-content:space-between;align-items:center;border-top:1px solid var(--border)}
.email-header-bar{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px;flex-wrap:wrap;gap:8px}
.email-account-tag{font-size:12px;color:var(--muted);background:var(--bg);border:1px solid var(--border);border-radius:20px;padding:3px 10px}
@media(max-width:900px){
  .email-layout{grid-template-columns:1fr;height:auto}
  .email-folders-panel{display:none}
  .email-list-panel{border-inline-end:none;height:50dvh}
  .email-preview-panel{height:50dvh}
  .compose-overlay{width:100%;right:0;border-radius:0;bottom:0}
}



/* ── Chat Panel ─────────────────────────────────────────────── */
#chat-panel {
  position:fixed; right:0; bottom:0; width:360px; height:520px;
  background:var(--card); border:1px solid var(--border); border-bottom:none;
  border-radius:14px 14px 0 0; box-shadow:0 -4px 32px rgba(0,0,0,.18);
  display:flex; flex-direction:column; z-index:3000;
  transform:translateY(100%); transition:transform .25s cubic-bezier(.4,0,.2,1);
}
#chat-panel.open { transform:translateY(0); }
.chat-header {
  display:flex; align-items:center; gap:10px; padding:14px 16px;
  border-bottom:1px solid var(--border); flex-shrink:0; background:var(--white);
  border-radius:14px 14px 0 0;
}
.chat-header-title { font-size:14px; font-weight:700; color:var(--text); flex:1; }
.chat-tabs { display:flex; gap:2px; padding:8px 10px; border-bottom:1px solid var(--border); flex-shrink:0; overflow-x:auto; }
.chat-tab {
  padding:5px 12px; border-radius:20px; font-size:12px; font-weight:600;
  cursor:pointer; color:var(--muted); background:none; border:none;
  white-space:nowrap; transition:all .15s; position:relative;
}
.chat-tab.active { background:rgba(247,143,30,.18); color:var(--orange); border:1px solid rgba(247,143,30,.4); box-shadow:0 2px 8px rgba(247,143,30,.2); font-weight:700; }
html.dark .chat-tab.active { background:rgba(247,143,30,.22); color:#fbbf24; border-color:rgba(247,143,30,.45); }
.chat-tab-badge {
  position:absolute; top:-2px; right:-2px; background:#ef4444; color:#fff;
  font-size:8px; font-weight:700; min-width:14px; height:14px; border-radius:7px;
  padding:0 3px; line-height:14px; text-align:center;
}
.chat-messages {
  flex:1; overflow-y:auto; padding:12px 14px; display:flex; flex-direction:column; gap:8px;
}
.chat-msg { display:flex; gap:8px; align-items:flex-end; }
.chat-msg.mine { flex-direction:row-reverse; }
.chat-msg-av {
  width:26px; height:26px; border-radius:50%; font-size:10px; font-weight:700;
  display:flex; align-items:center; justify-content:center; flex-shrink:0; margin-bottom:2px;
}
.chat-bubble {
  max-width:220px; padding:7px 11px; border-radius:12px; font-size:13px;
  line-height:1.5; word-break:break-word;
}
.chat-msg.mine .chat-bubble { background:var(--orange); color:#fff; border-radius:12px 12px 2px 12px; }
.chat-msg:not(.mine) .chat-bubble { background:var(--bg); color:var(--text); border-radius:12px 12px 12px 2px; }
.chat-meta { font-size:10px; color:var(--muted); margin-top:2px; text-align:right; }
.chat-input-row {
  display:flex; gap:8px; padding:10px 12px; border-top:1px solid var(--border); flex-shrink:0;
}
.chat-input {
  flex:1; padding:8px 12px; border-radius:20px; border:1px solid var(--border);
  background:var(--bg); color:var(--text); font-size:13px; outline:none;
  font-family:var(--font-body); resize:none;
}
.chat-input:focus { border-color:var(--orange); }
.chat-send-btn {
  width:34px; height:34px; border-radius:50%; background:var(--orange); border:none;
  color:#fff; cursor:pointer; display:flex; align-items:center; justify-content:center;
  flex-shrink:0; transition:background .15s;
}
.chat-send-btn:hover { background:#d4720a; }
.chat-day-sep { text-align:center; font-size:10px; color:var(--muted); margin:4px 0; }
@media(max-width:600px){
  #chat-panel { width:100%; border-radius:14px 14px 0 0; height:70vh; }
}
/* ── INBOX / WA STYLES ─────────────────────────────────────────── */
.wa-thread-list { display:flex;flex-direction:column;gap:2px; }
.wa-convo { display:flex;align-items:center;gap:12px;padding:11px 14px;border-radius:10px;cursor:pointer;transition:background .15s;border:1px solid transparent }
.wa-convo:hover { background:var(--bg-alt,rgba(0,0,0,.04)) }
.wa-convo.active { background:rgba(37,211,102,.08);border-color:rgba(37,211,102,.2) }
.wa-avatar { width:40px;height:40px;border-radius:50%;background:linear-gradient(135deg,#25d366,#128c7e);display:flex;align-items:center;justify-content:center;color:#fff;font-weight:700;font-size:15px;flex-shrink:0 }
.wa-convo-name { font-weight:600;font-size:13px;color:var(--text) }
.wa-convo-preview { font-size:11px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:220px }
.wa-unread-dot { min-width:18px;height:18px;background:#25d366;color:#fff;border-radius:10px;font-size:10px;font-weight:700;display:flex;align-items:center;justify-content:center;padding:0 5px;flex-shrink:0 }
.wa-msg { display:flex;margin:6px 0 }
.wa-msg.out { justify-content:flex-end }
.wa-bubble { max-width:72%;padding:9px 13px;border-radius:14px;font-size:13px;line-height:1.5;word-break:break-word }
.wa-bubble.in  { background:var(--bg);border:1px solid var(--border);border-bottom-left-radius:4px }
.wa-bubble.out { background:#dcf8c6;color:#111;border-bottom-right-radius:4px }
html.dark .wa-bubble.out { background:#1a472a;color:#d1fae5 }
.wa-time { font-size:10px;color:var(--muted);margin-top:3px }
.wa-inbox-layout { display:grid;grid-template-columns:300px 1fr;gap:0;height:calc(100vh - 180px);border:1px solid var(--border);border-radius:12px;overflow:hidden }
.wa-left { border-inline-end:1px solid var(--border);overflow-y:auto;padding:10px }
.wa-right { display:flex;flex-direction:column }
.wa-thread-header { padding:14px 16px;border-bottom:1px solid var(--border);display:flex;align-items:center;gap:12px }
.wa-thread-messages { flex:1;overflow-y:auto;padding:14px 16px;display:flex;flex-direction:column;gap:0 }
.wa-reply-bar { padding:10px 14px;border-top:1px solid var(--border);display:flex;gap:8px;align-items:flex-end }
.wa-reply-bar textarea { flex:1;padding:9px 12px;border-radius:10px;border:1px solid var(--border);background:var(--input-bg);color:var(--text);font-family:var(--font);font-size:13px;resize:none;min-height:40px;max-height:100px }
@media(max-width:700px){.wa-inbox-layout{grid-template-columns:1fr}  .wa-right{display:none}.wa-right.active{display:flex}}
/* ── SEQUENCES STYLES ──────────────────────────────────────────── */
.seq-card { background:var(--bg);border:1px solid var(--border);border-radius:12px;padding:16px 18px;margin-bottom:10px;display:flex;align-items:center;justify-content:space-between;gap:12px }
.seq-status { font-size:10px;font-weight:700;padding:3px 8px;border-radius:6px;text-transform:uppercase }
.seq-status.active  { background:rgba(15,169,104,.12);color:#0fa968 }
.seq-status.draft   { background:rgba(148,163,184,.12);color:#94a3b8 }
.seq-status.paused  { background:rgba(245,158,11,.12);color:#f59e0b }
.seq-step { background:var(--bg-alt,rgba(0,0,0,.03));border:1px solid var(--border);border-radius:10px;padding:12px 14px;position:relative }

/* ── Meetings page ──────────────────────────────────────────── */
.meetings-kpi-row { display:flex; gap:12px; margin-bottom:20px; flex-wrap:wrap; }
.meetings-kpi-card { flex:1; min-width:120px; background:var(--white); border:1px solid var(--border); border-radius:var(--radius-lg); padding:14px 16px; }
.meetings-kpi-label { font-size:11px; color:var(--muted); text-transform:uppercase; letter-spacing:.4px; margin-bottom:5px; }
.meetings-kpi-val { font-size:24px; font-weight:700; color:var(--text); }
.meetings-section { margin-bottom:24px; }
.meetings-section-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:12px; }
.meetings-section-title { font-size:13px; font-weight:600; color:var(--text); }
.room-cards { display:grid; grid-template-columns:repeat(auto-fill,minmax(190px,1fr)); gap:10px; }
.room-card { background:var(--white); border:1px solid var(--border); border-radius:var(--radius-lg); padding:14px; transition:border-color .2s; }
.room-card:hover { border-color:var(--orange); }
.room-card-icon { color:var(--orange); margin-bottom:7px; }
.room-card-name { font-size:13px; font-weight:600; color:var(--text); margin-bottom:3px; }
.room-card-desc { font-size:11px; color:var(--muted); margin-bottom:10px; }
.room-card-status { display:flex; align-items:center; gap:5px; font-size:11px; color:var(--muted); margin-bottom:10px; }
.room-card-status .sdot { width:7px;height:7px;border-radius:50%;background:#ccc;flex-shrink:0; }
.mtabs { display:flex; gap:4px; }
.mtab { padding:5px 13px; border-radius:6px; border:1px solid var(--border); background:transparent; font-size:12.5px; font-weight:500; color:var(--muted); cursor:pointer; transition:all .15s; }
.mtab:hover { color:var(--text); }
.mtab.active { background:rgba(19,45,68,.13); color:var(--navy); border-color:rgba(19,45,68,.35); font-weight:700; box-shadow:0 2px 8px rgba(19,45,68,.1); }
html.dark .mtab.active { background:rgba(96,165,250,.18); color:#93c5fd; border-color:rgba(96,165,250,.35); }
.meeting-row { display:flex; align-items:center; gap:12px; background:var(--white); border:1px solid var(--border); border-radius:var(--radius-lg); padding:12px 14px; margin-bottom:7px; }
.meeting-row.mlive { border-color:var(--green); background:#f0faf6; }
html.dark .meeting-row.mlive { background:rgba(15,169,104,.08); }
.mrow-time { text-align:center; min-width:44px; flex-shrink:0; }
.mrow-time-h { font-size:14px; font-weight:700; color:var(--text); }
.mrow-time-d { font-size:10px; color:var(--muted); margin-top:1px; }
.mrow-divider { width:1px; height:32px; background:var(--border); flex-shrink:0; }
.mrow-info { flex:1; min-width:0; }
.mrow-title { font-size:13px; font-weight:600; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.mrow-meta { font-size:11px; color:var(--muted); display:flex; gap:8px; flex-wrap:wrap; margin-top:2px; }
.mrow-actions { display:flex; gap:6px; flex-shrink:0; }
.mtag { padding:2px 7px; border-radius:4px; font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:.4px; white-space:nowrap; flex-shrink:0; }
.mtag-team   { background:rgba(19,45,68,.1);   color:var(--navy); }
.mtag-client { background:rgba(15,169,104,.1);  color:var(--green); }
.mtag-deal   { background:rgba(247,143,30,.12); color:var(--orange); }
.mtag-tour   { background:rgba(120,80,200,.1);  color:#7850c8; }
html.dark .mtag-team { background:rgba(255,255,255,.08); color:var(--text2); }
.meeting-type-chips { display:flex; gap:6px; flex-wrap:wrap; }
.mtype-chip { padding:5px 13px; border:1.5px solid var(--border); border-radius:7px; background:transparent; font-size:12px; font-weight:600; color:var(--muted); cursor:pointer; transition:all .15s; }
.mtype-chip.active { border-color:var(--orange); color:var(--orange); background:rgba(247,143,30,.07); }
.meeting-live-modal { position:fixed; inset:0; background:rgba(0,0,0,.88); z-index:1000; display:flex; flex-direction:column; }
.meeting-live-header { height:50px; background:var(--navy); display:flex; align-items:center; padding:0 18px; gap:10px; flex-shrink:0; }
.meeting-live-title { font-size:13px; font-weight:600; color:#fff; flex:1; }
