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

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: #000; }
::-webkit-scrollbar-thumb { background: #1e293b; border-radius: 2px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #000;
  color: #e2e8f0;
  min-height: 100vh;
  font-size: 15px;
}

/* ── Page shell ── */
.page { display: flex; flex-direction: column; height: 100vh; }

/* ── Header ── */
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.55rem 1.2rem;
  border-bottom: 1px solid #1e293b;
  background: #000;
  flex-shrink: 0;
  gap: 1rem;
}
.header-left  { display: flex; align-items: center; gap: 0.75rem; }
.header-right { display: flex; align-items: center; gap: 0.6rem; }

.logo { font-size: 0.92rem; font-weight: 700; color: #fff; font-family: monospace; letter-spacing: 0.1em; }

.mode-pill {
  font-family: monospace; font-size: 0.92rem; padding: 2px 8px; border-radius: 20px;
  background: #052e16; border: 1px solid #166534; color: #4ade80;
}

.header-date { font-family: monospace; font-size: 0.92rem; color: #334155; }

.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.dot.live { background: #4ade80; box-shadow: 0 0 4px #4ade80; }

/* ── User (header) ── */
.user-avatar {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  background: rgba(74,222,128,0.1); border: 1px solid rgba(74,222,128,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 600; color: #4ade80; font-family: monospace;
}
.user-email {
  color: #475569; font-size: 0.95rem; font-family: monospace;
  max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.super-badge {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.05em;
  background: #052e16; color: #4ade80; border: 1px solid #166534;
  border-radius: 20px; padding: 1px 6px; text-transform: uppercase; font-family: monospace;
}
.readonly-badge {
  font-size: 0.68rem; font-weight: 700;
  background: #0f172a; color: #475569; border: 1px solid #1e293b;
  border-radius: 20px; padding: 1px 6px; text-transform: uppercase; font-family: monospace;
}
.auth-btn {
  font-family: monospace; font-size: 0.92rem; padding: 3px 10px; border-radius: 4px;
  border: 1px solid #334155; background: #0f172a; color: #94a3b8;
  cursor: pointer; transition: all 0.1s;
}
.auth-btn:hover { border-color: #475569; color: #e2e8f0; }
.auth-btn.signin { background: #052e16; border-color: #166534; color: #4ade80; }
.auth-btn.signin:hover { background: #064e23; }

/* ── Nav tabs ── */
.nav {
  display: flex;
  padding: 0 1.2rem;
  border-bottom: 1px solid #1e293b;
  background: #000;
  flex-shrink: 0;
}
.nav-item {
  font-family: monospace; font-size: 0.92rem; padding: 0.45rem 1rem;
  color: #475569; background: none; border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer; letter-spacing: 0.1em; text-transform: uppercase;
  transition: color 0.1s; user-select: none;
}
.nav-item:hover { color: #94a3b8; }
.nav-item.active { color: #e2e8f0; border-bottom-color: #3b82f6; }
.nav-link { text-decoration: none; }
.nav-divider { width: 1px; height: 20px; background: #1e293b; margin: 0 0.5rem; align-self: center; }

/* ── Main content ── */
.main { flex: 1; overflow-y: auto; padding: 1rem 1.2rem; }

/* ── Section header row ── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.75rem;
}
.section-title { font-family: monospace; font-size: 0.95rem; color: #475569; text-transform: uppercase; letter-spacing: 0.08em; }

/* ── Buttons ── */
.btn {
  font-family: monospace; font-size: 0.92rem; padding: 3px 10px; border-radius: 4px;
  border: 1px solid #334155; background: #0f172a; color: #94a3b8;
  cursor: pointer; transition: all 0.1s; display: inline-flex; align-items: center; gap: 4px;
}
.btn:hover { border-color: #475569; color: #e2e8f0; }
.btn-primary { background: #052e16; border-color: #166534; color: #4ade80; }
.btn-primary:hover { background: #064e23; border-color: #16a34a; }
.btn-ghost { background: transparent; border-color: #1e293b; color: #475569; }
.btn-ghost:hover { border-color: #334155; color: #94a3b8; }
.btn-sm { padding: 2px 8px; font-size: 0.75rem; }

/* ── KPI grid ── */
.kpi-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 0.6rem; margin-bottom: 0.75rem; }
.kpi-card {
  background: #050810; border: 1px solid #1e293b; border-radius: 6px; padding: 0.65rem 0.85rem;
}
.kpi-label { font-family: monospace; font-size: 0.95rem; color: #475569; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.3rem; }
.kpi-value { font-family: monospace; font-size: 1.3rem; font-weight: 700; color: #e2e8f0; line-height: 1; margin-bottom: 0.2rem; }
.kpi-meta  { font-family: monospace; font-size: 0.98rem; color: #334155; }
.kpi-card.em .kpi-value { color: #4ade80; }
.kpi-card.bl .kpi-value { color: #60a5fa; }
.kpi-card.am .kpi-value { color: #fbbf24; }
.kpi-card.cy .kpi-value { color: #22d3ee; }
.kpi-card.pu .kpi-value { color: #a78bfa; }

/* ── Panels (cards) ── */
.card {
  background: #050810; border: 1px solid #1e293b; border-radius: 6px;
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.4rem 0.75rem; border-bottom: 1px solid #1e293b; flex-shrink: 0;
}
.card-title { font-family: monospace; font-size: 0.92rem; color: #475569; text-transform: uppercase; letter-spacing: 0.08em; }
.card-body { padding: 0.75rem; }

/* ── Grids ── */
.two-col   { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin-bottom: 0.6rem; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.6rem; margin-bottom: 0.6rem; }
.col-2-1   { display: grid; grid-template-columns: 2fr 1fr; gap: 0.6rem; margin-bottom: 0.6rem; }
.mb16 { margin-bottom: 0.6rem; }

/* ── Table ── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; padding: 0.25rem 0.6rem;
  font-size: 0.98rem; color: #334155; font-family: monospace;
  text-transform: uppercase; letter-spacing: 0.08em;
  position: sticky; top: 0; background: #050810; z-index: 1;
  border-bottom: 1px solid #0f172a;
}
.data-table th.r { text-align: right; }
.data-table td { padding: 0.25rem 0.6rem; font-family: monospace; font-size: 0.92rem; border-bottom: 1px solid #0a0f1e; color: #94a3b8; }
.data-table td.r { text-align: right; }
.data-table tr:hover td { background: #0a0f1e; color: #e2e8f0; }
.num { font-family: monospace; color: #e2e8f0; text-align: right; }

/* ── Pills ── */
.pill { font-family: monospace; font-size: 0.98rem; padding: 1px 6px; border-radius: 20px; display: inline-flex; align-items: center; }
.pill-em   { background: #052e16; border: 1px solid #166534; color: #4ade80; }
.pill-am   { background: #1c1400; border: 1px solid #92400e; color: #fbbf24; }
.pill-re   { background: #1c0a0a; border: 1px solid #7f1d1d; color: #f87171; }
.pill-bl   { background: #0c1a3a; border: 1px solid #1d4ed8; color: #60a5fa; }
.pill-pu   { background: #1a0a3a; border: 1px solid #7c3aed; color: #c4b5fd; }
.pill-cy   { background: #0a1f2a; border: 1px solid #0e7490; color: #22d3ee; }
.pill-gray { background: #0f172a; border: 1px solid #334155; color: #64748b; }

/* ── Row items ── */
.row-item { display: flex; align-items: flex-start; justify-content: space-between; padding: 0.4rem 0.75rem; border-bottom: 1px solid #080d17; gap: 10px; }
.row-item:last-child { border-bottom: none; }
.row-name { font-size: 0.95rem; color: #e2e8f0; font-weight: 500; margin-bottom: 2px; }
.row-sub  { font-size: 0.95rem; color: #475569; font-family: monospace; }
.row-right { flex-shrink: 0; display: flex; align-items: center; gap: 6px; }

/* ── Learning cards ── */
.learning-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 0.6rem; }
.learning-card { background: #050810; border: 1px solid #1e293b; border-radius: 6px; padding: 0.75rem; }
.learning-card:hover { border-color: #334155; }
.learning-title { font-size: 0.95rem; color: #e2e8f0; font-weight: 500; margin-bottom: 5px; line-height: 1.4; }
.learning-body  { font-size: 0.7rem; color: #64748b; line-height: 1.5; margin-bottom: 8px; }
.learning-meta  { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.imp-dots { display: flex; gap: 3px; align-items: center; }
.imp-dot  { width: 5px; height: 5px; border-radius: 50%; }

/* ── Strategy board ── */
.strategy-board { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.75rem; }
.strategy-col-header { font-size: 0.98rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; padding: 0 0 0.5rem; margin-bottom: 0.5rem; border-bottom: 1px solid; font-family: monospace; }
.strategy-col-header.active  { color: #4ade80; border-color: #166534; }
.strategy-col-header.testing { color: #fbbf24; border-color: #92400e; }
.strategy-col-header.paused  { color: #475569; border-color: #1e293b; }
.strategy-card { background: #050810; border: 1px solid #1e293b; border-radius: 6px; padding: 0.65rem; margin-bottom: 0.5rem; }
.strategy-card:hover { border-color: #334155; }
.strategy-title { font-size: 0.92rem; color: #e2e8f0; font-weight: 500; margin-bottom: 4px; }
.strategy-body  { font-size: 0.95rem; color: #64748b; line-height: 1.5; margin-bottom: 7px; }
.strategy-tags  { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }

/* ── Report card ── */
.report-card { padding: 0.75rem; border-bottom: 1px solid #0a0f1e; }
.report-card:last-child { border-bottom: none; }
.report-date { font-size: 0.95rem; color: #60a5fa; font-family: monospace; margin-bottom: 0.5rem; }
.report-section { margin-bottom: 0.5rem; }
.report-section-label { font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.08em; color: #475569; margin-bottom: 3px; font-family: monospace; }
.report-text { font-size: 0.92rem; color: #94a3b8; line-height: 1.6; }
.report-kpis { display: flex; gap: 1.25rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.report-kpi-val { font-size: 1rem; font-weight: 700; font-family: monospace; color: #e2e8f0; }
.report-kpi-lbl { font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.08em; color: #475569; font-family: monospace; }

/* ── References ── */
.refs-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 0.6rem; }
.ref-card { background: #050810; border: 1px solid #1e293b; border-radius: 6px; padding: 0.75rem; cursor: pointer; }
.ref-card:hover { border-color: #334155; }
.ref-title { font-size: 0.92rem; color: #e2e8f0; font-weight: 500; margin-bottom: 4px; }
.ref-meta  { font-size: 0.92rem; color: #475569; font-family: monospace; }
.ref-viewer { background: #050810; border: 1px solid #1e293b; border-radius: 6px; padding: 1rem; margin-top: 0.6rem; }
.ref-viewer-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; padding-bottom: 0.6rem; border-bottom: 1px solid #1e293b; }
.ref-viewer-title { font-size: 0.9rem; color: #e2e8f0; font-weight: 600; }
.ref-content { font-size: 0.92rem; color: #94a3b8; line-height: 1.8; white-space: pre-wrap; max-height: 70vh; overflow-y: auto; }
.ref-content h1, .ref-content h2, .ref-content h3 { color: #e2e8f0; margin: 1rem 0 0.4rem; }
.ref-content code { background: #0f172a; border: 1px solid #1e293b; border-radius: 3px; padding: 1px 5px; font-family: monospace; font-size: 0.95rem; }

/* ── Code block ── */
.code-block { background: #000; border: 1px solid #1e293b; border-radius: 6px; padding: 0.65rem 0.85rem; font-family: monospace; font-size: 0.98rem; color: #4ade80; white-space: pre; overflow-x: auto; margin-bottom: 0.6rem; line-height: 1.7; }

/* ── Empty / Error ── */
.empty { text-align: center; padding: 2rem 1rem; color: #334155; font-size: 0.95rem; font-family: monospace; }
.empty-icon { font-size: 1.2rem; margin-bottom: 0.5rem; opacity: 0.3; }
.api-error { background: rgba(248,113,113,0.05); border: 1px solid rgba(248,113,113,0.15); border-radius: 6px; padding: 0.6rem 0.75rem; margin-bottom: 0.6rem; font-size: 0.95rem; color: #f87171; font-family: monospace; }

/* ── Loading ── */
#loading-screen { position: fixed; inset: 0; background: #000; z-index: 100; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 10px; }
.load-wordmark { font-family: monospace; font-size: 0.95rem; letter-spacing: 5px; color: #334155; text-transform: uppercase; }
.load-logo { font-family: monospace; font-size: 1.8rem; font-weight: 700; color: #4ade80; letter-spacing: -1px; }
.loading-bar { width: 140px; height: 1px; background: #1e293b; overflow: hidden; }
.loading-fill { height: 100%; background: #4ade80; animation: load 1.6s ease-in-out infinite; }
@keyframes load { 0%{width:0%} 70%{width:100%} 100%{width:100%} }
.loading-status { font-size: 0.95rem; color: #334155; font-family: monospace; letter-spacing: 2px; text-transform: uppercase; }

/* ── Sections ── */
.section { display: none; }
.section.active { display: block; }

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(4px); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.hidden { display: none; }
.modal { background: #0f172a; border: 1px solid #1e293b; border-radius: 8px; padding: 1.5rem; width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto; }
.modal-title { font-family: monospace; font-size: 0.92rem; color: #94a3b8; letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 1.25rem; }
.form-group { margin-bottom: 0.85rem; }
.form-label { display: block; font-size: 0.92rem; color: #475569; margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.08em; font-family: monospace; }
.form-input, .form-textarea, .form-select { width: 100%; background: #000; border: 1px solid #334155; color: #e2e8f0; padding: 0.4rem 0.6rem; border-radius: 4px; font-size: 0.9rem; font-family: monospace; outline: none; transition: border-color 0.1s; }
.form-input:focus, .form-textarea:focus, .form-select:focus { border-color: #475569; }
.form-textarea { min-height: 80px; resize: vertical; }
.form-select { appearance: none; cursor: pointer; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid #1e293b; }

/* ── Misc ── */
.sep { border: none; border-top: 1px solid #1e293b; margin: 0.75rem 0; }

/* ── Toast ── */
#toast { position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 300; padding: 0.5rem 0.85rem; border-radius: 6px; font-size: 0.95rem; font-family: monospace; animation: slideUp 0.2s ease; display: none; }
#toast.success { background: rgba(74,222,128,0.1); color: #4ade80; border: 1px solid #166534; }
#toast.error   { background: rgba(248,113,113,0.1); color: #f87171; border: 1px solid #7f1d1d; }
@keyframes slideUp { from{transform:translateY(8px);opacity:0} to{transform:translateY(0);opacity:1} }

/* ── Responsive ── */
@media (max-width:1100px) { .kpi-grid { grid-template-columns: repeat(2,1fr); } .learning-grid { grid-template-columns: repeat(2,1fr); } .refs-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width:700px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .strategy-board, .two-col, .three-col, .col-2-1 { grid-template-columns: 1fr; }
  .header-date { display: none; }
}
