/* Developed by Codevance (https://codevance.dev) */
/* ============================================================
   DIMENSION REALTY SOLUTION - Admin Panel CSS
   ============================================================ */

:root {
  --primary: #1B3A6B;
  --primary-light: #2a5298;
  --accent: #C9A84C;
  --cta: #E07B39;
  --white: #ffffff;
  --bg: #f0f3f8;
  --bg-card: #ffffff;
  --sidebar-bg: #0f1f3d;
  --sidebar-text: rgba(255,255,255,0.75);
  --sidebar-active: rgba(255,255,255,0.12);
  --text-dark: #1e293b;
  --text-gray: #64748b;
  --text-light: #94a3b8;
  --border: #e2e8f0;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.12);
  --radius: 10px;
  --radius-sm: 6px;
  --font: 'Open Sans', sans-serif;
  --font-heading: 'Montserrat', sans-serif;
}

/* ── Dark mode overrides ─────────────────────────────────────── */
[data-theme="dark"] {
  --bg:         #0f172a;
  --bg-card:    #1e293b;
  --text-dark:  #f1f5f9;
  --text-gray:  #94a3b8;
  --text-light: #64748b;
  --border:     #334155;
  --shadow:     0 2px 12px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 20px rgba(0,0,0,0.5);
  --sidebar-bg: #020817;
  --sidebar-active: rgba(255,255,255,0.08);
}
[data-theme="dark"] body                      { background: var(--bg); color: var(--text-dark); }
[data-theme="dark"] .admin-header             { background: #1e293b; border-bottom-color: #334155; }
[data-theme="dark"] .card                     { background: var(--bg-card); }
[data-theme="dark"] .admin-table th           { background: #1e293b; color: var(--text-gray); border-color: #334155; }
[data-theme="dark"] .admin-table td           { border-color: #334155; }
[data-theme="dark"] .admin-table tbody tr:hover td { background: #293548; }
[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group select,
[data-theme="dark"] .form-group textarea      { background: #0f172a; color: var(--text-dark); border-color: var(--border); }
[data-theme="dark"] .modal-box,
[data-theme="dark"] .modal-content            { background: #1e293b; }
[data-theme="dark"] .modal-header             { border-bottom-color: #334155; background: #1e293b; }
[data-theme="dark"] .modal-footer             { border-top-color: #334155; background: #1e293b; }
[data-theme="dark"] .user-dropdown            { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .user-dropdown-header     { border-bottom-color: #334155; }
[data-theme="dark"] .user-dropdown-item       { color: var(--text-dark); }
[data-theme="dark"] .user-dropdown-item:hover { background: #293548; }
[data-theme="dark"] .notif-panel              { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .notif-panel-header       { border-bottom-color: #334155; }
[data-theme="dark"] .notif-item:hover         { background: #293548; }
[data-theme="dark"] .gs-palette               { background: #1e293b; }
[data-theme="dark"] .gs-input-wrap            { border-bottom-color: #334155; }
[data-theme="dark"] .gs-input                 { color: var(--text-dark); }
[data-theme="dark"] .gs-item:hover            { background: #293548; }
[data-theme="dark"] .filter-select,
[data-theme="dark"] .leads-filter-select      { background: #1e293b; color: var(--text-dark); border-color: #334155; }
[data-theme="dark"] .idle-warn-box            { background: #1e293b; }
[data-theme="dark"] .confirm-modal-box        { background: #1e293b; }
[data-theme="dark"] .input-modal-box          { background: #1e293b; }
[data-theme="dark"] .page-loader              { background: #0f172a; }
[data-theme="dark"] .bulk-action-bar          { background: #1e3a5f; border-color: #1d4ed8; }
[data-theme="dark"] .bulk-count               { color: #93c5fd; }
[data-theme="dark"] .card-header              { border-bottom-color: #334155; }
[data-theme="dark"] .tab-header               { border-bottom-color: #334155; }
[data-theme="dark"] .form-section-label       { background: #1e293b; border-bottom-color: #334155; }
[data-theme="dark"] .stat-card                { background: var(--bg-card); }
[data-theme="dark"] .lead-note-row            { border-color: #334155; background: #0f172a; }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: var(--font); background: var(--bg); color: var(--text-dark); min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f1f3d 0%, var(--primary) 100%);
  padding: 20px;
}
.login-card {
  background: var(--white);
  border-radius: 16px;
  padding: 44px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-logo {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-bottom: 28px;
}
.login-card h2 { font-family: var(--font-heading); font-size: 1.5rem; font-weight: 700; color: var(--text-dark); margin-bottom: 8px; }
.login-card > p { color: var(--text-gray); font-size: 0.9rem; margin-bottom: 28px; }
.login-hint {
  margin-top: 20px;
  font-size: 0.78rem;
  color: var(--text-light);
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  line-height: 1.6;
}
.login-hint code { background: #dde3ef; padding: 1px 5px; border-radius: 3px; font-size: 0.82rem; }
.input-group { margin-bottom: 18px; }
.input-group label { display: block; font-size: 0.83rem; font-weight: 600; color: var(--text-dark); margin-bottom: 6px; }
.input-wrap { position: relative; }
.input-wrap input { width: 100%; padding: 12px 44px 12px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 0.9rem; outline: none; transition: border-color 0.2s; }
.input-wrap input:focus { border-color: var(--primary); }
.toggle-pass { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--text-light); font-size: 0.9rem; }

/* ============================================================
   ADMIN APP LAYOUT
   ============================================================ */
.admin-app {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  width: 250px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.3s ease;
}
.sidebar-header {
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo { display: flex; align-items: center; gap: 10px; }
.sidebar-logo-icon {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 0.9rem;
}
.sidebar-brand { font-family: var(--font-heading); font-weight: 700; font-size: 0.85rem; color: var(--white); }
.sidebar-sub { font-size: 0.65rem; color: var(--accent); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.sidebar-close { background: none; border: none; color: var(--sidebar-text); font-size: 1rem; display: none; }

.sidebar-nav { padding: 16px 0; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  color: var(--sidebar-text);
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}
.nav-item i { width: 18px; text-align: center; }
.nav-item:hover { color: var(--white); background: var(--sidebar-active); }
.nav-item.active { color: var(--white); background: var(--sidebar-active); border-left-color: var(--accent); }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-brand-footer {
  padding: 12px 16px 14px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
}

.sidebar-brand-footer span {
  font-size: 0.62rem;
  color: rgba(255,255,255,0.28);
  letter-spacing: 0.03em;
}

.sidebar-brand-footer a {
  font-size: 0.68rem;
  font-weight: 600;
  color: rgba(255,255,255,0.42);
  text-decoration: none;
  letter-spacing: 0.04em;
  transition: color 0.18s;
}

.sidebar-brand-footer a:hover {
  color: rgba(255,255,255,0.72);
}
.btn-ghost {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  color: var(--sidebar-text);
  background: transparent;
  border: 1px solid rgba(255,255,255,0.15);
  cursor: pointer;
  transition: all 0.2s;
}
.btn-ghost:hover { color: var(--white); background: var(--sidebar-active); }
.btn-ghost.danger:hover { color: #fca5a5; border-color: #fca5a5; }

/* --- Main Content --- */
.admin-main {
  margin-left: 250px;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.admin-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}
.admin-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-dark);
  flex: 1;
}
.admin-header-right { display: flex; gap: 12px; align-items: center; }
.menu-toggle { background: none; border: none; color: var(--text-gray); font-size: 1.1rem; display: none; }

/* View Site link in header */
.header-view-site {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.82rem; font-weight: 500; color: var(--text-gray);
  text-decoration: none; padding: 6px 12px;
  border: 1px solid var(--border); border-radius: 20px;
  transition: all 0.18s;
}
.header-view-site:hover { color: var(--primary); border-color: var(--primary); background: #f0f4ff; }

.header-help-btn {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  font-size: 1rem; color: var(--text-gray);
  border: 1px solid var(--border); border-radius: 50%;
  text-decoration: none; transition: all 0.18s;
}
.header-help-btn:hover { color: var(--primary); border-color: var(--primary); background: #f0f4ff; }

/* User dropdown menu */
.user-menu { position: relative; }
.user-menu-trigger {
  display: flex; align-items: center; gap: 8px;
  background: none; border: 1px solid var(--border); border-radius: 24px;
  padding: 5px 12px 5px 6px; cursor: pointer;
  color: var(--text-dark); font-size: 0.84rem; font-weight: 500;
  transition: all 0.18s;
}
.user-menu-trigger:hover { border-color: var(--primary); background: #f0f4ff; }
.user-menu-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem; font-weight: 700; overflow: hidden; flex-shrink: 0;
}
.user-menu-name { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-chevron { font-size: 0.65rem; color: var(--text-gray); transition: transform 0.18s; }
.user-dropdown.open ~ .user-menu-trigger .user-menu-chevron,
.user-menu:has(.user-dropdown.open) .user-menu-chevron { transform: rotate(180deg); }

.user-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 220px; background: var(--white);
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: all 0.18s; z-index: 200;
}
.user-dropdown.open { opacity: 1; visibility: visible; transform: translateY(0); }
.user-dropdown-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.user-dropdown-name { font-weight: 600; font-size: 0.88rem; color: var(--text-dark); }
.user-dropdown-role { font-size: 0.72rem; color: var(--text-gray); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.4px; }
.user-dropdown-divider { margin: 4px 0; border: none; border-top: 1px solid var(--border); }
.user-dropdown-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 16px;
  background: none; border: none; text-align: left;
  font-size: 0.85rem; color: var(--text-dark); cursor: pointer;
  transition: background 0.15s; border-radius: 0;
}
.user-dropdown-item:first-of-type { border-radius: 0; }
.user-dropdown-item:last-child { border-radius: 0 0 12px 12px; }
.user-dropdown-item:hover { background: #f5f7fa; }
.user-dropdown-item.danger { color: var(--danger); }
.user-dropdown-item.danger:hover { background: #fff0f0; }
.user-dropdown-item i { width: 16px; text-align: center; opacity: 0.7; }

.tab-content { padding: 28px; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}
.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.card-header h3 {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================================================
   STATS
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.stat-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.stat-icon.blue { background: #dbeafe; color: #1d4ed8; }
.stat-icon.red { background: #fee2e2; color: #dc2626; }
.stat-icon.gold { background: #fef3c7; color: #d97706; }
.stat-icon.green { background: #dcfce7; color: #16a34a; }
.stat-number { font-family: var(--font-heading); font-size: 1.3rem; font-weight: 800; color: var(--text-dark); }
.stat-label  { font-size: 0.72rem; color: var(--text-gray); margin-top: 1px; }

.stat-trend  { font-size: 0.68rem; font-weight: 600; margin-top: 3px; display: flex; align-items: center; gap: 3px; }
.stat-trend.up   { color: #10b981; }
.stat-trend.down { color: #ef4444; }
.stat-trend.flat { color: var(--text-gray); }

/* Overdue follow-up alert strip */
.followup-alert-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-left: 4px solid #f97316;
  border-radius: 10px;
  padding: 14px 18px;
  flex-wrap: wrap;
}
.followup-alert-left {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  color: #9a3412;
}
.followup-alert-left > i {
  font-size: 1.1rem;
  margin-top: 2px;
  color: #f97316;
  flex-shrink: 0;
}
.followup-alert-left strong { font-size: 0.95rem; }
.followup-alert-sub { font-size: 0.78rem; color: #c2410c; margin-top: 2px; opacity: 0.85; }

.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.market-snapshot-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
@media (max-width: 900px) { .market-snapshot-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .market-snapshot-grid { grid-template-columns: 1fr; } }
@media (max-width: 380px) { .market-snapshot-grid { grid-template-columns: 1fr; gap: 8px; } }
.portfolio-panel {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card, var(--white));
}
.portfolio-panel-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.portfolio-panel-icon.blue  { background: #dbeafe; color: #1d4ed8; }
.portfolio-panel-icon.green { background: #dcfce7; color: #16a34a; }
.portfolio-panel-icon.amber { background: #fef3c7; color: #d97706; }
@media (max-width: 480px) {
  .portfolio-panel { padding: 12px 14px; gap: 10px; }
  .portfolio-panel-icon { width: 34px; height: 34px; font-size: 0.85rem; }
  .portfolio-count { font-size: 1.25rem; }
}
.portfolio-count { font-family: var(--font-heading); font-size: 1.55rem; font-weight: 800; color: var(--text-dark); line-height: 1; }
.portfolio-label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-gray); margin-top: 2px; }
.portfolio-value { font-size: 0.82rem; font-weight: 600; margin-top: 5px; }
.portfolio-value.green { color: #16a34a; }
.portfolio-value.blue  { color: #1d4ed8; }
.portfolio-value.amber { color: #d97706; }
@media (max-width: 640px) { .portfolio-grid { grid-template-columns: 1fr; } }

/* ── Agent Performance ───────────────────────────────────────── */
.perf-rank-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border-bottom: 1px solid var(--border);
}
[data-theme="dark"] .perf-rank-banner { background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%); }
.perf-rank-medal {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; font-weight: 900; flex-shrink: 0;
}
.perf-rank-medal.gold   { background: #fef3c7; color: #d97706; box-shadow: 0 0 0 3px #fde68a; }
.perf-rank-medal.silver { background: #f1f5f9; color: #64748b; box-shadow: 0 0 0 3px #e2e8f0; }
.perf-rank-medal.bronze { background: #fff7ed; color: #c2410c; box-shadow: 0 0 0 3px #fed7aa; }
.perf-rank-medal.other  { background: #f8fafc; color: #94a3b8; box-shadow: 0 0 0 3px #e2e8f0; }
.perf-rank-text   { font-size: 1rem; font-weight: 700; color: var(--text-dark); }
.perf-rank-sub    { font-size: 0.78rem; color: var(--text-gray); margin-top: 1px; }

.perf-tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-top: 1px solid var(--border);
}
.perf-tile {
  padding: 16px 20px;
  border-right: 1px solid var(--border);
  text-align: center;
}
.perf-tile:last-child { border-right: none; }
.perf-tile-value { font-family: var(--font-heading); font-size: 1.45rem; font-weight: 800; color: var(--text-dark); line-height: 1; }
.perf-tile-label { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-gray); margin-top: 4px; }
.perf-tile-sub   { font-size: 0.78rem; margin-top: 5px; color: var(--text-gray); }
.perf-delta      { display: inline-flex; align-items: center; gap: 3px; font-size: 0.75rem; font-weight: 700; padding: 1px 6px; border-radius: 999px; margin-top: 4px; }
.perf-delta.up   { background: #dcfce7; color: #16a34a; }
.perf-delta.down { background: #fee2e2; color: #dc2626; }
.perf-delta.flat { background: #f1f5f9; color: #64748b; }

.perf-footer { padding: 10px 24px; border-top: 1px solid var(--border); font-size: 0.82rem; color: var(--text-gray); display: flex; gap: 20px; flex-wrap: wrap; }
.perf-footer strong { color: var(--text-dark); }

/* Enhanced leaderboard table */
.leaderboard-medal { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; font-size: 0.72rem; font-weight: 800; }
.leaderboard-medal.gold   { background: #fef3c7; color: #d97706; }
.leaderboard-medal.silver { background: #f1f5f9; color: #64748b; }
.leaderboard-medal.bronze { background: #fff7ed; color: #c2410c; }
.leaderboard-medal.other  { background: transparent; color: #94a3b8; }
.achieve-pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.achieve-pill.great  { background: #dcfce7; color: #16a34a; }
.achieve-pill.good   { background: #dbeafe; color: #1d4ed8; }
.achieve-pill.low    { background: #fee2e2; color: #dc2626; }
.achieve-pill.none   { background: #f1f5f9; color: #94a3b8; }

@media (max-width: 900px) { .perf-tiles { grid-template-columns: repeat(2, 1fr); } .perf-tile:nth-child(2) { border-right: none; } .perf-tile:nth-child(3) { border-top: 1px solid var(--border); } }
@media (max-width: 600px) { .perf-tiles { grid-template-columns: 1fr 1fr; } }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap, .table-responsive { overflow-x: auto; }
/* Scroll-shadow affordance: shows a fading edge only when there's more table
   content off-screen, so mobile users know columns like "Status" are there
   to scroll to, rather than the table just silently cutting off. */
@media (max-width: 768px) {
  .table-wrap, .table-responsive {
    background:
      linear-gradient(to right, var(--white) 30%, rgba(255,255,255,0)) 0 0,
      linear-gradient(to right, rgba(255,255,255,0), var(--white) 70%) 100% 0,
      radial-gradient(farthest-side at 0% 50%, rgba(15,30,70,0.22), rgba(0,0,0,0)) 0 0,
      radial-gradient(farthest-side at 100% 50%, rgba(15,30,70,0.22), rgba(0,0,0,0)) 100% 0;
    background-repeat: no-repeat;
    background-color: var(--white);
    background-size: 32px 100%, 32px 100%, 12px 100%, 12px 100%;
    background-attachment: local, local, scroll, scroll;
  }
}
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.admin-table th {
  background: var(--bg);
  padding: 12px 16px;
  text-align: left;
  font-family: var(--font-heading);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-gray);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.admin-table td {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  color: var(--text-dark);
  vertical-align: middle;
}
.admin-table tr:hover td { background: #fafbff; }
.table-img {
  width: 60px;
  height: 44px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}
.table-address { font-weight: 600; font-size: 0.85rem; }
.table-sub { font-size: 0.78rem; color: var(--text-gray); }
.table-price { font-family: var(--font-heading); font-weight: 700; color: var(--primary); }

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.badge-active { background: #dcfce7; color: #16a34a; }
.badge-sold { background: #fee2e2; color: #dc2626; }
.badge-pending { background: #fef3c7; color: #d97706; }
.badge-yes { background: #fef3c7; color: #d97706; }
.badge-no { background: var(--bg); color: var(--text-light); }
.badge-role-super_admin { background: #1B3A6B; color: #fff; }
.badge-role-admin       { background: #dbeafe; color: #1d4ed8; }
.badge-role-marketing   { background: #fce7f3; color: #be185d; }
.badge-role-sales_agent { background: #dcfce7; color: #15803d; }
/* Activity log badges */
.log-filters {
  display: flex; gap: 10px; flex-wrap: wrap;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
  background: #f8fafc;
}
.log-filters select,
.log-filters input[type="date"] {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 0.82rem; color: var(--text-dark); background: var(--white);
  outline: none;
}
.log-filters select:focus,
.log-filters input[type="date"]:focus { border-color: var(--primary); }

.log-badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px;
}
.log-login  { background: #eff6ff; color: #3b82f6; }
.log-logout { background: #f1f5f9; color: #64748b; }
.log-create { background: #dcfce7; color: #15803d; }
.log-update { background: #dbeafe; color: #1d4ed8; }
.log-delete { background: #fee2e2; color: #dc2626; }

.badge-video { background: #fee2e2; color: #dc2626; }
.badge-blog { background: #dbeafe; color: #1d4ed8; }

/* Type radio buttons */
.type-radio-label { cursor: pointer; }
.type-radio-label input[type="radio"] { display: none; }
.type-radio-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-gray);
  transition: all 0.2s;
  cursor: pointer;
}
.type-radio-label input[type="radio"]:checked + .type-radio-btn {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--white);
}

/* Action buttons */
.action-btns { display: flex; gap: 6px; }
.action-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}
@media (max-width: 768px) {
  .action-btn { width: 38px; height: 38px; font-size: 0.85rem; }
}
.action-btn.edit { background: #dbeafe; color: #1d4ed8; }
.action-btn.edit:hover { background: #1d4ed8; color: var(--white); }
.action-btn.delete { background: #fee2e2; color: #dc2626; }
.action-btn.delete:hover { background: #dc2626; color: var(--white); }

/* ============================================================
   FORM
   ============================================================ */
.form-section-label {
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 20px 24px 12px;
  border-bottom: 1px solid var(--border);
  background: #fafbff;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 20px 24px;
}
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 0.82rem; font-weight: 600; color: var(--text-dark); }
.form-group input,
.form-group select,
.form-group textarea {
  padding: 10px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: var(--text-dark);
  background: var(--white);
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--primary); }
.form-group textarea { resize: vertical; min-height: 100px; }
.form-group small { font-size: 0.75rem; color: var(--text-gray); }
.form-group small a { color: var(--primary); text-decoration: underline; }
.form-group.full-col { grid-column: 1 / -1; padding: 0 24px; }
.form-group.padded { padding: 0 24px 20px; }

.input-prefix { position: relative; }
.input-prefix span {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-gray);
  font-weight: 600;
}
.input-prefix input { padding-left: 28px; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-dark);
}
.checkbox-label input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; accent-color: var(--primary); }

.img-preview {
  width: 100%;
  height: 180px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  overflow: hidden;
  color: var(--text-light);
  font-size: 0.85rem;
}
.img-preview img { width: 100%; height: 100%; object-fit: cover; }

/* ── Photo Grid ─────────────────────────────────────────────── */
/* ── Agent picker dropdown ── */
.agent-picker-wrap { position: relative; max-width: 480px; }

.agent-picker-trigger {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 13px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--white); cursor: pointer;
  font-size: 0.88rem; color: var(--text-dark);
  transition: border-color 0.15s;
  user-select: none;
}
.agent-picker-trigger:hover,
.agent-picker-wrap.open .agent-picker-trigger { border-color: var(--primary); }
.agent-picker-trigger-label { flex: 1; display: flex; flex-wrap: wrap; gap: 5px; align-items: center; min-height: 22px; }
.agent-picker-trigger-label .apt-placeholder { color: var(--text-gray); }
.agent-pick-tag {
  display: inline-flex; align-items: center; gap: 4px;
  background: #eef2ff; color: var(--primary);
  border: 1px solid #c7d2fe; border-radius: 4px;
  padding: 2px 7px; font-size: 0.75rem; font-weight: 600;
}
.agent-pick-tag button {
  background: none; border: none; cursor: pointer;
  color: var(--primary); font-size: 0.65rem; padding: 0; line-height: 1;
}
.agent-picker-trigger-arrow { font-size: 0.75rem; color: var(--text-gray); flex-shrink: 0; transition: transform 0.2s; }
.agent-picker-wrap.open .agent-picker-trigger-arrow { transform: rotate(180deg); }

.agent-picker-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--white); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  z-index: 200; max-height: 260px; overflow-y: auto; display: none;
}
.agent-picker-wrap.open .agent-picker-dropdown { display: block; }

.agent-pick-option {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; cursor: pointer;
  transition: background 0.12s;
}
.agent-pick-option:hover { background: #f5f7ff; }
.agent-pick-option.selected { background: #eef2ff; }
.agent-pick-option-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: var(--primary); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.agent-pick-option-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.agent-pick-option-init { font-size: 0.68rem; font-weight: 700; color: #fff; }
.agent-pick-option-name { font-size: 0.85rem; font-weight: 600; color: var(--text-dark); flex: 1; }
.agent-pick-option-check { font-size: 0.75rem; color: var(--primary); opacity: 0; }
.agent-pick-option.selected .agent-pick-option-check { opacity: 1; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 12px;
  border-radius: var(--radius-sm);
  transition: background 0.18s;
}
.photo-grid.drag-over {
  background: #eef2ff;
  outline: 2px dashed var(--primary);
}
.photo-card {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg);
  border: 2px solid var(--border);
}
.photo-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.photo-card-err {
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-light);
  font-size: 0.72rem;
}
.photo-card-err i { font-size: 1.3rem; }
.photo-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: var(--primary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 20px;
  pointer-events: none;
}
.photo-remove {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.photo-card:hover .photo-remove { opacity: 1; }
.photo-add-tile {
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-sm);
  border: 2px dashed var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  color: var(--text-light);
  font-size: 0.78rem;
  background: var(--bg);
  transition: border-color 0.18s, color 0.18s, background 0.18s;
}
.photo-add-tile:hover { border-color: var(--primary); color: var(--primary); background: #f0f5ff; }
.photo-add-tile i { font-size: 1.4rem; }
.photo-input-tile {
  border-radius: var(--radius-sm);
  border: 2px solid var(--primary);
  background: #f8faff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  grid-column: span 2;
}
.photo-upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.18s;
  width: 100%;
}
.photo-upload-btn:hover { background: var(--primary-light); }
.photo-upload-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.photo-input-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--text-light);
}
.photo-input-divider::before,
.photo-input-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.photo-url-row { display: flex; gap: 6px; }
.photo-url-row input[type="url"] {
  flex: 1;
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-family: var(--font);
  outline: none;
  min-width: 0;
}
.photo-url-row input[type="url"]:focus { border-color: var(--primary); }
.photo-input-actions { display: flex; gap: 5px; margin-top: 2px; }
.photo-input-actions .btn { padding: 5px 10px; font-size: 0.72rem; flex: 1; }
.photo-card.uploading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #eef2ff;
  border-color: var(--primary);
  color: var(--primary);
  font-size: 0.72rem;
}
.photo-card.uploading i { font-size: 1.3rem; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.form-actions {
  padding: 20px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-light); }
.btn-danger { background: #dc2626; color: var(--white); }
.btn-danger:hover { background: #b91c1c; }
.btn-outline { background: transparent; color: var(--text-dark); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 7px 16px; font-size: 0.78rem; }
.full-width { width: 100%; justify-content: center; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.5;
}
.alert i { margin-top: 1px; flex-shrink: 0; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-danger { background: #fee2e2; color: #dc2626; border: 1px solid #fecaca; }
.alert-success { background: #dcfce7; color: #16a34a; border: 1px solid #bbf7d0; }

/* ============================================================
   EXPORT STEPS
   ============================================================ */
.export-steps { padding: 24px; display: flex; flex-direction: column; gap: 28px; }
.step { display: flex; gap: 20px; align-items: flex-start; }
.step-num {
  width: 36px;
  height: 36px;
  background: var(--primary);
  color: var(--white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.step-body h4 { font-family: var(--font-heading); font-weight: 700; color: var(--text-dark); margin-bottom: 6px; font-size: 0.95rem; }
.step-body p { color: var(--text-gray); font-size: 0.88rem; margin-bottom: 14px; }
.step-body code { background: var(--bg); padding: 2px 6px; border-radius: 3px; font-size: 0.82rem; }
.upload-steps { padding-left: 18px; display: flex; flex-direction: column; gap: 6px; color: var(--text-gray); font-size: 0.88rem; }
.upload-steps li { padding: 3px 0; }
.export-preview {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.82rem;
  color: var(--text-gray);
  max-height: 140px;
  overflow-y: auto;
  margin-top: 10px;
}
.filter-select {
  padding: 7px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  color: var(--text-dark);
  background: var(--white);
  cursor: pointer;
  outline: none;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal {
  background: var(--white);
  border-radius: var(--radius);
  padding: 36px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.modal-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  margin: 0 auto 16px;
}
.modal-icon.danger  { background: #fee2e2; color: #dc2626; }
.modal-icon.warning { background: #fef3c7; color: #d97706; }
.btn-warning { background: #d97706; color: #fff; border: none; padding: 10px 24px; border-radius: 8px; font-weight: 600; cursor: pointer; transition: background 0.15s; }
.btn-warning:hover { background: #b45309; }
.modal h3 { font-family: var(--font-heading); font-size: 1.2rem; font-weight: 700; margin-bottom: 8px; }
.modal p { color: var(--text-gray); font-size: 0.9rem; margin-bottom: 24px; }
.modal-actions { display: flex; gap: 12px; justify-content: center; }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text-dark);
  color: var(--white);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s;
  z-index: 2000;
  pointer-events: none;
  max-width: 320px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: #16a34a; }
.toast.error { background: #dc2626; }

/* ============================================================
   STAT CARD ENHANCEMENTS
   ============================================================ */
.stats-grid { grid-template-columns: repeat(4, 1fr); }
.stat-card { transition: all 0.2s; }
.stat-card.stat-clickable { cursor: pointer; }
.stat-card.stat-clickable:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon.orange { background: #ffedd5; color: #ea580c; }
.stat-icon.teal   { background: #ccfbf1; color: #0d9488; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }

/* ============================================================
   QUICK ACTIONS (dashboard)
   ============================================================ */
.quick-actions { display: flex; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.quick-action-btn {
  flex: 1;
  min-width: 180px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius);
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dark);
  cursor: pointer;
  transition: all 0.18s;
  box-shadow: var(--shadow);
  text-align: left;
}
.qa-icon {
  width: 40px; height: 40px; flex-shrink: 0;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}
.qa-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.qa-label { font-size: 0.88rem; font-weight: 700; }
.qa-sub { font-size: 0.72rem; font-weight: 500; opacity: 0.65; }
.qa-arrow { font-size: 0.7rem; opacity: 0; transition: opacity 0.18s, transform 0.18s; flex-shrink: 0; }
.quick-action-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.quick-action-btn:hover .qa-arrow { opacity: 0.6; transform: translateX(3px); }

.qa-blue  { border-left-color: #1d4ed8; }
.qa-blue  .qa-icon { background: #dbeafe; color: #1d4ed8; }
.qa-blue:hover  { border-color: #1d4ed8; border-left-color: #1d4ed8; }

.qa-purple { border-left-color: #7c3aed; }
.qa-purple .qa-icon { background: #ede9fe; color: #7c3aed; }
.qa-purple:hover { border-color: #7c3aed; border-left-color: #7c3aed; }

.qa-green  { border-left-color: #16a34a; }
.qa-green  .qa-icon { background: #dcfce7; color: #16a34a; }
.qa-green:hover  { border-color: #16a34a; border-left-color: #16a34a; }

.qa-amber  { border-left-color: #d97706; }
.qa-amber  .qa-icon { background: #fef3c7; color: #d97706; }
.qa-amber:hover  { border-color: #d97706; border-left-color: #d97706; }

/* Leads stat badge */
.stat-new-badge {
  display: inline-flex;
  align-items: center;
  background: #3B82F6;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  margin-left: 6px;
  vertical-align: middle;
}
.stat-icon.indigo { background: #e0e7ff; color: #4338ca; }

/* Dashboard 2-col bottom */
.dashboard-bottom {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  align-items: stretch;
}

/* Equal-height cards with scrollable content */
.dashboard-bottom .card {
  display: flex;
  flex-direction: column;
  max-height: 540px;
}
.dashboard-bottom .card .table-responsive {
  flex: 1;
  overflow-y: auto;
}
.dashboard-bottom .dash-leads-list {
  flex: 1;
  overflow-y: auto;
  max-height: none;
}

/* Recent Leads widget */
.dash-leads-card .card-header { padding-bottom: 0; border-bottom: none; }
.dash-leads-new-badge {
  display: inline-flex;
  align-items: center;
  background: #3B82F6;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 10px;
  margin-left: 8px;
  vertical-align: middle;
}
.dash-leads-list { padding: 8px 0 4px; }
.dash-leads-loading { padding: 24px; text-align: center; font-size: 0.85rem; color: var(--text-gray); }
.dash-leads-empty { padding: 32px 20px; text-align: center; color: var(--text-gray); }
.dash-leads-empty i { font-size: 1.8rem; margin-bottom: 8px; display: block; opacity: 0.4; }
.dash-leads-empty p { font-size: 0.85rem; margin: 0; }
.dash-lead-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.14s;
}
.dash-lead-row:last-child { border-bottom: none; }
.dash-lead-row:hover { background: var(--bg-light); }
.dash-lead-new { background: rgba(59,130,246,0.04); }
.dash-lead-new:hover { background: rgba(59,130,246,0.08) !important; }
.dash-lead-avatar {
  width: 36px; height: 36px; flex-shrink: 0;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-heading); font-size: 0.95rem; font-weight: 800;
}
.dash-lead-info { flex: 1; min-width: 0; }
.dash-lead-name {
  font-size: 0.85rem; font-weight: 600; color: var(--text-dark);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dash-lead-new .dash-lead-name { font-weight: 700; }
.dash-lead-meta {
  font-size: 0.75rem; color: var(--text-gray); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dash-lead-right {
  display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0;
}
.dash-lead-time { font-size: 0.72rem; color: var(--text-light); white-space: nowrap; }

/* ============================================================
   TABLE TOOLBAR (search + filter row)
   ============================================================ */
.table-toolbar {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  background: var(--bg);
}
.search-wrap { position: relative; flex: 1; min-width: 180px; }
.search-wrap > i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-light); font-size: 0.8rem; pointer-events: none; }
.search-input {
  width: 100%;
  padding: 8px 12px 8px 30px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-family: var(--font);
  color: var(--text-dark);
  background: var(--white);
  outline: none;
  transition: border-color 0.2s;
}
.search-input:focus { border-color: var(--primary); }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state-cell { text-align: center; padding: 60px 20px !important; }
.empty-state { display: inline-flex; flex-direction: column; align-items: center; gap: 12px; }
.empty-state > i { font-size: 2.5rem; color: var(--border); }
.empty-state h4 { font-family: var(--font-heading); color: var(--text-dark); font-size: 1rem; margin: 0; }
.empty-state p { color: var(--text-gray); font-size: 0.85rem; margin: 0; }

/* ============================================================
   INLINE FEATURED TOGGLE
   ============================================================ */
.feature-toggle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-light);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  margin: 0 auto;
}
.feature-toggle:hover { border-color: #d97706; color: #d97706; }
.feature-toggle.active { background: #fef3c7; border-color: #d97706; color: #d97706; }

/* ============================================================
   SIDEBAR USER INFO
   ============================================================ */
.sidebar-user-info { display: flex; align-items: center; gap: 10px; padding: 4px 0 10px; }
.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--white);
  flex-shrink: 0;
  text-transform: uppercase;
}
.sidebar-user-name { font-size: 0.82rem; font-weight: 600; color: var(--white); line-height: 1.3; }
.sidebar-user-role { font-size: 0.68rem; color: var(--accent); text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600; }

/* ============================================================
   DB STATUS PANEL (Export / Backup tab)
   ============================================================ */
.db-status-panel { padding: 24px; }
.db-status-row { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 24px; flex-wrap: wrap; }
.db-status-counts { display: flex; gap: 12px; flex-wrap: wrap; }
.db-count-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 20px;
  background: var(--bg);
  border-radius: var(--radius);
  text-align: center;
  min-width: 100px;
  border: 1px solid var(--border);
}
.db-count-num { font-family: var(--font-heading); font-size: 1.5rem; font-weight: 800; color: var(--primary); }
.db-count-label { font-size: 0.75rem; color: var(--text-gray); }

/* ============================================================
   AVATAR UPLOADER (team, testimonials, admin users)
   ============================================================ */
.avatar-uploader {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 0 4px;
}
.avatar-preview {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  color: var(--text-light);
  font-size: 1.6rem;
  position: relative;
}
.avatar-preview img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.avatar-preview .avatar-initials {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--white);
  background: var(--primary);
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
}
.avatar-uploader-controls { display: flex; flex-direction: column; gap: 6px; }
.avatar-uploader-controls small { color: var(--text-gray); font-size: 0.74rem; }
.avatar-uploading { opacity: 0.5; }

/* ============================================================
   TESTIMONIALS
   ============================================================ */
.star-rating-input {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.star-btn {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--border);
  padding: 2px;
  transition: color 0.15s, transform 0.1s;
  line-height: 1;
}
.star-btn:hover,
.star-btn.active { color: #d97706; }
.star-btn:hover { transform: scale(1.15); }

.testi-stars { color: #d97706; font-size: 0.78rem; letter-spacing: 1px; white-space: nowrap; }
.testi-quote { font-size: 0.82rem; color: var(--text-gray); display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 360px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  /* Sidebar as a slide-in drawer */
  .sidebar { transform: translateX(-100%); z-index: 300; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 299; }
  .sidebar.open ~ .sidebar-overlay { display: block; }

  /* Main content fills full width */
  .admin-main { margin-left: 0; }
  .menu-toggle { display: block; }

  /* Header */
  .admin-header { padding: 0 12px; }
  .header-view-site span { display: none; }

  /* Dashboard stats */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .dashboard-bottom { grid-template-columns: 1fr; }
  .dash-charts-row { grid-template-columns: 1fr; }
  .quick-actions { gap: 8px; }
  .quick-action-btn { min-width: 130px; padding: 10px 12px; }
  .qa-sub { display: none; }
  .dash-range-bar { flex-wrap: wrap; gap: 6px; }

  /* Tables */
  .table-toolbar { padding: 10px 12px; flex-wrap: wrap; gap: 6px; }
  .leads-toolbar { flex-wrap: wrap; gap: 8px; }
  .admin-table th, .admin-table td { padding: 8px 10px; font-size: 0.8rem; }
  .table-responsive { -webkit-overflow-scrolling: touch; }

  /* Forms */
  .form-grid { grid-template-columns: 1fr; padding: 14px 16px; }
  .form-grid-3 { grid-template-columns: 1fr; }
  .form-section-label { padding: 14px 16px; }
  .form-actions { padding: 14px 16px; flex-direction: column; }
  .tab-content { padding: 14px; }
  .card-header { padding: 12px 14px; flex-wrap: wrap; gap: 6px; }

  /* Modals */
  .modal-box, .modal-content { width: 96vw; max-width: 96vw; padding: 20px 16px; margin: 12px; }
  .lead-modal-body { flex-direction: column; }
  .lead-modal-left, .lead-modal-right { width: 100%; }

  /* Performance table */
  .perf-table { font-size: 0.78rem; }
  .perf-summary-strip { grid-template-columns: repeat(2, 1fr); }

  /* Misc */
  .export-steps { padding: 14px; }
  .bulk-action-bar { flex-wrap: wrap; gap: 6px; padding: 8px 12px; }
  .cal-page-header { flex-wrap: wrap; gap: 8px; }
  .cal-legend { flex-wrap: wrap; gap: 6px; }
  .docs-layout { flex-direction: column; }
  .docs-agent-panel { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card { padding: 14px; }
  .stat-val { font-size: 1.4rem; }
  .quick-action-btn { min-width: 42%; }
  .qa-icon { width: 30px; height: 30px; font-size: 0.85rem; }
  .header-view-site { display: none; }
  .user-menu-name { display: none; }
  .db-status-counts { gap: 8px; }
  .db-count-item { min-width: 75px; padding: 10px 12px; }
  .perf-summary-strip { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  /* Hide Source column on tiny screens — scoped to the leads table only.
     This used to target .admin-table generically, which also hid the 3rd
     column (e.g. Status) on every other admin table on the page. */
  .leads-table th:nth-child(4),
  .leads-table td:nth-child(4) { display: none; }
  .notif-panel { width: 90vw; right: -8px; }
  .idle-warn-box { padding: 1.5rem 1rem; }
  .idle-warn-actions { flex-direction: column; }
  .idle-warn-actions .btn { min-width: 100%; }
}

/* ═══════════════════════════════════════════════════════════
   DOCUMENT PORTAL
   ═══════════════════════════════════════════════════════════ */

/* ── Two-column layout ─────────────────────────────────────── */
.docs-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-height: 620px;
}

/* ── Agent sidebar ──────────────────────────────────────────── */
.docs-agents-panel {
  border-right: 1px solid var(--border);
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.docs-agents-header {
  padding: 13px 14px 12px;
  font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-light);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.docs-agents-count {
  background: var(--primary); color: #fff;
  font-size: 0.65rem; font-weight: 700;
  padding: 1px 6px; border-radius: 10px;
  min-width: 18px; text-align: center;
}
.docs-agents-search {
  position: relative;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.docs-agents-search i {
  position: absolute; left: 22px; top: 50%; transform: translateY(-50%);
  font-size: 0.72rem; color: #94a3b8; pointer-events: none;
}
.docs-agents-search input {
  width: 100%; padding: 6px 10px 6px 28px;
  border: 1px solid #e2e8f0; border-radius: 20px;
  font-size: 0.8rem; background: #f8fafc; outline: none;
  transition: border-color 0.15s, background 0.15s;
  box-sizing: border-box;
}
.docs-agents-search input:focus { border-color: var(--primary); background: #fff; }
.docs-agents-list { overflow-y: auto; flex: 1; }
.docs-agent-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 13px; cursor: pointer;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  transition: background 0.13s;
  position: relative;
}
.docs-agent-item:hover  { background: rgba(27,58,107,0.05); }
.docs-agent-item.active {
  background: rgba(27,58,107,0.08);
  border-right: 3px solid var(--primary);
}
.docs-agent-item.active .docs-agent-avatar {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}
.docs-agent-avatar {
  width: 38px; height: 38px; flex-shrink: 0; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #2a5298);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; letter-spacing: 0.5px;
}
.docs-agent-info  { flex: 1; min-width: 0; }
.docs-agent-row1  {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 4px; margin-bottom: 3px;
}
.docs-agent-name  {
  font-size: 0.83rem; font-weight: 600; color: #1e293b;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1; min-width: 0;
}
.docs-agent-time  { font-size: 0.68rem; color: #94a3b8; flex-shrink: 0; white-space: nowrap; }
.docs-agent-item.active .docs-agent-time { color: var(--primary); }
.docs-agent-row2  { display: flex; align-items: center; gap: 5px; }
.docs-agent-role-tag {
  font-size: 0.62rem; font-weight: 600; padding: 1px 5px; border-radius: 3px;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.docs-role-sales_agent  { background: #eff6ff; color: #1d4ed8; }
.docs-role-marketing    { background: #f0fdf4; color: #15803d; }
.docs-agent-files { font-size: 0.7rem; color: #94a3b8; }
.docs-agent-empty {
  padding: 28px 16px; text-align: center;
  color: #94a3b8; font-size: 0.82rem;
}
.docs-agent-empty i { font-size: 1.2rem; margin-bottom: 6px; opacity: 0.5; display: block; }

/* ── Workspace ─────────────────────────────────────────────── */
.docs-workspace       { display: flex; flex-direction: column; min-height: 620px; background: #fff; }
.docs-workspace-full  { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); background: #fff; overflow: hidden; }
.docs-select-prompt   { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-gray); gap: 12px; padding: 60px 24px; }
.docs-select-prompt i { font-size: 3rem; opacity: 0.15; }
.docs-select-prompt p { font-size: 0.88rem; margin: 0; }
.docs-loading         { padding: 32px; text-align: center; font-size: 0.85rem; color: var(--text-gray); }

/* ── Workspace header ──────────────────────────────────────── */
.docs-ws-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 20px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}
.docs-ws-title {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 0.95rem; color: var(--text-dark);
  min-width: 0;
}
.docs-ws-title i      { color: #f59e0b; font-size: 1.1rem; flex-shrink: 0; }
.docs-ws-title span   { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.docs-ws-actions      { display: flex; gap: 8px; flex-shrink: 0; }
.docs-new-folder-btn  { font-size: 0.79rem !important; padding: 5px 12px !important; gap: 5px; }
.docs-back-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  border: 1.5px solid var(--border); background: #fff;
  cursor: pointer; color: var(--text-dark); transition: all 0.15s; flex-shrink: 0;
}
.docs-back-btn:hover { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ── Upload zone ───────────────────────────────────────────── */
.docs-upload-zone     { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.docs-drop-area {
  border: 2px dashed #d1d5db;
  border-radius: 10px;
  padding: 22px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #fafafa;
}
.docs-drop-area:hover,
.docs-drop-area.dragging { border-color: var(--primary); background: #eff6ff; }
.docs-drop-area i     { font-size: 1.7rem; color: var(--primary); opacity: 0.55; margin-bottom: 6px; display: block; }
.docs-drop-area p     { margin: 0 0 2px; font-size: 0.85rem; color: var(--text-dark); }
.docs-upload-hint     { font-size: 0.73rem !important; color: var(--text-light) !important; }
.docs-browse-link     { color: var(--primary); font-weight: 700; cursor: pointer; text-decoration: none; border-bottom: 1px solid; }
.docs-upload-row      { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.docs-upload-file-info {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.83rem; color: var(--text-dark);
  background: #f0f4ff; padding: 9px 12px;
  border-radius: 7px; border: 1px solid #c7d2fe;
}
.docs-upload-file-info i { color: var(--primary); font-size: 1rem; }
.docs-file-ext   { background: var(--primary); color: #fff; font-size: 0.6rem; font-weight: 700; padding: 1px 5px; border-radius: 3px; margin-left: 4px; }
.docs-file-size  { color: var(--text-light); font-size: 0.76rem; margin-left: auto; }
.docs-desc-input {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 7px; font-size: 0.85rem; color: var(--text-dark);
  background: #fff; outline: none; transition: border-color 0.2s; box-sizing: border-box;
}
.docs-desc-input:focus { border-color: var(--primary); }
.docs-upload-actions  { display: flex; gap: 8px; }
.docs-upload-progress { display: flex; align-items: center; gap: 10px; }
.docs-progress-bar    { flex: 1; height: 5px; background: #e5e7eb; border-radius: 3px; overflow: hidden; }
.docs-progress-fill   { height: 100%; background: var(--primary); border-radius: 3px; transition: width 0.15s ease; }
.docs-upload-progress span { font-size: 0.76rem; color: var(--text-gray); white-space: nowrap; }

/* ── File + folder list area ────────────────────────────────── */
.docs-file-list       { flex: 1; overflow-y: auto; }
.docs-empty {
  padding: 48px 24px; text-align: center; color: var(--text-gray);
}
.docs-empty i   { font-size: 2.5rem; opacity: 0.2; display: block; margin-bottom: 10px; }
.docs-empty p   { font-size: 0.88rem; margin: 0 0 4px; }

/* Section labels above folders / files */
.docs-section-label {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 20px 8px;
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: #9ca3af;
}
.docs-count-badge {
  background: var(--primary); color: #fff;
  font-size: 0.62rem; font-weight: 700;
  padding: 1px 7px; border-radius: 20px; line-height: 1.6;
}

/* ── Folder grid ────────────────────────────────────────────── */
.docs-folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  padding: 4px 20px 16px;
}
.docs-folder-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  padding: 16px 14px 12px;
  border-radius: 10px;
  border: 1.5px solid #e5e7eb;
  background: #fff;
  cursor: pointer;
  transition: all 0.18s;
  overflow: hidden;
}
.docs-folder-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
  transform: scaleX(0);
  transition: transform 0.18s;
  transform-origin: left;
}
.docs-folder-card:hover {
  border-color: #f59e0b;
  box-shadow: 0 3px 12px rgba(245,158,11,0.15);
  transform: translateY(-1px);
}
.docs-folder-card:hover::before { transform: scaleX(1); }
.docs-folder-card-icon {
  font-size: 2rem;
  color: #f59e0b;
  line-height: 1;
  margin-bottom: 10px;
}
.docs-folder-card-name {
  font-weight: 700; font-size: 0.83rem; color: #1e293b;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  width: 100%;
}
.docs-folder-card-count {
  font-size: 0.7rem; color: #94a3b8; margin-top: 3px;
}
.docs-folder-actions {
  position: absolute; top: 6px; right: 6px;
  display: flex; gap: 3px; align-items: center;
  opacity: 0; transition: opacity 0.15s; z-index: 1;
}
.docs-folder-card:hover .docs-folder-actions { opacity: 1; }
.docs-folder-action-btn {
  width: 22px; height: 22px; border-radius: 50%;
  background: transparent; border: none; cursor: pointer;
  color: #9ca3af; font-size: 0.62rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.docs-folder-rename:hover { background: #ede9fe; color: #7c3aed; }
.docs-folder-delete:hover { background: #fee2e2; color: #dc2626; }

/* ── File rows ──────────────────────────────────────────────── */
.docs-file-table { display: flex; flex-direction: column; padding-bottom: 8px; }
.docs-file-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 20px;
  border-radius: 0;
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.12s;
}
.docs-file-row:last-child   { border-bottom: none; }
.docs-file-row:hover        { background: #f8fafc; }
.docs-file-icon {
  width: 38px; height: 38px; flex-shrink: 0; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}
/* Colored icon backgrounds by type */
.docs-file-icon:has(.fa-file-pdf)   { background: #fef2f2; }
.docs-file-icon:has(.fa-file-word)  { background: #eff6ff; }
.docs-file-icon:has(.fa-file-image) { background: #faf5ff; }
.docs-file-icon:has(.fa-file-alt),
.docs-file-icon:has(.fa-file)       { background: #f8fafc; }
.docs-file-icon .fa-file-pdf        { color: #ef4444; }
.docs-file-icon .fa-file-word       { color: #3b82f6; }
.docs-file-icon .fa-file-image      { color: #8b5cf6; }
.docs-file-icon .fa-file-alt,
.docs-file-icon .fa-file            { color: #94a3b8; }
.docs-file-body        { flex: 1; min-width: 0; }
.docs-file-name        { font-size: 0.85rem; font-weight: 600; color: #1e293b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.docs-file-desc        { font-size: 0.76rem; color: #64748b; margin-top: 1px; }
.docs-file-meta        { font-size: 0.72rem; color: #94a3b8; margin-top: 3px; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.docs-by-admin         { background: #dbeafe; color: #1d4ed8; font-size: 0.6rem; font-weight: 700; padding: 1px 6px; border-radius: 3px; }
.docs-by-agent         { background: #dcfce7; color: #15803d; font-size: 0.6rem; font-weight: 700; padding: 1px 6px; border-radius: 3px; }
.docs-file-actions     { display: flex; gap: 5px; flex-shrink: 0; opacity: 0.3; transition: opacity 0.15s; }
.docs-file-row:hover .docs-file-actions { opacity: 1; }
.btn-outline-danger    { border: 1px solid #fca5a5; color: #ef4444; background: transparent; }
.btn-outline-danger:hover { background: #fee2e2; border-color: #ef4444; color: #dc2626; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .docs-folder-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
/* Back button — hidden on desktop */
.docs-mobile-back { display: none; }

@media (max-width: 768px) {
  /* Two-step mobile flow: agents list first, workspace second */
  .docs-layout               { grid-template-columns: 1fr; min-height: auto; }

  /* Step 1: show agents panel full height, hide workspace */
  .docs-agents-panel         { border-right: none; border-bottom: none; max-height: none; min-height: 60vh; }
  .docs-workspace            { display: none; }

  /* Step 2: when agent is selected — hide agents panel, show workspace */
  .docs-layout.docs-agent-selected .docs-agents-panel { display: none; }
  .docs-layout.docs-agent-selected .docs-workspace    { display: block; }

  /* Show back button only on mobile */
  .docs-mobile-back          { display: inline-flex; margin-right: 6px; padding: 4px 10px; min-height: 32px; }

  .docs-file-row             { padding: 10px 16px; }
  .docs-ws-header            { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
  .docs-upload-zone          { padding: 12px 16px; }
  .docs-folder-grid          { padding: 4px 16px 14px; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .docs-ws-title             { flex-wrap: wrap; gap: 6px; }
  .docs-ws-actions           { width: 100%; }
  .docs-new-folder-btn       { width: 100%; justify-content: center; }
}

@media (max-width: 480px) {
  .docs-agents-panel         { min-height: 70vh; }
  .docs-agent-item           { padding: 12px 14px; }
  .docs-agent-name           { font-size: 0.9rem; }
}

/* ═══════════════════════════════════════════════════════════
   KNOWLEDGE BASE — Rich UI
   ═══════════════════════════════════════════════════════════ */

/* ── Toolbar ─────────────────────────────────────────────────── */
.kb-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.kb-search-wrap {
  position: relative;
  flex: 1;
  min-width: 240px;
  max-width: 460px;
}
.kb-search-wrap i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 0.9rem;
  pointer-events: none;
}
.kb-search-wrap input {
  width: 100%;
  padding: 11px 16px 11px 38px;
  border: 1.5px solid var(--border);
  border-radius: 30px;
  font-size: 0.88rem;
  background: var(--white);
  color: var(--text-dark);
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.kb-search-wrap input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27,58,107,0.1);
}

/* ── Category section ────────────────────────────────────────── */
.kb-category-section { margin-bottom: 44px; }

.kb-category-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding: 14px 20px;
  background: linear-gradient(135deg, rgba(27,58,107,0.05) 0%, rgba(27,58,107,0.02) 100%);
  border-left: 4px solid var(--primary);
  border-radius: 0 10px 10px 0;
}
.kb-category-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 0.88rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(27,58,107,0.25);
}
.kb-category-name {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
  flex: 1;
  letter-spacing: 0.2px;
}
.kb-category-count {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
  background: rgba(27,58,107,0.1);
  border-radius: 30px;
  padding: 3px 12px;
  letter-spacing: 0.3px;
}

/* ── Items grid ──────────────────────────────────────────────── */
.kb-items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

/* ── Item card ───────────────────────────────────────────────── */
.kb-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: box-shadow 0.25s, transform 0.25s;
  position: relative;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.kb-card:hover {
  box-shadow: 0 12px 32px rgba(27,58,107,0.13);
  transform: translateY(-4px);
}

/* Colored banner top — the visual identity of the card */
.kb-card-banner {
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}
.kb-card-banner--thumb { height: 160px; }
.kb-card-banner.pdf     { background: linear-gradient(135deg,#fee2e2,#fecaca); }
.kb-card-banner.doc     { background: linear-gradient(135deg,#dbeafe,#bfdbfe); }
.kb-card-banner.xls     { background: linear-gradient(135deg,#dcfce7,#bbf7d0); }
.kb-card-banner.ppt     { background: linear-gradient(135deg,#ffedd5,#fed7aa); }
.kb-card-banner.article { background: linear-gradient(135deg,#f3e8ff,#e9d5ff); }
.kb-card-banner.video   { background: linear-gradient(135deg,#e0e7ff,#c7d2fe); }
.kb-card-banner.file    { background: linear-gradient(135deg,#f1f5f9,#e2e8f0); }
.kb-card-banner.img     { background: linear-gradient(135deg,#fce7f3,#fbcfe8); }
.kb-card-banner--thumb { padding: 0; overflow: hidden; display: block; }
.kb-card-banner--thumb .kb-banner-badge { background: rgba(0,0,0,0.45); color: #fff; position: absolute; bottom: 8px; left: 10px; }
.kb-thumb-img { width: 100%; height: 100%; object-fit: cover; display: block; position: absolute; top: 0; left: 0; }

.kb-card-banner-icon {
  font-size: 2rem;
  opacity: 0.85;
  transition: transform 0.25s;
}
.kb-card:hover .kb-card-banner-icon { transform: scale(1.12); }

.kb-card-banner.pdf     .kb-card-banner-icon { color: #dc2626; }
.kb-card-banner.doc     .kb-card-banner-icon { color: #1d4ed8; }
.kb-card-banner.xls     .kb-card-banner-icon { color: #15803d; }
.kb-card-banner.ppt     .kb-card-banner-icon { color: #c2410c; }
.kb-card-banner.article .kb-card-banner-icon { color: #7c3aed; }
.kb-card-banner.video   .kb-card-banner-icon { color: #4338ca; }
.kb-card-banner.file    .kb-card-banner-icon { color: #64748b; }
.kb-card-banner.img     .kb-card-banner-icon { color: #db2777; }

/* Type badge pinned bottom-right of banner */
.kb-banner-badge {
  position: absolute;
  bottom: 8px;
  right: 10px;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 30px;
  backdrop-filter: blur(6px);
}
.kb-card-banner.pdf     .kb-banner-badge { background:rgba(220,38,38,0.12);  color:#dc2626; }
.kb-card-banner.doc     .kb-banner-badge { background:rgba(29,78,216,0.12);  color:#1d4ed8; }
.kb-card-banner.xls     .kb-banner-badge { background:rgba(21,128,61,0.12);  color:#15803d; }
.kb-card-banner.ppt     .kb-banner-badge { background:rgba(194,65,12,0.12);  color:#c2410c; }
.kb-card-banner.article .kb-banner-badge { background:rgba(124,58,237,0.12); color:#7c3aed; }
.kb-card-banner.video   .kb-banner-badge { background:rgba(67,56,202,0.12);  color:#4338ca; }
.kb-card-banner.file    .kb-banner-badge { background:rgba(100,116,139,0.12);color:#64748b; }
.kb-card-banner.img     .kb-banner-badge { background:rgba(219,39,119,0.12);  color:#db2777; }

/* Card body */
.kb-card-body {
  padding: 16px 18px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kb-card-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text-dark);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.kb-card-desc {
  font-size: 0.78rem;
  color: var(--text-gray);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.kb-file-size {
  font-size: 0.72rem;
  color: var(--text-light);
  font-weight: 500;
  margin-top: 2px;
}

/* Card footer — action + admin controls */
.kb-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 14px;
  gap: 6px;
}
.kb-card-admin-overlay {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 6px;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s, transform 0.2s;
  z-index: 2;
}
.kb-card:hover .kb-card-admin-overlay {
  opacity: 1;
  transform: translateY(0);
}
.kb-card-admin-overlay button {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.75rem;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  flex-shrink: 0;
}
.kb-card-admin-overlay button:hover { transform: scale(1.12); box-shadow: 0 4px 12px rgba(0,0,0,0.25); }
/* Edit — blue */
.kb-card-admin-overlay button:not(.del):not(.approve) { background: var(--primary); color: #fff; }
/* Delete — red */
.kb-card-admin-overlay button.del { background: var(--danger); color: #fff; }
/* Approve — green */
.kb-card-admin-overlay button.approve { background: #10b981; color: #fff; }

/* ── Empty state ─────────────────────────────────────────────── */
.kb-empty {
  text-align: center;
  padding: 80px 24px;
  color: var(--text-light);
}
.kb-empty-icon {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, rgba(27,58,107,0.06), rgba(27,58,107,0.03));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  font-size: 2rem;
  color: rgba(27,58,107,0.3);
}
.kb-empty h4 {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-gray);
  margin: 0 0 8px;
}
.kb-empty p { font-size: 0.85rem; margin: 0; }

/* ── Type switcher (Add form) ────────────────────────────────── */
.kb-type-tabs {
  display: flex;
  gap: 10px;
  margin: 0 0 24px;
  flex-wrap: wrap;
}
.kb-type-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--white);
  color: var(--text-gray);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  flex: 1;
  min-width: 140px;
  justify-content: center;
}
.kb-type-tab i { font-size: 1rem; }
.kb-type-tab:hover { border-color: var(--primary); color: var(--primary); background: rgba(27,58,107,0.03); }
.kb-type-tab.active {
  border-color: var(--primary);
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: var(--white);
  box-shadow: 0 4px 14px rgba(27,58,107,0.25);
}

/* ── File drop zone ──────────────────────────────────────────── */
.kb-file-drop {
  border: 2px dashed #cbd5e1;
  border-radius: 14px;
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #f8fafc;
}
.kb-file-drop:hover, .kb-file-drop.drag-over {
  border-color: var(--primary);
  background: rgba(27,58,107,0.03);
  box-shadow: 0 0 0 4px rgba(27,58,107,0.06);
}
.kb-file-drop i {
  font-size: 2.4rem;
  color: var(--primary);
  opacity: 0.5;
  margin-bottom: 12px;
  display: block;
  transition: transform 0.2s, opacity 0.2s;
}
.kb-file-drop:hover i { transform: translateY(-4px); opacity: 0.8; }
.kb-file-drop p { font-size: 0.92rem; color: var(--text-dark); margin: 0 0 6px; font-weight: 600; }
.kb-file-drop small { font-size: 0.78rem; color: var(--text-light); }

.kb-file-info {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: linear-gradient(135deg,rgba(27,58,107,0.04),rgba(27,58,107,0.02));
  border: 1.5px solid rgba(27,58,107,0.15);
  border-radius: 12px;
  padding: 4px 12px;
  margin-top: 12px;
}

/* Multi-file staged list rows */
.kb-file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.kb-file-row:last-child { border-bottom: none; }
.kb-file-row-icon { font-size: 1.25rem; flex-shrink: 0; }
.kb-file-row-icon.pdf     { color: #dc2626; }
.kb-file-row-icon.doc     { color: #1d4ed8; }
.kb-file-row-icon.xls     { color: #15803d; }
.kb-file-row-icon.ppt     { color: #c2410c; }
.kb-file-row-icon.img     { color: #db2777; }
.kb-file-row-icon.video   { color: #4338ca; }
.kb-file-row-icon.file    { color: #64748b; }
.kb-file-row-info { flex: 1; min-width: 0; }
.kb-file-row-info .kb-fn { font-weight: 600; font-size: 0.84rem; color: var(--text-dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kb-file-row-info .kb-fs { font-size: 0.73rem; color: var(--text-light); margin-top: 1px; }
.kb-file-row button { flex-shrink: 0; }

/* ── Category manager table ──────────────────────────────────── */
.kb-cats-table { width: 100%; border-collapse: collapse; }
.kb-cats-table th, .kb-cats-table td {
  padding: 12px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.kb-cats-table th {
  background: var(--bg-light);
  font-weight: 700;
  color: var(--text-gray);
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.kb-cats-table tr:hover td { background: rgba(27,58,107,0.02); }

/* ── KB Reader Modal ─────────────────────────────────────────── */
.kb-reader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6,14,30,0.65);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.kb-reader-box {
  background: var(--white);
  border-radius: 20px;
  width: 100%;
  max-width: 860px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 32px 100px rgba(0,0,0,0.35);
  overflow: hidden;
}

/* Modal header — dark gradient band */
.kb-reader-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 28px 32px 24px;
  background: linear-gradient(135deg, #0f1f3d 0%, #1B3A6B 100%);
  flex-shrink: 0;
}
.kb-reader-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 3px 10px;
  border-radius: 30px;
  margin-bottom: 10px;
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.9);
  border: 1px solid rgba(255,255,255,0.2);
}
.kb-reader-header h2 {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--white);
  margin: 0;
  line-height: 1.25;
}
.kb-reader-desc {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.65);
  margin: 8px 0 0;
  line-height: 1.5;
}
.kb-reader-close {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.8);
  flex-shrink: 0;
  transition: background 0.2s;
}
.kb-reader-close:hover { background: rgba(255,255,255,0.25); color: var(--white); }

.kb-reader-body {
  flex: 1;
  overflow-y: auto;
  padding: 36px 40px;
  background: #fafbfd;
}
.kb-reader-body:has(.kb-pdf-embed) { padding: 0; overflow: hidden; }
.kb-pdf-embed { display: flex; flex-direction: column; height: 100%; min-height: 500px; }
.kb-pdf-embed iframe { flex: 1; width: 100%; border: none; min-height: 500px; }
.kb-pdf-fallback { display: none; text-align: center; padding: 32px; }
.kb-pdf-embed iframe:not([src]) + .kb-pdf-fallback,
.kb-pdf-embed:empty .kb-pdf-fallback { display: block; }

/* Article typography — clean document feel */
.kb-article-body {
  font-size: 0.94rem;
  color: #1e293b;
  line-height: 1.85;
  word-break: break-word;
  white-space: pre-wrap;
  max-width: 680px;
}
.kb-article-body h2 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--primary);
  margin: 28px 0 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid rgba(27,58,107,0.1);
}
.kb-article-body h3 {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-dark);
  margin: 20px 0 8px;
}

/* Video embed */
.kb-video-embed {
  aspect-ratio: 16 / 9;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.kb-video-embed iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .kb-items-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
}
@media (max-width: 560px) {
  .kb-items-grid { grid-template-columns: 1fr; }
  .kb-reader-box { max-height: 96vh; border-radius: 14px; }
  .kb-reader-header { padding: 20px 22px 18px; }
  .kb-reader-body { padding: 24px 20px; }
  .kb-reader-header h2 { font-size: 1.15rem; }
  .kb-type-tab { min-width: 100px; padding: 10px 14px; font-size: 0.8rem; }
  .kb-article-body { font-size: 0.88rem; }
}

/* ── Logo Upload (Settings tab) ──────────────────────────────── */
.logo-upload-row {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px;
  background: var(--bg-secondary, #f9fafb);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  margin-bottom: 8px;
}
.logo-preview-wrap {
  flex-shrink: 0;
  width: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.logo-upload-controls {
  flex: 1;
}
.btn-secondary {
  background: #6b7280;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 0.83rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s;
}
.btn-secondary:hover { background: #4b5563; }
.btn-outline-danger {
  background: transparent;
  color: var(--danger, #ef4444);
  border: 1.5px solid var(--danger, #ef4444);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.83rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
}
.btn-outline-danger:hover { background: var(--danger, #ef4444); color: #fff; }

/* ── KB Stats bar ────────────────────────────────────────────── */
.kb-stats-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.kb-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-gray);
  padding: 2px 6px;
}
.kb-stat strong { color: var(--text-dark); font-weight: 700; }
.kb-stat i { font-size: 0.8rem; }
.kb-stat-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
}

/* ── KB Filter bar ───────────────────────────────────────────── */
.kb-filter-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 28px;
}
.kb-cat-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.kb-cat-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border: 1.5px solid var(--border);
  border-radius: 30px;
  background: var(--white);
  color: var(--text-gray);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
}
.kb-cat-tab:hover { border-color: var(--primary); color: var(--primary); background: rgba(27,58,107,0.04); }
.kb-cat-tab.active { background: var(--primary); color: var(--white); border-color: var(--primary); font-weight: 600; }
.kb-cat-tab i { font-size: 0.75rem; opacity: 0.8; }

.kb-type-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.kb-type-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 14px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: var(--white);
  color: var(--text-gray);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
}
.kb-type-chip:hover { border-color: var(--primary); color: var(--primary); }
.kb-type-chip.active { background: rgba(27,58,107,0.08); border-color: var(--primary); color: var(--primary); font-weight: 700; }
.kb-type-chip i { font-size: 0.75rem; }

/* ── KB Collapse ─────────────────────────────────────────────── */
.kb-category-header--toggle { transition: background 0.18s; }
.kb-category-header--toggle:hover { background: linear-gradient(135deg, rgba(27,58,107,0.08) 0%, rgba(27,58,107,0.04) 100%); }
.kb-collapse-icon {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--primary);
  opacity: 0.6;
  transition: transform 0.2s;
}
.kb-collapsed-hint {
  padding: 10px 20px;
  font-size: 0.78rem;
  color: var(--text-light);
  font-style: italic;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 24px;
}

/* ── Export / Publish tab ────────────────────────────────────── */
.export-live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #16a34a;
  background: #dcfce7;
  border-radius: 30px;
  padding: 4px 12px;
  letter-spacing: 0.3px;
}
.export-live-badge i { font-size: 0.5rem; animation: pulse-dot 1.8s ease-in-out infinite; }
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

.export-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding: 24px;
}
.export-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--white);
  transition: box-shadow 0.2s, border-color 0.2s;
}
.export-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.07); border-color: var(--primary-light, #4a72b0); }
.export-card-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.export-card-body { flex: 1; min-width: 0; }
.export-card-title { font-weight: 700; font-size: 0.88rem; color: var(--text-dark); margin-bottom: 2px; }
.export-card-desc  { font-size: 0.76rem; color: var(--text-gray); line-height: 1.4; }

/* ══════════════════════════════════════════════════════════════
   LEADS CRM
══════════════════════════════════════════════════════════════ */

/* Nav badge */
.nav-badge {
  display: inline-block;
  background: #EF4444;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 10px;
  margin-left: 4px;
  vertical-align: middle;
  line-height: 1.4;
}

/* Pipeline bar */
.leads-pipeline {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--white);
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 16px 24px;
  margin-bottom: 18px;
  overflow-x: auto;
}
.pipeline-total {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 70px;
  padding-right: 20px;
  margin-right: 20px;
  border-right: 1px solid var(--border);
}
.pipeline-total-num {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}
.pipeline-total-lbl { font-size: 0.7rem; color: var(--text-gray); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 3px; }
.pipeline-stages { display: flex; gap: 4px; flex: 1; }
.pipeline-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 72px;
  padding: 6px 4px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s;
}
.pipeline-stage:hover { background: rgba(27,58,107,0.05); }
.pipeline-stage-bar { width: 100%; height: 4px; border-radius: 2px; margin-bottom: 6px; }
.pipeline-stage-count { font-family: var(--font-heading); font-size: 1.3rem; font-weight: 700; line-height: 1; }
.pipeline-stage-label { font-size: 0.65rem; color: var(--text-gray); text-align: center; margin-top: 3px; white-space: nowrap; }

/* Toolbar */
.leads-toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.leads-search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.leads-search-wrap i {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-gray);
  font-size: 0.8rem;
}
.leads-search-wrap input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.86rem;
  background: var(--white);
  color: var(--text-dark);
  transition: border-color 0.2s;
}
.leads-search-wrap input:focus { outline: none; border-color: var(--primary); }
.leads-filter-select {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.84rem;
  background: var(--white);
  color: var(--text-dark);
  cursor: pointer;
  min-width: 140px;
}

/* Table */
.leads-table td { vertical-align: middle; }
.leads-row { cursor: pointer; transition: background 0.15s; }
.leads-row:hover { background: rgba(27,58,107,0.04); }
.lead-name { font-weight: 600; font-size: 0.88rem; color: var(--text-dark); }
.lead-property { font-size: 0.75rem; color: var(--text-gray); margin-top: 2px; display: flex; align-items: center; gap: 4px; }
.lead-property i { color: var(--accent); font-size: 0.65rem; }
.lead-contact-line { font-size: 0.78rem; color: var(--text-gray); display: flex; align-items: center; gap: 5px; margin-bottom: 2px; }
.lead-contact-line i { width: 12px; color: var(--accent); font-size: 0.65rem; }
.lead-source-badge {
  display: inline-block;
  background: rgba(27,58,107,0.08);
  color: var(--primary);
  font-size: 0.71rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
}
.lead-status-chip {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
}
.lead-agent-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 0.8rem; color: var(--primary); font-weight: 600; }
.lead-agent-tag i { font-size: 0.7rem; color: var(--accent); }
.lead-unassigned { font-size: 0.78rem; color: var(--text-gray); font-style: italic; }
.lead-date { font-size: 0.78rem; color: var(--text-gray); white-space: nowrap; }

/* New lead highlight */
.lead-row-new { background: rgba(59,130,246,0.04); }
.lead-row-new:hover { background: rgba(59,130,246,0.08) !important; }
.lead-row-new .lead-name { font-weight: 700; }
.lead-new-dot {
  display: inline-block;
  width: 7px; height: 7px;
  background: #3B82F6;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  flex-shrink: 0;
}

/* ── Leads Pager ─────────────────────────────────────────── */
.leads-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-light);
  gap: 12px;
  flex-wrap: wrap;
}
.leads-pager-info { font-size: 0.82rem; color: var(--text-gray); white-space: nowrap; }
.leads-pager-label { font-size: 0.82rem; color: var(--text-gray); white-space: nowrap; }
.leads-pager-controls { display: flex; align-items: center; gap: 4px; }
.leads-pager-btn {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  background: var(--white);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem; color: var(--text-dark);
  cursor: pointer; transition: all 0.15s;
}
.leads-pager-btn:hover:not(:disabled) { background: var(--primary); color: var(--white); border-color: var(--primary); }
.leads-pager-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.leads-pager-pages { display: flex; align-items: center; gap: 3px; }
.leads-page-btn {
  min-width: 32px; height: 32px; padding: 0 6px;
  border: 1px solid var(--border); background: var(--white);
  border-radius: var(--radius-sm); font-size: 0.82rem; font-weight: 600;
  color: var(--text-dark); cursor: pointer; transition: all 0.15s;
}
.leads-page-btn:hover { background: var(--bg-light); }
.leads-page-btn.active { background: var(--primary); color: var(--white); border-color: var(--primary); }
.leads-page-ellipsis { font-size: 0.82rem; color: var(--text-gray); padding: 0 2px; line-height: 32px; }

/* Lead modal */
.modal-xl { max-width: 900px; }
.modal-box {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 560px;
  overflow: hidden;
}
.modal-xl { max-width: 700px; }
.lead-modal-box { padding: 0; overflow: hidden; border-radius: 14px; }

/* Header */
.lead-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  background: var(--primary);
  color: #fff;
  gap: 12px;
}
.lead-modal-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.lead-modal-header-icon {
  font-size: 2rem;
  opacity: 0.85;
  flex-shrink: 0;
}
.lead-modal-name {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  margin: 0 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lead-modal-header-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.lead-modal-date { font-size: 0.75rem; color: rgba(255,255,255,0.7); }
.lead-modal-header .lead-source-badge {
  background: rgba(255,255,255,0.18);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
}
.lead-modal-close-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.12);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: background 0.15s, border-color 0.15s;
}
.lead-modal-close-btn:hover {
  background: rgba(255,255,255,0.25);
  border-color: rgba(255,255,255,0.6);
}

/* Body layout */
.lead-modal-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
}

/* Left pane */
.lead-modal-info {
  padding: 22px 24px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  max-height: calc(90vh - 72px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.lead-info-card {
  background: #f8f9fb;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.lead-info-card .lead-modal-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.lead-info-card .lead-modal-label i { color: var(--accent); font-size: 0.7rem; }

/* Right pane */
.lead-modal-crm {
  padding: 22px 22px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  max-height: calc(90vh - 72px);
  border-left: none;
}
.lead-modal-crm .lead-modal-label {
  display: flex;
  align-items: center;
  gap: 6px;
}
.lead-modal-crm .lead-modal-label i { color: var(--accent); }

/* Contact links */
.lead-modal-contact { display: flex; flex-direction: column; gap: 7px; }
.lead-contact-link {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.87rem; color: var(--primary); text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}
.lead-contact-link:hover { color: var(--accent); }
.lead-contact-link i { width: 15px; color: var(--accent); font-size: 0.8rem; }

/* Property row */
.lead-modal-property {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.84rem; color: var(--primary); font-weight: 500;
  background: rgba(212,167,70,0.1);
  border: 1px solid rgba(212,167,70,0.3);
  padding: 9px 14px; border-radius: 10px;
}
.lead-modal-property i { color: var(--accent); flex-shrink: 0; }

/* Text fields */
.lead-modal-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-gray); margin: 0 0 4px; }
.lead-modal-value { font-size: 0.87rem; color: var(--text-dark); margin: 0; line-height: 1.65; }
.lead-modal-message { white-space: pre-wrap; word-break: break-word; max-height: 150px; overflow-y: auto; }

/* Status picker */
.lead-status-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.status-pick-btn {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1.5px solid rgba(100,116,139,0.25);
  cursor: pointer;
  background: #f1f5f9;
  color: #475569;
  transition: all 0.15s;
}
.status-pick-btn:hover { background: rgba(100,116,139,0.15); border-color: rgba(100,116,139,0.4); }
.status-pick-btn.active {
  background: var(--sc, #3B82F6);
  color: #fff;
  border-color: var(--sc, #3B82F6);
}

/* Actions */
.lead-modal-actions { display: flex; gap: 8px; margin-top: 20px; align-items: center; }
.lead-modal-actions .btn-primary { flex: 1; justify-content: center; }
.lead-save-result { margin-top: 10px; font-size: 0.85rem; text-align: center; min-height: 20px; }

@media (max-width: 700px) {
  .lead-modal-layout { grid-template-columns: 1fr; }
  .lead-modal-info { border-right: none; border-bottom: 1px solid var(--border); max-height: none; }
  .leads-pipeline { flex-direction: column; gap: 12px; }
  .pipeline-total { border-right: none; border-bottom: 1px solid var(--border); padding-right: 0; margin-right: 0; padding-bottom: 12px; margin-bottom: 8px; }
}

/* ── Tasks Tab ──────────────────────────────────────────────── */
.tasks-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.tasks-page-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-dark);
}
.tasks-page-title i { color: #f59e0b; }
.tasks-page-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.tasks-filter-bar {
  display: flex;
  gap: 4px;
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 3px;
}
.tasks-filter-btn {
  padding: 5px 14px;
  border-radius: 18px;
  border: none;
  background: transparent;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-gray);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.tasks-filter-btn:hover  { color: var(--primary); }
.tasks-filter-btn.active { background: var(--white); color: var(--primary); font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,0.1); }

/* Status inline select in table */
.tasks-status-select {
  font-size: 0.73rem;
  font-weight: 600;
  padding: 4px 22px 4px 10px;
  border-radius: 20px;
  border: 1.5px solid;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%236b7280'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  min-width: 110px;
  transition: all 0.15s;
}
.tasks-status-select:focus { outline: none; box-shadow: 0 0 0 2px rgba(99,102,241,0.2); }

/* Lead chip */
.task-lead-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.73rem;
  font-weight: 500;
  background: #e0e7ff;
  color: #4338ca;
  border-radius: 20px;
  padding: 3px 10px;
  cursor: pointer;
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid #c7d2fe;
  transition: background 0.15s;
}
.task-lead-chip:hover { background: #c7d2fe; }

/* ── #1 Dashboard Date Range Filter ────────────────────────── */
.dash-range-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.dash-range-label { font-size: 0.8rem; color: var(--text-gray); display: flex; align-items: center; gap: 6px; }
.dash-range-btns  { display: flex; gap: 6px; flex-wrap: wrap; }
.dash-range-btn {
  padding: 4px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  font-size: 0.77rem;
  font-weight: 500;
  color: var(--text-gray);
  cursor: pointer;
  transition: all 0.15s;
}
.dash-range-btn:hover  { border-color: var(--primary); color: var(--primary); }
.dash-range-btn.active { border-color: var(--primary); background: var(--primary); color: #fff; }

/* ── #4 & #14 Dashboard Charts Row ─────────────────────────── */
.dash-charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
.dash-chart-card { overflow: hidden; }
.chart-empty-msg {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  font-size: 0.82rem;
  gap: 6px;
}
.chart-empty-msg i { font-size: 1.6rem; opacity: 0.4; }
@media (max-width: 768px) { .dash-charts-row { grid-template-columns: 1fr; } }

/* ── Mobile Responsiveness Fixes ──────────────────────────── */

/* Export grid — was missing all mobile rules */
@media (max-width: 768px) {
  .export-grid { grid-template-columns: 1fr; padding: 14px; gap: 10px; }
}
@media (max-width: 480px) {
  .export-grid { padding: 10px; }
}

/* Settings subnav — allow wrapping on small screens */
@media (max-width: 600px) {
  .settings-subnav { padding: 0 10px; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .settings-subnav .stab { padding: 10px 12px 9px; font-size: 0.78rem; }
}

/* Lead modal — extend collapse to 768px, not just 700px */
@media (max-width: 768px) {
  .lead-modal-layout { grid-template-columns: 1fr; }
  .lead-modal-info { border-right: none; border-bottom: 1px solid var(--border); max-height: none; }
}

/* Modal — add 480px coverage */
@media (max-width: 480px) {
  .modal-box, .modal-content { width: 98vw; max-width: 98vw; padding: 16px 12px; margin: 6px; border-radius: 10px; }
  .lead-modal-actions { flex-direction: column; }
  .lead-modal-actions .btn { width: 100%; justify-content: center; }
}

/* Inline form-grid overrides — force 1-col on mobile */
.form-grid-2col { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 768px) {
  .form-grid[style] { grid-template-columns: 1fr !important; }
  .form-grid-2col { grid-template-columns: 1fr; }
}

/* Quick actions — stack to single column on very small screens */
@media (max-width: 380px) {
  .quick-action-btn { min-width: 100%; }
  .quick-actions { flex-direction: column; }
}

/* Performance tiles — single column at xsmall */
@media (max-width: 380px) {
  .perf-tiles { grid-template-columns: 1fr; }
  .perf-tile { border-right: none; border-top: 1px solid var(--border); }
  .perf-tile:first-child { border-top: none; }
}

/* KB cards — xsmall breakpoint */
@media (max-width: 380px) {
  .kb-items-grid { grid-template-columns: 1fr; gap: 10px; }
}

/* Dashboard charts row — 480px polish */
@media (max-width: 480px) {
  .dash-charts-row { gap: 12px; }
  .dash-range-bar select, .dash-range-bar button { font-size: 0.8rem; padding: 6px 10px; }
}

/* Leads pipeline — mobile padding reduction */
@media (max-width: 480px) {
  .leads-pipeline { padding: 10px 12px; gap: 8px; font-size: 0.8rem; }
  .pipeline-stat-val { font-size: 1.1rem; }
}

/* Dashboard bottom — stack fully on mobile */
@media (max-width: 768px) {
  .dashboard-bottom { grid-template-columns: 1fr; gap: 16px; }
}

/* Perf rank banner — stack on small phones */
@media (max-width: 480px) {
  .perf-rank-banner { flex-wrap: wrap; padding: 12px 16px; gap: 8px; }
  .perf-rank-medal  { width: 36px; height: 36px; font-size: 1.1rem; }
  .perf-rank-text   { font-size: 0.9rem; }
}

/* DB status panel — tighten on mobile */
@media (max-width: 480px) {
  .db-status-panel  { padding: 14px; }
  .db-status-row    { flex-direction: column; gap: 10px; }
  .db-count-item    { min-width: 80px; padding: 12px 14px; }
  .db-count-num     { font-size: 1.2rem; }
}

/* Agent leaderboard card — ensure full-width on mobile */
@media (max-width: 768px) {
  #dash-sold-leaderboard { margin-bottom: 16px; }
}

/* ── #3 Tasks Widget ────────────────────────────────────────── */
.dash-task-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.dash-task-row:last-child { border-bottom: none; }
.dash-task-row:hover { background: var(--bg-light); }
.dash-task-check {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  color: var(--text-light);
  flex-shrink: 0;
  margin-top: 2px;
}
.dash-task-check:hover i { color: #22c55e !important; }
.dash-task-body { flex: 1; min-width: 0; }
.dash-task-title { font-size: 0.85rem; font-weight: 500; color: var(--text-dark); }
.dash-task-desc  { font-size: 0.75rem; color: var(--text-gray); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-task-meta  { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.dash-task-prio  { font-size: 0.72rem; font-weight: 600; text-transform: capitalize; }
.dash-task-due   { font-size: 0.72rem; color: var(--text-gray); }
.dash-task-due.overdue { color: var(--danger); font-weight: 600; }
.dash-task-actions { display: flex; gap: 4px; flex-shrink: 0; opacity: 0; transition: opacity 0.15s; }
.dash-task-row:hover .dash-task-actions { opacity: 1; }

/* ── #15 Lead Notes ─────────────────────────────────────────── */
.lead-note-row {
  background: var(--bg-light);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 6px;
}
.lead-note-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.lead-note-author { font-size: 0.75rem; font-weight: 600; color: var(--primary); flex: 1; }
.lead-note-time   { font-size: 0.7rem; color: var(--text-gray); }
.lead-note-del    { background: none; border: none; cursor: pointer; color: var(--text-light); padding: 0 2px; font-size: 0.7rem; }
.lead-note-del:hover { color: var(--danger); }
.lead-note-text   { font-size: 0.82rem; color: var(--text-dark); white-space: pre-wrap; word-break: break-word; }

/* ── #37 Role Permissions UI ────────────────────────────────── */
/* Legacy pill-style kept for fallback */
.role-perm-block  { margin-bottom: 18px; }
.role-perm-title  { font-weight: 600; font-size: 0.85rem; color: var(--text-dark); margin-bottom: 8px; }
.role-perm-checks { display: flex; flex-wrap: wrap; gap: 6px; }
.role-perm-check  {
  display: flex; align-items: center; gap: 6px; padding: 4px 10px;
  background: var(--bg-light); border: 1px solid var(--border); border-radius: 20px;
  font-size: 0.78rem; cursor: pointer; transition: all 0.15s;
}
.role-perm-check:has(input:checked) { border-color: var(--primary); background: rgba(99,102,241,0.08); color: var(--primary); }
.role-perm-check input { accent-color: var(--primary); }

/* ── Permission Matrix Table ──────────────────────────────────── */
.perm-matrix-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.perm-matrix-table th,
.perm-matrix-table td { padding: 9px 14px; border: 1px solid var(--border); }
.perm-role-header { text-align: center; font-weight: 700; font-size: 0.82rem; background: #f8fafc; color: var(--text-dark); }
.perm-col-header  { text-align: center; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-gray); background: #f8fafc; width: 60px; }
[data-theme="dark"] .perm-role-header,
[data-theme="dark"] .perm-col-header { background: #1e293b; }
.perm-feature-label { font-weight: 600; min-width: 140px; }
.perm-feature-label .fas { width: 16px; opacity: .55; margin-right: 6px; }
.perm-write-hint { font-size: 0.72rem; color: var(--text-gray); font-weight: 400; margin-top: 2px; }
.perm-cell { text-align: center; vertical-align: middle; }
.perm-cb { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.perm-matrix-note { font-size: 0.78rem; color: var(--text-gray); margin-top: 12px; line-height: 1.6; }
.perm-matrix-note .fas { margin-right: 5px; color: #6366f1; }

/* ── Dashboard Performance Metrics ──────────────────────────── */

/* Summary strip (admin) */
.perf-summary-strip {
  display: flex;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}
.perf-summary-item {
  flex: 1;
  min-width: 90px;
  text-align: center;
  padding: 14px 10px;
  border-right: 1px solid var(--border);
}
.perf-summary-item:last-child { border-right: none; }
.perf-summary-val {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}
.perf-summary-lbl {
  font-size: 0.7rem;
  color: var(--text-gray);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Table */
.perf-table-wrap { overflow-x: auto; }
.perf-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.perf-table th {
  padding: 8px 12px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-gray);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.perf-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.perf-table tbody tr:last-child td { border-bottom: none; }
.perf-table tbody tr:hover { background: rgba(99,102,241,0.04); }

/* Rank + name merged cell */
.perf-agent-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.perf-medal { font-size: 1.15rem; line-height: 1; flex-shrink: 0; }
.perf-rank-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-gray);
  flex-shrink: 0;
}
.perf-agent-name { font-weight: 500; color: var(--text); }

/* Number columns — headers AND cells both right-aligned */
.perf-num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.perf-table th.perf-num { text-align: right; }
.perf-won      { color: #10b981 !important; }
.perf-lost     { color: #ef4444 !important; }
.perf-pipeline { color: #6366f1 !important; }
.perf-rate-na  { color: var(--text-gray); }
.perf-rate     { font-weight: 700; }

/* Bar cell */
.perf-bar-cell { min-width: 90px; padding-right: 16px !important; }
.perf-bar {
  display: flex;
  height: 6px;
  border-radius: 4px;
  overflow: hidden;
  background: #e2e8f0;
  gap: 1px;
}
.perf-bar-seg { border-radius: 2px; }
.perf-bar-seg.won  { background: #10b981; }
.perf-bar-seg.lost { background: #ef4444; }
.perf-bar-seg.open { background: #cbd5e1; }

/* Agent personal stats (agent/marketing role) */
.perf-agent-stats {
  display: flex;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}
.perf-agent-stat {
  flex: 1;
  min-width: 90px;
  text-align: center;
  padding: 14px 8px;
  border-right: 1px solid var(--border);
}
.perf-agent-stat:last-child { border-right: none; }
.perf-agent-stat-val {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}
.perf-agent-stat-lbl {
  font-size: 0.7rem;
  color: var(--text-gray);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.perf-agent-stat-won  .perf-agent-stat-val { color: #10b981; }
.perf-agent-stat-lost .perf-agent-stat-val { color: #ef4444; }
.perf-agent-stat-open .perf-agent-stat-val { color: #6366f1; }
.perf-agent-stat-rate .perf-agent-stat-val { color: #f59e0b; }

/* ── Calendar Tab ────────────────────────────────────────────── */
.cal-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.cal-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
/* Color chip: colored left border + subtle tinted bg */
.cal-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text);
  background: color-mix(in srgb, var(--chip) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--chip) 30%, transparent);
  white-space: nowrap;
}
.cal-chip::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--chip);
  flex-shrink: 0;
}

/* Card wrapper */
.cal-card { padding: 20px 24px 24px; }

/* ── FullCalendar overrides ───────────────────────────────────── */

/* Toolbar nav buttons (prev / next / today) */
#drs-calendar .fc-button {
  background: #fff !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  font-size: 0.8rem !important;
  font-weight: 500 !important;
  padding: 5px 13px !important;
  border-radius: 6px !important;
  text-transform: capitalize !important;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05) !important;
  transition: background 0.15s, border-color 0.15s !important;
}
#drs-calendar .fc-button:hover {
  background: var(--bg) !important;
  border-color: var(--primary) !important;
  color: var(--primary) !important;
}
#drs-calendar .fc-button:focus { box-shadow: none !important; }

/* Active view button (Month / Week / Agenda active state) */
#drs-calendar .fc-button-active {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
}
#drs-calendar .fc-button-active:hover { opacity: 0.9 !important; color: #fff !important; }

/* Group the view-toggle buttons together */
#drs-calendar .fc-button-group .fc-button { border-radius: 0 !important; }
#drs-calendar .fc-button-group .fc-button:first-child { border-radius: 6px 0 0 6px !important; }
#drs-calendar .fc-button-group .fc-button:last-child  { border-radius: 0 6px 6px 0 !important; }

/* Month/year title */
#drs-calendar .fc-toolbar-title {
  font-size: 1.05rem !important;
  font-weight: 700 !important;
  color: var(--text) !important;
}
#drs-calendar .fc-toolbar { gap: 10px; align-items: center; }
#drs-calendar .fc-toolbar.fc-header-toolbar { margin-bottom: 16px !important; }

/* Day-of-week header */
#drs-calendar .fc-col-header-cell {
  background: var(--bg) !important;
  padding: 8px 0 !important;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-gray);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
#drs-calendar .fc-col-header-cell-cushion { color: inherit !important; }

/* Day cells */
#drs-calendar .fc-daygrid-day-number {
  font-size: 0.8rem;
  color: var(--text-gray);
  padding: 6px 8px !important;
}
#drs-calendar .fc-day-other .fc-daygrid-day-number { color: #c0c8d8; }

/* Today highlight */
#drs-calendar .fc-day-today { background: rgba(99,102,241,0.05) !important; }
#drs-calendar .fc-day-today .fc-daygrid-day-number {
  color: var(--primary) !important;
  font-weight: 700;
  background: var(--primary);
  color: #fff !important;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px;
  padding: 0 !important;
}

/* Events */
#drs-calendar .fc-event {
  border-radius: 5px !important;
  border: none !important;
  font-size: 0.75rem !important;
  font-weight: 500 !important;
  padding: 2px 6px !important;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
#drs-calendar .fc-event:hover { filter: brightness(1.1); box-shadow: 0 2px 6px rgba(0,0,0,0.18); }
#drs-calendar .fc-daygrid-event-dot { display: none; }

/* "+N more" link */
#drs-calendar .fc-more-link {
  font-size: 0.7rem;
  color: var(--primary);
  font-weight: 600;
  padding: 1px 4px;
}

/* Grid borders */
#drs-calendar .fc-scrollgrid { border-color: var(--border) !important; }
#drs-calendar .fc-scrollgrid td, #drs-calendar .fc-scrollgrid th { border-color: var(--border) !important; }

/* List view */
#drs-calendar .fc-list-event:hover td { background: rgba(99,102,241,0.05) !important; }
#drs-calendar .fc-list-day-cushion {
  background: var(--bg) !important;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-gray);
  padding: 8px 14px !important;
}
#drs-calendar .fc-list-event-title { font-size: 0.85rem; }
#drs-calendar .fc-list-event-dot { border-color: transparent !important; }
#drs-calendar .fc-list-empty { padding: 40px !important; color: var(--text-gray); text-align: center; }

/* ── Task assignee-only banner ───────────────────────────────── */
.task-assignee-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.82rem;
  color: #1e40af;
  margin-bottom: 12px;
}
.task-assignee-banner i { flex-shrink: 0; }

/* Disabled task modal fields — show as read-only, not greyed-out */
#task-modal input:disabled,
#task-modal select:disabled,
#task-modal textarea:disabled {
  background: var(--bg);
  color: var(--text-gray);
  cursor: not-allowed;
  opacity: 0.85;
  border-color: var(--border);
}

/* ── Auth loading screen ─────────────────────────────────────── */
#page-loader {
  position: fixed;
  inset: 0;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.page-loader-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.page-loader-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e2e8f0;
  border-top-color: var(--primary, #6366f1);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Idle session warning modal ──────────────────────────────── */
#idle-warn-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}
.idle-warn-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(2px);
}
.idle-warn-box {
  position: relative;
  background: #fff;
  border-radius: 16px;
  padding: 2.5rem 2rem 2rem;
  max-width: 380px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  animation: idlePopIn 0.25s ease;
}
@keyframes idlePopIn {
  from { opacity: 0; transform: scale(0.88) translateY(16px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}
.idle-warn-icon {
  font-size: 2.5rem;
  color: var(--primary, #6366f1);
  margin-bottom: 0.75rem;
}
.idle-warn-box h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-dark, #1e293b);
  margin: 0 0 0.5rem;
}
.idle-warn-box p {
  font-size: 0.9rem;
  color: var(--text-gray, #64748b);
  margin: 0 0 1.5rem;
  line-height: 1.5;
}
.idle-warn-box p strong {
  color: var(--text-dark, #1e293b);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}
.idle-warn-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}
.idle-warn-actions .btn {
  min-width: 130px;
}

/* ── Leads bulk action bar ───────────────────────────────────── */
.bulk-action-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 20px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  margin-bottom: 12px;
}
.bulk-count {
  font-weight: 600;
  font-size: 0.85rem;
  color: #1d4ed8;
  white-space: nowrap;
}

/* ── Notification bell ───────────────────────────────────────── */
.notif-bell-wrap {
  position: relative;
}
.notif-bell-btn {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-gray, #64748b);
  font-size: 1rem;
  transition: background 0.15s, color 0.15s;
}
.notif-bell-btn:hover { background: #f1f5f9; color: var(--primary, #6366f1); }
.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: #ef4444;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  line-height: 1;
}
.notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 300px;
  background: #fff;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.14);
  z-index: 500;
  overflow: hidden;
}
.notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border, #e2e8f0);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-dark, #1e293b);
}
.notif-clear-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--primary, #6366f1);
  padding: 0;
}
.notif-panel-body { padding: 6px 0; max-height: 300px; overflow-y: auto; }
.notif-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}
.notif-item:hover { background: #f8fafc; }
.notif-item-icon { font-size: 1rem; width: 20px; flex-shrink: 0; }
.notif-item-text { flex: 1; font-size: 0.82rem; color: var(--text-dark, #1e293b); line-height: 1.3; }
.notif-item-arrow { font-size: 0.65rem; color: var(--text-light, #94a3b8); }
.notif-empty {
  padding: 20px 16px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-gray, #64748b);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.notif-empty i { color: #10b981; }

/* ── Global search palette ───────────────────────────────────── */
#global-search-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
  z-index: 10000;
}
.gs-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15,31,61,0.5);
  backdrop-filter: blur(3px);
}
.gs-palette {
  position: relative;
  width: 580px;
  max-width: 94vw;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.22);
  overflow: hidden;
  animation: idlePopIn 0.2s ease;
}
.gs-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border, #e2e8f0);
}
.gs-icon { color: var(--text-gray); font-size: 0.95rem; flex-shrink: 0; }
.gs-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 0.95rem;
  color: var(--text-dark);
  background: transparent;
}
.gs-esc {
  font-size: 0.7rem;
  color: var(--text-gray);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  cursor: pointer;
  flex-shrink: 0;
}
.gs-results { max-height: 420px; overflow-y: auto; padding: 6px 0; }
.gs-hint {
  padding: 14px 16px;
  font-size: 0.82rem;
  color: var(--text-gray);
}
.gs-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
}
.gs-item:hover { background: #f8fafc; }
.gs-item-icon { width: 28px; height: 28px; border-radius: 6px; background: #f1f5f9; display: flex; align-items: center; justify-content: center; font-size: 0.78rem; flex-shrink: 0; }
.gs-item-body { flex: 1; min-width: 0; }
.gs-item-label { display: block; font-size: 0.87rem; font-weight: 600; color: var(--text-dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-item-sub { display: block; font-size: 0.75rem; color: var(--text-gray); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-item-arrow { font-size: 0.65rem; color: var(--text-light); flex-shrink: 0; }

/* Settings sub-tabs */
/* Settings sub-tabs */
.settings-subnav {
  display: flex;
  gap: 2px;
  padding: 0 24px;
  border-bottom: 2px solid #e8edf2;
  flex-wrap: wrap;
  background: #fafbff;
}
.settings-subnav .stab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 13px 16px 11px;
  border: none;
  background: none;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-gray);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  border-radius: 0;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.settings-subnav .stab i { font-size: 0.78rem; opacity: 0.75; }
.settings-subnav .stab:hover { color: var(--primary); background: #f0f4ff; }
.settings-subnav .stab.active { color: var(--primary); border-bottom-color: var(--primary); background: #fff; }
.settings-subnav .stab.active i { opacity: 1; }

/* Stab panels */
.stab-panel { padding: 0; }
.stab-panel.hidden { display: none; }
/* Section labels break out of inner content padding to run full width */
.stab-panel .form-section-label { margin: 0; }
/* Content areas inside panels get consistent padding */
.stab-panel-body { padding: 20px 24px; }
.stab-panel-body + .form-section-label { margin-top: 0; }

/* Upload placeholder — shown when no image is set */
.upload-placeholder {
  width: 120px;
  height: 64px;
  flex-shrink: 0;
  border-radius: 6px;
  border: 1.5px dashed #c8d3dd;
  background: #f4f7fa url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23b0bec5' stroke-width='1.5'%3E%3Crect x='3' y='3' width='18' height='18' rx='2'/%3E%3Ccircle cx='8.5' cy='8.5' r='1.5'/%3E%3Cpath d='m21 15-5-5L5 21'/%3E%3C/svg%3E") center/26px no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
}
.upload-placeholder.sq { width: 64px; height: 64px; }
.upload-placeholder.wide { width: 140px; height: 64px; }

/* Save footer inside each panel */
.stab-save-footer {
  padding: 16px 24px;
  border-top: 1px solid #e8edf2;
  background: #fafbff;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
}
.stab-save-footer .hint { font-size: 0.8rem; color: var(--text-light); }

/* City card editor rows */
.city-editor-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid #e8edf2;
  border-radius: 8px;
  margin-bottom: 8px;
  background: #fafbfc;
}
.city-editor-thumb {
  width: 80px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 5px;
  border: 1px dashed #ccd5de;
  background: #f0f4f8 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23b0bec5' stroke-width='2'%3E%3Crect x='3' y='3' width='18' height='18' rx='2'/%3E%3Ccircle cx='8.5' cy='8.5' r='1.5'/%3E%3Cpath d='m21 15-5-5L5 21'/%3E%3C/svg%3E") center/20px no-repeat;
  object-fit: cover;
}
.city-editor-thumb.has-img {
  border-style: solid;
  border-color: #e0e0e0;
  background-color: #f0f0f0;
  background-image: none;
}
.city-editor-row .form-group { flex: 1; margin: 0; }

/* ============================================================
   HELP CENTER
   ============================================================ */
.help-hero {
  text-align: center;
  padding: 36px 20px 28px;
  margin-bottom: 24px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: var(--radius);
  color: var(--white);
}
.help-hero-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}
.help-hero h2 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0 0 6px;
}
.help-hero p {
  color: rgba(255,255,255,0.78);
  font-size: 0.9rem;
  margin: 0 0 22px;
}
.help-search-wrap {
  position: relative;
  max-width: 560px;
  margin: 0 auto;
}
.help-search-wrap i.fa-search {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 0.9rem;
}
.help-search-wrap input {
  width: 100%;
  padding: 14px 44px;
  border: none;
  border-radius: 30px;
  font-size: 0.92rem;
  outline: none;
  box-shadow: 0 6px 24px rgba(0,0,0,0.18);
  color: var(--text-dark);
  background: var(--white);
}
.help-search-clear {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg);
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-gray);
  cursor: pointer;
  font-size: 0.7rem;
}
.help-search-clear:hover { background: var(--border); }

.help-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 900px) {
  .help-layout { grid-template-columns: 1fr; }
}

/* ── Left nav ── */
.help-nav {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px;
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
}
.help-nav-cat { border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 3px; }
.help-nav-cat-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.help-nav-cat-header:hover { background: var(--bg); }
.help-nav-cat-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  flex-shrink: 0;
}
.help-nav-cat-label {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-dark);
}
.help-nav-chevron {
  font-size: 0.7rem;
  color: var(--text-light);
  transition: transform 0.2s;
}
.help-nav-cat.open .help-nav-chevron { transform: rotate(180deg); }
.help-nav-articles {
  display: none;
  flex-direction: column;
  padding: 2px 0 6px 48px;
}
.help-nav-cat.open .help-nav-articles { display: flex; }
.help-nav-art {
  background: none;
  border: none;
  text-align: left;
  padding: 7px 10px;
  font-size: 0.81rem;
  color: var(--text-gray);
  border-radius: 6px;
  cursor: pointer;
  line-height: 1.4;
}
.help-nav-art:hover { background: var(--bg); color: var(--text-dark); }
.help-nav-art.active {
  background: var(--primary);
  color: var(--white);
  font-weight: 600;
}

/* ── Search results in nav ── */
.help-search-results-label {
  padding: 8px 10px 6px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-light);
}
.help-search-result {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px;
  cursor: pointer;
  margin-bottom: 2px;
}
.help-search-result:hover { background: var(--bg); }
.help-search-result.active { background: var(--bg); box-shadow: inset 3px 0 0 var(--primary); }
.help-search-result-cat {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.help-search-result-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-dark);
}
.help-search-result-snippet {
  font-size: 0.76rem;
  color: var(--text-gray);
  line-height: 1.4;
}
.help-no-results {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-light);
}
.help-no-results i { font-size: 1.6rem; margin-bottom: 10px; display: block; }
.help-no-results p { margin: 0; font-size: 0.85rem; }

/* ── Article content pane ── */
.help-content-pane {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 36px;
  min-height: 400px;
}
.help-article-crumb { margin-bottom: 14px; }
.help-article-cat-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
}
.help-article h2 {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-dark);
  margin: 0 0 18px;
}
.help-article-body { color: var(--text-gray); font-size: 0.92rem; line-height: 1.75; }
.help-article-body h4 {
  font-family: var(--font-heading);
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-dark);
  margin: 22px 0 10px;
}
.help-article-body h4:first-child { margin-top: 0; }
.help-article-body p { margin: 0 0 14px; }
.help-article-body ul,
.help-article-body ol { margin: 0 0 14px; padding-left: 22px; }
.help-article-body li { margin-bottom: 7px; }
.help-article-body strong { color: var(--text-dark); }
.help-article-body code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.85em;
  color: var(--primary);
}
.help-article-img {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin: 6px 0 20px;
  display: block;
}

@media (max-width: 600px) {
  .help-hero { padding: 28px 16px 22px; }
  .help-content-pane { padding: 22px 18px; }
}

/* ── Content Approval Workflow ────────────────────────────── */
.appr-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.02em;
}
.appr-pending  { background: #fef3c7; color: #92400e; }
.appr-rejected { background: #fee2e2; color: #991b1b; }

.approval-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ef4444;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  margin-left: 8px;
  vertical-align: middle;
}

.appr-list { padding: 0; }
.appr-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
}
.appr-item:last-child { border-bottom: none; }
.appr-item-left  { display: flex; align-items: flex-start; gap: 12px; flex: 1; min-width: 0; }
.appr-item-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.appr-type-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
  font-size: 0.8rem;
}
.appr-item-info { min-width: 0; }
.appr-item-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 360px;
}
.appr-item-meta { font-size: 0.78rem; color: var(--text-gray); margin-top: 2px; }
.appr-note { font-size: 0.78rem; color: #92400e; margin-top: 4px; background: #fef3c7; padding: 3px 8px; border-radius: 6px; }

.btn-xs {
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid;
  cursor: pointer;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
}
.btn-xs.btn-success { color: #10b981; border-color: #10b981; }
.btn-xs.btn-success:hover { background: #10b981; color: #fff; }
.btn-xs.btn-danger  { color: #ef4444; border-color: #ef4444; }
.btn-xs.btn-danger:hover  { background: #ef4444; color: #fff; }

/* Approval settings toggle rows */
.approval-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--text-dark);
  cursor: pointer;
  user-select: none;
}
.approval-toggle-row input[type=checkbox] {
  width: 16px; height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ── Collapsible nav groups ───────────────────────────────── */
.nav-group { margin: 0 10px 6px; }

/* The card — wraps header + items together */
.nav-group-box {
  background: rgba(255,255,255,0.055);
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.07);
  overflow: hidden;
  transition: border-color 0.2s;
}

.nav-group:not(.open) .nav-group-box {
  border-color: rgba(255,255,255,0.1);
}

.nav-group.has-active .nav-group-box {
  border-color: rgba(255,255,255,0.15);
}

.nav-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 11px 14px;
  background: transparent;
  border: none;
  cursor: pointer;
  user-select: none;
  font-family: inherit;
  outline: none;
  transition: background 0.15s;
}

.nav-group-header:hover {
  background: rgba(255,255,255,0.04);
}

.nav-group-label {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.71rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: rgba(255,255,255,0.5);
  transition: color 0.18s;
}

.nav-group-label i {
  font-size: 0.73rem;
  width: 15px;
  text-align: center;
}

.nav-group-chevron {
  font-size: 0.6rem;
  color: rgba(255,255,255,0.35);
  transition: transform 0.22s ease, color 0.18s;
}

.nav-group-header:hover .nav-group-label  { color: rgba(255,255,255,0.78); }
.nav-group-header:hover .nav-group-chevron { color: rgba(255,255,255,0.6); }
.nav-group.has-active .nav-group-label    { color: rgba(255,255,255,0.88); }
.nav-group.has-active .nav-group-chevron  { color: var(--accent); }

/* chevron-right rotates 90° → points down when open */
.nav-group.open .nav-group-chevron { transform: rotate(90deg); }

/* Items collapse inside the card */
.nav-group-items {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.24s ease;
  border-top: 1px solid transparent;
}

.nav-group.open .nav-group-items {
  max-height: 600px;
  border-top-color: rgba(255,255,255,0.06);
}

/* Items inside the card — flush, no left border */
.nav-group .nav-item {
  padding: 10px 14px;
  border-left: none;
  border-radius: 0;
  margin: 0;
  font-size: 0.875rem;
}

.nav-group .nav-item:hover {
  background: rgba(255,255,255,0.07);
  color: var(--white);
}

.nav-group .nav-item.active {
  background: rgba(255,255,255,0.1);
  color: var(--white);
  border-left: none;
}

.nav-item-help {
  margin: 6px 10px 0;
  border-radius: 10px;
}

/* ── Task modal – JIRA-style layout ─────────────────────────── */
.task-modal-wide { max-width: 1060px; width: 95vw; }

.task-modal-body {
  display: flex;
  min-height: 0;
  max-height: 75vh;
  overflow: hidden;
}

.task-modal-form {
  flex: 1 1 420px;
  padding: 20px 24px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
}

.task-modal-activity {
  flex: 0 0 300px;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  background: var(--bg);
}

/* Activity header */
.task-act-header {
  padding: 14px 16px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-gray);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* Scrollable activity list */
.task-act-list {
  flex: 1 1 0;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.task-act-empty {
  font-size: 0.82rem;
  color: var(--text-gray);
  text-align: center;
  padding: 20px 0;
}

/* Single activity item */
.task-act-item {
  display: flex;
  gap: 9px;
  align-items: flex-start;
}

.task-act-avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.task-act-body { flex: 1; min-width: 0; }

.task-act-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}

.task-act-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dark);
}

.task-act-time {
  font-size: 0.72rem;
  color: var(--text-gray);
}

.task-act-text {
  font-size: 0.8rem;
  color: var(--text-dark);
  line-height: 1.45;
  word-break: break-word;
}

.task-act-old { color: var(--text-gray); text-decoration: line-through; }
.task-act-new { color: #16a34a; font-weight: 500; }

/* Comment variant */
.task-act-item--comment .task-act-avatar { background: #6366f1; }
.task-act-comment-text {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-dark);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Comment input box */
.task-comment-box {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.task-comment-box textarea {
  font-size: 0.82rem;
  resize: none;
}

.task-comment-box .btn {
  align-self: flex-end;
}

/* Responsive: stack on narrow screens */
@media (max-width: 700px) {
  .task-modal-body { flex-direction: column; max-height: 90vh; }
  .task-modal-form { border-right: none; border-bottom: 1px solid var(--border); }
  .task-modal-activity { flex: 0 0 260px; }
}

.task-title-link:hover { text-decoration: underline; }

/* ── Document Preview Modal ──────────────────────────────── */
.doc-preview-dialog {
  background: var(--bg-card, #fff);
  border-radius: var(--radius);
  width: 92vw;
  height: 90vh;
  max-width: 1400px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.35);
  animation: modalIn 0.18s ease;
}
.doc-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-shrink: 0;
  background: var(--bg-card, #fff);
}
.doc-preview-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-dark);
  min-width: 0;
}
.doc-preview-title span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-preview-title .fas { font-size: 1.25rem; flex-shrink: 0; }
.doc-preview-title .fa-file-pdf   { color: #dc2626; }
.doc-preview-title .fa-file-word  { color: #1d4ed8; }
.doc-preview-title .fa-file-image { color: #16a34a; }
.doc-preview-title .fa-file-alt   { color: #64748b; }
.doc-preview-hactions { display: flex; gap: 8px; flex-shrink: 0; }
.doc-preview-body {
  flex: 1;
  overflow: hidden;
  background: #f1f5f9;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.doc-preview-frame { width: 100%; height: 100%; border: none; display: block; background: #fff; }
.doc-preview-img-wrap { width: 100%; height: 100%; overflow: auto; display: flex; align-items: center; justify-content: center; padding: 24px; box-sizing: border-box; }
.doc-preview-img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; box-shadow: 0 4px 24px rgba(0,0,0,0.18); }
.doc-preview-unsupported { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--text-gray); text-align: center; padding: 48px; }
.doc-preview-unsupported .fas { font-size: 4rem; opacity: 0.25; margin-bottom: 8px; }
.doc-preview-unsupported .doc-preview-fname { font-size: 1rem; font-weight: 600; color: var(--text-dark); }
.doc-preview-unsupported .doc-preview-fsize { font-size: 0.82rem; }
.docs-file-row { cursor: pointer; transition: background 0.12s; }
.docs-file-row:hover { background: var(--bg-hover, #f8fafc); }
@media (max-width: 768px) {
  .doc-preview-dialog { width: 100vw; height: 100dvh; border-radius: 0; }
  .doc-preview-title span { max-width: 180px; }
}

/* ── Gallery Admin ──────────────────────────────────────────── */
.gallery-admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.gallery-admin-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.15s;
}
.gallery-admin-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.10); }
.gallery-admin-card.gallery-inactive { opacity: 0.55; }
.gallery-admin-thumb {
  position: relative;
  height: 160px;
  overflow: hidden;
  cursor: pointer;
  background: #f1f5f9;
}
.gallery-admin-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s;
}
.gallery-admin-thumb:hover img { transform: scale(1.04); }
.gallery-admin-badge-off {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.gallery-admin-info {
  padding: 10px 12px 4px;
  flex: 1;
}
.gallery-admin-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dark);
  margin: 0 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gallery-admin-caption {
  font-size: 0.75rem;
  color: var(--text-gray);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.gallery-admin-actions {
  padding: 8px 10px;
  display: flex;
  gap: 6px;
  border-top: 1px solid var(--border);
  background: var(--bg-light, #f8fafc);
}
.btn-xs {
  padding: 4px 9px;
  font-size: 0.75rem;
  border-radius: 5px;
  min-height: 28px;
}

/* Admin gallery lightbox */
.gallery-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}
.glb-content {
  max-width: 900px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.glb-content img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
.glb-info { text-align: center; color: #fff; }
.glb-title { font-size: 1rem; font-weight: 700; margin: 0 0 4px; }
.glb-caption { font-size: 0.85rem; color: rgba(255,255,255,0.7); margin: 0 0 6px; }
.glb-counter { font-size: 0.75rem; color: rgba(255,255,255,0.45); margin: 0; }
.glb-close {
  position: fixed;
  top: 16px;
  right: 20px;
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  font-size: 1.3rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.glb-close:hover { background: rgba(255,255,255,0.25); }
.glb-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  font-size: 1.2rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  z-index: 10000;
}
.glb-nav:hover { background: rgba(255,255,255,0.25); }
.glb-prev { left: 12px; }
.glb-next { right: 12px; }

@media (max-width: 768px) {
  .gallery-admin-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .gallery-admin-thumb { height: 130px; }
  .glb-nav { display: none; }
}
@media (max-width: 480px) {
  .gallery-admin-grid { grid-template-columns: 1fr; }
}

/* Gallery upload preview */
.gallery-upload-preview-item {
  display: grid;
  grid-template-columns: 100px 1fr;
  grid-template-rows: auto auto;
  gap: 8px 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.gallery-upload-preview-item:last-child { border-bottom: none; padding-bottom: 0; }
.gallery-upload-preview-item img {
  grid-row: span 2;
  width: 100px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}
@media (max-width: 480px) {
  .gallery-upload-preview-item { grid-template-columns: 1fr; }
  .gallery-upload-preview-item img { grid-row: span 1; width: 100%; height: 140px; }
}
