/* Shared prototype components — consumes tokens.css only. */
@import url("https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600&display=swap");

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--background);
  color: var(--foreground);
  font-size: var(--text-sm);
  line-height: 1.5;
  font-feature-settings: "tnum" off;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- typography ---------- */
.type-display { font-size: var(--text-display); line-height: 1.02; font-weight: 500; letter-spacing: -0.02em; }
.type-h1 { font-size: var(--text-h1); line-height: 1.05; font-weight: 500; letter-spacing: -0.02em; }
.type-h2 { font-size: var(--text-h2); line-height: 1.05; font-weight: 500; letter-spacing: -0.02em; }
.type-h3 { font-size: var(--text-h3); line-height: 1.375; font-weight: 500; letter-spacing: -0.01em; }
.type-eyebrow { font-size: var(--text-xs); font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--primary); }
.type-kpi { font-size: var(--text-kpi); line-height: 1; font-weight: 500; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.text-base { font-size: var(--text-base); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-ui { font-size: var(--text-ui); line-height: 1.25rem; font-weight: 500; letter-spacing: -0.01em; }
.text-2xs { font-size: var(--text-2xs); line-height: 0.875rem; font-weight: 500; }
.muted { color: var(--muted-foreground); }
.faint { color: var(--faint); }
.kw { color: var(--primary); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: var(--radius-md); border: 1px solid transparent;
  font-size: var(--text-ui); font-weight: 500; letter-spacing: -0.01em;
  height: 36px; padding: 0 14px; transition: background-color .15s, border-color .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.08); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ink { background: var(--ink); color: #fff; }
.btn-ink:hover { background: #2e2e2e; }
.btn-outline { background: var(--card); border-color: var(--border); box-shadow: var(--shadow-card); }
.btn-outline:hover { background: var(--muted); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--muted); }
.btn-sm { height: 32px; padding: 0 12px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: var(--text-sm); }

/* ---------- cards / surfaces ---------- */
.card {
  background: var(--card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card), 0 0 0 1px rgb(23 23 23 / 0.08);
  padding: 16px;
}
.card-lg { padding: 24px; }
.hairline { box-shadow: 0 0 0 1px rgb(23 23 23 / 0.08); }

/* badges & chips */
.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px;
  border-radius: 999px; font-size: var(--text-2xs); font-weight: 500;
}
.badge-brand { background: var(--brand-50); color: var(--brand-700); box-shadow: 0 0 0 1px var(--brand-200); }
.badge-neutral { background: var(--muted); color: var(--muted-foreground); box-shadow: 0 0 0 1px var(--border); }
.badge-success { background: var(--success-soft); color: var(--success); box-shadow: 0 0 0 1px var(--success-border); }
.badge-warning { background: var(--warning-soft); color: var(--warning); box-shadow: 0 0 0 1px var(--warning-border); }
.badge-danger { background: var(--danger-soft); color: var(--danger); box-shadow: 0 0 0 1px var(--danger-border); }
.badge-info { background: var(--info-soft); color: var(--info); box-shadow: 0 0 0 1px var(--info-border); }

/* grade medallion */
.grade { display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; font-weight: 500; font-variant-numeric: tabular-nums; }
.grade-a { background: var(--success-soft); color: var(--success); box-shadow: 0 0 0 1px var(--success-border); }
.grade-b { background: #f0fdf4; color: #15803d; box-shadow: 0 0 0 1px #bbf7d0; }
.grade-c { background: var(--warning-soft); color: var(--warning); box-shadow: 0 0 0 1px var(--warning-border); }
.grade-f { background: var(--danger-soft); color: var(--danger); box-shadow: 0 0 0 1px var(--danger-border); }

/* inputs */
.input {
  height: 36px; width: 100%; border-radius: var(--radius-md);
  border: 1px solid transparent; background: rgb(23 23 23 / 0.06);
  padding: 0 12px; font: inherit; font-size: var(--text-sm); color: var(--foreground);
}
.input::placeholder { color: rgb(23 23 23 / 0.5); }
.input:focus { outline: none; background: #fff; border-color: var(--ring); box-shadow: 0 0 0 3px rgb(0 130 86 / 0.25); }
label.fld { display: block; font-size: var(--text-xs); font-weight: 500; color: var(--muted-foreground); margin-bottom: 8px; }

/* tables */
.tbl { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.tbl th { height: 40px; text-align: left; font-size: var(--text-xs); font-weight: 500; color: var(--muted-foreground); border-bottom: 1px solid var(--border); padding: 0 12px; }
.tbl td { height: 44px; border-bottom: 1px solid var(--border); padding: 0 12px; font-variant-numeric: tabular-nums; }
.tbl tr:hover td { background: rgb(245 245 245 / 0.5); }
.tbl .num { text-align: right; }

/* progress bar */
.bar { height: 6px; border-radius: 999px; background: var(--muted); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--brand-500); }

/* ---------- marketing shell ---------- */
.mk-nav {
  position: sticky; top: 0; z-index: 40; background: rgb(247 247 247 / 0.85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.mk-nav-in { max-width: 1120px; margin: 0 auto; padding: 0 24px; height: 56px; display: flex; align-items: center; gap: 24px; }
.mk-nav-links { display: flex; gap: 20px; font-size: var(--text-ui); font-weight: 500; color: var(--muted-foreground); margin-left: auto; align-items: center; }
.mk-nav-links a:hover { color: var(--foreground); }
.mk-container { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.mk-section { padding-top: 80px; }
.mk-section-head { margin-bottom: 48px; text-align: center; }
.mk-section-head .type-eyebrow { display: block; margin-bottom: 12px; }
.mk-footer { margin-top: 96px; border-top: 1px solid var(--border); background: var(--card); padding: 48px 0 32px; font-size: var(--text-ui); color: var(--muted-foreground); }
.logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; letter-spacing: -0.01em; color: var(--foreground); }
.logo img { height: 24px; width: auto; display: block; }
.burger { display: none; }

/* ---------- product shell (dashboard) ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex: none; background: var(--background); border-right: 1px solid var(--border);
  padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh;
}
.side-item {
  display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px; border-radius: var(--radius-md);
  font-size: var(--text-ui); font-weight: 500; color: var(--muted-foreground);
}
.side-item:hover { background: var(--muted); color: var(--foreground); }
.side-item.active { background: #fff; color: var(--foreground); box-shadow: var(--shadow-card), 0 0 0 1px rgb(23 23 23 / 0.08); }
.side-item .ic { width: 16px; text-align: center; color: var(--faint); }
.side-item.active .ic { color: var(--primary); }
.main { flex: 1; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: 52px; background: rgb(247 247 247 / 0.9); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 0 24px;
}
.page { padding: 24px; max-width: 1180px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--card);
  font-size: var(--text-ui); font-weight: 500; box-shadow: var(--shadow-card);
}
.kbd {
  display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 4px; background: var(--muted); border: 1px solid var(--border);
  font-size: var(--text-2xs); color: var(--muted-foreground); font-family: inherit;
}

/* KPI row */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi-label { font-size: var(--text-xs); font-weight: 500; color: var(--muted-foreground); display: flex; align-items: center; gap: 6px; }
.delta-up { color: var(--success); font-size: var(--text-xs); font-weight: 500; font-variant-numeric: tabular-nums; }
.delta-down { color: var(--danger); font-size: var(--text-xs); font-weight: 500; font-variant-numeric: tabular-nums; }

/* insight strip under charts */
.insight { display: flex; gap: 8px; align-items: flex-start; font-size: var(--text-ui); color: var(--muted-foreground); background: var(--muted); border-radius: var(--radius-md); padding: 8px 12px; }
.insight::before { content: "→"; color: var(--primary); font-weight: 500; }

/* avatars */
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 999px; font-size: var(--text-2xs); font-weight: 500; flex: none; }

/* ---------- flow / diagram primitives ---------- */
.flow { display: flex; align-items: stretch; gap: 0; flex-wrap: wrap; }
.flow-step { flex: 1; min-width: 180px; position: relative; padding-right: 40px; }
.flow-step:not(:last-child)::after {
  content: "→"; position: absolute; right: 12px; top: 42px; color: var(--faint); font-size: 18px;
}
.flow-node { background: var(--card); border-radius: var(--radius-lg); box-shadow: var(--shadow-card), 0 0 0 1px rgb(23 23 23 / 0.08); padding: 16px; height: 100%; }
.flow-num { display: inline-flex; width: 24px; height: 24px; border-radius: 999px; background: var(--brand-50); color: var(--brand-700); box-shadow: 0 0 0 1px var(--brand-200); align-items: center; justify-content: center; font-size: var(--text-xs); font-weight: 500; margin-bottom: 8px; }
.state { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px; font-size: var(--text-xs); font-weight: 500; }

/* ---------- annotation system ---------- */
.anno {
  position: absolute; z-index: 50; display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 999px; background: var(--info); color: #fff;
  font-size: var(--text-2xs); font-weight: 600; box-shadow: 0 0 0 3px rgb(29 78 216 / 0.2); cursor: default;
}
.anno.diff { background: var(--danger); box-shadow: 0 0 0 3px rgb(185 28 28 / 0.18); }
.anno-host { position: relative; }
body.hide-annos .anno, body.hide-annos .anno-drawer { display: none !important; }
.anno-drawer {
  position: fixed; right: 16px; bottom: 60px; z-index: 60; width: 340px; max-height: 60vh; overflow: auto;
  background: var(--card); border-radius: var(--radius-lg); box-shadow: var(--shadow-overlay), 0 0 0 1px rgb(23 23 23 / 0.1);
  padding: 16px; font-size: var(--text-ui);
}
.anno-drawer h4 { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted-foreground); margin-bottom: 12px; }
.anno-drawer li { display: flex; gap: 10px; margin-bottom: 10px; list-style: none; color: var(--muted-foreground); }
.anno-drawer li b.n { flex: none; display: inline-flex; width: 20px; height: 20px; border-radius: 999px; background: var(--info); color: #fff; align-items: center; justify-content: center; font-size: var(--text-2xs); }
.anno-drawer li.diff b.n { background: var(--danger); }
.proto-toolbar {
  position: fixed; right: 16px; bottom: 16px; z-index: 70; display: flex; gap: 8px;
  background: var(--ink-dark); border-radius: 999px; padding: 6px 8px; box-shadow: var(--shadow-overlay);
}
.proto-toolbar button { background: transparent; border: 0; color: #cbd5e1; font-size: var(--text-2xs); font-weight: 500; padding: 4px 10px; border-radius: 999px; }
.proto-toolbar button.on { background: rgb(255 255 255 / 0.14); color: #fff; }
body.show-grid .mk-container, body.show-grid .page {
  background-image: repeating-linear-gradient(to right, rgb(2 132 199 / 0.06) 0 1px, transparent 1px calc((100% - 11 * 24px) / 12 + 24px));
}

/* spec strip at top of each screen */
.spec-strip { background: var(--ink-dark); color: #cbd5e1; font-size: var(--text-ui); padding: 10px 24px; display: flex; gap: 24px; flex-wrap: wrap; align-items: center; }
.spec-strip b { color: #fff; font-weight: 500; }
.spec-strip .sep { color: #475569; }
.spec-strip a { color: var(--brand-400); }

/* ---------- responsive (390 mobile) ---------- */
@media (max-width: 720px) {
  .mk-nav-links { display: none; }
  .burger { display: inline-flex; margin-left: auto; }
  .mk-section { padding-top: 48px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .sidebar { display: none; }
  .page { padding: 16px; }
  .flow-step { min-width: 100%; padding-right: 0; margin-bottom: 32px; }
  .flow-step:not(:last-child)::after { content: "↓"; right: auto; left: 50%; top: auto; bottom: -26px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr !important; }
  .hide-mobile { display: none !important; }
  .type-display { font-size: 34px; }
  .anno-drawer { display: none; }
  /* mobile product shell: bottom tab bar */
  .mobile-tabs {
    display: flex !important; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: rgb(255 255 255 / 0.95); backdrop-filter: blur(8px); border-top: 1px solid var(--border);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }
  .mobile-tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; font-weight: 500; color: var(--faint); padding: 4px 0; border-radius: 8px; }
  .mobile-tabs a.active { color: var(--primary); }
  body.has-mobile-tabs .page { padding-bottom: 84px; }
}
.mobile-tabs { display: none; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
