:root {
  --bg: #faf9f6;
  --surface: #ffffff;
  --surface-muted: #f3f1ec;
  --ink: #141619;
  --ink-muted: #5a6069;
  --border: #e4e2dc;
  --accent: #0f52ba;
  --accent-soft: #eef4ff;
  --green: #0d7a5f;
  --green-soft: #e9f7f2;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  --font-serif: "Georgia", "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  font-size: 14px;
}

.hidden { display: none !important; }

.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr 310px;
  min-height: 100vh;
}

/* Left Rail */
.left-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  color: var(--accent);
  text-transform: uppercase;
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
  margin-top: 2px;
}

.score-pill {
  margin-top: 10px;
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid #c3e8db;
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}
.score-label { font-size: 11px; font-weight: 600; }
.score-value { font-size: 16px; font-weight: 800; }

.view-switcher {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--surface-muted);
  padding: 4px;
  border-radius: 8px;
}

.view-btn {
  border: none;
  background: transparent;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.view-btn.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.badge-count {
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 99px;
}

.toc-heading {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin-bottom: 6px;
}

.toc-nav { display: flex; flex-direction: column; gap: 2px; }
.toc-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-decoration: none;
  color: var(--ink-muted);
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12.5px;
  transition: background 0.15s;
}
.toc-link:hover, .toc-link.active {
  background: var(--surface-muted);
  color: var(--ink);
  font-weight: 600;
}
.dwell-tag {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-muted);
}

.resources-box.resources-featured {
  background: var(--accent-soft);
  border: 1.5px solid #bfd5fb;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(15, 82, 186, 0.08);
}
.resources-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.resources-eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--accent);
}
.resources-pill {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  background: #ffffff;
  border: 1px solid #bfd5fb;
  padding: 1px 7px;
  border-radius: 99px;
}
.resource-switcher {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}
.res-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid #c9dcfb;
  background: #ffffff;
  padding: 8px 11px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}
.res-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.res-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(15, 82, 186, 0.22);
}
.res-arrow {
  font-size: 14px;
  opacity: 0.7;
}
.res-btn.active .res-arrow {
  opacity: 1;
}
.resource-card-slot {
  margin-top: 10px;
}

.mcp-status-box { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.mcp-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.mcp-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--ink-muted);
}
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
}

/* Main Stage */
.main-stage {
  padding: 32px 44px 80px;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.pill-live {
  background: var(--green-soft);
  color: var(--green);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 99px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.meta-text { font-size: 12px; color: var(--ink-muted); }

.memo-header h1 {
  font-family: var(--font-serif);
  font-size: 28px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.memo-tagline {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--ink-muted);
  font-size: 16px;
  margin-top: 8px;
  margin-bottom: 22px;
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.kpi-card:hover { border-color: var(--accent); }
.kpi-label { font-size: 11px; font-weight: 600; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-val { font-size: 20px; font-weight: 800; margin-top: 4px; color: var(--ink); }
.kpi-sub { font-size: 11.5px; color: var(--ink-muted); margin-top: 2px; }

.memo-section {
  padding-top: 28px;
  margin-top: 28px;
  border-top: 1px solid var(--border);
}
.memo-section h2 {
  font-family: var(--font-serif);
  font-size: 21px;
  margin-bottom: 12px;
}
.memo-section h3 {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  margin: 20px 0 10px;
}
.section-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.lead-p { font-size: 15px; margin-bottom: 12px; color: var(--ink); }
.body-p { margin-bottom: 12px; color: #2b3036; }
.hint-text { font-size: 12.5px; color: var(--ink-muted); margin-bottom: 12px; }

.card-grid { display: grid; gap: 12px; margin: 12px 0; }
.two-col { grid-template-columns: repeat(2, 1fr); }
.three-col { grid-template-columns: repeat(3, 1fr); }

.info-card, .panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.info-card h4 { font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.info-card .card-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 7px;
  border-radius: 5px;
  margin-bottom: 8px;
}

.callout-box {
  background: var(--surface-muted);
  border-left: 3px solid var(--accent);
  padding: 12px 14px;
  border-radius: 0 8px 8px 0;
  margin: 14px 0;
  font-size: 13.5px;
}
.muted-box {
  background: var(--surface-muted);
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13px;
}

.thesis-list, .pain-list { display: flex; flex-direction: column; gap: 10px; }
.thesis-item, .pain-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}
.thesis-item strong, .pain-item strong { display: block; margin-bottom: 4px; font-size: 14px; }

.vision-banner {
  margin-top: 18px;
  background: #141619;
  color: #fff;
  padding: 16px 20px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.vision-label { font-size: 10px; letter-spacing: 0.1em; color: #9ca3af; font-weight: 700; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 10px 0 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left;
  background: var(--surface-muted);
  padding: 9px 12px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-muted);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr.total-row { background: var(--surface-muted); font-weight: 700; }
.data-table tr.mcp-updated { background: var(--amber-soft); }

.mcp-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  background: var(--amber);
  color: #fff;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}

/* Simulator */
.simulator-panel {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin: 14px 0 20px;
}
.sim-control { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; }
.sim-control input[type="range"] { accent-color: var(--accent); cursor: pointer; }

/* Filter Chips */
.filter-bar { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 5px 10px;
  border-radius: 99px;
  font-size: 12px;
  cursor: pointer;
  color: var(--ink-muted);
}
.chip.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

/* Buttons */
.btn-secondary {
  background: var(--ink);
  color: #fff;
  border: none;
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn-ghost {
  background: transparent;
  color: var(--ink-muted);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn-ghost:hover { background: var(--surface-muted); color: var(--ink); }
.full-width { width: 100%; }
.btn-row { display: flex; gap: 8px; }

/* Right Drawer */
.right-drawer {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
}
.drawer-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 14px;
  background: var(--surface-muted);
  padding: 4px;
  border-radius: 8px;
}
.drawer-tab {
  border: none;
  background: transparent;
  padding: 6px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer;
}
.drawer-tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.drawer-intro { font-size: 12px; color: var(--ink-muted); margin-bottom: 14px; }
.drawer-intro code { font-family: var(--font-mono); font-size: 11px; background: var(--surface-muted); padding: 1px 4px; border-radius: 4px; }

.sync-presets { display: flex; flex-direction: column; gap: 8px; }
.preset-btn {
  text-align: left;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: border-color 0.15s;
}
.preset-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.preset-btn strong { font-size: 12.5px; color: var(--ink); }
.preset-btn span { font-size: 11.5px; color: var(--ink-muted); }

.drawer-divider { height: 1px; background: var(--border); margin: 16px 0; }
.sync-log { display: flex; flex-direction: column; gap: 8px; font-size: 12px; }
.sync-entry {
  background: var(--surface-muted);
  padding: 8px 10px;
  border-radius: 6px;
  border-left: 3px solid var(--amber);
}
.sync-entry .sync-time { font-family: var(--font-mono); font-size: 10px; color: var(--ink-muted); }

.evidence-list { display: flex; flex-direction: column; gap: 10px; }
.evidence-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
}
.evidence-card strong { display: block; color: var(--ink); margin-bottom: 2px; }
.evidence-card .ev-src { font-size: 11px; color: var(--accent); }
.evidence-card .ev-src-link {
  display: inline-block;
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.evidence-card .ev-src-link:hover {
  text-decoration: underline;
}

/* Analytics Bar Charts */
.bar-chart { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 48px; align-items: center; gap: 10px; font-size: 12px; }
.bar-track { background: var(--surface-muted); height: 10px; border-radius: 99px; overflow: hidden; }
.bar-fill { background: var(--accent); height: 100%; border-radius: 99px; }

.cite-link {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-style: dotted;
  cursor: pointer;
  font-weight: 600;
}

.comp-name-link {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}
.comp-name-link:hover {
  text-decoration: underline;
}
.demo-pill-row {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-left: 6px;
  vertical-align: middle;
}
.demo-pill {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 6px;
  border-radius: 4px;
  text-decoration: none;
}
.demo-pill:hover {
  text-decoration: underline;
}

/* Internal Password Gate */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(20, 22, 25, 0.72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 26px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
}
.auth-card h2 {
  font-family: var(--font-serif);
  font-size: 20px;
  margin: 6px 0 8px;
}
.auth-sub {
  font-size: 12.5px;
  color: var(--ink-muted);
  margin-bottom: 16px;
}
.auth-sub code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--surface-muted);
  padding: 1px 4px;
  border-radius: 4px;
}
.auth-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  font-family: var(--font-sans);
}
.auth-input:focus {
  outline: none;
  border-color: var(--accent);
}
.auth-error {
  color: #b91c1c;
  font-size: 12px;
  margin-top: 8px;
  font-weight: 600;
}

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 200px 1fr; }
  .right-drawer { display: none; }
}
