:root {
    --bg: #071018;
    --surface: #0d1923;
    --surface-2: #122432;
    --border: #203746;
    --text: #e6f0f4;
    --muted: #8fa7b3;
    --accent: #27c4a8;
    --accent-2: #40a9ff;
    --danger: #ff6b74;
    --warning: #f2b84b;
    --sidebar: #09141d;
    --shadow: 0 18px 55px rgba(0, 0, 0, .22);
}

html[data-theme="light"] {
    --bg: #edf3f6;
    --surface: #ffffff;
    --surface-2: #f4f8fa;
    --border: #d6e2e8;
    --text: #12232e;
    --muted: #607783;
    --sidebar: #102431;
    --shadow: 0 16px 45px rgba(21, 54, 71, .11);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 80% 0, rgba(34, 126, 148, .12), transparent 35%), var(--bg); color: var(--text); font-family: Inter, "Segoe UI", sans-serif; }
a { color: inherit; }
button, input { font: inherit; }
select { padding: 10px 11px; border: 1px solid var(--border); border-radius: 7px; color: var(--text); background: var(--surface-2); }

.sidebar { position: fixed; inset: 0 auto 0 0; width: 252px; padding: 24px 18px; z-index: 10; background: linear-gradient(180deg, #0a1a24, var(--sidebar)); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; letter-spacing: -.4px; font-size: 21px; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; color: #071018; background: linear-gradient(145deg, var(--accent), #7ce3cf); font: 700 28px Georgia, serif; box-shadow: 0 8px 26px rgba(39, 196, 168, .24); }
.brand small { display: block; margin-top: 2px; color: #809ba8; font-size: 9px; letter-spacing: 1.6px; text-transform: uppercase; }
.sidebar nav { display: grid; gap: 4px; margin-top: 42px; }
.sidebar nav a { padding: 12px 13px; border-radius: 9px; color: #a9bdc7; text-decoration: none; font-size: 14px; transition: .15s ease; }
.sidebar nav a span { display: inline-block; width: 25px; color: #6e909f; font-size: 17px; }
.sidebar nav a:hover, .sidebar nav a.active { color: white; background: rgba(39, 196, 168, .1); }
.scope-note { margin-top: auto; padding: 12px; color: #7895a2; border: 1px solid rgba(88, 131, 148, .2); border-radius: 9px; font-size: 12px; }
.status-dot { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }

.app-shell { margin-left: 252px; min-height: 100vh; }
.topbar { height: 68px; padding: 0 34px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 84%, transparent); backdrop-filter: blur(14px); }
.topbar > div, .top-actions { display: flex; align-items: center; gap: 14px; }
.topbar-left { min-width: 0; flex: 1; }
.symbol-search { width: min(330px, 35vw); display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.symbol-search input { width: 100%; padding: 8px 0; border: 0; background: transparent; box-shadow: none; }
.market-state, .top-status, .top-freshness, .attention-link { color: var(--muted); font-size: 11px; white-space: nowrap; text-decoration: none; }
.market-state strong, .top-status strong, .top-freshness strong, .attention-link strong { color: var(--text); }
.top-status .status-dot { width: 7px; height: 7px; }
.environment { padding: 5px 9px; border: 1px solid var(--border); border-radius: 12px; color: var(--muted); font-size: 9px; letter-spacing: 1.3px; }
.icon-button, .link-button { border: 0; color: var(--muted); background: none; cursor: pointer; }
#nav-toggle { display: none; }
.user-name { color: var(--muted); font-size: 13px; }
.content { max-width: 1640px; padding: 34px; margin: 0 auto; }

.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 30px; margin-bottom: 27px; }
.page-heading h1 { margin: 3px 0 7px; font-size: clamp(28px, 3vw, 42px); letter-spacing: -1.4px; }
.page-heading p { max-width: 740px; margin: 0; color: var(--muted); }
.eyebrow { margin: 0 !important; color: var(--accent) !important; font-size: 10px !important; font-weight: 700; letter-spacing: 1.8px; }
.subdued { color: var(--muted); font-size: .47em; font-weight: 400; letter-spacing: 0; }
.freshness-badge { min-width: 190px; padding: 12px 15px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.freshness-badge span, .freshness-badge strong { display: block; }
.freshness-badge span { color: var(--muted); font-size: 10px; }
.freshness-badge strong { margin-top: 4px; font-size: 13px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; margin-bottom: 20px; }
.metric-card, .panel { border: 1px solid var(--border); background: linear-gradient(145deg, color-mix(in srgb, var(--surface) 94%, white 2%), var(--surface)); box-shadow: var(--shadow); }
.metric-card { position: relative; min-height: 132px; padding: 20px; border-radius: 12px; overflow: hidden; }
.metric-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 2px; background: #4c7180; }
.metric-card.accent::before { background: var(--accent); }
.metric-card.danger::before { background: var(--danger); }
.metric-card.warning::before { background: var(--warning); }
.metric-card span, .metric-card small, .metric-card strong { display: block; }
.metric-card span { color: var(--muted); font-size: 12px; }
.metric-card strong { margin: 8px 0; font-size: 32px; letter-spacing: -1px; }
.metric-card small { color: #718c98; }
.metric-grid.compact .metric-card { min-height: 105px; }

.panel { padding: 22px; border-radius: 13px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.panel h2 { margin: 5px 0; letter-spacing: -.5px; }
.text-link { color: var(--accent); text-decoration: none; font-size: 13px; }
.split-panel { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; }
.regime-card { padding: 6px 4px 0 24px; border-left: 1px solid var(--border); }
.regime-card > p:not(.eyebrow) { color: var(--muted); line-height: 1.6; }
.regime-visual { height: 8px; margin: 21px 0; border-radius: 8px; background: linear-gradient(90deg, var(--danger), var(--warning), var(--accent)); }
.regime-visual span { display: block; width: 13px; height: 13px; margin-left: 47%; transform: translateY(-3px); border: 2px solid white; border-radius: 50%; background: #122432; }
dl { margin: 0; }
dl div { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border); }
dt { color: var(--muted); }
dd { margin: 0; font-weight: 600; }

.two-column { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(340px, .75fr); gap: 20px; margin-bottom: 20px; }
.chart { height: 390px; }
.empty-state { padding: 70px 20px; color: var(--muted); text-align: center; }
.lead { color: #c8d8df; line-height: 1.65; }
.case-grid { display: grid; gap: 12px; margin: 20px 0; }
.case-grid > div { padding: 15px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); }
.case-grid h3 { margin: 0 0 7px; font-size: 13px; }
.case-grid p, .thesis-panel li { color: var(--muted); line-height: 1.55; font-size: 13px; }
.model-note { padding-top: 14px; border-top: 1px solid var(--border); color: #6d8995; font-size: 11px; }
.evidence-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }
.evidence-grid li, .evidence-grid dd, .lab-stage li { color: var(--muted); font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; }
.evidence-grid dl dt { margin-top: 9px; font-size: 11px; }
.status-pill { padding: 7px 11px; border: 1px solid var(--border); border-radius: 20px; color: var(--warning); font-size: 11px; letter-spacing: .5px; text-transform: uppercase; }
.status-pill.actionable { color: var(--accent); }
.status-pill.notrade { color: var(--danger); }

.lab-stage { min-height: 420px; display: flex; align-items: center; justify-content: center; gap: 55px; }
.lab-stage > div:last-child { max-width: 520px; }
.lab-visual { display: grid; place-items: center; width: 160px; height: 160px; border: 1px solid rgba(39, 196, 168, .35); border-radius: 50%; color: var(--accent); background: radial-gradient(circle, rgba(39, 196, 168, .18), transparent 65%); font: 700 90px Georgia, serif; }
.provider-form { display: grid; grid-template-columns: minmax(160px, .8fr) 1fr auto; gap: 12px; align-items: end; padding: 18px 0; border-bottom: 1px solid var(--border); }
.provider-form > form:first-child { display: contents; }
.provider-test-detail { grid-column: 1 / -1; margin: 0; color: var(--text-muted); font-size: .82rem; line-height: 1.45; }
.provider-title span { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
input { min-width: 0; padding: 10px 11px; border: 1px solid var(--border); border-radius: 7px; color: var(--text); background: var(--surface-2); outline: none; }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(39, 196, 168, .12); }
.primary-button { padding: 10px 14px; border: 0; border-radius: 7px; color: #031713; background: var(--accent); font-weight: 700; cursor: pointer; }
.secondary-button, .danger-button { padding: 8px 11px; border: 1px solid var(--border); border-radius: 7px; color: var(--text); background: var(--surface-2); cursor: pointer; }
.page-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.grid-action-link { color: var(--accent); font-weight: 700; text-decoration: none; }
.grid-action-link:hover, .grid-action-link:focus-visible { text-decoration: underline; }
.danger-button { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.automation-banner { margin: -18px 0 28px; padding: 12px 15px; display: flex; justify-content: space-between; align-items: center; gap: 18px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.automation-banner > div { display: flex; align-items: center; gap: 10px; }
.automation-banner > div > span:last-child { color: var(--muted); font-size: 12px; }
.automation-banner.awaitingapprovedmodel .status-dot, .automation-banner.newentriespaused .status-dot { background: var(--warning); box-shadow: 0 0 10px var(--warning); }
.automation-banner.emergencystopped .status-dot, .automation-banner.degraded .status-dot { background: var(--danger); box-shadow: 0 0 10px var(--danger); }
.automation-actions { justify-content: flex-end; flex-wrap: wrap; }
.automation-actions form { margin: 0; }
.today-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(320px, .55fr); gap: 20px; margin-bottom: 20px; }
.cycle-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 24px; }
.cycle-strip > div { padding: 13px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.cycle-strip span, .cycle-strip strong { display: block; }
.cycle-strip span { margin-bottom: 5px; color: var(--muted); font-size: 10px; }
.cycle-strip strong { font-size: 12px; }
.plain-list { color: var(--muted); line-height: 1.6; }
.activity-list { display: grid; gap: 9px; }
.activity-list.horizontal { grid-template-columns: repeat(3, 1fr); }
.activity-item { position: relative; display: grid; gap: 4px; padding: 12px 13px; border: 1px solid var(--border); border-left: 3px solid var(--accent-2); border-radius: 8px; color: inherit; background: var(--surface-2); text-decoration: none; }
.activity-item.attention { border-left-color: var(--warning); }
.activity-item.warning, .activity-item.critical { border-left-color: var(--danger); }
.activity-item small, .activity-item time { color: var(--muted); font-size: 11px; line-height: 1.45; }
.activity-item time { font-size: 9px; }
.activity-preview { margin-top: 20px; }
.asset-tabs, .research-tabs { display: flex; gap: 4px; margin-bottom: 18px; overflow-x: auto; }
.asset-tabs button, .research-tabs a { padding: 9px 13px; border: 0; border-bottom: 2px solid transparent; color: var(--muted); background: transparent; text-decoration: none; cursor: pointer; white-space: nowrap; }
.asset-tabs button.active, .research-tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.research-tabs { margin: -10px 0 20px; padding: 0 4px; border-bottom: 1px solid var(--border); }
.explorer-filters { display: flex; align-items: center; gap: 7px; margin-bottom: 16px; color: var(--muted); font-size: 11px; flex-wrap: wrap; }
.explorer-filters a { padding: 5px 8px; border: 1px solid transparent; border-radius: 6px; color: var(--muted); text-decoration: none; }
.explorer-filters a.active { color: var(--accent); border-color: var(--border); background: var(--surface-2); }
.decision-plan { margin-bottom: 20px; }
.decision-plan p { color: var(--muted); font-size: 12px; line-height: 1.5; }
.schedule-list { display: grid; }
.schedule-list > div { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.schedule-list span { color: var(--accent); font-size: 11px; }
.schedule-list small { color: var(--muted); }
.diagnostic-panel { border-style: dashed; box-shadow: none; }
.activity-toolbar { display: flex; gap: 10px; margin-bottom: 20px; }
.activity-toolbar input { flex: 1; }
.timeline { display: grid; }
.timeline-item { position: relative; display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.timeline-marker { width: 10px; height: 10px; margin-top: 5px; border: 2px solid var(--accent-2); border-radius: 50%; }
.timeline-item.attention .timeline-marker { border-color: var(--warning); }
.timeline-item.warning .timeline-marker, .timeline-item.critical .timeline-marker { border-color: var(--danger); }
.timeline-heading { display: flex; align-items: center; gap: 10px; }
.timeline-item p { margin: 7px 0; color: var(--muted); }
.timeline-item time { color: var(--muted); font-size: 10px; }
.settings-summary dt { margin-top: 18px; font-size: 11px; }
.settings-summary dd { padding: 5px 0 14px; border-bottom: 1px solid var(--border); }
.settings-lower { margin-top: 20px; }
.safety-callout { margin-top: 25px; padding: 15px; border: 1px solid rgba(39, 196, 168, .35); border-radius: 9px; background: rgba(39, 196, 168, .06); }
.safety-callout p { margin-bottom: 0; color: var(--muted); }
.toast-message { margin-bottom: 18px; padding: 12px; border: 1px solid rgba(39, 196, 168, .35); border-radius: 8px; color: var(--accent); background: rgba(39, 196, 168, .07); }
.error-message { margin-bottom: 18px; padding: 12px; border: 1px solid rgba(255, 107, 116, .42); border-radius: 8px; color: var(--danger); background: rgba(255, 107, 116, .08); }
.operations-layout { grid-template-columns: minmax(360px, .8fr) minmax(520px, 1.2fr); }
.sync-form { display: grid; gap: 16px; margin-top: 24px; }
.sync-form small { color: #718c98; }
.date-fields { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.snapshot-table-wrap { overflow-x: auto; }
.snapshot-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.snapshot-table th, .snapshot-table td { padding: 12px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.snapshot-table th { color: var(--muted); font-weight: 500; }
.compact-empty { padding: 45px 10px; }
.inline-button { display: inline-block; margin: 8px 0 25px; text-decoration: none; }
hr { margin: 25px 0; border: 0; border-top: 1px solid var(--border); }
.mfa-panel { max-width: 760px; }
.mfa-panel li { margin: 12px 0; color: var(--muted); line-height: 1.6; }
.mfa-enrollment-grid { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 28px; align-items: center; margin-top: 22px; }
.qr-card { display: grid; justify-items: center; gap: 10px; padding: 18px; border: 1px solid var(--border); border-radius: 12px; text-align: center; background: var(--surface-2); }
.qr-card img { display: block; width: min(232px, 100%); height: auto; padding: 10px; border-radius: 8px; background: #fff; image-rendering: pixelated; }
.qr-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.shared-key, .uri-value { display: inline-block; max-width: 100%; padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; color: var(--accent); background: var(--surface-2); overflow-wrap: anywhere; }
.mfa-panel details { margin: 22px 0; color: var(--muted); }
.mfa-panel details code { margin-top: 10px; }
.mfa-form { display: flex; align-items: end; gap: 12px; margin-top: 22px; }

.login-body { display: grid; place-items: center; padding: 25px; }
.login-card { width: min(440px, 100%); padding: 38px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.login-brand { margin-bottom: 32px; }
.login-card > p, .login-card > small { color: var(--muted); }
.login-card form { display: grid; gap: 16px; margin: 26px 0; }
.check-label { display: flex; align-items: center; grid-template-columns: auto 1fr; }
.check-label input { min-width: auto; }
.wide { width: 100%; }
.validation { color: var(--danger); }

.dx-widget { font-family: inherit !important; }
.dx-datagrid { background: transparent !important; }
.dx-datagrid-headers { color: var(--muted) !important; }

@media (max-width: 1100px) {
    .metric-grid, .evidence-grid { grid-template-columns: repeat(2, 1fr); }
    .split-panel, .two-column { grid-template-columns: 1fr; }
    .regime-card { padding: 20px 0 0; border: 0; border-top: 1px solid var(--border); }
    .provider-form { grid-template-columns: 1fr; }
    .operations-layout { grid-template-columns: 1fr; }
    .today-grid { grid-template-columns: 1fr; }
    .cycle-strip { grid-template-columns: 1fr; }
    .activity-list.horizontal { grid-template-columns: 1fr 1fr; }
    .market-state, .top-freshness { display: none; }
}

@media (max-width: 760px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    body.nav-open .sidebar { transform: translateX(0); }
    .app-shell { margin-left: 0; }
    .mfa-enrollment-grid { grid-template-columns: 1fr; }
    #nav-toggle { display: inline-block; }
    .content { padding: 22px 15px; }
    .topbar { padding: 0 17px; }
    .metric-grid, .evidence-grid { grid-template-columns: 1fr; }
    .date-fields { grid-template-columns: 1fr; }
    .page-heading { display: block; }
    .freshness-badge { margin-top: 18px; }
    .lab-stage { flex-direction: column; text-align: center; }
    .automation-banner { align-items: flex-start; flex-direction: column; }
    .automation-banner > div { align-items: flex-start; flex-wrap: wrap; }
    .activity-list.horizontal { grid-template-columns: 1fr; }
    .symbol-search { width: min(230px, 45vw); }
    .user-name, .top-status { display: none; }
    .timeline-item { grid-template-columns: 18px minmax(0, 1fr); }
    .timeline-item form { grid-column: 2; }
}
