/* ═══════════════════════════════════════════════════════════════
   Lattice design system — v2 modern
   Loads AFTER chat.css + animations.css so these tokens and
   component overrides win the cascade. Preserves EY yellow as
   brand anchor and adds a coherent surface / elevation / spacing
   / radius / typography system on top.
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* Brand */
  --brand-yellow:        #FFE600;
  --brand-yellow-600:    #F7B500;
  --brand-yellow-100:    #FFF7B8;
  --brand-charcoal:      #0F1012;
  --brand-charcoal-800:  #1A1B1F;
  --brand-charcoal-600:  #2E2E38;

  /* Surfaces (light-mode base; easy to flip for future dark mode) */
  --surface-0:   #FFFFFF;
  --surface-1:   #FAFAF8;
  --surface-2:   #F4F4EF;
  --surface-3:   #ECECE6;
  --surface-inverse: #0F1012;

  /* Borders & dividers */
  --border-1:    #ECECE6;
  --border-2:    #DDDDD4;
  --border-strong: #2E2E38;

  /* Semantic */
  --success:     #10B981;
  --success-bg:  #E7FAF1;
  --warning:     #F59E0B;
  --warning-bg:  #FEF4DC;
  --danger:      #EF4444;
  --danger-bg:   #FDECEC;
  --info:        #6366F1;
  --info-bg:     #EEF0FF;

  /* Text */
  --text-1:      #0F1012;
  --text-2:      #3A3B41;
  --text-3:      #696A70;
  --text-4:      #9B9CA1;
  --text-inverse: #FAFAF8;

  /* Elevation (hand-tuned for light bg) */
  --shadow-xs: 0 1px 2px rgba(15, 16, 18, 0.04);
  --shadow-sm: 0 2px 6px rgba(15, 16, 18, 0.05), 0 1px 2px rgba(15, 16, 18, 0.04);
  --shadow-md: 0 8px 20px rgba(15, 16, 18, 0.06), 0 2px 4px rgba(15, 16, 18, 0.04);
  --shadow-lg: 0 16px 36px rgba(15, 16, 18, 0.08), 0 4px 8px rgba(15, 16, 18, 0.04);
  --shadow-xl: 0 28px 60px rgba(15, 16, 18, 0.12), 0 8px 16px rgba(15, 16, 18, 0.06);
  --shadow-yellow: 0 8px 24px rgba(247, 181, 0, 0.28);

  /* Radius */
  --r-1: 6px;  --r-2: 10px; --r-3: 14px; --r-4: 20px; --r-pill: 999px;

  /* Spacing scale (4px base) */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-7: 32px; --s-8: 40px; --s-9: 56px;

  /* Typography */
  --font-sans:    'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, 'Liberation Mono', monospace;
  --font-display: 'Inter', var(--font-sans);

  /* Type scale */
  --fs-xs: 11px; --fs-sm: 12.5px; --fs-md: 14px; --fs-lg: 16px;
  --fs-xl: 20px; --fs-2xl: 26px; --fs-3xl: 34px; --fs-4xl: 44px;

  /* Motion */
  --ease-standard: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-bounce:   cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ─── Typography reset ─────────────────────────────────────── */
html, body {
  font-family: var(--font-sans);
  font-feature-settings: 'cv11', 'ss01', 'ss03';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--text-1);
  background: var(--surface-1);
}
h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 700; letter-spacing: -0.018em;
  color: var(--text-1);
}
h1 { font-size: var(--fs-3xl); line-height: 1.12; }
h2 { font-size: var(--fs-2xl); line-height: 1.18; }
h3 { font-size: var(--fs-xl); line-height: 1.25; }
h4 { font-size: var(--fs-lg); line-height: 1.3; font-weight: 600; }
p, li, td { color: var(--text-2); }
code, pre { font-family: var(--font-mono); }

/* ─── Body layout ──────────────────────────────────────────── */
.app-body {
  background:
    radial-gradient(circle at 100% 0%, rgba(255, 230, 0, 0.06), transparent 50%),
    radial-gradient(circle at 0% 100%, rgba(99, 102, 241, 0.04), transparent 55%),
    var(--surface-1);
}

/* ─── Sidebar v2 ───────────────────────────────────────────── */
.app-sidebar {
  background: rgba(255, 255, 255, 0.78) !important;
  border-right: 1px solid var(--border-1);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
}
.sidebar-brand {
  padding: var(--s-6) var(--s-5) var(--s-4);
  border-bottom: 1px solid var(--border-1);
  display: flex; align-items: center; gap: var(--s-3);
}
.sidebar-brand .brand-title {
  font-family: var(--font-display);
  font-weight: 800; font-size: var(--fs-xl);
  letter-spacing: -0.02em; color: var(--text-1);
}
.sidebar-brand .brand-tag {
  font-size: 10.5px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-3); font-weight: 500;
}
.ey-logo-sidebar {
  width: 32px; height: 32px; border-radius: var(--r-1);
  background: linear-gradient(135deg, var(--brand-yellow), var(--brand-yellow-600));
  padding: 2px; box-shadow: var(--shadow-sm);
}
.sidebar-nav {
  display: flex; flex-direction: column;
  padding: var(--s-3) var(--s-2); gap: 2px;
}
.nav-item {
  display: flex !important; align-items: center; gap: var(--s-3) !important;
  padding: 10px var(--s-3) !important;
  border-radius: var(--r-2);
  color: var(--text-2);
  font-size: var(--fs-md); font-weight: 500;
  text-decoration: none;
  transition: all 180ms var(--ease-standard);
}
.nav-item:hover {
  background: var(--surface-2) !important;
  color: var(--text-1);
}
.nav-item.is-active {
  background: linear-gradient(135deg, var(--brand-yellow-100), rgba(255, 230, 0, 0.15)) !important;
  color: var(--text-1); font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(255, 230, 0, 0.35);
}
.nav-item.is-active::before { display: none; }
.nav-item .nav-icon {
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-3); flex-shrink: 0;
}
.nav-item.is-active .nav-icon { color: var(--brand-charcoal); }
.nav-item .nav-icon svg { width: 18px; height: 18px; stroke-width: 1.6; }
.sidebar-foot {
  padding: var(--s-3) var(--s-3) var(--s-4);
  border-top: 1px solid var(--border-1); margin-top: auto;
}
.sidebar-live { padding: var(--s-2) var(--s-3); margin-bottom: var(--s-2); }
.user-chip {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-3); border-radius: var(--r-2);
  text-decoration: none; color: var(--text-2);
  transition: background 180ms var(--ease-standard);
}
.user-chip:hover { background: var(--surface-2); }
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-yellow), var(--brand-yellow-600));
  color: var(--brand-charcoal);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
  box-shadow: var(--shadow-sm);
}
.user-meta .user-name { font-weight: 600; font-size: var(--fs-md); color: var(--text-1); }
.user-meta .user-sub  { font-size: var(--fs-xs); color: var(--text-3); }

/* ─── Topbar v2 ────────────────────────────────────────────── */
.topbar {
  background: rgba(255, 255, 255, 0.80) !important;
  backdrop-filter: saturate(160%) blur(14px) !important;
  -webkit-backdrop-filter: saturate(160%) blur(14px) !important;
  border-bottom: 1px solid var(--border-1);
  padding: var(--s-3) var(--s-6);
}
.breadcrumb {
  display: flex; align-items: center; gap: var(--s-2);
  font-size: var(--fs-md); color: var(--text-3);
}
.breadcrumb a { color: var(--text-3); text-decoration: none; }
.breadcrumb a:hover { color: var(--text-1); }
.crumb-current { color: var(--text-1); font-weight: 600; }
.crumb-sep { color: var(--border-2); }
.topbar-search {
  position: relative;
  display: flex; align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  border-radius: var(--r-pill);
  padding: 0 var(--s-4);
  transition: border-color 180ms, background 180ms;
}
.topbar-search:focus-within {
  background: var(--surface-0);
  border-color: var(--brand-yellow);
  box-shadow: 0 0 0 3px rgba(255, 230, 0, 0.14);
}
.topbar-search input {
  border: 0; background: transparent;
  padding: 8px 0 8px 6px;
  font-size: var(--fs-md); min-width: 260px;
  color: var(--text-1); outline: none;
}
.topbar-search-icon {
  width: 16px; height: 16px;
  margin-right: var(--s-1);
  color: var(--text-3);
}

/* ─── Page container ──────────────────────────────────────── */
.page {
  max-width: 1440px;
  margin: 0 auto;
  padding: var(--s-6) var(--s-7);
}
@media (max-width: 860px) { .page { padding: var(--s-5) var(--s-4); } }

/* ─── Buttons v2 ──────────────────────────────────────────── */
.btn, .btn-primary, .btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  padding: 9px var(--s-4);
  border-radius: var(--r-2);
  font-family: var(--font-sans); font-size: var(--fs-md);
  font-weight: 600; letter-spacing: -0.006em;
  cursor: pointer; text-decoration: none;
  border: 1px solid transparent;
  transition: transform 180ms var(--ease-standard),
              box-shadow 220ms var(--ease-standard),
              filter 180ms var(--ease-standard),
              background 180ms ease, color 180ms ease;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--brand-yellow) 0%, var(--brand-yellow-600) 100%);
  color: var(--brand-charcoal);
  box-shadow: var(--shadow-yellow);
}
.btn-primary:hover {
  transform: translateY(-1px); filter: brightness(1.03);
  box-shadow: 0 12px 28px rgba(247, 181, 0, 0.38);
}
.btn-ghost {
  background: var(--surface-0); color: var(--text-1);
  border-color: var(--border-2); box-shadow: var(--shadow-xs);
}
.btn-ghost:hover {
  background: var(--surface-2); border-color: var(--text-3);
  transform: translateY(-1px);
}
.btn:disabled, .btn-primary:disabled, .btn-ghost:disabled {
  opacity: 0.45; cursor: not-allowed; pointer-events: none;
}
.link-btn {
  background: transparent; border: 0;
  color: var(--text-2);
  font-family: var(--font-sans); font-size: var(--fs-sm); font-weight: 500;
  padding: 4px 8px; border-radius: var(--r-1); cursor: pointer;
  transition: all 180ms ease;
}
.link-btn:hover { background: var(--surface-2); color: var(--text-1); }
.link-btn--danger { color: var(--danger); }
.link-btn--danger:hover { background: var(--danger-bg); color: var(--danger); }

/* ─── Inputs / selects / textareas ────────────────────────── */
input[type="text"], input[type="number"], input[type="date"], input[type="search"],
input[type="email"], input[type="tel"], input[type="url"], input[type="password"],
select, textarea {
  font-family: var(--font-sans); font-size: var(--fs-md);
  color: var(--text-1); background: var(--surface-0);
  border: 1px solid var(--border-2); border-radius: var(--r-2);
  padding: 8px 12px;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}
input:hover, select:hover, textarea:hover { border-color: var(--text-3); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand-yellow);
  box-shadow: 0 0 0 3px rgba(255, 230, 0, 0.18);
}
textarea { resize: vertical; line-height: 1.55; }

/* ─── Cards / panels v2 ───────────────────────────────────── */
.panel, .doc-module, .kpi-card, .meth-card, .rag-tile, .ctc-tile,
.budget-metric, .raid-card, .eng-card {
  background: var(--surface-0);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-xs);
}
.panel { padding: 0; overflow: hidden; }
.panel-head {
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border-1);
  background: linear-gradient(180deg, var(--surface-0), var(--surface-1));
}
.panel-head--split { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-5); }
.panel-head h2 { margin: 0; font-size: var(--fs-lg); font-weight: 700; letter-spacing: -0.012em; }
.panel-sub { color: var(--text-3); font-size: var(--fs-sm); margin: 4px 0 0; }
.panel-body { padding: var(--s-4) var(--s-5); }
.panel-actions { display: flex; align-items: center; gap: var(--s-2); }

/* KPI v2 */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-4); margin: var(--s-6) 0; }
@media (max-width: 1000px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .kpi-grid { grid-template-columns: 1fr; } }
.kpi-card { padding: var(--s-5); position: relative; overflow: hidden; }
.kpi-card::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 100% 0%, rgba(255, 230, 0, 0.08), transparent 60%);
  opacity: 0; transition: opacity 220ms ease;
}
.kpi-card:hover::before { opacity: 1; }
.kpi-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-3); }
.kpi-value {
  font-family: var(--font-display);
  font-size: var(--fs-3xl); font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-1); margin: 6px 0 4px;
  font-variant-numeric: tabular-nums;
}
.kpi-sub { font-size: var(--fs-sm); color: var(--text-3); }
.kpi-card--accent {
  background: linear-gradient(135deg, var(--brand-charcoal) 0%, var(--brand-charcoal-800) 100%);
  border-color: var(--brand-charcoal);
  color: var(--text-inverse);
}
.kpi-card--accent .kpi-label { color: var(--brand-yellow); }
.kpi-card--accent .kpi-value { color: var(--surface-0); }
.kpi-card--accent .kpi-sub   { color: rgba(250, 250, 248, 0.6); }
.kpi-total { font-size: var(--fs-xl); color: var(--text-3); font-weight: 600; }

/* ─── Hero ────────────────────────────────────────────────── */
.hero { padding: var(--s-7) var(--s-5) var(--s-5); position: relative; }
.hero-eyebrow { font-size: var(--fs-sm); font-weight: 600; color: var(--text-3); letter-spacing: 0.02em; }
.hero-title {
  font-family: var(--font-display);
  font-size: var(--fs-4xl);
  letter-spacing: -0.035em; font-weight: 800;
  margin: 10px 0 8px; line-height: 1.05;
  background: linear-gradient(180deg, var(--text-1) 0%, var(--text-2) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub { font-size: var(--fs-lg); color: var(--text-3); max-width: 720px; }

/* ─── Status chips v2 ──────────────────────────────────────── */
.status-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--border-1);
}
.status-chip.status-active    { background: var(--success-bg); color: #047857; border-color: #b9f0d6; }
.status-chip.status-on_hold   { background: var(--warning-bg); color: #b45309; border-color: #fde7b3; }
.status-chip.status-archived,
.status-chip.status-closed    { background: var(--surface-2); color: var(--text-3); }
.status-chip.status-proposed  { background: var(--info-bg); color: #4338ca; border-color: #dadfff; }

/* ─── Tables v2 ──────────────────────────────────────────── */
.fb-table, .bm-table, .data-table {
  width: 100%; border-collapse: collapse; font-size: var(--fs-md);
  background: var(--surface-0);
}
.fb-table th, .bm-table th, .data-table th {
  text-align: left; font-size: var(--fs-xs); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-3);
  padding: 10px var(--s-3);
  border-bottom: 1px solid var(--border-1);
  background: var(--surface-1);
}
.fb-table td, .bm-table td, .data-table td {
  padding: 12px var(--s-3);
  border-bottom: 1px solid var(--border-1);
  color: var(--text-2); vertical-align: middle;
}
.fb-table tr:last-child td { border-bottom: 0; }

/* ─── Meta chips ─────────────────────────────────────────── */
.meta-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  border-radius: var(--r-pill);
  font-size: var(--fs-sm); color: var(--text-2);
}
.meta-chip strong { color: var(--text-1); font-weight: 600; }
.meta-chip input, .meta-chip select {
  border: 0; background: transparent; padding: 0 2px;
  font-weight: 600; color: var(--text-1); font-size: var(--fs-sm);
}
.meta-chip input:focus, .meta-chip select:focus { box-shadow: none; }

/* ─── Doc head / eng head ────────────────────────────────── */
.doc-head, .eng-head {
  padding: var(--s-7) 0 var(--s-5);
  border-bottom: 1px solid var(--border-1);
  margin-bottom: var(--s-6);
}
.eng-head-code, .doc-head .eng-head-code {
  display: inline-block;
  padding: 3px 10px;
  background: var(--brand-charcoal);
  color: var(--brand-yellow);
  border-radius: var(--r-1);
  font-family: var(--font-mono); font-size: var(--fs-xs);
  font-weight: 600; letter-spacing: 0.04em;
  margin-bottom: var(--s-3);
}
.eng-head-meta { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-3); }

/* ─── Doc-hub cards v2 ───────────────────────────────────── */
.docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--s-4);
}
.doc-module { padding: 0; }
.doc-module-head {
  padding: var(--s-5);
  display: flex; gap: var(--s-4); align-items: flex-start; justify-content: space-between;
  border-bottom: 1px solid var(--border-1);
}
.doc-kind {
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-3); font-weight: 600; margin-bottom: 4px;
}
.doc-module h2 { margin: 0; font-size: var(--fs-lg); line-height: 1.25; }
.doc-sub { font-size: var(--fs-sm); color: var(--text-3); margin-top: 4px; line-height: 1.5; }
.doc-list { list-style: none; margin: 0; padding: var(--s-3) 0; }
.doc-list > li { padding: 0 var(--s-3); }
.doc-card {
  display: block;
  padding: 10px var(--s-3);
  border-radius: var(--r-2);
  text-decoration: none; color: inherit;
  transition: background 180ms ease;
}
.doc-card:hover { background: var(--surface-2); }
.doc-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.doc-card-id  { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-3); font-weight: 600; letter-spacing: 0.04em; }
.doc-card-title { font-weight: 600; font-size: var(--fs-md); color: var(--text-1); line-height: 1.35; }
.doc-card-foot {
  display: flex; justify-content: space-between; gap: var(--s-2);
  margin-top: 6px;
  font-size: 11.5px; color: var(--text-3);
}
.doc-empty {
  padding: var(--s-4) var(--s-3);
  color: var(--text-3); font-size: var(--fs-sm); text-align: center;
  border-top: 1px dashed var(--border-1);
}

/* ─── Section heads ─────────────────────────────────────── */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--s-4); margin-top: var(--s-6);
}
.section-head h2 { margin: 0; font-size: var(--fs-xl); }
.section-link { font-size: var(--fs-sm); color: var(--text-3); text-decoration: none; font-weight: 500; }
.section-link:hover { color: var(--text-1); }

/* ─── Tabs ──────────────────────────────────────────────── */
.tabs, .tab-row {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border-1);
  margin-top: var(--s-5);
  overflow-x: auto;
}
.tab {
  padding: 10px var(--s-4);
  color: var(--text-3); font-size: var(--fs-md); font-weight: 500;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color 160ms ease, border-color 160ms ease;
  white-space: nowrap;
}
.tab:hover { color: var(--text-1); }
.tab.is-active { color: var(--text-1); border-bottom-color: var(--brand-yellow); font-weight: 600; }

/* ─── Agent ring ────────────────────────────────────────── */
.agent-ring {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-yellow), var(--info));
  padding: 2px; box-shadow: var(--shadow-sm);
}
.agent-ring > span {
  width: 100%; height: 100%; border-radius: 50%;
  background: var(--surface-0);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-size: 12px;
  color: var(--text-1);
}

/* ─── Activity dots ─────────────────────────────────────── */
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--info); margin-top: 7px; }
.activity-dot.kind-message { background: var(--info); }
.activity-dot.kind-ticket  { background: var(--warning); }
.activity-dot.kind-sow,
.activity-dot.kind-estimate,
.activity-dot.kind-deck,
.activity-dot.kind-rfp { background: var(--brand-yellow-600); }

/* ─── RAG tiles v2 ──────────────────────────────────────── */
.rag-tile {
  padding: var(--s-4) var(--s-5);
  background: var(--surface-0);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-xs);
}
.rag-tile::before { border-radius: var(--r-3) 0 0 var(--r-3); }
.rag-tile.rag-green  { box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.15), var(--shadow-xs); }
.rag-tile.rag-amber  { box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.20), var(--shadow-xs); }
.rag-tile.rag-red    { box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.22), var(--shadow-xs); }

/* ─── CTC v2 ────────────────────────────────────────────── */
.ctc-tile { padding: var(--s-5); }
.ctc-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-3); font-weight: 600; }
.ctc-value { font-family: var(--font-display); font-size: var(--fs-2xl); font-weight: 800; letter-spacing: -0.022em; color: var(--text-1); margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.ctc-sub { color: var(--text-3); }

/* ─── kbd ─────────────────────────────────────────────────── */
kbd, .kbd {
  display: inline-flex; align-items: center;
  font-family: var(--font-mono); font-size: 10.5px;
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px; color: var(--text-2);
}

/* ─── Small-screen sidebar ──────────────────────────────── */
@media (max-width: 860px) {
  .app-body { grid-template-columns: 1fr !important; }
  .app-sidebar { position: static !important; height: auto; border-right: 0; border-bottom: 1px solid var(--border-1); }
  .sidebar-foot, .sidebar-live { display: none; }
  .sidebar-nav { flex-direction: row !important; overflow-x: auto; padding: var(--s-2); }
  .nav-item { white-space: nowrap; }
}

/* ─── Engagement card polish ────────────────────────────── */
.eng-card {
  display: block;
  padding: var(--s-4);
  text-decoration: none; color: inherit;
  transition: transform 180ms var(--ease-standard), box-shadow 220ms var(--ease-standard), border-color 180ms;
}
.eng-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--brand-yellow);
}
.eng-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-2); }
.eng-code { font-family: var(--font-mono); font-size: var(--fs-sm); font-weight: 600; color: var(--text-3); letter-spacing: 0.04em; }
.eng-name { font-weight: 600; font-size: var(--fs-md); color: var(--text-1); line-height: 1.35; margin-bottom: 4px; }
.eng-meta { display: flex; flex-wrap: wrap; gap: var(--s-2); font-size: var(--fs-xs); color: var(--text-3); }
.eng-dot { color: var(--border-2); }

/* ─── Toast refinement ────────────────────────────────────── */
#lattice-toast-host { top: var(--s-5); right: var(--s-5); }
.toast {
  background: var(--brand-charcoal) !important;
  color: var(--surface-0);
  border-radius: var(--r-2);
  border-left-width: 3px;
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm);
}

/* ─── Command palette ────────────────────────────────────── */
#lattice-cmdk {
  position: fixed; inset: 0; z-index: 100000;
  display: none; align-items: flex-start; justify-content: center;
  padding-top: 12vh;
}
#lattice-cmdk.is-open { display: flex; }
.cmdk-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 16, 18, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fadeIn 180ms ease;
}
.cmdk-panel {
  position: relative;
  width: min(640px, 92vw);
  max-height: 72vh;
  background: var(--surface-0);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  display: flex; flex-direction: column;
  animation: cmdk-in 220ms var(--ease-bounce);
}
@keyframes cmdk-in {
  from { opacity: 0; transform: translateY(-12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.cmdk-input-row {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 14px var(--s-5);
  border-bottom: 1px solid var(--border-1);
}
.cmdk-icon { width: 18px; height: 18px; color: var(--text-3); flex-shrink: 0; }
.cmdk-input {
  flex: 1 1 auto;
  border: 0 !important; outline: none !important;
  background: transparent !important;
  font-family: var(--font-sans); font-size: var(--fs-lg) !important;
  color: var(--text-1); padding: 0 !important;
  box-shadow: none !important;
}
.cmdk-esc {
  font-family: var(--font-mono); font-size: 10.5px;
  background: var(--surface-2); color: var(--text-3);
  border: 1px solid var(--border-1); border-bottom-width: 2px;
  border-radius: 4px; padding: 1px 6px;
}
.cmdk-list {
  overflow-y: auto; padding: 6px;
  min-height: 60px;
}
.cmdk-group {
  padding: 8px 10px 4px;
  font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-3); font-weight: 600;
}
.cmdk-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--r-1);
  cursor: pointer;
  transition: background 120ms ease;
}
.cmdk-item.is-cursor {
  background: linear-gradient(135deg, rgba(255,230,0,0.18), rgba(255,230,0,0.05));
  outline: 1px solid rgba(255,230,0,0.35);
}
.cmdk-item-label { font-size: var(--fs-md); font-weight: 500; color: var(--text-1); }
.cmdk-item-hint  { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.cmdk-chev { width: 16px; height: 16px; color: var(--text-4); }
.cmdk-empty { padding: 28px; text-align: center; color: var(--text-3); font-size: var(--fs-sm); }
.cmdk-footer {
  display: flex; gap: var(--s-4);
  padding: 10px var(--s-5);
  border-top: 1px solid var(--border-1);
  background: var(--surface-1);
  font-size: 11.5px; color: var(--text-3);
}
.cmdk-footer kbd {
  background: var(--surface-0); border: 1px solid var(--border-1); border-bottom-width: 2px;
  border-radius: 3px; padding: 1px 5px; margin-right: 3px;
  font-family: var(--font-mono); font-size: 10.5px;
}
@media (prefers-reduced-motion: reduce) {
  .cmdk-panel, .cmdk-backdrop { animation: none !important; }
}

/* ─── Print clean ────────────────────────────────────────── */
@media print {
  .app-sidebar, .topbar, #lattice-toast-host, #lattice-cmdk { display: none !important; }
  .page { padding: 0; }
}
