/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  /* Gradient */
  --grad-bg: linear-gradient(160deg, #e8e0f7 0%, #f0edfb 25%, #ffffff 55%);

  /* Brand colours */
  --color-primary: #4f46e5;
  --color-primary-light: #6366f1;
  --color-teal: #22d3ee;
  --color-teal-dark: #0891b2;

  /* Grade colours */
  --color-grade-a: linear-gradient(135deg, #6366f1, #4f46e5);
  --color-grade-b: linear-gradient(135deg, #22d3ee, #0891b2);
  --color-grade-c: linear-gradient(135deg, #f59e0b, #d97706);
  --color-grade-d: linear-gradient(135deg, #ef4444, #dc2626);
  --color-grade-f: linear-gradient(135deg, #dc2626, #991b1b);

  /* Verdict colours */
  --color-go: linear-gradient(135deg, #22d3ee, #4f46e5);
  --color-stand-aside: linear-gradient(135deg, #ef4444, #dc2626);
  --color-conditional: linear-gradient(135deg, #f59e0b, #d97706);

  /* Semantic */
  --color-win: #16a34a;
  --color-loss: #dc2626;
  --color-warn: #f59e0b;
  --color-neutral: #94a3b8;

  /* Text */
  --text-primary: #0f172a;
  --text-secondary: #374151;
  --text-muted: #94a3b8;

  /* Glass card */
  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-border: rgba(220, 215, 240, 0.6);
  --glass-blur: blur(12px);

  /* Border radius */
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-phone: 36px;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 14px;
  --space-lg: 20px;
  --space-xl: 28px;

  /* Shadows */
  --shadow-card: 0 4px 16px rgba(99, 102, 241, 0.12);
  --shadow-elevated: 0 8px 32px rgba(99, 102, 241, 0.18);

  /* Font */
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
}

/* ============================================================
   RESET + BASE
   ============================================================ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  font-family: var(--font);
  background: #dde3f0;
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

button { cursor: pointer; font-family: var(--font); border: none; background: none; }
textarea { font-family: var(--font); }

/* ============================================================
   APP SHELL
   ============================================================ */
.app-shell {
  max-width: 430px;
  margin: 0 auto;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

.screen {
  display: none;
  flex-direction: column;
  height: 100vh;
  background: var(--grad-bg);
  overflow: hidden;
}

.screen.active {
  display: flex;
}

.tab-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
}

/* ============================================================
   STATUS BAR
   ============================================================ */
.status-bar {
  padding: 12px 20px 4px;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
}

/* ============================================================
   APP HEADER
   ============================================================ */
.app-header {
  padding: 8px 20px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(200, 190, 230, 0.3);
  flex-shrink: 0;
}

.app-header-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.app-header-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* ============================================================
   TAB BAR
   ============================================================ */
.tab-bar {
  display: flex;
  padding: 12px 14px 14px;
  gap: 8px;
  border-top: 1px solid rgba(200, 190, 230, 0.3);
  background: rgba(255, 255, 255, 0.3);
  backdrop-filter: var(--glass-blur);
  flex-shrink: 0;
}

.tab {
  flex: 1;
  padding: 10px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}

.tab.active {
  background: #f1f5ff;
  color: var(--color-primary);
}

/* ============================================================
   GLASS CARD
   ============================================================ */
.glass {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 1.5px solid var(--glass-border);
  border-radius: var(--radius-lg);
}

/* ============================================================
   SECTION TITLE
   ============================================================ */
.section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 10px 20px 6px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-radius: var(--radius-md);
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.2px;
  transition: opacity 0.15s;
}

.btn-primary:hover { opacity: 0.9; }

.btn-primary-sm {
  background: var(--color-primary);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 700;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.6);
  border: 1.5px solid var(--glass-border);
  color: var(--color-primary);
  border-radius: var(--radius-md);
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 700;
}

.btn-link {
  color: var(--color-primary);
  font-size: 12px;
  font-weight: 700;
  background: none;
  border: none;
  text-decoration: underline;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 24px;
  text-align: center;
  min-height: 300px;
}

.empty-icon { font-size: 48px; }

.empty-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.empty-sub {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 260px;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
}

.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  background: #fff;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-primary);
}

.modal-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: -8px;
}

.paste-input {
  width: 100%;
  border: 1.5px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 12px;
  font-size: 12px;
  color: var(--text-secondary);
  resize: none;
  outline: none;
  background: #fafafa;
}

.paste-input:focus { border-color: var(--color-primary); }

.paste-error {
  font-size: 12px;
  color: var(--color-loss);
  font-weight: 600;
}

.modal-actions {
  display: flex;
  gap: 12px;
}

.modal-actions .btn-secondary,
.modal-actions .btn-primary {
  flex: 1;
}

/* ============================================================
   DRIVE BANNER
   ============================================================ */
.drive-banner {
  position: fixed;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.75);
  color: #fff;
  font-size: 12px;
  padding: 8px 16px;
  border-radius: 20px;
  display: flex;
  gap: 12px;
  align-items: center;
  max-width: 380px;
  width: calc(100% - 32px);
  z-index: 50;
}

.drive-banner.hidden { display: none; }

/* ============================================================
   TAB 1 — AT A GLANCE COMPONENTS
   (Populated dynamically by tab1.js — classes defined here)
   ============================================================ */

/* Chart window */
.chart-window {
  margin: 12px 14px 10px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  background: #1a1a2e;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.chart-btn-tv {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 700;
  backdrop-filter: blur(4px);
}

.chart-no-image {
  color: rgba(255,255,255,0.4);
  font-size: 13px;
  font-weight: 600;
}

/* Grade card */
.grade-card {
  margin: 0 14px 10px;
  padding: 16px;
  border-radius: var(--radius-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-elevated);
  color: #fff;
}

.grade-card.grade-a { background: var(--color-grade-a); }
.grade-card.grade-b { background: var(--color-grade-b); }
.grade-card.grade-c { background: var(--color-grade-c); }
.grade-card.grade-d, .grade-card.grade-f { background: var(--color-grade-d); }

.grade-letter {
  font-size: 40px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -2px;
}

.grade-name {
  font-size: 14px;
  font-weight: 700;
  margin-top: 4px;
}

.grade-strategy {
  font-size: 12px;
  opacity: 0.8;
  margin-top: 2px;
}

/* Score ring */
.score-ring-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.score-ring {
  width: 56px;
  height: 56px;
  position: relative;
}

.score-ring svg {
  width: 56px;
  height: 56px;
  transform: rotate(-90deg);
}

.score-ring circle {
  fill: none;
  stroke-width: 5;
  r: 23;
  cx: 28;
  cy: 28;
}

.score-ring .ring-bg { stroke: rgba(255,255,255,0.2); }
.score-ring .ring-fill { stroke: #fff; stroke-linecap: round; transition: stroke-dashoffset 0.5s ease; }

.score-number {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 900;
  color: #fff;
}

.score-label {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.75);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Lens confirmation row */
.lens-row {
  display: flex;
  gap: 8px;
  margin: 0 14px 10px;
}

.lens-card {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius-md);
  text-align: center;
}

.lens-card.confirmed {
  background: rgba(22,163,74,0.1);
  border: 1.5px solid rgba(22,163,74,0.3);
}

.lens-card.unconfirmed {
  background: rgba(239,68,68,0.08);
  border: 1.5px solid rgba(239,68,68,0.25);
}

.lens-badge {
  font-size: 18px;
  margin-bottom: 4px;
}

.lens-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
}

/* Pillar bars */
.pillars-wrap {
  margin: 0 14px 10px;
  padding: 14px 16px;
}

.pillar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.pillar-row:last-child { margin-bottom: 0; }

.pillar-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  width: 24px;
  flex-shrink: 0;
}

.pillar-bar-track {
  flex: 1;
  height: 6px;
  background: rgba(99,102,241,0.1);
  border-radius: 4px;
  overflow: hidden;
}

.pillar-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.pillar-bar-fill.strong { background: var(--color-primary); }
.pillar-bar-fill.moderate { background: var(--color-teal); }
.pillar-bar-fill.weak { background: var(--color-warn); }

.pillar-score {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  width: 20px;
  text-align: right;
  flex-shrink: 0;
}

/* Execution strip */
.execution-strip {
  display: flex;
  gap: 8px;
  margin: 0 14px 10px;
}

.exec-cell {
  flex: 1;
  padding: 10px 8px;
  border-radius: var(--radius-md);
  text-align: center;
}

.exec-cell-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.exec-cell-value {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-primary);
}

/* Trade ID + entry section */
.trade-meta {
  margin: 0 14px 10px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.trade-id-text {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
  font-family: monospace;
}

.btn-copy-id {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-primary);
  background: rgba(99,102,241,0.08);
  border: 1.5px solid rgba(99,102,241,0.2);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
}

/* Entry management */
.entries-wrap {
  margin: 0 14px 10px;
  padding: 14px 16px;
}

.entry-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-secondary);
  padding: 4px 0;
  border-bottom: 1px solid rgba(220,215,240,0.3);
}

.entry-row:last-of-type { border-bottom: none; }

.entry-avg {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1.5px solid rgba(220,215,240,0.5);
}

.btn-add-entry {
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  background: rgba(99,102,241,0.08);
  border: 1.5px dashed rgba(99,102,241,0.3);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 700;
  color: var(--color-primary);
}

/* Verdict button */
.verdict-btn {
  margin: 0 14px 10px;
  padding: 16px;
  border-radius: var(--radius-lg);
  color: #fff;
  box-shadow: var(--shadow-elevated);
  text-align: center;
}

.verdict-btn.go { background: var(--color-go); }
.verdict-btn.stand-aside { background: var(--color-stand-aside); }
.verdict-btn.conditional { background: var(--color-conditional); }

.verdict-label {
  font-size: 16px;
  font-weight: 900;
  letter-spacing: -0.3px;
}

.verdict-reason {
  font-size: 12px;
  opacity: 0.85;
  margin-top: 4px;
}

/* Divider */
.divider {
  height: 1px;
  background: rgba(200,190,230,0.25);
  margin: 2px 14px;
}

/* ============================================================
   TAB 2 — FULL ANALYSIS COMPONENTS
   ============================================================ */

/* Tab 2 — lens tag colour variants */
.lens-tag { display: inline-block; font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 8px; margin-bottom: 10px; }
.lens-tag-l1 { background: rgba(99,102,241,0.1); color: #4f46e5; }
.lens-tag-l2 { background: rgba(8,145,178,0.1); color: #0891b2; }
.lens-tag-interconnections { background: rgba(99,102,241,0.08); color: #6366f1; }
.lens-tag-execution { background: rgba(22,163,74,0.1); color: #16a34a; }
.lens-tag-verdict { background: rgba(99,102,241,0.1); color: #4f46e5; }

/* Tab 2 — section nav chips */
.section-nav { display: flex; gap: 6px; padding: 8px 14px 6px; overflow-x: auto; scrollbar-width: none; }
.section-nav::-webkit-scrollbar { display: none; }
.nav-chip { padding: 6px 12px; border-radius: 20px; font-size: 11px; font-weight: 700; white-space: nowrap; border: none; cursor: pointer; flex-shrink: 0; }
.nav-chip.active { background: #4f46e5; color: #fff; }
.nav-chip.done { background: rgba(22,163,74,0.12); color: #16a34a; border: 1.5px solid rgba(22,163,74,0.3); }
.nav-chip.inactive { background: rgba(255,255,255,0.5); color: #94a3b8; border: 1.5px solid rgba(220,215,240,0.5); }

/* Tab 2 — content card */
.content-card { margin: 0 14px 10px; padding: 18px 16px; min-height: 240px; }
.content-title { font-size: 15px; font-weight: 800; color: #0f172a; margin-bottom: 12px; letter-spacing: -0.3px; }
.content-text { font-size: 13px; line-height: 1.75; color: #374151; }

/* Tab 2 — progress dots */
.progress-dots { display: flex; justify-content: center; gap: 6px; padding: 8px 0; }
.dot { width: 6px; height: 6px; border-radius: 50%; }
.dot.active { background: #4f46e5; width: 18px; border-radius: 4px; }
.dot.done { background: #16a34a; }
.dot.inactive { background: #e2e8f0; }

/* Tab 2 — nav arrows */
.nav-arrows { display: flex; justify-content: space-between; align-items: center; padding: 4px 14px 8px; }
.nav-btn { background: rgba(255,255,255,0.6); border: 1.5px solid rgba(220,215,240,0.6); border-radius: 12px; padding: 10px 20px; font-size: 13px; font-weight: 700; color: #4f46e5; cursor: pointer; }
.nav-btn.next { background: #4f46e5; color: #fff; border-color: #4f46e5; }

/* ============================================================
   TAB 3 — JOURNAL COMPONENTS
   ============================================================ */

/* Tab 3 — Journal */
.period-tabs { display: flex; gap: 6px; }
.period-tab { flex: 1; padding: 7px 4px; border-radius: 10px; text-align: center; font-size: 11px; font-weight: 700; border: none; cursor: pointer; }
.period-tab.active { background: #4f46e5; color: #fff; }
.period-tab.inactive { background: rgba(255,255,255,0.4); color: #94a3b8; border: 1.5px solid rgba(220,215,240,0.5); }

.grade-dots-card { margin: 0 14px 12px; padding: 14px 16px; }
.grade-dots-header { display: flex; justify-content: space-between; margin-bottom: 10px; }
.grade-dots-title { font-size: 11px; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: 0.06em; }
.grade-pct { font-size: 18px; font-weight: 800; color: #4f46e5; }
.grade-dots { display: flex; gap: 5px; flex-wrap: wrap; }
.grade-dot { width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 800; color: white; }
.dot-a { background: linear-gradient(135deg,#6366f1,#4f46e5); }
.dot-b { background: linear-gradient(135deg,#0891b2,#0e7490); }
.dot-c { background: linear-gradient(135deg,#d97706,#b45309); }
.dot-d { background: linear-gradient(135deg,#ef4444,#dc2626); }

.trade-list { padding: 0 14px; display: flex; flex-direction: column; gap: 10px; padding-bottom: 12px; }
.trade-card { padding: 14px 16px; cursor: pointer; }
.trade-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.trade-info { flex: 1; padding: 0 10px; }
.trade-strategy { font-size: 13px; font-weight: 700; color: #0f172a; }
.trade-pnl { text-align: right; }
.pnl-value { font-size: 16px; font-weight: 800; }
.pnl-value.win { color: #16a34a; }
.pnl-value.loss { color: #dc2626; }
.pnl-sub { font-size: 10px; color: #94a3b8; font-weight: 600; margin-top: 1px; }

.trade-story { font-size: 12px; line-height: 1.6; color: #374151; background: rgba(99,102,241,0.05); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; border-left: 3px solid #6366f1; }
.trade-story.warn { border-left-color: #ef4444; background: rgba(239,68,68,0.04); }

.deviation-row { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 6px; }
.dev-tag { font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 8px; }
.dev-tag.tracked { background: rgba(99,102,241,0.1); color: #4f46e5; }
.dev-tag.warn { background: rgba(239,68,68,0.1); color: #dc2626; }
.dev-tag.ok { background: rgba(22,163,74,0.1); color: #16a34a; }

.stats-pills { display: flex; gap: 5px; }
.pill { font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 8px; background: rgba(148,163,184,0.12); color: #64748b; }

.intuition-card { margin: 0 14px 12px; padding: 14px 16px; }
.intuition-title { font-size: 12px; font-weight: 700; color: #0f172a; margin-bottom: 10px; }
.intuition-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid rgba(220,215,240,0.4); }
.intuition-row:last-child { border-bottom: none; padding-bottom: 0; }
.intuition-label { font-size: 12px; color: #374151; font-weight: 500; flex: 1; }
.intuition-stat { font-size: 12px; font-weight: 800; }
.intuition-stat.good { color: #16a34a; }
.intuition-stat.warn { color: #d97706; }
.intuition-stat.bad { color: #dc2626; }
.intuition-bar-wrap { width: 60px; height: 6px; background: #e2e8f0; border-radius: 6px; overflow: hidden; margin: 0 8px; }
.intuition-bar { height: 100%; border-radius: 6px; }
