
  :root {
    --bg: #090a0f;
    --panel: rgba(18, 22, 32, 0.85);
    --panel-raised: rgba(28, 34, 49, 0.9);
    --border: rgba(255, 255, 255, 0.08);
    --text: #e2e8f0;
    --text-dim: #828fa5;
    --amber: #f39c12;
    --amber-glow: rgba(243, 156, 18, 0.35);
    --cyan: #00d2ff;
    --cyan-glow: rgba(0, 210, 255, 0.35);
    --red: #ff3f34;
    --red-glow: rgba(255, 63, 52, 0.35);
    --green: #2ecc71;
    --green-glow: rgba(46, 204, 113, 0.35);
    --violet: #9b7bff;
  }

  * { box-sizing: border-box; }

  html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'IBM Plex Sans', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
  }

  /* subtle grain texture for depth */
  body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 5;
    opacity: 0.035;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  }

  .bg-glow {
    position: fixed;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
  }
  .glow-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.12;
    transition: opacity 1.2s ease;
  }
  .glow-1 { background: var(--amber); width: 400px; height: 400px; top: -100px; right: 10%; }
  .glow-2 { background: var(--cyan); width: 500px; height: 500px; bottom: -100px; left: 10%; }
  .glow-3 { background: var(--red); width: 320px; height: 320px; top: 40%; right: 35%; opacity: 0; }
  .glow-3.hot { opacity: 0.10; }

  /* ---- Top status bar ---- */
  .topbar {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 22px;
    border-bottom: 1px solid var(--border);
    background: rgba(9, 10, 15, 0.75);
    backdrop-filter: blur(20px);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: var(--text-dim);
    flex-wrap: wrap;
    gap: 8px;
  }
  .topbar-left, .topbar-right { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
  .topbar .divider { width: 1px; height: 12px; background: var(--border); }
  .live-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--green); display: inline-block; margin-right: 6px;
    box-shadow: 0 0 8px var(--green);
    animation: dotPulse 1.6s infinite ease-in-out;
  }
  .topbar-reset {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    letter-spacing: .06em;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: all .2s;
  }
  .topbar-reset:hover { border-color: var(--red); color: var(--red); }

  .app {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
  }
  @media (max-width: 980px) { .app { flex-direction: column; } }

  /* ---- Sidebar ---- */
  .sidebar {
    width: 320px;
    flex-shrink: 0;
    background: var(--panel);
    border-right: 1px solid var(--border);
    padding: 26px 20px;
    display: flex;
    flex-direction: column;
    gap: 25px;
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    overflow-y: auto;
  }
  @media (max-width: 980px) {
    .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  }

  .eyebrow {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    letter-spacing: .18em;
    color: var(--amber);
    text-transform: uppercase;
    margin: 0 0 6px;
    text-shadow: 0 0 10px var(--amber-glow);
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .eyebrow::before {
    content: '';
    width: 14px; height: 1px; background: var(--amber);
    box-shadow: 0 0 6px var(--amber);
  }
  .title {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 20px;
    font-weight: 700;
    margin: 0;
    line-height: 1.3;
    letter-spacing: -0.5px;
  }
  .subtitle {
    color: var(--text-dim);
    font-size: 12.5px;
    line-height: 1.6;
    margin: 10px 0 0;
  }

  .section-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    letter-spacing: .12em;
    color: var(--text-dim);
    text-transform: uppercase;
    margin: 0 0 12px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 6px;
    display: flex;
    justify-content: space-between;
  }

  .scenario-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .scenario-btn {
    display: block;
    width: 100%;
    text-align: left;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px 14px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'IBM Plex Sans', sans-serif;
  }
  .scenario-btn:hover {
    border-color: var(--amber);
    background: rgba(243, 156, 18, 0.05);
    transform: translateY(-1px);
  }
  .scenario-btn.selected {
    border-color: var(--cyan);
    background: rgba(0, 210, 255, 0.08);
    box-shadow: 0 0 15px rgba(0, 210, 255, 0.1);
  }
  .scenario-btn .tag {
    display: block;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 9.5px;
    color: var(--text-dim);
    letter-spacing: .04em;
    margin-top: 5px;
  }

  textarea {
    width: 100%;
    min-height: 110px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px;
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 13px;
    border-radius: 6px;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
  }
  textarea:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 10px rgba(0, 210, 255, 0.1);
  }

  .settings-panel {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    font-size: 12px;
  }
  .settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
  }
  .settings-row:last-child { margin-bottom: 0; }
  .settings-select {
    background: var(--panel-raised);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    outline: none;
  }
  .key-input {
    width: 100%;
    background: var(--panel-raised);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-family: 'IBM Plex Mono', monospace;
    margin-top: 5px;
    outline: none;
  }

  .run-btn {
    padding: 12px;
    background: var(--amber);
    color: #090a0f;
    font-weight: 700;
    border: none;
    border-radius: 6px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    letter-spacing: .08em;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: 0 4px 15px rgba(243, 156, 18, 0.25);
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
  }
  .run-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(243, 156, 18, 0.4);
  }
  .run-btn:active:not(:disabled) { transform: translateY(0); }
  .run-btn:disabled {
    background: #20242b;
    color: var(--text-dim);
    box-shadow: none;
    cursor: not-allowed;
  }

  .manual-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    color: var(--text);
  }
  .manual-btn:hover {
    border-color: var(--cyan);
    background: rgba(0, 210, 255, 0.05);
  }

  .kbd-hint {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 9.5px;
    color: var(--text-dim);
    text-align: center;
    margin-top: 8px;
  }
  .kbd-hint kbd {
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 1px 5px;
    font-family: 'IBM Plex Mono', monospace;
  }

  /* Telemetry widgets */
  .telemetry-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 10px;
  }
  .telemetry-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px;
    text-align: center;
  }
  .telemetry-val {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 16px;
    font-weight: 700;
    margin-top: 2px;
    transition: color .3s;
  }
  .telemetry-val.green { color: var(--green); text-shadow: 0 0 8px var(--green-glow); }
  .telemetry-val.red { color: var(--red); text-shadow: 0 0 8px var(--red-glow); }

  .ratio-bar-wrap {
    font-size: 10px;
    color: var(--text-dim);
    font-family: 'IBM Plex Mono', monospace;
  }
  .ratio-bar-labels { display: flex; justify-content: space-between; margin-bottom: 5px; }
  .ratio-bar {
    height: 8px;
    width: 100%;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
  }
  .ratio-bar-fill-auto { height: 100%; background: var(--green); box-shadow: 0 0 8px var(--green-glow) inset; transition: width .5s ease; }
  .ratio-bar-fill-esc { height: 100%; background: var(--red); box-shadow: 0 0 8px var(--red-glow) inset; transition: width .5s ease; }

  .session-log {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11.5px;
    color: var(--text-dim);
    line-height: 1.8;
    max-height: 160px;
    overflow-y: auto;
  }
  .session-log b { color: var(--text); }
  .session-log .esc { color: var(--red); }
  .session-log .auto { color: var(--green); }

  /* ---- Main Dashboard Layout ---- */
  .main {
    flex: 1;
    padding: 35px 45px;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    gap: 25px;
  }
  @media (max-width: 980px) { .main { padding: 25px 20px; } }

  .main-head {
    border-bottom: 1px solid var(--border);
    padding-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
  }
  .main-head h1 {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    font-weight: 600;
    margin: 0 0 8px;
    color: var(--cyan);
    letter-spacing: .08em;
    text-transform: uppercase;
    text-shadow: 0 0 8px var(--cyan-glow);
  }
  .main-head p { margin: 0; color: var(--text-dim); font-size: 14px; line-height: 1.5; max-width: 520px; }

  .ref-chip {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10.5px;
    color: var(--text-dim);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 6px 10px;
    background: rgba(255,255,255,0.02);
    white-space: nowrap;
  }
  .ref-chip b { color: var(--amber); }

  /* Overall progress bar */
  .progress-track {
    height: 4px;
    width: 100%;
    background: rgba(255,255,255,0.05);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
  }
  .progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--amber), var(--cyan));
    box-shadow: 0 0 10px var(--cyan-glow);
    transition: width .5s cubic-bezier(.19,1,.22,1);
  }
  .progress-fill.escalated { background: linear-gradient(90deg, var(--amber), var(--red)); box-shadow: 0 0 10px var(--red-glow); }

  /* Live Pipeline System */
  .pipeline {
    display: flex;
    flex-direction: column;
    position: relative;
  }

  .station {
    position: relative;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 20px;
    opacity: .35;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    overflow: hidden;
  }
  .station.active {
    opacity: 1;
    border-color: var(--amber);
    box-shadow: 0 0 20px rgba(243, 156, 18, 0.15);
  }

  .station.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(243, 156, 18, 0.08), transparent);
    animation: scan 1.8s infinite linear;
  }
  @keyframes scan {
    0% { left: -100%; }
    100% { left: 200%; }
  }

  .station.done-pass {
    opacity: 1;
    border-color: var(--cyan);
    box-shadow: 0 0 15px rgba(0, 210, 255, 0.05);
  }
  .station.done-escalate {
    opacity: 1;
    border-color: var(--red);
    box-shadow: 0 0 15px rgba(255, 63, 52, 0.08);
  }
  .station.done-error {
    opacity: 1;
    border-color: var(--red);
  }

  .conduit {
    width: 3px;
    height: 25px;
    margin-left: 34px;
    background: var(--border);
    position: relative;
  }
  .conduit.flowing::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, transparent, var(--amber), transparent);
    animation: flowLaser 0.6s linear infinite;
  }
  .conduit.passed { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
  .conduit.escalated { background: var(--red); box-shadow: 0 0 8px var(--red); }

  @keyframes flowLaser {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100%); }
  }

  .station-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .station-name { display: flex; align-items: center; gap: 14px; }

  .station-icon {
    width: 26px; height: 26px;
    border-radius: 50%;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: all .3s ease;
    position: relative;
  }
  .station-icon svg { width: 13px; height: 13px; stroke: var(--text-dim); transition: stroke .3s; }
  .station.active .station-icon { border-color: var(--amber); box-shadow: 0 0 12px var(--amber-glow); animation: dotPulse 1.2s infinite ease-in-out; }
  .station.active .station-icon svg { stroke: var(--amber); }
  .station.done-pass .station-icon { border-color: var(--cyan); box-shadow: 0 0 10px var(--cyan-glow); }
  .station.done-pass .station-icon svg { stroke: var(--cyan); }
  .station.done-escalate .station-icon, .station.done-error .station-icon { border-color: var(--red); box-shadow: 0 0 10px var(--red-glow); }
  .station.done-escalate .station-icon svg, .station.done-error .station-icon svg { stroke: var(--red); }

  @keyframes dotPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.12); opacity: 0.7; }
  }

  .station-name b { font-family: 'IBM Plex Mono', monospace; font-size: 13.5px; font-weight: 600; }
  .station-role { font-size: 12px; color: var(--text-dim); margin-top: 3px; }
  .station-meta { display: flex; align-items: center; gap: 10px; }
  .station-status {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--text-dim);
    font-weight: 700;
  }
  .station-time {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 9.5px;
    color: var(--text-dim);
    opacity: .7;
  }
  .station.active .station-status { color: var(--amber); }
  .station.done-pass .station-status { color: var(--cyan); }
  .station.done-escalate .station-status, .station.done-error .station-status { color: var(--red); }

  .station-body {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    display: none;
    animation: expand 0.35s cubic-bezier(.19,1,.22,1);
  }
  .station.active .station-body, .station.done-pass .station-body, .station.done-escalate .station-body, .station.done-error .station-body {
    display: block;
  }

  @keyframes expand {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
  }

  /* confidence gauge */
  .gauge-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
  .gauge {
    display: flex; align-items: center; gap: 8px;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px 6px 6px;
  }
  .gauge svg { width: 30px; height: 30px; }
  .gauge-label { font-family: 'IBM Plex Mono', monospace; font-size: 10px; line-height: 1.4; }
  .gauge-label .gl-top { color: var(--text-dim); letter-spacing: .08em; text-transform: uppercase; font-size: 9px; }
  .gauge-label .gl-bottom { font-weight: 700; font-size: 12px; }
  .badge {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: 4px 9px;
    border-radius: 4px;
    border: 1px solid;
    font-weight: 600;
  }
  .badge.resolve { color: var(--green); border-color: rgba(46,204,113,0.35); background: rgba(46,204,113,0.07); }
  .badge.escalate { color: var(--red); border-color: rgba(255,63,52,0.35); background: rgba(255,63,52,0.07); }

  pre {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11.5px;
    line-height: 1.6;
    color: #cddce0;
    background: #0d0f14;
    border: 1px solid rgba(255,255,255,0.03);
    border-radius: 6px;
    padding: 12px 14px;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 240px;
    overflow: auto;
  }
  .jkey { color: var(--cyan); }
  .jstr { color: var(--amber); }
  .jnum { color: var(--green); }
  .jbool { color: var(--violet); }
  .jnull { color: var(--red); }

  /* ---- Audit Report Document Design ---- */
  .report-wrap {
    margin-top: 30px;
    background: #f7f6f0;
    color: #1a1e24;
    border-radius: 8px;
    padding: 35px 40px;
    position: relative;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12.5px;
    line-height: 1.8;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4), inset 0 0 40px rgba(0, 0, 0, 0.05);
    display: none;
    border: 1px solid #e2dfd2;
    overflow: hidden;
  }
  .report-wrap.show { display: block; animation: slideUpDoc 0.5s cubic-bezier(0.19, 1, 0.22, 1); }

  .letterhead {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2px solid #1a1e24;
    padding-bottom: 14px;
    margin-bottom: 22px;
  }
  .letterhead-title { font-size: 15px; font-weight: 700; letter-spacing: .04em; }
  .letterhead-sub { font-size: 10px; color: #6b7583; margin-top: 4px; letter-spacing: .05em; }
  .letterhead-meta { text-align: right; font-size: 10px; color: #6b7583; line-height: 1.6; }
  .letterhead-meta b { color: #1a1e24; }

  .report-text-area {
    outline: none;
    padding: 6px;
    border: 1px dashed transparent;
    border-radius: 6px;
    transition: all 0.2s;
    white-space: pre-wrap;
  }
  .report-text-area:hover {
    border-color: rgba(0, 0, 0, 0.15);
    background: rgba(0, 0, 0, 0.005);
  }
  .report-text-area:focus {
    border-color: var(--cyan);
    background: rgba(255, 255, 255, 0.6);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.06);
  }

  .report-controls-bar {
    display: flex;
    align-items: center;
    margin-bottom: 25px;
    font-size: 11px;
    color: #636e72;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    padding-bottom: 15px;
    gap: 8px;
    flex-wrap: wrap;
  }

  .status-toggle-btn {
    padding: 5px 12px;
    font-size: 10px;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: bold;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid transparent;
    text-transform: uppercase;
    transition: all 0.2s;
  }
  .status-toggle-btn.btn-auto {
    background: rgba(46, 204, 113, 0.1);
    color: #1e7c3c;
    border-color: rgba(46, 204, 113, 0.2);
  }
  .status-toggle-btn.btn-auto:hover, .status-toggle-btn.btn-auto.active {
    background: #2ecc71;
    color: white;
  }
  .status-toggle-btn.btn-esc {
    background: rgba(192, 57, 43, 0.1);
    color: #c0392b;
    border-color: rgba(192, 57, 43, 0.2);
  }
  .status-toggle-btn.btn-esc:hover, .status-toggle-btn.btn-esc.active {
    background: #e74c3c;
    color: white;
  }

  .document-actions-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
    gap: 10px;
    flex-wrap: wrap;
  }

  .doc-action-btn {
    background: var(--panel-raised);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 18px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    font-family: 'IBM Plex Mono', monospace;
    transition: all 0.2s;
  }
  .doc-action-btn:hover {
    border-color: var(--cyan);
    background: rgba(0,210,255,0.05);
  }

  @keyframes slideUpDoc {
    from { opacity: 0; transform: translateY(40px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .stamp {
    position: absolute;
    top: 25px;
    right: 35px;
    border: 4px double;
    padding: 8px 16px;
    font-weight: 800;
    font-size: 13px;
    letter-spacing: .12em;
    transform: rotate(-7deg);
    border-radius: 6px;
    font-family: 'IBM Plex Mono', monospace;
    text-shadow: none;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.2);
    pointer-events: none;
  }
  .stamp.auto {
    color: #1c7c3c;
    border-color: #1c7c3c;
    background: rgba(46, 204, 113, 0.05);
  }
  .stamp.esc {
    color: #c0392b;
    border-color: #c0392b;
    background: rgba(192, 57, 43, 0.05);
  }

  .hint { font-size: 12px; color: var(--text-dim); margin-top: 14px; text-align: center; min-height: 16px; }

  /* Toasts */
  .toast-stack {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
  }
  .toast {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    padding: 10px 16px;
    border-radius: 6px;
    background: var(--panel-raised);
    border: 1px solid var(--border);
    color: var(--text);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    animation: toastIn .3s cubic-bezier(.19,1,.22,1), toastOut .3s ease 3.2s forwards;
    max-width: 300px;
  }
  .toast.ok { border-color: rgba(46,204,113,0.4); color: var(--green); }
  .toast.warn { border-color: rgba(255,63,52,0.4); color: var(--red); }
  @keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
  @keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }

  @media print {
    body { background: white !important; color: black !important; }
    .sidebar, .main-head, .pipeline, .bg-glow, .topbar, .toast-stack, .no-print { display: none !important; }
    .main { padding: 0 !important; margin: 0 !important; max-width: 100% !important; }
    .report-wrap { display: block !important; box-shadow: none !important; border: none !important; margin-top: 0 !important; padding: 0 !important; background: white !important; color: black !important; }
    .stamp { box-shadow: none !important; }
    .report-text-area { border: none !important; padding: 0 !important; background: transparent !important; }
  }

/* ============================================================
   Feature 3 — Confidence Score bar
   Lives inside .report-wrap which has a light (#f7f6f0) background,
   so all colours here are calibrated for a light context.
   ============================================================ */
.confidence-bar {
  display: none;
  margin: 0 0 18px;
  font-family: 'IBM Plex Mono', monospace;
}
.confidence-badge {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 7px 16px;
  border-radius: 6px;
  border: 1px solid;
  font-size: 11px;
  font-weight: 700;
}
.conf-label {
  font-size: 9px;
  letter-spacing: .12em;
  text-transform: uppercase;
  opacity: 0.7;
  font-weight: 600;
}
.conf-value {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.conf-delta {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  background: rgba(0,0,0,0.05);
  padding: 2px 7px;
  border-radius: 3px;
}
.confidence-low-nudge {
  margin-top: 8px;
  font-size: 11.5px;
  color: #7a4f00;
  background: rgba(243, 156, 18, 0.1);
  border: 1px solid rgba(243, 156, 18, 0.25);
  border-radius: 5px;
  padding: 7px 12px;
  font-family: 'IBM Plex Sans', sans-serif;
  line-height: 1.55;
}

/* ============================================================
   Feature 2 — Re-run from edits button
   Uses violet (--violet) to visually distinguish it from the
   other report-action buttons without adding a new colour token.
   ============================================================ */
#rerunBtn {
  background: rgba(155, 123, 255, 0.07);
  border: 1px solid rgba(155, 123, 255, 0.32);
  color: #6a4fd8;
}
#rerunBtn:hover:not(:disabled) {
  background: rgba(155, 123, 255, 0.16);
  border-color: #9b7bff;
  color: #9b7bff;
}
#rerunBtn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

/* ============================================================
   Historical Similar Incidents Feature
   ============================================================ */
.similar-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  margin-top: 25px;
  display: none;
  animation: expand 0.35s cubic-bezier(.19,1,.22,1);
}
.similar-panel.show {
  display: block;
}
.similar-panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}
.similar-panel-head h2 {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13.5px;
  font-weight: 600;
  margin: 0;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: .08em;
}
.similar-empty {
  font-size: 12px;
  color: var(--text-dim);
  font-style: italic;
  padding: 10px 0;
}
.similar-row {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 10px;
  overflow: hidden;
  transition: border-color 0.2s;
}
.similar-row:last-child { margin-bottom: 0; }
.similar-row:hover { border-color: rgba(255,255,255,0.15); }
.similar-row-header {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
}
.similar-row-title {
  flex: 1;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.similar-row-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}
.similar-date {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text-dim);
}
.similar-score {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid;
}
.similar-score.high { color: var(--green); border-color: rgba(46,204,113,0.35); background: rgba(46,204,113,0.07); }
.similar-score.med { color: var(--amber); border-color: rgba(243,156,18,0.35); background: rgba(243,156,18,0.07); }
.similar-score.low { color: var(--red); border-color: rgba(255,63,52,0.35); background: rgba(255,63,52,0.07); }

.similar-reasoning {
  padding: 0 14px 10px;
  font-size: 11.5px;
  color: var(--text-dim);
  font-style: italic;
  display: block;
}

.similar-row-body {
  padding: 0 14px 14px;
  display: none;
  border-top: 1px solid rgba(255,255,255,0.04);
  margin-top: 5px;
  padding-top: 10px;
}
.similar-row.expanded .similar-row-body { display: block; }
.similar-details-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 4px;
  margin-top: 8px;
}
.similar-details-text {
  font-size: 12px;
  color: #cddce0;
  line-height: 1.5;
  background: rgba(0,0,0,0.2);
  padding: 8px 10px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.02);
}
