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

:root {
  --bg: #0f1117;
  --bg-card: #1a1c2e;
  --bg-sidebar: #161822;
  --bg-input: #232538;
  --bg-hover: #252840;
  --border: #2a2d42;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-heading: #f1f5f9;
  --radius: 8px;
  --sidebar-width: 240px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 10;
}

.sidebar-brand {
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  height: 57px;
}

.sidebar-brand h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-heading);
}

.sidebar nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover { background: var(--bg-hover); color: var(--text); }
.nav-link.active { background: var(--accent); color: #fff; }
.nav-link.active svg { stroke: #fff; }

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

/* ===== Main ===== */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  height: 57px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sidebar);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-heading);
  white-space: nowrap;
  margin-right: auto;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ===== Global Search ===== */
.global-search-wrapper {
  position: relative;
  flex: 0 1 360px;
}
.global-search-input {
  width: 100%;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-main);
  color: var(--text-heading);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
.global-search-input:focus {
  border-color: var(--accent);
}
.global-search-input::placeholder {
  color: var(--text-muted);
}
.search-results-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  max-height: 400px;
  overflow-y: auto;
  z-index: 100;
}
.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: rgba(99,102,241,0.1); }
.search-result-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.search-result-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-detail {
  font-size: 11px;
  color: var(--text-muted);
}
.search-result-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.search-result-type {
  font-size: 10px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.content {
  padding: 24px 28px;
  flex: 1;
  min-width: 0;
}

/* ===== Cards ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.card-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-heading);
}

.card-value.accent { color: var(--accent); }
.card-value.success { color: var(--success); }
.card-value.warning { color: var(--warning); }
.card-value.sm { font-size: 20px; }
.card-value.md { font-size: 24px; }

/* ===== Delta Badges ===== */
.delta-row {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.delta {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  cursor: default;
}
.delta-up { background: #14532d; color: #4ade80; }
.delta-down { background: #7f1d1d; color: #fca5a5; }
.delta-neutral { background: #374151; color: #9ca3af; }

/* ===== Clickable Cards ===== */
a.card-clickable {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
}
a.card-clickable:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

/* ===== Activity Feed ===== */
.activity-feed {
  max-height: 400px;
  overflow-y: auto;
}
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-icon { font-size: 16px; flex-shrink: 0; line-height: 1.4; }
.activity-body { flex: 1; min-width: 0; }
.activity-link {
  display: inline-block;
  font-size: 11px;
  color: var(--accent);
  margin-left: 6px;
}
.activity-time { white-space: nowrap; flex-shrink: 0; }

/* ===== Health Score Badge ===== */
.health-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  min-width: 28px;
  text-align: center;
  padding: 2px 6px;
  border-radius: 10px;
}
.health-good { background: #14532d; color: #4ade80; }
.health-moderate { background: #78350f; color: #fbbf24; }
.health-risk { background: #7f1d1d; color: #fca5a5; }

.health-info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-muted);
  cursor: pointer;
  vertical-align: middle;
  margin-left: 4px;
}
.health-info-btn:hover { background: var(--text-muted); color: var(--bg); }

.health-popover {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 100;
  min-width: 220px;
  background: var(--bg-card, #1e1e2e);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  font-weight: 400;
  font-size: 12px;
  line-height: 1.6;
  max-width: 320px;
  overflow-wrap: break-word;
}
.health-popover-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 6px;
}

.health-filter-group {
  display: flex;
  gap: 4px;
}

.btn.btn-warning {
  background: #78350f;
  color: #fbbf24;
  border: 1px solid #92400e;
}
.btn.btn-warning:hover:not(:disabled) { background: #92400e; }

/* ===== Admin Notes ===== */
.notes-list { max-height: 300px; overflow-y: auto; }
.note-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.note-item:last-child { border-bottom: none; }
.note-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
  line-height: 1;
}
.btn-icon:hover { color: #ef4444; }

/* ===== Card Title (inside .card) ===== */
.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-heading);
  margin: 0 0 12px;
}

/* ===== Table Toolbar Title ===== */
.toolbar-title {
  font-weight: 600;
  font-size: 14px;
}

/* ===== Distribution Bar Rows ===== */
.dist-row {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.dist-row:last-child { border-bottom: none; }
.dist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.dist-label { font-size: 13px; font-weight: 500; }
.dist-value { font-size: 13px; font-weight: 600; }
.dist-pct { font-weight: 400; color: var(--text-muted); font-size: 12px; }
.dist-bar-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.dist-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
}
.dist-bar-fill.green { background: var(--success); }

/* ===== Responsive Grid Utilities ===== */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }

@media (max-width: 1024px) {
  .grid-5 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-2-1 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .grid-5 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .grid-5, .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

/* ===== Version Rollout Table ===== */
.version-rollout-table { overflow-x: auto; }

/* ===== Flex Distribution Layout ===== */
.dist-layout {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
.dist-layout > div { flex: 1; min-width: 280px; }
.dist-scroll { max-height: 300px; overflow-y: auto; padding: 4px 0; }

/* ===== Quick Action List ===== */
.quick-action-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.btn-block { width: 100%; justify-content: center; }

/* ===== Tables ===== */
.table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

td {
  padding: 12px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

tr:hover td { background: var(--bg-hover); }
tr:last-child td { border-bottom: none; }

.table-empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-free { background: #374151; color: #9ca3af; }
.badge-pro { background: #1e3a5f; color: #60a5fa; }
.badge-premium { background: #4c1d95; color: #a78bfa; }
.badge-muted { background: #2a2d42; color: var(--text-muted); }
.badge-success { background: #14532d; color: #4ade80; }
.badge-danger { background: #7f1d1d; color: #fca5a5; }
.badge-warning { background: #78350f; color: #fbbf24; }
.badge-primary { background: #1e3a5f; color: #60a5fa; }
.badge-accent { background: #2e1065; color: #c084fc; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

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

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }

.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-outline:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 6px; }

/* ===== Inputs ===== */
input[type="text"], input[type="search"], input[type="number"],
input[type="date"], input[type="datetime-local"],
select, textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}

.search-input {
  width: 280px;
  padding-left: 12px;
}

/* ===== Forms ===== */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: 440px;
  max-width: 90vw;
}

.modal h3 {
  font-size: 16px;
  margin-bottom: 8px;
  color: var(--text-heading);
}

.modal p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  min-width: 280px;
  animation: slideIn 0.2s ease;
}

.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-error { border-left: 3px solid var(--danger); }

@keyframes slideIn {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== Charts ===== */
.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
  overflow-x: auto;
}

.chart-container h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 16px;
}

canvas {
  width: 100% !important;
  height: 200px !important;
}

/* ===== Detail Page ===== */
.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.detail-header h3 {
  font-size: 16px;
  color: var(--text-heading);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.detail-field label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.detail-field p {
  font-size: 14px;
  color: var(--text);
  margin-top: 2px;
}

/* ===== Promo Form ===== */
.promo-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.promo-card .promo-info h4 {
  font-size: 14px;
  color: var(--text-heading);
}

.promo-card .promo-info p {
  font-size: 13px;
  color: var(--text-muted);
}

/* ===== Tabs ===== */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ===== Utilities ===== */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-mono { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 13px; }
.mb-4 { margin-bottom: 4px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-0 { margin-top: 0; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.clickable { cursor: pointer; }
.clickable:hover { color: var(--accent); }
.link-accent { color: var(--accent); }
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 60px 0;
  color: var(--text-muted);
}

/* ===== Section Titles ===== */
.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-heading);
  margin: 24px 0 16px;
}

/* ===== Funnel Chart ===== */
.funnel-step {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.funnel-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--accent);
  border-radius: var(--radius);
  padding: 10px 16px;
  min-height: 40px;
  transition: width 0.3s ease;
}
.funnel-label {
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  white-space: nowrap;
}
.funnel-value {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}
.funnel-conversion {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ===== Card value variants ===== */
.card-value.danger { color: #ef4444; }

/* ===== Misc ===== */
.mt-24 { margin-top: 24px; }

/* ===== Sidebar Toggle (mobile) ===== */
.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius);
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: var(--bg-hover); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 15;
}

/* ===== Responsive: Tablet (≤ 1024px) ===== */
@media (max-width: 1024px) {
  .sidebar { width: 60px; }
  .sidebar-brand h1, .nav-link span, .sidebar-footer { display: none; }
  .nav-link { justify-content: center; padding: 12px; }
  .main { margin-left: 60px; }
  .content { padding: 20px; }
}

/* ===== Responsive: Small tablet / large phone (≤ 768px) ===== */
@media (max-width: 768px) {
  .sidebar-toggle { display: flex; }

  .sidebar {
    left: -240px;
    width: 240px;
    transition: left 0.2s ease;
    z-index: 20;
  }
  .sidebar.open { left: 0; }
  .sidebar.open ~ .sidebar-overlay { display: block; }

  /* Restore sidebar text when open */
  .sidebar.open .sidebar-brand h1,
  .sidebar.open .nav-link span,
  .sidebar.open .sidebar-footer { display: revert; }
  .sidebar.open .nav-link { justify-content: flex-start; padding: 10px 12px; }

  .main { margin-left: 0; }
  .content { padding: 16px; }

  .topbar { padding: 12px 16px; gap: 12px; }
  .topbar h2 { font-size: 16px; }
  .global-search-wrapper { flex: 1 1 auto; min-width: 0; }

  .card-grid { grid-template-columns: 1fr 1fr !important; }
  .detail-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }

  .flex-between { flex-wrap: wrap; }

  .table-wrapper { overflow-x: auto; }
  .table-wrapper th { white-space: nowrap; }
  .table-toolbar { flex-wrap: wrap; }
  .search-input { width: 100%; }
}

/* ===== Responsive: Phone (≤ 480px) ===== */
@media (max-width: 480px) {
  .content { padding: 12px; }
  .topbar { padding: 10px 12px; }

  .card-grid { grid-template-columns: 1fr !important; }
  .card-value { font-size: 22px; }
  .card { padding: 16px; }

  .global-search-wrapper { display: none; }
  .topbar-actions .badge { font-size: 10px; padding: 2px 6px; }

  .flex { flex-wrap: wrap; }
  .detail-header { flex-wrap: wrap; gap: 8px; }

  canvas { height: 160px !important; }

  .toast-container {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }
  .toast { min-width: auto; }

  .modal { width: calc(100vw - 32px); padding: 16px; }

  .promo-card { flex-direction: column; align-items: flex-start; gap: 12px; }

  .funnel-bar { padding: 8px 12px; }
  .funnel-label { font-size: 12px; }
}

/* ===== Notification Bell ===== */
.notification-bell { position: relative; background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 6px; border-radius: 6px; transition: color .15s; transform: translateY(2px); }
.notification-bell:hover { color: var(--text); background: var(--bg-hover); }
.notification-count { position: absolute; top: 0; right: -2px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 0 4px; line-height: 1; }

/* ===== Notification Feed Items ===== */
.notif-item { display: flex; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .15s; }
.notif-item:hover { background: var(--bg-hover); }
.notif-item.unread { background: rgba(99, 102, 241, 0.06); }
.notif-icon { flex-shrink: 0; width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.notif-icon.order { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.notif-icon.subscription { background: rgba(99, 102, 241, 0.15); color: var(--accent); }
.notif-icon.cancellation { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.notif-icon.contact { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.notif-icon.beta_signup { background: rgba(99, 102, 241, 0.15); color: var(--accent); }
.notif-icon.support_ticket { background: rgba(14, 165, 233, 0.15); color: #0ea5e9; }
.notif-content { flex: 1; min-width: 0; }
.notif-title { font-weight: 600; font-size: 13px; color: var(--text-heading); }
.notif-body { font-size: 12px; color: var(--text-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-time { font-size: 11px; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; align-self: center; }

/* ===== Blog CMS ===== */
.blog-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.blog-editor-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-heading);
}

.blog-editor-layout {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 16px;
  margin-bottom: 16px;
}

.blog-editor-pane {
  display: flex;
  flex-direction: column;
}

.blog-editor-tabs {
  display: none;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.blog-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.blog-tab:hover { color: var(--text); }
.blog-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.blog-textarea {
  width: 100%;
  min-height: 420px;
  resize: vertical;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.6;
  padding: 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.blog-textarea:focus { border-color: var(--accent); }

.blog-preview-pane {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  min-height: 420px;
  max-height: 600px;
  overflow-y: auto;
}

.blog-preview-content {
  color: var(--text);
  font-size: 14px;
  line-height: 1.7;
}

.blog-preview-content h1 { font-size: 24px; font-weight: 700; color: var(--text-heading); margin: 20px 0 12px; }
.blog-preview-content h2 { font-size: 20px; font-weight: 600; color: var(--text-heading); margin: 18px 0 10px; }
.blog-preview-content h3 { font-size: 16px; font-weight: 600; color: var(--text-heading); margin: 16px 0 8px; }
.blog-preview-content p { margin-bottom: 12px; }
.blog-preview-content ul, .blog-preview-content ol { margin: 0 0 12px 20px; }
.blog-preview-content li { margin-bottom: 4px; }
.blog-preview-content code {
  background: var(--bg-input);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 13px;
}
.blog-preview-content pre {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  overflow-x: auto;
  margin-bottom: 12px;
}
.blog-preview-content pre code { background: none; padding: 0; }
.blog-preview-content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 14px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.blog-preview-content a { color: var(--accent); text-decoration: underline; }
.blog-preview-content img { max-width: 100%; border-radius: var(--radius); }

.blog-meta-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.blog-meta-section summary {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.blog-meta-section summary:hover { color: var(--text); }

.blog-meta-section[open] summary {
  border-bottom: 1px solid var(--border);
}

.blog-meta-section .form-row,
.blog-meta-section .form-group {
  padding: 0 16px;
}

.blog-meta-section .form-row:first-of-type {
  padding-top: 12px;
}

.blog-meta-section .form-group:last-child {
  padding-bottom: 16px;
}

.char-count {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 6px;
}

.badge-stale {
  background: #7c2d12;
  color: #fb923c;
}

.blog-empty-state {
  text-align: center;
  padding: 60px 20px;
}

.blog-empty-state svg {
  margin-bottom: 16px;
  opacity: 0.4;
}

.blog-empty-state h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 8px;
}

.blog-empty-state p {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.blog-empty-state .btn { margin: 0 4px; }

/* Blog editor responsive: stack below 1024px */
@media (max-width: 1024px) {
  .blog-editor-layout { grid-template-columns: 1fr; }
  .blog-editor-tabs { display: flex; }
  .blog-preview-pane { display: none; }
  .blog-preview-pane.active { display: block; }
}

@media (max-width: 480px) {
  .blog-textarea { min-height: 300px; }
  .blog-preview-pane { min-height: 300px; padding: 14px; }
  .blog-editor-header { flex-direction: column; align-items: flex-start; }
}

/* ===== Intelligence Hub (Story 13.3) ===== */

.intelligence-freshness {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
}

.intelligence-freshness-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.intelligence-freshness-success {
  background: rgba(34, 197, 94, 0.1);
  color: var(--success);
}
.intelligence-freshness-success .intelligence-freshness-dot { background: var(--success); }

.intelligence-freshness-warning {
  background: rgba(251, 191, 36, 0.1);
  color: var(--warning);
}
.intelligence-freshness-warning .intelligence-freshness-dot { background: var(--warning); }

.intelligence-freshness-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}
.intelligence-freshness-danger .intelligence-freshness-dot { background: var(--danger); }

.intelligence-freshness-muted {
  background: rgba(156, 163, 175, 0.1);
  color: var(--text-muted);
}
.intelligence-freshness-muted .intelligence-freshness-dot { background: var(--text-muted); }

.intelligence-nav-badge {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
}

.intelligence-brief {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 16px;
}

.intelligence-confidence {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.intelligence-confidence-high { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.intelligence-confidence-medium { background: rgba(96, 165, 250, 0.15); color: #60a5fa; }
.intelligence-confidence-low { background: rgba(251, 191, 36, 0.15); color: var(--warning); }
.intelligence-confidence-failed { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

.intelligence-unverified {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.9em;
  opacity: 0.7;
  cursor: help;
}

.intelligence-funnel {
  margin-top: 16px;
}

.intelligence-funnel-stage {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
  min-width: 0;
  overflow: hidden;
}

.intelligence-missed {
  background: rgba(96, 165, 250, 0.1);
  border: 1px solid rgba(96, 165, 250, 0.3);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: #60a5fa;
}

.intelligence-raw {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-family: 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  margin: 0;
}
