/* Risk Narrative Engine — Dark Ops Theme */
/* MOPS-SPEC-RNE-001 */

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

:root {
  --bg:        #0a0e17;
  --surface:   #131a2b;
  --surface2:  #1a2236;
  --border:    #1e2a3a;
  --border2:   #263347;
  --text:      #e0e6ed;
  --text2:     #8892a0;
  --text3:     #5a6780;
  --accent:    #4A90D9;
  --accent2:   #2d6aad;
  --gold:      #C5A55A;
  --teal:      #14B8A6;
  --red:       #ef4444;
  --green:     #22c55e;
  --amber:     #f59e0b;
  --sidebar-w: 260px;
  --header-h:  52px;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; font-size: 13px; line-height: 1.5; }

/* ── Header ───────────────────────────────────────────────────────────── */
.header {
  position: fixed; top: 0; left: 0; right: 0; height: var(--header-h);
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; z-index: 100;
}
.header-brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { color: var(--accent); display: flex; align-items: center; }
.brand-name { font-weight: 700; font-size: 14px; color: var(--text); letter-spacing: 0.3px; }
.brand-sep { color: var(--border2); }
.brand-product { color: var(--accent); font-weight: 500; font-size: 13px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.classification-badge { background: rgba(74,144,217,0.12); border: 1px solid rgba(74,144,217,0.3); color: var(--accent); padding: 2px 8px; border-radius: 3px; font-size: 10px; font-weight: 700; letter-spacing: 1px; }
.header-version { color: var(--text3); font-size: 11px; }

/* ── Layout ───────────────────────────────────────────────────────────── */
.layout {
  display: flex;
  margin-top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.sidebar-section { flex: 1; overflow-y: auto; padding: 12px 0; }
.sidebar-title { padding: 6px 16px 8px; font-size: 10px; font-weight: 700; letter-spacing: 1.5px; color: var(--text3); text-transform: uppercase; }
.sidebar-footer { padding: 10px 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }

.assessment-list { display: flex; flex-direction: column; }
.assessment-item {
  padding: 10px 16px; cursor: pointer; border-left: 2px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}
.assessment-item:hover { background: var(--surface2); }
.assessment-item.active { background: rgba(74,144,217,0.08); border-left-color: var(--accent); }
.assessment-item-title { font-weight: 500; color: var(--text); font-size: 12px; line-height: 1.4; margin-bottom: 3px; }
.assessment-item-meta { font-size: 10px; color: var(--text3); }
.assessment-item-status { display: inline-block; padding: 1px 5px; border-radius: 2px; font-size: 9px; font-weight: 700; letter-spacing: 0.5px; margin-top: 3px; }
.status-DRAFT { background: rgba(88,102,126,0.3); color: var(--text2); }
.status-UNDER_REVIEW { background: rgba(245,158,11,0.15); color: var(--amber); }
.status-DECIDED { background: rgba(34,197,94,0.15); color: var(--green); }

/* ── Main Content ─────────────────────────────────────────────────────── */
.main { flex: 1; overflow-y: auto; padding: 24px; }

/* ── Welcome Screen ───────────────────────────────────────────────────── */
.welcome-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 60vh; text-align: center; gap: 16px; }
.welcome-icon { opacity: 0.5; }
.welcome-title { font-size: 24px; font-weight: 700; color: var(--text); }
.welcome-sub { color: var(--text2); font-size: 14px; }
.welcome-features { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 8px 0; }
.feature-chip { background: rgba(74,144,217,0.1); border: 1px solid rgba(74,144,217,0.25); color: var(--accent); padding: 4px 12px; border-radius: 20px; font-size: 11px; font-weight: 500; }
.welcome-hint { color: var(--text3); font-size: 12px; }

/* ── Assessment Header ────────────────────────────────────────────────── */
.assessment-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.assessment-header-left { display: flex; flex-direction: column; gap: 4px; }
.assessment-status-badge { display: inline-block; padding: 2px 8px; border-radius: 3px; font-size: 10px; font-weight: 700; letter-spacing: 1px; width: fit-content; }
.assessment-title { font-size: 20px; font-weight: 700; color: var(--text); line-height: 1.3; max-width: 700px; }
.assessment-meta { color: var(--text3); font-size: 11px; }
.confidence-indicator { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.confidence-label { font-size: 10px; color: var(--text3); letter-spacing: 0.5px; text-transform: uppercase; }
.confidence-value { font-size: 13px; font-weight: 700; }
.confidence-HIGH { color: var(--green); }
.confidence-MODERATE { color: var(--amber); }
.confidence-LOW { color: var(--red); }

/* ── Tab Nav ──────────────────────────────────────────────────────────── */
.tab-nav { display: flex; gap: 2px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.tab-btn {
  padding: 8px 16px; background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text2); cursor: pointer; font-size: 12px; font-weight: 500;
  transition: color 0.15s, border-color 0.15s; white-space: nowrap;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Panels ───────────────────────────────────────────────────────────── */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 16px; }
.panel-title { font-size: 10px; font-weight: 700; letter-spacing: 1.5px; color: var(--text3); text-transform: uppercase; margin-bottom: 12px; }
.panel-subtitle { font-weight: 400; color: var(--text3); letter-spacing: 0; text-transform: none; font-size: 11px; margin-left: 6px; }
.panel-grid { display: grid; gap: 16px; }
.two-col { grid-template-columns: 1fr 1fr; }
.panel-col { display: flex; flex-direction: column; gap: 16px; }

/* ── Narrative Text ───────────────────────────────────────────────────── */
.narrative-text { color: var(--text); line-height: 1.8; font-size: 13px; white-space: pre-line; }
.phia-highlight { border-radius: 3px; padding: 0 3px; font-weight: 600; font-size: 12px; }
.weasel-highlight { background: rgba(245,158,11,0.15); border-bottom: 1px dashed var(--amber); color: var(--amber); cursor: help; border-radius: 2px; padding: 0 2px; }

/* ── PHIA Summary ─────────────────────────────────────────────────────── */
.phia-summary { font-size: 12px; color: var(--text2); }
.phia-quality-bar { margin: 8px 0; }
.quality-label { display: flex; justify-content: space-between; margin-bottom: 4px; }
.quality-track { background: var(--border); border-radius: 4px; height: 6px; overflow: hidden; }
.quality-fill { height: 100%; border-radius: 4px; transition: width 0.4s; }
.quality-excellent { background: var(--green); }
.quality-acceptable { background: var(--teal); }
.quality-needs { background: var(--amber); }
.quality-poor { background: var(--red); }
.phia-term-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.phia-term-chip { padding: 2px 7px; border-radius: 3px; font-size: 10px; font-weight: 600; color: #fff; }

/* ── Confidence Cards ─────────────────────────────────────────────────── */
.confidence-cards { display: flex; flex-direction: column; gap: 8px; }
.confidence-card { background: var(--surface2); border: 1px solid var(--border); border-radius: 4px; padding: 10px 12px; }
.confidence-card-label { font-size: 9px; font-weight: 700; letter-spacing: 1px; color: var(--text3); text-transform: uppercase; margin-bottom: 4px; }
.confidence-card-text { font-size: 12px; color: var(--text2); line-height: 1.5; }

/* ── Projection Layout ────────────────────────────────────────────────── */
.projection-layout { display: grid; grid-template-columns: 1fr 280px; gap: 16px; align-items: start; }
.chart-area { display: flex; flex-direction: column; gap: 16px; }
.chart-panel { }
.cost-panel { }
.chart-wrapper { position: relative; height: 320px; }
.chart-wrapper-sm { height: 180px; }

/* ── Variable Controls ────────────────────────────────────────────────── */
.controls-panel { }
.control-group { margin-bottom: 14px; }
.control-label { display: block; font-size: 11px; color: var(--text2); margin-bottom: 6px; font-weight: 500; }
.slider-row { display: flex; align-items: center; gap: 10px; }
.slider { flex: 1; -webkit-appearance: none; appearance: none; height: 4px; background: var(--border2); border-radius: 4px; outline: none; cursor: pointer; }
.slider::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); cursor: pointer; box-shadow: 0 0 0 2px rgba(74,144,217,0.3); }
.slider::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); cursor: pointer; border: none; }
.slider-value { font-size: 11px; font-weight: 600; color: var(--text); min-width: 52px; text-align: right; }
.coa-controls { display: flex; flex-direction: column; gap: 12px; }
.coa-ctrl-group { background: var(--surface2); border: 1px solid var(--border); border-radius: 4px; padding: 10px; }
.coa-ctrl-title { font-size: 10px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.control-note { font-size: 10px; color: var(--text3); margin-top: 12px; font-style: italic; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 14px; }

/* ── COA Comparison Grid ──────────────────────────────────────────────── */
.coa-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.coa-card { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.coa-card.selected-for-decision { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.coa-card-title { font-size: 13px; font-weight: 700; color: var(--text); line-height: 1.4; }
.coa-card-desc { font-size: 12px; color: var(--text2); line-height: 1.6; }
.coa-cost { font-size: 18px; font-weight: 700; color: var(--text); }
.coa-cost-label { font-size: 10px; color: var(--text3); }
.coa-horizons { display: flex; flex-direction: column; gap: 5px; }
.horizon-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; border-bottom: 1px solid var(--border); }
.horizon-year { font-size: 11px; color: var(--text3); }
.horizon-band { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 3px; color: #fff; }
.horizon-prob { font-size: 11px; color: var(--text2); }
.coa-select-btn { margin-top: auto; }

/* ── Accountability / Decision Form ───────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 11px; color: var(--text2); margin-bottom: 5px; font-weight: 500; }
.required { color: var(--red); }
.form-hint { color: var(--text3); font-weight: 400; }
.form-input, .form-select, .form-textarea {
  width: 100%; background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 4px; color: var(--text); font-size: 12px; padding: 8px 10px;
  outline: none; transition: border-color 0.15s; font-family: inherit;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--accent); }
.form-select option { background: var(--surface2); }
.form-textarea { resize: vertical; line-height: 1.5; }
.phia-tool-textarea { min-height: 300px; }
.char-count { font-size: 10px; color: var(--text3); margin-top: 3px; text-align: right; }
.toggle-group { display: flex; gap: 4px; }
.toggle-btn { flex: 1; padding: 6px; background: var(--surface2); border: 1px solid var(--border2); border-radius: 4px; color: var(--text2); cursor: pointer; font-size: 11px; font-weight: 500; transition: all 0.15s; text-align: center; }
.toggle-btn:hover { border-color: var(--border); color: var(--text); }
.toggle-btn.active { background: rgba(74,144,217,0.15); border-color: var(--accent); color: var(--accent); }
.disregarded-list { display: flex; flex-direction: column; gap: 8px; }
.disregarded-item { background: var(--surface2); border: 1px solid var(--border); border-radius: 4px; padding: 8px 10px; }
.disregarded-item-title { font-size: 11px; font-weight: 600; color: var(--text2); margin-bottom: 4px; }
.btn-lock { width: 100%; margin-top: 8px; display: flex; align-items: center; justify-content: center; gap: 8px; }

/* ── Decision Record ──────────────────────────────────────────────────── */
.decision-record { }
.decision-locked-banner { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.3); border-radius: 4px; padding: 10px 14px; color: var(--green); font-size: 12px; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.decision-field { margin-bottom: 10px; }
.decision-field-label { font-size: 10px; color: var(--text3); letter-spacing: 0.5px; text-transform: uppercase; margin-bottom: 2px; }
.decision-field-value { font-size: 12px; color: var(--text); }

/* ── Audit Trail ──────────────────────────────────────────────────────── */
.audit-trail { display: flex; flex-direction: column; gap: 0; max-height: 600px; overflow-y: auto; }
.audit-entry { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.audit-entry:last-child { border-bottom: none; }
.audit-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border2); flex-shrink: 0; margin-top: 4px; }
.audit-dot-CREATED { background: var(--teal); }
.audit-dot-DECIDED { background: var(--green); }
.audit-dot-LOCKED { background: var(--red); }
.audit-dot-VARIABLE_CHANGED { background: var(--accent); }
.audit-dot-MODIFIED { background: var(--gold); }
.audit-dot-COA_ADDED { background: var(--text2); }
.audit-body { flex: 1; }
.audit-action { font-size: 11px; font-weight: 600; color: var(--text); }
.audit-detail { font-size: 10px; color: var(--text3); margin-top: 1px; }
.audit-time { font-size: 10px; color: var(--text3); white-space: nowrap; }

/* ── PHIA Tool Results ────────────────────────────────────────────────── */
.phia-tool-results { font-size: 12px; }
.phia-result-section { margin-bottom: 16px; }
.phia-result-title { font-size: 10px; font-weight: 700; letter-spacing: 1px; color: var(--text3); text-transform: uppercase; margin-bottom: 8px; }
.phia-result-item { background: var(--surface2); border: 1px solid var(--border); border-radius: 4px; padding: 8px 10px; margin-bottom: 6px; }
.phia-result-term { font-weight: 700; font-size: 12px; margin-bottom: 3px; }
.phia-result-context { color: var(--text2); font-size: 11px; line-height: 1.5; margin-bottom: 4px; }
.phia-result-suggestion { color: var(--amber); font-size: 11px; font-style: italic; }
.phia-score-big { font-size: 32px; font-weight: 800; margin-bottom: 4px; }
.phia-grade { font-size: 13px; font-weight: 600; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
button { cursor: pointer; font-family: inherit; }
.btn-accent { background: var(--accent); color: #fff; border: none; padding: 8px 16px; border-radius: 4px; font-size: 12px; font-weight: 600; transition: background 0.15s; }
.btn-accent:hover { background: var(--accent2); }
.btn-ghost { background: none; border: 1px solid var(--border2); color: var(--text2); padding: 6px 12px; border-radius: 4px; font-size: 11px; font-weight: 500; transition: all 0.15s; }
.btn-ghost:hover { border-color: var(--border); color: var(--text); }
.btn-danger { background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.3); color: var(--red); padding: 8px 16px; border-radius: 4px; font-size: 12px; font-weight: 600; transition: all 0.15s; }
.btn-danger:hover { background: rgba(239,68,68,0.2); }
.btn-sm { font-size: 11px; padding: 5px 10px; }
.btn-outline { background: none; border: 1px solid var(--border2); color: var(--text2); padding: 6px 12px; border-radius: 4px; font-size: 11px; font-weight: 500; transition: all 0.15s; }
.btn-outline.active, .btn-outline:hover { border-color: var(--accent); color: var(--accent); }

/* ── Modal ────────────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center; z-index: 200; }
.modal { background: var(--surface); border: 1px solid var(--border2); border-radius: 8px; padding: 20px; width: 480px; max-width: 95vw; max-height: 90vh; overflow-y: auto; }
.modal-sm { width: 360px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-title { font-size: 15px; font-weight: 700; color: var(--text); }
.modal-close { background: none; border: none; color: var(--text3); font-size: 20px; cursor: pointer; padding: 0 4px; }
.modal-body { font-size: 13px; color: var(--text2); margin-bottom: 16px; line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ── Misc ─────────────────────────────────────────────────────────────── */
.loading-state { padding: 16px; color: var(--text3); font-size: 12px; text-align: center; }
.empty-state { color: var(--text3); font-size: 12px; text-align: center; padding: 24px; }
.divider { height: 1px; background: var(--border); margin: 12px 0; }

/* ── Scrollbar ────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
  .projection-layout { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  :root { --sidebar-w: 200px; }
  .main { padding: 16px; }
}
