/* Smart Investor Factory — UI stylesheet
   Redesigned 2026-06-16: professional design-token system.
   No HTML/class changes were needed — every existing selector is preserved,
   restyled around CSS custom properties. Editable by hand, no build step. */

/* ============================================================
   Design tokens
   ============================================================ */
:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Code', 'JetBrains Mono', Menlo, Consolas, monospace;

  /* Neutrals */
  --bg:           #eaedf3;
  --surface:      #ffffff;
  --surface-2:    #f5f7fb;
  --surface-3:    #eef1f7;
  --border:       #e4e8ef;
  --border-strong:#d2d9e4;

  --text:   #101728;
  --text-2: #4d5666;
  --text-3: #8b94a4;
  --text3:  #8b94a4; /* alias used inline in some templates */

  /* Brand + semantic */
  --brand:        #d62839;
  --brand-dark:   #b21f2e;
  --primary:      #2f6fe4;
  --primary-hover:#1f57c4;
  --primary-soft: #e9f1fd;
  --primary-ink:  #1b3e7a;
  --success:      #1f9d57;
  --success-soft: #e6f6ed;
  --success-ink:  #156b3c;
  --warn:         #d98a17;
  --warn-soft:    #fdf2e0;
  --warn-ink:     #8a5910;
  --danger:       #d33a3a;
  --danger-soft:  #fdebeb;
  --danger-ink:   #962222;
  --info:         #0e7aa0;
  --info-soft:    #e3f4fa;

  /* Elevation */
  --radius:    12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --shadow-xs: 0 1px 2px rgba(16,24,40,.05);
  --shadow-sm: 0 1px 3px rgba(16,24,40,.07), 0 1px 2px rgba(16,24,40,.04);
  --shadow-md: 0 6px 18px rgba(16,24,40,.09), 0 2px 6px rgba(16,24,40,.05);
  --shadow-lg: 0 18px 44px rgba(16,24,40,.16);
  --ring: 0 0 0 3px rgba(47,111,228,.22);

  --topbar-h: 58px;
  --transition: .16s cubic-bezier(.4,0,.2,1);
}

* { box-sizing: border-box; }

html, body {
  font-family: var(--font-sans);
  margin: 0;
  background:
    radial-gradient(1200px 600px at 100% -10%, #f0f3fa 0%, rgba(240,243,250,0) 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

main { max-width: 1180px; margin: 28px auto 64px; padding: 0 20px; }

h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 4px; }
h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 12px; }
h3 { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
a  { color: var(--primary); }

/* ============================================================
   Top bar
   ============================================================ */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 24px;
  height: var(--topbar-h);
  background: linear-gradient(180deg, #1c1f29 0%, #14161d 100%);
  color: #eef0f5;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 1px 0 rgba(255,255,255,.04), 0 6px 20px rgba(0,0,0,.18);
  border-bottom: 2px solid var(--brand);
}
.brand {
  color: #fff;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-decoration: none;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
}
.brand::before {
  content: "SI";
  display: inline-grid;
  place-items: center;
  width: 26px; height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  box-shadow: 0 2px 6px rgba(214,40,57,.4);
}
.topbar-link {
  color: #fff;
  text-decoration: none;
  padding: 6px 13px;
  border-radius: var(--radius-pill);
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  font-size: 13px;
  font-weight: 600;
  transition: background var(--transition), border-color var(--transition);
}
.topbar-link:hover { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.28); }
#auto-refresh-indicator { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; opacity: .65; margin-right: 4px; }
#auto-refresh-dot { color: #2bd66f; font-size: 10px; transition: color .3s; }
.user  { margin-left: auto; display: inline-flex; gap: 10px; align-items: center; font-size: 13px; font-weight: 500; color: #d6dae3; }
.role  { padding: 3px 9px; border-radius: var(--radius-pill); font-size: 10.5px; letter-spacing: .03em; text-transform: uppercase; font-weight: 700; }
.role-editor   { background: rgba(47,111,228,.95); color: #fff; }
.role-producer { background: rgba(217,138,23,.95);  color: #fff; }
.role-admin    { background: rgba(214,40,57,.95);   color: #fff; }
.topbar .link, button.link {
  background: none; border: none; color: #c6cbd6; padding: 0; width: auto;
  text-decoration: none; font-size: 13px; cursor: pointer; font-weight: 500;
  transition: color var(--transition);
}
.topbar .link:hover, button.link:hover { color: #fff; text-decoration: underline; }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin: 18px 0;
  box-shadow: var(--shadow-sm);
}
.card > h2:first-child, .card > h1:first-child { margin-top: 0; }
.card.narrow { max-width: 440px; margin: 56px auto; }
.card.center { text-align: center; }
.card.alert  { border-color: var(--warn); border-left: 4px solid var(--warn); background: linear-gradient(180deg,var(--warn-soft),var(--surface) 60%); }
.card.action { border-left: 4px solid var(--primary); background: linear-gradient(180deg,var(--primary-soft),var(--surface) 60%); }

/* Section heading accent inside cards */
.card > h2 {
  display: flex; align-items: center; gap: 8px;
  color: var(--text);
}

/* ============================================================
   Forms
   ============================================================ */
label { display: block; margin: 14px 0; font-size: 14px; font-weight: 600; color: var(--text); }
label .muted, label .small { font-weight: 400; }
input, select, textarea {
  font-size: 14px;
  font-family: inherit;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  width: 100%;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  margin-top: 6px;
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring);
}
select { cursor: pointer; }
textarea { resize: vertical; line-height: 1.5; }

/* ============================================================
   Buttons
   ============================================================ */
button { cursor: pointer; font-family: inherit; }

.btn, button.primary, button.warn, button.danger,
button[type="submit"]:not(.link) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  min-height: 40px;
  box-sizing: border-box;
  width: auto;
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition: background var(--transition), border-color var(--transition),
              box-shadow var(--transition), transform var(--transition), color var(--transition);
}
.btn:hover, button.primary:hover, button.warn:hover, button.danger:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.btn:active, button:active { transform: translateY(0); box-shadow: var(--shadow-xs); }
.btn:focus-visible, button:focus-visible { outline: none; box-shadow: var(--ring); }

.btn { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }

button.primary, .btn.primary {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-hover) 100%);
  color: #fff; border-color: var(--primary-hover);
}
button.primary:hover, .btn.primary:hover { background: linear-gradient(180deg, #3a78ec 0%, #2057c4 100%); }

button.warn, .btn.warn {
  background: linear-gradient(180deg, #e89a2a 0%, var(--warn) 100%);
  color: #fff; border-color: var(--warn-ink);
}
button.warn:hover, .btn.warn:hover { background: linear-gradient(180deg, #eea93f 0%, #c97f10 100%); }

button.danger, .btn.danger {
  background: linear-gradient(180deg, #e04848 0%, var(--danger) 100%);
  color: #fff; border-color: var(--danger-ink);
}
button.danger:hover, .btn.danger:hover { background: linear-gradient(180deg, #e85a5a 0%, #c23232 100%); }

button.link {
  background: none; border: none; padding: 0; width: auto; min-height: 0;
  text-decoration: underline; box-shadow: none; font-weight: 500;
}
button.link:hover { transform: none; box-shadow: none; }

.btn.ghost {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary-ink);
  box-shadow: none;
}
.btn.ghost:hover { background: var(--primary-soft); }

.btn.small { padding: 6px 12px; font-size: 12.5px; min-height: 34px; }
.btn.danger.small, .btn.danger { min-height: 40px; }
.btn.big { padding: 13px 26px; font-size: 16px; min-height: 48px; }

form.inline { display: inline; margin: 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ============================================================
   Lists / dashboards
   ============================================================ */
.dash-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 8px 0 20px; flex-wrap: wrap; }
.dash-header h1 { margin: 0; }

.session-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.session-row a {
  display: flex; gap: 14px; align-items: center;
  padding: 12px 14px; border-radius: var(--radius-sm); text-decoration: none; color: inherit;
  border: 1px solid transparent;
  position: relative;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.session-row a:hover {
  background: var(--surface-2);
  border-color: var(--border);
  box-shadow: var(--shadow-xs);
}
.session-row a::after {
  content: "›";
  margin-left: auto;
  color: var(--text-3);
  font-size: 20px;
  line-height: 1;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity var(--transition), transform var(--transition);
}
.session-row a:hover::after { opacity: 1; transform: translateX(0); }
.sid    { font-family: var(--font-mono); font-size: 12px; color: var(--text-2); min-width: 170px; }
.sid.counter   { font-size: 15px; font-weight: 800; color: var(--primary); min-width: 56px; letter-spacing: -0.02em; }
.sid.timestamp { font-size: 12px; color: var(--text-3); min-width: 150px; }

/* New-session form: "Your new video will be #N" hint */
.next-id-hint {
  background: linear-gradient(135deg, var(--primary-soft) 0%, #f3f7fe 100%);
  border: 1px solid #cddcf5;
  border-radius: var(--radius);
  padding: 18px;
  margin: 8px 0 24px;
  text-align: center;
  font-size: 14px;
  color: var(--primary-ink);
}
.next-id-hint .big-id { font-size: 34px; font-weight: 800; color: var(--primary-hover); display: inline-block; margin: 0 4px; letter-spacing: -0.03em; }

/* Session detail: big session ID at the top */
.big-session-id {
  display: inline-flex; align-items: center;
  padding: 5px 15px;
  border-radius: var(--radius-sm);
  font-weight: 800;
  margin-right: 12px;
  letter-spacing: -0.02em;
}
.big-session-id.counter   { background: linear-gradient(135deg,var(--primary),var(--primary-hover)); color: #fff; font-size: 26px; box-shadow: var(--shadow-sm); }
.big-session-id.timestamp { background: var(--surface-3); color: var(--text-2); font-family: var(--font-mono); font-size: 14px; }
.topic  { flex: 1; min-width: 0; }

/* ============================================================
   State + status badges
   ============================================================ */
.state {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  border: 1px solid transparent;
}
.state::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; opacity: .9; flex: none;
}
.state[data-short]::before { content: attr(data-short) " · "; width: auto; height: auto; border-radius: 0; opacity: .7; background: none; font-weight: 700; }
.state-draft           { background: var(--surface-3); color: #5a6473; }
.state-script_writing  { background: var(--primary-soft); color: var(--primary-ink); }
.state-script_review   { background: var(--warn-soft); color: var(--warn-ink); }
.state-script_locked   { background: var(--success-soft); color: var(--success-ink); }
.state-avatar_rendering { background: var(--primary-soft); color: var(--primary-ink); }
.state-avatar_review    { background: var(--warn-soft); color: var(--warn-ink); }
.state-graphics_building{ background: var(--primary-soft); color: var(--primary-ink); }
.state-graphics_review  { background: var(--warn-soft); color: var(--warn-ink); }
.state-final_rendering  { background: var(--primary-soft); color: var(--primary-ink); }
.state-video_review     { background: var(--warn-soft); color: var(--warn-ink); }
.state-awaiting_publish { background: #fcf3c9; color: #785f10; }
.state-published        { background: var(--success-soft); color: var(--success-ink); }
.state-failed           { background: var(--danger-soft); color: var(--danger-ink); }
.state-aborted          { background: var(--surface-3); color: #5a6473; }

.stage  { font-family: var(--font-mono); font-size: 11px; color: var(--text-3); }
.stage-num { font-family: var(--font-mono); font-weight: 700; margin-right: 6px; }
.stage-friendly { font-size: 11px; }

.pulse  {
  background: var(--primary); color: #fff; padding: 3px 10px; border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; gap: 5px;
  animation: pulse 1.6s ease-in-out infinite;
}
.pulse::before { content:""; width:6px; height:6px; border-radius:50%; background:#fff; }
@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: 0.45 } }

.badge.action-needed {
  background: var(--brand); color: #fff; padding: 3px 10px; border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 700; box-shadow: 0 0 0 0 rgba(214,40,57,.5); animation: nudge 2s ease-out infinite;
}
@keyframes nudge { 0% { box-shadow: 0 0 0 0 rgba(214,40,57,.45); } 70% { box-shadow: 0 0 0 7px rgba(214,40,57,0); } 100% { box-shadow: 0 0 0 0 rgba(214,40,57,0); } }

.approval-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.approval-list li { margin: 0; }
.approval-list a {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--brand); text-decoration: none; font-weight: 600;
  padding: 8px 12px; border-radius: var(--radius-sm); background: var(--danger-soft);
  border: 1px solid #f5cccc; transition: background var(--transition);
}
.approval-list a:hover { background: #fbe0e0; }
.approval-list a code { background: rgba(0,0,0,.05); padding: 1px 6px; border-radius: 4px; }

/* ============================================================
   Utility text
   ============================================================ */
.muted { color: var(--text-2); }
.small { font-size: 12px; }
.error { background: var(--danger-soft); color: var(--danger-ink); border: 1px solid #f3c4c4; padding: 12px 14px; border-radius: var(--radius-sm); margin: 12px 0; }
.error-msg { color: var(--danger); font-size: 12px; }
code { font-family: var(--font-mono); font-size: .92em; }

/* ============================================================
   Session detail meta
   ============================================================ */
.session-detail .meta {
  display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; font-size: 13px;
}
.session-detail .meta > span {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 5px 13px;
  display: inline-flex; align-items: center; gap: 5px;
}
.session-detail .meta > span strong { color: var(--text-2); font-weight: 600; }
.session-detail .meta .error-msg { background: var(--danger-soft); border-color: #f3c4c4; }

/* ============================================================
   Per-segment review grid
   ============================================================ */
.segments {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 14px;
}
@media (min-width: 500px) {
  .segments { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
}
.segment {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition);
}
.segment:hover { box-shadow: var(--shadow-sm); }
.seg-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.segment video, .segment audio { max-width: 100%; border-radius: var(--radius-sm); }
.script-line { font-style: italic; color: var(--text-2); font-size: 13px; margin: 8px 0; line-height: 1.5; }
.seg-fb-form { margin-top: 8px; }
.seg-fb-form textarea { margin-bottom: 4px; }
.fb { padding: 7px 10px; margin: 4px 0; border-radius: var(--radius-sm); font-size: 12px; }
.fb-pending  { background: var(--warn-soft); color: var(--warn-ink); }
.fb-resolved { background: var(--success-soft); color: var(--success-ink); text-decoration: line-through; }

.seg-state-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-left: 6px;
}
.seg-state-pending    { background: var(--surface-3); color: #5a6473; }
.seg-state-approved   { background: var(--success-soft); color: var(--success-ink); }
.seg-state-needs_regen{ background: var(--danger-soft); color: var(--danger-ink); }
.segment.seg-approved   { border-left: 4px solid var(--success); }
.segment.seg-needs_regen{ border-left: 4px solid var(--danger); }
.segment.seg-pending    { border-left: 4px solid var(--border-strong); }
.seg-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-top: 10px; }
.seg-actions .seg-fb-form.inline { flex: 1; min-width: 220px; margin: 0; }
.seg-actions .seg-fb-form.inline textarea { margin-bottom: 4px; }

.approval-summary {
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
  padding: 14px 16px; border-radius: var(--radius); margin: 14px 0;
  border: 1px solid var(--border); background: var(--surface-2);
}
.approval-summary.all-approved { background: var(--success-soft); border-color: #b6e6c8; }
.approval-summary.pending      { background: var(--warn-soft); border-color: #f3d79e; }
.approval-summary .btn { margin-left: auto; }

.regen-action-card {
  background: linear-gradient(135deg, #fff6f5 0%, var(--warn-soft) 100%);
  border: 1px solid #f3c89a;
  border-left: 4px solid var(--warn);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin: 18px 0;
}
.regen-action-card h3 { margin: 0 0 8px 0; color: var(--warn-ink); font-size: 17px; }

.intent-legend { list-style: none; padding: 0; margin: 8px 0 12px; }
.intent-legend li { padding: 4px 0; }
.intent-tag {
  display: inline-block; padding: 2px 9px; border-radius: var(--radius-pill);
  font-family: var(--font-mono); font-size: 10px; font-weight: 700; margin-right: 6px;
}
.intent-tag.script_rewrite   { background: var(--primary-soft); color: var(--primary-ink); }
.intent-tag.delivery_change  { background: var(--primary-soft); color: var(--primary-ink); }
.intent-tag.visual_zoom      { background: var(--success-soft); color: var(--success-ink); }
.intent-tag.posture_change   { background: var(--warn-soft); color: var(--warn-ink); }
.intent-tag.broll_change     { background: var(--success-soft); color: var(--success-ink); }
.intent-tag.quality_only     { background: var(--surface-3); color: #5a6473; }

/* ============================================================
   Stage timeline table
   ============================================================ */
.stage-runs-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--radius); }
table.stage-runs { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 600px; }
table.stage-runs thead th {
  background: var(--surface-2); color: var(--text-2); font-weight: 700;
  text-transform: uppercase; font-size: 11px; letter-spacing: .04em;
  position: sticky; top: 0;
}
table.stage-runs th, table.stage-runs td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); }
table.stage-runs tbody tr:last-child td { border-bottom: none; }
table.stage-runs tbody tr:hover { background: var(--surface-2); }
table.stage-runs td.err { max-width: 320px; white-space: normal; word-break: break-word; color: var(--danger-ink); }
.stage-failed { background: var(--danger-soft) !important; }
.stage-waiting_approval { background: var(--warn-soft) !important; }

/* ============================================================
   Live log
   ============================================================ */
.log-tail {
  background: #0f1117; color: #c4cbd8;
  padding: 14px 16px; border-radius: var(--radius);
  height: 300px; overflow: auto;
  font-family: var(--font-mono); font-size: 12px;
  white-space: pre-wrap; word-break: break-word;
  border: 1px solid #1f2330;
  box-shadow: inset 0 1px 4px rgba(0,0,0,.4);
}

.assets { display: flex; gap: 14px; flex-wrap: wrap; }
.assets > div { background: var(--surface-2); border: 1px solid var(--border); padding: 14px; border-radius: var(--radius-sm); }

.gate {
  padding: 16px 18px; border: 1px solid #cddcf5; border-radius: var(--radius);
  background: linear-gradient(180deg, var(--primary-soft), var(--surface) 70%);
  margin: 14px 0; box-shadow: var(--shadow-xs);
}
.gate h3 { margin: 0 0 6px 0; font-size: 16px; }

/* ============================================================
   Update banner
   ============================================================ */
.update-banner {
  position: sticky; top: var(--topbar-h); z-index: 100;
  padding: 11px 16px;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-hover) 100%);
  color: #fff; font-size: 14px; font-weight: 600; text-align: center;
  cursor: pointer; box-shadow: var(--shadow-md);
}
.update-banner:hover { filter: brightness(1.06); }

/* ============================================================
   Generic user_input gate (askUser prompts)
   ============================================================ */
.prompt-choices { margin: 12px 0; }
.prompt-choice {
  display: block; padding: 12px 14px; margin: 8px 0;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); cursor: pointer; transition: background var(--transition), border-color var(--transition);
}
.prompt-choice:hover { background: var(--primary-soft); border-color: #c5d8f5; }
.prompt-choice input[type=radio] { margin-right: 8px; vertical-align: middle; width: auto; }
.prompt-choice-label { font-size: 14px; font-weight: 600; }
.prompt-choice-detail { display: block; margin-left: 24px; margin-top: 2px; color: var(--text-2); font-weight: 400; }
.prompt-custom { display: block; margin: 8px 0 0 24px; width: calc(100% - 24px); padding: 8px 11px; font-size: 14px; }

/* ============================================================
   Send-back / published banners
   ============================================================ */
.sent-back-note {
  background: var(--warn-soft); border-left: 3px solid var(--warn);
  padding: 8px 12px; margin: 4px 0 12px 24px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px; list-style: none;
}
.sent-back-reason { font-style: italic; color: var(--warn-ink); margin-left: 6px; }
.published-banner { background: linear-gradient(180deg,var(--success-soft),var(--surface) 70%); border-left: 4px solid var(--success); }
.published-banner h2 { color: var(--success-ink); margin-top: 0; }
.published-banner .btn.primary { background: linear-gradient(180deg,#27ae62,var(--success)); border-color: var(--success-ink); }

/* ============================================================
   Script-rewrite diff display
   ============================================================ */
.script-rewrite-run { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 8px; }
.script-rewrite-run summary { cursor: pointer; padding: 4px 0; font-weight: 600; }
.script-diff { margin: 12px 0; padding: 8px 0; border-top: 1px dashed var(--border); }
.script-diff h4 { margin: 0 0 6px; font-size: 14px; color: var(--text); }
.diff-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.diff-before, .diff-after { padding: 10px; border-radius: var(--radius-sm); font-size: 13px; }
.diff-before { background: var(--danger-soft); border-left: 3px solid #f08989; }
.diff-after  { background: var(--success-soft); border-left: 3px solid #6fcf97; }
.diff-before pre, .diff-after pre { white-space: pre-wrap; margin: 4px 0 0; font-family: inherit; font-size: 13px; }

/* ============================================================
   Ownership / handoff
   ============================================================ */
.ownership-card .ownership-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.handoff-picker {
  margin-top: 12px; padding: 14px; background: var(--primary-soft);
  border-left: 3px solid var(--primary); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.handoff-picker label { display: block; margin-bottom: 8px; }
.handoff-picker select { width: 100%; }
.admin-reassign { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
.admin-reassign summary { cursor: pointer; font-weight: 600; }
.reassign-grid { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: end; margin-top: 12px; }
.reassign-grid label { display: block; }
.reassign-grid select { width: 100%; }
.badge.unassigned {
  background: var(--warn-soft); color: var(--warn-ink); border: 1px solid #f3c89a;
  padding: 2px 9px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 600; margin-left: 6px;
}

/* ============================================================
   Cost / presence badges
   ============================================================ */
@keyframes cost-badge-flash { 0%, 100% { box-shadow: 0 0 0 0 rgba(14,122,160,0); } 30% { box-shadow: 0 0 0 4px rgba(14,122,160,.45); } }
.cost-badge-flash { animation: cost-badge-flash 1.5s ease-out; }
.viewers-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; background: var(--info-soft); border: 1px solid #b8e3ef; border-radius: var(--radius-pill); font-size: 12px; color: var(--info); }
.viewer-chip { padding: 1px 7px; border-radius: var(--radius-pill); background: rgba(0,0,0,.05); font-size: 11px; margin-right: 2px; }
.viewer-chip.viewer-role-editor   { background: var(--primary-soft); color: var(--primary-ink); }
.viewer-chip.viewer-role-producer { background: var(--warn-soft); color: var(--warn-ink); }
.viewer-chip.viewer-role-admin    { background: var(--danger-soft); color: var(--danger-ink); }

/* ============================================================
   Dashboard filter bar (was broken: white-on-light translucent)
   ============================================================ */
.dashboard-filter {
  display: flex; gap: 12px; align-items: center;
  max-width: 1180px; margin: 18px auto -8px; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-xs);
  flex-wrap: wrap;
}
.dashboard-filter input[type="search"] {
  flex: 1 1 280px; min-width: 200px; margin-top: 0; padding: 8px 12px;
  border-radius: var(--radius-pill); background: var(--surface-2);
  border: 1px solid var(--border-strong); color: var(--text); font-family: inherit;
}
.dashboard-filter .state-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.dashboard-filter .chip {
  padding: 5px 12px; border-radius: var(--radius-pill); background: var(--surface-2);
  border: 1px solid var(--border-strong); color: var(--text-2); font-family: inherit;
  font-size: 12px; font-weight: 600; cursor: pointer; transition: all var(--transition);
}
.dashboard-filter .chip:hover { background: var(--surface-3); color: var(--text); }
.dashboard-filter .chip.active { background: var(--primary); border-color: var(--primary-hover); color: #fff; }
.dashboard-filter .link { background: none; border: none; color: var(--primary); cursor: pointer; text-decoration: underline; padding: 0; font-size: 12px; width: auto; }

.badge.cost-row {
  background: var(--info-soft); color: var(--info); border: 1px solid #b8e3ef;
  padding: 2px 9px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 600;
  margin-left: 6px; font-variant-numeric: tabular-nums;
}

/* ============================================================
   Session notes thread
   ============================================================ */
.session-notes-card .add-note-form { display: flex; gap: 8px; align-items: flex-start; margin: 12px 0; }
.session-notes-card .add-note-form textarea { flex: 1; padding: 8px 10px; font-family: inherit; font-size: 14px; margin-top: 0; }
.session-notes-card .note {
  background: var(--surface-2); border-left: 3px solid var(--border-strong);
  padding: 10px 14px; margin-bottom: 8px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.session-notes-card .note-header { display: flex; gap: 6px; align-items: center; margin-bottom: 4px; font-size: 13px; }
.session-notes-card .note-body { white-space: pre-wrap; font-size: 14px; }
.note-delete { background: transparent; border: none; color: var(--text-3); cursor: pointer; margin-left: auto; padding: 0 6px; width: auto; min-height: 0; box-shadow: none; }
.note-delete:hover { color: var(--danger); transform: none; box-shadow: none; }

/* ============================================================
   References + segment swap uploads
   ============================================================ */
.references-card #add-reference-form { display: flex; gap: 8px; align-items: center; margin: 12px 0; }
.references-card .references-list { list-style: none; padding: 0; margin: 0; }
.references-card .references-list li { padding: 8px 10px; border-bottom: 1px dashed var(--border); display: flex; gap: 8px; align-items: center; }
.references-card .references-list li:last-child { border-bottom: none; }
.reference-delete { background: transparent; border: none; color: var(--text-3); cursor: pointer; margin-left: auto; padding: 0 6px; width: auto; min-height: 0; box-shadow: none; }
.reference-delete:hover { color: var(--danger); transform: none; box-shadow: none; }
.seg-swap-form { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
.seg-swap-form summary { cursor: pointer; padding: 4px 0; font-weight: 600; }
.seg-swap-upload { margin-top: 6px; }
.seg-swap-upload input[type="file"] { display: block; margin-bottom: 6px; }

/* ============================================================
   Regen status banner
   ============================================================ */
.regen-status-card { border-left: 4px solid var(--primary); background: linear-gradient(180deg,var(--primary-soft),var(--surface) 70%); }
.regen-status-card.regen-running { border-left-color: var(--primary); }
.regen-status-card.regen-complete { border-left-color: var(--success); background: linear-gradient(180deg,var(--success-soft),var(--surface) 70%); }
.regen-status-card h2 { margin-top: 0; }
.regen-outcomes { list-style: none; padding: 0; margin: 6px 0; }
.regen-outcomes li { padding: 5px 0; font-size: 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.regen-outcomes code { background: var(--surface); border: 1px solid var(--border); padding: 2px 7px; border-radius: 4px; font-size: 13px; min-width: 100px; }
.comp-only-hint { margin-left: 8px; font-style: italic; }

/* ============================================================
   Script editor card
   ============================================================ */
.script-editor-card { background: var(--surface); color: var(--text); border-left: 4px solid #7c5cd6; }
.script-editor-card h2 { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 0; color: var(--text); }
.script-editor-card p, .script-editor-card details, .script-editor-card summary { color: var(--text); }
.script-editor-card a { color: #5b3fb0; }
.script-editor-card code, .script-editor-card pre { color: var(--text); }
.script-segments-editor { display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }
.scene-edit, .segment-edit {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid #7c5cd6; border-radius: var(--radius-sm);
  padding: 16px; color: var(--text); margin-bottom: 12px;
}
.scene-edit label, .segment-edit label { display: block; color: var(--text); margin: 10px 0; }
.scene-edit .muted, .segment-edit .muted { color: var(--text-2); font-weight: 500; }
.scene-edit-header, .segment-edit .seg-edit-header {
  display: flex; gap: 10px; align-items: baseline; margin-bottom: 10px;
  padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.scene-edit-header strong, .segment-edit .seg-edit-header strong { color: var(--text); font-size: 15px; }
.scene-edit-row { display: flex; gap: 16px; flex-wrap: wrap; margin: 8px 0; }
.scene-edit-field { flex: 1 1 240px; min-width: 0; }
.scene-edit-field input, .scene-edit-field select, .scene-edit-field textarea { color: var(--text); background: var(--surface); }
.scene-edit-field input::placeholder { color: var(--text-3); }
.scene-edit-broll { margin-top: 10px; padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius-sm); }
.scene-edit-broll summary { cursor: pointer; color: var(--text); font-weight: 600; }
.scene-edit-dirty { color: var(--warn) !important; font-weight: 700; }
.segment-edit textarea {
  width: 100%; font-family: inherit; font-size: 14px; padding: 10px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  resize: vertical; background: var(--surface-2);
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.segment-edit textarea:focus { background: var(--surface); border-color: #7c5cd6; outline: none; box-shadow: 0 0 0 3px rgba(124, 92, 214, 0.2); }
.script-edit-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
#script-edit-status { font-style: italic; }

/* ============================================================
   Residual violations
   ============================================================ */
.residual-violations-block {
  background: var(--danger-soft); border: 1px solid #f3c4c4; border-left: 4px solid var(--danger);
  padding: 14px 16px; margin: 12px 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--text);
}
.residual-violations-header strong { color: var(--danger-ink); font-size: 14px; }
.residual-violations-header p { margin: 4px 0 10px; }
.violation-card { background: var(--surface); border: 1px solid #f3c4c4; border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 8px; }
.violation-card:last-child { margin-bottom: 0; }
.violation-card-header { display: flex; gap: 8px; align-items: baseline; margin-bottom: 4px; }
.violation-num { font-weight: 800; color: var(--danger-ink); min-width: 28px; }
.violation-where { background: var(--danger-soft); padding: 2px 7px; border-radius: 4px; font-size: 12px; color: var(--text); }
.violation-rule { font-weight: 700; color: var(--text); margin-bottom: 4px; }
.violation-detail { margin-bottom: 4px; line-height: 1.45; }
.violation-suggestion { margin-bottom: 8px; padding: 8px 10px; background: var(--primary-soft); border-left: 3px solid var(--primary); border-radius: 0 4px 4px 0; color: var(--text); }
.violation-suggestion strong { color: var(--primary-ink); }
.violation-fix-row { margin-top: 8px; padding-top: 8px; border-top: 1px dashed #f3c4c4; }
.violation-fix-label { display: block; margin-bottom: 4px; }
.violation-fix-label code { background: var(--surface-3); padding: 1px 5px; border-radius: 3px; font-size: 11px; }
.violation-fix-input { width: 100%; font-family: inherit; font-size: 13px; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); resize: vertical; min-height: 36px; }
.violation-fix-input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.violation-fix-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.violation-fix-status { flex: 1; min-width: 120px; }
.violation-card.is-resolved { opacity: 0.65; background: var(--success-soft); border-color: #b6e6c8; }
.violation-card.is-skipped  { opacity: 0.65; background: var(--surface-2); border-color: var(--border-strong); }
.violation-card.is-resolved .violation-fix-status { color: var(--success-ink); font-weight: 600; }
.violation-card.is-skipped  .violation-fix-status { color: var(--text-2); }
.violation-fix-row-structural p { margin: 6px 0; line-height: 1.45; }
.violations-all-clear {
  margin-top: 12px; padding: 12px 14px; background: var(--success-soft);
  border: 1px solid #b6e6c8; border-left: 4px solid var(--success);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--success-ink); font-weight: 600;
}

/* ============================================================
   Sticky "waiting on whom" banner
   ============================================================ */
.gate-status-banner {
  position: sticky; top: var(--topbar-h); z-index: 50;
  padding: 13px 18px; margin: 0 0 16px;
  font-size: 14px; line-height: 1.4;
  border: 1px solid; border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.gate-status-mine  { background: var(--warn-soft); border-color: #f0cf94; color: var(--warn-ink); }
.gate-status-mine strong { color: var(--warn-ink); }
.gate-status-other { background: var(--primary-soft); border-color: #c5d8f5; color: var(--primary-ink); }
.gate-status-other strong { color: var(--primary-ink); }
.gate-status-jump { display: inline-block; margin-left: 12px; font-weight: 700; text-decoration: underline; }
.gate-status-mine .gate-status-jump { color: var(--warn-ink); }
.gate-status-other .gate-status-jump { color: var(--primary-ink); }

/* ============================================================
   Compression warning / info
   ============================================================ */
.compression-warning {
  background: var(--warn-soft); border-left: 4px solid var(--warn);
  padding: 12px 14px; margin: 12px 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.compression-warning strong { color: var(--warn-ink); }
.compression-warning p { margin: 4px 0 0; }
.compression-info {
  background: var(--success-soft); border-left: 4px solid var(--success);
  padding: 8px 14px; margin: 12px 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 13px;
}

/* Override-safe ghost (was duplicated at file end) */
.btn.ghost { background: transparent; border: 1px solid #7c5cd6; color: #5b3fb0; }
.btn.ghost:hover { background: #f5f1fd; }

/* ============================================================
   Misc
   ============================================================ */
details > summary { cursor: pointer; }
hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
::selection { background: rgba(47,111,228,.18); }

/* Scrollbar polish (WebKit) */
.log-tail::-webkit-scrollbar, .stage-runs-wrap::-webkit-scrollbar { height: 10px; width: 10px; }
.log-tail::-webkit-scrollbar-thumb { background: #333a4a; border-radius: 6px; }
.stage-runs-wrap::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; }
