:root {
  --bg: #f4f5f6;
  --surface: #ffffff;
  --ink: #17202a;
  --muted: #64717d;
  --line: #d8dde2;
  --navy: #163f6b;
  --navy-soft: #edf3f8;
  --amber: #c76a00;
  --amber-soft: #fff7e8;
  --red: #b3261e;
  --green: #167345;
  --radius: 5px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 1180px; font-size: 13px; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.primary { border: 1px solid var(--navy); background: var(--navy); border-radius: 4px; color: white; padding: 7px 11px; font-weight: 700; }
.primary:hover { background: #0f3154; }
.primary:disabled, .secondary:disabled { cursor: wait; opacity: .55; }
.topbar { height: 58px; display: grid; grid-template-columns: 250px 1fr auto; align-items: center; background: var(--surface); border-bottom: 1px solid #b9c0c7; padding: 0 18px; }
.brand { font-size: 23px; font-weight: 760; letter-spacing: -0.04em; }
.source-line { display: flex; gap: 28px; color: #33404c; padding-left: 22px; border-left: 1px solid var(--line); }
.campaign { color: #3c4853; padding-left: 24px; }
.workspace { height: calc(100vh - 58px); min-height: 700px; display: grid; grid-template-columns: 252px minmax(680px, 1fr) 318px; }
.position-rail, .inspector { background: var(--surface); overflow: auto; }
.position-rail { border-right: 1px solid #b9c0c7; padding: 18px; }
.inspector { border-left: 1px solid #b9c0c7; padding: 18px; }
.rail-title { text-transform: uppercase; font-size: 11px; font-weight: 750; letter-spacing: .08em; margin-bottom: 13px; }
.segmented { display: grid; grid-template-columns: 1fr 1.25fr; margin-bottom: 16px; }
.segmented button { border: 1px solid #bfc6cd; background: white; padding: 7px; color: #303943; }
.segmented button:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.segmented button:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.segmented .active { background: var(--navy); color: white; border-color: var(--navy); }
form label { display: block; color: #4b5661; font-size: 11px; margin-bottom: 11px; }
input, textarea, select { width: 100%; margin-top: 4px; border: 1px solid #cbd1d7; border-radius: 3px; background: #fff; color: var(--ink); padding: 7px 8px; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--navy); box-shadow: 0 0 0 2px #dce8f2; }
textarea { min-height: 62px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.broker-import { margin: -2px 0 13px; padding: 9px; border: 1px solid #c9d8e5; border-radius: var(--radius); background: var(--navy-soft); }
.broker-import .secondary { width: 100%; color: var(--navy); border-color: #9eb6ca; }
.broker-import label { margin: 9px 0 0; }
.broker-import [hidden] { display: none; }
.broker-import small { display: block; margin-top: 7px; color: var(--muted); font-size: 9px; line-height: 1.35; }
.check { display: flex; gap: 7px; align-items: center; margin: 7px 0; }
.check input { width: auto; margin: 0; accent-color: var(--navy); }
.bps-only { display: none; }
body[data-strategy="BPS"] .bps-only { display: block; }
.cross-only { display: none; }
body[data-mode="cross"] .cross-only { display: block; }
label small { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; line-height: 1.35; }
.rail-foot { color: var(--muted); font-size: 10px; margin-top: 18px; }
.main-panel { padding: 0 14px 14px; overflow: auto; }
.tabs { height: 58px; display: flex; align-items: stretch; gap: 24px; border-bottom: 1px solid var(--line); }
.tab { border: 0; background: transparent; padding: 0 14px; font-weight: 680; color: #37424d; border-bottom: 3px solid transparent; }
.tab.active { color: var(--navy); border-color: var(--navy); }
.tab-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.secondary, .file-button { border: 1px solid #bfc8d0; background: white; border-radius: 4px; color: #263540; padding: 7px 11px; font-weight: 650; }
.file-button input { display: none; }
.data-alert { margin: 14px 0 -2px; border: 1px solid #d09a45; border-left: 5px solid var(--amber); background: var(--amber-soft); border-radius: var(--radius); padding: 12px 14px; color: #744000; line-height: 1.45; }
.data-alert.error { border-color: #d39a96; border-left-color: var(--red); background: #fff1f0; color: #7f211b; }
.data-alert strong { display: block; margin-bottom: 3px; text-transform: uppercase; font-size: 11px; letter-spacing: .03em; }
.data-alert[hidden] { display: none; }
.gate-strip { margin: 14px 0; border: 1px solid #e0a34e; background: var(--amber-soft); border-radius: var(--radius); display: grid; grid-template-columns: 180px repeat(4, 1fr); min-height: 82px; }
.gate-title { padding: 15px; color: var(--amber); font-weight: 750; text-transform: uppercase; font-size: 11px; }
.gate-item { border-left: 1px solid #eadac2; padding: 13px 12px; text-align: center; }
.gate-item span { display: block; color: var(--muted); font-size: 10px; margin-bottom: 7px; }
.gate-item strong { font-size: 16px; font-weight: 650; }
.negative { color: var(--red) !important; }
.positive { color: var(--green) !important; }
.ranking, .counterfactual { background: var(--surface); border: 1px solid #cfd5da; border-radius: var(--radius); }
.section-head { height: 47px; display: flex; align-items: center; justify-content: space-between; padding: 0 15px; border-bottom: 1px solid var(--line); }
h1 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; margin: 0; }
.section-head span { color: var(--muted); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { font-size: 9px; font-weight: 720; color: #4d5964; background: #f7f8f9; padding: 9px 7px; border-bottom: 1px solid #cfd5da; border-right: 1px solid #e6e9ec; text-align: left; white-space: nowrap; }
td { padding: 10px 7px; border-bottom: 1px solid #e0e4e8; border-right: 1px solid #edf0f2; white-space: nowrap; }
tbody tr { transition: background .12s ease; }
tbody tr:hover, tbody tr.selected { background: var(--navy-soft); }
tbody tr.selected { box-shadow: inset 3px 0 var(--navy); }
.decision { font-size: 10px; border: 1px solid; border-radius: 3px; padding: 5px 6px; display: inline-block; }
.decision.paper { color: var(--green); border-color: #72a88b; }
.decision.review { color: var(--amber); border-color: #dfa24e; }
.decision.blocked { color: var(--red); border-color: #d59a96; }
.table-note { display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; padding: 10px 14px; }
.counterfactual { margin-top: 14px; padding: 14px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.scenario { border-right: 1px solid var(--line); padding: 2px 14px 2px 2px; min-height: 104px; }
.scenario:last-child { border-right: 0; }
.scenario h2 { font-size: 11px; text-transform: uppercase; margin: 0 0 12px; }
.metric { display: flex; justify-content: space-between; gap: 10px; margin: 7px 0; color: #44515d; }
.metric strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.warning-band { margin-top: 14px; border: 1px solid #e0a34e; background: var(--amber-soft); border-radius: var(--radius); display: grid; grid-template-columns: 150px 1fr; gap: 12px; padding: 13px 15px; line-height: 1.45; }
.warning-band strong { color: var(--amber); text-transform: uppercase; font-size: 11px; }
.inspector-kicker { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.inspector h2 { font-size: 18px; margin: 4px 0 15px; }
.inspect-section { border-top: 1px solid var(--line); padding: 13px 0; }
.inspect-section h3 { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; margin: 0 0 10px; color: #4e5a65; }
.violation { color: var(--red); margin: 7px 0; line-height: 1.35; }
.warn { color: var(--amber); margin: 7px 0; line-height: 1.35; }
.decision-box { border: 1px solid currentColor; border-radius: var(--radius); padding: 13px; text-align: center; font-size: 16px; font-weight: 760; }
.empty { color: var(--muted); padding-top: 40px; text-align: center; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: #17202a; color: white; padding: 10px 14px; border-radius: 4px; opacity: 0; pointer-events: none; transition: .18s ease; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.connection-status.connected { color: var(--green); }
.connection-status.offline { color: var(--red); }
.login-overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(19, 29, 39, .72); backdrop-filter: blur(5px); }
.login-overlay[hidden] { display: none; }
.login-panel { width: min(390px, calc(100vw - 32px)); background: white; border-radius: 7px; padding: 28px; box-shadow: 0 22px 70px #0005; }
.login-panel h2 { margin: 24px 0 7px; font-size: 20px; }
.login-panel p { margin: 0 0 20px; color: var(--muted); line-height: 1.45; }
.login-panel .primary { width: 100%; padding: 10px; margin-top: 6px; }
#login-error { min-height: 18px; margin-top: 12px; text-align: center; }
@media (max-width: 1250px) { body { min-width: 1024px; } .workspace { grid-template-columns: 230px minmax(600px, 1fr); } .inspector { position: fixed; right: 0; top: 58px; bottom: 0; width: 330px; box-shadow: -8px 0 24px #0002; transform: translateX(100%); transition: transform .2s ease; z-index: 5; } .inspector.open { transform: translateX(0); } }
@media (max-width: 800px) {
  body { min-width: 0; font-size: 12px; }
  .topbar { height: auto; min-height: 96px; grid-template-columns: 1fr auto; gap: 8px 14px; padding: 12px 14px; }
  .brand { font-size: 21px; }
  .source-line { grid-column: 1 / -1; order: 3; padding: 8px 0 0; border-left: 0; border-top: 1px solid var(--line); flex-wrap: wrap; gap: 7px 16px; font-size: 10px; }
  .campaign { padding: 0; font-size: 10px; }
  .workspace { height: auto; min-height: 0; display: block; }
  .position-rail { border-right: 0; border-bottom: 1px solid #b9c0c7; padding: 15px; }
  .main-panel { padding: 0 10px 12px; overflow: visible; }
  .tabs { height: auto; min-height: 54px; gap: 6px; flex-wrap: wrap; }
  .tab { min-height: 45px; padding: 0 8px; }
  .tab-actions { width: 100%; justify-content: flex-end; padding-bottom: 9px; }
  .gate-strip { grid-template-columns: 1fr 1fr; }
  .gate-title { grid-column: 1 / -1; border-bottom: 1px solid #eadac2; }
  .gate-item { min-height: 74px; }
  .section-head { align-items: flex-start; height: auto; min-height: 48px; padding: 10px 12px; gap: 8px; }
  .section-head span { text-align: right; font-size: 10px; }
  .table-wrap { max-width: calc(100vw - 22px); overflow-x: auto; }
  table { min-width: 920px; }
  .counterfactual { grid-template-columns: 1fr; }
  .scenario { border-right: 0; border-bottom: 1px solid var(--line); padding: 8px 2px 14px; min-height: 0; }
  .scenario:last-child { border-bottom: 0; }
  .warning-band { grid-template-columns: 1fr; }
  .inspector { position: static; width: auto; transform: none; box-shadow: none; border-left: 0; border-top: 1px solid #b9c0c7; padding: 16px; }
}
