:root {
  --bg: #0a0c12;
  --card: #12182a;
  --gold: #d4af37;
  --text: #e8eaf2;
  --muted: #8b90a5;
  --bull: #2ecc71;
  --bear: #e74c3c;
  --danger: #c0392b;
  --sidebar-w: 220px;
  --topbar-h: auto;
}
body.theme-light {
  --bg: #f0f2f8;
  --card: #ffffff;
  --text: #1a2030;
  --muted: #5a6278;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: Inter, system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

.dash-app { display: flex; min-height: 100vh; }

/* Sidebar */
.dash-sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: #0e1220;
  border-right: 1px solid rgba(212,175,55,.12); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; z-index: 50;
}
body.theme-light .dash-sidebar { background: #e8eaf2; border-color: #ccc; }
.dash-sidebar-brand { padding: 0.85rem 0.65rem; border-bottom: 1px solid rgba(212,175,55,.1); }
.dash-sidebar-brand a {
  display: inline-flex; align-items: center; font-size: 0; line-height: 0;
  color: transparent; text-decoration: none;
}
.dash-sidebar-brand a:hover { text-decoration: none; opacity: 0.95; }
.dash-sidebar-brand .logo-img {
  width: 100%;
  max-width: 100%;
  max-height: 56px;
  height: auto;
  -webkit-mask-image: url('../assets/aura-logo-frame-mask.svg');
  mask-image: url('../assets/aura-logo-frame-mask.svg');
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}
.dash-nav { list-style: none; padding: .75rem 0; flex: 1; overflow-y: auto; }
.dash-nav li button {
  width: 100%; text-align: left; padding: .65rem 1rem; background: transparent; border: none;
  color: var(--muted); font-size: .85rem; cursor: pointer; border-left: 3px solid transparent;
}
.dash-nav li button:hover { color: var(--text); background: rgba(212,175,55,.06); }
.dash-nav li button.active { color: var(--gold); border-left-color: var(--gold); background: rgba(212,175,55,.08); font-weight: 600; }
.dash-sidebar-foot { padding: .75rem 1rem; border-top: 1px solid rgba(255,255,255,.06); font-size: .72rem; color: var(--muted); }
.dash-sidebar-foot a { display: block; margin: .25rem 0; }

/* Main */
.dash-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* Top bar */
.dash-topbar {
  padding: .75rem 1.25rem; background: #0e1220;
  border-bottom: 1px solid rgba(212,175,55,.12);
}
body.theme-light .dash-topbar { background: #fff; }
.dash-topbar-row { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; justify-content: space-between; }
.dash-topbar-title { font-size: 1rem; font-weight: 600; }
.dash-topbar-title span { color: var(--gold); }
.dash-topbar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.dash-ticker {
  display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; font-size: .78rem; font-weight: 600;
  padding: .5rem 0; border-bottom: 1px solid rgba(255,255,255,.05); margin-bottom: .65rem;
}
.dash-ticker-item .lbl { color: var(--muted); font-weight: 400; margin-right: .25rem; }
.dash-ticker-item.up { color: var(--bull); }
.dash-ticker-item.down { color: var(--bear); }

.btn-dash {
  background: #1a2030; border: 1px solid rgba(212,175,55,.35); color: var(--gold);
  padding: .4rem .75rem; border-radius: 6px; font-size: .78rem; font-weight: 600; cursor: pointer;
}
.btn-dash:hover { opacity: .9; }
.btn-dash-primary { background: var(--gold); color: #0a0c12; border-color: var(--gold); }
.range-toggle { display: flex; gap: 2px; background: #1a2030; border-radius: 6px; padding: 2px; }
.range-toggle button {
  background: transparent; border: none; color: var(--muted); padding: .35rem .55rem;
  font-size: .72rem; border-radius: 4px; cursor: pointer;
}
.range-toggle button.active { background: var(--gold); color: #0a0c12; font-weight: 700; }

.user-chip {
  display: inline-flex; align-items: center; gap: .45rem; padding: .3rem .65rem;
  background: #1a2030; border-radius: 999px; font-size: .75rem; border: 1px solid #333;
}
.user-avatar {
  width: 26px; height: 26px; border-radius: 50%; background: var(--gold); color: #0a0c12;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .7rem;
}

.status-bar {
  display: flex; flex-wrap: wrap; gap: .35rem .65rem; margin-top: .5rem;
  padding: .35rem .75rem; border-radius: 6px;
  font-size: .75rem; font-weight: 600; background: #1a2030; border: 1px solid #444;
}
.status-line { white-space: nowrap; }
.status-bar.live { border-color: var(--bull); color: var(--bull); }
.status-bar.demo { border-color: var(--gold); color: var(--gold); }
.refresh-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--bull); margin-right: 4px; animation: blink 1.5s infinite; }
@keyframes blink { 50% { opacity: .3; } }

.edu-badge {
  display: inline-block; margin: .35rem 0; padding: .28rem .6rem; border-radius: 999px;
  font-size: .65rem; font-weight: 700; border: 1px solid rgba(212,175,55,.45);
  color: var(--gold); background: rgba(212,175,55,.08);
}

/* KPI row */
.kpi-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .65rem; margin: .75rem 0;
}
.kpi-card {
  background: var(--card); border: 1px solid rgba(212,175,55,.12); border-radius: 10px;
  padding: .75rem; text-align: center;
}
.kpi-card .kpi-label { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi-card .kpi-value { font-size: 1.15rem; font-weight: 700; color: var(--gold); margin-top: .25rem; }
.kpi-card .kpi-sub { font-size: .68rem; color: var(--muted); margin-top: .15rem; }
.kpi-card.ok .kpi-value { color: var(--bull); }
.kpi-card.warn .kpi-value { color: #e67e22; }
.kpi-card.err .kpi-value { color: var(--bear); }

/* Panels */
.dash-content { padding: 1rem 1.25rem 2rem; flex: 1; }
.dash-panel { display: none; }
.dash-panel.active { display: block; }
.grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem; max-width: 1280px;
}
.card { background: var(--card); border: 1px solid rgba(212,175,55,.12); border-radius: 14px; padding: 1rem; transition: border-color 0.25s ease; }
.lux-body .dash-content .card { background: linear-gradient(145deg, rgba(18,24,42,.95), rgba(12,16,26,.9)); }
.lux-body .kpi-card { background: linear-gradient(145deg, rgba(18,24,42,.95), rgba(12,16,26,.9)); }
.card h2 { font-size: .78rem; color: var(--gold); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .75rem; }
.card-wide { grid-column: 1 / -1; }
.chart-wrap { position: relative; height: 220px; margin-top: .5rem; }

.prob-bars .prob-row { display: flex; align-items: center; gap: .5rem; margin: .4rem 0; font-size: .85rem; }
.bar { flex: 1; height: 10px; background: #0a0e16; border-radius: 5px; overflow: hidden; }
body.theme-light .bar { background: #ddd; }
.fill { height: 100%; transition: width .4s; }
.fill.bull { background: var(--bull); }
.fill.bear { background: var(--bear); }
.grade { margin-top: .75rem; font-weight: 600; font-size: .88rem; }
.sentiment { color: var(--muted); font-size: .88rem; }
.checklist { list-style: none; }
.checklist li { padding: .35rem 0; font-size: .88rem; }
.checklist li.pass::before { content: "☑ "; color: var(--bull); }
.checklist li.fail::before { content: "☐ "; color: var(--bear); }
.check-result { margin-top: .5rem; font-weight: 600; }
.session-active { font-size: 1.15rem; color: var(--gold); }
.muted { color: var(--muted); font-size: .8rem; }
.stats { list-style: none; font-size: .9rem; }
.stats li { margin: .4rem 0; display: flex; justify-content: space-between; }
.feed-list { list-style: none; max-height: 220px; overflow-y: auto; font-size: .82rem; }
.feed-list li { padding: .5rem 0; border-bottom: 1px solid rgba(255,255,255,.06); }
.risk-tag { color: var(--danger); font-weight: 600; font-size: .7rem; }

.event-log { list-style: none; max-height: 280px; overflow-y: auto; font-size: .8rem; }
.event-log li { padding: .45rem .5rem; border-bottom: 1px solid rgba(255,255,255,.06); display: flex; gap: .5rem; align-items: flex-start; }
.event-log .ev-time { color: var(--muted); font-size: .7rem; white-space: nowrap; min-width: 52px; }
.event-log .ev-msg { flex: 1; }
.event-log .ev-level { font-size: .65rem; font-weight: 700; padding: .1rem .35rem; border-radius: 4px; text-transform: uppercase; }
.event-log .ev-info .ev-level { background: rgba(93,173,226,.2); color: #5dade2; }
.event-log .ev-warn .ev-level { background: rgba(230,126,34,.2); color: #e67e22; }
.event-log .ev-error .ev-level { background: rgba(231,76,60,.2); color: var(--bear); }

.health-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .5rem; }
.health-item { padding: .5rem .65rem; border-radius: 8px; font-size: .78rem; border: 1px solid #333; display: flex; justify-content: space-between; align-items: center; }
.health-item.ok { border-color: rgba(46,204,113,.4); color: var(--bull); }
.health-item.fail { border-color: rgba(231,76,60,.4); color: var(--bear); }

#journalForm {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .5rem; margin-bottom: 1rem;
}
#journalForm input, #journalForm select {
  padding: .45rem; background: #080c14; border: 1px solid #333; color: var(--text); border-radius: 6px;
}
body.theme-light #journalForm input, body.theme-light #journalForm select { background: #fff; border-color: #ccc; }
.btn-primary {
  background: var(--gold); color: #0a0c12; border: none; padding: .55rem;
  border-radius: 8px; font-weight: 600; cursor: pointer; grid-column: 1 / -1;
}
.insights { background: #080c14; padding: .75rem; border-radius: 8px; font-size: .82rem; margin-bottom: .75rem; line-height: 1.5; }
body.theme-light .insights { background: #f5f5f5; }
.journal-list { list-style: none; max-height: 200px; overflow-y: auto; font-size: .82rem; }
.journal-list li { padding: .5rem 0; border-bottom: 1px solid rgba(255,255,255,.06); }
#chartCanvas { max-width: 100%; margin-top: .75rem; border: 1px solid #333; border-radius: 8px; background: #000; }
.analysis-out { margin-top: .75rem; font-size: .8rem; white-space: pre-wrap; background: #080c14; padding: .75rem; border-radius: 8px; line-height: 1.5; }
.upload-label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: .35rem; }

.crash-banner {
  background: var(--danger); color: #fff; padding: .6rem 1rem; border-radius: 8px;
  margin-top: .65rem; font-weight: 700;
}
.crash-banner.hidden { display: none; }
.disclaimer { font-size: .7rem; color: var(--gold); margin-top: .45rem; line-height: 1.4; }
.sync-badge { font-size: .68rem; color: var(--bull); margin-left: .5rem; }
.sync-badge.local { color: var(--muted); }

.settings-block { margin-bottom: 1.25rem; }
.settings-block h3 { font-size: .85rem; color: var(--gold); margin-bottom: .5rem; }
.settings-block input[type=email] {
  width: 100%; max-width: 320px; padding: .5rem; background: #080c14; border: 1px solid #333;
  color: var(--text); border-radius: 6px; margin-right: .5rem;
}

.footer-mini { text-align: center; padding: 1rem; color: var(--muted); font-size: .72rem; border-top: 1px solid rgba(255,255,255,.06); }
.footer-mini a { color: var(--gold); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.sidebar-toggle { display: none; }

@media (max-width: 768px) {
  .dash-sidebar {
    position: fixed; left: 0; top: 0; transform: translateX(-100%);
    transition: transform .2s; box-shadow: 4px 0 24px rgba(0,0,0,.4);
  }
  .dash-sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: inline-flex; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
}

.inst-mount { grid-column: 1 / -1; }
