/* BidIQ Margin — management-grade finance UI
   White working surface, deep navy navigation, restrained blue accent.
   Green = within policy, amber = review / conditional, red = genuine breach. */

:root {
  --navy: #14284B;
  --navy-2: #1D3763;
  --navy-3: #2B4878;
  --paper: #FFFFFF;
  --canvas: #F4F6F9;
  --ink: #1A2433;
  --muted: #5D6878;
  --faint: #8A94A3;
  --rule: #DDE2E9;
  --rule-strong: #C7CFDA;
  --blue: #2A5DB0;
  --blue-soft: #E8EFFA;
  --green: #1E7A4C;
  --green-soft: #E7F3EC;
  --amber: #9A6400;
  --amber-soft: #FBF1DC;
  --red: #B3261E;
  --red-soft: #FBE9E7;
  --neutral-soft: #EEF1F5;
  --radius: 6px;
  --font: "Public Sans", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

html, body { background: var(--canvas); }
body {
  font-family: var(--font);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  font-feature-settings: "tnum" 1, "lnum" 1;
  -webkit-font-smoothing: antialiased;
}
.bq-app.container-fluid { padding: 0; }
@media (min-width: 861px) {
  html, body { height: 100%; overflow: hidden; }
  .bq-app.container-fluid { height: 100vh; display: flex; flex-direction: column; }
}

/* ---------- top bar ---------- */
.bq-topbar {
  position: relative; z-index: 20; flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  background: var(--navy); color: #fff;
  padding: 12px 28px; border-bottom: 1px solid #0E1D38;
}
.bq-brand__name { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.bq-brand__sub { font-size: 12px; color: #B9C6DC; }
.bq-top__meta { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.bq-bid { display: flex; flex-direction: column; text-align: right; }
.bq-bid__id { font-weight: 600; font-size: 13px; }
.bq-bid__name { font-size: 12px; color: #B9C6DC; }
.bq-top__item { display: flex; align-items: center; gap: 8px; }
.bq-top__label { font-size: 12px; color: #B9C6DC; }
.bq-top__link, .bq-top__link:hover { text-decoration: none; }
.bq-top__link:focus-visible { outline: 2px solid #fff; outline-offset: 2px; border-radius: 4px; }

/* ---------- shell ---------- */
.bq-shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); flex: 1 1 auto; min-height: 0; }
.bq-nav {
  background: var(--navy-2); color: #fff; padding: 20px 12px;
  display: flex; flex-direction: column; justify-content: space-between;
  min-height: 0; overflow-y: auto;
}
.bq-nav .form-group, .bq-nav .shiny-input-radiogroup { margin: 0; width: 100%; }
.bq-nav .shiny-options-group { display: flex; flex-direction: column; gap: 2px; }
.bq-nav .radio { margin: 0; padding: 0; }
.bq-nav .radio label {
  display: block; width: 100%; padding: 10px 14px; border-radius: var(--radius);
  cursor: pointer; border-left: 3px solid transparent; color: #DCE4F2;
}
.bq-nav .radio input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.bq-nav .radio label:hover { background: var(--navy-3); color: #fff; }
.bq-nav .radio label:has(input:checked) { background: #fff; color: var(--navy); border-left-color: var(--blue); }
.bq-nav .radio label:has(input:focus-visible) { outline: 2px solid #9DB8E6; outline-offset: 1px; }
.bq-nav__title { display: block; font-weight: 600; font-size: 14px; }
.bq-nav__hint { display: block; font-size: 11.5px; opacity: 0.75; }
.bq-nav__foot { padding: 14px; border-top: 1px solid rgba(255,255,255,0.12); margin-top: 24px; }
.bq-nav__foot-label { font-size: 11px; color: #9FB0CC; }
.bq-nav__foot-value { font-size: 12.5px; font-weight: 600; }
.bq-nav__foot-note { font-size: 11px; color: #9FB0CC; margin-top: 6px; }

.bq-main { padding: 28px 32px 56px; min-width: 0; min-height: 0; overflow-y: auto; }
.bq-page { max-width: 1320px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }

/* ---------- page header ---------- */
.bq-page__head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; padding-bottom: 4px; }
.bq-page__title { font-size: 26px; font-weight: 700; letter-spacing: -0.015em; color: var(--navy); margin: 0; }
.bq-page__purpose { margin: 4px 0 0; color: var(--muted); font-size: 15px; max-width: 72ch; }
.bq-status { display: inline-flex; align-items: center; gap: 8px; }
.bq-status-label { font-size: 12px; color: var(--muted); }

/* ---------- badges ---------- */
.bq-badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.01em; line-height: 1.5;
  white-space: nowrap; border: 1px solid transparent; vertical-align: middle;
}
.bq-badge--lg { font-size: 12.5px; padding: 4px 10px; }
.bq-badge--success { background: var(--green-soft); color: var(--green); border-color: #BFDCCB; }
.bq-badge--warning { background: var(--amber-soft); color: var(--amber); border-color: #EBD3A2; }
.bq-badge--danger  { background: var(--red-soft); color: var(--red); border-color: #F0C3BE; }
.bq-badge--neutral { background: var(--neutral-soft); color: #44505F; border-color: var(--rule); }
.bq-badge--info    { background: var(--blue-soft); color: var(--blue); border-color: #C9D8F0; }
.bq-badge + .bq-badge { margin-left: 4px; }

/* ---------- KPIs ---------- */
.bq-kpi-row { display: grid; gap: 12px; }
.bq-kpi-row--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.bq-kpi-row--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.bq-kpi-row--5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.bq-kpi-row--6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.bq-kpi {
  position: relative; background: var(--paper); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 14px 16px 26px; min-width: 0;
}
.bq-kpi__label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.bq-kpi__value { font-size: 24px; font-weight: 700; color: var(--navy); letter-spacing: -0.01em; margin-top: 2px; white-space: nowrap; }
.bq-kpi__sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.bq-kpi--emphasis { border-top: 3px solid var(--blue); }
.bq-kpi--success .bq-kpi__value { color: var(--green); }
.bq-kpi--warning .bq-kpi__value { color: var(--amber); }
.bq-kpi--danger .bq-kpi__value { color: var(--red); }
.bq-kpi--neutral .bq-kpi__value { color: #44505F; }
.bq-trace {
  position: absolute; left: 16px; bottom: 7px;
  font-size: 10.5px; color: var(--faint);
}
td .bq-trace { position: static; font-size: 11.5px; }

/* ---------- sections ---------- */
.bq-section { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); min-width: 0; }
.bq-section .bq-kpi { background: var(--canvas); border-color: transparent; }
.bq-section__head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  padding: 14px 20px 10px; border-bottom: 1px solid var(--rule);
}
.bq-section__title { font-size: 15.5px; font-weight: 700; color: var(--navy); margin: 0; }
.bq-section__note { font-size: 12.5px; color: var(--muted); margin: 2px 0 0; max-width: 100ch; }
.bq-section__body { padding: 16px 20px 18px; display: flex; flex-direction: column; gap: 14px; }
.bq-grid { display: grid; gap: 20px; align-items: start; }
.bq-grid > .bq-section { height: 100%; }

/* ---------- callouts ---------- */
.bq-callout { border-left: 3px solid var(--blue); background: var(--blue-soft); padding: 10px 14px; border-radius: 0 var(--radius) var(--radius) 0; font-size: 13.5px; }
.bq-callout__title { display: block; color: var(--navy); margin-bottom: 2px; }
.bq-callout--success { border-color: var(--green); background: var(--green-soft); }
.bq-callout--warning { border-color: var(--amber); background: var(--amber-soft); }
.bq-callout--danger { border-color: var(--red); background: var(--red-soft); }
.bq-callout--neutral { border-color: var(--rule-strong); background: var(--canvas); }

/* ---------- tables ---------- */
.bq-table-wrap { overflow-x: auto; }
.bq-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.bq-table th {
  text-align: left; font-weight: 600; font-size: 12px; color: var(--muted);
  padding: 8px 10px; border-bottom: 1px solid var(--rule-strong); background: var(--paper); vertical-align: bottom;
}
.bq-table td { padding: 9px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.bq-table--compact td { padding: 7px 10px; }
.bq-table tbody tr:last-child td { border-bottom: none; }
.bq-table tbody tr:hover td { background: #FAFBFD; }
.bq-table .a-right { text-align: right; white-space: nowrap; }
.bq-table .a-center { text-align: center; }
.bq-table tr.is-anchor td { background: var(--canvas); font-weight: 600; }
.bq-table tr.is-flagged td:first-child { box-shadow: inset 3px 0 0 var(--red); }
.bq-table tr.is-current td { background: var(--blue-soft); }
.bq-table tr.is-selected td { background: var(--blue-soft); }
.bq-table tr.is-chain td { padding-top: 11px; padding-bottom: 11px; }
.bq-empty { color: var(--muted); font-style: italic; text-align: center; padding: 18px; }
.bq-sub { font-size: 11.5px; color: var(--muted); font-weight: 400; }
.bq-sub--warn { color: var(--amber); font-weight: 600; }
.is-excluded { color: var(--faint); text-decoration: line-through; text-decoration-color: var(--rule-strong); }
.nowrap { white-space: nowrap; }
.t-success { color: var(--green); }
.t-danger { color: var(--red); }
.bq-mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.bq-footnote { font-size: 12px; color: var(--muted); margin: 0; }
.bq-lead { font-size: 14.5px; margin: 0; color: var(--ink); }

.bq-meter { display: inline-block; width: 72px; height: 6px; background: var(--neutral-soft); border-radius: 3px; vertical-align: middle; overflow: hidden; }
.bq-meter__fill { display: block; height: 100%; background: var(--blue); }
.bq-meter__fill--neutral { background: var(--faint); }

/* ---------- definition lists ---------- */
.bq-dl { display: grid; grid-template-columns: minmax(150px, max-content) 1fr; gap: 7px 18px; margin: 0; font-size: 13.5px; }
.bq-dl dt { color: var(--muted); font-weight: 500; }
.bq-dl dd { margin: 0; }
.bq-detail { background: var(--canvas); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.bq-details summary { cursor: pointer; color: var(--blue); font-size: 13px; font-weight: 600; margin-bottom: 8px; }

/* ---------- form controls ---------- */
.bq-section .form-group { margin-bottom: 0; }
.bq-section .shiny-input-radiogroup .radio-inline, .bq-section .shiny-input-radiogroup .form-check-inline { margin-right: 14px; }
.bq-section .form-select, .bq-section .selectize-input { font-size: 13px; border-color: var(--rule-strong); }
.bq-section .control-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.bq-inline-control { display: flex; align-items: flex-end; gap: 12px; }

/* ---------- charts ---------- */
.bq-chart-wrap { width: 100%; }
.bq-chart { display: block; max-width: 100%; height: auto; font-family: var(--font); }

/* ---------- negotiation packages ---------- */
.bq-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.bq-option { border: 1px solid var(--rule); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; background: var(--paper); }
.bq-option--ok { border-top: 4px solid var(--green); }
.bq-option--fail { border-top: 4px solid var(--red); background: #FFFCFB; }
.bq-option header { display: flex; justify-content: space-between; align-items: center; }
.bq-option__id { font-weight: 700; color: var(--navy); }
.bq-option__pref { font-size: 11.5px; color: var(--blue); font-weight: 600; }
.bq-option__name { font-size: 14px; font-weight: 600; margin: 0; color: var(--ink); }
.bq-option .bq-badge--lg { align-self: flex-start; }
.bq-option .bq-dl { grid-template-columns: 1fr auto; font-size: 13px; }
.bq-option .bq-dl dd { text-align: right; }

/* ---------- executive hero ---------- */
.bq-hero {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 0;
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden;
}
.bq-hero__main { padding: 26px 30px; border-left: 6px solid var(--amber); }
.bq-hero__main:has(.bq-hero__decision--success) { border-left-color: var(--green); }
.bq-hero__main:has(.bq-hero__decision--danger) { border-left-color: var(--red); }
.bq-hero__label { font-size: 12.5px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.bq-hero__decision { font-size: 38px; line-height: 1.08; font-weight: 700; letter-spacing: -0.02em; color: var(--navy); }
.bq-hero__decision--warning { color: var(--amber); }
.bq-hero__decision--success { color: var(--green); }
.bq-hero__decision--danger { color: var(--red); }
.bq-hero__reason { font-size: 16px; margin: 12px 0 0; max-width: 62ch; color: var(--ink); }
.bq-hero__human { font-size: 12.5px; margin: 14px 0 0; color: var(--muted); max-width: 70ch; }
.bq-hero__rule { background: var(--canvas); padding: 22px 24px; border-left: 1px solid var(--rule); }

.bq-ladder { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.bq-rung { padding: 7px 12px; border-radius: 4px; border: 1px solid transparent; color: var(--muted); }
.bq-rung__outcome { font-weight: 700; font-size: 12.5px; color: #44505F; }
.bq-rung__state { float: right; font-size: 11px; color: var(--faint); }
.bq-rung__test { font-size: 11.5px; }
.bq-rung__evidence { font-size: 12px; margin-top: 4px; color: var(--ink); }
.bq-rung.is-active { background: var(--paper); border-color: var(--rule-strong); box-shadow: inset 4px 0 0 var(--amber); color: var(--ink); }
.bq-rung.is-active .bq-rung__outcome { color: var(--amber); }
.bq-rung--success.is-active { box-shadow: inset 4px 0 0 var(--green); }
.bq-rung--success.is-active .bq-rung__outcome { color: var(--green); }
.bq-rung--danger.is-active { box-shadow: inset 4px 0 0 var(--red); }
.bq-rung--danger.is-active .bq-rung__outcome { color: var(--red); }
.bq-rung.is-active .bq-rung__state { color: var(--ink); font-weight: 600; }

/* input workbook panel */
.bq-input__grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(260px, 1fr); gap: 24px; align-items: start; }
.bq-input__controls { display: flex; flex-direction: column; gap: 8px; }
.bq-input__controls .form-group { margin-bottom: 0; }
.bq-input__controls .control-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.bq-btn { align-self: flex-start; }
.bq-staged { border: 1px solid var(--rule-strong); border-left: 4px solid var(--blue); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.bq-staged__title { color: var(--navy); }
.bq-staged__action { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
@media (max-width: 1100px) { .bq-input__grid { grid-template-columns: 1fr; } }

/* lifecycle label */
.bq-lifecycle { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 4px 10px; border-radius: 4px; white-space: nowrap; }
.bq-lifecycle--post { background: var(--neutral-soft); color: var(--navy); border: 1px solid var(--rule-strong); }
.bq-lifecycle--pre { background: var(--blue-soft); color: var(--blue); border: 1px solid #C9D8F0; }

/* conditions */
.bq-conds { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.bq-cond { padding: 11px 0; border-bottom: 1px solid var(--rule); }
.bq-cond:first-child { padding-top: 0; }
.bq-cond:last-child { border-bottom: none; padding-bottom: 0; }
.bq-cond > div:first-child { display: flex; justify-content: space-between; align-items: center; }
.bq-cond__id { font-weight: 700; font-size: 12.5px; color: var(--navy); }
.bq-cond__text { margin: 4px 0; font-size: 13.5px; }
.bq-cond__meta { font-size: 12px; }
.bq-cond__status { display: inline-flex; align-items: center; gap: 4px; }
.bq-cond__closeout { font-size: 12px; margin-top: 6px; padding: 6px 10px; background: var(--canvas); border-radius: 4px; }
.bq-cond--historical .bq-cond__text { color: var(--muted); }

/* learning flow */
.bq-flow { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; border: 1px solid var(--rule); border-radius: var(--radius); }
.bq-flow__step { padding: 14px 18px; position: relative; }
.bq-flow__step + .bq-flow__step { border-left: 1px solid var(--rule); }
.bq-flow__step + .bq-flow__step::before {
  content: ""; position: absolute; left: -7px; top: 50%; width: 12px; height: 12px; margin-top: -6px;
  background: var(--paper); border-top: 1px solid var(--rule-strong); border-right: 1px solid var(--rule-strong); transform: rotate(45deg);
}
.bq-flow__label { font-size: 12px; color: var(--muted); font-weight: 600; }
.bq-flow__value { font-size: 24px; font-weight: 700; color: var(--navy); }

.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .bq-kpi-row--5, .bq-kpi-row--6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .bq-grid { grid-template-columns: 1fr !important; }
  .bq-hero { grid-template-columns: 1fr; }
  .bq-hero__rule { border-left: none; border-top: 1px solid var(--rule); }
}
@media (max-width: 860px) {
  .bq-shell { grid-template-columns: minmax(0, 1fr); }
  .bq-nav { position: static; height: auto; padding: 10px; min-width: 0; }
  .bq-nav .shiny-options-group { flex-direction: row; overflow-x: auto; }
  .bq-nav .radio label { white-space: nowrap; }
  .bq-kpi__sub .bq-badge { white-space: normal; }
  .bq-kpi__value { font-size: 21px; }
  .bq-nav__hint, .bq-nav__foot { display: none; }
  .bq-topbar { flex-direction: column; align-items: flex-start; padding: 12px 16px; position: static; }
  .bq-bid { text-align: left; }
  .bq-main { padding: 18px 16px 40px; overflow-y: visible; }
  .bq-kpi-row--3, .bq-kpi-row--4, .bq-kpi-row--5, .bq-kpi-row--6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bq-flow { grid-template-columns: 1fr; }
  .bq-flow__step + .bq-flow__step { border-left: none; border-top: 1px solid var(--rule); }
  .bq-flow__step + .bq-flow__step::before { display: none; }
  .bq-hero__decision { font-size: 30px; }
}
@media print {
  .bq-nav, .bq-topbar { display: none; }
  .bq-shell { display: block; }
  html, body, .bq-app.container-fluid, .bq-main { height: auto !important; overflow: visible !important; }
  .bq-section, .bq-hero, .bq-kpi { break-inside: avoid; }
}

.bq-nav__release { margin-top: 10px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,0.12); }
