:root {
  color-scheme: light dark;
  --bg: light-dark(#F6F5F1, #07070A);
  --surface: light-dark(#FFFFFF, #0F1015);
  --surface-2: light-dark(#ECE9E2, #171820);
  --border: light-dark(#D6D1C6, #272936);
  --text: light-dark(#171614, #ECE9E2);
  --muted: light-dark(#5E5A52, #9A968D);
  --accent: light-dark(#9E0B1E, #C8102E);
  --accent-hi: light-dark(#B91C1C, #FF4D6A);
  --info: light-dark(#0369A1, #3FA2FF);
  --ok: light-dark(#15803D, #22C55E);
  --trim: light-dark(#9A6F26, #B8893B);
  --font-display: Georgia, 'Times New Roman', serif;
  --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, 'Cascadia Mono', Consolas, monospace;
}
:root:has(> head > meta[name="color-scheme"][content="dark"]) { color-scheme: dark; }
:root:has(> head > meta[name="color-scheme"][content="light"]) { color-scheme: light; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--font-sans); font-size: 14px; line-height: 1.55; }

.page { max-width: 1440px; margin: 0 auto; padding: 20px 24px 56px; }
.header { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-bottom: 18px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.coin { width: 42px; height: 42px; border-radius: 50%; border: 1.5px solid var(--trim); background: var(--surface); color: var(--accent-hi); display: grid; place-items: center; font-family: var(--font-mono); font-weight: 700; flex: none; }
.brand h1 { margin: 0; font-family: var(--font-display); font-size: clamp(22px, 3vw, 31px); font-weight: 500; line-height: 1.1; }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.controls-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.btn { font: 600 13px/1.2 var(--font-sans); padding: 9px 14px; border-radius: 3px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { border-color: var(--accent-hi); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }
.btn.primary:hover { background: var(--accent-hi); }

#theme-toggle .lbl-dark, #theme-toggle .lbl-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) #theme-toggle .lbl-light { display: inline; }
  :root:has(> head > meta[name="color-scheme"][content="light"]) #theme-toggle .lbl-dark { display: inline; }
}
@media (prefers-color-scheme: light) {
  :root:not(:has(> head > meta[name="color-scheme"][content="dark"])) #theme-toggle .lbl-dark { display: inline; }
  :root:has(> head > meta[name="color-scheme"][content="dark"]) #theme-toggle .lbl-light { display: inline; }
}

.e2e-hero { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 4px; padding: 16px 20px; margin-bottom: 22px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.e2e-hero h2 { margin: 0 0 4px; font-family: var(--font-display); font-size: 21px; font-weight: 500; }
.e2e-hero p { margin: 0; color: var(--muted); font-size: 13.5px; max-width: 820px; }

.wedges { margin-bottom: 24px; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.sec-head h2 { margin: 0; font-family: var(--font-display); font-size: 20px; font-weight: 500; }
.sec-head span { color: var(--muted); font-size: 13px; }
.wedge-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.wedge-card { background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--accent); border-radius: 3px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.wedge-card .rank { font-family: var(--font-mono); font-size: 12px; color: var(--trim); font-weight: 700; }
.wedge-card h3 { margin: 0; font-size: 16px; }
.wedge-card p { margin: 0; color: var(--muted); font-size: 13px; flex: 1; }

.filter-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.search-wrap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex: 1; min-width: 240px; }
.input, .select { padding: 8px 12px; border: 1px solid var(--border); border-radius: 3px; background: var(--surface); color: var(--text); font: inherit; }
.input { min-width: 220px; flex: 1; max-width: 360px; }

[role="tablist"] { display: flex; overflow-x: auto; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 18px; scroll-snap-type: inline proximity; scrollbar-width: thin; }
[role="tab"] { position: relative; flex: none; scroll-snap-align: start; background: transparent; border: 0; padding: 10px 14px 12px; font: 600 13px/1.2 var(--font-sans); color: var(--muted); cursor: pointer; white-space: nowrap; }
[role="tab"]:hover { color: var(--text); }
[role="tab"][aria-selected="true"] { color: var(--text); }
[role="tab"][aria-selected="true"]::after { content: ""; position: absolute; inset: auto 0 0; border-block-end: 3px solid var(--accent-hi); }
.panel-inner { padding-block: 4px 12px; }

.catalog-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.saas-card { background: var(--surface); border: 1px solid var(--border); border-radius: 4px; overflow: hidden; display: flex; flex-direction: column; }
.saas-thumb { border-bottom: 1px solid var(--border); background: var(--surface-2); display: block; }
.saas-thumb svg { display: block; width: 100%; height: auto; }
.saas-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.saas-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); font-family: var(--font-mono); }
.saas-body h3 { margin: 0; font-size: 18px; line-height: 1.2; }
.saas-body p { margin: 0; color: var(--muted); font-size: 13.5px; }
.saas-buyer { font-size: 12.5px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 3px; padding: 6px 8px; }
.saas-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 6px; }
.badge-top { font-size: 11px; font-family: var(--font-mono); font-weight: 700; color: var(--trim); border: 1px solid var(--trim); padding: 2px 6px; border-radius: 2px; }

.matrix-sec { margin-top: 34px; }
.table-wrapper { overflow: auto; max-inline-size: 100%; max-block-size: min(520px, 75vh); container-type: inline-size; border: 1px solid var(--border); border-radius: 3px; background: var(--surface); }
.table-wrapper table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
.table-wrapper thead { position: sticky; inset-block-start: 0; z-index: 2; }
.table-wrapper th, .table-wrapper td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table-wrapper thead th { background: var(--surface-2); font-size: 12px; color: var(--muted); }
.table-wrapper tbody th { position: sticky; inset-inline-start: 0; z-index: 1; background: var(--surface); font-family: var(--font-mono); }
.table-wrapper tbody td { background: var(--surface); }
@container (width < 600px) {
  .table-wrapper table, .table-wrapper thead, .table-wrapper tbody, .table-wrapper tr, .table-wrapper th, .table-wrapper td { display: block; white-space: normal; }
  .table-wrapper thead { display: none; }
  .table-wrapper tr { margin-block-end: 12px; border: 1px solid var(--border); border-radius: 3px; }
  .table-wrapper tbody th { position: sticky; inset-block-start: 0; z-index: 2; background: var(--surface-2); border-bottom: 1px solid var(--border); }
  .table-wrapper td:nth-child(2)::before { content: var(--label-2) ": "; font-weight: 700; color: var(--muted); }
  .table-wrapper td:nth-child(3)::before { content: var(--label-3) ": "; font-weight: 700; color: var(--muted); }
  .table-wrapper td:nth-child(4)::before { content: var(--label-4) ": "; font-weight: 700; color: var(--muted); }
  .table-wrapper td:nth-child(5)::before { content: var(--label-5) ": "; font-weight: 700; color: var(--muted); }
  .table-wrapper td:nth-child(6)::before { content: var(--label-6) ": "; font-weight: 700; color: var(--muted); }
  .table-wrapper td:nth-child(7)::before { content: var(--label-7) ": "; font-weight: 700; color: var(--muted); }
}

dialog.preview-dialog { width: min(1320px, 95vw); height: min(860px, 90vh); max-width: none; max-height: none; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--text); padding: 0; overflow: hidden; }
dialog.preview-dialog:modal, dialog.pilot-modal:modal { overscroll-behavior: contain; }
dialog.preview-dialog::backdrop, dialog.pilot-modal::backdrop { overflow: hidden; overscroll-behavior: contain; background: rgba(0,0,0,0.72); }
dialog.pilot-modal { width: min(560px, 94vw); border: 1px solid var(--border); border-top: 3px solid var(--accent); border-radius: 4px; background: var(--surface); color: var(--text); padding: 0; }
dialog.pilot-modal[open] { display: block; }
.pilot-inner { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.pilot-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.pilot-head h2 { margin: 0; font-family: var(--font-display); font-size: 20px; font-weight: 500; }
.pilot-summary { padding: 10px 12px; background: var(--surface-2); border-left: 3px solid var(--ok); font-size: 13px; }
.pilot-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.pilot-field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.pilot-field label { font-weight: 600; }
.pilot-field input { padding: 9px 10px; min-height: 40px; border: 1px solid var(--border); border-radius: 3px; background: var(--surface-2); color: var(--text); font: inherit; font-size: max(1rem, 1em); }
.pilot-field input:focus-visible { outline: 2px solid var(--info); outline-offset: 1px; }
.pilot-field input:is(:user-invalid, .user-invalid-fallback) { border-color: var(--accent-hi); }
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.status-msg { margin: 2px 0 0; font-size: 13px; min-height: 1.4em; color: var(--muted); }
.status-msg.is-ok { color: var(--ok); font-weight: 600; }
.status-msg.is-warn { color: var(--accent-hi); }
.status-msg a { color: var(--info); font-weight: 600; }
@media (max-width: 560px) { .pilot-grid { grid-template-columns: minmax(0, 1fr); } }
.dlg-shell { display: grid; grid-template-rows: auto minmax(0, 1fr); height: 100%; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.dlg-frame { width: 100%; height: 100%; border: 0; background: #111; }

/* End-to-End OS & Self-Serve Bundle Builder Layout */
.e2e-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr); gap: 18px; align-items: start; }
.stage-card { background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 14px; margin-bottom: 12px; }
.stage-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.stage-head h3 { margin: 0; font-size: 15px; }
.stage-handoff { font-family: var(--font-mono); font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.mod-pills { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.mod-pick { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 3px; background: var(--surface-2); cursor: pointer; font-size: 13px; }
.mod-pick.is-on { border-color: var(--accent-hi); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.cart-panel { position: sticky; top: 18px; background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--accent); border-radius: 4px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.tier-ladder { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; font-family: var(--font-mono); font-size: 11.5px; text-align: center; }
.tier-step { padding: 6px 4px; border: 1px solid var(--border); border-radius: 3px; background: var(--surface-2); color: var(--muted); }
.tier-step.active { border-color: var(--ok); color: var(--ok); font-weight: 700; }
.trace-strip { background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 12px 14px; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 12.5px; }

@media (max-width: 1180px) {
  .wedge-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .e2e-grid { grid-template-columns: minmax(0, 1fr); }
  .cart-panel { position: static; }
}
@media (max-width: 680px) {
  .page { padding: 14px 14px 40px; }
  .wedge-grid, .catalog-grid { grid-template-columns: minmax(0, 1fr); }
  .tier-ladder { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
