/* ============================================================
   IAT - Main Stylesheet
   CSS Custom Properties for tenant theming (set in index.php)
   ============================================================ */

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

:root {
  /* Tenant-overridable (injected by PHP) */
  --tenant-primary: #1c1917;
  --tenant-secondary: #f97316;

  /* UI System */
  --bg: #fafaf9;
  --bg-white: #ffffff;
  --text: #1c1917;
  --text-muted: #78716c;
  --border: #e7e5e4;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --transition: 0.2s ease;

  /* Status Colors */
  --success: #22c55e;
  --warning: #eab308;
  --danger: #ef4444;
  --info: #06b6d4;

  /* Accent */
  --accent: #f97316;
  --accent-hover: #ea580c;
  --accent-light: #ffedd5;
  --accent-light-text: #9a3412;

  /* Layout */
  --sidebar-width: 240px;
  --header-height: 0px;
}

html { font-size: 14.5px; }
body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--tenant-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Login Screen --- */
.logged-out {
  display: flex;
  align-items: center;
  justify-content: center;
}

#login-wrapper {
  width: 100%;
  max-width: 400px;
  padding: 2rem 1rem;
}

.login-card {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 2.5rem 2rem;
  text-align: center;
}

.login-card h1 {
  font-size: 1.4rem;
  color: var(--tenant-primary);
  margin-bottom: 1.5rem;
}

.login-logo {
  max-width: 180px;
  max-height: 60px;
  margin-bottom: 1rem;
}

/* --- Forms --- */
.form-group {
  margin-bottom: 1rem;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1.2rem;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  letter-spacing: 0.01em;
}

.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-secondary {
  background: var(--tenant-primary);
  color: #fff;
}

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-outline:hover { background: var(--bg); }

.btn-danger { background: var(--danger); color: #fff; }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-full { width: 100%; }

.btn:disabled, .btn.loading {
  opacity: 0.6;
  cursor: not-allowed;
}

/* --- Alerts --- */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-error { background: #fce4e4; color: var(--danger); border: 1px solid #f5c6cb; }
.alert-success { background: #d4edda; color: var(--success); border: 1px solid #c3e6cb; }
.alert-info { background: #d1ecf1; color: var(--info); border: 1px solid #bee5eb; }

/* --- App Shell Layout --- */
.logged-in {
  display: flex;
  flex-direction: column;
}

#impersonation-bar {
  background: var(--warning);
  color: #333;
  text-align: center;
  padding: 0.4rem;
  font-size: 0.85rem;
}

#app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
#sidebar {
  width: var(--sidebar-width);
  background: #1c1917;
  color: rgba(255,255,255,0.65);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-header {
  padding: 1.2rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-logo {
  max-width: 36px;
  max-height: 36px;
  border-radius: 4px;
}

.sidebar-title {
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  list-style: none;
  flex: 1;
  padding: 0.5rem 0;
}

.sidebar-nav li { margin: 0; }

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1.2rem;
  color: rgba(255,255,255,0.6);
  font-size: 0.88rem;
  font-weight: 400;
  transition: all var(--transition);
  border-left: 3px solid transparent;
}

.sidebar-nav .nav-link:hover {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.9);
  text-decoration: none;
}

.sidebar-nav .nav-link.active {
  background: rgba(249,115,22,0.1);
  color: #fb923c;
  font-weight: 600;
  border-left-color: #fb923c;
}

.nav-icon { font-size: 0.6rem; opacity: 0.6; }

.sidebar-divider {
  height: 1px;
  background: rgba(255,255,255,0.1);
  margin: 0.5rem 1rem;
}

.sidebar-api-spend {
  padding: 8px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-size: 0.72rem;
}
.sidebar-api-spend .spend-label { color: rgba(255,255,255,0.5); }
.sidebar-api-spend .spend-amount { float: right; color: rgba(255,255,255,0.8); font-weight: 600; }
.sidebar-api-spend .spend-bar { height: 3px; background: rgba(255,255,255,0.1); border-radius: 2px; margin-top: 4px; clear: both; }
.sidebar-api-spend .spend-bar-fill { height: 100%; border-radius: 2px; transition: width 0.3s; }

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  position: relative;
}

.sidebar-user {
  margin-bottom: 0.5rem;
}

.user-name {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
}

.user-role {
  display: block;
  font-size: 0.75rem;
  opacity: 0.6;
}

.sidebar-footer .btn-outline {
  color: rgba(255,255,255,0.75);
  border-color: rgba(255,255,255,0.3);
  flex: 1;
}
.sidebar-footer .btn-outline:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

/* --- Main Content --- */
#main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 1.5rem 2rem;
  min-height: 100vh;
}

.content-loading {
  text-align: center;
  padding: 4rem;
  color: var(--text-muted);
}

/* --- Screen Headers --- */
.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.screen-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

/* --- Cards --- */
.card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card-header {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.75rem;
}

/* --- Tables --- */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.data-table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.data-table tr:hover { background: var(--bg); }

#dir-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  color: var(--text-muted);
}
#dir-table tbody tr {
  transition: background 0.15s ease;
}
#dir-table tbody tr:hover {
  background: var(--bg);
}

/* --- Badges --- */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success { background: #d4edda; color: var(--success); }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger { background: #f8d7da; color: var(--danger); }
.badge-info { background: #d1ecf1; color: var(--info); }
.badge-muted { background: #e9ecef; color: var(--text-muted); }

/* --- Utility --- */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-sm { margin-top: 0.75rem; }
.mt-md { margin-top: 1.5rem; }
.mb-sm { margin-bottom: 0.75rem; }
.mb-md { margin-bottom: 1.5rem; }
.d-flex { display: flex; }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 1rem; }

/* --- Stats Grid --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.stat-card { text-align: center; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); }
.stat-value { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; color: var(--tenant-primary); }

/* --- Pipeline Bars (Dashboard) --- */
.pipeline-bar-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.pipeline-label { width: 100px; font-size: 0.85rem; text-align: right; }
.pipeline-bar-track { flex: 1; height: 20px; background: #eee; border-radius: 4px; overflow: hidden; }
.pipeline-bar-fill { height: 100%; background: var(--tenant-primary); border-radius: 4px; transition: width 0.3s; }
.pipeline-count { width: 40px; font-size: 0.85rem; font-weight: 600; }

/* --- Usage Bars --- */
.usage-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem; }
.usage-label { width: 140px; font-size: 0.85rem; text-align: right; }
.usage-bar-track { flex: 1; height: 14px; background: #eee; border-radius: 4px; overflow: hidden; }
.usage-bar-fill { height: 100%; background: var(--tenant-secondary); border-radius: 4px; transition: width 0.3s; }
.usage-bar-warning { background: var(--warning); }
.usage-bar-danger { background: var(--danger); }
.usage-count { width: 100px; font-size: 0.8rem; color: var(--text-muted); }

/* --- Activity Feed --- */
.activity-item {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.activity-item:last-child { border-bottom: none; }
.activity-time { font-size: 0.8rem; color: var(--text-muted); }

/* --- Score Badges --- */
.score-badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 700;
}
.score-good, .score-fill-good { background: #d4edda; color: var(--success); }
.score-ok, .score-fill-ok { background: #fff3cd; color: #856404; }
.score-poor, .score-fill-poor { background: #f8d7da; color: var(--danger); }

/* --- Score Bars (Profile) --- */
.score-bar-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem; }
.score-bar-label { width: 80px; font-size: 0.85rem; font-weight: 600; }
.score-bar-track { flex: 1; height: 18px; background: #eee; border-radius: 4px; overflow: hidden; }
.score-bar-fill { height: 100%; border-radius: 4px; transition: width 0.5s; }
.score-fill-good { background: var(--success); }
.score-fill-ok { background: var(--warning); }
.score-fill-poor { background: var(--danger); }
.score-bar-value { width: 30px; font-size: 0.85rem; font-weight: 700; text-align: right; }

/* --- Score Ring --- */
.score-ring {
  width: 70px; height: 70px;
  border-radius: 50%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  border: 4px solid #eee;
}
.score-ring-good { border-color: var(--success); }
.score-ring-ok { border-color: var(--warning); }
.score-ring-poor { border-color: var(--danger); }
.score-ring-value { font-size: 1.3rem; font-weight: 700; line-height: 1; }
.score-ring-label { font-size: 0.6rem; color: var(--text-muted); text-transform: uppercase; }

/* --- Search Results --- */
.search-result-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}
.search-result-row:last-child { border-bottom: none; }
.search-result-check { flex-shrink: 0; }
.search-result-info { flex: 1; }

/* --- Slide-over Panel --- */
.slideover { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 500; }
.slideover-backdrop { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.3); }
.slideover-panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: 600px; max-width: 90vw;
  background: var(--bg-white);
  box-shadow: -8px 0 32px rgba(0,0,0,0.12);
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.slideover-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.slideover-header h3 { font-size: 1.15rem; }
.slideover-body { padding: 1.25rem; flex: 1; overflow-y: auto; }

/* Slide-over tabs */
.slide-tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); }
.slide-tab {
  padding: 0.5rem 1rem; font-size: 0.85rem; font-weight: 600;
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: all var(--transition);
}
.slide-tab:hover { color: var(--text); }
.slide-tab.active { color: var(--tenant-primary); border-bottom-color: var(--tenant-primary); }
.slide-tab-panel { padding-top: 1rem; }
.slide-header-bar { padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.slide-address { font-size: 0.9rem; }

/* --- Review Items --- */
.review-item { padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.review-item:last-child { border-bottom: none; }

/* --- Kanban Pipeline --- */
.kanban-board {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  min-height: 400px;
}

.kanban-col {
  flex: 1;
  min-width: 180px;
  max-width: 250px;
  background: var(--bg);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
}

.kanban-col-header {
  padding: 0.75rem;
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  display: flex; align-items: center; gap: 0.5rem;
}

.kanban-count {
  background: var(--border);
  color: var(--text-muted);
  padding: 0.1rem 0.4rem;
  border-radius: 8px;
  font-size: 0.75rem;
}

.kanban-cards {
  padding: 0.5rem;
  flex: 1;
  min-height: 100px;
}

.kanban-cards.kanban-drop-active {
  background: rgba(46,134,171,0.1);
  border: 2px dashed var(--tenant-secondary);
  border-radius: var(--radius);
}

.kanban-card {
  background: var(--bg-white);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.4rem;
  box-shadow: var(--shadow);
  cursor: grab;
  transition: box-shadow var(--transition);
}

.kanban-card:hover { box-shadow: var(--shadow-md); }
.kanban-card-dragging { opacity: 0.5; }
.kanban-card-name { font-weight: 600; font-size: 0.85rem; }
.kanban-card-meta { font-size: 0.75rem; margin-top: 0.2rem; }

/* --- Prospect Cards --- */
.prospect-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.prospect-card { padding: 1rem; }

.prospect-card-header {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.need-gauge {
  width: 55px; height: 55px;
  border-radius: 50%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  flex-shrink: 0;
}
.need-hot { background: #f8d7da; border: 3px solid var(--danger); }
.need-warm { background: #fff3cd; border: 3px solid #e0a800; }
.need-cool { background: #d4edda; border: 3px solid var(--success); }
.need-value { font-size: 1.1rem; font-weight: 700; line-height: 1; }
.need-label { font-size: 0.55rem; text-transform: uppercase; color: var(--text-muted); }

.prospect-card-info { flex: 1; }

.prospect-pills { display: flex; gap: 0.3rem; flex-wrap: wrap; margin-top: 0.5rem; }
.pill {
  padding: 0.15rem 0.5rem;
  background: #e9ecef;
  border-radius: 10px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.prospect-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Prospect Score Breakdown Bars */
.prospect-scores { margin-top: 0.5rem; }
.prospect-score-row { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.25rem; }
.prospect-score-label { width: 65px; font-size: 0.72rem; font-weight: 600; color: var(--text-muted); }
.prospect-score-track { flex: 1; height: 12px; background: #eee; border-radius: 3px; overflow: hidden; }
.prospect-score-fill { height: 100%; border-radius: 3px; transition: width 0.5s; }
.prospect-score-val { width: 24px; font-size: 0.72rem; font-weight: 700; text-align: right; }

/* Enriched pill variants */
.pill-good { background: #d4edda; color: var(--success); }
.pill-bad { background: #f8d7da; color: var(--danger); }

/* --- Notes --- */
.notes-log { white-space: pre-wrap; font-size: 0.9rem; line-height: 1.6; }

/* --- Portal Score Ring --- */
.portal-score-section {
  display: flex;
  gap: 2rem;
  align-items: center;
  background: var(--bg-white);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}
.portal-score-ring-wrap { position: relative; width: 120px; height: 120px; flex-shrink: 0; }
.portal-score-ring { width: 100%; height: 100%; }
.portal-score-value {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}
.portal-score-value span { font-size: 2rem; font-weight: 700; color: var(--text); display: block; line-height: 1; }
.portal-score-value small { font-size: 0.85rem; color: var(--text-muted); }

.portal-subscores { flex: 1; }
.subscore-item { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.subscore-item .subscore-label { width: 120px; font-size: 0.85rem; font-weight: 600; }
.subscore-bar-track { flex: 1; height: 14px; background: #eee; border-radius: 4px; overflow: hidden; }
.subscore-bar-fill { height: 100%; border-radius: 4px; transition: width 1s ease, background 0.3s; }
.subscore-val { width: 30px; text-align: right; font-weight: 700; font-size: 0.85rem; }

/* --- Portal Grid --- */
.portal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }

/* --- Info Table --- */
.info-table { width: 100%; font-size: 0.9rem; }
.info-table td { padding: 0.35rem 0.5rem; border-bottom: 1px solid #f0f0f0; vertical-align: top; }
.info-table td:first-child { width: 130px; color: var(--text-muted); }
.info-table th { padding: 0.35rem 0.5rem; border-bottom: 2px solid var(--border); text-align: left; font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }

/* --- Review Items (small/compact) --- */
.review-item-sm { padding: 0.5rem 0; border-bottom: 1px solid #f0f0f0; }
.review-item-sm:last-child { border-bottom: none; }
.review-item-sm .review-header { font-size: 0.85rem; }
.review-text-sm { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.25rem; }
.review-stars { color: #f0ad4e; letter-spacing: -1px; }

/* --- Review Items (full) --- */
.review-item { padding: 1rem; border-bottom: 1px solid var(--border); }
.review-item:last-child { border-bottom: none; }
.review-item .review-header { margin-bottom: 0.35rem; }
.review-text { font-size: 0.9rem; color: var(--text); margin: 0.35rem 0; }
.review-response { background: #f8f9fa; padding: 0.75rem; border-radius: var(--radius-sm); margin-top: 0.5rem; font-size: 0.85rem; border-left: 3px solid var(--tenant-primary); }
.review-positive { border-left: 3px solid var(--success); }
.review-negative { border-left: 3px solid var(--danger); }
.review-neutral { border-left: 3px solid var(--warning); }

/* --- Modal --- */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-content {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-width: 550px;
  width: 95%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.1rem; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}
.modal-body { padding: 1.25rem; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
}

/* --- Tabs --- */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1rem;
}
.tab-btn {
  padding: 0.65rem 1.25rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: color var(--transition), border-color var(--transition);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--tenant-primary); border-bottom-color: var(--tenant-primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* --- Stats Grid Variants --- */
.stats-grid-4 { grid-template-columns: repeat(4, 1fr); }
.stats-grid-5 { grid-template-columns: repeat(5, 1fr); }
.stat-mini { text-align: center; padding: 0.5rem; }
.stat-mini strong { display: block; font-size: 1.5rem; color: var(--tenant-primary); }
.stat-mini small { color: var(--text-muted); font-size: 0.8rem; }

/* --- Filter Row --- */
.filter-row { display: flex; gap: 0.5rem; align-items: center; }
.form-control-sm { padding: 0.3rem 0.5rem; font-size: 0.85rem; }

/* --- Form Row --- */
.form-row { display: flex; gap: 1rem; }
.flex-1 { flex: 1; }

/* --- Card Header Action --- */
.card-header { display: flex; justify-content: space-between; align-items: center; }
.card-header-action { font-size: 0.85rem; }

/* --- Card Footer --- */
.card-footer { padding: 0.75rem 1rem; border-top: 1px solid var(--border); }

/* --- Report Cards --- */
.report-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid #f0f0f0;
}
.report-card:last-child { border-bottom: none; }
.report-card-icon { font-size: 2rem; }
.report-card-info { flex: 1; }
.report-card-info strong { display: block; }
.report-card-info span { display: block; font-size: 0.85rem; }

/* --- Volume Chart (simple bar chart) --- */
.volume-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 120px;
  padding-top: 10px;
}
.volume-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}
.volume-bar {
  width: 100%;
  min-width: 6px;
  background: var(--tenant-primary);
  border-radius: 2px 2px 0 0;
  transition: height 0.3s;
}
.volume-bar-wrap small {
  font-size: 0.6rem;
  color: var(--text-muted);
  margin-top: 2px;
  transform: rotate(-45deg);
  white-space: nowrap;
}

/* --- Table Enhancements --- */
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th { text-align: left; padding: 0.6rem 0.75rem; background: #f8f9fa; border-bottom: 2px solid var(--border); font-size: 0.8rem; text-transform: uppercase; color: var(--text-muted); }
.table td { padding: 0.6rem 0.75rem; border-bottom: 1px solid #f0f0f0; vertical-align: top; }
.table-sm td, .table-sm th { padding: 0.4rem 0.6rem; }

/* --- Badge Variants --- */
.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-error { background: #f8d7da; color: #721c24; }
.badge-muted { background: #e9ecef; color: #6c757d; }
.badge-primary { background: color-mix(in srgb, var(--tenant-primary) 15%, white); color: var(--tenant-primary); }
.badge-sm { font-size: 0.7rem; padding: 0.15rem 0.4rem; }

/* --- Impersonation Bar --- */
#impersonation-bar {
  background: var(--warning);
  color: #333;
  text-align: center;
  padding: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
}
#impersonation-bar a { color: #333; text-decoration: underline; }

/* --- Email Debug Mode Banner --- */
#debug-email-banner {
  background: #d63031;
  color: #fff;
  text-align: center;
  padding: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
#debug-email-banner strong { color: #fff; text-decoration: underline; }

/* --- Responsive --- */
@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition);
  }
  #sidebar.open { transform: translateX(0); }
  #main-content { margin-left: 0; padding: 1rem; }
  .kanban-board { flex-direction: column; }
  .kanban-col { max-width: none; }
  .slideover-panel { width: 100vw; }
  .portal-score-section { flex-direction: column; text-align: center; }
  .portal-grid { grid-template-columns: 1fr; }
  .stats-grid-4, .stats-grid-5 { grid-template-columns: repeat(2, 1fr); }
  .form-row { flex-direction: column; }
  .tab-bar { overflow-x: auto; }
  .filter-row { flex-wrap: wrap; }
}

/* --- Notification Bell & Dropdown --- */
.sidebar-actions { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.5rem; }
.notification-bell {
  position: relative;
  background: none;
  border: none;
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
  flex-shrink: 0;
}
.notification-bell:hover { background: rgba(255,255,255,0.1); color: #fff; }
.notification-badge {
  position: absolute;
  top: 0; right: 0;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  border-radius: 8px;
  padding: 0 4px;
}
.notification-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0; right: 0;
  margin-bottom: 0.5rem;
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 1000;
  max-height: 400px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
}
.notification-dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.notification-dropdown-header a { font-size: 0.8rem; }
.notification-list {
  overflow-y: auto;
  max-height: 340px;
}
.notification-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.notification-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}
.notification-item:last-child { border-bottom: none; }
.notification-item:hover { background: var(--bg); }
.notification-item.unread { background: #f0f7ff; }
.notification-item.unread:hover { background: #e3f0fd; }
.notification-title { font-size: 0.85rem; font-weight: 600; margin-bottom: 2px; }
.notification-body { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 2px; }
.notification-time { font-size: 0.75rem; color: var(--text-muted); }

/* ============================================================
   Phase 4 — Bulk Actions, Analytics, Team, Multi-directory
   ============================================================ */

/* --- Tabs (screen-level) --- */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.25rem;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* --- Form Helpers --- */
.form-control {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color var(--transition);
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

.form-select {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--bg-white);
  cursor: pointer;
}

.form-help {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

.form-select-sm {
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
  width: auto;
}

.screen-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* --- Checkbox Lists (Bulk select) --- */
.bulk-select-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}
.bulk-select-controls .form-control { flex: 1; }

.checkbox-list {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  background: #fafbfc;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.checkbox-item:hover { background: #f0f2f5; }
.checkbox-item input[type=checkbox] { flex-shrink: 0; }

/* --- Report Links --- */
.report-links {
  list-style: none;
  padding: 0;
}
.report-links li {
  padding: 0.35rem 0;
  border-bottom: 1px solid #f0f0f0;
}
.report-links li:last-child { border-bottom: none; }

/* --- Permission Grid (Team) --- */
.permission-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem;
}

.permission-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.permission-item:hover { background: var(--bg); }
.permission-item input[type=checkbox] { flex-shrink: 0; }

/* --- Directory Grid (Multi-directory) --- */
.directory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 1rem;
}

.directory-card {
  text-align: center;
}
.directory-card .card-body {
  padding: 24px;
}

/* --- Period Selector (Analytics) --- */
.period-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.period-selector label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* --- Analytics Grid --- */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.metric-card {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  text-align: center;
}

.metric-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--tenant-primary);
  line-height: 1.2;
}

.metric-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-top: 0.25rem;
}

/* --- Funnel Visualization --- */
.funnel-container {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.25rem;
  padding: 2rem 1rem;
  min-height: 300px;
}

.funnel-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  max-width: 180px;
}

.funnel-bar {
  width: 100%;
  background: var(--tenant-primary);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 0.5rem;
  min-height: 40px;
  transition: height 0.5s ease;
}

.funnel-bar .funnel-count {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
}

.funnel-stage-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 0.5rem;
  text-align: center;
}

.funnel-rate {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.funnel-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 1.5rem;
  padding-bottom: 2rem;
}

/* --- Bar Chart (Analytics) --- */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 160px;
  padding: 0.5rem 0;
}

.chart-bar {
  flex: 1;
  min-width: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}

.chart-bar-fill {
  width: 100%;
  background: var(--tenant-primary);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: height 0.3s;
  min-height: 2px;
}

.chart-bar small {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 3px;
  transform: rotate(-45deg);
  white-space: nowrap;
}

/* --- Metric List (Analytics) --- */
.metric-list {
  list-style: none;
  padding: 0;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 0.9rem;
}
.metric-row:last-child { border-bottom: none; }

.metric-row strong {
  color: var(--tenant-primary);
}

/* --- Text utilities (Phase 4) --- */
.text-error { color: var(--danger); }
.text-success { color: var(--success); }

/* --- Responsive (Phase 4 additions) --- */
@media (max-width: 768px) {
  .permission-grid { grid-template-columns: 1fr; }
  .directory-grid { grid-template-columns: 1fr; }
  .analytics-grid { grid-template-columns: 1fr 1fr; }
  .funnel-container { flex-wrap: wrap; }
  .funnel-arrow { display: none; }
  .bulk-select-controls { flex-wrap: wrap; }
  .tabs { overflow-x: auto; }
}

/* --- Email Crawler Popover --- */
.email-crawl-popover {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 340px;
  max-width: 90vw;
  font-size: 0.875rem;
  z-index: 10000;
}
.crawl-popover-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius) var(--radius) 0 0;
}
.crawl-popover-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 0 4px;
}
.crawl-popover-close:hover { color: var(--danger); }
.crawl-popover-list { max-height: 200px; overflow-y: auto; }
.crawl-email-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  border-bottom: 1px solid #f0f0f0;
}
.crawl-email-row:last-child { border-bottom: none; }
.crawl-email-addr {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  margin-right: 8px;
}
.crawl-popover-empty { padding: 12px; text-align: center; }

/* --- Import Modal Styles --- */
.import-dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--bg);
}
.import-dropzone:hover,
.import-dropzone.dragover {
  border-color: var(--accent);
  background: rgba(249, 115, 22, 0.04);
}
.import-column-map-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.import-column-map-table th,
.import-column-map-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.import-column-map-table th {
  background: var(--bg);
  font-weight: 600;
}
.import-column-map-table select {
  width: 100%;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

/* --- Imported Records Tab --- */
.imported-records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.imported-records-table th,
.imported-records-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
.imported-records-table th {
  background: var(--bg);
  font-weight: 600;
  position: sticky;
  top: 0;
}
.imported-records-table tr:hover { background: rgba(0,0,0,0.02); }
.imported-batch-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  flex-wrap: wrap;
}
#imported-count-badge {
  display: inline-block;
  background: var(--danger);
  color: #fff;
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 0.75rem;
  margin-left: 4px;
  vertical-align: middle;
}
#imported-count-badge:empty { display: none; }

/* --- Auto-find Email States --- */
.prospect-email-row {
  padding: 4px 0;
  font-size: 0.85rem;
  min-height: 24px;
}
.auto-crawl-spinner {
  display: inline-block;
  animation: crawl-spin 1s linear infinite;
  color: var(--tenant-secondary);
  font-size: 1rem;
}
@keyframes crawl-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.auto-crawl-found {
  color: var(--text);
  font-size: 0.85rem;
  word-break: break-all;
}
.auto-crawl-more {
  display: inline-block;
  background: var(--tenant-secondary);
  color: #fff;
  border-radius: 8px;
  padding: 0 5px;
  font-size: 0.7rem;
  vertical-align: middle;
  margin-left: 2px;
}
.auto-crawl-none {
  font-size: 0.8rem;
  font-style: italic;
}
.auto-find-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--tenant-primary);
  cursor: pointer;
}

/* --- Icon Buttons (Directory Actions) --- */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.15s ease;
  padding: 0;
  line-height: 1;
  color: var(--text-muted);
}
.btn-icon:hover {
  background: var(--border);
  color: var(--text);
}
.btn-icon-accent {
  color: var(--accent);
  background: transparent;
  border: none;
}
.btn-icon-accent:hover {
  background: var(--accent-light);
  color: var(--accent-hover);
}

/* --- Featured Star Toggle --- */
.toggle-featured-btn { background: none; border: none; font-size: 1.2rem; color: #ccc; cursor: pointer; padding: 2px 4px; line-height: 1; }
.toggle-featured-btn:hover { color: #f5a623; }
.toggle-featured-btn.featured-active { color: #f5a623; }

/* --- Email Verify Unchecked Icon --- */
.email-unchecked {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #94a3b8;
  font-size: 0.65rem;
  font-weight: 700;
  cursor: pointer;
  margin-left: 4px;
  vertical-align: middle;
}
.email-unchecked:hover {
  background: #cbd5e1;
  color: #64748b;
}

/* --- Email Event Icons --- */
.email-evt {
  display: inline-block;
  font-size: 0.9rem;
  margin-right: 3px;
  cursor: default;
  opacity: 0.85;
}
.email-evt:hover {
  opacity: 1;
  transform: scale(1.15);
}
