/* ─── QUANTITATIVE EASING SIMULATOR ─── */

.qe-sim-page {
    --qe-blue: #2E5FC4;
    --qe-gold: #B07D1A;
    --qe-teal: #00949C;
    --qe-none: #7A8A9A;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
}

.qe-sim-page h1 {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    color: var(--navy-ink);
    margin: 0 0 10px;
    font-size: clamp(1.5rem, 3vw, 2rem);
    letter-spacing: -.01em;
}

.qe-sim-page .sub {
    color: var(--text-dim);
    margin-bottom: 20px;
    line-height: 1.6;
    max-width: 78ch;
}

.qe-sim-page .panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(11, 29, 58, 0.06);
    margin-bottom: 16px;
    min-width: 0;
}

.qe-sim-page .panel h2 {
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin: 0 0 14px;
}

.qe-sim-page .footer-note {
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.55;
    margin-top: 12px;
}

/* ─── Controls ─── */
.qe-sim-page .qe-policy-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.qe-sim-page .qe-policy-head h2 { margin: 0; }
.qe-sim-page .qe-scenario { min-width: 240px; }

.qe-sim-page .qe-controls {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px 18px;
}

.qe-sim-page .field label,
.qe-sim-page .qe-speed label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-dim);
    letter-spacing: 1.1px;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.qe-sim-page .qe-val {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

.qe-sim-page .qe-val span:first-child { color: var(--navy-ink); font-weight: 700; }

.qe-sim-page input[type="range"] {
    width: 100%;
    accent-color: var(--gold);
}

.qe-sim-page select {
    width: 100%;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 9px 11px;
    outline: none;
}

.qe-sim-page select:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-glow);
}

/* ─── Player ─── */
.qe-sim-page .qe-player {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.qe-sim-page .qe-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

.qe-sim-page button {
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .3px;
    padding: 10px 18px;
    border-radius: 999px;
    border: 1px solid var(--gold);
    background: var(--gold);
    color: #fff;
    cursor: pointer;
    transition: background .2s, color .2s, border-color .2s;
}

.qe-sim-page button:hover { background: var(--gold-dim); border-color: var(--gold-dim); }
.qe-sim-page #qePlayBtn { min-width: 92px; }

.qe-sim-page button.ghost {
    background: var(--surface);
    color: var(--text-dim);
    border-color: var(--border);
}

.qe-sim-page button.ghost:hover { background: var(--surface-raised); color: var(--navy-ink); }

.qe-sim-page .qe-speed {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-muted);
}

.qe-sim-page .qe-speed label { margin: 0; }
.qe-sim-page .qe-speed input { width: 120px; }

.qe-sim-page .qe-timebar {
    height: 4px;
    border-radius: 999px;
    background: var(--surface-raised);
    margin-bottom: 16px;
    overflow: hidden;
}

.qe-sim-page .qe-timebar > div {
    height: 100%;
    width: 0;
    background: var(--gold);
    border-radius: 999px;
    transition: width .2s linear;
}

/* ─── Phase + stats ─── */
.qe-sim-page .qe-top {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.9fr);
    gap: 16px;
}

.qe-sim-page .qe-phase {
    border-left: 4px solid var(--gold);
}

.qe-sim-page .qe-phase[data-phase="waiting"] { border-left-color: var(--red); }
.qe-sim-page .qe-phase[data-phase="calm"],
.qe-sim-page .qe-phase[data-phase="qtdone"] { border-left-color: var(--green); }

.qe-sim-page .qe-month {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 1.4px;
    text-transform: uppercase;
}

.qe-sim-page .qe-phase h3 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.35rem;
    color: var(--navy-ink);
    margin: 6px 0 8px;
}

.qe-sim-page .qe-phase p {
    color: var(--text-dim);
    line-height: 1.6;
    margin: 0;
    font-size: 14px;
}

.qe-sim-page .qe-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.qe-sim-page .qe-stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 14px;
}

.qe-sim-page .qe-stat .k {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-dim);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.qe-sim-page .qe-hint { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--text-muted); }

.qe-sim-page .qe-stat .v {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--navy-ink);
    font-variant-numeric: tabular-nums;
    margin: 2px 0;
}

.qe-sim-page .qe-delta { font-size: 12px; color: var(--text-muted); }
.qe-sim-page .qe-delta.good { color: var(--green); }
.qe-sim-page .qe-delta.bad { color: var(--red); }

/* ─── Flow diagram + balance sheet ─── */
.qe-sim-page .qe-mid {
    display: grid;
    grid-template-columns: minmax(0, 1.9fr) minmax(0, 1.1fr);
    gap: 16px;
}

.qe-sim-page .qe-flow svg { display: block; width: 100%; height: auto; }

.qe-sim-page .qe-node rect {
    fill: var(--surface-raised);
    stroke: var(--border-subtle);
    stroke-width: 1;
}

.qe-sim-page .qe-node-fed rect { fill: #0B1D3A; stroke: #0B1D3A; }
.qe-sim-page .qe-node-fed text { fill: #fff; }

.qe-sim-page .qe-node-title {
    font-family: 'DM Sans', sans-serif;
    font-size: 17px;
    font-weight: 700;
    fill: var(--navy-ink);
}

.qe-sim-page .qe-node-value {
    font-family: 'DM Sans', sans-serif;
    font-size: 15px;
    fill: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

.qe-sim-page .qe-node-fed .qe-node-value { fill: #D8E0EC; }

.qe-sim-page .qe-pipe {
    fill: none;
    stroke-linecap: round;
    opacity: .35;
    transition: stroke-width .4s ease, opacity .4s ease;
}

.qe-sim-page .qe-pipe.is-idle { opacity: .15; }

.qe-sim-page .qe-pipe.is-frozen {
    stroke: var(--red);
    stroke-dasharray: 2 10;
    opacity: .7;
}

.qe-sim-page .qe-pipe-label {
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    font-weight: 600;
    fill: var(--text-dim);
}

.qe-sim-page .qe-dot { stroke: #fff; stroke-width: 1.5; }
.qe-sim-page .qe-dot-reserves { fill: var(--qe-teal); }
.qe-sim-page .qe-dot-bonds { fill: var(--qe-gold); }
.qe-sim-page .qe-dot-loans,
.qe-sim-page .qe-dot-invest { fill: var(--qe-blue); }

.qe-sim-page .qe-bs-cols {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.qe-sim-page .qe-bs-head {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 700;
    color: var(--navy-ink);
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 6px;
    margin-bottom: 8px;
}

.qe-sim-page .qe-bs-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2px 10px;
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 8px;
}

.qe-sim-page .qe-bs-row b { color: var(--navy-ink); font-variant-numeric: tabular-nums; }

.qe-sim-page .qe-bs-track {
    grid-column: 1 / -1;
    height: 8px;
    background: var(--surface-raised);
    border-radius: 999px;
    overflow: hidden;
}

.qe-sim-page .qe-bs-bar {
    height: 100%;
    width: 0;
    border-radius: 999px;
    transition: width .3s ease;
}

.qe-sim-page .qe-bs-bar.tsy { background: var(--qe-blue); }
.qe-sim-page .qe-bs-bar.mbs { background: var(--qe-gold); }
.qe-sim-page .qe-bs-bar.reserves { background: var(--qe-teal); }
.qe-sim-page .qe-bs-bar.other { background: var(--qe-none); opacity: .55; }

/* ─── Charts ─── */
.qe-sim-page .qe-charts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px 24px;
}

.qe-sim-page .qe-chart { min-width: 0; }

.qe-sim-page .qe-chart-head h3 {
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: var(--navy-ink);
    margin: 0 0 4px;
}

.qe-sim-page .qe-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.qe-sim-page .qe-legend-item { display: inline-flex; align-items: center; gap: 6px; }

.qe-sim-page .qe-swatch {
    display: inline-block;
    width: 16px;
    height: 0;
    border-top: 2px solid var(--c);
}

.qe-sim-page .qe-swatch.dashed { border-top-style: dashed; }

.qe-sim-page .qe-canvas-wrap { position: relative; }

.qe-sim-page .qe-canvas-wrap canvas {
    display: block;
    width: 100%;
    height: 200px;
    cursor: crosshair;
    touch-action: pan-y;
}

.qe-sim-page .qe-tip {
    position: absolute;
    top: 6px;
    pointer-events: none;
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    box-shadow: 0 6px 18px rgba(11, 29, 58, 0.12);
    padding: 8px 10px;
    font-size: 12px;
    color: var(--text-dim);
    min-width: 170px;
    z-index: 2;
}

.qe-sim-page .qe-tip-date { font-weight: 700; color: var(--navy-ink); margin-bottom: 4px; }

.qe-sim-page .qe-tip-row {
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1.7;
}

.qe-sim-page .qe-tip-row b { margin-left: auto; padding-left: 12px; color: var(--navy-ink); font-variant-numeric: tabular-nums; }
.qe-sim-page .qe-tip-row.total { border-top: 1px solid var(--border-subtle); margin-top: 2px; }

/* ─── Details: table + info ─── */
.qe-sim-page details.qe-info {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    margin-bottom: 16px;
}

.qe-sim-page details.qe-info > summary {
    cursor: pointer;
    padding: 16px 20px;
    font-weight: 700;
    color: var(--navy-ink);
    font-size: 14px;
}

.qe-sim-page .qe-info-content,
.qe-sim-page .qe-table-scroll { padding: 0 20px 18px; }

.qe-sim-page .qe-table-scroll { overflow-x: auto; }

.qe-sim-page table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.qe-sim-page th,
.qe-sim-page td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--border-subtle);
    text-align: left;
}

.qe-sim-page th {
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: .8px;
    text-transform: uppercase;
}

.qe-sim-page .right { text-align: right; }

.qe-sim-page .qe-info-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.qe-sim-page .qe-info-tile {
    background: var(--surface-raised);
    border-radius: 12px;
    padding: 14px;
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--text-dim);
}

.qe-sim-page .qe-info-tile strong {
    display: block;
    color: var(--navy-ink);
    font-size: 14px;
    margin-bottom: 4px;
}

/* ─── Responsive ─── */
@media (max-width: 1100px) {
    .qe-sim-page .qe-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .qe-sim-page .qe-top,
    .qe-sim-page .qe-mid { grid-template-columns: 1fr; }
    .qe-sim-page .qe-info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .qe-sim-page .qe-bs-cols { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 700px) {
    .qe-sim-page .panel { padding: 16px; }
    .qe-sim-page .qe-controls,
    .qe-sim-page .qe-charts,
    .qe-sim-page .qe-info-grid,
    .qe-sim-page .qe-bs-cols { grid-template-columns: 1fr; }
    .qe-sim-page .qe-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .qe-sim-page .qe-stat .v { font-size: 1.3rem; }
    .qe-sim-page .qe-scenario { min-width: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .qe-sim-page .qe-pipe,
    .qe-sim-page .qe-bs-bar,
    .qe-sim-page .qe-timebar > div { transition: none; }
}
