/* Event Terminal UI 2026-11 — visual layer only. Loaded last; no behaviour changes. */
:root {
  --ui-bg: #080c14;
  --ui-surface: #0f1522;
  --ui-surface-2: #151d2d;
  --ui-surface-3: #1b2538;
  --ui-line: #232f45;
  --ui-line-strong: #33425e;
  --ui-text: #e9eef6;
  --ui-muted: #8d9ab0;
  --ui-faint: #5f6c82;
  --ui-brand: #2ee6b6;
  --ui-brand-ink: #032a20;
  --ui-brand-soft: #2ee6b61a;
  --ui-up: #2ee6b6;
  --ui-down: #e88e73;
  --ui-warn: #f6b54a;
  --ui-info: #6ea8ff;
  --ui-radius: 14px;
  --ui-radius-sm: 10px;
  --ui-font: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Segoe UI", Inter, sans-serif;
  /* existing theme variables, re-pointed */
  --terminal-bg: var(--ui-bg); --terminal-panel: var(--ui-surface); --terminal-line: var(--ui-line);
  --terminal-text: var(--ui-text); --terminal-muted: var(--ui-muted); --terminal-accent: var(--ui-brand);
  --accent: var(--ui-brand); --terminal-green: var(--ui-up); --terminal-font: var(--ui-font);
  color-scheme: dark;
}
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 12px; }
html, body, #app, button, input, select, textarea, .card, .pill, label, h1, h2, h3, summary, table { font-family: var(--ui-font) !important; letter-spacing: normal; }
body { background: var(--ui-bg) !important; background-image: radial-gradient(1200px 600px at 100% -10%, #2ee6b60f, transparent 60%), radial-gradient(900px 500px at -10% 10%, #6ea8ff0d, transparent 60%) !important; color: var(--ui-text); }
.metric, .price, .kpi-value, .health-value, td, .pixel-kpi strong, input[type="number"] { font-variant-numeric: tabular-nums; }
a { color: var(--ui-info); }
.muted, .compact-note, small.muted { color: var(--ui-muted) !important; }

/* ---------- surfaces ---------- */
.shell { max-width: 1680px; padding: 18px 22px 40px; }
.card, .terminal-module { background: var(--ui-surface) !important; border: 1px solid var(--ui-line) !important; border-radius: var(--ui-radius) !important; box-shadow: 0 1px 0 #ffffff05 inset, 0 10px 30px #00000033 !important; }
.terminal-module .terminal-module, .module-details, .session-status, .reference-context, .real-orders, .real-config, .execution-panel, .cloud-extension, .health-grid, .real-report .card, .workbench-library, .simulation-active, .history-cache-summary, .backtest-progress, fieldset {
  border-radius: var(--ui-radius-sm) !important; border-color: var(--ui-line) !important; box-shadow: none !important;
}
.module-details, .collapsible-module, .connection-panel, .execution-panel { background: var(--ui-surface-2) !important; }
fieldset { border: 1px solid var(--ui-line) !important; padding: 14px; }
legend { color: var(--ui-muted); padding: 0 6px; }
hr, .workbench-body > * + * { border-color: var(--ui-line) !important; }

/* headings */
.workbench-head h1, .workbench-head h2 { font-size: 22px; font-weight: 700; letter-spacing: 0; color: var(--ui-text); }
.module-code { color: var(--ui-brand) !important; font-size: 11px; font-weight: 600; letter-spacing: .12em; opacity: .9; }
.module-name, .section-title { font-weight: 650; color: var(--ui-text); }
.module-summary { border-radius: var(--ui-radius-sm); }

/* ---------- controls ---------- */
button {
  min-height: 42px; padding: 10px 16px; border-radius: var(--ui-radius-sm) !important; border: 1px solid transparent !important;
  background: var(--ui-brand) !important; color: var(--ui-brand-ink) !important; font-weight: 650; box-shadow: none !important;
  transition: background .15s, border-color .15s, transform .05s; text-shadow: none !important; line-height: 1.2;
}
button.secondary { background: var(--ui-surface-3) !important; border-color: var(--ui-line-strong) !important; color: var(--ui-text) !important; }
button.danger, button.stop-button, button.quiet-danger { background: #e88e731f !important; border-color: #e88e7366 !important; color: #f4cabe !important; }
button:disabled { opacity: .45 !important; filter: none !important; }
@media (hover:hover) and (pointer:fine) {
  button:not(:disabled):hover { filter: brightness(1.08); }
  button.secondary:not(:disabled):hover { border-color: var(--ui-brand) !important; }
}
button:not(:disabled):active { transform: translateY(1px); }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--ui-brand) !important; outline-offset: 2px; }

input, select, textarea {
  min-height: 44px; width: 100%; padding: 10px 12px; border-radius: var(--ui-radius-sm) !important;
  border: 1px solid var(--ui-line-strong) !important; background: #0b111c !important; color: var(--ui-text) !important;
  box-shadow: none !important; font-size: 15px;
}
input[type="checkbox"], input[type="radio"] { width: 18px; min-height: 18px; height: 18px; padding: 0; accent-color: var(--ui-brand); }
input:focus, select:focus, textarea:focus { border-color: var(--ui-brand) !important; outline: 2px solid var(--ui-brand-soft) !important; }
input:disabled, select:disabled, textarea:disabled { opacity: .55; }
select { appearance: none; -webkit-appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%238d9ab0' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important; background-position: right 12px center !important; text-overflow: ellipsis; }
textarea, .json-editor { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace !important; font-size: 13px; line-height: 1.55; }
/* datetime: left-aligned, vertically centred on iOS/Safari and Chromium */
input[type="datetime-local"], input[type="date"], input[type="time"] {
  -webkit-appearance: none; appearance: none; display: flex; align-items: center; text-align: left;
  min-width: 0; font-variant-numeric: tabular-nums; line-height: 1.2;
}
input[type="datetime-local"]::-webkit-date-and-time-value { text-align: left; margin: 0; min-height: 1.2em; }
input[type="datetime-local"]::-webkit-datetime-edit { padding: 0; }
input[type="datetime-local"]::-webkit-calendar-picker-indicator { filter: invert(.75); opacity: .8; margin-left: 6px; cursor: pointer; }
label { color: var(--ui-muted) !important; font-size: 13px; font-weight: 500; gap: 6px; min-width: 0; }
label > input[type="checkbox"] { margin: 0; }

/* pills / status */
.pill, .module-badge { border-radius: 999px !important; padding: 4px 10px !important; border: 1px solid var(--ui-line-strong) !important; background: var(--ui-surface-3) !important; color: var(--ui-muted) !important; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.positive, .module-badge.positive { color: var(--ui-up) !important; border-color: #2ee6b655 !important; background: #2ee6b614 !important; }
.pill.negative, .module-badge.negative { color: #ffc56b !important; border-color: #f6b54a55 !important; background: #f6b54a14 !important; }
.positive { color: var(--ui-up); } .negative { color: var(--ui-down); }
.direction-up { color: var(--ui-up) !important; } .direction-down { color: var(--ui-down) !important; }
.error, .notice { border-radius: var(--ui-radius-sm) !important; }
.notice { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px !important; background: #f6b54a14 !important; border: 1px solid #f6b54a55 !important; color: #ffd28a !important; box-shadow: none !important; }
.notice button { min-height: 34px; padding: 6px 12px; flex: none; }

/* ---------- top bar & brand ---------- */
.topbar { border-bottom: 1px solid var(--ui-line) !important; padding-bottom: 14px; margin-bottom: 16px; align-items: center; }
.brand-link { display: flex; align-items: center; gap: 12px; text-decoration: none; flex-wrap: wrap; }
.brand { font-size: 19px !important; font-weight: 750 !important; letter-spacing: .04em !important; color: var(--ui-text) !important; text-shadow: none !important; gap: 10px !important; }
.brand::before { width: 30px !important; height: 30px !important; flex: 0 0 30px !important; margin: 0 !important; box-shadow: none !important; border-radius: 8px;
  background: url("/assets/workspace-20261121-r22-favicon.svg") center / contain no-repeat !important; }
.brand::before { transform: none !important; }
.auth { background: transparent !important; }
.auth-card { width: min(400px, 100%) !important; padding: 30px 26px !important; border-radius: 18px !important; }
.auth-card .brand { font-size: 19px !important; }
.auth-card .form { gap: 16px; margin-top: 22px; }
.auth-card .row { display: block !important; }
.auth-card .row button { width: 100%; min-height: 48px; font-size: 16px; }
.brand-caption { margin: 0 !important; font-size: 12px !important; letter-spacing: .04em !important; color: var(--ui-muted) !important; }
.topbar-status { gap: 10px; }
.logout-button { min-height: 36px; padding: 6px 14px; }

/* ---------- desktop rail ---------- */
.terminal-rail, .market-sidebar { background: transparent !important; border: 0 !important; box-shadow: none !important; }
.rail-nav { gap: 4px !important; }
.rail-label { color: var(--ui-faint) !important; font-size: 11px; letter-spacing: .12em; }
.rail-nav a { border-radius: var(--ui-radius-sm) !important; border: 1px solid transparent !important; color: var(--ui-muted) !important; background: transparent !important; box-shadow: none !important; padding: 10px 12px !important; font-weight: 600; }
.rail-nav a:hover { color: var(--ui-text) !important; background: var(--ui-surface-2) !important; }
.rail-nav a[aria-current] { color: var(--ui-text) !important; background: var(--ui-surface-2) !important; border-color: var(--ui-line) !important; box-shadow: inset 3px 0 0 var(--ui-brand) !important; }
.nav-glyph { color: var(--ui-brand) !important; opacity: .8; font-variant-numeric: tabular-nums; }
.rail-nav a:first-of-type { font-size: 15px; }
.rail-footer { color: var(--ui-faint) !important; }
.rail-dot { background: var(--ui-brand) !important; box-shadow: 0 0 0 4px var(--ui-brand-soft) !important; }

/* ---------- live module: emphasised ---------- */
#live-workspace { border-color: #2ee6b640 !important; background: linear-gradient(180deg, #2ee6b60a, transparent 220px), var(--ui-surface) !important; }
.live-status { border-radius: var(--ui-radius-sm) !important; background: var(--ui-surface-2) !important; border: 1px solid var(--ui-line) !important; padding: 14px 16px !important; }
.live-status.is-enabled { border-color: #2ee6b666 !important; background: #2ee6b612 !important; }
.live-status.is-waiting { border-color: #f6b54a55 !important; background: #f6b54a10 !important; }
.live-status-icon { border-radius: 50% !important; box-shadow: none !important; }
.live-status.is-enabled .live-status-icon { background: var(--ui-up) !important; box-shadow: 0 0 0 5px #2ee6b62a !important; }
.cloud-status-copy strong { font-size: 18px; }
.live-readiness span { border-radius: 999px !important; padding: 4px 10px !important; background: var(--ui-surface-2) !important; border: 1px solid var(--ui-line) !important; }
.live-readiness span.ready { color: var(--ui-up) !important; border-color: #2ee6b655 !important; }
.live-readiness i { border-radius: 50%; }
.live-metrics > *, .live-kpis > *, .execution-focus-grid > * { border-color: var(--ui-line) !important; }
.live-actions button:first-child, .real-acknowledgement + .live-actions button:first-child { font-size: 15px; }
.real-acknowledgement { padding: 12px 14px; border-radius: var(--ui-radius-sm); background: var(--ui-surface-2); border: 1px solid var(--ui-line); color: var(--ui-text) !important; display: flex; gap: 10px; align-items: center; }
.pixel-kpi, .workbench-kpi { border-radius: var(--ui-radius-sm) !important; box-shadow: none !important; background: var(--ui-surface-2) !important; border: 1px solid var(--ui-line) !important; }
.pixel-meter { border-radius: 999px; overflow: hidden; }

/* ---------- tables ---------- */
.table-wrap, .trade-table, .real-orders-table, .history-cache-table, .daily-results-table { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--ui-radius-sm); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th { color: var(--ui-muted) !important; font-weight: 600; background: var(--ui-surface-2) !important; white-space: nowrap; }
th, td { border-color: var(--ui-line) !important; padding: 10px 12px !important; }
tbody tr:hover td { background: #ffffff05; }

.cloud-live .real-orders-table { block-size: auto !important; max-block-size: 420px; }
@media (max-width: 820px) { .cloud-live .real-orders-table { max-block-size: 60vh; } }

/* backtest tabs */
.backtest-detail-tabs, [role="tablist"] { gap: 6px !important; border: 0 !important; background: transparent !important; box-shadow: none !important; padding: 0 !important; }
.backtest-detail-tabs button, [role="tab"] { background: var(--ui-surface-2) !important; color: var(--ui-muted) !important; border: 1px solid var(--ui-line) !important; }
.backtest-detail-tabs button.active, [role="tab"][aria-selected="true"] { background: var(--ui-brand-soft) !important; color: var(--ui-brand) !important; border-color: #2ee6b666 !important; }
.workbench-empty { border-radius: var(--ui-radius-sm) !important; border-color: var(--ui-line-strong) !important; color: var(--ui-muted); }

/* quick range buttons */
.workbench-presets, .ui-quick-times { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.workbench-presets button, .ui-quick-times button { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.ui-quick-times { margin-top: 6px; }

/* ---------- layout: forms line up ---------- */
.cloud-settings-fields, .workbench-fund-fields, .workbench-range, .cloud-diagnostic-grid { align-items: end; }
.cloud-settings-fields > label, .workbench-fund-fields > label, .workbench-range > label { align-self: end; }

/* ---------- mobile ---------- */
@media (max-width: 820px), (max-width: 1023px) and (pointer: coarse) {
  html { scroll-padding-top: 8px; scroll-padding-bottom: 90px; }
  .shell { padding: 12px 12px calc(92px + env(safe-area-inset-bottom)) !important; }
  .topbar { padding-top: env(safe-area-inset-top); }
  .brand { font-size: 17px !important; }
  .brand-caption { display: none; }
  .workspace { display: block !important; }
  .market-sidebar, .terminal-rail { display: none !important; }
  .card, .terminal-module { padding: 14px !important; }
  .workbench-head h1, .workbench-head h2 { font-size: 20px; }
  /* bottom tab bar */
  .mobile-nav { position: fixed !important; left: 0; right: 0; bottom: 0; top: auto !important; z-index: 60 !important; display: grid !important;
    grid-template-columns: repeat(4, 1fr); gap: 0 !important; margin: 0 !important; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)) !important;
    background: #0b1019f2 !important; border: 0 !important; border-top: 1px solid var(--ui-line) !important; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); overflow: visible !important; }
  .mobile-nav a { display: flex !important; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 52px !important; padding: 4px 2px !important;
    border: 0 !important; border-radius: 10px !important; background: transparent !important; box-shadow: none !important; color: var(--ui-muted) !important; font-size: 11px !important; font-weight: 600; text-decoration: none; white-space: nowrap; }
  .mobile-nav a svg { width: 22px; height: 22px; stroke: currentColor; }
  .mobile-nav a[aria-current] { color: var(--ui-brand) !important; background: var(--ui-brand-soft) !important; }
  .mobile-nav a:first-child:not([aria-current]) { color: var(--ui-muted) !important; border: 0 !important; background: transparent !important; }

  /* every form field full width, two-column grids aligned on the input baseline */
  .cloud-diagnostic-grid { display: grid !important; grid-template-columns: 1fr !important; gap: 12px !important; }
  .cloud-settings-fields, .workbench-fund-fields, .workbench-range, .simulation-summary, .workbench-market-inputs {
    display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 12px !important; align-items: end !important; }
  .cloud-settings-fields > label, .workbench-fund-fields > label { min-width: 0; }
  .cloud-field-strategy, .cloud-field-clock, .workbench-range > label { grid-column: 1 / -1 !important; }
  label { width: 100%; }
  input, select { font-size: 16px !important; } /* prevents iOS zoom-on-focus */
  input[type="datetime-local"] { min-height: 46px; }

  /* button groups: equal, wrap cleanly */
  .live-actions { display: grid !important; grid-template-columns: 1fr !important; gap: 10px !important; }
  .live-actions .action-heading { font-size: 13px; color: var(--ui-muted); font-weight: 600; }
  .live-actions > .row > button:first-child { grid-column: 1 / -1; min-height: 52px; font-size: 16px; }
  .cloud-extension-actions, .simulation-controls, .report-controls, .workbench-launch, .row {
    display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px !important; align-items: stretch; }
  .cloud-extension-actions > *, .simulation-controls > *, .report-controls > *, .workbench-launch > *, .row > * { width: 100%; min-width: 0; margin: 0 !important; }
  .row > button:last-of-type:nth-of-type(odd), .simulation-controls > button:last-of-type:nth-of-type(odd), .cloud-extension-actions > button:last-of-type:nth-of-type(odd) { grid-column: 1 / -1; }
  .live-actions > .row > button:last-of-type:nth-of-type(odd) { grid-column: auto; }
  .workbench-launch > button:first-child { grid-column: 1 / -1; min-height: 50px; font-size: 16px; }
  .workbench-launch > a, .workbench-launch > button.link { justify-self: center; }
  .row > .muted, .row > span, .row > small, .row > label { grid-column: 1 / -1; }
  .workbench-presets { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workbench-presets > small { grid-column: 1 / -1; }
  .workbench-presets button { padding: 6px 4px; font-size: 13px; white-space: nowrap; }
  .workbench-tab-content { min-height: 0 !important; }
  .real-orders, .real-orders > *, .report-failures, .report-failures > * { min-height: 0 !important; }
  /* nested modules: less indentation */
  .terminal-module .terminal-module, .module-details, fieldset { padding: 12px !important; margin-left: 0 !important; margin-right: 0 !important; }
  .module-details > .module-body, .terminal-module .terminal-module > .module-body { padding: 4px 0 0 !important; }
  .module-summary { padding: 4px 0 !important; }
  .ui-quick-times { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  button { min-height: 44px; }
  .notice { flex-wrap: wrap; }
  .live-readiness { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px !important; }
  .live-readiness span { justify-content: space-between; display: flex; }
  .live-metrics, .live-kpis, .execution-focus-grid { gap: 10px !important; }
  .cloud-live-reservations { flex-wrap: wrap; gap: 8px; }
  .compact-note { white-space: normal !important; }
  .cloud-inline-status { white-space: normal !important; overflow: visible !important; text-overflow: clip !important; }
  .table-wrap { margin: 0 -2px; }
  table { font-size: 12.5px; }
  th, td { padding: 9px 10px !important; }
  .chart-host { border-radius: var(--ui-radius-sm); overflow: hidden; }
  .simulation-alerts { bottom: calc(76px + env(safe-area-inset-bottom)) !important; top: auto !important; }
}
@media (max-width: 380px) {
  .cloud-settings-fields, .workbench-fund-fields, .simulation-summary { grid-template-columns: 1fr !important; }
  .workbench-presets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { button { transition: none; } }

/* The previous theme forces square corners through a high-specificity :is() list. */
html body :is(.card,button,input,select,textarea,.notice,.session-status,.real-config,.execution-panel,.reference-context,.real-orders,.simulation-active,.simulation-alert,.backtest-progress,.terminal-module,.module-details,.cloud-extension,fieldset,.live-status,.pixel-kpi,.workbench-kpi,.workbench-empty) { border-radius: var(--ui-radius-sm) !important; }
html body :is(.card,.terminal-module) { border-radius: var(--ui-radius) !important; }
html body :is(.simulation-summary,.daily-overview) > div { border-radius: var(--ui-radius-sm) !important; }
html body :is(.pill,.module-badge,.live-readiness span) { border-radius: 999px !important; }
html body .mobile-nav a { border-radius: 10px !important; }
html body input[type="checkbox"] { border-radius: 4px !important; }
html body .auth-card { border-radius: 18px !important; padding: 30px 24px !important; }

/* WebKit sizes <select> to its longest option; keep fields inside their column. */
label { grid-template-columns: minmax(0, 1fr); }
select, input, textarea { max-width: 100%; min-width: 0; }
@media (max-width: 820px), (max-width: 1023px) and (pointer: coarse) {
  td .row, th .row { display: flex !important; gap: 6px !important; }
  td .row > * { width: auto !important; }
}
select { overflow: hidden; }
@media (max-width: 820px), (max-width: 1023px) and (pointer: coarse) { .shell { overflow-x: clip; } }
.pixel-kpi { padding: 16px !important; }
@media (max-width: 520px) { .pixel-kpi { padding: 14px 12px !important; } }

/* ---------- mobile: flatten nesting so content uses the screen width ---------- */
@media (max-width: 820px), (max-width: 1023px) and (pointer: coarse) {
  html body .shell { padding-left: 6px !important; padding-right: 6px !important; }
  html body .grid { gap: 10px !important; }
  /* level 1: the four workspace cards */
  html body .grid > .card, html body .grid > .terminal-module { padding: 12px 10px !important; }
  html body .workbench-body, html body .cloud-live-report-body, html body .health-body, html body .module-body,
  html body .live-console, html body .report-fold-body { padding-left: 0 !important; padding-right: 0 !important; }
  /* level 2: sections inside a card become flat, separated by rules */
  html body .card .module-details, html body .card .terminal-module, html body .card .real-report, html body .card .real-orders,
  html body .card .collapsible-module, html body .card .execution-panel, html body .card .connection-panel {
    padding-left: 0 !important; padding-right: 0 !important; border-left: 0 !important; border-right: 0 !important;
    border-radius: 0 !important; background: transparent !important; box-shadow: none !important; margin-left: 0 !important; margin-right: 0 !important; }
  html body .card .module-details > .module-summary, html body .card .terminal-module > .module-summary { padding: 10px 2px !important; }
  /* level 3: small boxed groups keep a frame, with tight padding */
  html body .card :is(fieldset, .session-status, .reference-context, .cloud-extension, .live-status, .execution-focus, .simulation-active, .history-cache-summary) {
    padding: 10px !important; margin-left: 0 !important; margin-right: 0 !important; }
  html body .card .card .card, html body .card .pixel-health { padding: 10px !important; }
  html body .pixel-kpi { padding: 12px 10px !important; }
  html body .live-kpis, html body .health-grid { gap: 8px !important; }
  html body .real-orders-table td, html body .real-orders-table th { padding-left: 8px !important; padding-right: 8px !important; }
}
@media (max-width: 820px), (max-width: 1023px) and (pointer: coarse) {
  html body :is(.workbench-head, .report-toolbar, .health-head, .real-orders-head, .module-summary, .history-head) { padding-left: 2px !important; padding-right: 2px !important; }
  input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
  input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
}
