/* =============================================
   Calbridge Portal — Stylesheet
   ============================================= */

:root {
  /* Calbridge Brand */
  --brand:       #2d5a27;
  --brand-dark:  #1e3a1a;
  --brand-mid:   #3d7a35;
  --brand-light: #edf5ec;
  --brand-hsl:   109, 37%, 25%;

  --success:     #2d5a27;
  --success-bg:  #edf5ec;
  --danger:      #c81e1e;
  --danger-bg:   #fde8e8;
  --warning:     #b45309;
  --warning-bg:  #fef3c7;
  --gray-50:     #f9fafb;
  --gray-100:    #f3f4f6;
  --gray-200:    #e5e7eb;
  --gray-400:    #9ca3af;
  --gray-600:    #4b5563;
  --gray-800:    #1a2e18;
  --sidebar-w:   240px;
  --radius:      8px;
  --shadow:      0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:   0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

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

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; color: var(--gray-800); background: var(--gray-50); }

/* ---- MOBILE HAMBURGER ---- */
.hamburger { display: none; position: fixed; top: 12px; left: 12px; z-index: 200; background: var(--brand-dark); border: none; border-radius: 6px; padding: 8px 10px; cursor: pointer; }
.hamburger span { display: block; width: 20px; height: 2px; background: #fff; margin: 4px 0; border-radius: 2px; transition: all .2s; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 99; }

/* ---- AUTH ---- */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #d8d0c4; }

.auth-card { background: #fff; border-radius: 12px; padding: 40px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }

.logo { text-align: center; margin-bottom: 28px; }
.logo img { height: 100px; width: auto; margin-bottom: 8px; }
.logo h1 { font-size: 28px; font-weight: 700; color: var(--brand); margin-bottom: 4px; display: none; }
.logo p  { color: var(--gray-400); font-size: 13px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 6px; color: var(--gray-600); }
.form-group input { width: 100%; padding: 10px 12px; border: 1px solid var(--gray-200); border-radius: var(--radius); font-size: 14px; transition: border-color .15s; }
.form-group input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(26,86,219,.12); }

.btn-primary { width: 100%; padding: 11px; background: var(--brand); color: #fff; border: none; border-radius: var(--radius); font-size: 15px; font-weight: 600; cursor: pointer; transition: background .15s; margin-top: 4px; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

.auth-switch { text-align: center; margin-top: 20px; color: var(--gray-400); }
.auth-switch a { color: var(--brand); text-decoration: none; font-weight: 500; }

.error-banner { background: var(--danger-bg); color: var(--danger); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; font-size: 13px; }
.hidden { display: none !important; }

/* ---- DASHBOARD LAYOUT ---- */
.dashboard-page { display: flex; min-height: 100vh; }
.dashboard-page body { overflow-x: hidden; }

.sidebar { width: var(--sidebar-w); background: var(--brand-dark); color: #fff; display: flex; flex-direction: column; flex-shrink: 0; position: fixed; top: 0; left: 0; height: 100vh; overflow-y: auto; }

.sidebar-logo { padding: 16px 18px; border-bottom: 1px solid rgba(0,0,0,.08); display: flex; align-items: center; justify-content: center; background: #ffffff; min-height: 72px; }
.sidebar-logo img { max-height: 48px; max-width: 180px; width: auto; height: auto; object-fit: contain; filter: none; }
.sidebar-logo h2 { font-size: 18px; font-weight: 700; color: var(--brand-dark); display: none; }

.sidebar-nav { flex: 1; padding: 16px 0; }
.nav-item { display: block; padding: 10px 20px; color: rgba(255,255,255,.65); text-decoration: none; border-radius: 0; transition: all .15s; font-size: 14px; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.10); color: #fff; border-left: 3px solid rgba(255,255,255,.5); }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-footer #client-name { display: block; font-size: 12px; color: rgba(255,255,255,.5); margin-bottom: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn-logout { width: 100%; padding: 8px; background: transparent; color: rgba(255,255,255,.5); border: 1px solid rgba(255,255,255,.15); border-radius: var(--radius); cursor: pointer; font-size: 13px; transition: all .15s; }
.btn-logout:hover { background: rgba(255,255,255,.08); color: #fff; }

.main-content { margin-left: var(--sidebar-w); flex: 1; padding: 0; overflow-x: hidden; min-height: 100vh; }

/* ---- HEADER ---- */
.dashboard-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 28px; background: #fff; border-bottom: 1px solid var(--gray-200); }
.dashboard-header h1 { font-size: 20px; font-weight: 600; }
.dashboard-header p { color: var(--gray-400); font-size: 13px; margin-top: 2px; }
.header-actions { display: flex; gap: 10px; align-items: center; }

.days-select { padding: 8px 12px; border: 1px solid var(--gray-200); border-radius: var(--radius); font-size: 13px; background: #fff; cursor: pointer; }
.custom-range { display: flex; align-items: center; gap: 8px; }
.date-input { padding: 7px 10px; border: 1px solid var(--gray-200); border-radius: var(--radius); font-size: 13px; background: #fff; }
.date-input:focus { outline: none; border-color: var(--brand); }
.btn-secondary { padding: 8px 14px; background: var(--gray-100); border: 1px solid var(--gray-200); border-radius: var(--radius); font-size: 13px; cursor: pointer; font-weight: 500; transition: background .15s; }
.btn-secondary:hover { background: var(--gray-200); }

/* ---- SECTIONS ---- */
.dashboard-section { padding: 24px 28px; }
.dashboard-section.hidden { display: none; }

/* ---- KPI CARDS ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi-grid-5 { grid-template-columns: repeat(5, 1fr) !important; }
.kpi-grid-6 { grid-template-columns: repeat(6, 1fr) !important; }
.kpi-grid-7 { grid-template-columns: repeat(7, 1fr) !important; }
.kpi-card { background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); border: 1px solid var(--gray-200); }
.kpi-card.highlight { border-color: var(--brand); background: var(--brand-light); border-left: 3px solid var(--brand); }
.kpi-label { font-size: 12px; font-weight: 600; color: var(--gray-400); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--gray-800); line-height: 1; }
.kpi-card.highlight .kpi-value { color: var(--brand); }
.kpi-sub { font-size: 12px; color: var(--gray-400); margin-top: 6px; }

/* ---- CHARTS ---- */
.charts-row { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 24px; }
.chart-card { background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); border: 1px solid var(--gray-200); }
.chart-card.wide { grid-column: span 1; }
.chart-card h3 { font-size: 14px; font-weight: 600; color: var(--gray-600); margin-bottom: 16px; }
.chart-card canvas { max-height: 220px; min-height: 180px; width: 100% !important; }
/* Metric trend picker pills */
.metric-pill { transition: all .15s ease; }
.metric-pill:hover { opacity: .85; transform: translateY(-1px); }
.metric-pill.active { box-shadow: 0 1px 4px rgba(0,0,0,.12); }
#metric-trend-card canvas { max-height: 200px; min-height: 160px; }

/* ---- TABLES ---- */
.table-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--gray-200); overflow: hidden; margin-bottom: 24px; }
.table-card h3 { font-size: 14px; font-weight: 600; color: var(--gray-600); padding: 16px 20px 12px; border-bottom: 1px solid var(--gray-200); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: 10px 16px; text-align: left; font-size: 11px; font-weight: 700; color: var(--gray-400); text-transform: uppercase; letter-spacing: .05em; background: var(--gray-50); border-bottom: 1px solid var(--gray-200); }
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--gray-100); font-size: 13px; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--gray-50); }
.loading-cell { text-align: center; color: var(--gray-400); padding: 32px !important; }

.cm-positive { color: var(--success); font-weight: 600; }
.cm-negative { color: var(--danger); font-weight: 600; }
.cm-neutral  { color: var(--warning); font-weight: 600; }

/* ---- ACCOUNT / SETTINGS ---- */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.settings-card { background: #fff; border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); border: 1px solid var(--gray-200); }
.settings-card-wide { grid-column: span 2; }
.settings-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.settings-desc { font-size: 13px; color: var(--gray-400); margin-bottom: 18px; }
.settings-hint { font-size: 12px; color: var(--gray-400); margin-top: 6px; }

.logo-preview-wrap { margin-bottom: 14px; }
.logo-preview { width: 100%; height: 90px; border: 2px dashed var(--gray-200); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; background: var(--gray-50); overflow: hidden; }
.logo-preview img { max-height: 80px; max-width: 100%; object-fit: contain; }
#logo-placeholder { font-size: 13px; color: var(--gray-400); }

.upload-row { display: flex; gap: 10px; align-items: center; }
.btn-upload { padding: 8px 16px; background: var(--brand); color: #fff; border-radius: var(--radius); font-size: 13px; font-weight: 600; cursor: pointer; display: inline-block; }
.btn-upload:hover { background: var(--brand-dark); }
.btn-remove { padding: 5px 10px; background: transparent; color: var(--danger); border: 1px solid var(--danger); border-radius: var(--radius); font-size: 12px; cursor: pointer; }

.team-invite-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.invite-input { padding: 9px 12px; border: 1px solid var(--gray-200); border-radius: var(--radius); font-size: 13px; flex: 1; min-width: 140px; }
.invite-input:focus { outline: none; border-color: var(--brand); }

.role-badge, .status-badge { padding: 3px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; text-transform: capitalize; }
.role-admin  { background: rgba(45,90,39,.1); color: var(--brand); }
.role-viewer { background: var(--gray-100); color: var(--gray-600); }
.status-pending  { background: var(--warning-bg); color: var(--warning); }
.status-active   { background: var(--success-bg); color: var(--success); }

.cogs-notice { background: var(--warning-bg); color: var(--warning); border-radius: var(--radius); padding: 12px 14px; font-size: 13px; margin-bottom: 16px; border-left: 3px solid var(--warning); }
.cogs-actions { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }

.status-msg { font-size: 13px; margin-top: 10px; padding: 8px 12px; border-radius: var(--radius); }
.status-success { background: var(--success-bg); color: var(--success); }
.status-error   { background: var(--danger-bg);  color: var(--danger); }
.status-info    { background: var(--brand-light); color: var(--brand); }

/* ---- DECISIONS BANNER ---- */
.decisions-banner { margin: 0; padding: 16px 28px; background: #fff; border-bottom: 1px solid var(--gray-200); }
.decisions-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.decisions-title { font-size: 14px; font-weight: 600; color: var(--gray-800); }
.decisions-counts { display: flex; gap: 8px; }
.insight-count { padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.count-danger  { background: var(--danger-bg);  color: var(--danger); }
.count-warning { background: var(--warning-bg); color: var(--warning); }
.count-opp     { background: var(--brand-light); color: var(--brand); }

.decisions-list { display: flex; flex-direction: column; gap: 8px; }
.decision-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-radius: var(--radius); border-left: 3px solid; gap: 16px; }
.decision-danger  { background: var(--danger-bg);  border-color: var(--danger); }
.decision-warning { background: var(--warning-bg); border-color: var(--warning); }
.decision-opportunity { background: var(--brand-light); border-color: var(--brand); }
.decision-content { flex: 1; }
.decision-title { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.decision-danger  .decision-title { color: var(--danger); }
.decision-warning .decision-title { color: var(--warning); }
.decision-opportunity .decision-title { color: var(--brand); }
.decision-msg { font-size: 12px; color: var(--gray-600); }
.decision-action { padding: 6px 12px; border: none; border-radius: var(--radius); font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; background: rgba(0,0,0,.08); color: var(--gray-800); }
.decision-action:hover { background: rgba(0,0,0,.14); }
.decisions-more { font-size: 12px; color: var(--gray-400); text-align: center; margin-top: 8px; }

/* ---- NAV DISABLED ---- */
.nav-item.nav-disabled { opacity: .35; pointer-events: none; cursor: not-allowed; }

/* ---- ADVERTISING PAGE ---- */
.kpi-grid-6 { grid-template-columns: repeat(6, 1fr); }

.table-header-row { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 12px; border-bottom: 1px solid var(--gray-200); flex-wrap: wrap; gap: 8px; }
.table-header-row h3 { font-size: 14px; font-weight: 600; color: var(--gray-600); margin: 0; }

/* Channel toggle in header */
.channel-toggle { display: flex; gap: 6px; }
.channel-tabs { display: flex; gap: 6px; }
.tab-btn { padding: 5px 14px; border: 1px solid var(--gray-200); border-radius: 20px; background: #fff; font-size: 12px; font-weight: 500; cursor: pointer; color: var(--gray-600); transition: all .15s; white-space: nowrap; }
.tab-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Legacy channel badges */
.badge-ads { background: rgba(26,86,219,.1);  color: #1a56db; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge-dsp { background: rgba(5,122,85,.1);   color: #057a55; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }

/* Ad type badges — SP/SB/SD/DSP */
.badge-ad-type { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; letter-spacing: .03em; }
.badge-sp      { background: rgba(26,86,219,.12);  color: #1a56db; }
.badge-sb      { background: rgba(224,123,34,.12); color: #c66a10; }
.badge-sd      { background: rgba(5,122,85,.12);   color: #057a55; }
.badge-dsp-type { background: rgba(126,58,242,.12); color: #6b21e8; }

/* Sortable table headers */
.data-table th.sortable:hover { background: var(--gray-100); color: var(--gray-800); }
.sort-arrow { font-size: 10px; }

/* Table pagination bar */
.table-pagination { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; border-top: 1px solid var(--gray-100); font-size: 12px; color: var(--gray-400); }

/* Glossary link in sidebar */
.glossary-link { display: block; color: rgba(255,255,255,.4); font-size: 12px; text-decoration: none; margin-bottom: 10px; padding: 4px 0; }
.glossary-link:hover { color: rgba(255,255,255,.7); }

/* ---- CONNECTIONS ---- */
.connections-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 24px; }
.connection-card { background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); border: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; }
.connection-card.connected { border-color: var(--success); }
.connection-info h4 { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.connection-info p { font-size: 12px; color: var(--gray-400); }
.connection-badge { padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.badge-connected    { background: var(--success-bg); color: var(--success); }
.badge-disconnected { background: var(--gray-100);   color: var(--gray-400); }
.btn-connect { padding: 8px 14px; background: var(--brand); color: #fff; border: none; border-radius: var(--radius); font-size: 12px; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-block; }

.sync-status { background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); border: 1px solid var(--gray-200); }
.sync-status h3 { font-size: 14px; font-weight: 600; color: var(--gray-600); margin-bottom: 14px; }
.sync-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--gray-100); font-size: 13px; }
.sync-item:last-child { border-bottom: none; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; display: inline-block; }
.dot-success { background: var(--success); }
.dot-failed  { background: var(--danger); }
.dot-running { background: var(--brand); }
.dot-none    { background: var(--gray-400); }

/* ================================================================
   AI CHAT WIDGET
   ================================================================ */
#cb-chat-root { position: fixed; bottom: 24px; right: 24px; z-index: 9999; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }

/* Bubble button */
#cb-chat-bubble {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  border: none;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,.22);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .15s;
  position: relative;
  z-index: 10000;
}
#cb-chat-bubble:hover { background: var(--brand-dark); transform: scale(1.07); }

/* Panel */
#cb-chat-panel {
  position: fixed;
  bottom: 86px; right: 24px;
  width: 360px;
  max-height: 520px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: opacity .2s, transform .2s;
  transform-origin: bottom right;
}
#cb-chat-panel.cb-chat-hidden { display: none; }

/* Header */
#cb-chat-header {
  background: var(--brand);
  color: #fff;
  padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
#cb-chat-title { display: flex; align-items: center; gap: 7px; font-weight: 600; font-size: 14px; }
#cb-chat-subtitle { font-size: 11px; font-weight: 400; opacity: .8; }
#cb-chat-header-actions { display: flex; gap: 4px; }
#cb-chat-header-actions button {
  background: transparent; border: none; color: rgba(255,255,255,.75);
  cursor: pointer; font-size: 14px; padding: 4px 6px; border-radius: 4px;
  transition: background .12s;
}
#cb-chat-header-actions button:hover { background: rgba(255,255,255,.15); color: #fff; }

/* Messages */
#cb-chat-messages {
  flex: 1; overflow-y: auto; padding: 12px 12px 6px;
  display: flex; flex-direction: column; gap: 8px;
  background: #d8d0c4;
}
.cb-msg { display: flex; }
.cb-msg-user  { justify-content: flex-end; }
.cb-msg-assistant { justify-content: flex-start; }
.cb-msg-bubble {
  max-width: 82%; padding: 9px 12px; border-radius: 14px;
  font-size: 13px; line-height: 1.45;
}
.cb-msg-user .cb-msg-bubble {
  background: var(--brand); color: #fff;
  border-bottom-right-radius: 4px;
}
.cb-msg-assistant .cb-msg-bubble {
  background: #fff; color: var(--gray-800);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.cb-msg-bubble ul { margin: 4px 0 4px 16px; padding: 0; }
.cb-msg-bubble li { margin-bottom: 2px; }

/* Typing indicator */
#cb-typing-indicator { padding: 6px 12px; flex-shrink: 0; background: #d8d0c4; }
.cb-typing-dots { display: flex; gap: 4px; align-items: center; }
.cb-typing-dots span {
  width: 7px; height: 7px; background: var(--gray-400);
  border-radius: 50%; animation: cb-bounce 1.2s infinite;
}
.cb-typing-dots span:nth-child(2) { animation-delay: .2s; }
.cb-typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes cb-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-6px); }
}

/* Input row */
#cb-chat-input-row {
  display: flex; gap: 8px; padding: 10px 12px;
  border-top: 1px solid var(--gray-200);
  background: #fff; flex-shrink: 0; align-items: flex-end;
}
#cb-chat-input {
  flex: 1; padding: 8px 10px; border: 1px solid var(--gray-200);
  border-radius: 8px; font-size: 13px; resize: none;
  font-family: inherit; line-height: 1.4; max-height: 120px; overflow-y: auto;
  transition: border-color .15s;
}
#cb-chat-input:focus { outline: none; border-color: var(--brand); }
#cb-send-btn {
  width: 34px; height: 34px; background: var(--brand); color: #fff;
  border: none; border-radius: 8px; cursor: pointer; font-size: 14px;
  flex-shrink: 0; transition: background .15s;
  display: flex; align-items: center; justify-content: center;
}
#cb-send-btn:hover { background: var(--brand-dark); }
#cb-send-btn:disabled { opacity: .5; cursor: not-allowed; }

.cb-hidden { display: none !important; }

/* ================================================================
   CAMPAIGNS PAGE
   ================================================================ */
.campaigns-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 12px; flex-wrap: wrap;
}
.campaigns-search-wrap { flex: 1; max-width: 320px; }
.campaign-search {
  width: 100%; padding: 8px 12px; border: 1px solid var(--gray-200);
  border-radius: var(--radius); font-size: 13px;
}
.campaign-search:focus { outline: none; border-color: var(--brand); }

.table-scroll { overflow-x: auto; }

.campaign-name-cell { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }

.campaign-status { padding: 3px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; text-transform: capitalize; display: inline-block; }
.status-active   { background: var(--success-bg); color: var(--success); }
.status-paused   { background: var(--warning-bg); color: var(--warning); }
.status-archived { background: var(--gray-100);   color: var(--gray-400); }

.badge-type { padding: 2px 7px; border-radius: 8px; font-size: 11px; font-weight: 600; background: var(--brand-light); color: var(--brand); }

.actions-cell { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; }
.btn-action {
  padding: 4px 9px; border: 1px solid var(--gray-200); border-radius: 6px;
  font-size: 11px; font-weight: 600; cursor: pointer; background: #fff;
  color: var(--gray-600); transition: all .12s; white-space: nowrap;
}
.btn-action:hover { background: var(--gray-100); }
.btn-action:disabled { opacity: .5; cursor: not-allowed; }
.btn-queued { background: var(--success-bg) !important; color: var(--success) !important; border-color: var(--success) !important; }

.expand-cell { width: 32px; }
.expand-btn {
  background: transparent; border: none; color: var(--gray-400);
  cursor: pointer; font-size: 11px; padding: 2px 4px;
  border-radius: 4px; transition: color .12s;
}
.expand-btn:hover { color: var(--brand); }

.campaign-expand-row.hidden { display: none; }
.campaign-expand-cell { padding: 0 !important; background: var(--gray-50); }
.campaign-expand-inner { padding: 16px 20px; }

.pending-actions-banner {
  background: var(--warning-bg); color: var(--warning);
  border-radius: var(--radius); padding: 10px 16px; font-size: 13px;
  margin-bottom: 16px; border-left: 3px solid var(--warning);
}

/* ================================================================
   TOAST NOTIFICATION
   ================================================================ */
.cb-toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--gray-800); color: #fff; padding: 10px 20px;
  border-radius: 20px; font-size: 13px; font-weight: 500;
  opacity: 0; transition: opacity .25s, transform .25s; z-index: 99999;
  white-space: nowrap; pointer-events: none;
}
.cb-toast.cb-toast-show { opacity: 1; transform: translateX(-50%) translateY(0); }
.cb-toast.cb-toast-error { background: var(--danger); }

/* ============================================================
   COLLAPSIBLE SIDEBAR
   ============================================================ */
.sidebar { transition: width .2s ease; overflow: hidden; }
.sidebar.collapsed { width: 60px; }
.sidebar.collapsed .sidebar-logo img { max-height: 30px; max-width: 40px; }
.sidebar.collapsed .nav-item { padding: 12px 0; justify-content: center; font-size: 18px; }
.sidebar.collapsed .nav-item-text { display: none; }
.sidebar.collapsed .sidebar-footer { padding: 12px 8px; }
.sidebar.collapsed #client-name,
.sidebar.collapsed .btn-logout { display: none; }
.sidebar.collapsed .sidebar-footer::after { content: '→'; color: rgba(255,255,255,.4); display: block; text-align: center; font-size: 16px; }

.sidebar-toggle { position: fixed; bottom: 60px; left: calc(var(--sidebar-w) - 12px); width: 24px; height: 24px; background: var(--brand-dark); border: 2px solid rgba(255,255,255,.3); border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; color: rgba(255,255,255,.8); font-size: 11px; transition: all .2s; z-index: 101; }
.sidebar-toggle:hover { background: var(--brand-mid); color: #fff; }
.sidebar.collapsed ~ * .sidebar-toggle,
.sidebar.collapsed .sidebar-toggle { left: calc(60px - 12px); }

.main-content { transition: margin-left .2s ease; }

/* ============================================================
   RESPONSIVE / MOBILE
   ============================================================ */
@media (max-width: 768px) {
  /* Show hamburger, hide sidebar by default */
  .hamburger { display: block; }
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; width: var(--sidebar-w) !important; position: fixed; z-index: 100; }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar-overlay.active { display: block; }
  .main-content { margin-left: 0 !important; }

  /* Header */
  .dashboard-header { padding: 14px 16px 14px 56px; flex-wrap: wrap; gap: 10px; }
  .dashboard-header h1 { font-size: 17px; }
  .header-actions { width: 100%; }
  .days-select { width: 100%; }
  .custom-range { flex-wrap: wrap; }

  /* KPI grids — stack to 2 columns on mobile */
  .kpi-grid, .kpi-grid-6, .kpi-grid-7 { grid-template-columns: repeat(2, 1fr) !important; }
  .kpi-value { font-size: 20px; }

  /* Charts — single column */
  .charts-row { grid-template-columns: 1fr !important; }

  /* Tables — horizontal scroll */
  .table-card { overflow-x: auto; }
  .data-table { min-width: 600px; }

  /* Settings grid — single column */
  .settings-grid { grid-template-columns: 1fr !important; }
  .settings-card-wide { grid-column: span 1 !important; }

  /* Connections grid — single column */
  .connections-grid { grid-template-columns: 1fr !important; }

  /* Decisions banner */
  .decisions-banner { padding: 12px 16px 12px 56px; }
  .decisions-list { gap: 6px; }
  .decision-item { flex-direction: column; align-items: flex-start; gap: 8px; }

  /* Dashboard section padding */
  .dashboard-section { padding: 16px; }

  /* Admin */
  .stats-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .invite-row { flex-direction: column; }
}

@media (max-width: 480px) {
  .kpi-grid, .kpi-grid-6, .kpi-grid-7 { grid-template-columns: 1fr !important; }
  .kpi-value { font-size: 22px; }
  .auth-card { margin: 16px; padding: 28px 20px; }
}

/* ---- BELL + INSIGHTS PANEL ---- */
.bell-btn { position: relative; background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 8px 12px; font-size: 16px; cursor: pointer; transition: background .15s; }
.bell-btn:hover { background: var(--gray-100); }
.bell-badge { position: absolute; top: -6px; right: -6px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 4px; }

.insights-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 299; }
.insights-panel { position: fixed; top: 0; right: 0; width: 380px; max-width: 95vw; height: 100vh; background: #fff; box-shadow: -4px 0 24px rgba(0,0,0,.12); z-index: 300; display: flex; flex-direction: column; transform: translateX(100%); transition: transform .25s ease; }
.insights-panel.open { transform: translateX(0); }
.insights-panel-header { display: flex; align-items: center; justify-content: space-between; padding: 20px; border-bottom: 1px solid var(--gray-200); background: var(--brand-dark); }
.insights-panel-header h3 { color: #fff; font-size: 15px; font-weight: 600; }
.insights-close { background: none; border: none; color: rgba(255,255,255,.7); font-size: 18px; cursor: pointer; padding: 4px; }
.insights-close:hover { color: #fff; }
.insights-list { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.insight-card { border-radius: var(--radius); padding: 14px; border-left: 3px solid; }
.insight-card.danger  { background: var(--danger-bg);  border-color: var(--danger); }
.insight-card.warning { background: var(--warning-bg); border-color: var(--warning); }
.insight-card.opportunity { background: var(--brand-light); border-color: var(--brand); }
.insight-card-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.insight-card.danger  .insight-card-title { color: var(--danger); }
.insight-card.warning .insight-card-title { color: var(--warning); }
.insight-card.opportunity .insight-card-title { color: var(--brand); }
.insight-card-msg { font-size: 12px; color: var(--gray-600); margin-bottom: 10px; line-height: 1.5; }
.insight-card-action { display: inline-block; padding: 5px 12px; background: rgba(0,0,0,.07); border: none; border-radius: var(--radius); font-size: 12px; font-weight: 600; cursor: pointer; color: var(--gray-800); }
.insight-card-action:hover { background: rgba(0,0,0,.12); }
.insights-empty { text-align: center; color: var(--gray-400); padding: 48px 20px; font-size: 14px; }
.insights-empty .insights-check { font-size: 40px; margin-bottom: 12px; }

/* ---- LAYOUT FIXES ---- */
html { scroll-behavior: smooth; }
.dashboard-page { overflow-x: hidden; }
.main-content { overflow-y: auto; height: 100vh; position: relative; box-sizing: border-box; }


/* ---- HEALTH SCORE BADGES ---- */
.health-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.health-healthy { background: var(--success-bg); color: var(--success); }
.health-fair    { background: var(--warning-bg); color: var(--warning); }
.health-at-risk { background: var(--danger-bg);  color: var(--danger); }

/* ---- CM WATERFALL ---- */
.cm-waterfall { display: flex; flex-direction: column; gap: 10px; padding: 8px 0; }
.cm-waterfall-row { display: flex; align-items: center; gap: 12px; }
.cm-waterfall-label { min-width: 180px; font-size: 13px; color: var(--gray-600); font-weight: 500; }
.cm-waterfall-bar-wrap { flex: 1; background: var(--gray-100); border-radius: 4px; height: 22px; overflow: hidden; }
.cm-waterfall-bar { height: 100%; border-radius: 4px; transition: width .4s ease; min-width: 4px; }
.cm-waterfall-value { min-width: 90px; text-align: right; font-size: 13px; font-weight: 600; }
.bar-revenue  { background: #1a56db; }
.bar-cm1      { background: #057a55; }
.bar-cm2      { background: #0694a2; }
.bar-cm3      { background: #2d5a27; }
.bar-negative { background: #e02424; }
.cm-wf-pct { font-size: 11px; color: var(--gray-400); margin-left: 4px; font-weight: 400; }
