/* MBI Vendor Pricing - 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); }

/* 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); }

/* funnel */
.funnel { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.funnel a { display: block; text-decoration: none; color: var(--text); background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 8px; text-align: center; }
.funnel a:hover { border-color: var(--border-2); }
.funnel .n { font-size: 20px; font-weight: 800; }
.funnel .l { font-size: 11px; color: var(--muted); line-height: 1.2; }

/* 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.status-not-contacted { background: #262e3a; color: #b9c6d2; }
.pill.status-reached-out { background: #16304d; color: #8ec3ff; }
.pill.status-in-discussion { background: #1f2f57; color: #b2c6ff; }
.pill.status-quote-requested { background: #3a2d12; color: #ffd27a; }
.pill.status-quote-received { background: #3c3610; color: #ffe38a; }
.pill.status-sample-trial { background: #3a1f4d; color: #e2b8ff; }
.pill.status-approved-vendor { background: #14392e; color: #7fe0b8; }
.pill.status-not-a-fit { background: #3d1a1e; color: #ffb4b8; }
.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); } }

/* vendor detail */
.detail-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; }
.detail-head h1 { margin: 0; }
.detail-meta { color: var(--muted); font-size: 13px; }
.stepper { display: flex; flex-wrap: wrap; gap: 4px; margin: 14px 0; }
.step { flex: 1 1 100px; text-align: center; padding: 8px 6px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); font-size: 11px; font-weight: 700; cursor: pointer; }
.step.done { background: #14392e; color: #7fe0b8; border-color: #1f5c46; }
.step.current { background: #16304d; color: #cfe5ff; border-color: #2f5f96; }
.step.terminal-bad.current { background: #3d1a1e; color: #ffb4b8; border-color: #6b2b30; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--border); margin: 10px 0 14px; }
.tab { padding: 8px 12px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-weight: 700; cursor: pointer; }
.tab.active { color: var(--text); border-bottom-color: var(--primary); }
.timeline { display: flex; flex-direction: column; gap: 10px; }
.tl-item { display: grid; grid-template-columns: 90px 1fr; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel-2); }
.tl-when { color: var(--muted); font-size: 12px; }
.tl-title { font-weight: 700; }
.tl-body { color: var(--muted); white-space: pre-wrap; margin-top: 4px; font-size: 13px; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.attr-row { display: grid; grid-template-columns: 1.2fr 1.4fr 1.6fr .8fr .5fr auto; gap: 8px; align-items: center; margin-bottom: 6px; }
.attr-row input { width: 100%; }
.empty-state { color: var(--muted); text-align: center; padding: 40px 20px; }
.help { background: var(--panel-2); border: 1px dashed var(--border-2); border-radius: 10px; padding: 10px 12px; font-size: 12px; color: var(--muted); }
code { background: #0e1621; padding: 1px 5px; border-radius: 6px; font-size: 12px; }
.danger-text { color: #ffb4b8; }

@media (max-width: 1100px) {
  .topbar { padding-top: 64px; }
  .funnel { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .status-pill { top: 64px; right: 12px; }
  .brand-title { font-size: 18px; }
  .brand-icon { width: 36px; height: 36px; }
  .container { padding: 16px 12px 60px; }
  .kv { grid-template-columns: 1fr; }
  .tl-item { grid-template-columns: 1fr; }
  .attr-row { grid-template-columns: 1fr 1fr; }
  .modal { max-height: 94vh; }
  .btn, .form-actions .btn { width: 100%; justify-content: center; }
}

/* 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; }

/* products: comparison and history charts */
.ok-text { color: #8ee6c4; }
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 12px; }
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row .input { flex: 1; }
input.factor { width: 90px; text-align: right; }
svg.chart { width: 100%; height: auto; display: block; }
svg.chart .grid { stroke: var(--border); stroke-width: 1; }
svg.chart .axis { fill: var(--muted-2); font-size: 11px; }
svg.chart .lbl { fill: var(--text); font-size: 12px; }
svg.chart .val { fill: var(--muted); font-size: 12px; }
svg.chart .val .good { fill: #8ee6c4; }
svg.chart .val .bad { fill: #ffb4b8; }
svg.chart .stem { stroke: #2f4257; stroke-width: 1; stroke-dasharray: 2 3; }
svg.chart .dot { fill: #4ea1ff; stroke: #0b1520; stroke-width: 1.5; }
svg.chart .dot.best { fill: var(--accent); }
svg.chart .dot.hollow { fill: var(--bg); stroke: var(--warn); stroke-width: 2; }
svg.chart .dot.sq { fill: var(--bg); stroke: var(--muted); stroke-width: 2; }
svg.chart .stale { opacity: .45; }
svg.chart .ours { stroke: var(--warn); stroke-width: 1.5; stroke-dasharray: 6 4; }
svg.chart .ours-label { fill: var(--warn); font-size: 11px; font-weight: 700; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; }
.legend-dot.solid { background: #4ea1ff; }
.legend-dot.hollow { border: 2px solid var(--warn); }
.legend-sq { display: inline-block; width: 10px; height: 10px; border: 2px solid var(--muted); vertical-align: -1px; }
tr.superseded td { opacity: .55; }

/* vendor hunter */
.hunter-running { margin-bottom: 14px; border-color: var(--primary); }
.hunter-desc { margin-top: 4px; color: var(--muted); }
.hunter-new { margin-bottom: 14px; border-color: var(--accent); }
svg.chart .bar { fill: #4ea1ff; }
svg.chart .bar.good { fill: var(--accent); }
svg.chart .bar.bad { fill: #e5484d; }
svg.chart .bar.muted { fill: #3a4d63; }
.dup-group { border-top: 1px solid var(--border); padding: 10px 0; display: grid; gap: 6px; }
.dup-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* photos & drawings */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.file-card { margin: 0; background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; display: grid; }
.file-thumb { all: unset; cursor: pointer; display: grid; place-items: center; height: 140px; background: #0b131b; }
.file-thumb:focus-visible { outline: 2px solid var(--primary); }
.file-thumb img { width: 100%; height: 140px; object-fit: cover; }
.file-icon { font: 800 22px/1 Arial, sans-serif; color: var(--muted); letter-spacing: .08em; }
.file-card figcaption { padding: 8px 10px; display: grid; gap: 4px; font-size: 13px; word-break: break-word; }
.file-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.file-upload { margin-top: 12px; flex-wrap: wrap; }
.best-price { color: #8ee6c4; font-weight: 800; }
.best-price::after { content: ' best'; font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; margin-left: 4px; color: var(--accent); }
.file-card { min-width: 0; }
.file-card figcaption, .file-card figcaption strong { overflow-wrap: anywhere; }
.file-card .file-pill { white-space: normal; text-align: left; }
.update-bar { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 1000; display: flex; gap: 12px; align-items: center; padding: 10px 14px; border-radius: 10px; background: #1d6ec8; color: #fff; box-shadow: 0 6px 24px rgba(0,0,0,.35); font-weight: 600; }
.update-bar .btn { background: #fff; color: #1d6ec8; border-color: #fff; }
