/* MBI Process Map - estate dark theme */
:root {
  color-scheme: dark;
  --bg: #091018;
  --bg-2: #0f1722;
  --panel: #121b25;
  --panel-2: #172231;
  --border: #243445;
  --border-2: #2f4257;
  --text: #eef4fb;
  --muted: #a6b7ca;
  --muted-2: #7e91a7;
  --primary: #1d6ec8;
  --primary-hover: #165ba7;
  --accent: #2cc39a;
  --warn: #f2b84b;
  --danger: #e5484d;
  --danger-bg: #2a1418;
  --radius: 14px;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 Arial, Helvetica, sans-serif; }
a { color: #8ec3ff; }
button, input, select, textarea { font: inherit; color: inherit; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2a3a4d; border-radius: 10px; }
::-webkit-scrollbar-track { background: #0c141d; }
* { scrollbar-color: #2a3a4d #0c141d; }

/* topbar: centered brand row above a centered tab row; the auth chip sits top-left, API pill top-right */
.topbar { position: sticky; top: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 20px 10px; background: rgba(12, 20, 29, 0.96); border-bottom: 1px solid var(--border); backdrop-filter: blur(6px); }
body.test-banner-active .topbar { top: 48px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); font-weight: 800; }
.brand-icon { width: 44px; height: 44px; }
.brand-title { white-space: nowrap; font-size: 22px; letter-spacing: .01em; }
.nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.nav-btn { padding: 8px 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 600; }
.nav-btn:hover { background: var(--panel-2); color: var(--text); }
.nav-btn.active { background: #16304d; color: #cfe5ff; }
.admin-only { display: none; }
body.is-admin .admin-only { display: inline-flex; }
.status-pill { position: absolute; top: 14px; right: 20px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); font-size: 12px; white-space: nowrap; }
.status-pill.ok { color: #9be7c4; border-color: #1f5c46; }
.status-pill.bad { color: #ffb4b8; border-color: #6b2b30; }

.container { max-width: 1400px; margin: 0 auto; padding: 22px 20px 60px; }
h1 { font-size: 22px; margin: 0 0 14px; }
h2 { font-size: 17px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.page-head .spacer { flex: 1; }
.subtle { color: var(--muted); }
.tiny { font-size: 12px; color: var(--muted-2); }
.added-detail { display: inline-block; margin-top: 3px; padding: 1px 7px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--accent, #1d4ed8); background: color-mix(in srgb, var(--accent, #1d4ed8) 12%, transparent); }

/* panels + grid */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.panel + .panel { margin-top: 14px; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .n { font-size: 26px; font-weight: 800; }
.stat .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.stat.warn .n { color: var(--warn); }
.stat.good .n { color: var(--accent); }

/* tables */
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { position: sticky; top: 0; background: var(--panel-2); color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; z-index: 1; }
.table tr:hover td { background: rgba(255, 255, 255, 0.02); }
.table tr.clickable { cursor: pointer; }
.table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .empty { color: var(--muted); text-align: center; padding: 26px; }

/* pills */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; background: #16304d; color: #8ec3ff; white-space: nowrap; }
.pill.a { background: #14392e; color: #7fe0b8; }
.pill.b { background: #3a2d12; color: #ffd27a; }
.pill.c { background: #2a2f38; color: #b9c6d2; }
.pill.warn { background: #4d2916; color: #ffbf8e; }
.pill.ok { background: #14392e; color: #7fe0b8; }
.pill.danger { background: #3d1a1e; color: #ffb4b8; }
.pill.info { background: #1f2f57; color: #b2c6ff; }
.overdue { color: #ffb4b8; font-weight: 700; }

/* forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
label.field.wide { grid-column: 1 / -1; }
label.field.inline { flex-direction: row; align-items: center; text-transform: none; font-weight: 500; font-size: 13px; }
.field input, .field select, .field textarea, input.input, select.input, textarea.input {
  width: 100%; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--border-2); background: #0e1621; color: var(--text); font-size: 14px; text-transform: none; letter-spacing: 0; font-weight: 400;
}
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29, 110, 200, 0.25); }
.field select option { background: #0e1621; color: var(--text); }
.field textarea { min-height: 96px; resize: vertical; }
.field input[type="checkbox"] { width: auto; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.form-hint { color: var(--muted); font-size: 12px; margin-top: 8px; }
.form-error { margin-top: 10px; padding: 10px 12px; border-radius: 10px; border: 1px solid #7e3743; background: var(--danger-bg); color: #ffd6dc; }
.form-success { margin-top: 10px; padding: 10px 12px; border-radius: 10px; border: 1px solid #1f5c46; background: #10241d; color: #9be7c4; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--border-2); background: var(--panel-2); color: var(--text); font-weight: 700; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #3d5670; background: #1c2a3b; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { background: transparent; border-color: #6b2b30; color: #ffb4b8; }
.btn.danger:hover { background: var(--danger-bg); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.link { background: transparent; border-color: transparent; color: #8ec3ff; padding: 4px 6px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.toolbar .input, .toolbar select { width: auto; min-width: 150px; }
.toolbar .search { min-width: 260px; flex: 1; }

/* modal + drawer */
.modal-backdrop { position: fixed; inset: 0; z-index: 10070; display: grid; place-items: center; background: rgba(4, 8, 14, 0.72); padding: 20px; }
.modal { width: min(820px, 100%); max-height: min(88vh, 900px); display: flex; flex-direction: column; background: var(--bg-2); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
.modal.wide { width: min(1100px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-foot { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--border); }
.modal-close { border: 0; background: transparent; color: #c7d4e8; font: 700 22px/1 Arial, Helvetica, sans-serif; cursor: pointer; }
.preview-frame { width: 100%; min-height: 360px; border: 0; border-radius: 12px; background: #fff; }

/* toast */
.toast-root { position: fixed; right: 18px; bottom: 18px; z-index: 10090; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 11px 14px; border-radius: 12px; background: #172231; border: 1px solid var(--border-2); color: var(--text); box-shadow: var(--shadow); max-width: 420px; animation: fadeIn .2s ease; }
.toast.ok { border-color: #1f5c46; }
.toast.error { border-color: #7e3743; background: var(--danger-bg); color: #ffd6dc; }
.toast.warn { border-color: #6b4a12; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* test-environment banner (env-agnostic; shows only on *-test hosts) */
body.test-banner-active { padding-top: 48px; }
.test-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 10050; display: none; align-items: center; justify-content: center; gap: 14px; background: #8a1f2d; color: #fff; text-align: center; font: 800 13px/1.2 Arial, Helvetica, sans-serif; letter-spacing: .12em; padding: 12px 16px; box-shadow: 0 10px 24px #0004; }
body.test-banner-active .test-banner { display: flex; }


/* ---------- Process Map ---------- */
:root { --wait-w: 92px; --step-w: 212px; --end-w: 170px; --va: #2cc39a; --nva: #e5677f; --inc: #8e99a6; --box: #2a2412; --box-border: #6b5520; }
.empty-state { color: var(--muted); padding: 30px; text-align: center; }
.spacer { flex: 1; }
.pre { white-space: pre-wrap; }
.warn-text { color: var(--warn); }
.crumbs { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.nav-search { width: 240px; padding: 7px 11px; border-radius: 10px; border: 1px solid var(--border-2); background: #0e1621; color: var(--text); margin-left: 8px; }
.input { padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border-2); background: #0e1621; color: var(--text); }
.input.sm { padding: 4px 8px; font-size: 12px; }
select.input option { background: #0e1621; }
.pair { display: flex; gap: 6px; }
.pair input { flex: 1 1 60px; min-width: 0; }
.pair select { flex: 1 1 90px; }
.pill.current { background: #16304d; color: #8ec3ff; }
.pill.future { background: #2a2357; color: #c6b8ff; }
.pill.muted { background: #2a2f38; color: #a7b1bd; }
.pill.k-idea { background: #1f2f57; color: #b2c6ff; }
.pill.k-planned { background: #3a2d12; color: #ffd27a; }
.pill.k-active { background: #4d2916; color: #ffbf8e; }
.pill.k-complete { background: #14392e; color: #7fe0b8; }
.pill.k-canceled { background: #2a2f38; color: #8e99a6; }
.stat.link { text-decoration: none; color: var(--text); }
.stat.link:hover { border-color: var(--border-2); }
.stat-row { margin-bottom: 14px; }
.attention { border-color: #6b4a12; background: #1d1810; margin-bottom: 14px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--border); margin: 12px 0 14px; }
.tab { padding: 8px 14px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-weight: 700; cursor: pointer; }
.tab.active { color: #cfe5ff; border-bottom-color: var(--primary); }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.plain-list li:last-child { border-bottom: 0; }
.history li { line-height: 1.5; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 12px 0; }
.facts dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding-top: 2px; }
.facts dd { margin: 0; }
.check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px 10px; max-height: 180px; overflow: auto; padding: 8px; border: 1px solid var(--border-2); border-radius: 10px; background: #0e1621; text-transform: none; letter-spacing: 0; font-weight: 400; }
.check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); }
.modal-foot .spacer { flex: 1; }
.update-bar { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 10080; display: flex; gap: 12px; align-items: center; padding: 10px 14px; border-radius: 12px; background: #16304d; border: 1px solid #2f5a8a; }

/* home: value streams with their maps, in hand-off order */
.stream { margin: 18px 0; }
.stream.depth-1, .stream.depth-2 { margin-left: 18px; padding-left: 14px; border-left: 2px solid var(--border); }
.stream-head { margin-bottom: 8px; }
.stream-head h2, .stream-head h3 { margin: 0; }
.map-row { display: flex; flex-wrap: wrap; align-items: stretch; gap: 10px; }
.map-card { display: flex; flex-direction: column; gap: 8px; width: 300px; padding: 14px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--border); color: var(--text); text-decoration: none; }
.map-card:hover { border-color: #3d5670; background: #142030; }
.map-card-head { display: flex; flex-wrap: wrap; gap: 6px; }
.map-card-title { font-weight: 800; font-size: 15px; }
.map-card-stats { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); }
.map-card-stats b { color: var(--text); }
.burst-count { color: #9be15d; font-weight: 700; }
.handoff-arrow { align-self: center; font-size: 26px; color: #4fb0f6; }

/* map page */
.map-head h1 { margin-right: 4px; }
.map-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--muted); font-size: 13px; }
.map-meta b { color: var(--text); font-weight: 600; }
.lane { margin-bottom: 22px; }
.lane-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 6px; }
.lane-head h3 { margin: 0; font-size: 16px; }
.lane-metrics { font-size: 13px; color: var(--muted); }
.lane-metrics b { color: var(--text); }
.lane-scroll { overflow-x: auto; padding: 8px 2px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: #0b131c; }
.vsm { display: grid; grid-auto-rows: auto; align-items: stretch; min-width: max-content; }
.wait-cell { position: relative; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
.flow-arrow { color: #4fb0f6; font-size: 22px; }
.tri { display: inline-flex; align-items: flex-end; justify-content: center; width: 78px; height: 58px; padding-bottom: 7px; clip-path: polygon(50% 0, 100% 100%, 0 100%); background: linear-gradient(#ff9fb0, #e5677f); color: #3d0d18; font-size: 11px; font-weight: 800; text-align: center; line-height: 1.1; }
.tri.sm { width: 56px; height: 30px; font-size: 9px; padding-bottom: 3px; vertical-align: middle; }
.ins { position: absolute; bottom: -2px; left: 50%; transform: translateX(-50%); width: 22px; height: 22px; border-radius: 50%; border: 1px solid #2f5a8a; background: #16304d; color: #cfe5ff; font-weight: 800; line-height: 18px; cursor: pointer; opacity: .35; }
.wait-cell:hover .ins, .ins:focus { opacity: 1; }
.step-card { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; width: var(--step-w); height: 100%; min-height: 150px; padding: 10px 10px 8px 14px; border-radius: 12px; background: var(--box); border: 1px solid var(--box-border); color: var(--text); text-align: left; cursor: pointer; font: inherit; }
.step-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; border-radius: 12px 0 0 12px; background: var(--va); }
.step-card.vt-non_value_add::before { background: var(--nva); }
.step-card.vt-incidental::before { background: var(--inc); }
.step-card:hover { border-color: #b38f2e; }
.step-card.selected { outline: 2px solid #4fb0f6; outline-offset: 2px; }
.step-n { font-size: 11px; font-weight: 800; color: #f2b33d; }
.burst { position: absolute; top: 6px; right: 8px; color: #9be15d; font-weight: 800; font-size: 12px; }
.step-title { font-size: 13px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.step-owner { display: flex; gap: 6px; align-items: center; margin-top: auto; }
.role-chip { display: inline-block; max-width: 170px; padding: 2px 8px; border-radius: 999px; background: #16304d; color: #9fd2ff; font-size: 11px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.role-chip.review { background: #3a2d12; color: #ffd27a; }
.role-chip.none { background: #3d1a1e; color: #ffb4b8; }
.step-systems { display: flex; flex-wrap: wrap; gap: 4px; }
.sys { padding: 1px 6px; border-radius: 6px; background: #1c2a3b; border: 1px solid #2f4257; font-size: 10px; color: #c7d4e8; }
.drill { font-size: 11px; color: #c6b8ff; font-weight: 700; }
.step-pt { font-size: 11px; color: var(--muted); border-top: 1px solid var(--box-border); width: 100%; padding-top: 4px; }
.end-cell { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; justify-content: center; padding: 0 12px; }
.add-step { border-style: dashed; }
.handoff { display: block; padding: 10px; border-radius: 10px; border: 1px dashed #2f5a8a; color: #8ec3ff; text-decoration: none; font-size: 12px; }
/* timeline: waits ride the upper line, process time the lower one (the VSM sawtooth) */
.tl-wait, .tl-work, .tl-total { font-size: 11px; text-align: center; padding: 3px 4px; margin-top: 8px; color: var(--muted); min-height: 22px; }
.tl-wait { border-top: 2px solid #e5677f; color: #ffb4c0; }
.tl-work { border-bottom: 2px solid #2cc39a; margin-top: 30px; color: #9be7c4; }
.tl-total { color: var(--text); border-left: 2px solid var(--border-2); }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }
.lg { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-left: 6px; }
.lg.vt-value_add { background: var(--va); } .lg.vt-non_value_add { background: var(--nva); } .lg.vt-incidental { background: var(--inc); }

/* step drawer */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 10040; width: min(460px, 100%); overflow: auto; padding: 18px; background: var(--bg-2); border-left: 1px solid var(--border); box-shadow: var(--shadow); }
body.test-banner-active .drawer { top: 48px; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.drawer h2 { font-size: 16px; line-height: 1.35; }
.drawer-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }

/* table (fast entry) */
.step-table td { vertical-align: middle; }
.step-table .cell { width: 100%; min-width: 110px; }
.step-table .grow { min-width: 300px; resize: vertical; }
.step-table .pair.cell input { width: 64px; }
.step-table .saved { border-color: #1f5c46; box-shadow: 0 0 0 2px rgba(44, 195, 154, .3); }
.step-table .bad { border-color: #7e3743; }
.quick-add td { background: #0f1a26; }
.table td.actions { white-space: nowrap; text-align: right; }

/* responsibilities */
.duty-list { margin: 0; padding-left: 22px; }
.duty-list li { padding: 4px 0; }

/* improvements board */
.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; align-items: start; }
.board-col { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.board-head { display: flex; gap: 8px; align-items: center; }
.k-card { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 10px; border-radius: 10px; border: 1px solid var(--border-2); background: var(--panel-2); color: var(--text); cursor: pointer; font: inherit; }
.k-card:hover { border-color: #3d5670; }
.k-title { font-size: 13px; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.board-empty { padding: 6px; }

@media (max-width: 900px) {
  :root { --step-w: 180px; --wait-w: 80px; }
  .nav-search { width: 100%; margin: 6px 0 0; }
}

@media print {
  body { background: #fff; color: #000; }
  .topbar, .auth-chip, .test-banner, .tabs, .btn, .drawer, .ins, .legend, #toastRoot, .update-bar { display: none !important; }
  body.test-banner-active { padding-top: 0; }
  .container { max-width: none; padding: 0; }
  .lane-scroll { overflow: visible; border: 0; background: none; }
  .step-card { background: #fff7d6; color: #000; border-color: #b38f2e; break-inside: avoid; }
  .role-chip, .sys { background: #eee; color: #000; border-color: #ccc; }
  .tl-wait, .tl-work, .tl-total, .lane-metrics, .map-meta, .tiny, .subtle { color: #000; }
  .vsm { zoom: .6; }
}
.tl-wait.none { border-top-color: transparent; }
table.table.fixed { table-layout: fixed; }
.page-filter { width: 260px; }
.step-table td:nth-child(3) { width: 38%; }
.step-table .grow { min-width: 340px; width: 100%; }
.step-table td:nth-child(4) select { max-width: 230px; }
.step-table th.num, .step-table td.num { width: 36px; }
.tl-work.none { border-bottom-color: transparent; }
