:root {
  --bg: #0b1120;
  --bg-sidebar: #070b14;
  --surface: #0c1425;
  --card: #111a2e;
  --card-alt: #162138;
  --border: #23314d;
  --border-soft: #1a263e;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --faint: #64748b;
  --gold: #c8a253;
  --gold-bright: #e0be70;
  --gold-light: #f0d898;
  --gold-soft: rgba(200, 162, 83, 0.14);
  --accent: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --sky: #38bdf8;
  --radius: 14px;
}

html.light-theme {
  --bg: #f4f6fa;
  --bg-sidebar: #0f172a;
  --surface: #f8fafc;
  --card: #ffffff;
  --card-alt: #f1f5f9;
  --border: #dbe2ec;
  --border-soft: #e2e8f0;
  --text: #0f172a;
  --muted: #475569;
  --faint: #64748b;
  --gold: #b08935;
  --gold-bright: #c8a253;
  --gold-light: #8a6518;
  --gold-soft: rgba(176, 137, 53, 0.12);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  display: flex;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.font-editorial { font-family: Georgia, Cambria, "Times New Roman", serif; }
.font-mono { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace; }

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #2b3b5c; border-radius: 9999px; }

/* === SHELL & SIDEBAR === */
.app-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(2px);
  z-index: 40;
}
.app-backdrop.open { display: block; }

.app-sidebar {
  width: 292px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  color: #f1f5f9;
  border-right: 1px solid rgba(35, 49, 77, 0.9);
  display: flex;
  flex-direction: column;
  height: 100vh;
  z-index: 50;
  transition: transform 0.22s ease;
}

@media (max-width: 1024px) {
  .app-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
  }
  .app-sidebar.open { transform: translateX(0); }
}

.sidebar-brand {
  padding: 16px 18px;
  border-bottom: 1px solid rgba(30, 41, 59, 0.9);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand-shield-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #e0be70, #c8a253, #8a6a24);
  color: #070b14;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(200, 162, 83, 0.25);
  flex-shrink: 0;
}

.sidebar-status-box {
  margin: 12px 14px 6px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #0e1628;
  border: 1px solid rgba(16, 185, 129, 0.32);
  font-size: 0.72rem;
  color: #94a3b8;
}

.sidebar-search-wrap { padding: 4px 14px 8px; }
.sidebar-search-wrap input {
  width: 100%;
  min-height: 36px;
  padding: 6px 11px;
  font-size: 0.78rem;
  border-radius: 10px;
  background: #0c1425;
  border: 1px solid #23314d;
  color: #f1f5f9;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sidebar-section-label {
  padding: 10px 10px 3px;
  font-size: 0.64rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #64748b;
}
.sidebar-section-label.gold { color: #e0be70; }

.tab-btn {
  width: 100%;
  min-height: 44px;
  padding: 8px 11px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: #cbd5e1;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: all 0.15s ease;
  text-decoration: none;
}
.tab-btn:hover { background: rgba(255, 255, 255, 0.04); border-color: rgba(200, 162, 83, 0.25); color: #fff; }
.tab-btn.active {
  background: rgba(200, 162, 83, 0.16);
  border-color: rgba(200, 162, 83, 0.55);
  color: #f0d898;
  box-shadow: inset 3px 0 0 #c8a253;
}

.nav-pill {
  font-size: 0.62rem;
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(148, 163, 184, 0.14);
  color: #94a3b8;
  flex-shrink: 0;
}
.tab-btn.active .nav-pill { background: rgba(200, 162, 83, 0.28); color: #f0d898; }

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid rgba(30, 41, 59, 0.9);
  background: #050810;
  font-size: 0.68rem;
  color: #64748b;
}

/* === MAIN & TOPBAR === */
.app-main-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 10px 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  z-index: 20;
}
.topbar-left, .topbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.hamburger-btn {
  display: none;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
}
@media (max-width: 1024px) {
  .hamburger-btn { display: inline-flex; align-items: center; }
}

.badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold-bright);
  border: 1px solid rgba(200, 162, 83, 0.4);
  white-space: nowrap;
}
.badge-green { background: rgba(16, 185, 129, 0.14); color: #6ee7b7; border-color: rgba(16, 185, 129, 0.4); }
html.light-theme .badge-green { color: #047857; }
.badge-warn { background: rgba(245, 158, 11, 0.16); color: #fcd34d; border-color: rgba(245, 158, 11, 0.42); }
html.light-theme .badge-warn { color: #b45309; }

.pill-btn {
  min-height: 34px;
  padding: 6px 11px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
  text-decoration: none;
}
.pill-btn:hover { border-color: var(--gold); }
.pill-btn-gold { background: linear-gradient(90deg, #e0be70, #c8a253); color: #070b14; border: none; font-weight: 800; }

.main-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
}
@media (max-width: 640px) {
  .main-scroll { padding: 10px; }
}

.container { max-width: 1240px; margin: 0 auto; width: 100%; }

.panel {
  display: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 18px 42px rgba(2, 6, 23, 0.25);
  animation: fadeSlide 0.2s ease-out;
  max-width: 100%;
  overflow-x: hidden;
}
.panel.active { display: block; }
@media (max-width: 640px) {
  .panel { padding: 14px; border-radius: 14px; }
}
.panel > h2 {
  margin-top: 0;
  font-family: Georgia, Cambria, "Times New Roman", serif;
  font-size: 1.35rem;
  color: var(--text);
}

/* === MODULE GUIDE & KPI === */
.module-guide-card {
  margin: 10px 0 16px;
  padding: 14px 16px;
  border-radius: 14px;
  background: radial-gradient(circle at 92% 15%, rgba(200, 162, 83, 0.14), transparent 50%), var(--card-alt);
  border: 1px solid rgba(200, 162, 83, 0.35);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.module-guide-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.module-guide-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; font-size: 0.78rem; color: var(--muted); }
.module-guide-step { padding: 8px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border-soft); }
.module-guide-step strong { color: var(--gold-bright); }
html.light-theme .module-guide-step strong { color: #9a6e17; }
.module-guide-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 10px; margin-top: 14px; }
.kpi-card { padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.kpi-card.gold { border-color: rgba(200, 162, 83, 0.55); background: var(--gold-soft); }
.kpi-card.green { border-color: rgba(16, 185, 129, 0.45); background: rgba(16, 185, 129, 0.09); }
.kpi-card.red { border-color: rgba(239, 68, 68, 0.45); background: rgba(239, 68, 68, 0.09); }
.kpi-card.warn { border-color: rgba(245, 158, 11, 0.45); background: rgba(245, 158, 11, 0.09); }
.kpi-lbl { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.kpi-val { font-size: 1.12rem; font-weight: 800; font-family: "JetBrains Mono", monospace; color: var(--text); margin-top: 4px; word-break: break-word; }
.kpi-card.gold .kpi-val { color: var(--gold-light); }
.kpi-card.green .kpi-val { color: #34d399; }
.kpi-card.red .kpi-val { color: #fb7185; }
.kpi-card.warn .kpi-val { color: #fbbf24; }
html.light-theme .kpi-card.green .kpi-val { color: #059669; }
html.light-theme .kpi-card.red .kpi-val { color: #dc2626; }
html.light-theme .kpi-card.warn .kpi-val { color: #b45309; }

/* === CAD SVG STAGE & GAUGES === */
.cad-stage {
  border-radius: 14px;
  border: 1px solid rgba(200, 162, 83, 0.4);
  background:
    linear-gradient(to right, rgba(56, 189, 248, 0.07) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(56, 189, 248, 0.07) 1px, transparent 1px),
    #070d1b;
  background-size: 20px 20px;
  padding: 14px;
  color: #f1f5f9;
  margin-bottom: 14px;
}
.cad-stage svg { width: 100%; height: auto; display: block; }

.gauge-track {
  width: 100%;
  height: 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
  margin: 8px 0;
}
.gauge-fill { height: 100%; border-radius: 999px; transition: width 0.35s ease; }

/* === INVESTOR PRIVACY SHIELD === */
body.investor-privacy .secret-field {
  filter: blur(7px);
  user-select: none;
  pointer-events: none;
}

/* === FORMS & VERDICTS === */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 0.84rem; font-weight: 600; color: var(--muted); }
input, select, textarea {
  min-height: 42px; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 0.92rem; max-width: 100%; width: 100%;
}
input[type="range"] { padding: 0; min-height: 28px; accent-color: var(--gold); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 2px rgba(200, 162, 83, 0.2); }
.checkbox-row { flex-direction: row; align-items: center; gap: 10px; color: var(--text); margin: 6px 0; cursor: pointer; }
.checkbox-row input[type="checkbox"] { min-height: 20px; width: 20px; flex-shrink: 0; accent-color: var(--gold); }

.btn {
  min-height: 42px; padding: 9px 16px; border-radius: 10px;
  border: 1px solid rgba(200, 162, 83, 0.45);
  background: linear-gradient(90deg, #e0be70, #c8a253);
  color: #070b14; font-weight: 800; font-size: 0.86rem; cursor: pointer;
}
.btn:hover { filter: brightness(1.06); }
.btn-secondary { background: var(--card-alt); border: 1px solid var(--border); color: var(--text); font-weight: 700; }
.btn-secondary:hover { border-color: var(--gold); }
.btn-accent { background: linear-gradient(90deg, #10b981, #059669); border-color: rgba(16, 185, 129, 0.5); color: #fff; }
.btn-danger { background: rgba(239, 68, 68, 0.16); border: 1px solid rgba(239, 68, 68, 0.5); color: #fecaca; }
html.light-theme .btn-danger { color: #991b1b; }

.subcard { margin-top: 14px; padding: 16px; border-radius: 14px; border: 1px solid var(--border); background: var(--card-alt); }
.subcard h3 { margin: 0 0 10px; font-size: 1rem; font-weight: 700; color: var(--text); }
.result-box {
  margin-top: 12px; padding: 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
  white-space: pre-wrap; word-break: break-word; font-size: 0.87rem; color: var(--text);
}
.verdict-card { margin-top: 14px; padding: 15px; border-radius: 12px; border: 1px solid var(--border); border-left-width: 6px; background: var(--surface); }
.verdict-RED { border-left-color: var(--danger); background: rgba(127, 29, 29, 0.22); }
.verdict-YELLOW { border-left-color: var(--warn); background: rgba(120, 53, 15, 0.2); }
.verdict-GREEN { border-left-color: var(--accent); background: rgba(6, 78, 59, 0.22); }
html.light-theme .verdict-GREEN { background: rgba(16, 185, 129, 0.1); }
html.light-theme .verdict-RED { background: rgba(239, 68, 68, 0.1); }
html.light-theme .verdict-YELLOW { background: rgba(245, 158, 11, 0.1); }

.chip-bar { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip-btn {
  padding: 5px 11px; border-radius: 999px; border: 1px solid rgba(200, 162, 83, 0.45);
  background: var(--gold-soft); color: var(--gold-light); font-size: 0.78rem; font-weight: 600; cursor: pointer;
}
html.light-theme .chip-btn { color: #7c580f; }

.table-wrap { width: 100%; overflow-x: auto; margin-top: 10px; }
table.data-tbl { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
table.data-tbl th, table.data-tbl td {
  padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left;
}
table.data-tbl th { color: var(--gold-bright); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; }

/* === CINEMA, TOUR, AI ASSISTANT, MODALS === */
.academy-stage {
  border-radius: 16px; border: 1px solid rgba(200, 162, 83, 0.45);
  background: radial-gradient(circle at 18% 20%, rgba(200, 162, 83, 0.14), transparent 48%), #070b14;
  color: #f1f5f9; padding: 20px; min-height: 290px;
}
.academy-chapters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 14px; }
.academy-chap-btn { padding: 9px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); text-align: left; cursor: pointer; }
.academy-chap-btn.active { background: var(--gold-soft); border-color: var(--gold); color: var(--text); }

.ai-fab {
  position: fixed; bottom: 18px; right: 18px; z-index: 45;
  display: inline-flex; align-items: center; gap: 8px; padding: 12px 16px;
  border-radius: 16px; background: linear-gradient(135deg, #0f172a, #162033);
  border: 2px solid #c8a253; color: #fff; font-size: 0.8rem; font-weight: 800;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45); cursor: pointer;
}
.ai-drawer {
  position: fixed; top: 0; bottom: 0; right: 0; z-index: 60; width: 440px; max-width: 100vw;
  background: #070b14; color: #f1f5f9; border-left: 1px solid rgba(200, 162, 83, 0.45);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.55); display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform 0.22s ease;
}
.ai-drawer.open { transform: translateX(0); }

.tour-overlay {
  display: none; position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 70; width: 94vw; max-width: 540px; background: #070b14; color: #f1f5f9;
  border: 2px solid #c8a253; border-radius: 18px; padding: 16px; box-shadow: 0 24px 50px rgba(0, 0, 0, 0.65);
}
.tour-overlay.open { display: block; }
.tour-highlight {
  position: relative !important; z-index: 55 !important;
  box-shadow: 0 0 0 4px #c8a253, 0 0 32px rgba(200, 162, 83, 0.7) !important;
  border-radius: 14px !important;
}

.modal-backdrop { position: fixed; inset: 0; background: rgba(2, 6, 23, 0.82); display: none; align-items: center; justify-content: center; padding: 16px; z-index: 65; }
.modal-backdrop.open { display: flex; }
.modal-card { width: 100%; max-width: 660px; max-height: 90vh; overflow-y: auto; background: var(--card); border: 1px solid rgba(200, 162, 83, 0.45); border-radius: 16px; padding: 20px; }

.toast-wrap { position: fixed; bottom: 76px; right: 18px; z-index: 75; display: flex; flex-direction: column; gap: 8px; max-width: 340px; pointer-events: none; }
.toast-item { pointer-events: auto; background: #0f172a; color: #f8fafc; border: 1px solid #334155; border-left: 4px solid #c8a253; border-radius: 12px; padding: 10px 14px; font-size: 0.78rem; box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45); }
.ai-act-footer { margin-top: 20px; padding: 14px 16px; border-left: 4px solid var(--gold); background: var(--card); border: 1px solid var(--border); border-radius: 12px; font-size: 0.8rem; color: var(--muted); }
.pulse-dot { width: 8px; height: 8px; border-radius: 999px; background: #34d399; display: inline-block; animation: pulseDot 2s infinite; }
@keyframes pulseDot { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes fadeSlide { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
