/* ════════════════════════════════════════════════════════
   DASHBOARD — Sociodynamic Diagnostics
   Extracted from dashboard prototype, shared by all views
   ════════════════════════════════════════════════════════ */

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

:root {
  --bg-deep: #0D0D1A; --bg-primary: #1A1A2E; --bg-elevated: #222240;
  --bg-card: #1E1E36; --bg-card-hover: #26264A;
  --amber: #D4A843; --amber-dim: rgba(212,168,67,0.15); --amber-glow: rgba(212,168,67,0.25);
  --red: #E05555; --red-dim: rgba(224,85,85,0.12); --red-glow: rgba(224,85,85,0.3);
  --orange: #E08A45; --orange-dim: rgba(224,138,69,0.12);
  --teal: #45B8A0; --teal-dim: rgba(69,184,160,0.12);
  --blue: #5588CC; --blue-dim: rgba(85,136,204,0.12);
  --text-primary: #E8E4DC; --text-secondary: #9A96A6; --text-dim: #6A6678;
  --border: rgba(255,255,255,0.06); --border-active: rgba(212,168,67,0.3);
}

html { font-size: 15px; }
body {
  background: var(--bg-deep); color: var(--text-primary);
  font-family: 'Inter', sans-serif; font-weight: 400; line-height: 1.5;
  min-height: 100vh; -webkit-font-smoothing: antialiased;
}
body::before {
  content: ''; position: fixed; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,0.012) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,0.012) 1px, transparent 1px);
  background-size: 60px 60px; pointer-events: none; z-index: 0;
}
.mono { font-family: 'JetBrains Mono', monospace; font-size: 0.88em; }
.dashboard { max-width: 1440px; margin: 0 auto; padding: 24px 32px 48px; position: relative; z-index: 1; }

/* ── TABS (with integrated brand) ── */
.tab-bar { display: flex; align-items: center; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab-brand { display: flex; align-items: center; padding: 8px 16px 10px 0; margin-right: 8px; border-right: 1px solid var(--border); }
.tab-phi { font-family: 'Outfit', sans-serif; font-size: 1.2rem; font-weight: 800; color: var(--amber); }
.tab-btn { font-family: 'Outfit', sans-serif; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.06em; padding: 10px 20px 12px; background: none; border: none; color: var(--text-dim); cursor: pointer; border-bottom: 2px solid transparent; transition: all 0.2s; text-transform: uppercase; }
.tab-btn.active { color: var(--amber); border-bottom-color: var(--amber); }
.tab-btn.disabled { opacity: 0.3; cursor: not-allowed; }
.tab-btn:not(.disabled):not(.active):hover { color: var(--text-secondary); }
.tab-back { margin-left: auto; font-family: 'Outfit', sans-serif; font-size: 0.75rem; font-weight: 500; color: var(--text-secondary); background: none; border: 1px solid var(--border); border-radius: 5px; cursor: pointer; padding: 5px 12px; transition: all 0.2s; letter-spacing: 0.02em; }
.tab-back:hover { color: var(--text-primary); border-color: var(--text-dim); }
.tab-btn.disabled { cursor: pointer; }
.tab-hint {
  font-size: 0.78rem; color: var(--text-dim); line-height: 1.6;
  padding: 10px 16px; margin-bottom: 12px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px;
}

/* ── POPULATION SELECTOR ── */
.pop-selector { display: flex; gap: 8px; margin-bottom: 20px; align-items: center; flex-wrap: wrap; }
.pop-selector-label { font-family: 'Outfit', sans-serif; font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-dim); margin-right: 4px; }
.pop-chip { font-family: 'Outfit', sans-serif; font-size: 0.75rem; font-weight: 600; padding: 6px 16px; border-radius: 20px; border: 1px solid var(--border); background: transparent; color: var(--text-secondary); cursor: pointer; transition: all 0.2s; }
.pop-chip.active { background: var(--amber-dim); border-color: var(--amber); color: var(--amber); }
.pop-chip:not(.active):hover { border-color: var(--text-dim); color: var(--text-primary); }
.pop-chip .pop-phi { font-family: 'JetBrains Mono', monospace; font-size: 0.68rem; margin-left: 6px; opacity: 0.7; }
.ms-badge { font-family: 'Outfit', sans-serif; font-size: 0.6rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; padding: 3px 8px; border-radius: 4px; background: var(--blue-dim); color: var(--blue); border: 1px solid rgba(85,136,204,0.2); margin-left: auto; }

/* ── HEADER ── */
.header { display: flex; align-items: flex-start; justify-content: space-between; padding-bottom: 20px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.header-left { display: flex; align-items: center; gap: 20px; }
.phi-hero { position: relative; width: 110px; height: 110px; display: flex; align-items: center; justify-content: center; flex-direction: column; }
.phi-ring { position: absolute; inset: 0; }
.phi-ring circle { fill: none; stroke-width: 3; stroke-linecap: round; }
.phi-ring .ring-bg { stroke: var(--border); }
.phi-ring .ring-value { stroke-dasharray: 302; stroke-dashoffset: 302; transition: stroke-dashoffset 2s cubic-bezier(0.23,1,0.32,1); transform: rotate(-90deg); transform-origin: center; }
.phi-ring.animated .ring-value { stroke-dashoffset: var(--ring-target, 249); }
.phi-value { font-family: 'Outfit', sans-serif; font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; z-index: 1; }
.phi-label { font-family: 'Outfit', sans-serif; font-size: 0.7rem; font-weight: 500; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.12em; text-align: center; margin-top: -2px; z-index: 1; }
.header-meta h1 { font-family: 'Outfit', sans-serif; font-size: 1.6rem; font-weight: 700; color: var(--text-primary); letter-spacing: -0.02em; line-height: 1.2; }
.header-meta .subtitle { font-size: 0.82rem; color: var(--text-secondary); margin-top: 4px; }
.header-right { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.header-controls { display: flex; align-items: center; gap: 12px; }
.quadrant-badge { display: inline-flex; align-items: center; gap: 8px; background: var(--orange-dim); border: 1px solid rgba(224,138,69,0.25); border-radius: 6px; padding: 6px 14px; font-family: 'Outfit', sans-serif; font-size: 0.78rem; font-weight: 600; color: var(--orange); letter-spacing: 0.04em; }
.quadrant-badge .q-num { font-weight: 800; font-size: 0.9rem; }
.term-toggle { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,0.04); border: 1px solid var(--border); border-radius: 6px; padding: 5px 6px; cursor: pointer; transition: border-color 0.2s; user-select: none; }
.term-toggle:hover { border-color: var(--border-active); }
.term-toggle-label { font-family: 'Outfit', sans-serif; font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; padding: 3px 8px; border-radius: 4px; transition: all 0.25s; }
.term-toggle-label.active { background: var(--amber-dim); color: var(--amber); }
.term-toggle-label.inactive { color: var(--text-dim); }
.header-stats { display: flex; gap: 20px; }
.header-stat { text-align: right; }
.header-stat .stat-label { font-size: 0.65rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.1em; font-family: 'Outfit', sans-serif; }
.header-stat .stat-value { font-family: 'Outfit', sans-serif; font-size: 1.35rem; font-weight: 700; letter-spacing: -0.01em; }

/* ── CARDS ── */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 20px; position: relative; transition: border-color 0.3s ease; }
.card:hover { border-color: var(--border-active); }
.card-title { font-family: 'Outfit', sans-serif; font-size: 0.7rem; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.12em; margin-bottom: 18px; display: flex; align-items: center; gap: 8px; }
.card-title .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--amber); flex-shrink: 0; }
.card-title .card-value { margin-left: auto; font-size: 1rem; font-weight: 700; letter-spacing: 0; }
.grid-main { display: grid; grid-template-columns: 300px 1fr 320px; gap: 20px; margin-bottom: 20px; }
.params-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 20px; }
.param-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; text-align: center; cursor: pointer; transition: border-color 0.2s, background 0.2s; }
.param-card:hover { border-color: var(--border-active); background: var(--bg-card-hover); }
.param-card.selected { border-color: var(--amber); background: var(--bg-card-hover); }
.param-var { font-family: 'Outfit', sans-serif; font-size: 0.68rem; color: var(--text-dim); font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; }
.param-value { font-family: 'Outfit', sans-serif; font-size: 1.4rem; font-weight: 700; color: var(--text-primary); margin: 4px 0; }
.param-value.amber-v { color: var(--amber); }
.param-value.red-v { color: var(--red); }
.param-desc { font-size: 0.62rem; color: var(--text-dim); line-height: 1.3; }

/* ── SIGMA PROFILE ── */
.sigma-bars { display: flex; flex-direction: column; gap: 16px; }
.sigma-row { position: relative; cursor: pointer; padding: 4px 0; border-radius: 4px; transition: background 0.15s; }
.sigma-row:hover { background: rgba(255,255,255,0.02); }
.sigma-row.selected { background: rgba(212,168,67,0.06); }
.sigma-label-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.sigma-name { font-family: 'Outfit', sans-serif; font-size: 0.85rem; font-weight: 500; color: var(--text-secondary); }
.sigma-val { font-family: 'JetBrains Mono', monospace; font-size: 0.8rem; color: var(--text-secondary); }
.sigma-val .eff-val { color: var(--red); font-weight: 500; }
.bar-track { width: 100%; height: 6px; background: rgba(255,255,255,0.04); border-radius: 3px; overflow: visible; position: relative; }
.bar-fill { height: 100%; border-radius: 3px; transition: width 1.5s cubic-bezier(0.23,1,0.32,1); width: 0; position: relative; }
.bar-fill.amber { background: var(--amber); box-shadow: 0 0 8px var(--amber-glow); }
.bar-fill.red { background: var(--red); box-shadow: 0 0 8px var(--red-glow); }
.bar-fill.teal { background: var(--teal); }
.bar-fill-ghost { position: absolute; top: 0; left: 0; height: 100%; border-radius: 3px; border: 1px dashed rgba(212,168,67,0.35); background: transparent; transition: width 1.5s cubic-bezier(0.23,1,0.32,1) 0.3s; width: 0; }
.boundary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); }
.boundary-item { text-align: center; padding: 10px 6px; background: rgba(255,255,255,0.02); border-radius: 8px; cursor: pointer; transition: background 0.2s; }
.boundary-item:hover { background: rgba(255,255,255,0.05); }
.boundary-item .b-var { font-family: 'Outfit', sans-serif; font-size: 0.68rem; color: var(--text-dim); font-weight: 500; }
.boundary-item .b-val { font-family: 'Outfit', sans-serif; font-size: 1.15rem; font-weight: 700; margin: 4px 0 2px; }
.boundary-item .b-val.disjunct { color: var(--red); }
.boundary-item .b-val.partial { color: var(--orange); }
.boundary-item .b-val.coincident { color: var(--teal); }
.boundary-item .b-desc { font-size: 0.62rem; color: var(--text-dim); }

/* ── BREAKDOWN (SCB / AAR) ── */
.center-stack { display: flex; flex-direction: column; gap: 20px; }
.breakdown-row { display: flex; align-items: flex-end; gap: 14px; height: 160px; padding: 0 8px; margin-bottom: 10px; position: relative; }
.breakdown-col { flex: 1; display: flex; flex-direction: column; align-items: center; position: relative; height: 100%; justify-content: flex-end; cursor: pointer; border-radius: 4px; transition: background 0.15s; }
.breakdown-col:hover { background: rgba(255,255,255,0.02); }
.breakdown-col.selected { background: rgba(212,168,67,0.06); }
.bk-bar-wrap { width: 100%; max-width: 48px; height: 100%; display: flex; align-items: flex-end; position: relative; }
.bk-bar { width: 100%; border-radius: 4px 4px 2px 2px; transition: height 1.5s cubic-bezier(0.23,1,0.32,1); height: 0; position: relative; }
.bk-bar.bottleneck, .bk-bar.driver { box-shadow: 0 0 12px var(--red-glow); }
.bk-val { font-family: 'JetBrains Mono', monospace; font-size: 0.75rem; font-weight: 500; color: var(--text-primary); margin-bottom: 4px; text-align: center; }
.bk-label { font-family: 'Outfit', sans-serif; font-size: 0.68rem; font-weight: 500; color: var(--text-dim); margin-top: 8px; text-align: center; white-space: nowrap; }
.bottleneck-tag, .driver-tag { font-size: 0.55rem; font-family: 'Outfit', sans-serif; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; padding: 2px 6px; border-radius: 3px; position: absolute; top: -4px; left: 50%; transform: translateX(-50%); white-space: nowrap; background: var(--red-dim); color: var(--red); border: 1px solid rgba(224,85,85,0.25); }
.threshold-line { position: absolute; left: 0; right: 0; border-top: 1.5px dashed; z-index: 2; transition: bottom 1.5s cubic-bezier(0.23,1,0.32,1); }
.threshold-line.scb-line { border-color: rgba(69,184,160,0.5); bottom: 0; }
.threshold-line.aar-line { border-color: rgba(224,85,85,0.5); bottom: 0; }
.threshold-label { position: absolute; right: -2px; top: -18px; font-size: 0.6rem; font-family: 'Outfit', sans-serif; font-weight: 600; }
.threshold-label.scb-lbl { color: var(--teal); }
.threshold-label.aar-lbl { color: var(--red); }
.formula-line { font-size: 0.7rem; color: var(--text-dim); font-family: 'JetBrains Mono', monospace; padding: 8px 8px 0; line-height: 1.6; }

/* ── RATIO BAR ── */
.phi-ratio-bar { display: flex; align-items: center; gap: 12px; padding: 16px 20px; background: rgba(255,255,255,0.02); border-radius: 8px; margin-top: 4px; }
.ratio-segment { height: 8px; border-radius: 4px; transition: width 1.5s cubic-bezier(0.23,1,0.32,1); }
.ratio-segment.scb-seg { background: var(--teal); width: 0; flex-shrink: 0; }
.ratio-segment.aar-seg { background: var(--red); width: 0; flex: 1; }
.ratio-text { font-family: 'Outfit', sans-serif; font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.ratio-text .scb-t { color: var(--teal); }
.ratio-text .aar-t { color: var(--red); }
.ratio-text .dim { color: var(--text-dim); }

/* ── DETAIL PANEL ── */
.detail-panel .card { min-height: 100%; }
.detail-header { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.detail-icon { width: 32px; height: 32px; border-radius: 6px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 0.9rem; }
.detail-icon.finding-icon { background: var(--red-dim); border: 1px solid rgba(224,85,85,0.2); }
.detail-icon.var-icon { background: var(--amber-dim); border: 1px solid rgba(212,168,67,0.2); }
.detail-title { font-family: 'Outfit', sans-serif; font-size: 1rem; font-weight: 600; color: var(--amber); line-height: 1.3; }
.detail-subtitle { font-family: 'Outfit', sans-serif; font-size: 0.78rem; font-weight: 500; color: var(--text-secondary); margin-top: 3px; }
.detail-section { margin-bottom: 20px; }
.detail-section-title { font-family: 'Outfit', sans-serif; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); margin-bottom: 8px; padding-bottom: 4px; border-bottom: 1px solid rgba(255,255,255,0.03); }
.detail-body { font-size: 0.88rem; color: var(--text-primary); line-height: 1.8; }
.detail-body .var-hl { color: var(--amber); font-family: 'Outfit', sans-serif; font-weight: 600; }
.detail-calc { background: rgba(255,255,255,0.03); border: 1px solid var(--border); border-radius: 6px; padding: 14px 16px; font-family: 'JetBrains Mono', monospace; font-size: 0.78rem; color: var(--text-secondary); line-height: 1.9; }
.detail-calc .calc-result { color: var(--amber); font-weight: 500; }

/* ── LOOPS ── */
.loops-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.loop-item { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; cursor: pointer; transition: all 0.25s; }
.loop-item:hover, .loop-item.expanded { background: var(--bg-card-hover); border-color: var(--border-active); }
.loop-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.loop-name { font-family: 'Outfit', sans-serif; font-size: 0.78rem; font-weight: 500; color: var(--text-secondary); flex: 1; }
.loop-status { font-family: 'Outfit', sans-serif; font-size: 0.6rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; padding: 3px 8px; border-radius: 4px; white-space: nowrap; }
.loop-status.active { background: var(--red-dim); color: var(--red); border: 1px solid rgba(224,85,85,0.2); }
.loop-status.inactive { background: rgba(255,255,255,0.03); color: var(--text-dim); border: 1px solid var(--border); }
.loop-status.weak, .loop-status.latent { background: var(--orange-dim); color: var(--orange); border: 1px solid rgba(224,138,69,0.2); }
.loop-chevron { color: var(--text-dim); font-size: 0.7rem; transition: transform 0.3s; }
.loop-item.expanded .loop-chevron { transform: rotate(180deg); }
.loop-detail { max-height: 0; overflow: hidden; transition: max-height 0.35s ease; font-size: 0.75rem; color: var(--text-dim); line-height: 1.6; }
.loop-item.expanded .loop-detail { max-height: 200px; padding-top: 10px; }

/* ── FINDING ── */
.finding-card { background: linear-gradient(135deg, rgba(224,85,85,0.06), rgba(212,168,67,0.04)); border: 1px solid rgba(224,85,85,0.15); padding: 24px; }
.finding-content { display: flex; gap: 20px; align-items: flex-start; }
.finding-icon-lg { width: 40px; height: 40px; border-radius: 8px; background: var(--red-dim); border: 1px solid rgba(224,85,85,0.2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 1.1rem; }
.finding-text h3 { font-family: 'Outfit', sans-serif; font-size: 1.05rem; font-weight: 600; color: var(--amber); margin-bottom: 10px; line-height: 1.4; }
.finding-text p { font-size: 0.9rem; color: var(--text-primary); line-height: 1.85; }
.finding-card--secondary { background: var(--bg-card); border: 1px solid var(--border); padding: 16px 20px; }
.finding-card--secondary .finding-icon-lg { width: 32px; height: 32px; font-size: 0.85rem; }
.finding-card--secondary .finding-text h3 { font-size: 0.88rem; margin-bottom: 6px; }
.finding-card--secondary .finding-text p { font-size: 0.82rem; line-height: 1.7; color: var(--text-secondary); }
.section-label { font-family: 'Outfit', sans-serif; font-size: 0.7rem; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.12em; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.section-label .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--amber); }

/* ── WARNING CARDS ── */
.warning-card { background: var(--red-dim); border: 1px solid rgba(224,85,85,0.2); border-radius: 8px; padding: 14px 18px; margin-bottom: 20px; display: flex; align-items: flex-start; gap: 12px; }
.warning-card .warning-icon { font-size: 1.1rem; flex-shrink: 0; }
.warning-card .warning-text { font-size: 0.8rem; color: var(--red); line-height: 1.6; }
.warning-card .warning-text strong { color: var(--text-primary); }

/* ── ANIMATIONS ── */
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.animate-in { opacity: 0; animation: fadeUp 0.6s ease forwards; }
.delay-1 { animation-delay: 0.1s; } .delay-2 { animation-delay: 0.2s; } .delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; } .delay-5 { animation-delay: 0.5s; } .delay-6 { animation-delay: 0.6s; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }

/* ── RESPONSIVE ── */
@media (max-width: 1200px) { .grid-main { grid-template-columns: 280px 1fr 300px; } }
@media (max-width: 1000px) { .grid-main { grid-template-columns: 1fr; } .loops-grid { grid-template-columns: repeat(2, 1fr); } .params-row { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px) {
  .dashboard { padding: 16px; }
  .header { flex-direction: column; gap: 16px; }
  .header-right { align-items: flex-start; }
  .params-row { grid-template-columns: repeat(2, 1fr); }
  .loops-grid { grid-template-columns: 1fr; }
  .finding-content { flex-direction: column; }
  .tab-bar { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tab-bar::-webkit-scrollbar { display: none; }
  .tab-btn { padding: 8px 12px; font-size: 0.68rem; white-space: nowrap; flex-shrink: 0; }
  .tab-btn.disabled { display: none; }
  .tab-brand { padding: 6px 10px 8px 0; margin-right: 6px; }
  .tab-back { padding: 4px 10px; font-size: 0.68rem; }
}
