*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
.targets-layout { display: flex; gap: 0; align-items: flex-start; }
.policy-body ul, .policy-body ol { padding-left: 24px; margin: 8px 0; }
.policy-body li { margin: 4px 0; }
.policy-editor ul, .policy-editor ol { padding-left: 24px; margin: 8px 0; }
.policy-editor li { margin: 4px 0; }
@keyframes navDropIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
select {
  appearance: none;
  background-color: var(--bg-card);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' fill='none' stroke='%23888' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding: 8px 30px 8px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  line-height: 1.4;
}
select:focus { outline: none; border-color: var(--accent); }
select:hover { border-color: var(--text-muted); }
select option { background: var(--bg-card); color: var(--text-primary); }

.info-tip:hover > .info-tip-box { display: block !important; }
.info-tip:hover { color: var(--text-secondary) !important; border-color: var(--text-faint) !important; }

.recharts-wrapper, .recharts-wrapper *, .recharts-surface { outline: none !important; }

/* Visible text selection on dark backgrounds */
::selection { background: #3b82f6; color: #ffffff; }
::-moz-selection { background: #3b82f6; color: #ffffff; }
input::selection, textarea::selection { background: #3b82f6; color: #ffffff; }
input::-moz-selection, textarea::-moz-selection { background: #3b82f6; color: #ffffff; }

/* System page sidebar - desktop defaults */
.targets-sidebar {
  width: 180px;
  flex-shrink: 0;
  position: sticky;
  top: 68px;
}
.targets-sidebar-inner {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.targets-sidebar-btn {
  width: 100%;
}

:root {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;

  /* ═══ Design Tokens (Blue Dark - Default) ═══ */
  color-scheme: dark;
  --bg-canvas: #060d1a;
  --bg-canvas-gradient:
    radial-gradient(ellipse at 20% 0%, rgba(15, 40, 71, 0.4) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(10, 22, 40, 0.3) 0%, transparent 50%),
    repeating-linear-gradient(0deg, transparent, transparent 60px, rgba(30, 58, 95, 0.03) 60px, rgba(30, 58, 95, 0.03) 61px),
    repeating-linear-gradient(90deg, transparent, transparent 60px, rgba(30, 58, 95, 0.03) 60px, rgba(30, 58, 95, 0.03) 61px),
    linear-gradient(160deg, #0b1a30 0%, #070e1a 40%, #040810 100%);
  --bg-card: #0a1220;
  --bg-card-alt: #0e1628;
  --bg-card-hover: #0f172a;
  --bg-input: #070f1c;
  --bg-sidebar: #0a1120;
  --bg-sidebar-hover: #0f172a;
  --bg-topbar: #0a1120;
  --bg-modal: rgba(0,0,0,0.7);

  /* Sidebar text -- stays readable on dark sidebar in both modes */
  --sidebar-text: #94a3b8;
  --sidebar-text-hover: #e2e8f0;
  --sidebar-text-active: #f1f5f9;
  --sidebar-text-faint: #475569;
  --sidebar-border: #1a2a3f;

  --border: #1a2a3f;
  --border-subtle: #0f1a2e;
  --border-active: rgba(56,189,248,0.2);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-dim: #64748b;
  --text-faint: #475569;
  --text-ghost: #334155;
  --text-on-card: #f1f5f9;

  --brand: #1e3a5f;
  --brand-dark: #0f1d32;
  --accent: #8b5cf6;
  --accent-soft: #1e1040;
  --accent-lime: #8b5cf6;

  --positive: #22c55e;
  --positive-bg: #052e16;
  --negative: #ef4444;
  --negative-bg: #2d0707;
  --warning: #f59e0b;
  --warning-bg: #2d1b00;
  --info: #8b5cf6;

  --shadow-card: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-card-hover: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-dropdown: 0 8px 24px rgba(0,0,0,0.5);

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 12px;
  --radius-full: 9999px;
}

/* ═══ Light Mode ═══ */
:root.light {
  color-scheme: light;
  --bg-canvas: #f0f2f5;
  --bg-canvas-gradient: linear-gradient(160deg, #f0f2f5 0%, #e8ecf1 100%);
  --bg-card: #ffffff;
  --bg-card-alt: #f8f9fb;
  --bg-card-hover: #f0f4f8;
  --bg-input: #ffffff;
  --bg-sidebar: #0a1120;
  --bg-sidebar-hover: #0f172a;
  --bg-topbar: #ffffff;
  --bg-modal: rgba(0,0,0,0.4);

  /* Sidebar text -- stays dark-theme readable even in light mode */
  --sidebar-text: #94a3b8;
  --sidebar-text-hover: #e2e8f0;
  --sidebar-text-active: #f1f5f9;
  --sidebar-text-faint: #475569;
  --sidebar-border: #1a2a3f;

  --border: #d1d9e6;
  --border-subtle: #e2e8f0;
  --border-active: rgba(37,99,235,0.3);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-dim: #94a3b8;
  --text-faint: #94a3b8;
  --text-ghost: #cbd5e1;
  --text-on-card: #0f172a;

  --brand: #1e40af;
  --brand-dark: #1e3a8a;
  --accent: #7c3aed;
  --accent-soft: #dbeafe;
  --accent-lime: #8b5cf6;

  --positive: #22c55e;
  --positive-bg: #dcfce7;
  --negative: #ef4444;
  --negative-bg: #fee2e2;
  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --info: #2563eb;

  --shadow-card: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-card-hover: 0 4px 12px rgba(0,0,0,0.10), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-dropdown: 0 8px 24px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
}

body {
  background: var(--bg-canvas-gradient, var(--bg-canvas));
  background-attachment: fixed;
  color: var(--text-primary);
  transition: background 200ms ease, color 200ms ease;
  min-height: 100vh;
  overflow-x: hidden;
  width: 100%;
}

#root {
  min-height: 100vh;
  overflow-x: hidden;
  width: 100%;
}

button { cursor: pointer; border: none; background: none; font-family: inherit; font-size: inherit; color: inherit; }
input { font-family: inherit; font-size: inherit; }
input[type="checkbox"], input[type="radio"] { cursor: pointer; }
a { cursor: pointer; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

.nav-hamburger { display: none !important; }

/* Sidebar nav layout: desktop shows the sidebar, mobile shows the drawer bar. */
.sidebar-desktop { display: flex; }
.mobile-nav-bar { display: none !important; }
@media (max-width: 768px) {
  .sidebar-desktop { display: none !important; }
  .mobile-nav-bar { display: flex !important; }
}

/* Heatmap fade in */
.heatmap-panel { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Heatmap border flash on new transaction — 5 pulses in 1.5s */
@keyframes borderFlash {
  0% { stroke-opacity: 0; }
  10% { stroke-opacity: 1; }
  20% { stroke-opacity: 0.1; }
  30% { stroke-opacity: 1; }
  40% { stroke-opacity: 0.1; }
  50% { stroke-opacity: 1; }
  60% { stroke-opacity: 0.1; }
  70% { stroke-opacity: 1; }
  80% { stroke-opacity: 0.1; }
  90% { stroke-opacity: 0.8; }
  100% { stroke-opacity: 0; }
}

/* ══════════════════════════════════════════════════════════════════════════
   TABLET (≤1200px)
   ══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1200px) {
  main { padding: 20px 16px 40px !important; }
  .dash-layout { flex-direction: column-reverse !important; }
  .dash-sidebar { width: 100% !important; position: static !important; max-height: none !important; }
}

/* ══════════════════════════════════════════════════════════════════════════
   PHONE (≤768px)
   ══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* ── Nav ── */
  .nav-hamburger { display: flex !important; }
  .nav-desktop { display: none !important; }
  .nav-hide-mobile { display: none !important; }
  .main-nav { padding: 0 12px !important; height: 48px !important; }

  /* ── Main ── */
  main {
    padding: 12px 10px 32px !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
  }

  /* ── Live page: KPI header stacks on mobile ── */
  .live-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
  }
  .live-header-stats {
    width: 100% !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .live-header-stats::-webkit-scrollbar { display: none; }
  .live-header-stats > div {
    flex-shrink: 0;
  }
  .live-header-stats > div > span:first-child {
    font-size: 15px !important;
  }

  /* ── Heatmap ── */
  .heatmap-panel {
    max-width: 100% !important;
    overflow: visible !important;
  }
  .heatmap-panel .recharts-responsive-container {
    min-width: 0 !important;
  }

  /* ── Live page: filter sidebar + heatmap stack vertically ── */
  .live-chart-row {
    flex-direction: column !important;
    gap: 10px !important;
  }
  .filter-sidebar {
    flex-direction: row !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 10px 12px !important;
    width: 100% !important;
    max-width: 100% !important;
    position: static !important;
    align-self: auto !important;
    box-sizing: border-box !important;
  }
  .filter-sidebar::-webkit-scrollbar { display: none; }
  .filter-sidebar > div {
    flex-direction: row !important;
    gap: 4px !important;
    flex-wrap: nowrap !important;
  }
  .filter-sidebar + div {
    width: 100% !important;
  }

  /* ── Charts on mobile ── */
  .heatmap-panel {
    max-width: 100% !important;
    overflow: visible !important;
    flex: none !important;
  }
  .live-chart-row > div:last-child {
    width: 100% !important;
    flex: none !important;
    display: block !important;
  }

  /* ── Account page header ── */
  .acct-header h1 { font-size: 17px !important; }

  /* ── Account page: show mobile dropdown, hide desktop sidebar ── */
  .acct-mobile-tabs { display: block !important; }
  .acct-sidebar-desktop { display: none !important; }
  .acct-layout { gap: 0 !important; }

  /* ── Account content area ── */
  .acct-layout > div:last-child {
    width: 100% !important;
    min-width: 0 !important;
  }

  /* ── Targets/System page sidebar ── */
  .targets-layout { flex-direction: column !important; }
  .targets-sidebar {
    width: 100% !important;
    flex-shrink: 1 !important;
    position: static !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .targets-sidebar::-webkit-scrollbar { display: none; }
  .targets-sidebar-inner {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 3px !important;
    width: max-content !important;
    min-width: 100% !important;
  }
  .targets-sidebar-btn {
    width: auto !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    border-left: none !important;
    border-bottom: none !important;
    padding: 8px 12px !important;
    font-size: 11px !important;
  }
  /* System page content area - prevent overflow on mobile */
  .targets-layout > div:last-child {
    width: 100% !important;
    min-width: 0 !important;
    overflow-x: auto !important;
  }
  .targets-layout table {
    font-size: 11px !important;
  }
  .targets-layout table th,
  .targets-layout table td {
    padding: 6px 8px !important;
  }
  .targets-layout input[type="number"] {
    width: 65px !important;
  }

  /* ── Accounts page ── */
  .accounts-header {
    flex-direction: column !important;
    align-items: flex-start !important;
  }
  .accounts-header-stats {
    width: 100% !important;
  }
  .accounts-header-stats > div {
    flex: 1;
    min-width: 0;
  }
  .accounts-mobile-filters {
    display: block !important;
  }
  .accounts-mobile-filters div::-webkit-scrollbar { display: none; }
  .accounts-layout {
    flex-direction: column !important;
    gap: 10px !important;
  }
  .accounts-sidebar {
    display: none !important;
  }

  /* ── TopHeader: hidden on mobile (MobileNav handles chrome) ── */
  .top-header { display: none !important; }

  /* ── Home page ── */
  .home-quicklinks { grid-template-columns: repeat(2, 1fr) !important; gap: 8px !important; }
  .home-stats { grid-template-columns: repeat(2, 1fr) !important; }
  .home-grid { grid-template-columns: 1fr !important; }
  .home-rps { grid-template-columns: repeat(3, 1fr) !important; }
  .home-rps-charts { grid-template-columns: 1fr !important; }

  /* ── HomeExecutive ── */
  .home-exec-canvas { margin: 0 !important; padding: 12px 4px !important; }
  .home-exec-hero  { grid-template-columns: 1fr !important; gap: 10px !important; }
  .home-exec-kpis  { grid-template-columns: repeat(3, 1fr) !important; gap: 8px !important; }
  .home-exec-rps   { grid-template-columns: repeat(3, 1fr) !important; gap: 8px !important; }
  .home-exec-2col  { grid-template-columns: 1fr !important; gap: 16px !important; }

  /* ── Chat Manager stats on mobile ── */
  .chat-mgr-stats {
    gap: 8px !important;
  }
  .chat-mgr-stats > div:nth-child(3) {
    display: none !important;
  }

  /* ── Swap Analysis detail sidebar ── */
  div[style*="width: '420px'"] {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* ── All inline grids: collapse ── */
  div[style*="grid-template-columns: repeat(4"] { grid-template-columns: 1fr 1fr !important; }
  div[style*="grid-template-columns: repeat(3"] { grid-template-columns: 1fr 1fr !important; }
  div[style*="grid-template-columns: repeat(5"] { grid-template-columns: 1fr 1fr !important; }
  div[style*="grid-template-columns: repeat(6"] { grid-template-columns: repeat(3, 1fr) !important; }
  div[style*="grid-template-columns: repeat(12"] { grid-template-columns: repeat(6, 1fr) !important; }

  /* ── AI Creators: hub diagram ── */
  .ai-hub-main-row { flex-wrap: wrap !important; gap: 10px !important; }
  .ai-hub-main-row > div { flex-basis: calc(50% - 5px) !important; flex-grow: 1 !important; }
  .ai-hub-conn { display: none !important; }
  .ai-hub-denied-row { display: none !important; }
  .ai-hub-topbar { flex-direction: column !important; align-items: flex-start !important; gap: 10px !important; }
  .ai-pipeline-sets-grid { grid-template-columns: 1fr !important; }
  .ai-grid-3col { grid-template-columns: 1fr 1fr !important; }
  .ai-grid-4col { grid-template-columns: 1fr 1fr !important; }
  .ai-upload-types { grid-template-columns: 1fr 1fr !important; }
  /* Content modal: stack image + info pane vertically */
  .ai-modal-2col { flex-direction: column !important; }
  .ai-modal-info-pane { width: 100% !important; border-left: none !important; border-top: 1px solid var(--border) !important; max-height: 55vh !important; }

  /* ── Charts ── */
  .recharts-responsive-container { min-width: 0 !important; }

  /* ── Typography ── */
  h1 { font-size: 18px !important; }
  h2 { font-size: 16px !important; }

  /* ── Reports page ── */
  .report-charts-grid { grid-template-columns: 1fr !important; }
  .report-table-desktop { display: none !important; }
  .report-cards-mobile { display: flex !important; }
  .report-scores > div { padding: 12px 16px !important; }
  .report-scores > div > div:first-child { font-size: 28px !important; }
  .report-header-badges { display: none !important; }

  /* ── All popups: bottom sheet on mobile ── */
  .mobile-bottom-sheet {
    align-items: flex-end !important;
    justify-content: center !important;
    padding: 0 !important;
  }
  .mobile-bottom-sheet-content {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 85vh !important;
    border-radius: 16px 16px 0 0 !important;
    border-bottom: none !important;
    animation: slideUp 0.2s ease-out;
  }

  @keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  /* ── Mobile popup (dashboard account) ── */
  .dash-mobile-popup > div {
    animation: slideUp 0.2s ease-out;
  }
}

/* ══════════════════════════════════════════════════════════════════════════
   SMALL PHONE (≤480px)
   ══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  main { padding: 10px 8px 28px !important; }

  .home-quicklinks { grid-template-columns: 1fr !important; }
  .home-stats { grid-template-columns: 1fr !important; }
  .home-rps { grid-template-columns: repeat(2, 1fr) !important; }
}

/* ══════════════════════════════════════════════════════════════════════════
   VERY SMALL (≤380px)
   ══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 380px) {
  :root { font-size: 13px; }
  .main-nav { height: 44px !important; }
}

/* ── Mobile table scroll wrapper ─────────────────────────────────────────── */
/* Wrap any overflow table in <div className="table-scroll"> */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; }
.table-scroll table { min-width: 480px; }

/* ── Global mobile polish ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Tooltips/popovers: never wider than screen */
  [class*="tooltip"], [class*="popover"] { max-width: calc(100vw - 20px) !important; }

  /* Cards with inline padding: reduce on phone */
  .card-padded { padding: 12px !important; }

  /* Modal backdrops: full-bleed padding so content reaches edge-to-edge */
  [class*="modal-backdrop"], [class*="ai-modal-backdrop"] { padding: 8px !important; }

  /* Button rows: allow wrapping so buttons don't clip off-screen */
  .btn-row { flex-wrap: wrap !important; gap: 8px !important; }

  /* Header right side: shrink gaps on small screens */
  header > div:last-child { gap: 8px !important; }

  /* Stat boxes with minWidth: let them shrink */
  [class*="stat-box"] { min-width: 0 !important; }
}

/* TipTap rich text editor */
.ProseMirror {
  outline: none;
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.6;
}
.ProseMirror p { margin: 0 0 0.4em 0; }
.ProseMirror p:last-child { margin-bottom: 0; }
.ProseMirror ul, .ProseMirror ol { padding-left: 1.4em; margin: 0.2em 0; }
.ProseMirror li { margin: 2px 0; }
.ProseMirror strong { color: var(--text-primary); }
.ProseMirror h1 { font-size: 18px; font-weight: 800; color: var(--text-primary); margin: 0.6em 0 0.3em; }
.ProseMirror h2 { font-size: 15px; font-weight: 700; color: var(--text-primary); margin: 0.5em 0 0.25em; }
.ProseMirror blockquote { border-left: 3px solid #8b5cf640; padding: 4px 12px; color: var(--text-secondary); margin: 0.4em 0; background: var(--bg-card-hover); border-radius: 0 4px 4px 0; }
.ProseMirror code { background: var(--bg-card-hover); color: var(--accent); border-radius: 3px; padding: 1px 5px; font-size: 12px; font-family: monospace; }
.ProseMirror pre { background: var(--bg-card-hover); border: 1px solid var(--border); border-radius: 6px; padding: 10px 14px; margin: 0.4em 0; overflow-x: auto; white-space: pre; }
.ProseMirror pre code { background: none; padding: 0; color: var(--accent); font-size: 12px; font-family: monospace; white-space: pre; }
.ProseMirror a { color: var(--accent); text-decoration: underline; cursor: pointer; }
.ProseMirror table { border-collapse: collapse; width: 100%; margin: 0.5em 0; }
.ProseMirror th, .ProseMirror td { border: 1px solid var(--border); padding: 5px 10px; font-size: 12px; vertical-align: top; line-height: 1.5; }
.ProseMirror th { background: var(--bg-card-alt); color: var(--text-secondary); font-weight: 700; text-align: left; }
.ProseMirror td { background: var(--bg-card); color: var(--text-secondary); }
.ProseMirror .selectedCell { background: #8b5cf610 !important; outline: 2px solid #8b5cf640; }
.ProseMirror img { max-width: 100%; border-radius: 4px; margin: 4px 0; }
.tiptap-eom .ProseMirror { outline: none; }
.tiptap-eom .ProseMirror p.is-editor-empty:first-child::before { content: attr(data-placeholder); color: var(--text-ghost); pointer-events: none; float: left; height: 0; }

/* Rich text display (read-only rendered HTML) */
.rich-text-display p { margin: 0 0 0.4em 0; }
.rich-text-display p:last-child { margin-bottom: 0; }
.rich-text-display ul, .rich-text-display ol { padding-left: 1.4em; margin: 0.2em 0; }
.rich-text-display li { margin: 2px 0; }
.rich-text-display strong { color: var(--text-primary); }
.rich-text-display h1 { font-size: 18px; font-weight: 800; color: var(--text-primary); margin: 0.6em 0 0.3em; }
.rich-text-display h2 { font-size: 15px; font-weight: 700; color: var(--text-primary); margin: 0.5em 0 0.25em; }
.rich-text-display blockquote { border-left: 3px solid #8b5cf640; padding: 4px 12px; color: var(--text-secondary); margin: 0.4em 0; background: var(--bg-card-hover); border-radius: 0 4px 4px 0; }
.rich-text-display table { border-collapse: collapse; width: 100%; margin: 0.5em 0; }
.rich-text-display th, .rich-text-display td { border: 1px solid var(--border); padding: 5px 10px; font-size: 12px; vertical-align: top; line-height: 1.5; }
.rich-text-display th { background: var(--bg-card-alt); color: var(--text-secondary); font-weight: 700; text-align: left; }
.rich-text-display td { background: var(--bg-card); color: var(--text-secondary); }
.rich-text-display code { background: var(--bg-card-hover); color: var(--accent); border-radius: 3px; padding: 1px 5px; font-size: 12px; font-family: monospace; }
.rich-text-display pre { background: var(--bg-card-hover); border: 1px solid var(--border); border-radius: 6px; padding: 10px 14px; margin: 0.4em 0; overflow-x: auto; white-space: pre; }
.rich-text-display pre code { background: none; padding: 0; color: var(--accent); font-size: 12px; font-family: monospace; white-space: pre; }
.rich-text-display a { color: var(--accent); text-decoration: underline; }

/* Playbook content (imported from BookStack HTML) */
.playbook-content { color: var(--text-secondary) !important; }
.playbook-content * { color: inherit !important; background-color: transparent !important; }

/* Typography */
.playbook-content h1, .playbook-content h2, .playbook-content h3, .playbook-content h4 { color: var(--text-primary) !important; margin: 20px 0 8px; font-weight: 800; }
.playbook-content h1 { font-size: 20px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.playbook-content h2 { font-size: 17px; }
.playbook-content h3 { font-size: 15px; }
.playbook-content h4 { font-size: 13px; color: var(--text-secondary) !important; }
.playbook-content p { margin: 6px 0; line-height: 1.7; }
.playbook-content strong, .playbook-content b { color: var(--text-primary) !important; font-weight: 700; }

/* Lists */
.playbook-content ul, .playbook-content ol { padding-left: 22px; margin: 8px 0; }
.playbook-content li { margin: 4px 0; line-height: 1.6; }
.playbook-content li::marker { color: var(--text-faint); }

/* Links */
.playbook-content a { color: var(--accent) !important; text-decoration: none; }
.playbook-content a:hover { text-decoration: underline; }

/* Tables */
.playbook-content table { width: 100%; border-collapse: collapse; margin: 14px 0; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.playbook-content th, .playbook-content td { padding: 10px 14px; border: 1px solid var(--border); font-size: 12px; text-align: left; line-height: 1.5; }
.playbook-content th { background: var(--bg-card-hover) !important; color: var(--text-secondary) !important; font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.3px; }
.playbook-content td { color: var(--text-secondary) !important; }
.playbook-content tr:nth-child(even) td { background: var(--bg-input) !important; }
.playbook-content tr:hover td { background: var(--bg-card-hover) !important; }

/* Images - proper sizing, not squished */
.playbook-content img { max-width: 100%; height: auto !important; border-radius: 8px; margin: 10px 0; display: block; }
.playbook-content img[src*="slack-edge.com"], .playbook-content img[src*="emoji.slack"] { display: inline; height: 20px !important; width: 20px !important; border-radius: 0; margin: 0 2px; vertical-align: middle; }

/* Blocks */
.playbook-content blockquote { border-left: 3px solid #8b5cf630; padding: 8px 14px; color: var(--text-secondary) !important; margin: 10px 0; background: var(--bg-input) !important; border-radius: 0 6px 6px 0; }
.playbook-content pre, .playbook-content code { background: var(--bg-input) !important; color: var(--text-secondary) !important; border-radius: 4px; padding: 2px 6px; font-size: 12px; }
.playbook-content pre { padding: 12px; margin: 10px 0; overflow-x: auto; }
.playbook-content hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* Slack emoji spans */
.playbook-content .c-emoji img { display: inline !important; height: 20px !important; width: 20px !important; margin: 0 2px; vertical-align: middle; border-radius: 0; }

/* Override any BookStack inline styles */
.playbook-content span[style], .playbook-content div[style], .playbook-content p[style] { color: inherit !important; background: transparent !important; }
.playbook-content font { color: inherit !important; }

/* Alert items (converted from ALL CAPS) */
.playbook-content .pb-alert-item { background: #f59e0b08; border: 1px solid #f59e0b25; border-radius: 6px; padding: 8px 12px; margin: 6px 0; list-style: none; color: #f59e0b !important; font-weight: 700; font-size: 12px; letter-spacing: 0.3px; }
.playbook-content .pb-highlight { color: #f59e0b !important; font-weight: 800; letter-spacing: 0.2px; }
.playbook-content .pb-alert { background: #ef444408; border: 1px solid #ef444420; border-radius: 6px; padding: 10px 14px; margin: 8px 0; color: #ef4444 !important; font-weight: 700; font-size: 12px; }

/* ── Sidebar item (nav row) ──────────────────────────────────────────────── */
.sidebar-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin: 1px 0;
  border-radius: 7px;
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--sidebar-text);
  background: transparent;
  border-left: 3px solid transparent;
  transition: background 120ms ease, color 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}
.sidebar-item.collapsed {
  padding: 9px 0;
  justify-content: center;
}
.sidebar-item-icon {
  position: relative;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 120ms ease;
}
.sidebar-item:hover {
  background: var(--bg-sidebar-hover);
  color: var(--sidebar-text-hover);
  box-shadow: inset 2px 0 0 var(--accent-lime);
}
.sidebar-item:hover .sidebar-item-icon {
  transform: translateX(2px);
}
.sidebar-item.active {
  color: var(--sidebar-text-active);
  background: linear-gradient(90deg, #1e293b, #0f172a);
  border-left: 3px solid var(--accent-lime);
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.25), inset 0 0 0 1px rgba(30, 64, 175, 0.25);
  font-weight: 600;
}
.sidebar-item.active.collapsed {
  border-left: 3px solid transparent;
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.25), inset 0 0 0 1px rgba(30, 64, 175, 0.25);
}
.sidebar-item.active.collapsed .sidebar-item-icon::before {
  content: '';
  position: absolute;
  top: -3px;
  left: -3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-lime);
  box-shadow: 0 0 6px var(--accent-lime);
}

.sidebar-item.ancestor {
  color: var(--sidebar-text-muted, #8a9a8e);
  border-left: 3px solid rgba(163, 196, 176, 0.4);
  background: rgba(255,255,255,0.03);
  font-weight: 500;
}

/* Top bar responsive rules */
@media (max-width: 768px) {
  .topbar-search-pill { width: 36px !important; padding: 7px 0 !important; justify-content: center !important; }
  .topbar-search-pill-label { display: none !important; }
  .topbar-search-pill-kbd { display: none !important; }
}
@media (max-width: 640px) {
  .topbar-breadcrumb { display: none !important; }
}

/* Announcements blog layout: stack sidebar above grid on narrow viewports. */
@media (max-width: 860px) {
  .ann-layout { flex-direction: column !important; }
  .ann-sidebar { width: 100% !important; position: static !important; }
}

/* ── AI Creator pages: mobile responsive ──────────────────────────────────── */
@media (max-width: 768px) {
  /* Modal backdrop: less padding so content has room */
  .ai-modal-backdrop { padding: 8px !important; }

  /* Two-column modals (item detail, set item): stack vertically */
  .ai-modal-2col { flex-direction: column !important; max-height: 95vh !important; overflow-y: auto !important; }
  .ai-modal-info-pane { width: 100% !important; border-left: none !important; border-top: 1px solid var(--border) !important; max-height: none !important; }

  /* Hide prev/next arrow buttons outside modals — use swipe or keyboard */
  .ai-modal-arrow { display: none !important; }

  /* Hub pipeline: wrap cards, hide animated connectors */
  .ai-hub-main-row { flex-wrap: wrap !important; gap: 10px !important; }
  .ai-hub-main-row > * { flex: 1 1 140px !important; min-width: 0 !important; }
  .ai-hub-conn { display: none !important; }
  .ai-hub-denied-row { display: none !important; }

  /* Distribution view: stack columns vertically */
  .ai-dist-layout { flex-direction: column !important; }
  .ai-dist-left { flex: 1 1 100% !important; }
  .ai-dist-right { flex: 1 1 100% !important; }

  /* Grids: collapse to 2 columns */
  .ai-grid-3col { grid-template-columns: repeat(2, 1fr) !important; }
  .ai-grid-4col { grid-template-columns: repeat(2, 1fr) !important; }
  .ai-upload-types { grid-template-columns: repeat(2, 1fr) !important; }
  .ai-content-grid { grid-template-columns: repeat(2, 1fr) !important; }

  /* Page padding reduction */
  .ai-detail-list { padding: 14px 12px !important; }

  /* Status header: wrap tabs below icon+title on mobile */
  .ai-content-header { flex-wrap: wrap !important; }
  .ai-content-tabs { margin-left: 0 !important; width: 100% !important; flex-wrap: wrap !important; }

  /* Gallery (pending/ready/denied etc): stack sidebar above content */
  .ai-gallery-layout { flex-direction: column !important; }
  /* Sidebar becomes a horizontal scrollable chip strip */
  .ai-gallery-sidebar {
    width: 100% !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    gap: 6px !important;
    padding-bottom: 6px !important;
    scrollbar-width: none !important;
    align-items: flex-start !important;
  }
  .ai-gallery-sidebar::-webkit-scrollbar { display: none; }
  /* Hide section labels; make filter button groups horizontal rows */
  .ai-filter-label { display: none !important; }
  .ai-filter-btns { flex-direction: row !important; flex-wrap: nowrap !important; gap: 4px !important; }
  .ai-filter-btns button { white-space: nowrap !important; padding: 5px 10px !important; font-size: 11px !important; }

  /* Creator grid on listing page */
  .ai-creators-grid { grid-template-columns: repeat(2, 1fr) !important; }

  /* Pending review: request button + stat pills stack */
  .ai-hub-topbar { flex-wrap: wrap !important; gap: 8px !important; }
}
