/* ========================================
   Farahi Law — Unified Marketing Intelligence
   Premium executive dashboard styling
   ======================================== */

:root {
  /* Backgrounds */
  --bg-base: #070A14;
  --bg-shell: #0A0E1A;
  --bg-panel: #0F1729;
  --bg-panel-2: #131C32;
  --bg-elev: #1A2440;
  --bg-hover: rgba(255, 255, 255, 0.04);
  --bg-active: rgba(212, 175, 55, 0.08);

  /* Borders */
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);
  --border-gold: rgba(212, 175, 55, 0.18);

  /* Text */
  --text: #F1F5F9;
  --text-2: #CBD5E1;
  --text-mute: #64748B;
  --text-dim: #475569;

  /* Brand */
  --gold: #D4AF37;
  --gold-2: #E9C868;
  --gold-3: #B8893A;
  --gold-soft: rgba(212, 175, 55, 0.12);

  /* Semantic */
  --good: #10B981;
  --good-soft: rgba(16, 185, 129, 0.12);
  --warn: #F59E0B;
  --warn-soft: rgba(245, 158, 11, 0.12);
  --bad: #EF4444;
  --bad-soft: rgba(239, 68, 68, 0.12);
  --info: #3B82F6;
  --info-soft: rgba(59, 130, 246, 0.12);
  --violet: #A78BFA;

  /* Brand colors */
  --c-jfj: #D4AF37;
  --c-ayuda: #EF4444;
  --c-visalia: #10B981;
  --c-kapwa: #A78BFA;

  /* Typography */
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6);
  --glow-gold: 0 0 0 1px rgba(212, 175, 55, 0.2), 0 8px 32px rgba(212, 175, 55, 0.1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-base);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(212, 175, 55, 0.06), transparent 60%),
    radial-gradient(900px 500px at -10% 90%, rgba(59, 130, 246, 0.05), transparent 60%),
    var(--bg-base);
  min-height: 100vh;
  overflow-x: hidden;
}

button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
table { border-collapse: collapse; width: 100%; }

/* ============================
   APP SHELL
   ============================ */
.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

/* ============================
   SIDEBAR
   ============================ */
.sidebar {
  background: linear-gradient(180deg, #0A0F1E 0%, #070B17 100%);
  border-right: 1px solid var(--border);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 4px; }

.brand-mark {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.brand-crest {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(212,175,55,0.15), rgba(212,175,55,0.05));
  border: 1px solid var(--border-gold);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-firm {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.02em;
  color: var(--text);
}

.brand-sub {
  font-size: 11px;
  color: var(--gold);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
}

/* Brand switcher */
.brand-switcher {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.switcher-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-mute);
  font-weight: 600;
  padding: 0 8px 10px;
}

.brand-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-2);
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: all 0.15s ease;
}
.brand-pill:hover { background: var(--bg-hover); color: var(--text); }
.brand-pill.active {
  background: var(--bg-active);
  border-color: var(--border-gold);
  color: var(--text);
}
.brand-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.04);
}
.brand-pill .dot.all { background: linear-gradient(135deg, var(--c-jfj), var(--c-ayuda) 33%, var(--c-visalia) 66%, var(--c-kapwa)); }
.brand-pill .dot.jfj { background: var(--c-jfj); }
.brand-pill .dot.ayuda { background: var(--c-ayuda); }
.brand-pill .dot.visalia { background: var(--c-visalia); }
.brand-pill .dot.kapwa { background: var(--c-kapwa); }
.brand-meta {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-mute);
  background: rgba(255,255,255,0.04);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

/* Navigation */
.nav { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.nav-group {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-mute);
  font-weight: 600;
  padding: 16px 8px 8px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s ease;
  cursor: pointer;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active {
  background: linear-gradient(90deg, var(--gold-soft), transparent);
  color: var(--text);
  position: relative;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -18px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  border-radius: 0 2px 2px 0;
}
.nav-item svg { color: var(--text-mute); flex-shrink: 0; }
.nav-item.active svg { color: var(--gold); }

.nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255,255,255,0.06);
  color: var(--text-2);
  font-family: var(--font-mono);
}
.nav-badge.alert { background: var(--bad-soft); color: var(--bad); }
.nav-badge.live { background: var(--good-soft); color: var(--good); position: relative; padding-left: 14px; }
.nav-badge.live::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--good);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.6); }
  50% { box-shadow: 0 0 0 4px rgba(16,185,129,0); }
}

/* Footer */
.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--gold-2), var(--gold-3));
  color: #0A0E1A;
  font-weight: 700;
  font-size: 13px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-mute); }
.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-mute);
  padding: 6px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  position: relative;
  transition: all 0.15s ease;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border); }

/* ============================
   MAIN
   ============================ */
.main { padding: 0; min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 28px;
  background: rgba(7, 10, 20, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-mute);
}
.crumb.current { color: var(--text); font-weight: 600; }

.search {
  flex: 1;
  max-width: 480px;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  transition: border-color 0.15s ease;
}
.search:focus-within { border-color: var(--border-gold); }
.search svg { color: var(--text-mute); }
.search input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
}
.search input::placeholder { color: var(--text-mute); }
.search kbd {
  font-size: 10px;
  padding: 3px 6px;
  background: rgba(255,255,255,0.05);
  color: var(--text-mute);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-weight: 600;
  border: 1px solid var(--border);
}

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.freshness {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--good-soft);
  border: 1px solid rgba(16,185,129,0.2);
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
  color: var(--good);
}
.freshness-pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 0 rgba(16,185,129,0.6);
  animation: pulse 2s infinite;
}

.date-range {
  display: flex;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
}
.seg {
  background: transparent;
  border: none;
  color: var(--text-mute);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s ease;
}
.seg:hover { color: var(--text); }
.seg.active {
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.icon-btn.ghost { background: var(--bg-panel); border-color: var(--border); padding: 8px; }
.dot-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--bad);
  border: 2px solid var(--bg-panel);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--gold-2), var(--gold-3));
  color: #0A0E1A;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: all 0.15s ease;
  box-shadow: 0 4px 12px rgba(212,175,55,0.2);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(212,175,55,0.3);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s ease;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border-strong); }
.btn-ghost.small { padding: 5px 10px; font-size: 11px; }

/* ============================
   VIEWS
   ============================ */
.view {
  display: none;
  padding: 28px;
  flex-direction: column;
  gap: 20px;
  animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.view.active { display: flex; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.view-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px 0;
  letter-spacing: -0.02em;
}
.view-title .serif {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 700;
  background: linear-gradient(135deg, var(--gold-2), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.view-sub {
  margin: 0;
  color: var(--text-mute);
  font-size: 13px;
}
.view-sub b { color: var(--text-2); font-weight: 600; }

.head-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.meta-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
}
.meta-chip.live {
  background: var(--good-soft);
  border-color: rgba(16,185,129,0.2);
  color: var(--good);
}
.meta-label { color: var(--text-mute); font-weight: 500; }
.meta-value { color: var(--text); font-weight: 600; font-family: var(--font-mono); }

/* ============================
   KPI CARDS
   ============================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
}
.kpi-grid.k5 { grid-template-columns: repeat(5, 1fr); }
.kpi-grid.k4 { grid-template-columns: repeat(4, 1fr); }

.kpi {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.025), rgba(255,255,255,0.005)),
    var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  overflow: hidden;
  transition: all 0.2s ease;
}
.kpi::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(400px 200px at 100% 0%, rgba(212,175,55,0.04), transparent 60%);
  pointer-events: none;
}
.kpi:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.kpi.gold {
  border-color: var(--border-gold);
  background:
    linear-gradient(180deg, rgba(212,175,55,0.06), rgba(212,175,55,0.01)),
    var(--bg-panel);
  box-shadow: var(--glow-gold);
}
.kpi.accent {
  border-color: rgba(16, 185, 129, 0.2);
  background:
    linear-gradient(180deg, rgba(16,185,129,0.05), rgba(16,185,129,0.01)),
    var(--bg-panel);
}

.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-mute);
  font-weight: 600;
}
.kpi-source {
  font-size: 9px;
  color: var(--text-dim);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.kpi-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  font-feature-settings: 'tnum' 1;
  margin-bottom: 8px;
  font-family: var(--font);
}
.kpi.gold .kpi-value {
  background: linear-gradient(135deg, #FFF, var(--gold-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.kpi-unit { font-size: 18px; color: var(--text-mute); font-weight: 500; margin-left: 2px; }

.kpi-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.trend {
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  padding: 3px 8px;
  border-radius: 100px;
  letter-spacing: 0.02em;
}
.trend.up { background: var(--good-soft); color: var(--good); }
.trend.down { background: var(--bad-soft); color: var(--bad); }
.trend.down.good { background: var(--good-soft); color: var(--good); }
.trend.up.good { background: var(--good-soft); color: var(--good); }
.trend.live { background: var(--good-soft); color: var(--good); display: inline-flex; align-items: center; gap: 6px; }
.trend.small { font-size: 10px; padding: 2px 6px; }

.spark { width: 80px !important; height: 28px !important; }

/* ============================
   PANELS
   ============================ */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  transition: border-color 0.15s ease;
}
.panel:hover { border-color: var(--border-strong); }

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}
.panel-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 2px;
  letter-spacing: -0.01em;
}
.panel-sub {
  font-size: 12px;
  color: var(--text-mute);
  margin: 0;
}

.panel-body { padding: 20px; }
.panel-body.chart-shell { padding: 16px 20px; min-height: 280px; position: relative; }
.panel-body.chart-shell.tall { min-height: 340px; }

.legend { display: flex; gap: 14px; }
.lg {
  font-size: 11px;
  color: var(--text-mute);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}
.lg::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 2px;
}
.lg-spend::before { background: var(--gold); }
.lg-leads::before { background: var(--info); }
.lg-signed::before { background: var(--good); }
.lg-conv::before { background: var(--violet); }

.seg-mini {
  display: flex;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
}
.seg-mini .seg { padding: 4px 10px; font-size: 11px; }

/* Donut */
.donut-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}
.donut-num {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.donut-lbl {
  display: block;
  font-size: 10px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2px;
}

.legend-stack {
  padding: 0 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lg-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-2);
}
.lg-row b {
  margin-left: auto;
  font-weight: 600;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11px;
}
.dot-sm { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }

/* ============================
   GRID LAYOUTS
   ============================ */
.grid-2-1 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}
.grid-1-1 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ============================
   FUNNEL
   ============================ */
.funnel { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.funnel-step {
  position: relative;
  padding: 14px 16px;
  border-radius: 10px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--c, var(--gold)) 18%, transparent), color-mix(in srgb, var(--c, var(--gold)) 6%, transparent));
  border: 1px solid color-mix(in srgb, var(--c, var(--gold)) 24%, transparent);
  width: var(--w, 100%);
  margin-left: 0;
  transition: all 0.2s ease;
}
.funnel-step:hover { transform: translateX(2px); }
.fs-label { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.fs-name { font-size: 12px; color: var(--text-2); font-weight: 600; }
.fs-val { font-size: 16px; font-weight: 700; color: var(--text); font-feature-settings: 'tnum' 1; }
.fs-rate {
  position: absolute;
  right: -68px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--text-mute);
  font-family: var(--font-mono);
  font-weight: 600;
}

/* ============================
   TABLES
   ============================ */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  font-size: 13px;
}
.data-table thead th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-mute);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-base);
  white-space: nowrap;
}
.data-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  vertical-align: middle;
}
.data-table tbody tr { transition: background 0.15s ease; }
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .num {
  text-align: right;
  font-family: var(--font-mono);
  font-feature-settings: 'tnum' 1;
  font-weight: 500;
  white-space: nowrap;
}
.data-table .num.pos { color: var(--good); font-weight: 600; }
.data-table .num.neg { color: var(--bad); font-weight: 600; }
.data-table .num.warn { color: var(--warn); font-weight: 600; }

.cell-strong { font-weight: 600; color: var(--text); }
.cell-sub { font-size: 11px; color: var(--text-mute); margin-top: 2px; font-family: var(--font-mono); }

.brand-tag {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
}
.brand-tag.jfj { background: rgba(212,175,55,0.12); color: var(--c-jfj); border: 1px solid rgba(212,175,55,0.2); }
.brand-tag.ayuda { background: rgba(239,68,68,0.12); color: var(--c-ayuda); border: 1px solid rgba(239,68,68,0.2); }
.brand-tag.visalia { background: rgba(16,185,129,0.12); color: var(--c-visalia); border: 1px solid rgba(16,185,129,0.2); }
.brand-tag.kapwa { background: rgba(167,139,250,0.12); color: var(--c-kapwa); border: 1px solid rgba(167,139,250,0.2); }

.platform-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
}
.platform-badge .plat-logo {
  flex-shrink: 0;
  border-radius: 3px;
}
.platform-badge > span {
  font-weight: 500;
  letter-spacing: 0.005em;
}

.status {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
}
.status.signed { background: var(--good-soft); color: var(--good); }
.status.engaged { background: var(--info-soft); color: var(--info); }
.status.pending { background: var(--warn-soft); color: var(--warn); }
.status.disqualified { background: rgba(100,116,139,0.18); color: var(--text-mute); }

/* ============================
   ALERTS FEED
   ============================ */
.alerts-feed { padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.alerts-feed.full { padding: 16px; gap: 8px; }

.alert-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-panel-2);
  transition: all 0.15s ease;
  align-items: flex-start;
}
.alert-item:hover { border-color: var(--border-strong); transform: translateX(2px); }
.alert-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-weight: 800;
  font-size: 14px;
}
.alert-item.critical { border-color: rgba(239,68,68,0.25); background: linear-gradient(180deg, rgba(239,68,68,0.05), transparent); }
.alert-item.critical .alert-icon { background: var(--bad-soft); color: var(--bad); }
.alert-item.warn { border-color: rgba(245,158,11,0.2); }
.alert-item.warn .alert-icon { background: var(--warn-soft); color: var(--warn); }
.alert-item.info .alert-icon { background: var(--info-soft); color: var(--info); }

.alert-body { flex: 1; min-width: 0; }
.alert-title { font-weight: 600; color: var(--text); font-size: 13px; margin-bottom: 2px; }
.alert-meta { font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.alert-time { font-size: 11px; color: var(--text-mute); font-family: var(--font-mono); }
.alert-actions { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }

/* ============================
   INTEGRATION CARDS
   ============================ */
.integration-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 14px;
  padding: 16px;
}
.integration-grid.full {
  padding: 0;
}

.int-card {
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.int-card.lg { padding: 18px; gap: 0; }
.int-card:hover { border-color: var(--border-strong); }
.int-card.ok { border-left: 3px solid var(--good); }
.int-card.warn { border-left: 3px solid var(--warn); }

.int-name {
  font-weight: 700;
  color: var(--text);
  font-size: 14px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.int-status { font-size: 11px; color: var(--good); font-weight: 600; }
.int-card.warn .int-status { color: var(--warn); }
.int-meta {
  font-size: 11px;
  color: var(--text-mute);
  margin-top: 8px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.int-bar {
  height: 4px;
  background: rgba(255,255,255,0.04);
  border-radius: 2px;
  margin-top: 10px;
  overflow: hidden;
}
.int-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--good), #34D399);
  border-radius: 2px;
}
.int-bar.warn span { background: linear-gradient(90deg, var(--warn), #FBBF24); }

.int-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
  min-width: 0;
}

.int-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  min-width: 0;
}
.int-stats > div { min-width: 0; overflow: hidden; }
.int-stats .kv-value {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.int-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.int-actions .btn-primary,
.int-actions .btn-ghost {
  flex: 1 1 auto;
  font-size: 11px;
  padding: 7px 10px;
  white-space: nowrap;
  text-align: center;
}
.int-actions .btn-primary { flex: 1 1 100%; min-width: 100%; }
@media (min-width: 420px) {
  .int-actions .btn-primary { flex: 1 1 calc(50% - 3px); min-width: 0; }
}

.kv-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.kv-label { font-size: 10px; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; margin-bottom: 2px; }
.kv-value { font-size: 14px; font-weight: 700; color: var(--text); font-family: var(--font-mono); }

/* ============================
   SPLIT BARS / RANK / SOURCE
   ============================ */
.split-row, .rank-row, .src-row {
  display: grid;
  grid-template-columns: 140px 1fr 100px;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  font-size: 13px;
}
.split-name, .rank-label, .src-name { color: var(--text-2); display: flex; align-items: center; gap: 8px; font-weight: 500; }
.split-bar, .rank-bar, .src-bar {
  height: 8px;
  background: rgba(255,255,255,0.04);
  border-radius: 4px;
  overflow: hidden;
}
.split-bar span, .rank-bar span, .src-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold-2));
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.split-val, .rank-val, .src-val {
  text-align: right;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text);
  font-size: 12px;
}

/* ============================
   RESPONSIVE
   ============================ */
@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .kpi-grid.k5 { grid-template-columns: repeat(3, 1fr); }
  /* Integration grid uses its own auto-fill rule — let it breathe */
}
@media (max-width: 1024px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; transform: translateX(-100%); z-index: 100; width: 280px; }
  .grid-2-1, .grid-1-1 { grid-template-columns: 1fr; }
  .kpi-grid, .kpi-grid.k5, .kpi-grid.k4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; padding: 12px 16px; }
  .search { order: 10; flex: 0 0 100%; max-width: none; margin-left: 0; }
  .view { padding: 16px; }
  .kpi-grid, .kpi-grid.k5, .kpi-grid.k4 { grid-template-columns: 1fr; }
  .view-title { font-size: 22px; }
  .date-range { display: none; }
}

/* ============================
   MODAL
   ============================ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(7, 10, 20, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  z-index: 200;
  padding: 24px;
  animation: fadeIn 0.18s ease;
}
.modal-backdrop[hidden] { display: none; }

.modal-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  width: 100%;
  max-width: 580px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6), 0 0 0 1px rgba(212,175,55,0.08);
  animation: slideUp 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-card.wide { max-width: 760px; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.modal-body {
  padding: 22px;
  overflow-y: auto;
  flex: 1;
}
.modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--bg-base);
  border-radius: 0 0 16px 16px;
}

/* Form fields inside modals */
.form-row { margin-bottom: 14px; }
.form-row.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-mute);
  margin-bottom: 6px;
  font-weight: 600;
}
.form-row .hint {
  font-size: 11px;
  color: var(--text-mute);
  margin-top: 6px;
  font-weight: 500;
  line-height: 1.5;
}
.form-row input,
.form-row select,
.form-row textarea {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s ease;
}
.form-row textarea {
  font-family: var(--font-mono);
  resize: vertical;
  min-height: 80px;
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--border-gold);
}
.form-row input.has-value::placeholder { color: var(--good); }

.scope-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.scope-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s ease;
}
.scope-chip input { margin: 0; accent-color: var(--gold); }
.scope-chip:hover { border-color: var(--border-strong); }
.scope-chip.checked { border-color: var(--border-gold); background: var(--bg-active); color: var(--text); }

.modal-msg {
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 14px;
  font-size: 13px;
}
.modal-msg.error { background: var(--bad-soft); color: var(--bad); }
.modal-msg.ok    { background: var(--good-soft); color: var(--good); }
.modal-msg.info  { background: var(--info-soft); color: var(--info); }

.row-actions { display: inline-flex; gap: 6px; justify-content: flex-end; }
.row-actions .btn-ghost { padding: 4px 8px; font-size: 11px; }

.qr-frame {
  background: #fff;
  padding: 12px;
  border-radius: 12px;
  display: inline-block;
  margin: 8px 0;
}
.qr-frame img { display: block; max-width: 220px; }

.cred-status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 100px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  flex-shrink: 0;
}
.cred-status.set     { background: var(--good-soft); color: var(--good); }
.cred-status.notset  { background: rgba(255,255,255,0.05); color: var(--text-mute); }

.brand-map-row {
  display: grid;
  grid-template-columns: 1fr 24px 1fr 36px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.brand-map-row .arrow { text-align: center; color: var(--text-mute); }
.brand-map-row .remove { background: transparent; border: 1px solid var(--border); color: var(--text-mute); border-radius: 6px; cursor: pointer; }
.brand-map-row .remove:hover { color: var(--bad); border-color: var(--bad); }

/* ============================
   GOALS
   ============================ */
.goal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 14px;
}

.goal-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  position: relative;
  overflow: hidden;
  transition: all 0.2s ease;
}
.goal-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(400px 200px at 100% 0%, var(--g-glow, rgba(212,175,55,0.04)), transparent 60%);
  pointer-events: none;
}
.goal-card:hover { border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow); }
.goal-card.pinned { border-color: var(--border-gold); box-shadow: var(--glow-gold); }

.goal-card.status-on_track { --g-glow: rgba(16, 185, 129, 0.06); border-left: 3px solid var(--good); }
.goal-card.status-achieved { --g-glow: rgba(212, 175, 55, 0.10); border-left: 3px solid var(--gold); }
.goal-card.status-at_risk  { --g-glow: rgba(245, 158, 11, 0.06); border-left: 3px solid var(--warn); }
.goal-card.status-behind   { --g-glow: rgba(239, 68, 68, 0.06);  border-left: 3px solid var(--bad); }
.goal-card.status-no_data  { border-left: 3px solid var(--text-dim); }

.goal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.goal-title { font-weight: 700; font-size: 14px; color: var(--text); margin: 0 0 2px; line-height: 1.35; }
.goal-meta  { font-size: 11px; color: var(--text-mute); display: flex; gap: 8px; flex-wrap: wrap; }
.goal-meta b { color: var(--text-2); font-weight: 600; }

.goal-status {
  font-size: 10px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 100px;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: var(--font-mono);
  flex-shrink: 0;
}
.goal-status.on_track { background: var(--good-soft); color: var(--good); }
.goal-status.achieved { background: rgba(212,175,55,0.15); color: var(--gold); }
.goal-status.at_risk  { background: var(--warn-soft); color: var(--warn); }
.goal-status.behind   { background: var(--bad-soft); color: var(--bad); }
.goal-status.no_data  { background: rgba(100,116,139,0.15); color: var(--text-mute); }

.goal-numbers {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.goal-numbers .gn-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-mute); font-weight: 600; margin-bottom: 4px; }
.goal-numbers .gn-value {
  font-size: 18px; font-weight: 700; color: var(--text);
  font-feature-settings: 'tnum' 1; letter-spacing: -0.01em;
}
.goal-numbers .gn-value.muted { color: var(--text-mute); font-weight: 500; font-size: 14px; }

.goal-progress {
  margin-bottom: 14px;
}
.goal-progress-bars {
  position: relative;
  height: 8px;
  background: rgba(255,255,255,0.04);
  border-radius: 4px;
  overflow: hidden;
}
.goal-progress-bars .actual {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold-2));
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.goal-progress-bars .pace {
  position: absolute;
  top: -3px; bottom: -3px;
  width: 2px;
  background: var(--text-mute);
  pointer-events: none;
}
.goal-progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-mute);
  margin-top: 6px;
  font-family: var(--font-mono);
}

.goal-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.goal-actions .btn-ghost,
.goal-actions .btn-primary {
  flex: 1 1 auto;
  font-size: 11px;
  padding: 7px 10px;
  white-space: nowrap;
}

/* AI insights modal */
.ai-summary {
  background: linear-gradient(180deg, rgba(212,175,55,0.06), rgba(212,175,55,0.02));
  border: 1px solid var(--border-gold);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.55;
}
.ai-summary::before {
  content: '✦';
  display: inline-block;
  margin-right: 8px;
  color: var(--gold);
  font-weight: 700;
}

.recs-list { display: flex; flex-direction: column; gap: 10px; }
.rec-item {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.rec-item .rec-title { font-weight: 600; color: var(--text); font-size: 13px; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.rec-item .rec-num {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--gold-soft); color: var(--gold);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.rec-item .rec-rationale { font-size: 12px; color: var(--text-2); line-height: 1.55; margin-bottom: 6px; }
.rec-item .rec-impact { font-size: 11px; color: var(--gold); font-weight: 600; }

.risks-list {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.risks-list h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-mute); margin: 0 0 8px; }
.risks-list li { font-size: 12px; color: var(--text-2); margin-bottom: 4px; }

.spinner {
  width: 28px; height: 28px;
  border: 3px solid rgba(255,255,255,0.08);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }
