/* HubesHub Design System */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

/* ─── Tokens ─── */
:root {
  --bg: #f2f3f5;
  --surface: #ffffff;
  --surface-raised: #e8eaed;
  --surface-hover: #f8f9fa;
  --border: #d1d5db;
  --border-light: #e5e7eb;

  --ink: #111827;
  --ink-2: #374151;
  --ink-3: #6b7280;
  --ink-4: #9ca3af;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-bg: #dbeafe;
  --accent-text: #1e40af;

  --positive: #059669;
  --positive-bg: #d1fae5;
  --positive-text: #065f46;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --warning-text: #92400e;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --danger-text: #991b1b;

  --shopify-color: #5e8e3e;
  --ebay-color: #3665f3;

  --font: 'Outfit', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;

  --radius: 8px;
  --radius-sm: 4px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);

  --nav-height: 56px;
  --bottom-nav-height: 60px;
}

/* ─── Dark Theme ─── */
.dark {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-raised: #252836;
  --surface-hover: #2a2d3a;
  --border: #2e3244;
  --border-light: #252836;

  --ink: #e8eaed;
  --ink-2: #c4c7cd;
  --ink-3: #8b8f9a;
  --ink-4: #5f6370;

  --accent: #5b8def;
  --accent-hover: #7ba3f7;
  --accent-bg: #1c2a4a;
  --accent-text: #93b4f5;

  --positive: #34d399;
  --positive-bg: #0d2e23;
  --positive-text: #6ee7b7;
  --warning: #fbbf24;
  --warning-bg: #362a0d;
  --warning-text: #fcd34d;
  --danger: #f87171;
  --danger-bg: #3b1515;
  --danger-text: #fca5a5;

  --shopify-color: #86c462;
  --ebay-color: #7b9df7;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.4), 0 2px 4px rgba(0,0,0,0.3);
}

/* ─── PIN Gate ─── */
.pin-gate {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  font-family: var(--font);
}
.pin-box {
  text-align: center;
  padding: 2.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  width: 320px;
}
.pin-logo { width: 48px; height: 48px; margin-bottom: 1rem; }
.pin-box h1 {
  font-size: 1.5rem; font-weight: 700; color: var(--ink);
  margin-bottom: 0.25rem;
}
.pin-box p {
  font-size: 0.875rem; color: var(--ink-3);
  margin-bottom: 1.25rem;
}
.pin-box input {
  width: 100%; padding: 0.75rem 1rem;
  font-family: var(--mono); font-size: 1.25rem;
  text-align: center; letter-spacing: 0.3em;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: var(--radius);
  outline: none; transition: border-color 0.15s;
}
.pin-box input:focus { border-color: var(--accent); }
.pin-submit {
  margin-top: 0.75rem; width: 100%; padding: 0.65rem;
  background: var(--accent); color: #fff; border: none; border-radius: var(--radius);
  font-family: var(--font); font-size: 0.95rem; font-weight: 600;
  cursor: pointer; transition: background 0.15s;
}
.pin-submit:hover { background: var(--accent-hover); }
.pin-error {
  margin-top: 0.75rem; font-size: 0.8rem;
  color: var(--danger); min-height: 1.2em;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}
.pin-box input.shake { animation: shake 0.3s ease-in-out; }

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

html { scroll-behavior: auto; /* JS handles smooth scroll */ color-scheme: light; }
html.dark { color-scheme: dark; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-top: var(--nav-height);
}

/* ─── Top Nav ─── */
.hub-topnav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  z-index: 200;
  gap: 0.25rem;
}

.hub-topnav-brand {
  font-family: var(--font);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--ink);
  text-decoration: none;
  margin-right: 2rem;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.hub-topnav-brand svg { width: 24px; height: 24px; flex-shrink: 0; }

.hub-topnav-links {
  display: flex;
  gap: 0.25rem;
  list-style: none;
}

.hub-topnav-links a {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink-3);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}
.hub-topnav-links a:hover {
  color: var(--ink);
  background: var(--surface-hover);
}
.hub-topnav-links a[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-bg);
  font-weight: 600;
}
.hub-topnav-links a svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ─── Theme Toggle ─── */
.theme-toggle {
  margin-left: auto;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.theme-toggle:hover {
  color: var(--ink);
  background: var(--surface-hover);
}
.theme-toggle svg { width: 18px; height: 18px; }

/* ─── Bottom Nav (mobile) ─── */
.hub-bottomnav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  padding-bottom: env(safe-area-inset-bottom, 0);
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 200;
}
.hub-bottomnav-inner {
  display: flex;
  height: 100%;
}
.hub-bottomnav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--ink-4);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.3px;
  transition: color 0.15s;
}
.hub-bottomnav a svg { width: 20px; height: 20px; }
.hub-bottomnav a[aria-current="page"] { color: var(--accent); }
.hub-bottomnav a:active { color: var(--ink-2); }

/* ─── Typography ─── */
h1 { font-size: 1.75rem; font-weight: 700; color: var(--ink); letter-spacing: -0.5px; line-height: 1.2; }
h2 { font-size: 1.15rem; font-weight: 600; color: var(--ink); letter-spacing: -0.2px; }
h3 { font-size: 0.95rem; font-weight: 600; color: var(--ink-2); }
p { color: var(--ink-2); font-size: 0.9rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
strong { color: var(--ink); font-weight: 600; }
.mono { font-family: var(--mono); }
.eyebrow {
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ink-4);
}

/* ─── Layout ─── */
.page-shell { max-width: 1060px; margin: 0 auto; padding: 1.5rem 1.5rem 5rem; }

.page-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  max-width: 1060px;
  margin: 0 auto;
  gap: 0;
}

.page-content { max-width: 780px; margin: 0 auto; padding: 1.5rem 1.5rem 5rem; }

/* Content container for sidebar pages */
.container {
  max-width: 780px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}
.container h1 { margin-bottom: 0.25rem; }
.container h2 {
  margin: 2.5rem 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border-light);
}
.container h3 { margin: 1.5rem 0 0.5rem; }
.container p { margin-bottom: 0.75rem; }
.container ul, .container ol { padding-left: 1.25rem; margin-bottom: 0.75rem; font-size: 0.9rem; color: var(--ink-2); }
.container li { margin-bottom: 0.35rem; }
.subtitle { font-size: 0.92rem; color: var(--ink-3); margin-bottom: 2rem; }
.footer { text-align: center; font-size: 0.78rem; color: var(--ink-4); margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--border-light); }

/* ─── Sidebar ─── */
.sidebar {
  position: sticky;
  top: calc(var(--nav-height) + 1rem);
  height: calc(100vh - var(--nav-height) - 2rem);
  overflow-y: auto;
  padding: 1rem 1rem 2rem 1.5rem;
}
.sidebar-title {
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--ink);
  margin-bottom: 0.75rem;
  letter-spacing: -0.2px;
}
.sidebar nav ul { list-style: none; }
.sidebar nav li { margin-bottom: 1px; }
.sidebar nav a {
  display: block;
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  color: var(--ink-3);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.sidebar nav a:hover { background: var(--surface-hover); color: var(--ink-2); text-decoration: none; }
.sidebar nav a.active { background: var(--accent-bg); color: var(--accent-text); font-weight: 600; }

/* ─── Cards ─── */
.card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 0.75rem; }
.card h3 { margin-top: 0; margin-bottom: 0.5rem; }
.card p { margin-bottom: 0.5rem; }
.card p:last-child { margin-bottom: 0; }
.card ul, .card ol { padding-left: 1.25rem; margin-bottom: 0.5rem; font-size: 0.88rem; color: var(--ink-2); }
.card li { margin-bottom: 0.3rem; }

/* ─── Metric Cards ─── */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 1rem;
}
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.metric-card .metric-label {
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ink-4);
  margin-bottom: 0.35rem;
}
.metric-card .metric-value {
  font-family: var(--mono);
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1;
  margin-bottom: 0.25rem;
}
.metric-card .metric-value.accent { color: var(--accent); }
.metric-card .metric-sub {
  font-size: 0.78rem;
  color: var(--ink-3);
}

/* ─── Stat Row (hero numbers) ─── */
.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border-light);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.stat-cell {
  padding: 1.25rem 1rem;
  text-align: center;
  background: var(--surface);
}
.stat-cell .stat-number {
  font-family: var(--mono);
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1;
  margin-bottom: 0.25rem;
}
.stat-cell .stat-number.accent { color: var(--accent); }
.stat-cell .stat-label {
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--ink-4);
}

/* ─── Stat Trio (3-col) ─── */
.stat-trio {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border-light);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 0.75rem;
}
.stat-trio .stat {
  background: var(--surface);
  padding: 1.25rem;
}
.stat-trio .stat-val {
  font-family: var(--mono);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.15rem;
}
.stat-trio .stat-label { font-size: 0.72rem; color: var(--ink-4); font-weight: 500; }
.stat-trio .stat-sub { font-size: 0.75rem; color: var(--ink-3); margin-top: 0.25rem; }

/* ─── Data Table ─── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0.5rem;
}
.data-table th {
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--ink-4);
  text-align: left;
  padding: 0.6rem 0.85rem;
  border-bottom: 2px solid var(--ink);
}
.data-table td {
  padding: 0.5rem 0.85rem;
  font-size: 0.85rem;
  color: var(--ink-2);
  border-bottom: 1px solid var(--border-light);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table .mono {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink);
}
.data-table .pos { color: var(--positive); }
.data-table .neg { color: var(--danger); }
.data-table .peak-row { background: var(--accent-bg); }
.data-table th.right, .data-table td.right { text-align: right; }
.data-table .shopify-col { color: var(--shopify-color); }
.data-table .ebay-col { color: var(--ebay-color); }
.data-table .combined-col { color: var(--accent); font-weight: 600; }

/* ─── Sections ─── */
.section { margin-bottom: 2rem; }
.section-head {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-light);
}
.section-num {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-4);
}
.section h2 {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--ink-2);
}
.section-context {
  font-size: 0.82rem;
  color: var(--ink-3);
  line-height: 1.6;
  margin-bottom: 1rem;
}
.section-context strong { color: var(--ink-2); }

/* ─── Callouts / Takeaways ─── */
.callout {
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin: 0.75rem 0;
  font-size: 0.85rem;
  line-height: 1.55;
}
.callout { background: var(--accent-bg); color: var(--accent-text); }
.callout p { margin-bottom: 0; }
.callout strong { color: var(--accent-text); font-weight: 700; }
.callout-info { background: var(--accent-bg); color: var(--accent-text); }
.callout-warning { background: var(--warning-bg); color: var(--warning-text); }
.callout-danger { background: var(--danger-bg); color: var(--danger-text); }
.callout-positive { background: var(--positive-bg); color: var(--positive-text); }

.takeaway {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  background: var(--accent-bg);
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1rem;
  margin-top: 0.75rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.takeaway-icon {
  font-family: var(--mono);
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
  padding-top: 2px;
}
.takeaway p { font-size: 0.8rem; color: var(--ink-2); line-height: 1.55; margin: 0; }

/* ─── Quality Bars ─── */
.quality-item {
  display: grid;
  grid-template-columns: 150px 1fr 55px;
  align-items: center;
  gap: 12px;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border-light);
}
.quality-item:last-child { border-bottom: none; }
.quality-label { font-size: 0.8rem; color: var(--ink-2); }
.quality-track { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.quality-fill { height: 100%; border-radius: 4px; transition: width 1s cubic-bezier(0.16, 1, 0.3, 1); }
.quality-fill.severe { background: var(--danger); }
.quality-fill.warning { background: var(--warning); }
.quality-fill.info { background: var(--ink-3); }
.quality-count { font-family: var(--mono); font-size: 0.75rem; font-weight: 500; color: var(--ink-3); text-align: right; }

/* ─── Opportunity Cards ─── */
.opp {
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
}
.opp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.25rem; }
.opp-title { font-weight: 600; font-size: 0.88rem; color: var(--ink); }
.opp-tag {
  font-family: var(--mono);
  font-size: 0.56rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}
.opp-tag.high { background: var(--danger-bg); color: var(--danger-text); }
.opp-tag.med { background: var(--warning-bg); color: var(--warning-text); }
.opp p { font-size: 0.82rem; color: var(--ink-3); line-height: 1.55; }
.opp .action { font-size: 0.78rem; color: var(--accent); font-weight: 500; margin-top: 0.3rem; }

/* ─── Channel Cards ─── */
.channel-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border-light);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 0.75rem;
}
.channel-card { background: var(--surface); padding: 1.25rem; }
.channel-card .ch-label {
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 0.6rem;
}
.channel-card .ch-label.shopify { color: var(--shopify-color); }
.channel-card .ch-label.ebay { color: var(--ebay-color); }
.channel-card .ch-big {
  font-family: var(--mono);
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1;
  margin-bottom: 0.5rem;
}
.channel-card .ch-stats { font-size: 0.78rem; color: var(--ink-3); line-height: 1.65; }
.channel-card .ch-stats strong { color: var(--ink-2); }

/* ─── Fee Callout ─── */
.fee-callout {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1px;
  background: var(--border-light);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 0.75rem;
}
.fee-item { background: var(--surface); padding: 1rem 1.25rem; text-align: center; }
.fee-item .fee-val { font-family: var(--mono); font-size: 1.15rem; font-weight: 600; margin-bottom: 0.15rem; }
.fee-item .fee-val.savings { color: var(--positive); }
.fee-item .fee-label { font-size: 0.68rem; color: var(--ink-4); }

/* ─── Collection Grid ─── */
.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px;
}
.collection-chip {
  background: var(--surface);
  border: 1px solid var(--border-light);
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
}
.collection-chip .cname { font-size: 0.82rem; font-weight: 500; color: var(--ink-2); margin-bottom: 0.1rem; }
.collection-chip .ctype { font-family: var(--mono); font-size: 0.6rem; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-4); }

/* ─── Pipeline Banner ─── */
.pipeline-banner {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.pipeline-banner h3 {
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.5rem;
}
.pipeline-banner p { font-size: 0.82rem; color: var(--ink-3); line-height: 1.6; margin-bottom: 0.35rem; }
.pipeline-banner p:last-child { margin-bottom: 0; }
.pipeline-banner strong { color: var(--ink-2); }
.pipeline-flow {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 0.75rem 0 0.5rem;
  flex-wrap: wrap;
}
.pipeline-step {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  padding: 0.3rem 0.7rem;
  background: var(--bg);
  border: 1px solid var(--border-light);
  color: var(--ink-2);
  white-space: nowrap;
}
.pipeline-step:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.pipeline-step:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.pipeline-arrow { font-size: 0.7rem; color: var(--ink-4); padding: 0 0.1rem; }

/* ─── Rule Cards (compliance) ─── */
.rule-card {
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 0.5rem;
}
.rule-card.safe { background: var(--positive-bg); border-left: 4px solid var(--positive); }
.rule-card.caution { background: var(--warning-bg); border-left: 4px solid var(--warning); }
.rule-card.stop { background: var(--danger-bg); border-left: 4px solid var(--danger); }
.rule-card h4 { font-size: 0.85rem; margin-bottom: 0.35rem; }
.rule-card p { font-size: 0.88rem; margin-bottom: 0; }
.rule-card p strong { color: var(--ink); }
.rule-card ul { padding-left: 1.25rem; margin: 0; }
.rule-card li { font-size: 0.82rem; margin-bottom: 0.2rem; }
.rule-card.safe h4 { color: var(--positive-text); }
.rule-card.caution h4 { color: var(--warning-text); }
.rule-card.stop h4 { color: var(--danger-text); }
.rule-card.safe li, .rule-card.safe p { color: var(--positive-text); }
.rule-card.caution li, .rule-card.caution p { color: var(--warning-text); }
.rule-card.stop li, .rule-card.stop p { color: var(--danger-text); }

/* ─── Phase Badges ─── */
.phase-badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}
.phase-badge.done { background: var(--positive-bg); color: var(--positive-text); }
.phase-badge.active { background: var(--accent-bg); color: var(--accent-text); }
.phase-badge.upcoming { background: var(--bg); color: var(--ink-4); }

/* ─── Loading ─── */
.loading {
  text-align: center;
  padding: 5rem 2rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-4);
  letter-spacing: 1px;
}
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 1.25rem auto 0;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Footer ─── */
.colophon {
  text-align: center;
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-light);
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--ink-4);
  letter-spacing: 0.5px;
  line-height: 2;
}

/* ─── Page Header ─── */
.page-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-light);
}
.page-header h1 { margin-bottom: 0.25rem; }
.page-header .subtitle { font-size: 0.88rem; color: var(--ink-3); }

/* ─── Mobile TOC Drawer ─── */
.toc-fab {
  display: none;
  position: fixed;
  right: 1rem;
  bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px) + 0.75rem);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  z-index: 150;
  align-items: center;
  justify-content: center;
}
.toc-fab svg { width: 20px; height: 20px; }

.toc-drawer {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
}
.toc-drawer.open { display: flex; flex-direction: column; justify-content: flex-end; }
.toc-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.3);
}
.toc-panel {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 1.25rem 1.5rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
  max-height: 60vh;
  overflow-y: auto;
}
.toc-panel-title {
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  color: var(--ink);
}
.toc-panel a {
  display: block;
  padding: 0.5rem 0.65rem;
  font-size: 0.85rem;
  color: var(--ink-3);
  text-decoration: none;
  border-radius: var(--radius-sm);
}
.toc-panel a:hover { background: var(--surface-hover); color: var(--ink-2); }
.toc-panel a.active { background: var(--accent-bg); color: var(--accent-text); font-weight: 600; }

/* ─── Responsive ─── */
@media (max-width: 767px) {
  body {
    padding-top: var(--nav-height);
    padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
    overflow-x: hidden;
  }

  .hub-topnav-links { display: none; }
  .hub-bottomnav { display: block; }
  .toc-fab { display: flex; }

  .page-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }

  .stat-row { grid-template-columns: 1fr 1fr; }
  .stat-trio { grid-template-columns: 1fr; }
  .channel-row { grid-template-columns: 1fr; }
  .fee-callout { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .collection-grid { grid-template-columns: 1fr 1fr; }

  h1 { font-size: 1.35rem; }
  .stat-cell .stat-number { font-size: 1.4rem; }
  .quality-item { grid-template-columns: 110px 1fr 42px; }
  .pipeline-flow { flex-direction: column; align-items: stretch; }
  .pipeline-step { border-radius: var(--radius-sm) !important; }
  .pipeline-arrow { text-align: center; transform: rotate(90deg); padding: 0.15rem 0; }

  .page-shell { padding: 1rem 1rem 4rem; }
  .page-content { padding: 1rem 1rem 4rem; }
  .container { padding: 1rem 1rem 4rem; }
  .container h2 { margin-top: 1.75rem; font-size: 1.05rem; }

  .rule-card { padding: 0.85rem 1rem; }
  .rule-card h4 { font-size: 0.8rem; }
  .rule-card p { font-size: 0.82rem; }

  .card { padding: 1rem 1.15rem; }
  .card ul, .card ol { font-size: 0.82rem; }

  .data-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  .metric-card .metric-value { font-size: 1.5rem; }
}

@media (max-width: 480px) {
  .metric-grid { grid-template-columns: 1fr; }
  .collection-grid { grid-template-columns: 1fr; }
}
