:root {
    color-scheme: light;
    --bg: #f4f1ec;
    --panel: #fffaf2;
    --panel-2: #ffffff;
    --ink: #172024;
    --muted: #637075;
    --line: #d8d1c6;
    --line-strong: #b9afa2;
    --accent: #116466;
    --accent-2: #2e7d5f;
    --warning: #b86b00;
    --danger: #a83b35;
    --success: #2d7a46;
    --code-bg: #11191b;
    --shadow: 0 18px 42px rgba(42, 35, 28, 0.12);
    --sidebar-width: 248px;
    --main-gutter: 84px;
    --mobile-header-height: 56px;
    --z-mobile-header: 1060;
    --z-sidebar: 1050;
    --z-sidebar-backdrop: 1040;
}

* {
    box-sizing: border-box;
}

html {
    scroll-padding-top: calc(var(--mobile-header-height) + env(safe-area-inset-top, 0px));
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(90deg, #243136 0 var(--sidebar-width), transparent var(--sidebar-width)),
        radial-gradient(circle at 72% 8%, rgba(17, 100, 102, 0.08), transparent 28rem),
        var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.app-mobile-header {
    display: none;
}

.app-sidebar-backdrop {
    display: none;
}

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    padding: 24px 18px;
    padding-left: calc(18px + env(safe-area-inset-left, 0px));
    color: #eef7f3;
    z-index: var(--z-sidebar);
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    text-decoration: none;
    margin-bottom: 34px;
}

.app-brand:hover {
    text-decoration: none;
}

.app-brand-mark {
    width: 42px;
    height: 42px;
    display: block;
    flex-shrink: 0;
    border-radius: 8px;
}

.app-brand-name,
.app-brand-subtitle {
    display: block;
}

.app-brand-name {
    font-weight: 800;
    font-size: 20px;
}

.app-brand-subtitle {
    color: rgba(238, 247, 243, 0.66);
    font-size: 12px;
    margin-top: 1px;
}

.app-nav {
    display: grid;
    gap: 6px;
}

.nav-link {
    display: block;
    color: rgba(238, 247, 243, 0.82);
    border-radius: 7px;
    padding: 10px 12px;
    font-weight: 650;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.09);
    color: #fff;
    text-decoration: none;
}

.app-logout {
    margin-top: auto;
    color: #ffd8d4;
}

.app-main {
    margin-left: var(--sidebar-width);
    padding: 34px 42px 56px;
}

.container {
    width: min(1440px, calc(100vw - var(--sidebar-width) - var(--main-gutter)));
    max-width: 100%;
}

.app-main img:not(.app-brand-mark):not(.login-brand-mark) {
    max-width: 100%;
    height: auto;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    margin: 0 0 14px;
    line-height: 1.16;
    letter-spacing: 0;
}

.h3,
h1 {
    font-size: 30px;
    font-weight: 780;
}

.h4 {
    font-size: 24px;
}

.h5,
h2 {
    font-size: 19px;
    font-weight: 760;
}

.h6,
h3 {
    font-size: 15px;
    font-weight: 780;
}

p {
    margin: 0 0 14px;
}

hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 28px 0;
}

code {
    padding: 2px 5px;
    border-radius: 5px;
    background: rgba(17, 32, 36, 0.08);
    color: #15353a;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 0.92em;
}

pre {
    margin: 0;
    overflow: auto;
    border-radius: 7px;
    border: 1px solid var(--line);
    background: #fffdf8;
    color: #182326;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.bg-dark {
    background: var(--code-bg) !important;
}

.bg-light,
.bg-white {
    background: var(--panel-2) !important;
}

.text-light {
    color: #f3f7f4 !important;
}

.text-muted {
    color: var(--muted) !important;
}

.text-danger {
    color: var(--danger) !important;
}

.text-success {
    color: var(--success) !important;
}

.text-uppercase {
    text-transform: uppercase;
}

.fst-italic {
    font-style: italic;
}

.fw-medium {
    font-weight: 700;
}

.fw-semibold {
    font-weight: 760;
}

.small {
    font-size: 13px;
}

.font-monospace {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 12px 16px;
    background: #f0e8da;
    border-bottom: 1px solid var(--line);
    font-weight: 760;
}

.card-body {
    padding: 17px;
}

.alert {
    border: 1px solid var(--line);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    padding: 11px 13px;
    margin-bottom: 18px;
    background: #fffdf8;
}

.alert-danger {
    border-left-color: var(--danger);
    background: #fff3f1;
}

.alert-warning {
    border-left-color: var(--warning);
    background: #fff7e8;
}

.alert-success {
    border-left-color: var(--success);
    background: #edf8ef;
}

.alert-info,
.alert-secondary {
    border-left-color: var(--accent);
}

.btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 7px 13px;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    background: #fffaf2;
    color: var(--ink);
    cursor: pointer;
    font-weight: 760;
    font-size: 14px;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(23, 32, 36, 0.12);
    text-decoration: none;
}

.btn:disabled,
.btn.disabled {
    opacity: 0.48;
    cursor: not-allowed;
}

.btn-sm {
    min-height: 30px;
    padding: 5px 10px;
    font-size: 12px;
}

.btn-primary,
.btn-success {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.btn-danger {
    border-color: var(--danger);
    background: var(--danger);
    color: #fff;
}

.btn-warning {
    border-color: #d99a29;
    background: #d99a29;
    color: #21170a;
}

.btn-outline-primary,
.btn-outline-secondary,
.btn-outline-dark {
    background: #fffdf8;
    color: var(--accent);
    border-color: rgba(17, 100, 102, 0.42);
}

.btn-outline-danger {
    background: #fffdf8;
    color: var(--danger);
    border-color: rgba(168, 59, 53, 0.42);
}

.btn-outline-warning {
    background: #fffdf8;
    color: var(--warning);
    border-color: rgba(184, 107, 0, 0.44);
}

.btn-close {
    width: 32px;
    min-height: 32px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--muted);
}

.btn-close::before {
    content: "x";
    font-size: 22px;
}

.form-control,
.form-select,
textarea,
select,
input[type="text"],
input[type="password"],
input[type="number"] {
    width: 100%;
    min-height: 38px;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    background: #fffdf8;
    color: var(--ink);
    padding: 8px 10px;
    font: inherit;
}

textarea.form-control,
textarea {
    min-height: 110px;
    resize: vertical;
}

.form-control:focus,
.form-select:focus,
textarea:focus,
select:focus,
input:focus {
    outline: 2px solid rgba(17, 100, 102, 0.22);
    border-color: var(--accent);
}

.form-label {
    display: block;
    margin-bottom: 6px;
    color: #26363a;
    font-weight: 760;
    font-size: 13px;
}

.form-text {
    color: var(--muted);
    font-size: 12px;
    margin-top: 5px;
}

.field-tip {
    display: inline-block;
    position: relative;
    margin-left: 0.35rem;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    border: 1px solid var(--line-strong);
    color: var(--muted);
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1rem;
    text-align: center;
    cursor: help;
    vertical-align: text-top;
}

.field-tip:hover,
.field-tip:focus-visible {
    color: var(--accent);
    border-color: var(--accent);
    outline: none;
}

.field-tip::before,
.field-tip::after {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 20;
}

.field-tip::after {
    content: attr(data-tip);
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: 280px;
    padding: 0.5rem 0.65rem;
    border-radius: 6px;
    background: var(--code-bg);
    color: #eef7f3;
    font-size: 0.78rem;
    font-weight: 400;
    line-height: 1.35;
    text-align: left;
    white-space: normal;
    box-shadow: var(--shadow);
}

.field-tip::before {
    content: '';
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--code-bg);
}

.field-tip:hover::before,
.field-tip:hover::after,
.field-tip:focus-visible::before,
.field-tip:focus-visible::after {
    opacity: 1;
}

.limits-diagram-panels {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.limits-diagram-basis {
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--panel-2);
    font-size: 12px;
    line-height: 1.45;
}

.limits-diagram-basis-title {
    margin: 0;
    color: #26363a;
}

.limits-diagram-basis-list {
    margin: 6px 0 0 0;
    padding-left: 1.2rem;
    color: var(--muted);
}

.limits-chip-runs-detail {
    white-space: normal;
    display: inline-block;
    max-width: 11rem;
    text-align: center;
}

.limits-diagram-panel-title {
    margin-bottom: 10px;
    color: #26363a;
}

.limits-cycle-flow,
.limits-pass-row,
.limits-tree-children {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 6px;
}

.limits-phase-wrap {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.limits-chip-runs {
    font-size: 10px;
    color: var(--muted);
    line-height: 1.2;
}

.limits-chip-llm {
    border-color: rgba(17, 100, 102, 0.45);
    background: rgba(17, 100, 102, 0.1);
}

.limits-panel-stat {
    font-size: 11px;
    color: var(--muted);
    line-height: 1.45;
}

.limits-panel-stat-total {
    font-weight: 600;
    color: #26363a;
}

.limits-tree-count {
    font-weight: 400;
    color: var(--muted);
    font-size: 11px;
}

.limits-chip {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: var(--panel-2);
    font-size: 12px;
    white-space: nowrap;
}

.limits-chip-pass {
    border-color: rgba(17, 100, 102, 0.35);
    background: rgba(17, 100, 102, 0.08);
}

.limits-chip-final {
    border-color: var(--accent);
    background: rgba(17, 100, 102, 0.14);
    font-weight: 600;
}

.limits-chip-child {
    font-size: 11px;
    padding: 3px 8px;
}

.limits-chip-more {
    font-size: 11px;
    color: var(--muted);
    border-style: dashed;
}

.limits-arrow {
    color: var(--muted);
    font-size: 12px;
}

.limits-delegation-tree {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.limits-tree-layer {
    margin-left: calc(var(--layer-depth, 0) * 14px);
}

.limits-tree-node {
    font-weight: 600;
    font-size: 12px;
    margin-bottom: 4px;
}

.limits-tree-node-leaf {
    color: var(--muted);
}

.limits-tree-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(168, 59, 53, 0.12);
    color: var(--danger);
    font-size: 10px;
    font-weight: 600;
}

.limits-diagram-legend {
    padding-top: 12px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
}

.form-check {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin-bottom: 9px;
}

.form-check-input {
    margin-top: 3px;
}

.btn-group {
    display: inline-flex;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    overflow: hidden;
}

.btn-check {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.btn-check + .btn {
    border: 0;
    border-radius: 0;
}

.btn-check:checked + .btn {
    background: var(--accent);
    color: #fff;
}

.btn-check#env_live:checked + .btn {
    background: var(--danger);
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -8px;
}

.row > * {
    padding: 0 8px;
}

.col-auto {
    flex: 0 0 auto;
}

.justify-content-center {
    justify-content: center;
}

.align-items-center {
    align-items: center;
}

.align-items-end {
    align-items: flex-end;
}

.d-flex {
    display: flex;
}

.d-block {
    display: block;
}

.d-table-cell {
    display: table-cell !important;
}

.flex-column {
    flex-direction: column !important;
}

.flex-wrap {
    flex-wrap: wrap;
}

.justify-content-between {
    justify-content: space-between;
}

.gap-2 {
    gap: 8px;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-2);
    box-shadow: 0 10px 26px rgba(42, 35, 28, 0.08);
}

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

.table th,
.table td {
    padding: 10px 11px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

.table th {
    background: #eee5d7;
    color: #344348;
    font-size: 12px;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0;
}

.table tr:last-child td {
    border-bottom: 0;
}

.table-striped tbody tr:nth-child(4n + 1),
.table-striped tbody tr:nth-child(4n + 2) {
    background: rgba(17, 100, 102, 0.025);
}

.table-secondary {
    background: #f0eee8;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 3px 8px;
    border-radius: 99px;
    background: #e7ece8;
    color: #243136;
    border: 1px solid rgba(36, 49, 54, 0.12);
    font-size: 12px;
    font-weight: 780;
}

.graph-confidence-authoritative { background: #d8f0e4; color: #1f4d36; }
.graph-confidence-provisional { background: #eef2d8; color: #4d4a1f; }
.graph-confidence-conflicted { background: #f5e0e0; color: #6b1f1f; }
.graph-leg-stop_loss td:nth-child(2),
.graph-leg-take_profit td:nth-child(2) { padding-left: 1.25rem; }
.graph-topology-row td { background: #f8f9fb; border-top: none; }
.graph-topology-details summary { cursor: pointer; font-weight: 600; }
.graph-topology-section { margin-top: 0.5rem; }
.graph-topology-section ul { padding-left: 1.25rem; }

.bg-primary,
.bg-info {
    background: rgba(17, 100, 102, 0.16) !important;
    color: #0e5051 !important;
}

.bg-secondary,
.bg-light {
    background: #ece6da !important;
    color: #3d4649 !important;
}

.bg-success {
    background: rgba(45, 122, 70, 0.16) !important;
    color: #236039 !important;
}

.bg-warning {
    background: rgba(217, 154, 41, 0.22) !important;
    color: #744300 !important;
}

.bg-danger {
    background: rgba(168, 59, 53, 0.16) !important;
    color: #7e2823 !important;
}

.border {
    border: 1px solid var(--line) !important;
}

.border-secondary {
    border-color: var(--line-strong) !important;
}

.rounded {
    border-radius: 7px !important;
}

.collapse {
    display: none;
}

.d-none {
    display: none !important;
}

.collapse.show {
    display: block;
}

tr.collapse.show {
    display: table-row;
}

.accordion-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    overflow: hidden;
}

.accordion-button {
    width: 100%;
    border: 0;
    background: #f0e8da;
    color: var(--ink);
    text-align: left;
    font-weight: 780;
}

.accordion-body {
    padding: 16px;
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 5000;
    background: rgba(18, 26, 28, 0.56);
    padding: 1.5rem;
    box-sizing: border-box;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
}

.modal-dialog {
    width: 560px;
    max-width: 100%;
    margin: 0;
    flex-shrink: 0;
}

.modal-content {
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 28px 70px rgba(0, 0, 0, 0.32);
    overflow: hidden;
}

.modal-header,
.modal-body {
    padding: 18px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 18px;
    border-top: 1px solid var(--line);
    flex-shrink: 0;
}

.modal-dialog-scrollable {
    width: min(920px, 100%);
}

.modal-dialog-scrollable .modal-content {
    max-height: min(85vh, calc(100dvh - 3rem));
    display: flex;
    flex-direction: column;
}

.modal-dialog-scrollable .modal-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
    min-height: 0;
}

.modal-open {
    overflow: hidden;
}

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 4px !important; }
.mb-2 { margin-bottom: 8px !important; }
.mb-3 { margin-bottom: 14px !important; }
.mb-4 { margin-bottom: 24px !important; }
.mt-1 { margin-top: 4px !important; }
.mt-2 { margin-top: 8px !important; }
.mt-4 { margin-top: 24px !important; }
.mt-5 { margin-top: 42px !important; }
.ms-2 { margin-left: 8px !important; }
.me-1 { margin-right: 4px !important; }
.p-0 { padding: 0 !important; }
.p-2 { padding: 8px !important; }
.p-3 { padding: 14px !important; }
.px-2 { padding-left: 8px !important; padding-right: 8px !important; }
.px-3 { padding-left: 14px !important; padding-right: 14px !important; }
.py-2 { padding-top: 8px !important; padding-bottom: 8px !important; }
.pb-5 { padding-bottom: 48px !important; }
.w-100 { width: 100% !important; }
.text-nowrap { white-space: nowrap; }
.user-select-all { user-select: all; }

.dashboard-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.dashboard-subtitle {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.dashboard-date-input {
    width: auto;
    min-width: 11rem;
    max-width: 100%;
}

.ops-compact {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 253, 248, 0.78);
    box-shadow: 0 8px 22px rgba(42, 35, 28, 0.07);
}

.ops-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.ops-segments {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    overflow: hidden;
    background: #f5eee2;
}

.mode-option {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 6px 11px;
    border-right: 1px solid var(--line-strong);
    color: #334449;
    cursor: pointer;
    font-size: 12px;
    font-weight: 780;
    white-space: nowrap;
}

.mode-option:last-child {
    border-right: 0;
}

.btn-check:checked + .mode-option {
    background: var(--accent);
    color: #fff;
}

.btn-check:checked + .mode-option-danger {
    background: var(--danger);
    color: #fff;
}

.operator-actions-panel {
    border: 1px solid rgba(184, 107, 0, 0.35);
    border-left: 4px solid var(--warning);
    border-radius: 8px;
    background: #fff8ef;
    padding: 12px;
}

.operator-actions-table tbody tr.operator-action-open {
    background: rgba(184, 107, 0, 0.06);
}

.operator-actions-detail-panel {
    border-left: 4px solid var(--warning);
}

.operator-action-instructions summary {
    cursor: pointer;
    color: var(--ink);
}

.operator-action-session-link {
    font-weight: 600;
    text-decoration: none;
}

.operator-action-session-link:hover {
    text-decoration: underline;
}

.sessions-shell {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 250, 242, 0.78);
    box-shadow: var(--shadow);
    overflow: visible;
}

.session-workspace {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    min-height: 680px;
}

.session-rail {
    overflow: visible;
    padding: 10px;
    background: #ebe4d8;
    border-right: 1px solid var(--line);
}

.session-list-item {
    width: 100%;
    display: block;
    margin: 0 0 8px;
    padding: 12px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: rgba(255, 253, 248, 0.72);
    color: var(--ink);
    text-align: left;
    cursor: pointer;
}

.session-list-item:hover {
    border-color: rgba(17, 100, 102, 0.28);
    background: #fffdf8;
}

.session-list-item.is-selected {
    border-color: rgba(17, 100, 102, 0.72);
    background: #fffdf8;
    box-shadow: inset 3px 0 0 var(--accent);
}

.session-list-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.session-list-top > span:last-child,
.session-list-meta {
    color: var(--muted);
    font-size: 12px;
}

.session-list-item strong {
    display: block;
    font-size: 14px;
    margin-bottom: 6px;
}

.session-list-meta {
    display: block;
}

.session-list-when {
    display: block;
    line-height: 1.35;
    margin-bottom: 6px;
}

.session-list-time {
    display: block;
}

.session-list-title {
    font-size: 14px;
    line-height: 1.3;
}

.session-detail {
    min-width: 0;
    padding: 18px;
    background: #f7f4ee;
}

.session-detail-header {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    margin-bottom: 16px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fffdf8;
}

.session-eyebrow {
    color: var(--muted);
    font-size: 12px;
    font-weight: 760;
    text-transform: uppercase;
}

.session-detail-header h3 {
    margin: 4px 0 9px;
    font-size: 22px;
}

.session-detail-badges,
.session-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.session-actions {
    justify-content: flex-end;
    max-width: 430px;
}

.session-detail-grid {
    display: grid;
    grid-template-columns: minmax(260px, 0.9fr) minmax(0, 1.35fr);
    gap: 12px;
    align-items: start;
}

.detail-panel {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fffdf8;
    overflow: hidden;
}

.detail-panel header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 42px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    background: #f0e8da;
}

.detail-panel header span {
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    color: #334449;
}

.detail-panel header small {
    color: var(--muted);
}

.panel-header-tools {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    min-height: 28px;
    padding: 0;
    border: 1px solid rgba(17, 100, 102, 0.35);
    border-radius: 7px;
    background: #fffdf8;
    color: var(--accent);
    cursor: pointer;
}

.icon-button:hover {
    background: #e9f4f1;
}

.icon-button:disabled {
    opacity: 0.42;
    cursor: default;
}

.icon-button svg {
    width: 17px;
    height: 17px;
    stroke: currentColor;
    stroke-width: 1.8;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.detail-panel-body {
    padding: 12px;
    max-height: 470px;
    overflow: auto;
}

.detail-panel-analysis .detail-panel-body {
    max-height: 620px;
}

.detail-panel-analysis {
    grid-row: span 2;
}

.detail-panel-execution .detail-panel-body {
    max-height: 360px;
}

.detail-panel-activity {
    grid-column: 1 / -1;
}

.detail-panel-activity .detail-panel-body {
    max-height: 240px;
}

.dashboard-json {
    margin: 0;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fbf7ef;
    color: #162326;
    font-size: 12px;
    line-height: 1.45;
}

.dashboard-copy {
    max-height: 210px;
    overflow: auto;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fbf7ef;
    white-space: pre-wrap;
}

.panel-label {
    margin: 14px 0 7px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.kv-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 4px;
}

.kv-grid div,
.analysis-summary div {
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fbf7ef;
}

.kv-grid span,
.analysis-summary span {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.kv-grid strong,
.analysis-summary strong {
    display: block;
    font-size: 14px;
}

.analysis-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.analysis-summary em {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-style: normal;
    margin-top: 2px;
}

.candidate-picks {
    display: grid;
    gap: 8px;
}

.candidate-pick {
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fbf7ef;
}

.candidate-pick-head {
    display: grid;
    grid-template-columns: minmax(64px, 1fr) auto auto;
    gap: 8px;
    align-items: center;
    margin-bottom: 6px;
}

.candidate-pick-head strong {
    font-size: 14px;
}

.candidate-pick-head span,
.candidate-pick-head em {
    color: var(--muted);
    font-size: 12px;
    font-style: normal;
}

.candidate-pick p {
    margin: 0;
    color: #223237;
    font-size: 13px;
}

.candidate-pick small {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

.candidate-price {
    margin-top: 8px;
}

.candidate-price .dashboard-json {
    max-height: 7rem !important;
}

.candidate-pick-more {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.activity-list {
    display: grid;
    gap: 8px;
}

.activity-line {
    display: grid;
    grid-template-columns: 172px 220px minmax(0, 1fr);
    gap: 10px;
    align-items: baseline;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fbf7ef;
}

.activity-line span {
    color: var(--muted);
    font-size: 12px;
}

.activity-line strong {
    font-size: 12px;
}

.activity-line p {
    margin: 0;
    color: #26363a;
    font-size: 13px;
}

.task-execution-kind {
    display: block;
    color: #3d4f54;
    font-size: 12px;
}

.task-ib-queue-text {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.task-error-text {
    display: block;
    margin-top: 2px;
    color: var(--danger);
    font-size: 12px;
}

.message-row {
    display: block;
}

.message-row-summary {
    cursor: pointer;
    list-style: none;
}

.message-row-summary::-webkit-details-marker {
    display: none;
}

.message-row-summary::marker {
    content: "";
}

.message-row[open] .message-row-summary {
    border-bottom-right-radius: 0;
    border-bottom-left-radius: 0;
    background: #fffdf8;
}

.message-payload {
    max-height: 420px;
    margin: 0;
    padding: 12px;
    overflow: auto;
    border: 1px solid var(--line);
    border-top: 0;
    border-radius: 0 0 7px 7px;
    background: #1f2a2e;
    color: #f7f4ee;
    font-size: 12px;
    line-height: 1.45;
    white-space: pre-wrap;
}

.workflow-tree {
    display: grid;
    gap: 6px;
}

.workflow-node {
    display: grid;
    grid-template-columns: 16px minmax(0, 1fr) 150px;
    gap: 10px;
    align-items: center;
    margin-left: calc(var(--depth, 0) * 18px);
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fbf7ef;
}

.workflow-state {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 2px solid #839196;
    background: #fffaf2;
}

.workflow-state.is-completed {
    border-color: #2f7d55;
    background: #2f7d55;
}

.workflow-state.is-running {
    border-color: #0b6f78;
    background: #d9fbff;
    box-shadow: 0 0 0 3px rgba(11, 111, 120, 0.13);
}

.workflow-state.is-waiting {
    border-color: #a76b00;
    background: #ffe3a8;
}

.workflow-state.is-failed {
    border-color: #a32121;
    background: #a32121;
}

.workflow-state.is-cancelled,
.workflow-state.is-skipped {
    border-color: #7b8387;
    background: #d8dde0;
}

.workflow-node-main {
    min-width: 0;
}

.workflow-node-main div {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
}

.workflow-node-main strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #18282c;
    font-size: 13px;
}

.workflow-node-main code {
    color: var(--muted);
    font-size: 11px;
}

.workflow-node-main p {
    margin: 2px 0 0;
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.workflow-node-main .workflow-detail {
    color: #163f45;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 12px;
}

.workflow-node time {
    color: var(--muted);
    font-size: 12px;
    text-align: right;
}

.workflow-map-modal {
    padding: 5vh 24px;
}

.workflow-map-dialog {
    width: min(1500px, calc(100vw - 300px));
}

.workflow-map-modal .modal-content {
    max-height: 90vh;
}

.workflow-map-modal .modal-header h3 {
    margin: 0;
    font-size: 18px;
}

.workflow-map-modal .modal-header p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.workflow-map-body {
    max-height: calc(90vh - 88px);
    overflow: auto;
    background: #fbf7ef;
}

.workflow-map-body--graph {
    overflow: hidden;
    padding: 0;
}

.workflow-graph-host {
    width: 100%;
    height: calc(90vh - 88px);
    min-height: 320px;
    background: #fbf7ef;
}

.workflow-graph-host svg {
    display: block;
}

.workflow-modal .modal-dialog.workflow-modal-dialog {
    width: min(96vw, 1600px);
    max-width: min(96vw, 1600px);
    margin-left: auto;
    margin-right: auto;
}

.workflow-modal .modal-content {
    height: min(92vh, 980px);
}

.workflow-modal-body {
    height: calc(min(92vh, 980px) - 58px);
    overflow: hidden;
    background: #fafafa;
}

.workflow-modal-graph {
    width: 100%;
    height: 100%;
    min-height: 680px;
    background: #fafafa;
}

.workflow-map {
    min-width: max-content;
    padding: 8px 8px 20px;
}

.workflow-map ul {
    display: flex;
    justify-content: center;
    gap: 0;
    margin: 0;
    padding: 24px 0 0;
    position: relative;
}

.workflow-map > ul {
    padding-top: 0;
}

.workflow-map li {
    list-style: none;
    margin: 0;
    padding: 24px 10px 0;
    position: relative;
    text-align: center;
}

.workflow-map > ul > li {
    padding-top: 0;
}

.workflow-map li::before,
.workflow-map li::after {
    content: "";
    position: absolute;
    top: 0;
    width: 50%;
    height: 24px;
    border-top: 1px solid var(--line-strong);
}

.workflow-map li::before {
    right: 50%;
}

.workflow-map li::after {
    left: 50%;
    border-left: 1px solid var(--line-strong);
}

.workflow-map li:only-child::before,
.workflow-map li:only-child::after,
.workflow-map > ul > li::before,
.workflow-map > ul > li::after {
    display: none;
}

.workflow-map li:first-child::before,
.workflow-map li:last-child::after {
    border-top: 0;
}

.workflow-map .workflow-map-node > ul::before,
.workflow-map .workflow-map-node > .workflow-map-branch > ul::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    height: 24px;
    border-left: 1px solid var(--line-strong);
}

.workflow-map-branch {
    position: relative;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.workflow-map-branch > ul {
    display: flex;
    justify-content: center;
    gap: 0;
    margin: 0;
    padding: 24px 0 0;
    position: relative;
}

.workflow-map-branch-summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 6px auto 0;
    padding: 4px 12px;
    font-size: 11px;
    color: #3d4f54;
    border: 1px dashed var(--line-strong);
    border-radius: 999px;
    background: #fffdf8;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.workflow-map-branch-summary::-webkit-details-marker {
    display: none;
}

.workflow-map-branch-summary::marker {
    content: "";
}

.workflow-branch-chevron {
    display: inline-block;
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-left: 7px solid var(--muted);
    transform: translateY(1px);
    transition: transform 0.15s ease;
}

details.workflow-map-branch[open] > .workflow-map-branch-summary .workflow-branch-chevron,
details.workflow-tree-branch[open] > .workflow-tree-branch-summary .workflow-branch-chevron {
    transform: translateY(1px) rotate(90deg);
}

.workflow-branch-label-open {
    display: none;
}

details.workflow-map-branch[open] > .workflow-map-branch-summary .workflow-branch-label-collapsed {
    display: none;
}

details.workflow-map-branch[open] > .workflow-map-branch-summary .workflow-branch-label-open {
    display: inline;
}

.workflow-map-branch-always-open {
    position: relative;
    text-align: center;
}

/* Activity panel: collapsible completed subtrees */
.workflow-tree-nested {
    gap: 4px;
}

.workflow-tree-branch {
    margin-left: calc(26px + var(--branch-depth, 0) * 18px);
    margin-bottom: 2px;
}

.workflow-tree-branch-summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    font-size: 11px;
    color: #3d4f54;
    border: 1px dashed var(--line-strong);
    border-radius: 999px;
    background: #fffdf8;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.workflow-tree-branch-summary::-webkit-details-marker {
    display: none;
}

.workflow-tree-branch-summary::marker {
    content: "";
}

details.workflow-tree-branch[open] > .workflow-tree-branch-summary .workflow-branch-label-collapsed {
    display: none;
}

details.workflow-tree-branch[open] > .workflow-tree-branch-summary .workflow-branch-label-open {
    display: inline;
}

.workflow-tree-branch-children {
    margin-left: calc(26px + var(--branch-depth, 0) * 18px);
    padding: 2px 0 4px 10px;
    border-left: 1px solid var(--line);
}

.workflow-tree-branch-children--nested-fold {
    margin-top: 4px;
}

.workflow-id-chip {
    display: inline-block;
    min-width: 1.25rem;
    text-align: center;
    font-size: 11px;
    color: var(--muted);
}

.workflow-id-chip--synthetic {
    font-weight: 700;
}

/* Activity tree: vertical branch when many siblings (see dashboard.php) */
.workflow-activity-vertical {
    list-style: none;
    margin: 4px 0 6px 0;
    padding: 0 0 0 14px;
    border-left: 2px solid var(--line-strong);
}

.workflow-activity-vertical-item {
    margin: 0 0 8px 0;
    padding: 0;
    position: relative;
}

.workflow-activity-vertical-item::before {
    content: "";
    position: absolute;
    left: -14px;
    top: 18px;
    width: 12px;
    border-top: 1px solid var(--line-strong);
}

.workflow-activity-vertical .workflow-tree-branch,
.workflow-activity-vertical .workflow-tree-branch-children {
    margin-left: 0;
}

.workflow-map-card {
    display: inline-grid;
    grid-template-columns: 16px minmax(150px, 220px);
    gap: 9px;
    align-items: start;
    min-height: 58px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fffdf8;
    box-shadow: 0 6px 16px rgba(42, 35, 28, 0.06);
    text-align: left;
}

.workflow-map-card strong {
    display: block;
    overflow: hidden;
    color: #18282c;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.workflow-map-card code {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 10px;
}

.workflow-map-card p {
    margin: 4px 0 0;
    overflow: hidden;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.workflow-map-card .workflow-map-detail {
    color: #163f45;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

/* Settings: hash targets stay visible below sticky nav / headers */
[id^="settings-"],
#ib-gateway-auth-status {
    scroll-margin-top: 5.5rem;
}

.settings-field-narrow {
    width: auto;
    min-width: 9rem;
    max-width: 14rem;
}

.settings-field-num {
    width: 5rem;
}

.settings-field-url {
    width: auto;
    min-width: 11rem;
    max-width: 20rem;
}

.settings-field-key {
    width: auto;
    min-width: 9rem;
    max-width: 14rem;
}

.settings-field-group .form-control-sm,
.settings-field-group .form-select-sm {
    height: 2rem;
    min-height: 2rem;
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
    line-height: 1.25;
}

.settings-field-group-check .form-check {
    display: flex;
    align-items: center;
    min-height: 2rem;
    margin-bottom: 0;
}

.settings-trading-mode-options {
    max-width: 46rem;
}

.settings-trading-mode-choice {
    margin-bottom: 1rem;
}

.settings-trading-mode-copy {
    display: block;
    min-width: 0;
}

.settings-trading-mode-nested {
    margin-top: 0.65rem;
}

.settings-email-subordinates {
    margin-left: 1.75rem;
    transition: opacity 0.15s ease;
}

.settings-email-subordinates.is-muted {
    opacity: 0.45;
}

.settings-llm-provider-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.settings-llm-provider-actions .settings-inline-action {
    margin-left: 0;
}

.settings-inline-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    column-gap: 2rem;
    row-gap: 1rem;
}

.settings-inline-row .settings-field-group {
    flex: 0 0 auto;
}

.settings-inline-row .settings-inline-text {
    flex: 0 0 auto;
    padding-bottom: 0.35rem;
}

.settings-inline-row .settings-inline-action {
    flex: 0 0 auto;
    margin-left: 0.5rem;
}

.login-card {
    width: 100%;
    max-width: 440px;
    margin: 0;
}

.login-card .col-md-5 {
    flex: 1 1 100%;
}

body.login-page {
    min-width: 0;
    background:
        radial-gradient(circle at 72% 8%, rgba(17, 100, 102, 0.08), transparent 28rem),
        var(--bg);
}

.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.login-brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    flex-shrink: 0;
}

.login-brand-name {
    font-weight: 800;
    font-size: 20px;
    color: var(--ink);
}

.login-brand-subtitle {
    font-size: 12px;
    color: var(--muted);
    margin-top: 1px;
}

.ib-login-prep-card {
    width: min(100%, 28rem);
}

.ib-login-prep-steps {
    display: grid;
    gap: 10px;
}

.ib-login-prep-step {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
}

.ib-login-prep-step.is-active {
    border-color: var(--accent);
    background: rgba(17, 100, 102, 0.06);
}

.ib-login-prep-step.is-done {
    border-color: rgba(17, 100, 102, 0.35);
}

.ib-login-prep-step.is-failed {
    border-color: #c45c5c;
    background: rgba(196, 92, 92, 0.06);
}

.ib-login-prep-icon {
    width: 1.25rem;
    text-align: center;
    font-weight: 700;
    color: var(--muted);
    flex-shrink: 0;
}

.ib-login-prep-step.is-active .ib-login-prep-icon {
    color: var(--accent);
}

.ib-login-prep-step.is-done .ib-login-prep-icon {
    color: var(--accent);
}

.ib-login-prep-step.is-failed .ib-login-prep-icon {
    color: #b42318;
}

.ib-login-prep-label {
    font-size: 14px;
    color: var(--ink);
}

.llm-budget-table-wrap {
    width: fit-content;
    max-width: 100%;
    overflow-x: auto;
}

.llm-budget-table {
    width: auto;
    margin-bottom: 0;
    table-layout: auto;
}

.llm-budget-table th:not(:first-child),
.llm-budget-table td:not(:first-child) {
    white-space: nowrap;
}

.portfolio-metrics {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.portfolio-metrics .card {
    box-shadow: none;
}

.portfolio-metrics .card-body {
    padding: 8px 10px;
}

.portfolio-metrics .metric-label {
    font-size: 11px;
    line-height: 1.2;
    color: var(--muted);
    margin-bottom: 2px;
}

.portfolio-metrics .metric-value {
    font-size: 15px;
    line-height: 1.2;
    white-space: nowrap;
}

/* V2 template utilities (Bootstrap-compatible class names, V1 theme) */
.col-6 {
    flex: 0 0 50%;
}

.text-end {
    text-align: right !important;
}

.ms-auto {
    margin-left: auto !important;
}

.g-3 {
    gap: 12px;
}

.me-2 {
    margin-right: 8px !important;
}

.g-2 {
    gap: 8px;
}

.text-warning {
    color: var(--warning) !important;
}

.form-check-label {
    font-size: 14px;
    line-height: 1.4;
}

.shadow-sm {
    box-shadow: 0 8px 22px rgba(42, 35, 28, 0.07) !important;
}

.list-group {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.list-group-flush {
    gap: 6px;
}

.list-group-item {
    display: block;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fffdf8;
    color: var(--ink);
}

.list-group-item.d-flex {
    display: flex;
}

#dashboard-sessions .list-group {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 250, 242, 0.78);
    box-shadow: var(--shadow);
    padding: 10px;
}

#dashboard-sessions .list-group-item {
    margin: 0;
    box-shadow: none;
}

.form-control-sm {
    min-height: 30px;
    padding: 4px 8px;
    font-size: 13px;
}

#dashboard-session-detail.session-detail {
    min-width: 0;
    padding: 18px;
    background: #f7f4ee;
}

#dashboard-session-detail .session-detail-inner {
    min-width: 0;
}

.symbol-analyzer-chart-wrap {
    position: relative;
    height: 280px;
    max-width: 100%;
}

@media (max-width: 575.98px) {
    .symbol-analyzer-chart-wrap {
        height: 220px;
    }

    .symbol-analyzer-export-row {
        flex-direction: column;
        align-items: stretch !important;
    }

    .symbol-analyzer-export-row .btn {
        width: 100%;
    }
}


.symbol-analyzer-metrics th {
    width: 38%;
    font-weight: 500;
}

.symbol-analyzer-export-row {
    justify-content: space-between;
}

.symbol-cell {
    white-space: nowrap;
}

.symbol-analyzer-launch {
    display: inline-flex;
    align-items: center;
    color: var(--accent, #116466);
    text-decoration: none;
    vertical-align: middle;
    opacity: 0.72;
}

.symbol-analyzer-launch:hover {
    opacity: 1;
    color: var(--accent, #116466);
}

.symbol-yahoo-launch {
    display: inline-flex;
    align-items: center;
    color: var(--accent, #116466);
    text-decoration: none;
    vertical-align: middle;
    opacity: 0.72;
}

.symbol-yahoo-launch:hover {
    opacity: 1;
    color: var(--accent, #116466);
}

.session-list-item .session-list-when {
    text-align: left;
}

.session-list-item .session-list-title {
    text-align: left;
}

.help-toc-list {
    columns: 2;
    column-gap: 2rem;
    padding-left: 1.1rem;
    margin: 0;
}

.help-section h2 {
    scroll-margin-top: 1rem;
}

.help-overview-lead {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--ink);
}

.help-overview-link {
    border: 1px solid var(--line);
    background: var(--panel);
    color: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.help-overview-link:hover {
    border-color: var(--accent);
    box-shadow: 0 8px 20px rgba(17, 100, 102, 0.08);
    color: inherit;
    text-decoration: none;
}

.help-overview-link-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.help-session .help-task-table th {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.help-badge {
    display: inline-block;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.help-badge-det {
    background: rgba(17, 100, 102, 0.12);
    color: var(--accent);
}

.help-badge-llm {
    background: rgba(184, 107, 0, 0.14);
    color: var(--warning);
}

.help-badge-infra {
    background: rgba(13, 110, 253, 0.12);
    color: #0d6efd;
}

.help-badge-legacy {
    background: rgba(111, 66, 193, 0.12);
    color: #6f42c1;
}

.help-flow-list {
    padding-left: 1.25rem;
    margin: 0;
}

.help-flow-list li + li {
    margin-top: 0.65rem;
}

.help-flow-list-unordered {
    list-style: disc;
}

.help-pre {
    margin: 0;
    padding: 0.85rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--line);
    background: #fffdf8;
    color: #182326;
    font-size: 0.78rem;
    line-height: 1.45;
    overflow: auto;
    max-height: 28rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.help-pre code {
    padding: 0;
    border-radius: 0;
    background: transparent;
    color: inherit;
    font-size: inherit;
}

.help-details {
    border: 1px solid var(--line);
}

.help-details-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem 1rem;
    padding: 0.85rem 1rem;
    cursor: pointer;
    list-style: none;
}

.help-details-summary::-webkit-details-marker {
    display: none;
}

.help-details-title {
    font-weight: 600;
}

.help-details[open] .help-details-summary {
    border-bottom: 1px solid var(--line);
    margin-bottom: 0.5rem;
}

.help-anatomy-timeline,
.help-anatomy-flow,
.help-anatomy-lifecycle {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 0.35rem 0.25rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
}

.help-anatomy-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 1.1rem;
    padding: 0 0.15rem;
    flex-shrink: 0;
}

.help-anatomy-timeline-node {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 7.5rem;
    max-width: 9.5rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    background: var(--panel);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.help-anatomy-timeline-node:hover {
    border-color: var(--accent);
    box-shadow: 0 6px 16px rgba(17, 100, 102, 0.08);
    color: inherit;
    text-decoration: none;
}

.help-anatomy-timeline-node-optional {
    border-style: dashed;
    opacity: 0.92;
}

.help-anatomy-timeline-phase {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.help-anatomy-timeline-label {
    font-weight: 600;
    font-size: 0.85rem;
    line-height: 1.25;
}

.help-anatomy-timeline-anchor {
    font-size: 0.72rem;
    color: var(--muted);
}

.help-anatomy-optional-badge {
    display: inline-block;
    margin-top: 0.15rem;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--warning);
}

.help-anatomy-lifecycle-node {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 8rem;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    background: #fffdf8;
}

.help-anatomy-status {
    font-size: 0.78rem;
    font-weight: 600;
}

.help-anatomy-lifecycle-arrow {
    display: flex;
    align-items: center;
    color: var(--muted);
    font-size: 1.1rem;
}

.help-anatomy-handoff {
    border: 1px solid var(--line);
    background: var(--panel);
}

.help-anatomy-handoff-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.help-anatomy-handoff-row-stack {
    margin: 0.75rem 0;
}

.help-anatomy-handoff-box {
    flex: 1 1 6.5rem;
    min-width: 6rem;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--line);
    border-radius: 0.45rem;
    background: #fff;
    text-align: center;
    line-height: 1.35;
}

.help-anatomy-handoff-box-accent {
    border-color: rgba(17, 100, 102, 0.35);
    background: rgba(17, 100, 102, 0.06);
}

.help-anatomy-handoff-stack {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px dashed var(--line);
    border-radius: 0.45rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.help-anatomy-flow .help-anatomy-node {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 6.5rem;
    max-width: 8.5rem;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--line);
    border-radius: 0.45rem;
    background: var(--panel);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s ease;
}

.help-anatomy-flow .help-anatomy-node:hover {
    border-color: var(--accent);
    color: inherit;
    text-decoration: none;
}

.help-anatomy-node-llm {
    border-left: 3px solid var(--warning);
}

.help-anatomy-node-deterministic {
    border-left: 3px solid var(--accent);
}

.help-anatomy-node-step {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.help-anatomy-node-label {
    font-weight: 600;
    font-size: 0.78rem;
    line-height: 1.25;
}

.help-anatomy-node-type {
    font-size: 0.65rem;
    font-family: var(--bs-font-monospace, monospace);
    color: var(--muted);
    word-break: break-all;
}

.help-anatomy-step {
    border: 1px solid var(--line);
    scroll-margin-top: 1rem;
}

.help-anatomy-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 999px;
    background: rgba(17, 100, 102, 0.12);
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 700;
}

.help-anatomy-detail-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin-bottom: 0.2rem;
}

.help-anatomy-session {
    scroll-margin-top: 1rem;
}

#what-this-is,
#market-day,
#sessions,
#task-reference,
#orchestration-timing,
#outside-world,
#appendix,
#market-day-anatomy,
#session-anatomy {
    scroll-margin-top: 1rem;
}

.help-guide-card {
    border: 1px solid var(--line);
    background: var(--panel);
}

.help-system-diagram {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding: 0.25rem 0;
}

.help-system-layer {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--line);
    border-radius: 0.65rem;
    background: var(--panel);
}

.help-system-layer-core,
.help-system-layer-state {
    border-color: rgba(17, 100, 102, 0.25);
    background: rgba(17, 100, 102, 0.04);
}

.help-system-layer-external {
    border-style: dashed;
}

.help-system-layer-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.help-system-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: 0.6rem;
}

.help-system-node {
    padding: 0.7rem 0.8rem;
    border: 1px solid var(--line);
    border-radius: 0.55rem;
    background: #fff;
    text-align: center;
}

.help-system-node strong {
    display: block;
    font-size: 0.86rem;
    margin-bottom: 0.25rem;
}

.help-system-node span {
    display: block;
    font-size: 0.72rem;
    color: var(--muted);
    line-height: 1.3;
}

.help-system-node-core {
    border-color: rgba(17, 100, 102, 0.35);
    background: rgba(17, 100, 102, 0.06);
}

.help-system-node-gateway {
    border-color: rgba(13, 110, 253, 0.3);
    background: rgba(13, 110, 253, 0.06);
}

.help-system-node-user {
    border-color: rgba(184, 107, 0, 0.35);
    background: rgba(184, 107, 0, 0.08);
}

.help-system-arrow,
.help-system-arrow-vertical {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 1.1rem;
    font-weight: 700;
    flex: 0 0 auto;
}

.help-system-arrow-vertical {
    min-height: 1rem;
    width: 100%;
}

.help-system-branch {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.help-details {
    scroll-margin-top: 1rem;
}

.help-session-details > .help-details-summary {
    align-items: center;
}

.help-task-contract {
    border: 1px solid var(--line);
    background: #fff;
    scroll-margin-top: 1rem;
}

.help-task-contract-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem 0.65rem;
    padding: 0.85rem 1rem;
    cursor: pointer;
    list-style: none;
}

.help-task-contract-summary::-webkit-details-marker {
    display: none;
}

.help-task-contract[open] > .help-task-contract-summary {
    border-bottom: 1px solid var(--line);
    margin-bottom: 0.5rem;
}

.help-contract-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
}

.help-contract-item {
    padding: 0.75rem;
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    background: #fffdf8;
}

.help-contract-list {
    padding-left: 1.1rem;
    margin: 0;
}

.help-contract-list li + li {
    margin-top: 0.35rem;
}

.help-contract-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--line);
}

.help-nested-details {
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    background: #fff;
}

.help-nested-details summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem 0.75rem;
    cursor: pointer;
}

.help-nested-details[open] summary {
    margin-bottom: 0.5rem;
}

.monitor-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.monitor-stat {
    padding: 13px 15px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 10px 26px rgba(42, 35, 28, 0.08);
}

.monitor-stat-label {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 4px;
}

.monitor-stat strong {
    font-size: 22px;
}

.monitor-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.monitor-chart-wrap {
    position: relative;
    min-height: 300px;
}

.monitor-card canvas {
    width: 100%;
}

.monitor-card-full {
    grid-column: 1 / -1;
}

.monitor-experience-pre {
    max-height: 320px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.8125rem;
    background: var(--bs-tertiary-bg, #f8f9fa);
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.375rem;
    padding: 0.75rem;
}

@media (max-width: 767.98px) {
    .monitor-summary,
    .monitor-grid {
        grid-template-columns: 1fr;
    }

    .help-contract-grid {
        grid-template-columns: 1fr;
    }

    .help-toc-list {
        columns: 1;
    }

    .help-system-diagram {
        gap: 0.35rem;
    }

    .help-system-row {
        grid-template-columns: 1fr;
    }
}

/* -- Responsive: shell -- */
@media (max-width: 991.98px) {
    :root {
        --sidebar-width: 0px;
    }

    body {
        background:
            radial-gradient(circle at 72% 8%, rgba(17, 100, 102, 0.08), transparent 28rem),
            var(--bg);
    }

    .app-mobile-header {
        display: flex;
        align-items: center;
        gap: 12px;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: var(--z-mobile-header);
        height: var(--mobile-header-height);
        padding: 0 12px;
        padding-top: env(safe-area-inset-top, 0px);
        padding-left: calc(12px + env(safe-area-inset-left, 0px));
        padding-right: calc(12px + env(safe-area-inset-right, 0px));
        background: #243136;
        color: #eef7f3;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
    }

    .app-menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        margin: 0;
        padding: 0;
        border: 0;
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.08);
        color: #fff;
        cursor: pointer;
        flex-shrink: 0;
    }

    .app-menu-toggle:hover,
    .app-menu-toggle:focus-visible {
        background: rgba(255, 255, 255, 0.14);
        outline: 2px solid rgba(255, 255, 255, 0.35);
        outline-offset: 2px;
    }

    .app-menu-icon {
        display: block;
        width: 18px;
        height: 2px;
        background: currentColor;
        border-radius: 1px;
        box-shadow: 0 -6px 0 currentColor, 0 6px 0 currentColor;
    }

    .app-mobile-brand {
        display: flex;
        align-items: center;
        gap: 10px;
        min-width: 0;
        flex: 1 1 auto;
        color: #fff;
        text-decoration: none;
        font-weight: 800;
    }

    .app-mobile-brand:hover {
        text-decoration: none;
        color: #fff;
    }

    .app-mobile-brand .app-brand-name {
        font-size: 17px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .app-mobile-logout {
        flex-shrink: 0;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        padding: 0 10px;
        border-radius: 7px;
        color: #ffd8d4;
        font-weight: 650;
        font-size: 13px;
        text-decoration: none;
    }

    .app-mobile-logout:hover {
        background: rgba(255, 255, 255, 0.08);
        color: #fff;
        text-decoration: none;
    }

    .app-sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: var(--z-sidebar-backdrop);
        background: rgba(18, 26, 28, 0.48);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
    }

    .app-sidebar-backdrop.is-visible {
        opacity: 1;
        pointer-events: auto;
    }

    .app-sidebar {
        width: min(280px, calc(100vw - 48px));
        background: #243136;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        padding-top: calc(24px + env(safe-area-inset-top, 0px));
        box-shadow: 8px 0 28px rgba(0, 0, 0, 0.22);
    }

    .app-sidebar.is-open {
        transform: translateX(0);
    }

    .app-sidebar .app-brand {
        display: none;
    }

    .app-sidebar .app-logout {
        display: none;
    }

    .app-sidebar .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    body.sidebar-open {
        overflow: hidden;
    }

    .app-main {
        margin-left: 0;
        padding: calc(var(--mobile-header-height) + env(safe-area-inset-top, 0px) + 16px) 16px 40px;
    }

    .container {
        width: 100%;
        max-width: 100%;
    }
}

@media (min-width: 768px) and (max-width: 991.98px) {
    .app-main {
        padding: calc(var(--mobile-header-height) + env(safe-area-inset-top, 0px) + 20px) 24px 48px;
    }
}

/* -- Responsive: grid columns -- */
@media (max-width: 767.98px) {
    .row > [class*="col-"]:not(.col-auto) {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

@media (min-width: 576px) {
    .col-sm { flex: 1 1 0; min-width: 0; max-width: 100%; }
    .col-sm-3 { flex: 0 0 25%; max-width: 25%; }
    .col-sm-4 { flex: 0 0 33.333%; max-width: 33.333%; }
    .col-sm-9 { flex: 0 0 75%; max-width: 75%; }
    .col-sm-auto { flex: 0 0 auto; max-width: none; }
}

@media (min-width: 768px) {
    .col-md-2 { flex: 0 0 16.666%; max-width: 16.666%; }
    .col-md-3 { flex: 0 0 25%; max-width: 25%; }
    .col-md-4 { flex: 0 0 33.333%; max-width: 33.333%; }
    .col-md-5 { flex: 0 0 41.666%; max-width: 41.666%; }
    .col-md-6 { flex: 0 0 50%; max-width: 50%; }

    .flex-md-row {
        flex-direction: row !important;
    }

    .d-md-none { display: none !important; }
    .d-md-block { display: block !important; }
    .d-md-table-cell { display: table-cell !important; }
}

@media (min-width: 992px) {
    .col-lg-2 { flex: 0 0 16.666%; max-width: 16.666%; }

    .d-lg-none { display: none !important; }
    .d-lg-block { display: block !important; }
}

@media (min-width: 1200px) {
    .col-xl-4 { flex: 0 0 33.333%; max-width: 33.333%; }
}

@media (min-width: 576px) {
    .d-sm-none { display: none !important; }
    .d-sm-block { display: block !important; }
    .d-sm-table-cell { display: table-cell !important; }
}

/* -- Responsive: dashboard -- */
@media (max-width: 991.98px) {
    .session-workspace {
        grid-template-columns: 1fr;
        min-height: 0;
    }
}

@media (max-width: 767.98px) {
    .dashboard-topbar {
        flex-direction: column;
        align-items: stretch;
    }

    .ops-compact {
        flex-wrap: wrap;
        width: 100%;
    }

    .session-detail-grid {
        grid-template-columns: 1fr;
    }

    .kv-grid,
    .analysis-summary {
        grid-template-columns: 1fr;
    }

    .activity-line {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .limits-diagram-panels {
        grid-template-columns: 1fr;
    }

    .dashboard-date-input {
        width: 100%;
        min-width: 0;
    }

    #dashboard-day-nav .form-control {
        flex: 1 1 100%;
        min-width: 0;
    }
}

@media (min-width: 576px) and (max-width: 767.98px) {
    .kv-grid,
    .analysis-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 575.98px) {
    .workflow-node,
    .candidate-pick-head {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .candidate-pick-head span,
    .candidate-pick-head em {
        justify-self: start;
    }
}

/* -- Responsive: workflow modal -- */
@media (max-width: 767.98px) {
    .workflow-modal .modal-dialog.workflow-modal-dialog {
        width: calc(100vw - 1rem);
        max-width: calc(100vw - 1rem);
        margin: 0.5rem auto;
    }

    .workflow-modal .modal-content {
        height: auto;
        max-height: 90vh;
    }

    .workflow-modal-body {
        height: auto;
        max-height: calc(90vh - 58px);
        overflow: auto;
    }

    .workflow-modal-graph {
        min-height: 50vh;
    }
}

/* -- Responsive: portfolio -- */
@media (min-width: 576px) {
    .portfolio-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 768px) {
    .portfolio-metrics {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1200px) {
    .portfolio-metrics {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}

@media (max-width: 575.98px) {
    .portfolio-metrics .metric-value {
        white-space: normal;
    }
}

.table td .badge.text-bg-warning,
.table td .badge.bg-warning {
    color: #3a2a08;
}

/* -- Responsive: settings -- */
.settings-credential-value,
.settings-inline-row code,
.app-main code.user-select-all,
.app-main .font-monospace {
    word-break: break-all;
}

/* -- Responsive: modals -- */
@media (max-width: 767.98px) {
    .modal {
        padding: 1rem;
    }

    .modal-dialog {
        width: calc(100% - 2rem);
        max-width: calc(100vw - 2rem);
    }

    .modal-dialog-scrollable {
        width: calc(100% - 2rem);
        max-width: calc(100vw - 2rem);
    }

    .modal-content {
        max-height: 90vh;
    }

    .modal-dialog-scrollable .modal-content {
        max-height: 90vh;
    }
}

/* -- Responsive: help -- */
.help-section pre,
.help-section code,
.help-details pre {
    overflow-x: auto;
    max-width: 100%;
}

