@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Tajawal:wght@400;500;700;800&display=swap');

/* ════════════════════════════════════════
   CSS VARIABLES — DARK MODE (default)
════════════════════════════════════════ */
:root {
  --teal:        #1064A0;
  --green:       #8AF6A0;
  --bg:          #0A0F1A;
  --bg-2:        #0D1520;
  --bg-3:        #111827;
  --bg-4:        #1a2234;
  --bg-card:     rgba(255,255,255,0.04);
  --border:      rgba(255,255,255,0.08);
  --border-teal: rgba(16,100,160,0.25);
  --text-1:      #ffffff;
  --text-2:      rgba(255,255,255,0.75);
  --text-3:      rgba(255,255,255,0.5);
  --text-4:      rgba(255,255,255,0.3);
  --grad:        linear-gradient(90deg,#1064A0,#8AF6A0);
  --grad-diag:   linear-gradient(135deg,#1064A0,#8AF6A0);
  --error:       #E25A5A;
  --warning:     #F0A84C;
  --success:     #8AF6A0;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
  --radius:      10px;
  --radius-lg:   16px;
  --font:        'Inter', sans-serif;
  --font-ar:     'Tajawal', sans-serif;
  --sidebar-w:   240px;
}

/* ── LIGHT MODE ── */
[data-theme="light"] {
  --bg:          #f4f6fb;
  --bg-2:        #ffffff;
  --bg-3:        #ffffff;
  --bg-4:        #f0f2f8;
  --bg-card:     rgba(0,0,0,0.03);
  --border:      rgba(0,0,0,0.09);
  --border-teal: rgba(16,100,160,0.3);
  --text-1:      #0d1117;
  --text-2:      rgba(13,17,23,0.75);
  --text-3:      rgba(13,17,23,0.5);
  --text-4:      rgba(13,17,23,0.3);
  --shadow:      0 4px 24px rgba(0,0,0,0.08);
}

/* ── ARABIC / RTL ── */
[dir="rtl"] {
  font-family: var(--font-ar), sans-serif;
}
[dir="rtl"] .sidebar { border-right: none; border-left: 1px solid var(--border); }
[dir="rtl"] .main-content { }
[dir="rtl"] .nav-brand { flex-direction: row-reverse; }

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

html { font-size: 15px; }

body {
  background: var(--bg);
  color: var(--text-1);
  font-family: var(--font);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background .25s, color .25s;
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 2px; }

.grad-text {
  background: var(--grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ════════════════════════════════════════
   LAYOUT
════════════════════════════════════════ */
#app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: 54px 1fr;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ════════════════════════════════════════
   TOP NAV
════════════════════════════════════════ */
.app-header {
  grid-column: 1 / -1;
  grid-row: 1;
  height: 54px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  display: flex; align-items: center; gap: 9px;
  text-decoration: none; flex-shrink: 0;
}
.header-logo {
  width: 32px; height: 32px;
  background: var(--grad-diag);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}
.header-name { font-size: 15px; font-weight: 800; color: var(--text-1); letter-spacing: -.4px; }
.header-sub  { font-size: 9px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: var(--teal); }

.header-spacer { flex: 1; }

.header-controls {
  display: flex; align-items: center; gap: 6px;
}

/* Toggle buttons */
.ctrl-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-2);
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
  white-space: nowrap;
}
.ctrl-btn:hover { border-color: var(--teal); color: var(--teal); }
.ctrl-btn.active { background: rgba(16,100,160,0.1); border-color: var(--teal); color: var(--teal); }

.user-chip {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 11px;
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px; color: var(--text-2);
}
.user-avatar {
  width: 22px; height: 22px;
  background: var(--grad-diag);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; color: #0A0F1A;
}

.btn-logout {
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-3);
  font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: all .15s;
}
.btn-logout:hover { border-color: var(--error); color: var(--error); }

/* ════════════════════════════════════════
   SIDEBAR
════════════════════════════════════════ */
.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow-y: auto;
  grid-column: 1;
  grid-row: 2;
  transition: background .25s;
}

.sidebar-section {
  padding: 16px 12px 4px;
  font-size: 10px; font-weight: 700;
  letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--text-4);
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  border-radius: var(--radius);
  margin: 1px 8px;
  cursor: pointer;
  text-decoration: none;
  color: var(--text-2);
  font-size: 13px; font-weight: 500;
  transition: all .15s;
  position: relative;
}
.nav-item:hover { background: var(--bg-card); color: var(--text-1); }
.nav-item.active { background: rgba(16,100,160,0.1); color: var(--teal); }
.nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 3px; border-radius: 2px;
  background: var(--grad);
}
[dir="rtl"] .nav-item.active::before { left: auto; right: 0; }

.nav-icon { font-size: 16px; flex-shrink: 0; width: 20px; text-align: center; }
.nav-label { flex: 1; }
.nav-badge {
  font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 10px;
  background: rgba(16,100,160,0.15);
  color: var(--teal);
}
.nav-badge.locked {
  background: rgba(255,255,255,0.06);
  color: var(--text-4);
}
.nav-check {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--grad-diag);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; color: #0A0F1A; font-weight: 900;
}

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

/* ════════════════════════════════════════
   MAIN CONTENT
════════════════════════════════════════ */
.main-content {
  grid-column: 2;
  grid-row: 2;
  overflow-y: auto;
  padding: 32px 36px;
  background: var(--bg);
  transition: background .25s;
}

/* ════════════════════════════════════════
   JIT MASTERCLASS MODAL
════════════════════════════════════════ */
.jit-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.jit-overlay.open { opacity: 1; pointer-events: all; }

.jit-modal {
  background: var(--bg-3);
  border: 1px solid var(--border-teal);
  border-radius: 20px;
  max-width: 560px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  position: relative;
  transform: translateY(20px) scale(.97);
  transition: transform .25s cubic-bezier(.34,1.56,.64,1);
}
.jit-overlay.open .jit-modal { transform: translateY(0) scale(1); }

.jit-top-bar {
  height: 4px;
  background: var(--grad);
  border-radius: 20px 20px 0 0;
}

.jit-body { padding: 36px; }

.jit-tag {
  font-size: 10px; font-weight: 700;
  letter-spacing: 2px; text-transform: uppercase;
  color: var(--teal); margin-bottom: 10px;
}
.jit-title { font-size: 24px; font-weight: 800; color: var(--text-1); margin-bottom: 8px; line-height: 1.25; }
.jit-sub   { font-size: 14px; color: var(--text-3); margin-bottom: 24px; line-height: 1.65; }

.jit-lesson {
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 20px;
}
.jit-lesson-title {
  font-size: 10px; font-weight: 700;
  letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--text-4); margin-bottom: 14px;
}
.jit-point {
  display: flex; gap: 12px;
  margin-bottom: 12px; align-items: flex-start;
}
.jit-point-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--grad-diag);
  margin-top: 7px; flex-shrink: 0;
}
.jit-point p { font-size: 13px; color: var(--text-2); line-height: 1.6; }
.jit-point strong { color: var(--text-1); }

.jit-btn {
  width: 100%; padding: 14px;
  background: var(--grad-diag);
  border: none; border-radius: 12px;
  color: #0A0F1A; font-size: 15px; font-weight: 800;
  cursor: pointer; font-family: inherit;
  transition: opacity .15s, transform .1s;
  margin-top: 8px;
}
.jit-btn:hover { opacity: .88; transform: translateY(-1px); }

/* ════════════════════════════════════════
   CARDS & COMPONENTS
════════════════════════════════════════ */
.page-title { font-size: 24px; font-weight: 800; color: var(--text-1); margin-bottom: 4px; }
.page-sub   { font-size: 13px; color: var(--text-3); margin-bottom: 28px; }

.card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: background .25s, border-color .15s;
  position: relative; overflow: hidden;
}
.card.accent { border-color: var(--border-teal); }
.card.accent::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--grad);
}

/* Animated traveling gradient border, matching startupsdna.co's feature cards */
@property --border-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}
.card.glow-border {
  border: 1px solid transparent;
  background:
    linear-gradient(var(--bg-3), var(--bg-3)) padding-box,
    conic-gradient(from var(--border-angle), var(--border), #1064A0, #8AF6A0, var(--border)) border-box;
  animation: borderRotate 5s linear infinite;
}
@keyframes borderRotate {
  to { --border-angle: 360deg; }
}
.plan-card.glow-border {
  border: 1px solid transparent;
  background:
    linear-gradient(var(--bg-3), var(--bg-3)) padding-box,
    conic-gradient(from var(--border-angle), var(--border), #1064A0, #8AF6A0, var(--border)) border-box;
  animation: borderRotate 5s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
  .card.glow-border, .plan-card.glow-border { animation: none; border-color: var(--border-teal); }
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px,1fr));
  gap: 14px; margin-bottom: 28px;
}
.stat-card {
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 13px; padding: 18px 20px;
  transition: background .25s;
}
.stat-val   { font-size: 28px; font-weight: 800; color: var(--text-1); line-height: 1; margin-bottom: 4px; }
.stat-val.teal  { color: var(--teal); }
.stat-val.green { color: var(--green); }
.stat-label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }

/* Forms */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block; font-size: 11px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 7px;
}
.form-input, .form-textarea, .form-select {
  width: 100%; padding: 11px 14px;
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-1); font-size: 14px;
  font-family: inherit; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(16,100,160,0.1);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-4); }
.form-textarea { resize: vertical; min-height: 100px; line-height: 1.6; }
.form-select { appearance: none; cursor: pointer; }
.form-hint { font-size: 11px; color: var(--text-4); margin-top: 5px; }

/* Buttons */
.btn-primary {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 22px;
  background: var(--grad-diag);
  border: none; border-radius: var(--radius);
  color: #0A0F1A; font-size: 14px; font-weight: 800;
  cursor: pointer; font-family: inherit;
  transition: opacity .15s, transform .1s;
}
.btn-primary:hover { opacity: .88; transform: translateY(-1px); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn-primary.full { width: 100%; justify-content: center; }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-2); font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: all .15s;
}
.btn-ghost:hover { border-color: var(--teal); color: var(--teal); }

/* Alerts */
.alert { border-radius: var(--radius); padding: 12px 16px; font-size: 13px; margin-bottom: 16px; display: none; }
.alert.show { display: block; }
.alert-error   { background: rgba(226,90,90,.1); border: 1px solid rgba(226,90,90,.25); color: var(--error); }
.alert-success { background: rgba(138,246,160,.1); border: 1px solid rgba(138,246,160,.25); color: var(--success); }
.alert-info    { background: rgba(16,100,160,.08); border: 1px solid rgba(16,100,160,.2); color: var(--teal); }

/* Progress bar */
.prog-track { height: 6px; background: var(--bg-4); border-radius: 3px; overflow: hidden; }
.prog-fill  { height: 100%; border-radius: 3px; background: var(--grad); transition: width .5s ease; }
.prog-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-3); margin-bottom: 6px; font-weight: 600; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700;
}
.badge-teal   { background: rgba(16,100,160,.12); color: var(--teal); border: 1px solid rgba(16,100,160,.2); }
.badge-green  { background: rgba(138,246,160,.12); color: var(--green); border: 1px solid rgba(138,246,160,.2); }
.badge-orange { background: rgba(240,168,76,.12); color: var(--warning); border: 1px solid rgba(240,168,76,.2); }
.badge-gray   { background: var(--bg-4); color: var(--text-3); border: 1px solid var(--border); }

/* Table */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; padding: 10px 14px;
  font-size: 10px; font-weight: 700;
  letter-spacing: 1px; text-transform: uppercase;
  color: var(--text-4);
  border-bottom: 1px solid var(--border);
}
[dir="rtl"] .data-table th { text-align: right; }
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text-2); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-card); }

/* AI Chat bubble */
.ai-bubble {
  position: fixed; bottom: 24px; right: 24px; z-index: 200;
}
[dir="rtl"] .ai-bubble { right: auto; left: 24px; }
.ai-bubble-btn {
  width: 64px; height: 78px;
  background: transparent;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0; position: relative;
  animation: dnaThrobFilter 2.2s ease-in-out infinite;
  transition: transform .2s;
}
.ai-bubble-btn:hover {
  transform: scale(1.12) translateY(-2px);
  animation: none;
  filter: drop-shadow(0 8px 28px rgba(16,100,160,0.75));
}
@keyframes dnaThrobFilter {
  0%   { filter: drop-shadow(0 4px 12px rgba(16,100,160,0.35)) drop-shadow(0 0 4px rgba(138,246,160,0.2)); transform: scale(1); }
  50%  { filter: drop-shadow(0 6px 22px rgba(16,100,160,0.75)) drop-shadow(0 0 16px rgba(138,246,160,0.5)); transform: scale(1.06); }
  100% { filter: drop-shadow(0 4px 12px rgba(16,100,160,0.35)) drop-shadow(0 0 4px rgba(138,246,160,0.2)); transform: scale(1); }
}

/* AI Chat panel */
.ai-panel {
  position: fixed; bottom: 88px; right: 24px;
  width: 340px; height: 480px;
  background: var(--bg-3);
  border: 1px solid var(--border-teal);
  border-radius: 18px;
  display: flex; flex-direction: column;
  z-index: 199;
  box-shadow: var(--shadow);
  transform: scale(.9) translateY(16px);
  opacity: 0; pointer-events: none;
  transition: all .22s cubic-bezier(.34,1.56,.64,1);
}
[dir="rtl"] .ai-panel { right: auto; left: 24px; }
.ai-panel.open { transform: scale(1) translateY(0); opacity: 1; pointer-events: all; }

.ai-panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-2);
  border-radius: 18px 18px 0 0;
}
.ai-panel-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--grad-diag);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}
.ai-panel-name   { font-size: 13px; font-weight: 700; color: var(--text-1); }
.ai-panel-status { font-size: 11px; color: var(--text-4); }
.ai-panel-close  { margin-left: auto; background: none; border: none; color: var(--text-3); font-size: 18px; cursor: pointer; padding: 2px; }
.ai-panel-close:hover { color: var(--text-1); }

.ai-messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.ai-msg { display: flex; }
.ai-msg.user { justify-content: flex-end; }
.ai-bubble-msg {
  max-width: 85%; padding: 9px 13px;
  border-radius: 12px; font-size: 13px; line-height: 1.55;
}
.ai-msg.bot  .ai-bubble-msg { background: var(--bg-4); color: var(--text-2); border-bottom-left-radius: 4px; }
.ai-msg.user .ai-bubble-msg { background: var(--grad-diag); color: #0A0F1A; font-weight: 600; border-bottom-right-radius: 4px; }
.ai-msg.thinking .ai-bubble-msg { background: var(--bg-4); color: var(--text-4); font-style: italic; }

.ai-input-row { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.ai-input {
  flex: 1; background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 12px;
  color: var(--text-1); font-size: 13px; font-family: inherit; outline: none;
}
.ai-input:focus { border-color: var(--teal); }
.ai-input::placeholder { color: var(--text-4); }
.ai-send {
  width: 36px; height: 36px;
  background: var(--grad-diag);
  border: none; border-radius: 8px;
  color: #0A0F1A; font-size: 16px; cursor: pointer; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* Interview cards */
.interview-card {
  background: var(--bg-4); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px;
  margin-bottom: 10px; position: relative;
}
.interview-card-name { font-size: 14px; font-weight: 700; color: var(--text-1); margin-bottom: 4px; }
.interview-card-meta { font-size: 12px; color: var(--text-4); margin-bottom: 8px; }
.interview-card-pain { font-size: 13px; color: var(--text-2); line-height: 1.5; }
.interview-del {
  position: absolute; top: 12px; right: 12px;
  background: none; border: none; cursor: pointer;
  color: var(--text-4); font-size: 14px; padding: 4px;
  transition: color .15s;
}
[dir="rtl"] .interview-del { right: auto; left: 12px; }
.interview-del:hover { color: var(--error); }

/* Pilot pipeline */
.pipeline { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.pipeline-col { flex: 0 0 200px; }
.pipeline-col-title {
  font-size: 10px; font-weight: 700; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--text-4);
  margin-bottom: 10px; padding: 0 2px;
}
.pilot-card {
  background: var(--bg-4); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px;
  margin-bottom: 8px; cursor: pointer;
  transition: border-color .15s, transform .1s;
}
.pilot-card:hover { border-color: var(--teal); transform: translateY(-1px); }
.pilot-card-co   { font-size: 13px; font-weight: 700; color: var(--text-1); margin-bottom: 3px; }
.pilot-card-name { font-size: 12px; color: var(--text-3); }

/* Spinner */
.spinner {
  width: 15px; height: 15px;
  border: 2px solid rgba(10,15,26,.25);
  border-top-color: #0A0F1A;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: none;
}
.spinner.light {
  border-color: rgba(255,255,255,.2);
  border-top-color: #fff;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Offer tier card */
.tier-card {
  background: var(--bg-4); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px;
  margin-bottom: 10px; display: flex;
  align-items: center; justify-content: space-between; gap: 12px;
}
.tier-name  { font-size: 15px; font-weight: 700; color: var(--text-1); }
.tier-price { font-size: 13px; color: var(--text-3); }
.tier-margin { font-size: 13px; font-weight: 700; color: var(--green); }

/* Data room section */
.data-section { margin-bottom: 28px; }
.data-section-title {
  font-size: 11px; font-weight: 700;
  letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--text-4); margin-bottom: 12px;
}

/* ════════════════════════════════
   DESKTOP NAV — proper positioning
════════════════════════════════ */
.header-nav {
  display: flex;
  gap: 2px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

/* Mobile bottom nav — hidden on desktop */
.mobile-nav { display: none; }

/* ════════════════════════════════
   MOBILE RESPONSIVE
════════════════════════════════ */
@media (max-width: 900px) {
  /* Header scrolls horizontally on mobile — nothing hidden */
  .app-header {
    padding: 0 10px;
    gap: 6px;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    justify-content: flex-start;
  }
  .app-header::-webkit-scrollbar { display: none; }
  /* Nav sits inline, not absolutely positioned on mobile */
  #header-center-nav {
    position: relative !important;
    left: unset !important;
    transform: none !important;
    flex-shrink: 0;
  }
  .header-spacer { display: none; }
  .sidebar-toggle-btn { display: none !important; }

  /* Sidebar off */
  .sidebar { display: none !important; }

  /* App layout — simple flex column */
  #app {
    display: flex !important;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
  }
  .app-header { flex-shrink: 0; }
  .main-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px 14px calc(90px + env(safe-area-inset-bottom));
    grid-column: unset;
    grid-row: unset;
  }

  /* Bottom nav — visible on mobile */
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 58px;
    height: calc(58px + env(safe-area-inset-bottom));
    background: var(--bg-2);
    border-top: 1px solid var(--border);
    z-index: 300;
    align-items: center;
    justify-content: space-around;
    padding: 0 4px;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 5px 8px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-4);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    transition: color .15s;
    min-width: 50px;
    cursor: pointer;
    background: none;
    border: none;
    font-family: inherit;
  }
  .mobile-nav-item.active { color: var(--teal); }
  .mobile-nav-item:hover  { color: var(--teal); }
  .mobile-nav-icon { font-size: 20px; line-height: 1; }

  /* Cards */
  .card { padding: 16px; border-radius: 12px; }
  .stats-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-val  { font-size: 22px; }
  .page-title { font-size: 20px; }
  .page-sub   { font-size: 12px; }

  /* Inputs — prevent iOS zoom */
  .form-input, .form-textarea, .form-select { font-size: 16px; }

  /* AI chat above mobile nav */
  .ai-bubble    { bottom: calc(72px + env(safe-area-inset-bottom)); right: 14px; }
  .ai-panel     { bottom: 82px; width: calc(100vw - 20px); right: 10px; max-height: 70vh; }
  .learning-nudge { bottom: 72px; width: calc(100vw - 20px); right: 10px; }
  .nudge-tab    { bottom: 124px; }

  /* Pipeline */
  .pipeline { overflow-x: auto; gap: 10px; }
  .pipeline-col { flex: 0 0 180px; }

  /* Profile menu */
  .profile-menu { right: 0; left: auto; width: 210px; }
}

/* Extra small */
@media (max-width: 400px) {
  .main-content { padding: 14px 10px 80px; }
  .mobile-nav-item { min-width: 42px; font-size: 8px; }
}


/* ════════════════════════════════════════
   HEADER NAV — from original index.html
════════════════════════════════════════ */
.sidebar-toggle-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-3);
  transition: all 0.15s; flex-shrink: 0;
}
.sidebar-toggle-btn:hover { border-color: rgba(16,100,160,0.3); color: var(--teal); }

#app.sidebar-hidden { grid-template-columns: 0 1fr !important; }
#app.sidebar-hidden .sidebar { min-width: 0 !important; width: 0 !important; opacity: 0; pointer-events: none; padding: 0; }

.header-nav-group { position: relative; }

.header-tab {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 14px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: 'Inter', var(--font-ar), sans-serif;
  transition: all 0.15s;
  white-space: nowrap;
  line-height: 1;
}
.header-tab:hover { background: var(--bg-card); color: var(--text-1); }
.header-tab.active { background: rgba(16,100,160,0.12); color: var(--teal); }
.header-tab svg { opacity: 0.7; flex-shrink: 0; }
.header-tab:hover svg, .header-tab.active svg { opacity: 1; }

.header-submenu {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 210px;
  background: var(--bg-2);
  border: 1px solid var(--border-teal);
  border-radius: 12px;
  padding: 5px;
  display: none;
  z-index: 99999;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5), 0 0 0 1px rgba(16,100,160,0.08);
}
.header-submenu.open { display: block; animation: submenuIn 0.15s ease; }
@keyframes submenuIn {
  from { opacity:0; transform: translateX(-50%) translateY(-6px); }
  to   { opacity:1; transform: translateX(-50%) translateY(0); }
}
.header-submenu::before {
  content: '';
  position: absolute;
  top: -6px; left: 50%;
  width: 10px; height: 10px;
  background: var(--bg-2);
  border-left: 1px solid var(--border-teal);
  border-top: 1px solid var(--border-teal);
  transform: translateX(-50%) rotate(45deg);
}

/* Mobile dropdown portal — reuses .header-submenu box styling but is
   rendered as a direct child of <body> (see base.html) and positioned via
   JS (getBoundingClientRect) so it escapes #app / .app-header's clipping,
   which is required on mobile for the horizontal tab-scroll to work. */
.mobile-submenu-portal {
  position: fixed !important;
  transform: none !important;
  left: 0; top: 0; /* overridden inline by JS on open */
}
.mobile-submenu-portal::before { display: none; }

/* Print — hide all app chrome so window.print() produces a clean, investor-ready
   document instead of the full nav/sidebar/mobile-nav/coach bubble. Applies to every
   page since Print/PDF buttons exist on several (Executive Summary, Certificates, etc). */
@media print {
  /* Redefine the dark-mode variables at the root so EVERY element using
     var(--text-2), var(--bg-4), etc — inline style or class, anywhere in
     the app — automatically prints in appropriate light-mode colors,
     instead of dark-mode colors rendering wrong (or invisible) on white
     paper. This fixes print output app-wide, not just one page at a time. */
  :root {
    --bg:          #ffffff;
    --bg-2:        #ffffff;
    --bg-3:        #f9fafb;
    --bg-4:        #f3f4f6;
    --bg-card:     #f9fafb;
    --border:      #e5e7eb;
    --border-teal: #99e2ef;
    --text-1:      #111827;
    --text-2:      #374151;
    --text-3:      #6b7280;
    --text-4:      #9ca3af;
    --shadow:      none;
  }

  .app-header, .sidebar, .mobile-nav, .ai-bubble,
  .header-submenu, #mobileSubmenuPortal, #moreMenuOverlay, #moreMenuSheet,
  .sidebar-toggle-btn {
    display: none !important;
  }
  #app { display: block !important; height: auto !important; overflow: visible !important; }
  .main-content { margin: 0 !important; padding: 0 !important; width: 100% !important; max-width: none !important; height: auto !important; overflow: visible !important; }
  body { background: #ffffff !important; color: #111827 !important; }
  .card, .card.accent { background: #ffffff !important; border: 1px solid #e5e7eb !important; box-shadow: none !important; }
  .btn-primary, .btn-ghost, button, .no-print { display: none !important; }
}
.hsub-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  cursor: pointer; font-size: 13px; font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}
.hsub-item:hover { background: rgba(16,100,160,0.1); color: var(--text-1); }
.hsub-item svg { opacity: 0.55; flex-shrink: 0; }
.hsub-item:hover svg { opacity: 1; }
.hsub-divider { height: 1px; background: var(--border); margin: 4px 6px; }

/* Profile dropdown */
.profile-wrap { position: relative; }
.profile-menu {
  position: absolute;
  top: calc(100% + 8px); right: 0;
  width: 200px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  display: none; z-index: 99999;
  box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}
.profile-menu.open { display: block; }
.profile-menu-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 7px;
  cursor: pointer; font-size: 13px; font-weight: 500;
  color: var(--text-2); transition: background 0.15s;
  text-decoration: none;
}
.profile-menu-item:hover { background: var(--bg-card); color: var(--text-1); }
.profile-menu-item.danger:hover { background: rgba(226,90,90,0.1); color: var(--error); }
.profile-menu-divider { height: 1px; background: var(--border); margin: 5px 0; }
.profile-menu-header {
  padding: 10px 10px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.profile-menu-name  { font-size: 13px; font-weight: 700; color: var(--text-1); }
.profile-menu-email { font-size: 11px; color: var(--text-4); margin-top: 2px; }

/* Light mode overrides for header */
[data-theme="light"] .header-tab { color: rgba(13,17,23,0.65); }
[data-theme="light"] .header-tab:hover { color: var(--text-1); background: rgba(0,0,0,0.05); }
[data-theme="light"] .header-submenu { background: #ffffff; }
[data-theme="light"] .header-submenu::before { background: #ffffff; }
[data-theme="light"] .hsub-item { color: rgba(13,17,23,0.7); }
[data-theme="light"] .profile-menu { background: #ffffff; }

/* ctrl-btn light mode */
[data-theme="light"] .ctrl-btn { color: rgba(13,17,23,0.65); }
[data-theme="light"] .ctrl-btn:hover { color: var(--teal); }



