/* ─────────────────────────────────────────────────────────────
   SolidDomino Ops Portal v2 — Master Stylesheet
   Brand: Navy #1A1F36, Gold #C9A84C
   Body font: Inter (UI), Cambo (display accents)
───────────────────────────────────────────────────────────── */

:root {
  --navy:        #1A1F36;
  --navy-light:  #252B47;
  --navy-muted:  #3A4268;
  --gold:        #C9A84C;
  --gold-light:  #E8C96A;
  --gold-dim:    #8B7235;
  --gold-bg:     #FBF5E6;
  --surface:     #FFFFFF;
  --surface2:    #F7F8FC;
  --surface3:    #ECEEF5;
  --text1:       #1A1F36;
  --text2:       #4A5070;
  --text3:       #8890B0;
  --border:      #DDE0EC;
  --border-med:  #BCC0D6;
  --green:       #1A9E75;
  --green-bg:    #E6F7F2;
  --green-text:  #0F6E56;
  --amber:       #C47F17;
  --amber-bg:    #FEF5E4;
  --red:         #C0392B;
  --red-bg:      #FBEAEA;
  --blue:        #1A6FC9;
  --blue-bg:     #EBF3FD;
  --r:           8px;
  --r-lg:        12px;
  --r-xl:        16px;
  --shadow-sm:   0 1px 3px rgba(26,31,54,.08);
  --shadow-md:   0 4px 12px rgba(26,31,54,.12);
  --shadow-lg:   0 8px 24px rgba(26,31,54,.16);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 13px;
  color: var(--text1);
  background: var(--surface2);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }

/* ── App Shell ─────────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
  /* NOTE: overflow:hidden is correct for desktop — the inner panels scroll.
     Mobile overrides below (line ~788) set height:auto so content can scroll. */
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;   /* clips horizontal; vertical handled by children */
  min-width: 0;
  min-height: 0;
  height: 100%;       /* fills app-shell */
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 10;
}

.sidebar-logo {
  padding: 18px 16px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.logo-mark {
  width: 34px; height: 34px;
  background: var(--gold);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
  color: var(--navy);
  letter-spacing: -1px;
  flex-shrink: 0;
}
.logo-mark.lg { width: 48px; height: 48px; font-size: 20px; border-radius: 10px; }

.logo-name { color: #fff; font-size: 14px; font-weight: 600; }
.logo-sub  { color: rgba(255,255,255,.3); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; margin-top: 1px; }

.sidebar-nav {
  padding: 14px 8px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-section {
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: rgba(255,255,255,.25);
  padding: 10px 8px 5px;
  margin-top: 4px;
}

.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px;
  border-radius: 6px;
  color: rgba(255,255,255,.5);
  font-size: 12.5px;
  transition: all .15s;
  cursor: pointer;
}
.nav-item i { font-size: 16px; width: 18px; text-align: center; flex-shrink: 0; }
.nav-item span:first-of-type { flex: 1; }
.nav-item:hover { background: rgba(255,255,255,.06); color: rgba(255,255,255,.85); }
.nav-item.active { background: rgba(201,168,76,.15); color: var(--gold); font-weight: 500; }

.nav-tag {
  font-size: 10px; font-weight: 600;
  background: rgba(201,168,76,.15); color: var(--gold);
  border-radius: 20px; padding: 1px 6px;
}

.sidebar-footer {
  padding: 12px 12px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex; flex-direction: column; gap: 8px;
}

.sidebar-version {
  font-size: 11px; color: rgba(255,255,255,.3);
  display: flex; align-items: center; gap: 5px;
}

.logout-btn {
  width: 100%;
  background: transparent; border: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.4);
  padding: 6px 10px; border-radius: 6px;
  font-size: 12px; cursor: pointer;
  display: flex; align-items: center; gap: 7px;
  transition: all .15s;
}
.logout-btn:hover { background: rgba(255,255,255,.06); color: rgba(255,255,255,.7); }

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 54px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.topbar-title { font-size: 15px; font-weight: 600; }
.topbar-sub   { font-size: 11px; color: var(--text3); margin-top: 1px; }
.topbar-actions { display: flex; gap: 8px; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--r);
  font-size: 12.5px; font-weight: 500;
  cursor: pointer; transition: all .15s;
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text2);
  white-space: nowrap;
}
.btn:hover { background: var(--surface2); }
.btn i { font-size: 14px; }

.btn-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-primary:hover { background: var(--navy-light); }

.btn-ghost { background: transparent; border-color: var(--border); color: var(--text2); }
.btn-ghost:hover { background: var(--surface2); }

.btn-full { width: 100%; justify-content: center; }

.btn-download-rib {
  background: var(--navy); color: white; border-color: var(--navy);
  padding: 9px 18px; font-size: 13px; font-weight: 600;
}
.btn-download-rib:hover { background: var(--navy-light); }

.btn-download-sab {
  background: var(--gold); color: var(--navy); border-color: var(--gold);
  padding: 9px 18px; font-size: 13px; font-weight: 600;
}
.btn-download-sab:hover { background: var(--gold-light); }

/* ── Run Page Layout ───────────────────────────────────────── */
/* Authoritative run-layout / input-panel / output-panel-wrap definitions
   live in the "RUN PAGE — RESIZABLE LAYOUT" block near the end of this file.
   This early block only carries shared, non-conflicting visual rules. */
.run-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
  height: 0;          /* critical: forces flex children to obey overflow */
}

/* Left input panel */
.input-panel {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;   /* inner .input-form scrolls */
  min-height: 0;
}

.panel-header {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-title { font-size: 13px; font-weight: 600; }
.panel-sub   { font-size: 11.5px; color: var(--text3); margin-top: 2px; }

.input-form {
  flex: 1; overflow-y: auto;
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 14px;
}

.field-group { display: flex; flex-direction: column; }
.field-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.field-label {
  font-size: 11.5px; font-weight: 500; color: var(--text2);
  margin-bottom: 5px;
  display: flex; justify-content: space-between; align-items: center;
}
.field-req      { color: var(--red); font-size: 10.5px; font-weight: 400; }
.field-optional { color: var(--text3); font-size: 10.5px; font-weight: 400; }

.field-input {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 12.5px; color: var(--text1);
  background: var(--surface2);
  outline: none;
  transition: border-color .15s, background .15s;
  font-family: inherit;
}
.field-input:focus { border-color: var(--navy); background: white; }
.field-input::placeholder { color: var(--text3); }
textarea.field-input { resize: vertical; line-height: 1.55; min-height: 80px; }

/* Output type cards */
.output-type-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.output-type-card {
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: 10px 12px;
  cursor: pointer;
  transition: all .15s;
  background: var(--surface);
  display: flex; flex-direction: column; gap: 3px;
}
.output-type-card input[type="radio"] { display: none; }
.output-type-card:has(input:checked) {
  border-color: var(--gold);
  background: var(--gold-bg);
}
.ot-icon { font-size: 18px; color: var(--text3); margin-bottom: 2px; }
.output-type-card:has(input:checked) .ot-icon { color: var(--amber); }
.ot-label { font-size: 12px; font-weight: 600; color: var(--text2); }
.output-type-card:has(input:checked) .ot-label { color: var(--amber); }
.ot-desc { font-size: 10.5px; color: var(--text3); }

/* SDR chips */
.sdr-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sdr-chip {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  border: 1px solid var(--border);
  color: var(--text2);
  background: var(--surface);
  cursor: pointer;
  transition: all .15s;
}
.sdr-chip.active { background: var(--navy); color: white; border-color: var(--navy); }
.sdr-chip:hover:not(.active) { background: var(--surface2); }

/* Run button */
.run-btn-area {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.run-btn {
  width: 100%; padding: 11px;
  background: var(--navy); color: white;
  border: none; border-radius: var(--r);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  letter-spacing: .02em;
  transition: background .15s, transform .1s;
  font-family: inherit;
}
.run-btn:hover:not(:disabled) { background: var(--navy-light); }
.run-btn:active:not(:disabled) { transform: scale(.99); }
.run-btn:disabled { opacity: .5; cursor: not-allowed; }
.run-btn i { font-size: 16px; }

/* ── Output Panel Wrap ─────────────────────────────────────── */
/* Authoritative definition lives in the "RUN PAGE — RESIZABLE LAYOUT" block. */

/* Empty state */
.output-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px; padding: 40px;
  text-align: center;
}
.empty-icon i { font-size: 48px; color: var(--border-med); }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text2); }
.empty-body  { font-size: 13px; color: var(--text3); max-width: 360px; line-height: 1.6; }

/* ── Pipeline Tracker ──────────────────────────────────────── */
.pipeline-tracker {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  flex-shrink: 0;
}

.pipeline-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
}
.pipeline-title {
  font-size: 11px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--text3);
}
.pipeline-elapsed { font-size: 12px; color: var(--text3); font-variant-numeric: tabular-nums; }

.pipeline-stages {
  display: flex; align-items: center; flex-wrap: wrap; gap: 0;
  min-width: 0; overflow: hidden;
}

.ps-stage {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--surface3);
  transition: all .3s;
  min-width: 0;
}
.ps-icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
  color: var(--text3);
  transition: all .3s;
}
.ps-name   { font-size: 11.5px; font-weight: 600; color: var(--text3); }
.ps-detail { font-size: 10.5px; color: var(--text3); opacity: .7; }
.ps-status { font-size: 13px; color: var(--text3); margin-left: auto; flex-shrink: 0; }

/* Stage states */
.ps-stage.done {
  background: var(--green-bg);
  border-color: #9FE1CB;
}
.ps-stage.done .ps-icon  { background: var(--green); border-color: var(--green); color: white; }
.ps-stage.done .ps-name  { color: var(--green-text); }
.ps-stage.done .ps-status { color: var(--green); }

.ps-stage.active {
  background: var(--navy);
  border-color: var(--navy);
  box-shadow: var(--shadow-sm);
}
.ps-stage.active .ps-icon   { background: rgba(255,255,255,.15); border-color: rgba(255,255,255,.2); color: white; }
.ps-stage.active .ps-name   { color: white; }
.ps-stage.active .ps-detail { color: rgba(255,255,255,.6); }
.ps-stage.active .ps-status { color: var(--gold); }

.ps-stage.error {
  background: var(--red-bg);
  border-color: #E8A0A0;
}
.ps-stage.error .ps-name { color: var(--red); }

.ps-connector {
  width: 24px; height: 1px;
  background: var(--border);
  flex-shrink: 0;
  transition: background .3s;
}
.ps-connector.done { background: var(--green); }

.pipeline-message {
  margin-top: 10px;
  font-size: 12px; color: var(--text3);
  display: flex; align-items: center; gap: 6px;
}

/* Spinner */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin .8s linear infinite; display: inline-block; }

/* Pulse dot */
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }
.pulse { animation: pulse 1.2s ease-in-out infinite; }

/* ── Results area ──────────────────────────────────────────── */
/* .results-area — definitive version is lower in this file */

/* Ops handoff block */
.ops-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.ops-block-head {
  background: var(--navy);
  padding: 12px 16px;
  display: flex; justify-content: space-between; align-items: center;
}
.ops-block-title {
  color: white; font-size: 12px; font-weight: 700;
  letter-spacing: .05em; text-transform: uppercase;
}
.ops-block-badges { display: flex; gap: 6px; }

.ops-block-body { padding: 14px 16px; }

.ops-table { width: 100%; border-collapse: collapse; }
.ops-table td { padding: 6px 0; vertical-align: top; }
.ops-table td:first-child {
  width: 130px;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text3);
  padding-right: 12px;
}
.ops-table td:last-child { font-size: 12.5px; color: var(--text1); line-height: 1.45; }

/* Opportunity sections in ops block */
.opp-section { padding: 12px 16px; border-top: 1px solid var(--border); }
.opp-num {
  font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text3); margin-bottom: 6px;
  display: flex; align-items: center; gap: 8px;
}
.opp-num::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.opp-name { font-size: 13px; font-weight: 600; line-height: 1.4; margin-bottom: 10px; }

/* Download/action bar inside block */
.block-actions {
  padding: 10px 16px;
  background: var(--surface3);
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; flex-wrap: wrap;
}

.action-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; border-radius: var(--r);
  font-size: 12px; font-weight: 500;
  cursor: pointer; border: 1px solid var(--border);
  background: var(--surface); color: var(--text2);
  transition: all .15s;
}
.action-btn:hover { background: var(--navy); color: white; border-color: var(--navy); }
.action-btn.gold  { background: var(--gold); color: var(--navy); border-color: var(--gold); font-weight: 600; }
.action-btn.gold:hover { background: var(--gold-light); }
.action-btn i { font-size: 13px; }

/* Email block */
.email-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.email-head {
  background: var(--surface3);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px;
}
.email-meta-row { display: flex; align-items: baseline; gap: 6px; font-size: 11.5px; margin-bottom: 3px; }
.email-meta-row:last-child { margin-bottom: 0; }
.email-meta-key { color: var(--text3); font-weight: 700; text-transform: uppercase; font-size: 10px; letter-spacing: .06em; width: 40px; flex-shrink: 0; }
.email-meta-val { color: var(--text1); }
.email-body { padding: 16px; font-size: 12.5px; color: var(--text2); line-height: 1.75; white-space: pre-wrap; font-family: 'Cambo', Georgia, serif; }

/* Status bar */
.status-bar {
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 7px 24px;
  display: flex; align-items: center; gap: 16px;
  flex-shrink: 0;
}
.stat-pill { display: flex; align-items: center; gap: 5px; font-size: 11.5px; }
.stat-dot  { width: 6px; height: 6px; border-radius: 50%; }
.dot-green { background: var(--green); }
.dot-amber { background: #E8A000; }
.dot-gray  { background: var(--border-med); }
.stat-label { color: var(--text3); }
.stat-val   { color: var(--text1); font-weight: 500; font-variant-numeric: tabular-nums; }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-green  { background: var(--green-bg);  color: var(--green-text); }
.badge-gold   { background: var(--gold-bg);   color: var(--amber); }
.badge-amber  { background: var(--amber-bg);  color: var(--amber); }
.badge-blue   { background: var(--blue-bg);   color: var(--blue); }
.badge-red    { background: var(--red-bg);    color: var(--red); }
.badge-navy   { background: rgba(26,31,54,.1); color: var(--navy); }

/* ── History Page ──────────────────────────────────────────── */
/* .history-container — definitive version below */
.history-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.history-table {
  width: 100%; border-collapse: collapse;
}
.history-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text3);
  background: var(--surface3);
  border-bottom: 1px solid var(--border);
}
.history-table td {
  padding: 10px 14px;
  font-size: 12.5px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.history-table tr:last-child td { border-bottom: none; }
.history-table tr:hover td { background: var(--surface2); }
.tbl-link { color: var(--navy); font-weight: 500; }
.tbl-link:hover { color: var(--gold); }
.tbl-action-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 8px; border-radius: 5px;
  font-size: 11.5px; color: var(--text2);
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; transition: all .15s;
  white-space: nowrap;
}
.tbl-action-btn:hover { background: var(--navy); color: white; border-color: var(--navy); }
.table-loading, .table-empty, .table-error {
  text-align: center; padding: 32px; color: var(--text3); font-size: 13px;
}
.date-cell    { color: var(--text3); font-size: 12px; }
.actions-cell { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.type-badge   { font-size: 11px; font-weight: 500; color: var(--text2); }
.stars        { color: var(--gold); letter-spacing: -1px; font-size: 13px; }
.history-pagination {
  display: flex; gap: 4px; margin-top: 12px; justify-content: flex-end;
}
.page-btn {
  padding: 5px 10px; border-radius: 5px; font-size: 12px;
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; color: var(--text2); transition: all .15s;
}
.page-btn.active, .page-btn:hover { background: var(--navy); color: white; border-color: var(--navy); }

/* ── Result Page ───────────────────────────────────────────── */
.result-container {
  flex: 1; overflow: auto;
  padding: 20px 24px;
  display: flex; flex-direction: column; gap: 16px;
}
.result-meta-bar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.meta-pill {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 10px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px; color: var(--text2);
}
.meta-pill i { color: var(--text3); font-size: 13px; }
.rating-pill { cursor: pointer; }
.rating-pill:hover { border-color: var(--gold); color: var(--amber); }

.download-bar {
  display: flex; gap: 10px; flex-wrap: wrap;
}

.result-tabs {
  display: flex; gap: 0; border-bottom: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--r) var(--r) 0 0;
  overflow: hidden; border: 1px solid var(--border);
}
.result-tab {
  padding: 10px 18px;
  font-size: 12.5px; font-weight: 500; color: var(--text3);
  background: transparent; border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer; transition: all .15s;
}
.result-tab:hover { color: var(--text1); background: var(--surface2); }
.result-tab.active { color: var(--navy); border-bottom-color: var(--gold); background: var(--surface); }

.result-tab-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--r) var(--r);
  overflow: hidden;
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

.output-block { padding: 20px; overflow-x: auto; }
.output-pre {
  white-space: pre-wrap;
  font-family: 'Cambo', Georgia, serif;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text1);
}
.email-pre { font-family: 'Inter', sans-serif; }

.email-preview {}
.email-preview-header {
  background: var(--surface3);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: flex-start;
}
.email-preview-meta {}
.ep-row { display: flex; align-items: baseline; gap: 8px; font-size: 12px; margin-bottom: 3px; }
.ep-label { width: 36px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text3); flex-shrink: 0; }
.ep-val { color: var(--text1); }
.email-preview-body { padding: 16px; }

/* ── Login Page ────────────────────────────────────────────── */
body.login-page {
  background: var(--navy);
  display: flex; align-items: center; justify-content: center;
}
.login-shell {
  display: flex;
  width: 100%;
  max-width: 900px;
  min-height: 500px;
  border-radius: var(--r-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.login-left {
  flex: 1;
  background: linear-gradient(135deg, var(--navy-light), var(--navy-muted));
  padding: 48px 40px;
  display: flex; flex-direction: column; gap: 40px;
  border-right: 1px solid rgba(255,255,255,.08);
}
.login-brand { display: flex; align-items: center; gap: 14px; }
.login-brand-name { font-size: 22px; font-weight: 700; color: white; }
.login-brand-tagline { font-size: 11px; color: rgba(255,255,255,.4); margin-top: 2px; letter-spacing: .06em; text-transform: uppercase; }
.login-pitch {}
.login-pitch-headline { font-size: 22px; font-weight: 700; color: var(--gold); line-height: 1.3; margin-bottom: 12px; font-family: 'Cambo', Georgia, serif; }
.login-pitch-body { font-size: 13px; color: rgba(255,255,255,.55); line-height: 1.7; }

.login-right {
  width: 380px;
  background: var(--surface);
  padding: 48px 40px;
  display: flex; align-items: center;
}
.login-card { width: 100%; }
.login-title { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.login-sub   { font-size: 13px; color: var(--text3); margin-bottom: 24px; }
.login-form  { display: flex; flex-direction: column; gap: 16px; }

.alert {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: var(--r);
  font-size: 12.5px; margin-bottom: 16px;
}
.alert-error { background: var(--red-bg); color: var(--red); border: 1px solid #EDBBBB; }

/* ── Error page ────────────────────────────────────────────── */
body.error-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.error-shell    { text-align: center; max-width: 400px; padding: 40px; }
.error-title    { font-size: 28px; font-weight: 700; margin-bottom: 12px; }
.error-message  { color: var(--text3); font-size: 14px; margin-bottom: 24px; line-height: 1.6; }

/* ── Generate Documents Panel ──────────────────────────────── */
.generate-panel {
  background: var(--surface);
  border: 2px solid var(--gold);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.generate-header {
  padding: 16px 20px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  background: linear-gradient(to right, rgba(201,168,76,.06), transparent);
}
.generate-title {
  font-size: 14px; font-weight: 600; color: var(--text1); margin-bottom: 4px;
}
.generate-sub {
  font-size: 12px; color: var(--text3);
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.generate-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px;
  background: var(--gold); color: var(--navy);
  border: none; border-radius: var(--r);
  font-size: 13px; font-weight: 700;
  cursor: pointer; white-space: nowrap;
  transition: background .15s, transform .1s;
  font-family: inherit;
  flex-shrink: 0;
}
.generate-btn:hover:not(:disabled) { background: var(--gold-light); }
.generate-btn:active:not(:disabled) { transform: scale(.98); }
.generate-btn:disabled { opacity: .5; cursor: not-allowed; }
.generate-btn i { font-size: 16px; }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE + VERTICAL WORKFLOW STYLES
   ═══════════════════════════════════════════════════════════ */

/* ── Responsive base ─────────────────────────────────────── */
.hide-sm { display: inline; }

@media (max-width: 768px) {
  .hide-sm { display: none; }
  .app-shell { flex-direction: column; height: auto; min-height: 100vh; }
  .sidebar { width: 100%; flex-direction: row; flex-shrink: 0; height: auto; }
  .sidebar-logo { border-bottom: none; border-right: 1px solid rgba(255,255,255,.08); padding: 12px 14px; }
  .sidebar-nav { flex-direction: row; padding: 8px; gap: 4px; overflow-x: auto; }
  .nav-section { display: none; }
  .nav-item { padding: 6px 10px; font-size: 12px; }
  .nav-tag { display: none; }
  .sidebar-footer { display: none; }
  .main-content { overflow: auto; height: auto; }
  /* Run-layout / input-panel / output-panel-wrap / results-area mobile
     overrides live in the consolidated "MOBILE (max 768px)" block further
     down this file — not redeclared here to avoid drift. */
  .field-row { grid-template-columns: 1fr; }
  .topbar { padding: 0 14px; }
  .topbar-title { font-size: 14px; }
  .history-container { padding: 14px; }
}

@media (max-width: 480px) {
  .output-type-grid { grid-template-columns: 1fr; }
  .sdr-chips { gap: 4px; }
  .sdr-chip { font-size: 11px; padding: 3px 8px; }
}

/* ── Vertical Workflow Tracker ────────────────────────────── */
.workflow-tracker {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  flex-shrink: 0;
}

.workflow-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.workflow-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text3);
}

.workflow-elapsed {
  font-size: 12px;
  color: var(--text3);
  font-variant-numeric: tabular-nums;
}

.workflow-steps {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.wf-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 6px 0;
}

.wf-step-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  width: 32px;
}

.wf-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface3);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text3);
  transition: all .25s;
  flex-shrink: 0;
}

.wf-line {
  width: 2px;
  flex: 1;
  min-height: 16px;
  background: var(--border);
  margin-top: 4px;
  transition: background .25s;
}

.wf-step-body {
  flex: 1;
  padding-top: 6px;
  min-width: 0;
}

.wf-step-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text3);
  transition: color .25s;
}

.wf-step-desc {
  font-size: 11.5px;
  color: var(--text3);
  opacity: .7;
  margin-top: 1px;
}

.wf-step-badge {
  font-size: 13px;
  color: var(--text3);
  padding-top: 8px;
  flex-shrink: 0;
  transition: color .25s;
}

/* Active state */
.wf-step.wf-active .wf-dot {
  background: var(--navy);
  border-color: var(--navy);
  color: white;
}
.wf-step.wf-active .wf-step-name { color: var(--navy); font-weight: 600; }
.wf-step.wf-active .wf-step-badge { color: var(--gold); }

/* Done state */
.wf-step.wf-done .wf-dot {
  background: var(--green);
  border-color: var(--green);
  color: white;
}
.wf-step.wf-done .wf-line { background: var(--green); }
.wf-step.wf-done .wf-step-name { color: var(--green-text); }
.wf-step.wf-done .wf-step-badge { color: var(--green); }

/* Error state */
.wf-step.wf-error .wf-dot { background: var(--red-bg); border-color: var(--red); color: var(--red); }
.wf-step.wf-error .wf-step-name { color: var(--red); }

.workflow-message {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text3);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Handoff Summary Card ─────────────────────────────────── */
.handoff-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.handoff-card-head {
  background: var(--navy);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.handoff-card-title {
  color: white;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 2px;
}

.handoff-card-sub {
  color: rgba(255,255,255,.45);
  font-size: 11.5px;
}

.handoff-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 0;
}

.hs-item {
  padding: 10px 16px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.hs-item:nth-child(2n) { border-right: none; }
.hs-full {
  grid-column: 1 / -1;
  border-right: none;
}
.hs-item:last-child { border-bottom: none; }

.hs-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text3);
  margin-bottom: 4px;
}

.hs-val {
  font-size: 13px;
  color: var(--text1);
  line-height: 1.4;
}

@media (max-width: 600px) {
  .handoff-summary-grid { grid-template-columns: 1fr; }
  .hs-item { border-right: none; }
}

/* ── Download section — large prominent cards ─────────────── */
.download-section {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.download-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text3);
  margin-bottom: 10px;
}

.download-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.download-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: var(--r-lg);
  border: 2px solid transparent;
  text-decoration: none;
  transition: all .15s;
  cursor: pointer;
}

.download-card-rib {
  background: var(--navy);
  color: white;
  border-color: var(--navy);
}

.download-card-rib:hover {
  background: var(--navy-light);
  border-color: var(--gold);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.download-card-sab {
  background: var(--gold);
  color: var(--navy);
  border-color: var(--gold);
}

.download-card-sab:hover {
  background: var(--gold-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.dl-icon {
  font-size: 26px;
  flex-shrink: 0;
  opacity: .9;
}

.dl-info { flex: 1; }

.dl-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 2px;
}

.dl-sub {
  font-size: 11.5px;
  opacity: .7;
}

.dl-arrow {
  font-size: 20px;
  opacity: .6;
}

/* ── History Cards ────────────────────────────────────────── */
.history-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s;
}

.history-card:hover { box-shadow: var(--shadow-md); }

.hc-header {
  padding: 12px 16px 8px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.hc-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text1);
  margin-bottom: 2px;
}

.hc-contact {
  font-size: 12px;
  color: var(--text3);
}

.hc-badges {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex-shrink: 0;
}

.hc-meta {
  padding: 6px 16px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: var(--text3);
  border-bottom: 1px solid var(--border);
}

.hc-meta i { font-size: 13px; margin-right: 2px; }

.hc-actions {
  padding: 10px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.hc-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: var(--r);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}

.hc-btn:hover { background: var(--navy); color: white; border-color: var(--navy); }
.hc-btn i { font-size: 13px; }

.hc-btn-rib {
  background: var(--navy);
  color: white;
  border-color: var(--navy);
  font-weight: 600;
}
.hc-btn-rib:hover { background: var(--navy-light); }

.hc-btn-sab {
  background: var(--gold);
  color: var(--navy);
  border-color: var(--gold);
  font-weight: 600;
}
.hc-btn-sab:hover { background: var(--gold-light); color: var(--navy); }

.hc-btn-email { color: var(--blue); border-color: var(--blue-bg); background: var(--blue-bg); }
.hc-btn-email:hover { background: var(--blue); color: white; border-color: var(--blue); }

/* ── Modal large ──────────────────────────────────────────── */
.modal-lg { width: min(640px, 95vw); max-height: 85vh; overflow-y: auto; }

/* ── Results area scrollable ──────────────────────────────── */
/* .results-area — definitive version is lower in this file */

/* ═══════════════════════════════════════════════════════════
   HORIZONTAL PIPELINE — RESTORED + RESPONSIVE
   ═══════════════════════════════════════════════════════════ */

/* Pipeline container scrolls horizontally when tight */
.pipeline-scroll-wrap {
  overflow-x: auto;
  overflow-y: visible;
  padding-bottom: 4px;
  /* constrained width so it scrolls instead of overflowing the page */
  min-width: 0;
  max-width: 100%;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.pipeline-scroll-wrap::-webkit-scrollbar { height: 4px; }
.pipeline-scroll-wrap::-webkit-scrollbar-track { background: transparent; }
.pipeline-scroll-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.pipeline-stages {
  display: flex;
  align-items: stretch;
  gap: 0;
  min-width: max-content; /* prevents wrapping, enables scroll */
}

/* Individual stage box */
.ps-stage {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--surface3);
  transition: all .25s;
  min-width: 140px;
  flex-shrink: 0;
}

.ps-icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--text3);
  transition: all .25s;
  flex-shrink: 0;
}

.ps-info { flex: 1; min-width: 0; }
.ps-name   { font-size: 11.5px; font-weight: 600; color: var(--text3); white-space: nowrap; }
.ps-detail { font-size: 10px; color: var(--text3); opacity: .7; white-space: nowrap; }
.ps-status { font-size: 13px; color: var(--text3); flex-shrink: 0; }

/* Connector line between stages */
.ps-connector {
  width: 20px; min-width: 20px;
  height: 2px;
  background: var(--border);
  align-self: center;
  transition: background .25s;
  flex-shrink: 0;
}
.ps-connector.done { background: var(--green); }

/* Active state */
.ps-stage.active {
  background: var(--navy);
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(26,31,54,.1);
}
.ps-stage.active .ps-icon   { background: rgba(255,255,255,.15); border-color: rgba(255,255,255,.2); color: white; }
.ps-stage.active .ps-name   { color: white; }
.ps-stage.active .ps-detail { color: rgba(255,255,255,.6); opacity: 1; }
.ps-stage.active .ps-status { color: var(--gold); }

/* Done state */
.ps-stage.done {
  background: var(--green-bg);
  border-color: #9FE1CB;
}
.ps-stage.done .ps-icon   { background: var(--green); border-color: var(--green); color: white; }
.ps-stage.done .ps-name   { color: var(--green-text); }
.ps-stage.done .ps-status { color: var(--green); }

/* Error state */
.ps-stage.error {
  background: var(--red-bg);
  border-color: #E8A0A0;
}
.ps-stage.error .ps-name { color: var(--red); }

/* Pipeline header */
.pipeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.pipeline-label {
  font-size: 10px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--text3);
}

/* Workflow message */
.workflow-message {
  margin-top: 10px;
  font-size: 12px; color: var(--text3);
  display: flex; align-items: center; gap: 6px;
}

/* Workflow tracker wrapper */
.workflow-tracker {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  flex-shrink: 0;
  /* must be constrained so pipeline scroll works correctly */
  min-width: 0;
  overflow: hidden;
}

/* ── Collapsible input panel ──────────────────────────────── */
.collapse-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--text3);
  cursor: pointer;
  transition: all .15s;
  flex-shrink: 0;
}
.collapse-btn:hover { background: var(--navy); color: white; border-color: var(--navy); }

/* Topbar hamburger — always visible, even when the input panel is collapsed */
.panel-toggle-btn {
  width: 32px; height: 32px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--text2);
  cursor: pointer;
  transition: all .15s;
  flex-shrink: 0;
}
.panel-toggle-btn:hover { background: var(--navy); color: white; border-color: var(--navy); }

/* Output panel — properly scrollable; full rules in the resizable-layout block below */

/* Empty state — centered in remaining space */
.output-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 20px;
  text-align: center;
  min-height: 200px;
}

/* ── Status bar pinned to bottom ──────────────────────────── */
.status-bar {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 7px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0; /* never shrinks — always visible */
  flex-wrap: wrap;
}

/* ── Responsive pipeline — at small widths just scroll ────── */
@media (max-width: 900px) {
  .ps-stage { min-width: 120px; padding: 6px 8px; }
  .ps-detail { display: none; }
  .ps-name { font-size: 11px; }
}

@media (max-width: 600px) {
  .workflow-tracker { padding: 10px 12px; }
  .ps-stage { min-width: 100px; padding: 6px 8px; gap: 6px; }
  .ps-connector { width: 12px; min-width: 12px; }
}

/* ── Document Preview Modal ──────────────────────────────────── */
#previewModal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  overflow: auto;
}

.preview-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(2px);
}

.preview-panel {
  position: relative;
  z-index: 1;
  background: #fff;
  width: min(900px, 96vw);
  margin: 0 auto;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
  overflow: hidden;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid #e5e7eb;
  background: #0D1B3E;
  border-radius: 10px 10px 0 0;
  gap: 12px;
  flex-shrink: 0;
}

.preview-title {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.preview-actions { display: flex; gap: 8px; }

.preview-body {
  overflow-y: auto;
  flex: 1;
  padding: 0;
  background: #f9fafb;
}

/* Markdown preview styles */
.md-preview {
  max-width: 780px;
  margin: 0 auto;
  padding: 32px 40px;
  font-family: Arial, sans-serif;
  color: #111827;
  font-size: 14px;
  line-height: 1.6;
}

.md-h1 {
  font-size: 18px;
  font-weight: 700;
  color: #0D1B3E;
  text-transform: uppercase;
  border-bottom: 3px solid #B8962E;
  padding-bottom: 8px;
  margin: 32px 0 16px;
  letter-spacing: 0.04em;
}

.md-h2 {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  background: #0D1B3E;
  padding: 8px 14px;
  margin: 28px 0 10px;
  border-bottom: 3px solid #B8962E;
  letter-spacing: 0.05em;
}

.md-h3 {
  font-size: 12px;
  font-weight: 700;
  color: #0D1B3E;
  text-transform: uppercase;
  margin: 20px 0 8px;
  border-left: 4px solid #C05820;
  padding-left: 10px;
}

.md-h4 {
  font-size: 12px;
  font-weight: 600;
  color: #1A2F5E;
  margin: 14px 0 6px;
}

.md-p {
  margin: 0 0 10px;
  font-size: 13.5px;
  color: #111827;
}

.md-bold {
  font-weight: 700;
  font-style: italic;
  color: #0D1B3E;
  margin: 12px 0;
}

.md-spacer { height: 8px; }

.md-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0 18px;
  font-size: 13px;
}

.md-cell {
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  vertical-align: top;
  text-align: left;
}

.md-table th.md-cell {
  background: #0D1B3E;
  color: #fff;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 11.5px;
  letter-spacing: 0.04em;
}

.md-table tr:nth-child(odd) td.md-cell { background: #F2F4F8; }
.md-table tr:nth-child(even) td.md-cell { background: #fff; }

/* Download card with preview button */
.download-card-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.download-card-wrap .download-card {
  flex: 1;
}

.preview-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  background: none;
  border: 1px solid var(--border-med);
  border-radius: 6px;
  color: var(--text2);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  font-weight: 500;
}

.preview-btn:hover {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}


/* ═══════════════════════════════════════════════════════════
   RESPONSIVE OVERHAUL v2 — Full mobile/tablet support
   ═══════════════════════════════════════════════════════════ */

/* ── Team page ───────────────────────────────────────────── */
.team-container {
  flex: 1;
  overflow: auto;
  padding: 20px 24px;
}
.team-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}
.sdr-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--navy); color: var(--gold);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}

/* ── Empty states ─────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}
.empty-icon {
  font-size: 40px;
  color: var(--text3);
  margin-bottom: 12px;
  line-height: 1;
}
.empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 6px;
}
.empty-sub {
  font-size: 13px;
  color: var(--text3);
}
.empty-sub a {
  color: var(--blue);
  text-decoration: underline;
}

/* ── History cards — full responsive ─────────────────────── */
.history-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 24px;
  min-height: 0;
}
.history-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.history-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s;
}
.history-card:hover { box-shadow: var(--shadow-md); }
.hc-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.hc-client { flex: 1; min-width: 0; }
.hc-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hc-contact { font-size: 12px; color: var(--text3); margin-top: 2px; }
.hc-badges { display: flex; gap: 6px; flex-wrap: wrap; flex-shrink: 0; }
.hc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 12px;
  color: var(--text3);
  margin-bottom: 10px;
}
.hc-meta span { display: flex; align-items: center; gap: 4px; }
.hc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.hc-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  text-decoration: none;
  transition: all .15s;
}
.hc-btn:hover { background: var(--surface3); color: var(--text1); }
.hc-btn-rib { background: var(--navy); color: #fff; border-color: var(--navy); }
.hc-btn-rib:hover { background: var(--navy-light); color: #fff; }
.hc-btn-sab { background: var(--gold-bg); color: var(--gold-dim); border-color: var(--gold); }
.hc-btn-sab:hover { background: var(--gold); color: #fff; }
.hc-btn-email { background: var(--blue-bg); color: var(--blue); border-color: var(--blue); }
.hc-btn-email:hover { background: var(--blue); color: #fff; }

/* ── History pagination ───────────────────────────────────── */
.history-pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 16px 0;
  flex-wrap: wrap;
}
.page-btn {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
  min-width: 36px;
}
.page-btn:hover { background: var(--surface3); }
.page-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ── Modal improvements ──────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(26,31,54,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  padding: 16px;
}
.modal-box {
  background: var(--surface);
  border-radius: var(--r-lg);
  width: min(420px, 100%);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.modal-title { font-size: 14px; font-weight: 600; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text3); font-size: 18px; padding: 4px;
  border-radius: 4px; transition: color .15s; line-height: 1;
}
.modal-close:hover { color: var(--text1); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
  flex-shrink: 0;
}
.modal-lg { width: min(640px, 100%); max-height: 85vh; }

/* ─────────────────────────────────────────────────────────────
   RUN PAGE — RESIZABLE LAYOUT (authoritative)
   This is the single source of truth for .run-layout, .input-panel,
   .panel-resizer, and .output-panel-wrap on the Run page. Earlier
   blocks above are intentionally minimal / comment-only to avoid
   conflicting redeclarations.
───────────────────────────────────────────────────────────── */
.run-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.input-panel {
  width: 340px;
  min-width: 280px;
  max-width: 560px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
  transition: width .2s ease, min-width .2s ease, max-width .2s ease;
}
/* While actively dragging, kill the transition so it tracks the cursor 1:1 */
.input-panel.resizing { transition: none; }

.input-form {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* Collapsed state — panel shrinks to a thin strip; content hidden */
.input-panel.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  max-width: 0 !important;
  border-right: none;
}
.input-panel.collapsed .input-form,
.input-panel.collapsed .run-btn-area,
.input-panel.collapsed .panel-header { display: none; }

/* Drag handle between the two panels */
.panel-resizer {
  width: 6px;
  flex-shrink: 0;
  cursor: col-resize;
  background: transparent;
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
}
.panel-resizer::after {
  content: '';
  width: 2px;
  height: 100%;
  background: var(--border);
  transition: background .15s;
}
.panel-resizer:hover::after,
.panel-resizer.dragging::after { background: var(--gold); }

/* When the input panel is collapsed, the resizer becomes a clickable
   re-expand strip so there's always a visible affordance at the seam */
.panel-resizer.collapsed-state {
  width: 18px;
  background: var(--surface3);
  border-right: 1px solid var(--border);
}
.panel-resizer.collapsed-state::after { display: none; }
.panel-resizer.collapsed-state .resizer-chevron { display: flex; }

.resizer-chevron {
  display: none;
  align-items: center; justify-content: center;
  width: 16px; height: 16px;
  color: var(--text3);
  font-size: 13px;
}
.panel-resizer.collapsed-state:hover { background: var(--navy); }
.panel-resizer.collapsed-state:hover .resizer-chevron { color: white; }

.output-panel-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface2);
  min-width: 0;
  min-height: 0;
  height: 100%;
}
.output-panel {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ── Topbar responsive ───────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  gap: 12px;
  flex-wrap: wrap;
  min-height: 56px;
}
.topbar-title { font-size: 15px; font-weight: 700; }
.topbar-sub { font-size: 12px; color: var(--text3); margin-top: 1px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* ── Handoff summary grid responsive ─────────────────────── */
.handoff-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
}
.hs-item {
  background: var(--surface);
  padding: 12px 14px;
}

/* ── Download section responsive ─────────────────────────── */
.download-section { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.download-buttons { display: flex; flex-direction: column; gap: 10px; }
.download-card-wrap { display: flex; flex-direction: column; gap: 6px; }

/* ── Result page responsive ──────────────────────────────── */
.result-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
.result-main {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  min-width: 0;
}
.result-sidebar {
  width: 280px;
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px 16px;
  flex-shrink: 0;
}

/* ─── LARGE DESKTOP (1200px+) — widen default input panel ─── */
@media (min-width: 1200px) {
  .input-panel:not([style*="width"]) { width: 380px; }
}

/* ── TABLET (769px–1024px) ─────────────────────────────────── */
@media (max-width: 1024px) and (min-width: 769px) {
  .input-panel:not(.collapsed):not([style*="width"]) { width: 300px; min-width: 260px; }
  .team-container { padding: 14px 16px; }
  .history-container { padding: 14px 16px; }
  .result-sidebar { width: 220px; }
}

/* ── MOBILE (max 768px) ────────────────────────────────────── */
@media (max-width: 768px) {
  /* ── Mobile: whole page scrolls instead of internal panels ── */
  .app-shell { height: auto; min-height: 100vh; overflow-x: hidden; }
  .main-content { height: auto; overflow: visible; flex: none; min-height: 0; }

  /* Sidebar becomes top nav */
  .sidebar {
    width: 100%; height: auto; flex-shrink: 0;
    flex-direction: row; align-items: center;
    padding: 0;
    position: sticky; top: 0; z-index: 100;
  }
  .sidebar-logo { border-bottom: none; border-right: 1px solid rgba(255,255,255,.12); padding: 10px 14px; flex-shrink: 0; }
  .logo-sub { display: none; }
  .sidebar-nav { flex-direction: row; padding: 6px 8px; gap: 4px; overflow-x: auto; flex: 1; }
  .nav-section { display: none; }
  .nav-item { padding: 7px 10px; font-size: 12px; white-space: nowrap; }
  .nav-tag { display: none; }
  .sidebar-footer { display: none; }

  /* Topbar */
  .topbar { height: auto; min-height: 52px; padding: 8px 14px; flex-wrap: wrap; gap: 8px; }
  .topbar-title { font-size: 14px; }
  .topbar-sub { font-size: 11px; }

  /* Run layout — stack vertically, page scrolls */
  .run-layout { flex-direction: column; height: auto; overflow: visible; flex: none; }
  .input-panel { width: 100% !important; max-width: 100% !important; min-width: 0 !important; border-right: none; border-bottom: 1px solid var(--border); overflow: visible; height: auto; flex-shrink: 0; }
  .input-panel.collapsed { width: 100% !important; height: auto; }
  .input-panel.collapsed .input-form,
  .input-panel.collapsed .run-btn-area { display: flex !important; }
  .panel-resizer { display: none; }
  .input-form { max-height: none; overflow: visible; padding: 14px; }
  .output-panel-wrap { height: auto; overflow: visible; min-height: 300px; flex: none; }
  .results-area { overflow: visible; height: auto; flex: none; min-height: 0; padding: 0; }
  .output-panel { overflow: visible; height: auto; }

  /* Fields */
  .field-row { grid-template-columns: 1fr; }
  .output-type-grid { grid-template-columns: 1fr; }
  .sdr-chips { gap: 4px; }
  .sdr-chip { font-size: 11px; padding: 4px 8px; }

  /* History & team */
  .history-container { padding: 12px 14px; overflow: visible; flex: none; height: auto; }
  .team-container { padding: 12px 14px; }
  .team-table-wrap { overflow-x: auto; }
  .hide-sm { display: none !important; }

  /* Result page */
  .result-layout { flex-direction: column; height: auto; overflow: visible; }
  .result-main { padding: 14px; }
  .result-sidebar { width: 100%; border-left: none; border-top: 1px solid var(--border); padding: 14px; }

  /* Workflow tracker */
  .workflow-tracker { padding: 10px 12px; overflow: hidden; }
  .ps-stage { min-width: 100px; }
  .ps-detail { display: none; }

  /* Preview modal */
  .preview-panel { width: 100%; margin: 0; border-radius: 0; max-height: 100vh; }
  #previewModal { align-items: stretch; padding: 0; }
  .md-preview { padding: 20px 16px; }

  /* Download cards */
  .download-card { padding: 12px 14px; }

  /* Handoff summary */
  .handoff-summary-grid { grid-template-columns: 1fr 1fr; }
}

/* ── SMALL MOBILE (max 480px) ──────────────────────────────── */
@media (max-width: 480px) {
  .topbar-actions .btn span { display: none; }
  .hc-meta span:nth-child(n+4) { display: none; }
  .handoff-summary-grid { grid-template-columns: 1fr; }
  .modal-box { border-radius: var(--r); }
  .history-card { padding: 12px; }
  .hc-name { font-size: 13px; }
  .btn { padding: 7px 12px; font-size: 12px; }
  .topbar-title { font-size: 13px; }
  .result-main { padding: 10px; }
}

/* ══════════════════════════════════════════════════════════
   DEFINITIVE SCROLL-CHAIN RULES — these are the source of truth.
   The app uses a fixed-height shell (100vh) with internal scrolling.
   Each level of the flex chain needs min-height:0 to allow overflow.
   ══════════════════════════════════════════════════════════ */

/* Results area: the only scrolling region in the run page */
/* ═══════════════════════════════════════════════════════
   RESULTS AREA — authoritative definition
   flex:1 + min-height:0 = this fills remaining space and scrolls.
   All ancestors must also have min-height:0 for this to work.
   Content items (download-section, email-block) have their own padding.
   ═══════════════════════════════════════════════════════ */
.results-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  /* Ensure scroll works even on Windows with overlay scrollbars */
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.results-area::-webkit-scrollbar { width: 6px; }
.results-area::-webkit-scrollbar-track { background: transparent; }
.results-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Empty state: centered in the scroll area */
.output-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  min-height: 200px;
}

/* Prevent any horizontal overflow on the page */
body { overflow-x: hidden; }
.app-shell { overflow-x: hidden; }


/* ═══════════════════════════════════════════════════════════
   EXPANDABLE PANELS — Ops Handoff raw data + Email body
   Both reuse the same "expand-box" pattern: a normal inline box
   with a small expand button, which clones the content into the
   full-screen #expandModal for distraction-free reading.
   ═══════════════════════════════════════════════════════════ */

/* Raw Ops Handoff Block panel — no longer hard-clipped at 360px.
   It now grows naturally with the page scroll, with a reasonable
   cap so very long blocks still offer an internal scrollbar. */
.raw-handoff-body {
  padding: 0 16px 16px;
  max-height: 480px;
  overflow-y: auto;
}

.expand-box-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.expand-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--r);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  transition: all .15s;
  flex-shrink: 0;
}
.expand-btn:hover { background: var(--navy); color: #fff; border-color: var(--navy); }
.expand-btn i { font-size: 13px; }

/* Email block — head now allows the meta column to wrap and the
   action buttons (Copy + Expand) to stay grouped together */
.email-head { flex-wrap: wrap; }
.email-actions { display: flex; gap: 6px; flex-shrink: 0; }
.email-body {
  max-height: 420px;
  overflow-y: auto;
}

/* ── Full-screen expand modal (shared by both Ops Handoff + Email) ── */
#expandModal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
}
#expandModal .preview-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(2px); }
#expandModal .preview-panel {
  position: relative;
  z-index: 1;
  background: #fff;
  width: min(800px, 96vw);
  margin: 0 auto;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
  overflow: hidden;
}
#expandModal .expand-modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  color: var(--text1);
}
#expandModal .expand-modal-body.is-email { font-family: 'Cambo', Georgia, serif; font-size: 13.5px; }
#expandModal .expand-modal-body.is-raw   { font-family: monospace; font-size: 12px; color: var(--text2); }

@media (max-width: 768px) {
  #expandModal { padding: 0; }
  #expandModal .preview-panel { width: 100%; border-radius: 0; max-height: 100vh; }
  .email-body, .raw-handoff-body { max-height: none; }
}

/* ─────────────────────────────────────────────────────────────
   ADDITIONS — Phase 1.5 verification stage + routing UI updates
   (previously shipped as a separate style_additions.css file —
   merged in here so there is only one stylesheet to manage)
───────────────────────────────────────────────────────────── */

/* Skipped pipeline stage (e.g. SAB Digest when routing = CR ONLY) */
.ps-stage.done[style*="opacity"] .ps-icon { background: var(--border-med); border-color: var(--border-med); }

/* Info callout used on the Run page in place of the removed output-type selector */
.info-callout {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  background: var(--blue-bg);
  border: 1px solid var(--blue);
  border-radius: var(--r);
  font-size: 11.5px;
  color: var(--text2);
  line-height: 1.5;
}
.info-callout i { color: var(--blue); font-size: 15px; flex-shrink: 0; margin-top: 1px; }
