
  @import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@300;400;500;600&family=Poppins:wght@400;500&display=swap');

  :root {
    --bg: #0D1117;
    --surface: #161B22;
    --surface2: #1C2330;
    --border: #30363D;
    --text: #CDD9E5;
    --text-dim: #768390;
    --text-bright: #ADBAC7;
    --teal: #00C9A7;
    --teal-dim: rgba(0,201,167,0.12);
    --s1: #6B7280; --s1-bg: rgba(107,114,128,0.1);
    --s2: #60A5FA; --s2-bg: rgba(96,165,250,0.1);
    --s3: #FBBF24; --s3-bg: rgba(251,191,36,0.1);
    --s4: #34D399; --s4-bg: rgba(52,211,153,0.1);
    --s5: #A78BFA; --s5-bg: rgba(167,139,250,0.1);
    --role-architect: #E9D08A;            /* wheat (dark theme) */
    --role-architect-ink: #1C2024;        /* readable text on the wheat fill (dark text) */
    --role-restore: #60A5FA;
    --role-builder: #34D399;
    --origin-external: #D6A461;
    --tier1: #34D399; --tier1-bg: rgba(52,211,153,0.1); --tier1-border: rgba(52,211,153,0.25);
    --tier2: #60A5FA; --tier2-bg: rgba(96,165,250,0.1); --tier2-border: rgba(96,165,250,0.25);
    --tier3: #F97316; --tier3-bg: rgba(249,115,22,0.1); --tier3-border: rgba(249,115,22,0.25);
    --fallback: #E5484D;
  }

  /* ── Light theme ── */
  body.light {
    --bg: #F5F6F8;
    --surface: #FFFFFF;
    --surface2: #F0F1F3;
    --border: #D8DAE0;
    --text: #1C2024;
    --text-dim: #60646C;
    --text-bright: #2C3036;
    --teal: #008573;
    --teal-dim: rgba(0,133,115,0.08);
    --s1: #6B7280; --s1-bg: rgba(107,114,128,0.08);
    --s2: #2563EB; --s2-bg: rgba(37,99,235,0.06);
    --s3: #D97706; --s3-bg: rgba(217,119,6,0.06);
    --s4: #059669; --s4-bg: rgba(5,150,105,0.06);
    --s5: #7C3AED; --s5-bg: rgba(124,58,237,0.06);
    --s6: #DC2626; --s6-bg: rgba(220,38,38,0.06);
    --role-architect: #7A5D17;            /* deep bronze (light theme) */
    --role-architect-ink: #FFFFFF;        /* readable text on the bronze fill (white text) */
    --role-restore: #1D4ED8;
    --role-builder: #047857;
    --origin-external: #B07A2E;
    --tier1: #059669; --tier1-bg: rgba(5,150,105,0.08); --tier1-border: rgba(5,150,105,0.25);
    --tier2: #2563EB; --tier2-bg: rgba(37,99,235,0.06); --tier2-border: rgba(37,99,235,0.2);
    --tier3: #D97706; --tier3-bg: rgba(217,119,6,0.06); --tier3-border: rgba(217,119,6,0.2);
    --fallback: #DC2626;
  }

  /* Light theme overrides for elements with hardcoded colors */
  body.light .card { border-color: var(--border); }
  body.light .card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
  body.light .spec-chip { background: var(--surface2); border-color: var(--border); }
  body.light .card-candidate { background: var(--surface2); border-color: rgba(37,99,235,0.15); }
  body.light .card-candidate-label { color: var(--role-restore); }
  body.light .inv-card { background: var(--surface2); border-color: var(--border); }
  body.light .pin-modal { background: var(--surface); border-color: var(--pin-accent, var(--border)); }
  body.light .pin-input { background: var(--surface2); border-color: var(--border); color: var(--text); }
  body.light .modal { background: var(--surface); border-color: var(--border); }
  body.light .activity-entry { background: var(--surface2); border-color: var(--border); }
  body.light textarea { background: var(--surface2); border-color: var(--border); color: var(--text); }
  body.light .form-input { background: var(--surface2); border-color: var(--border); color: var(--text); }
  body.light .csv-preview { background: var(--surface2); border-color: var(--border); }
  body.light .deadline-input { background: var(--surface2); border-color: var(--border); color: var(--text); }
  body.light .log-select { background: var(--surface2); border-color: var(--border); color: var(--text); }

  /* ── Theme toggle ── */
  .theme-toggle {
    background: none; border: 1px solid var(--border); border-radius: 4px;
    color: var(--text-dim); cursor: pointer; padding: 3px 8px; font-size: 13px;
    line-height: 1; transition: all 0.15s;
  }
  .theme-toggle:hover { border-color: var(--text-dim); color: var(--text); }

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

  body {
    font-family: 'IBM Plex Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 13px;
  }

  .mono { font-family: 'IBM Plex Mono', monospace; }

  /* ── Tier 1: Identity bar ── */
  .identity-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 10px 20px;
    display: flex;
    align-items: flex-end;          /* bottom-align both columns */
    justify-content: space-between;
    gap: 16px;
    min-height: 100px;
    position: sticky;
    top: 0;
    z-index: 100;
  }

  /* ── Tier 2: View tabs ── */
  :root { --identity-height: 42px; }
  .view-tabs {
    background: var(--surface2);
    border-bottom: 2px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
    padding: 10px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: sticky;
    top: var(--identity-height, 42px);
    z-index: 99;
  }
  body.light .view-tabs { box-shadow: 0 2px 6px rgba(0,0,0,0.06); }

  /* Row containers */
  .view-tab-pipeline-row { display: flex; }
  .view-tabs-roles { display: flex; gap: 8px; }

  /* All pills */
  .view-tab {
    padding: 7px 18px; border-radius: 20px;
    border: 1px solid var(--border); background: transparent; color: var(--text-dim);
    font-family: 'IBM Plex Sans', sans-serif; font-size: 13px; font-weight: 500;
    cursor: pointer; transition: all 0.15s; letter-spacing: 0.02em; white-space: nowrap;
  }
  .view-tab:hover { color: var(--text); border-color: var(--text-dim); }
  .view-tab.active {
    color: var(--active-tab-color, var(--teal));
    border-color: var(--active-tab-color, var(--teal));
    font-weight: 600;
  }

  /* Pipeline pill: full width, label normal weight, count italic */
  .view-tab.tab-pipeline { width: 100%; text-align: center; font-size: 14px; }
  .view-tab.tab-pipeline .tab-count { font-style: italic; }

  /* Role pills: equal width, brighter inactive */
  .view-tabs-roles .view-tab { flex: 1; text-align: center; color: var(--text-bright); }
  .view-tabs-roles .view-tab:hover { color: var(--text); }

  .view-tab .tab-count {
    font-family: 'IBM Plex Mono', monospace; font-size: 10px;
    background: rgba(255,255,255,0.06); border-radius: 8px; padding: 0 6px;
    margin-left: 6px;
  }
  /* Divider not used in two-row pill layout */
  .view-tab-divider { display: none; }

  @media (max-width: 640px) {
    .view-tabs { padding: 8px 12px; gap: 6px; }
    .view-tab { font-size: 12px; padding: 6px 14px; }
    .view-tabs-roles .view-tab { font-size: 11px; padding: 6px 8px; }
    .view-tabs-roles .tab-count { display: none; }
  }

  /* ── Tier 3: Context bar ── */
  .context-bar {
    padding: 6px 20px; display: flex; gap: 6px; align-items: center;
    background: var(--bg); border-bottom: 1px solid var(--border); flex-wrap: wrap;
  }

  /* ── Admin drawer ── */
  .admin-toggle {
    background: none; border: 1px solid var(--border); border-radius: 4px;
    color: var(--text-dim); cursor: pointer; padding: 3px 8px; font-size: 11px;
    font-family: 'IBM Plex Sans', sans-serif; transition: all 0.15s;
    display: flex; align-items: center; gap: 4px;
  }
  .admin-toggle:hover { border-color: var(--text-dim); color: var(--text); }
  .admin-toggle.open { border-color: var(--role-architect); color: var(--role-architect); }
  .admin-drawer {
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 12px 20px; display: none;
  }
  .admin-drawer.open { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
  .admin-section-label {
    font-size: 10px; color: var(--text-dim); text-transform: uppercase;
    letter-spacing: 0.06em; margin-right: 4px;
  }
  .admin-divider { width: 100%; height: 1px; background: var(--border); margin: 2px 0; }

  /* ── Dev "View as" banner ── */
  .devview-banner {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    background: #60A5FA; color: #06182f;
    padding: 6px 14px; font-size: 12px; font-weight: 500;
  }
  .devview-exit {
    margin-left: auto; background: rgba(6,24,47,0.18); color: #06182f;
    border: 1px solid rgba(6,24,47,0.35); border-radius: 5px;
    padding: 3px 12px; font-size: 11px; font-weight: 600; cursor: pointer;
  }
  .devview-exit:hover { background: rgba(6,24,47,0.30); }

  /* ── PIN modal ── */
  .pin-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 300;
    display: flex; align-items: center; justify-content: center;
  }
  .pin-modal {
    background: var(--surface); border: 1px solid var(--pin-accent, var(--border)); border-radius: 8px;
    padding: 24px 32px; text-align: center; min-width: 280px;
  }
  .pin-modal-title {
    font-size: 14px; color: var(--text-bright); margin-bottom: 4px;
  }
  .pin-modal-role {
    font-family: 'IBM Plex Mono', monospace; font-size: 12px;
    margin-bottom: 16px;
  }
  .pin-input {
    background: var(--surface2); border: 1px solid var(--border); border-radius: 6px;
    color: var(--text); font-family: 'IBM Plex Mono', monospace; font-size: 20px;
    padding: 10px 16px; width: 140px; text-align: center; letter-spacing: 0.3em;
    outline: none; transition: border-color 0.15s;
  }
  .pin-input:focus { border-color: var(--pin-accent, var(--teal)); }
  .pin-input.error { border-color: #E5484D; animation: shake 0.3s; }
  @keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }
  .pin-error-msg { color: #E5484D; font-size: 11px; margin-top: 8px; min-height: 16px; }
  .pin-actions { margin-top: 16px; display: flex; gap: 8px; justify-content: center; }
  .pin-remember {
    display: flex; align-items: center; gap: 6px; margin-top: 12px; justify-content: center;
    font-size: 11px; color: var(--text-dim);
  }
  .pin-remember input { accent-color: var(--teal); }

  /* ── PIN management in admin ── */
  .pin-config-row {
    display: flex; align-items: center; gap: 8px; font-size: 11px;
  }
  .pin-config-label {
    font-family: 'IBM Plex Mono', monospace; font-size: 11px; width: 70px;
  }
  .pin-config-input {
    background: var(--surface2); border: 1px solid var(--border); border-radius: 3px;
    color: var(--text); font-family: 'IBM Plex Mono', monospace; font-size: 11px;
    padding: 3px 6px; width: 60px; text-align: center; outline: none;
  }
  .pin-config-input:focus { border-color: var(--teal); }

  .logo {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    color: var(--teal);
    letter-spacing: 0.08em;
    font-weight: 500;
    flex-shrink: 0;
  }
  .logo span { color: var(--text-dim); }

  /* Project logo (inline SVG, js/logo.js). Fills bound to the pipeline palette so
     the mark auto-adapts to light/dark. cls-3 separators rendered transparent.
     cls-2 is FIXED wheat in both themes (decoupled from --role-architect, which
     darkens to bronze on light) so the brand swoosh stays constant. */
  .app-logo-svg { display: block; height: 100%; width: auto; }
  .app-logo-svg .cls-2 { fill: #E9D08A; }
  .app-logo-svg .cls-3 { fill: transparent; }
  .app-logo-svg .cls-4 { fill: var(--teal); }
  .app-logo-svg .cls-5 { fill: var(--role-restore); }
  .app-logo-svg .cls-1 { font-family: 'Poppins', 'IBM Plex Sans', sans-serif; }
  /* Header (G4): logo mark beside the stacked project name + GWP. */
  .ident-left .logo-mark { display: inline-flex; height: 46px; width: auto; flex-shrink: 0; }
  .ident-left .logo-mark .app-logo-svg { height: 46px; }
  /* Login: mark above an HTML wordmark (so size/spacing/font are controllable). */
  .login-logo { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 14px; }
  .login-logo .login-mark { display: inline-flex; height: 88px; }
  .login-logo .login-mark .app-logo-svg { height: 88px; }
  .login-wordmark {
    font-family: 'Poppins', 'IBM Plex Sans', sans-serif; font-weight: 500;
    font-size: 30px; line-height: 1; letter-spacing: 0.005em;
  }
  .login-wordmark .wm-re { color: var(--role-restore); }
  .login-wordmark .wm-verify { color: var(--teal); }

  /* ── Identity bar (G4) layout ── */
  .ident-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
  .ident-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
  .ident-proj {
    font-family: 'IBM Plex Sans', sans-serif; font-size: 15px; font-weight: 600;
    color: var(--text-bright); letter-spacing: 0.01em; white-space: nowrap;
  }
  .ident-gwp {
    display: flex; align-items: center; gap: 6px;
    font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--text-dim);
  }
  .ident-gwp strong { color: #34D399; font-weight: 600; }
  body.light .ident-gwp strong { color: #008573; }
  .ident-gwp-ico { width: 13px; height: 13px; flex: 0 0 auto; display: inline-flex; color: #34D399; }
  .ident-gwp-ico svg { width: 100%; height: 100%; display: block; }
  body.light .ident-gwp-ico { color: #008573; }
  /* Right cluster: role · theme · Live on one row (bottoms aligned); version
     centred directly beneath Live. role/theme are lifted by the version's height
     so all three badges share a baseline while the version drops below Live. */
  .ident-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
  .ident-conn { display: flex; flex-direction: column; align-items: center; gap: 2px; }
  .ident-ver { font-size: 9px; color: var(--text-dim); letter-spacing: 0.04em; text-align: center; }
  /* Role button — square mark-above-label, mirroring the login role-picker. Sits
     far right; theme toggle + Live/version badge are to its left. */
  .role-chip {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; width: 56px; height: 56px; padding: 5px; box-sizing: border-box;
    border: 1px solid var(--border); border-radius: 8px; background: transparent;
    cursor: pointer; font-family: 'IBM Plex Sans', sans-serif;
    transition: filter 0.12s, background 0.12s;
  }
  .role-chip:hover { filter: brightness(1.12); }
  .role-chip-ico { display: inline-flex; align-items: center; height: 22px; }
  .role-chip-ico svg { height: 22px; width: auto; }
  /* Fit within the 56px square chip's content box (~44px wide, 22px mark slot):
     constrain both axes so wide or tall logos scale down to contain, never
     overflow the bordered button. */
  .role-chip-logo { max-height: 22px; max-width: 44px; width: auto; height: auto; object-fit: contain; }
  .role-chip-label { font-size: 9px; font-weight: 500; line-height: 1; }
  .role-chip.Architect { border-color: var(--role-architect); color: var(--role-architect); background: rgba(233,208,138,0.10); }
  .role-chip.ReStore  { border-color: var(--role-restore);  color: var(--role-restore);  background: rgba(96,165,250,0.08); }
  .role-chip.Builder  { border-color: var(--role-builder);  color: var(--role-builder);  background: rgba(52,211,153,0.08); }

  .header-sep { width: 1px; height: 20px; background: var(--border); flex-shrink: 0; }

  .stat-pill {
    background: var(--surface2); border: 1px solid var(--border); border-radius: 4px;
    padding: 3px 10px; font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--text-dim);
  }
  .stat-pill strong { color: var(--teal); }
  .stat-pill.gwp-pill {
    background: rgba(52,211,153,0.08); border-color: rgba(52,211,153,0.3); color: #34D399;
  }
  .stat-pill.gwp-pill strong { color: #34D399; }
  body.light .stat-pill.gwp-pill {
    background: rgba(0,133,115,0.08); border-color: rgba(0,133,115,0.3); color: #008573;
  }
  body.light .stat-pill.gwp-pill strong { color: #008573; }

  /* ── GWP admin editor ── */
  .gwp-admin-block {
    width: 100%; margin-top: 10px; padding: 10px;
    background: var(--surface2); border: 1px solid var(--border); border-radius: 4px;
  }
  /* Shared expanded-section wrapper: border + background that visibly
     encapsulate the section's toggle and its content (the GWP-block look,
     unified across every admin drawer). */
  .admin-block {
    width: 100%; min-width: 340px; padding: 10px;
    background: var(--surface2); border: 1px solid var(--border); border-radius: 6px;
  }
  .gwp-residual-row {
    display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
    padding-bottom: 8px; border-bottom: 1px solid var(--border);
  }
  .gwp-residual-row label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
  .gwp-residual-row input[type=range] { flex: 1; max-width: 200px; }
  .gwp-residual-row .gwp-residual-value { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--text-bright); min-width: 45px; text-align: right; }
  .gwp-ref-table { width: 100%; font-size: 11px; border-collapse: collapse; }
  .gwp-ref-table th { text-align: left; padding: 4px 6px; font-size: 9px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); border-bottom: 1px solid var(--border); }
  .gwp-ref-table td { padding: 3px 6px; border-bottom: 1px solid var(--border); }
  .gwp-ref-table input { background: var(--bg); border: 1px solid var(--border); border-radius: 3px; color: var(--text); font-family: inherit; font-size: 11px; padding: 2px 5px; outline: none; }
  .gwp-ref-table input:focus { border-color: var(--teal); }
  .gwp-ref-table input.gwp-num { width: 60px; font-family: 'IBM Plex Mono', monospace; text-align: right; }
  .gwp-ref-table input.gwp-unit { width: 45px; font-family: 'IBM Plex Mono', monospace; }
  .gwp-ref-table input.gwp-source { width: 220px; }

  /* ── Per-item GWP block in modal ── */
  .gwp-item-block {
    margin: 10px 0; padding: 10px;
    background: rgba(52,211,153,0.04); border: 1px solid rgba(52,211,153,0.2); border-radius: 4px;
  }
  body.light .gwp-item-block { background: rgba(0,133,115,0.04); border-color: rgba(0,133,115,0.2); }
  .gwp-item-row { display: flex; justify-content: space-between; align-items: baseline; padding: 2px 0; font-size: 11px; }
  .gwp-item-row .gwp-item-label { color: var(--text-dim); }
  .gwp-item-row .gwp-item-value { font-family: 'IBM Plex Mono', monospace; color: var(--text-bright); }
  .gwp-item-row .gwp-item-value.warn { color: #FBBF24; }
  .gwp-item-row .gwp-item-value.error { color: #E5484D; }
  .gwp-source-chip {
    display: inline-block; font-size: 9px; padding: 1px 6px; border-radius: 3px;
    text-transform: uppercase; letter-spacing: 0.05em;
    background: var(--surface2); border: 1px solid var(--border); color: var(--text-dim);
  }
  .gwp-source-chip.override { color: #FBBF24; border-color: rgba(251,191,36,0.4); }
  .gwp-source-chip.default { color: #34D399; border-color: rgba(52,211,153,0.4); }
  .gwp-source-chip.warn { color: #FBBF24; border-color: rgba(251,191,36,0.4); }
  .gwp-source-chip.error { color: #E5484D; border-color: rgba(229,72,77,0.4); }

  /* ── Toolbar ── */
  .toolbar {
    padding: 8px 20px; display: flex; gap: 8px; align-items: center;
    background: var(--bg); border-bottom: 1px solid var(--border); flex-wrap: wrap;
  }

  .filter-label { color: var(--text-dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; flex-shrink: 0; }

  .filter-btn {
    padding: 3px 10px; border-radius: 3px; border: 1px solid var(--border);
    background: transparent; color: var(--text-dim); cursor: pointer; font-size: 11px;
    white-space: nowrap; flex-shrink: 0; font-family: 'IBM Plex Sans', sans-serif; transition: all 0.12s;
  }
  .filter-btn.active, .filter-btn:hover { border-color: var(--teal); color: var(--teal); background: var(--teal-dim); }
  /* G3: category-chip leading glyph */
  .filter-btn { display: inline-flex; align-items: center; gap: 5px; }
  .filter-btn .chip-ico { width: 13px; height: 13px; flex: 0 0 auto; color: var(--text-dim); display: inline-flex; align-items: center; justify-content: center; }
  .filter-btn .chip-ico svg { width: 100%; height: 100%; display: block; }
  .filter-btn.active .chip-ico, .filter-btn:hover .chip-ico { color: var(--teal); }
  .filter-btn .chip-inf { width: 18px; font-size: 17px; line-height: 1; transform: scaleX(1.45); font-family: 'IBM Plex Mono', monospace; }

  .panel-btn {
    padding: 4px 12px; border-radius: 4px; border: 1px solid var(--border); background: transparent;
    color: var(--text-dim);
    cursor: pointer; font-family: 'IBM Plex Sans', sans-serif; font-size: 11px; font-weight: 500; transition: all 0.15s;
  }
  .panel-btn:hover { opacity: 0.9; }
  .panel-btn.active { opacity: 1; }

  /* ── Supply inventory panel ── */
  .panel {
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 12px 20px; display: none;
  }
  .panel.open { display: block; }

  .panel-title {
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
    margin-bottom: 10px; display: flex; align-items: center; gap: 8px;
  }
  .panel-title .count {
    background: rgba(255,255,255,0.06); border-radius: 10px; padding: 1px 8px;
    font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  }

  .inv-grid {
    display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px;
    align-items: flex-start;   /* each card keeps its natural height — don't
                                  stretch sparse cards to a tall matched neighbour */
  }

  .inv-card {
    background: var(--surface2); border: 1px solid var(--border); border-radius: 5px;
    padding: 10px; min-width: 200px; max-width: 200px; flex-shrink: 0; transition: border-color 0.15s;
  }
  .inv-card:hover { border-color: var(--text-dim); }

  .inv-card-id { font-family: 'IBM Plex Mono', monospace; font-size: 11px; font-weight: 500; color: var(--role-restore); margin-bottom: 2px; }
  .inv-card-type { font-size: 11px; color: var(--text-bright); margin-bottom: 3px; }
  .inv-card-spec { font-size: 10px; color: var(--text-dim); line-height: 1.3; margin-bottom: 4px; }
  .inv-card-source { font-size: 10px; color: var(--text-dim); font-style: italic; margin-bottom: 6px; }

  .propose-btn {
    width: 100%; padding: 4px 8px; border-radius: 3px; border: 1px solid var(--role-restore);
    background: transparent; color: var(--role-restore); cursor: pointer; font-size: 10px;
    font-weight: 500; font-family: 'IBM Plex Sans', sans-serif; transition: all 0.12s;
  }
  .propose-btn:hover { background: rgba(96,165,250,0.12); }
  .propose-btn:disabled { opacity: 0.3; cursor: not-allowed; }

  .propose-select {
    width: 100%; padding: 3px 4px; border-radius: 3px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); font-family: 'IBM Plex Sans', sans-serif;
    font-size: 10px; margin-bottom: 4px; outline: none;
  }
  /* Inline table-cell variant: accented so it reads as an action, not a field. */
  .propose-inline {
    border-color: var(--role-restore); color: var(--role-restore);
    font-weight: 500; cursor: pointer; margin-bottom: 0;
  }
  .propose-inline:hover { background: rgba(96,165,250,0.10); }

  /* ── Builder logistics panel ── */
  .builder-table {
    width: 100%; border-collapse: collapse; font-size: 11px;
  }
  .builder-table th {
    text-align: left; padding: 6px 8px; color: var(--text-dim); font-size: 10px;
    text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--border);
    cursor: pointer; user-select: none; white-space: nowrap;
  }
  .builder-table th:hover { color: var(--teal); }
  .builder-table th.sorted { color: var(--teal); }
  .builder-table td {
    padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: middle;
  }
  .builder-table tr:hover td { background: var(--surface2); }

  /* ── Logistics status chips ── */
  .logistics-chip {
    font-family: 'IBM Plex Mono', monospace; font-size: 10px;
    padding: 2px 8px; border-radius: 3px; display: inline-block; white-space: nowrap;
  }
  .log-on-site      { background: rgba(52,211,153,0.12); color: #34D399; border: 1px solid rgba(52,211,153,0.3); }
  .log-awaiting      { background: rgba(107,114,128,0.12); color: #9CA3AF; border: 1px solid rgba(107,114,128,0.3); }
  .log-dispatched    { background: rgba(96,165,250,0.12); color: #60A5FA; border: 1px solid rgba(96,165,250,0.3); }
  .log-in-storage    { background: rgba(251,191,36,0.12); color: #FBBF24; border: 1px solid rgba(251,191,36,0.3); }
  .log-ready         { background: rgba(167,139,250,0.12); color: #A78BFA; border: 1px solid rgba(167,139,250,0.3); }
  .log-installed     { background: rgba(0,201,167,0.12); color: var(--teal); border: 1px solid rgba(0,201,167,0.3); }
  .log-at-supplier   { background: rgba(217,164,97,0.12); color: var(--origin-external); border: 1px solid rgba(217,164,97,0.3); }
  .log-received      { background: rgba(0,201,167,0.12); color: var(--teal); border: 1px solid rgba(0,201,167,0.3); }

  /* ── Deadline badges ── */
  .deadline-chip {
    font-family: 'IBM Plex Mono', monospace; font-size: 10px;
    padding: 2px 8px; border-radius: 3px; display: inline-block; margin-top: 4px;
  }
  .deadline-ok { background: rgba(52,211,153,0.08); color: #34D399; border: 1px solid rgba(52,211,153,0.2); }
  .deadline-warn { background: rgba(251,191,36,0.12); color: #FBBF24; border: 1px solid rgba(251,191,36,0.3); }
  .deadline-critical { background: rgba(229,72,77,0.15); color: #E5484D; border: 1px solid rgba(229,72,77,0.4); animation: pulse-critical 2s ease-in-out infinite; }
  .deadline-overdue { background: rgba(229,72,77,0.25); color: #E5484D; border: 1px solid rgba(229,72,77,0.5); }
  @media (prefers-reduced-motion: no-preference) {
    @keyframes pulse-critical { 0%,100%{opacity:1} 50%{opacity:0.7} }
  }

  .deadline-input {
    background: var(--surface2); border: 1px solid var(--border); border-radius: 4px;
    color: var(--text); font-family: 'IBM Plex Mono', monospace; font-size: 12px;
    padding: 4px 8px; outline: none; transition: border-color 0.15s;
  }
  .deadline-input:focus { border-color: var(--teal); }

  .order-new-btn {
    padding: 4px 10px; border-radius: 3px; border: 1px solid #E5484D;
    background: rgba(229,72,77,0.1); color: #E5484D; cursor: pointer;
    font-size: 10px; font-weight: 600; font-family: 'IBM Plex Sans', sans-serif;
    transition: all 0.12s; white-space: nowrap;
  }
  .order-new-btn:hover { background: rgba(229,72,77,0.2); }

  .log-select {
    padding: 2px 4px; border-radius: 3px; border: 1px solid var(--border);
    background: var(--surface2); color: var(--text); font-family: 'IBM Plex Mono', monospace;
    font-size: 10px; outline: none; cursor: pointer;
  }

  /* ── Pipeline ── */
  .pipeline {
    display: flex; gap: 0; padding: 16px; overflow-x: auto;
    min-height: calc(100vh - 160px); align-items: flex-start;
  }

  .stage-col { min-width: 230px; max-width: 230px; flex-shrink: 0; margin-right: 10px; }

  .stage-header {
    padding: 8px 10px; border-radius: 6px 6px 0 0; display: flex;
    align-items: center; gap: 8px; margin-bottom: 2px; border-bottom: 2px solid;
  }

  .stage-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
  .stage-title { font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; flex: 1; }
  .stage-count {
    background: rgba(255,255,255,0.08); border-radius: 10px; padding: 1px 7px;
    font-family: 'IBM Plex Mono', monospace; font-size: 10px; color: inherit; opacity: 0.8;
  }

  .stage-cards { display: flex; flex-direction: column; gap: 6px; padding-top: 6px; }

  /* ── Cards ── */
  .card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 5px;
    padding: 10px; cursor: pointer; transition: border-color 0.15s, transform 0.1s; position: relative;
    border-left: 3px solid var(--border);
  }
  .card:hover { transform: translateY(-1px); }
  .card.tier1 { border-left-color: var(--tier1); }
  .card.tier2 { border-left-color: var(--tier2); }
  .card.tier3 { border-left-color: var(--tier3); }
  .card.fallback { border-left-color: var(--fallback); }

  /* ── G3 redesigned card (icon-forward, status alert, no inline actions) ── */
  .card.tier1 { --tint: var(--tier1); } .card.tier2 { --tint: var(--tier2); }
  .card.tier3 { --tint: var(--tier3); } .card.fallback { --tint: var(--fallback); }
  .card { display: flex; flex-direction: column; padding: 13px 13px 12px; --rc-ico: 44px; --rc-gap: 10px; }
  .card:hover { border-color: var(--tint, var(--teal)); }
  .card .mat-icon { color: var(--tint, var(--text-dim)); }

  /* ── Card KIND: demand ("Need", wheat) vs supply ("Stock", blue) ─────────
     The most important macro signal — which side of the market you're on —
     is carried by a persistent left spine + a faint whole-card tint, keyed to
     the authoring role (Architect = wheat, ReStore = blue) rather than to tier.
     This removes the old collision where a Tier-2 demand and any supply both
     read as blue. Tier survives as the small corner badge. (v16.5.0) */
  .card.kind-demand { --kind: var(--role-architect); }
  .card.kind-supply { --kind: var(--role-restore); }
  .card.kind-demand, .card.kind-supply {
    --tint: var(--kind);
    border-left: 1px solid var(--border);
    background: color-mix(in srgb, var(--kind) 5%, var(--surface));
    padding-left: 36px;
  }
  .rc-spine {
    position: absolute; top: 0; left: 0; bottom: 0; width: 24px;
    display: flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--kind) 16%, var(--surface));
    border-right: 1px solid color-mix(in srgb, var(--kind) 40%, var(--surface));
    border-radius: 5px 0 0 5px;
  }
  .rc-spine-label {
    writing-mode: vertical-rl; transform: rotate(180deg);
    font-size: 8.5px; letter-spacing: 0.14em; text-transform: uppercase;
    font-weight: 600; color: var(--kind);
  }

  /* Tracker: the matched supply docked inside its demand card (socket + plug).
     Keeps supply's own blue identity so it never reads as another demand line. */
  .rc-nest { margin-top: 10px; }
  .rc-nest-conn {
    font-size: 9.5px; color: var(--text-dim); margin-bottom: 5px;
    display: flex; align-items: center; gap: 5px;
  }
  .rc-nest-conn .rc-lico { width: 12px; height: 12px; opacity: .85; display: inline-flex; }
  .rc-nest-conn .rc-lico svg { width: 100%; height: 100%; }
  .rc-supply-chip {
    --tint: var(--role-restore);
    background: var(--surface2);
    border: 1px solid color-mix(in srgb, var(--role-restore) 45%, transparent);
    border-left: 4px solid var(--role-restore);
    border-radius: 0 5px 5px 0;
    padding: 8px 10px; display: flex; align-items: center; gap: 9px;
  }
  .rc-sc-id { font-family: 'IBM Plex Mono', monospace; font-size: 12px; font-weight: 700; color: var(--role-restore); }
  .rc-sc-sub { font-family: 'IBM Plex Mono', monospace; font-size: 9.5px; color: var(--text-dim); margin-top: 2px; }
  .rc-sc-check { margin-left: auto; color: var(--tier1); display: inline-flex; width: 14px; height: 14px; }
  .rc-sc-check svg { width: 100%; height: 100%; }

  /* ── Supply card: graded match status (v16.6.0) ──────────────────────────
     The Supply view's card mode used to collapse a rich status into one flat
     pill. It now grades the match by the demand's stage, runs a lifecycle
     stepper, surfaces verification + reserved/sold, and docks the need it fills
     inside as a wheat chip. Off-market stock (installed on site, or sold) recedes
     so available stock stands out. */
  .card.kind-supply.claimed { opacity: 0.6; }
  .card.kind-supply.claimed:hover { opacity: 0.85; }

  /* verification + reserved/sold meta-line */
  .rc-meta { margin-top: 9px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
  .rc-meta .verify-badge { margin-top: 0; }
  .rc-av {
    font-family: 'IBM Plex Mono', monospace; font-size: 8px; font-weight: 600;
    border: 1px solid; border-radius: 7px; padding: 1px 6px; letter-spacing: 0.04em;
  }

  /* graded match pill — colour set inline per stage */
  .rc-mpill { margin-top: 10px; }

  /* lifecycle stepper: Verified · Proposed · Approved · On site */
  .rc-step { margin-top: 11px; display: flex; align-items: center; }
  .rc-step-node { width: 7px; height: 7px; border-radius: 50%; background: var(--border); flex: 0 0 auto; }
  .rc-step-bar { height: 1.5px; flex: 1; background: var(--border); }
  .rc-step-node.on { background: var(--role-restore); }
  .rc-step-node.done { background: var(--role-builder); }
  .rc-step-bar.done { background: var(--role-builder); }
  .rc-step-labels {
    display: flex; justify-content: space-between; margin-top: 4px;
    font-size: 8px; letter-spacing: 0.02em; text-transform: uppercase; color: var(--text-dim);
  }

  /* "Fills" — the demand this supply serves, docked inside (wheat) */
  .rc-fills { margin-top: 9px; }
  .rc-fills-head { font-size: 9.5px; color: var(--text-dim); margin-bottom: 5px; display: flex; align-items: center; gap: 5px; }
  .rc-fills-head .rc-lico { width: 12px; height: 12px; opacity: .85; display: inline-flex; }
  .rc-fills-head .rc-lico svg { width: 100%; height: 100%; }
  .rc-need-chip {
    --tint: var(--role-architect);
    background: var(--surface2);
    border: 1px solid color-mix(in srgb, var(--role-architect) 45%, transparent);
    border-left: 4px solid var(--role-architect);
    border-radius: 0 5px 5px 0;
    padding: 7px 9px; display: flex; align-items: center; gap: 9px;
  }
  .rc-need-id { font-family: 'IBM Plex Mono', monospace; font-size: 12px; font-weight: 700; color: var(--role-architect); }
  .rc-need-sub { font-size: 9.5px; color: var(--text-dim); margin-top: 2px; }
  .rc-body { flex: 1 1 auto; }
  .rc-head { display: flex; align-items: center; gap: var(--rc-gap); }
  .rc-ico { width: var(--rc-ico); height: var(--rc-ico); }
  .rc-id { font-family: 'IBM Plex Mono', monospace; font-size: 15px; font-weight: 700; color: var(--text-bright); }
  .rc-badges { position: absolute; top: 10px; right: 11px; display: flex; gap: 4px; }
  .rc-indent { margin-left: calc(var(--rc-ico) + var(--rc-gap)); margin-top: 4px; }
  .rc-type { font-size: 12px; font-weight: 600; color: var(--text); line-height: 1.25; }
  .rc-spec { font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; color: var(--text-dim); margin-top: 4px; }
  .rc-extra { margin-top: 7px; display: flex; flex-direction: column; gap: 3px; }
  .rc-line { font-size: 10.5px; color: var(--text-dim); display: flex; align-items: center; gap: 5px; }
  .rc-line .rc-lico { width: 12px; height: 12px; flex: 0 0 auto; opacity: .85; display: inline-flex; }
  .rc-line .rc-lico svg { width: 100%; height: 100%; }
  .rc-line.dl-overdue, .rc-line.dl-critical { color: var(--fallback); }
  .rc-line.dl-warn { color: #FBBF24; }
  .card-alert { margin-top: 12px; display: flex; align-items: center; gap: 6px; font-size: 10.5px; font-weight: 600; padding: 5px 9px; border-radius: 7px; border: 1px solid; }
  .card-alert .alert-ico { width: 14px; height: 14px; flex: 0 0 auto; display: inline-flex; }
  .card-alert .alert-ico svg { width: 100%; height: 100%; }
  .card-alert .alert-arrow { margin-left: auto; opacity: .55; }
  .alert-action { color: var(--role-architect); border-color: rgba(233,208,138,.45); background: rgba(233,208,138,.10); }
  .alert-urgent { color: var(--fallback); border-color: rgba(229,72,77,.45); background: rgba(229,72,77,.09); }
  .alert-confirm { color: #A78BFA; border-color: rgba(167,139,250,.45); background: rgba(167,139,250,.09); }
  .alert-info { color: var(--text-dim); border-color: var(--border); background: var(--surface2); }

  .card-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 3px; }
  /* G3 material icon — inline SVG visual key. Inherits color via currentColor. */
  .mat-icon { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; color: var(--text-dim); }
  .mat-icon svg { width: 100%; height: 100%; display: block; }
  /* Poster photo standing in for the material icon on the supply card header.
     Square crop, rounded to match the card language; the photo is full-colour
     so it is not tinted like the line glyphs. */
  .mat-photo { display: inline-flex; flex: 0 0 auto; border-radius: 7px; overflow: hidden; border: 1px solid var(--border); background: var(--surface); }
  .mat-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
  /* Icon coverage pass — action-button prefix, nav/view, table-cell glyphs.
     All inherit color via currentColor. */
  .btn-ico { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; opacity: .85; }
  .btn-ico svg { width: 100%; height: 100%; display: block; }
  .action-btn.has-ico, .panel-btn.has-ico, .home-action-btn.has-ico,
  .propose-btn.has-ico, .order-new-btn.has-ico {
    display: inline-flex; align-items: center; gap: 5px;
  }
  .view-ico { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; color: var(--text-dim); }
  .view-ico svg { width: 100%; height: 100%; display: block; }
  /* table-cell / inline leading glyph (id cells, status chips, pills) */
  .cell-ico { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; vertical-align: -2px; margin-right: 4px; }
  .cell-ico svg { width: 100%; height: 100%; display: block; }
  .logistics-chip.has-ico, .verify-badge.has-ico { display: inline-flex; align-items: center; gap: 4px; }
  .card-cat.has-ico { display: inline-flex; align-items: center; gap: 3px; }
  .card-cat.has-ico .cell-ico { margin-right: 0; vertical-align: 0; }
  .card-cat {
    font-family: 'IBM Plex Mono', monospace; font-size: 9px; padding: 1px 5px;
    border-radius: 3px; letter-spacing: 0.04em; white-space: nowrap;
  }
  .cat-tier1 { background: var(--tier1-bg); color: var(--tier1); border: 0.5px solid var(--tier1-border); }
  .cat-tier2 { background: var(--tier2-bg); color: var(--tier2); border: 0.5px solid var(--tier2-border); }
  .cat-tier3 { background: var(--tier3-bg); color: var(--tier3); border: 0.5px solid var(--tier3-border); }

  .qty-chip {
    font-family: 'IBM Plex Mono', monospace; font-size: 11px; font-weight: 500;
    padding: 1px 6px; border-radius: 3px;
  }
  .qty-tier2 { background: var(--tier2-bg); color: var(--tier2); border: 0.5px solid var(--tier2-border); }
  .qty-tier3 { background: var(--tier3-bg); color: var(--tier3); border: 0.5px solid var(--tier3-border); }

  .card-loc { font-size: 10px; color: var(--text-dim); display: flex; align-items: center; gap: 4px; margin-top: 3px; }
  .loc-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--text-dim); opacity: 0.4; }
  .card-note {
    font-size: 10px; color: var(--text-dim); font-style: italic;
    margin-top: 4px; padding-top: 4px; border-top: 0.5px solid var(--border);
  }
  .supply-qty-ok { color: #34D399; font-weight: 500; font-style: normal; }
  .supply-qty-short { color: #E5484D; font-weight: 500; font-style: normal; }
  .card-fallback {
    margin-top: 5px; padding: 5px 7px; background: rgba(229,72,77,0.04);
    border: 0.5px solid rgba(229,72,77,0.15); border-left: 2px solid #E5484D;
    border-radius: 0 3px 3px 0; font-size: 10px;
  }
  .fallback-label { font-size: 9px; text-transform: uppercase; letter-spacing: 0.05em; color: #E5484D; margin-bottom: 1px; font-weight: 600; }
  .fallback-text { color: var(--text-dim); }
  .card-tests { margin-top: 5px; display: flex; flex-direction: column; gap: 2px; }
  .card-test-row { display: flex; justify-content: space-between; align-items: center; font-size: 10px; padding: 2px 0; }
  .card-test-name { color: var(--text-dim); }
  .card-test-chip { font-family: 'IBM Plex Mono', monospace; font-size: 9px; padding: 1px 5px; border-radius: 2px; }
  .card-test-pass { background: rgba(52,211,153,0.1); color: #34D399; border: 0.5px solid rgba(52,211,153,0.3); }
  .card-test-pend { background: rgba(251,191,36,0.1); color: #FBBF24; border: 0.5px solid rgba(251,191,36,0.3); }
  .card-test-fail { background: rgba(229,72,77,0.1); color: #E5484D; border: 0.5px solid rgba(229,72,77,0.3); }
  .card-split-actions { margin-top: 6px; display: flex; gap: 0; }
  .split-btn {
    flex: 1; padding: 4px 0; border: 0.5px solid; background: transparent;
    font-size: 9px; font-weight: 500; font-family: 'IBM Plex Sans', sans-serif; cursor: pointer; transition: all 0.12s;
  }
  .split-btn:first-child { border-radius: 3px 0 0 3px; }
  .split-btn:last-child { border-radius: 0 3px 3px 0; border-left: none; }
  .split-btn.split-accept { border-color: var(--role-architect); color: var(--role-architect); }
  .split-btn.split-accept:hover { background: rgba(233,208,138,0.12); }
  .split-btn.split-reject { border-color: #E5484D; color: #E5484D; }
  .split-btn.split-reject:hover { background: rgba(229,72,77,0.1); }
  .test-add-row { display: flex; gap: 6px; margin-top: 6px; }
  .test-add-input { flex: 1; background: var(--surface2); border: 1px solid var(--border); border-radius: 4px; color: var(--text); font-size: 11px; padding: 4px 8px; outline: none; }
  .test-add-input:focus { border-color: var(--teal); }
  .test-remove-btn { background: none; border: none; color: #E5484D; cursor: pointer; font-size: 14px; padding: 0 4px; opacity: 0.5; }
  .test-remove-btn:hover { opacity: 1; }

  /* ── Verification badge ── */
  .verify-badge {
    display: inline-flex; align-items: center; gap: 4px;
    font-family: 'IBM Plex Mono', monospace; font-size: 9px;
    padding: 2px 6px; border-radius: 3px; margin-top: 4px;
  }
  .verify-badge.verified-restore { background: rgba(96,165,250,0.1); color: #60A5FA; border: 0.5px solid rgba(96,165,250,0.25); }
  .verify-badge.verified-architect { background: rgba(52,211,153,0.1); color: #34D399; border: 0.5px solid rgba(52,211,153,0.25); }
  .verify-badge.unverified { background: rgba(107,114,128,0.1); color: #9CA3AF; border: 0.5px solid rgba(107,114,128,0.25); }
  .verify-dot { width: 5px; height: 5px; border-radius: 50%; }
  .verify-badge.verified-restore .verify-dot { background: #60A5FA; }
  .verify-badge.verified-architect .verify-dot { background: #34D399; }
  .verify-badge.unverified .verify-dot { background: #9CA3AF; }

  body.light .verify-badge.verified-restore { background: rgba(37,99,235,0.06); color: #1D4ED8; border-color: rgba(37,99,235,0.2); }
  body.light .verify-badge.verified-architect { background: rgba(5,150,105,0.06); color: #047857; border-color: rgba(5,150,105,0.2); }

  /* Shared detail band (v17.5.0): one banded row reused for the certificate,
     Architect's Instruction and on-site logistics status across the item-detail
     drawers. Layout only — colour comes from a tint modifier (.band-* below, or
     a .log-* logistics class which already carries bg/colour/border). */
  .detail-band {
    display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
    padding: 7px 11px; border-radius: 7px; font-size: 11px; margin-top: 10px;
  }
  .detail-band .db-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
  .detail-band .db-label { font-weight: 600; }
  .detail-band .db-id { font-family: 'IBM Plex Mono', monospace; font-weight: 600; }
  .detail-band .db-sep { opacity: 0.4; }
  .detail-band .db-note, .detail-band .db-date { color: var(--text-dim); }
  .detail-band .db-spacer { flex: 1 1 auto; }
  .detail-band .db-action { font-size: 9px; padding: 2px 8px; flex-shrink: 0; }

  .band-architect { background: rgba(52,211,153,0.1); color: #34D399; border: 0.5px solid rgba(52,211,153,0.28); }
  .band-restore   { background: rgba(96,165,250,0.1); color: #60A5FA; border: 0.5px solid rgba(96,165,250,0.28); }
  .band-instruct  { background: rgba(84,160,255,0.1); color: #54A0FF; border: 0.5px solid rgba(84,160,255,0.28); }
  .band-revoked   { background: rgba(220,36,36,0.1);  color: #DC2424; border: 0.5px solid rgba(220,36,36,0.28); }
  body.light .band-architect { background: rgba(5,150,105,0.07); color: #047857; border-color: rgba(5,150,105,0.22); }
  body.light .band-restore   { background: rgba(37,99,235,0.07); color: #1D4ED8; border-color: rgba(37,99,235,0.22); }
  body.light .band-instruct  { background: rgba(37,99,235,0.07); color: #1D4ED8; border-color: rgba(37,99,235,0.22); }
  body.light .band-revoked   { background: rgba(185,28,28,0.07); color: #B91C1C; border-color: rgba(185,28,28,0.22); }

  /* ── Photo gallery ── */
  .photo-grid { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
  .photo-thumb {
    width: 44px; height: 44px; border-radius: 3px; object-fit: cover;
    border: 1px solid var(--border); cursor: pointer; transition: border-color 0.15s;
  }
  .photo-thumb:hover { border-color: var(--teal); }
  .photo-thumb-placeholder {
    width: 44px; height: 44px; border-radius: 3px; border: 1px dashed var(--border);
    display: flex; align-items: center; justify-content: center; color: var(--text-dim);
    font-size: 18px; cursor: pointer; transition: all 0.15s;
  }
  .photo-thumb-placeholder:hover { border-color: var(--teal); color: var(--teal); }

  .photo-lightbox {
    position: fixed; inset: 0; background: rgba(0,0,0,0.9); z-index: 400;
    display: flex; align-items: center; justify-content: center; cursor: pointer;
  }
  .photo-lightbox img { max-width: 90vw; max-height: 90vh; border-radius: 6px; }

  .photo-upload-area {
    border: 1px dashed var(--border); border-radius: 6px; padding: 12px;
    text-align: center; cursor: pointer; transition: all 0.15s; margin-top: 8px;
  }
  .photo-upload-area:hover { border-color: var(--teal); color: var(--teal); }
  .photo-upload-label { font-size: 11px; color: var(--text-dim); }
  .photo-upload-area:hover .photo-upload-label { color: var(--teal); }

  /* ── Supply verification workspace ── */
  .inv-card-expanded { max-width: 320px; min-width: 280px; }
  .inv-card.matched { border-color: var(--teal); border-left: 3px solid var(--teal); opacity: 0.85; }
  body.light .inv-card.matched { border-color: #008573; border-left-color: #008573; }
  .inv-verify-section { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
  .inv-verify-status { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
  .inv-test-row { display: flex; justify-content: space-between; align-items: center; padding: 3px 0; font-size: 10px; }
  .inv-test-name { color: var(--text-dim); }

  .card.has-notes::after { content: '●'; position: absolute; top: 6px; right: 8px; font-size: 7px; color: var(--teal); }

  .card-tag { font-family: 'IBM Plex Mono', monospace; font-size: 12px; font-weight: 500; margin-bottom: 3px; }
  .card-type { color: var(--text-dim); font-size: 11px; margin-bottom: 4px; line-height: 1.3; }

  .card-specs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
  .spec-chip {
    font-family: 'IBM Plex Mono', monospace; font-size: 10px; padding: 2px 6px; border-radius: 3px;
    background: var(--surface2); border: 1px solid var(--border); color: var(--text-dim);
  }
  .spec-chip.test-pend { border-color: rgba(251,191,36,0.4); color: #FBBF24; }
  .spec-chip.test-pass { border-color: rgba(52,211,153,0.4); color: #34D399; }

  .card-candidate {
    margin-top: 6px; padding: 6px 8px; background: var(--surface2);
    border: 1px solid rgba(96,165,250,0.2); border-left: 3px solid var(--role-restore); border-radius: 3px; font-size: 10px;
  }
  .card-candidate-label { font-size: 9px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--role-restore); margin-bottom: 2px; font-weight: 600; }
  .card-candidate-name { color: var(--text-bright); margin-bottom: 1px; }
  .card-candidate-source { color: var(--text-dim); font-style: italic; }

  .card-actions { margin-top: 8px; display: flex; gap: 4px; flex-wrap: wrap; }

  .action-btn {
    padding: 3px 8px; border-radius: 3px; border: 1px solid; background: transparent;
    cursor: pointer; font-size: 10px; font-weight: 500; font-family: 'IBM Plex Sans', sans-serif;
    transition: all 0.12s; white-space: nowrap;
  }
  .btn-teal { border-color: var(--teal); color: var(--teal); }
  .btn-teal:hover { background: var(--teal-dim); }
  .btn-amber { border-color: #FBBF24; color: #FBBF24; }
  .btn-amber:hover { background: rgba(251,191,36,0.1); }
  .btn-green { border-color: #34D399; color: #34D399; }
  .btn-green:hover { background: rgba(52,211,153,0.1); }
  .btn-purple { border-color: #A78BFA; color: #A78BFA; }
  .btn-purple:hover { background: rgba(167,139,250,0.1); }
  .btn-orange { border-color: var(--role-architect); color: var(--role-architect); }
  .btn-orange:hover { background: rgba(233,208,138,0.12); }
  .btn-blue { border-color: #60A5FA; color: #60A5FA; }
  .btn-blue:hover { background: rgba(96,165,250,0.1); }
  .btn-red { border-color: #E5484D; color: #E5484D; }
  .btn-red:hover { background: rgba(229,72,77,0.1); }
  .btn-gray { border-color: var(--border); color: var(--text-dim); }
  .btn-gray:hover { border-color: var(--text-dim); color: var(--text); }
  .btn-disabled { border-color: var(--border); color: var(--text-dim); opacity: 0.3; cursor: not-allowed; pointer-events: none; }

  /* ── Modal ── */
  .overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 200;
    display: flex; align-items: flex-start; justify-content: center; padding: 20px; overflow-y: auto;
  }
  .modal {
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    width: 100%; max-width: 580px; margin: auto;
  }
  .modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; gap: 12px; }
  .modal-tag { font-family: 'IBM Plex Mono', monospace; font-size: 18px; font-weight: 500; flex-shrink: 0; }
  .modal-meta { flex: 1; }
  .modal-type { font-size: 14px; color: var(--text-bright); margin-bottom: 4px; }
  .modal-stage { font-size: 11px; }
  .modal-close { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 18px; line-height: 1; padding: 0; flex-shrink: 0; margin-left: auto; }
  .modal-close:hover { color: var(--text); }
  .modal-body { padding: 16px 20px; }

  .spec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
  .spec-row { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
  .spec-key { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
  /* overflow-wrap:anywhere so a long monospace value (ids, dims, supplier names)
     wraps instead of forcing the spec column wider than the modal. */
  .spec-val { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--text-bright); min-width: 0; overflow-wrap: anywhere; }

  .section-label {
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--text-dim); margin-bottom: 6px; padding-bottom: 4px; border-bottom: 1px solid var(--border);
  }

  .field-group { margin-bottom: 14px; }

  /* ── Detail-modal drawers (item detail redesign) ── */
  /* Topical sections collapse into drawers; each header carries a status
     badge so a user can triage without opening anything. Default: only the
     first (Identity) drawer is open. */
  .dwr-glance {
    display: flex; gap: 6px; flex-wrap: wrap;
    padding: 0 0 12px; margin-bottom: 4px; border-bottom: 1px solid var(--border);
  }
  .dwr { border-bottom: 1px solid var(--border); }
  .dwr-h {
    width: 100%; display: flex; align-items: center; gap: 9px;
    padding: 11px 0; background: none; border: none; cursor: pointer;
    text-align: left; font-family: 'IBM Plex Sans', sans-serif; color: var(--text);
  }
  .dwr-ico { width: 16px; height: 16px; flex-shrink: 0; color: var(--text-dim); display: inline-flex; }
  .dwr-ico svg { width: 16px; height: 16px; }
  .dwr-title {
    flex: 1; font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--text-dim);
  }
  .dwr-h:hover .dwr-title, .dwr-h:hover .dwr-ico { color: var(--text-bright); }
  .dwr-chev { width: 14px; height: 14px; flex-shrink: 0; color: var(--text-dim); display: inline-flex; transition: transform 0.2s; }
  .dwr-chev svg { width: 14px; height: 14px; }
  .dwr.open > .dwr-h .dwr-chev { transform: rotate(180deg); }
  .dwr-body { max-height: 0; overflow: hidden; transition: max-height 0.28s ease; }
  .dwr.open > .dwr-body { max-height: 2400px; }
  .dwr-body-inner { padding: 2px 0 14px; }

  .dwr-badge {
    display: inline-flex; align-items: center; gap: 4px;
    font-family: 'IBM Plex Mono', monospace; font-size: 9px; font-weight: 600;
    letter-spacing: 0.02em; padding: 2px 8px; border-radius: 10px; white-space: nowrap;
  }
  .dwr-badge-ico { width: 11px; height: 11px; display: inline-flex; }
  .dwr-badge-ico svg { width: 11px; height: 11px; }
  .dwr-badge.b-ok   { background: var(--s4-bg); color: var(--s4); border: 0.5px solid rgba(52,211,153,0.3); }
  .dwr-badge.b-info { background: rgba(96,165,250,0.12); color: var(--role-restore); border: 0.5px solid rgba(96,165,250,0.28); }
  .dwr-badge.b-warn { background: rgba(217,164,97,0.14); color: var(--origin-external); border: 0.5px solid var(--origin-external); }
  .dwr-badge.b-miss { background: var(--surface2); color: var(--text-dim); border: 0.5px dashed var(--border); }

  body.light .dwr-badge.b-info { background: rgba(37,99,235,0.08); color: var(--role-restore); border-color: rgba(37,99,235,0.25); }
  body.light .dwr-badge.b-warn { background: rgba(176,122,46,0.12); color: var(--origin-external); border-color: var(--origin-external); }

  textarea {
    width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: 4px;
    color: var(--text); font-family: 'IBM Plex Sans', sans-serif; font-size: 12px; padding: 8px 10px;
    resize: vertical; transition: border-color 0.15s; outline: none;
  }
  textarea:focus { border-color: var(--teal); }
  textarea:disabled { opacity: 0.4; cursor: not-allowed; }

  .test-section { margin-bottom: 14px; }
  .test-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
  .test-name { flex: 1; color: var(--text-bright); }
  .test-status { font-family: 'IBM Plex Mono', monospace; font-size: 11px; padding: 2px 8px; border-radius: 3px; }
  .test-status.pending { background: rgba(251,191,36,0.1); color: #FBBF24; border: 1px solid rgba(251,191,36,0.3); }
  .test-status.pass { background: rgba(52,211,153,0.1); color: #34D399; border: 1px solid rgba(52,211,153,0.3); }
  .test-status.fail { background: rgba(229,72,77,0.15); color: #E5484D; border: 1px solid rgba(229,72,77,0.4); }
  .test-status.na { background: var(--surface2); color: var(--text-dim); border: 1px solid var(--border); }

  .activity-log { display: flex; flex-direction: column; gap: 8px; max-height: 200px; overflow-y: auto; margin-bottom: 10px; }
  .activity-entry { background: var(--surface2); border: 1px solid var(--border); border-radius: 4px; padding: 8px 10px; }
  .activity-meta { display: flex; gap: 8px; align-items: center; margin-bottom: 3px; }
  .activity-role { font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 2px; letter-spacing: 0.05em; }
  .activity-role.Architect { background: rgba(233,208,138,0.18); color: var(--role-architect); }
  .activity-role.ReStore { background: rgba(96,165,250,0.15); color: var(--role-restore); }
  .activity-role.Builder { background: rgba(52,211,153,0.15); color: var(--role-builder); }
  .activity-time { font-size: 10px; color: var(--text-dim); font-family: 'IBM Plex Mono', monospace; }
  .activity-text { font-size: 12px; color: var(--text-bright); line-height: 1.4; }
  .add-note-row { display: flex; gap: 6px; align-items: flex-start; }
  .add-note-row textarea { min-height: 52px; }

  .modal-actions {
    padding: 12px 20px; border-top: 1px solid var(--border);
    display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  }
  .modal-actions .action-btn { font-size: 11px; padding: 5px 12px; }

  .empty-col {
    text-align: center; padding: 20px 10px; color: var(--text-dim);
    font-size: 11px; border: 1px dashed var(--border); border-radius: 5px;
  }

  .role-indicator {
    display: flex; align-items: center; gap: 6px; font-size: 11px;
    padding: 4px 10px; border-radius: 4px; border: 1px solid;
  }
  .role-indicator.Architect { border-color: var(--role-architect); color: var(--role-architect); background: rgba(233,208,138,0.10); }
  .role-indicator.ReStore { border-color: var(--role-restore); color: var(--role-restore); background: rgba(96,165,250,0.08); }
  .role-indicator.Builder { border-color: var(--role-builder); color: var(--role-builder); background: rgba(52,211,153,0.08); }

  /* ── Connection indicator ── */
  .conn-badge {
    font-family: 'IBM Plex Mono', monospace; font-size: 10px;
    padding: 2px 8px; border-radius: 3px; display: inline-flex; align-items: center; gap: 4px;
  }
  .conn-badge.live { background: rgba(52,211,153,0.12); color: #34D399; border: 1px solid rgba(52,211,153,0.3); }
  .conn-badge.demo { background: rgba(251,191,36,0.12); color: #FBBF24; border: 1px solid rgba(251,191,36,0.3); }
  .conn-dot { width: 6px; height: 6px; border-radius: 50%; }
  .conn-badge.live .conn-dot { background: #34D399; }
  .conn-badge.demo .conn-dot { background: #FBBF24; }

  /* ── CSV import ── */
  .csv-input { display: none; }
  .csv-status {
    font-size: 10px; color: var(--teal); padding: 4px 8px;
    background: var(--teal-dim); border-radius: 3px; display: none;
  }
  .csv-status.visible { display: inline-block; }

  .csv-preview {
    background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
    padding: 12px 16px; margin-bottom: 12px;
  }
  .csv-preview-title { font-size: 11px; font-weight: 600; color: var(--teal); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }
  .csv-preview-table {
    width: 100%; border-collapse: collapse; font-size: 10px; margin-bottom: 8px;
  }
  .csv-preview-table th {
    text-align: left; padding: 4px 6px; color: var(--text-dim); font-size: 9px;
    text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--border);
  }
  .csv-preview-table td { padding: 4px 6px; border-bottom: 1px solid var(--border); color: var(--text-bright); }
  .csv-preview-actions { display: flex; gap: 6px; }

  /* ── Create supply form ── */
  .form-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px;
  }
  /* min-width:0 lets a field shrink to its grid/flex track — without it a wide
     <select> option or long value imposes its intrinsic width and overflows the
     modal off the right edge on mobile. */
  .form-field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
  .form-field.full { grid-column: 1 / -1; }
  .form-label {
    font-size: 10px; color: var(--text-dim); text-transform: uppercase;
    letter-spacing: 0.05em;
  }
  .form-input {
    background: var(--surface2); border: 1px solid var(--border); border-radius: 4px;
    color: var(--text); font-family: 'IBM Plex Sans', sans-serif; font-size: 12px;
    padding: 6px 8px; outline: none; transition: border-color 0.15s;
    width: 100%; min-width: 0; max-width: 100%;
  }
  .form-input:focus { border-color: var(--teal); }
  .form-input::placeholder { color: var(--text-dim); opacity: 0.6; }
  select.form-input { cursor: pointer; }

  /* Mobile: a two-up form/spec grid is too cramped at ~140px/col and is the main
     overflow culprit — collapse both to a single column. Pairs with the
     min-width:0 fixes above (single column alone still overflows without them). */
  @media (max-width: 640px) {
    .form-grid, .spec-grid { grid-template-columns: 1fr; }
  }

  /* ── v12.4: Login screen responsive ───────────────────────────── */
  .login-screen {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; min-height: 100vh; gap: 24px; padding: 20px;
    box-sizing: border-box;
  }
  .role-cards-row {
    display: flex; gap: 12px; flex-wrap: wrap; justify-content: center;
    width: 100%; max-width: 600px;
  }
  /* Square cards on every width: flex:1 to a shared cap + aspect-ratio:1, with a
     column layout so the stat pills bottom-align regardless of how many show. The
     squares shrink (never stack full-width) on mobile. */
  .role-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; padding: 16px 14px; cursor: pointer;
    transition: all 0.15s; text-align: center; box-sizing: border-box;
    flex: 1 1 0; max-width: 180px; aspect-ratio: 1 / 1; overflow: hidden;
    display: flex; flex-direction: column; align-items: center;
  }
  /* Role icon at the top of each card. Architect/Contractor inherit the role
     colour via currentColor; ReStore carries its own two-tone brand fills. */
  .role-card-icon {
    display: inline-flex; align-items: center; justify-content: center;
    height: 30px; margin-bottom: 8px;
  }
  .role-card-icon svg { height: 28px; width: auto; }
  .role-card-name { font-size: 14px; font-weight: 500; margin-bottom: 4px; }
  .role-card-desc { font-size: 10px; color: var(--text-dim); line-height: 1.4; }
  @media (max-width: 640px) {
    .role-cards-row { gap: 8px; max-width: 100%; }
    .role-card { padding: 12px 7px; }
    .role-card-icon { height: 24px; margin-bottom: 6px; }
    .role-card-icon svg { height: 24px; }
    .role-card-name { font-size: 11.5px; margin-bottom: 0; }
    /* The square is too short for the long descriptor on mobile — drop it and keep
       the icon + role name + glance stats, which fit cleanly. */
    .role-card-desc { display: none; }
    .role-card-stats { gap: 3px; padding-top: 8px; }
    .role-stat-pill { font-size: 8px; padding: 2px 6px; gap: 3px; }
    .role-stat-count { font-size: 8.5px; }
  }
  /* Pre-login glance pills on the role cards — margin-top:auto pins them to the
     card foot so unequal pill counts don't make the cards ragged. */
  .role-card-stats {
    display: flex; gap: 5px; justify-content: center; flex-wrap: wrap;
    margin-top: auto; padding-top: 10px;
  }
  .role-stat-pill {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 9.5px; line-height: 1; padding: 3px 8px; border-radius: 10px;
    background: var(--surface2); color: var(--text-dim); white-space: nowrap;
  }
  .role-stat-count {
    font-weight: 700; font-size: 10px; color: var(--pill-accent, var(--text-bright));
  }
  .role-stat-pill.clear { color: var(--tier1); background: var(--tier1-bg); }
  /* Login swing-tag — one featured open need styled like a "for supply" tag:
     notched left point + punch hole (clip-path + a dot), a bold ReStore-blue
     banner, a prominent price block, and a right-aligned pill CTA. Banner/CTA
     ink uses var(--bg) so it auto-contrasts in both themes (dark ink on the
     light-blue dark-theme banner; light ink on the deep-blue light-theme one). */
  .login-tag {
    position: relative; align-self: center;
    width: min(300px, 100%);
    background: var(--surface); border: 1px solid var(--border);
    cursor: pointer; transition: transform 0.15s; text-align: left;
    clip-path: polygon(24px 0, 100% 0, 100% 100%, 24px 100%, 0 50%);
  }
  .login-tag:hover { transform: translateY(-2px); }
  .login-tag-hole {
    position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
    width: 9px; height: 9px; border-radius: 50%;
    border: 1.5px solid var(--text-dim); background: var(--bg); z-index: 2;
  }
  .login-tag-banner {
    background: var(--role-restore); color: var(--bg);
    font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
    text-transform: uppercase; padding: 6px 14px 6px 38px;
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
  }
  .login-tag-body { padding: 12px 16px 14px 38px; }
  .login-tag-row { display: flex; align-items: center; gap: 10px; }
  .login-tag-info { flex: 1; min-width: 0; }
  .login-tag-name { font-size: 13px; font-weight: 600; color: var(--text-bright); }
  .login-tag-meta { font-size: 10px; color: var(--text-dim); margin-top: 3px; line-height: 1.5; }
  .login-tag-price { flex: 0 0 auto; text-align: right; }
  .login-tag-price-val { font-size: 16px; font-weight: 700; color: var(--role-builder); line-height: 1; }
  .login-tag-price-lbl { font-size: 9px; color: var(--text-dim); margin-top: 2px; }
  .login-tag-cta-wrap { margin-top: 11px; text-align: right; }
  .login-tag-cta {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 10.5px; font-weight: 600; color: var(--bg);
    background: var(--role-restore); border-radius: 999px; padding: 6px 14px;
  }

  /* ── Login form (email + password, replaces PIN role-cards) ── */
  .login-form {
    width: 100%; max-width: 360px;
    display: flex; flex-direction: column; gap: 10px;
  }
  .login-input {
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 6px; color: var(--text); font-size: 14px;
    padding: 11px 14px; width: 100%; box-sizing: border-box;
    outline: none; transition: border-color 0.15s;
  }
  .login-input:focus { border-color: var(--teal); }
  .login-pw-wrap { position: relative; display: flex; align-items: center; }
  .login-pw-wrap .login-input { padding-right: 42px; width: 100%; }
  .login-eye {
    position: absolute; right: 10px;
    background: none; border: none; cursor: pointer;
    color: var(--text-dim); padding: 4px; display: flex;
    transition: color 0.15s; line-height: 0;
  }
  .login-eye:hover { color: var(--text); }
  .login-eye svg { width: 18px; height: 18px; }
  .login-btn-primary {
    background: var(--teal); color: #fff; border: none;
    border-radius: 6px; font-size: 14px; font-weight: 600;
    padding: 12px; cursor: pointer; transition: opacity 0.15s; width: 100%;
  }
  .login-btn-primary:hover:not(:disabled) { opacity: 0.85; }
  .login-btn-primary:disabled { opacity: 0.5; cursor: default; }
  .login-btn-ghost {
    background: transparent; color: var(--text-dim);
    border: 1px solid var(--border); border-radius: 6px;
    font-size: 13px; padding: 10px; cursor: pointer; width: 100%;
    transition: border-color 0.15s, color 0.15s;
  }
  .login-btn-ghost:hover:not(:disabled) { border-color: var(--teal); color: var(--text); }
  .login-btn-ghost:disabled { opacity: 0.5; cursor: default; }
  .login-error { color: #E5484D; font-size: 11px; min-height: 16px; }
  .login-hint { color: var(--text-dim); font-size: 11px; text-align: center; margin-top: 2px; }
  .login-magic-confirm {
    background: color-mix(in srgb, var(--teal) 10%, transparent);
    border: 1px solid var(--teal); border-radius: 6px;
    color: var(--teal); font-size: 12px; padding: 10px 14px; text-align: center;
  }
  .login-form.shake { animation: shake 0.3s; }
  .login-tag-note { font-size: 10px; color: var(--text-dim); margin-top: 8px; text-align: right; }

  /* ── v12.4: Identity bar — responsive collapse ────────────────── */
  @media (max-width: 640px) {
    .identity-bar { padding: 8px 12px; gap: 8px; flex-wrap: wrap; }
    .header-sep { display: none !important; }
    .ident-proj { font-size: 14px; }
    .ident-gwp { font-size: 9px; }
    .conn-text { display: none; }
  }

  /* ── v12.4: Categories admin editor ──────────────────────────── */
  .cat-editor-table {
    width: 100%; border-collapse: collapse; font-size: 11px; margin-top: 6px;
  }
  .cat-editor-table th {
    text-align: left; padding: 4px 6px; color: var(--text-dim); font-size: 10px;
    text-transform: uppercase; letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
  }
  .cat-editor-table td { padding: 3px 4px; vertical-align: middle; }
  .cat-editor-input {
    background: var(--surface2); border: 1px solid var(--border); border-radius: 3px;
    color: var(--text); font-family: 'IBM Plex Sans', sans-serif; font-size: 11px;
    padding: 3px 6px; outline: none; width: 100%;
  }
  .cat-editor-input:focus { border-color: var(--teal); }
  .provisional-badge {
    font-size: 9px; font-family: 'IBM Plex Mono', monospace;
    background: rgba(251,191,36,0.15); color: #FBBF24;
    border: 1px solid rgba(251,191,36,0.3); border-radius: 3px;
    padding: 1px 5px; white-space: nowrap;
  }
  .cat-code-cell {
    font-family: 'IBM Plex Mono', monospace; font-size: 10px;
    color: var(--text-dim); white-space: nowrap;
  }


/* ── Ephemeral [Slip] undo toast (v14.2) ── */
.undo-toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 400; display: flex; align-items: center; gap: 14px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  font-size: 13px; color: var(--text); max-width: 90vw;
}
.undo-toast .undo-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.undo-toast .undo-btn {
  background: none; border: none; color: var(--teal); font-weight: 600;
  cursor: pointer; font-size: 13px; font-family: inherit; padding: 2px 4px; flex-shrink: 0;
}
.undo-toast .undo-btn:hover { text-decoration: underline; }

/* ── In-range pricing signal chip (v14.3) ── */
.in-range-chip {
  display: inline-block; margin-top: 5px;
  font-size: 9px; font-weight: 600; letter-spacing: 0.03em;
  border: 1px solid; border-radius: 3px; padding: 1px 6px;
  font-family: 'IBM Plex Mono', monospace;
}

/* ── B3: Office tasks collapsible toggle (mobile) ── */
.office-tasks-toggle {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; margin-bottom: 12px;
  border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer; user-select: none;
  background: var(--surface2); font-size: 11px;
  transition: border-color 0.15s;
}
.office-tasks-toggle:hover { border-color: var(--origin-external); }
.office-tasks-badge {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  padding: 1px 7px; border-radius: 10px; font-weight: 600;
  background: rgba(217,164,97,0.2); color: var(--origin-external);
  border: 1px solid rgba(217,164,97,0.4);
}

/* ── SORT drawer: collapsible sort control for card-mode registers ──
   Sort buttons read differently from filter chips: dashed border +
   up/down sort glyph (direction arrow when active). */
.sort-drawer {
  border: 1px dashed var(--border); border-radius: 6px;
  background: var(--surface2); max-width: 100%; align-self: stretch;
}
.sort-drawer-toggle {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 12px; width: 100%; border: none; background: transparent;
  cursor: pointer; user-select: none; font-family: 'IBM Plex Sans', sans-serif;
}
.sort-drawer-ico {
  width: 13px; height: 13px; flex: 0 0 auto; color: var(--text-dim);
  display: inline-flex; align-items: center; justify-content: center;
}
.sort-drawer-ico svg { width: 100%; height: 100%; display: block; }
.sort-drawer-toggle:hover .sort-drawer-ico { color: var(--teal); }
.sort-caret { font-size: 10px; color: var(--text-dim); margin-left: auto; white-space: nowrap; }
.sort-drawer-body { display: flex; flex-direction: column; gap: 7px; padding: 2px 12px 10px; }
.sort-drawer-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.sort-drawer-row > .filter-label { min-width: 124px; }
.sort-select {
  padding: 3px 8px; border-radius: 3px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer;
  font-size: 11px; font-family: 'IBM Plex Sans', sans-serif; max-width: 280px;
}
.sort-select:hover, .sort-select:focus { border-color: var(--teal); outline: none; }
.sort-btn {
  padding: 3px 10px; border-radius: 3px; border: 1px dashed var(--border);
  background: transparent; color: var(--text-dim); cursor: pointer; font-size: 11px;
  white-space: nowrap; flex-shrink: 0; font-family: 'IBM Plex Sans', sans-serif;
  transition: all 0.12s; display: inline-flex; align-items: center; gap: 5px;
}
.sort-btn .sort-btn-ico {
  width: 11px; height: 11px; flex: 0 0 auto; font-size: 9px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; opacity: 0.75;
}
.sort-btn .sort-btn-ico svg { width: 100%; height: 100%; display: block; }
.sort-btn:hover { border-color: var(--teal); color: var(--teal); background: var(--teal-dim); }
.sort-btn.active { border: 1px solid var(--teal); color: var(--teal); background: var(--teal-dim); }

/* ── B3: Builder Logistics mobile layout ── */
.view-toggle-ctrl { display: flex; gap: 6px; align-items: center; }
@media (max-width: 640px) {
  .view-toggle-ctrl { display: none; }
  .logistics-cards-grid { flex-direction: column; gap: 8px; }
  .logistics-cards-grid .inv-card { min-width: unset; max-width: unset; width: 100%; box-sizing: border-box; }
}

/* Mobile: iOS Safari auto-zooms into any focused input whose computed
   font-size is < 16px, and never zooms back out — leaving the page stuck
   zoomed and scrolled out of position (notably on the login screen, then
   carried into the main app). Forcing 16px on touch keeps pinch-zoom
   available (unlike maximum-scale=1) while preventing the focus auto-zoom. */
@media (max-width: 640px) {
  input, select, textarea, .login-input { font-size: 16px; }
}

/* ── G2: Role Home / dashboard ── */
.home-card {
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); margin-bottom: 12px; overflow: hidden;
}
.home-card-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.home-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
}
.home-row:last-child { border-bottom: none; }
.home-stat-strip { display: flex; gap: 10px; flex-wrap: wrap; }
.home-stat {
  flex: 1; min-width: 130px; text-align: left;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); cursor: pointer; transition: border-color 0.15s;
}
.home-stat:hover { border-color: var(--home-accent, var(--role-architect)); }
.home-quick-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.home-action-btn {
  padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); cursor: pointer; font-size: 12px; font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
}
.home-action-btn:hover { background: var(--surface2); }
@media (max-width: 640px) {
  .home-stat { min-width: calc(50% - 5px); }
  .home-action-btn { flex: 1; min-width: calc(50% - 4px); text-align: center; }
}

/* ── v17.0.0: tab-shell navigation ──
   The nav tabs and the active view's panel share ONE bordered container; the
   active tab connects to its panel by a masked-bottom-border folder-tab join
   (no overlay, no JS). The panel header is the per-view band. */
.tab-shell { margin: 10px 12px 0; --panel-bg: var(--surface); }
.nav-cards {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end;
  position: relative; z-index: 2;
}
.nav-tab {
  min-width: 150px; max-width: 240px; text-align: left; cursor: pointer;
  padding: 7px 11px 11px;                            /* extra bottom padding → more proportional height + space from the band */
  margin-bottom: 0;                                  /* inactive tabs sit ON the band's top line (bottom edge at it), not over it */
  border: 1px solid var(--border); border-bottom: none;  /* open bottom → the band's top border runs unbroken beneath inactive tabs */
  border-radius: 8px 8px 0 0; background: var(--surface);
  display: flex; flex-direction: column; gap: 3px;
  transition: border-color 0.15s, background 0.15s;
}
.nav-tab:hover { border-color: var(--tab-accent, var(--nav-accent, var(--teal))); }
.nav-tab.active {
  border-color: var(--tab-accent, var(--nav-accent, var(--teal)));
  border-bottom: 1px solid var(--panel-bg);          /* mask the panel's top border under the tab */
  background: var(--panel-bg);
  margin-bottom: -1px;                                /* dip into the panel by exactly one border-width */
  z-index: 3;
}
.nav-tab-row { display: flex; align-items: center; gap: 7px; min-width: 0; }
.nav-tab-ico { width: 15px; height: 15px; flex: 0 0 auto; color: var(--text-dim); display: inline-flex; }
.nav-tab-ico svg { width: 100%; height: 100%; display: block; }
.nav-tab.active .nav-tab-ico { color: var(--tab-accent, var(--nav-accent, var(--teal))); }
.nav-tab-label { min-width: 0; flex: 0 1 auto; font-size: 12px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-tab.active .nav-tab-label { color: var(--tab-accent, var(--nav-accent, var(--teal))); }
.nav-tab-count { margin-left: auto; padding-left: 8px; font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--text-dim); }
.nav-tab-alert {
  margin-left: auto; font-size: 10px; font-weight: 600; padding: 1px 7px; border-radius: 8px;
  background: var(--origin-external); color: #fff; min-width: 14px; text-align: center;
}
.nav-tab-sub { font-size: 10px; color: var(--text-dim); margin-left: 22px; }  /* align under the label (past the 15px icon + 7px gap), not under the icon */

/* The active view's bordered container; its top border is what the active tab joins. */
.tab-panel {
  border: 1px solid var(--nav-accent, var(--teal)); border-radius: 8px;
  background: var(--panel-bg); position: relative; z-index: 1; overflow: hidden;
}
.tab-shell.flush-left .tab-panel { border-radius: 0 8px 8px 8px; }  /* Home flush-left → tab caps the corner */
.tab-panel > .panel { background: transparent; border-bottom: none; }

/* view band — the per-view header at the top of the panel (VIEW_META) */
.view-band {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 13px 20px; border-bottom: 1px solid var(--border);
}
.view-band-head { display: flex; align-items: center; gap: 13px; min-width: 0; }
.view-band-ico { width: 26px; height: 26px; flex: 0 0 auto; color: var(--nav-accent, var(--teal)); display: inline-flex; align-items: center; }
.view-band-ico svg { width: 100%; height: 100%; display: block; }
.view-band-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.view-band-titlerow { display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; }
.view-band-title { font-size: 18px; font-weight: 600; color: var(--nav-accent, var(--teal)); line-height: 1.15; }
.view-band-count {
  font-family: 'IBM Plex Mono', monospace; font-size: 11px;
  color: var(--nav-accent, var(--teal));
  background: color-mix(in srgb, var(--nav-accent, var(--teal)) 16%, transparent);
  border-radius: 10px; padding: 1px 9px;
}
.view-band-desc { font-size: 11px; color: var(--text-dim); }
.view-band-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.view-band-btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap;
  font-size: 12px; font-weight: 500; font-family: 'IBM Plex Sans', sans-serif;
  padding: 6px 13px; border-radius: 6px;
  border: 1px solid var(--nav-accent, var(--teal)); background: transparent; color: var(--nav-accent, var(--teal));
  transition: opacity 0.12s;
}
.view-band-btn:hover { opacity: 0.85; }
.view-band-btn.primary { background: var(--nav-accent, var(--teal)); color: var(--role-architect-ink, #0a1a2e); border-color: var(--nav-accent, var(--teal)); }

.nav-card-alert {
  font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 8px;
  background: var(--origin-external); color: #fff; min-width: 14px; text-align: center;
}
.nav-drawer {
  width: 100%; box-sizing: border-box; margin-top: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; display: flex; gap: 18px;
}
.nav-menu-col { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 150px; }
.nav-menu-group {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-dim); margin-bottom: 4px;
}
.nav-menu-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--border); background: var(--surface); border-radius: 6px;
  cursor: pointer; color: var(--text); font-size: 12px; text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.nav-menu-item:hover { background: var(--surface2); border-color: var(--nav-accent, var(--teal)); }
.nav-menu-item.active {
  background: var(--surface2); color: var(--nav-accent, var(--teal)); font-weight: 600;
  border-color: var(--nav-accent, var(--teal));
}
.nav-menu-label { flex: 1; }
.nav-menu-count { font-family: 'IBM Plex Mono', monospace; font-size: 10px; color: var(--text-dim); }
.nav-menu-item.nav-dim { opacity: 0.45; }
/* Icon coverage pass — nav menu-item leading glyph */
.nav-menu-item { gap: 8px; }
.nav-menu-ico { width: 15px; height: 15px; flex: 0 0 auto; color: var(--text-dim); display: inline-flex; }
.nav-menu-ico svg { width: 100%; height: 100%; display: block; }
.nav-menu-item.active .nav-menu-ico { color: var(--nav-accent, var(--teal)); }
/* nav-card leading glyph (Home / All views) */
.nav-card-ico { width: 14px; height: 14px; display: inline-flex; vertical-align: -2px; margin-right: 4px; color: currentColor; }
.nav-card-ico svg { width: 100%; height: 100%; display: block; }
@media (max-width: 640px) {
  .tab-shell { margin: 10px 8px 0; }
  .nav-tab { flex: 1 1 calc(33% - 6px); min-width: calc(33% - 6px); max-width: none; padding: 6px 9px 10px; }
  /* Tabs span full width on mobile, so long labels wrap (not clip) and the
     active "All views" tab is flush right — square the panel's top-right corner.
     Reserve a 2-line label so a wrapped tab and a 1-line tab share one height
     (tops stay aligned). */
  .nav-tab-label { flex: 1 1 auto; white-space: normal; font-size: 11px; line-height: 1.2; min-height: 2.4em; }
  /* Drop the plain count on mobile so the label gets the full width to wrap
     (the count still shows in the band and the All-views menu); keep alerts. */
  .nav-tab-count { display: none; }
  .nav-tab-sub { font-size: 9px; }
  .tab-shell.flush-right .tab-panel { border-radius: 8px 0 8px 8px; }
  .nav-drawer { flex-direction: column; gap: 10px; }
  .view-band { padding: 11px 14px; }
  .view-band-actions { width: 100%; }
}
