:root {
  --ink: #12233f;
  --muted: #64748b;
  --canvas: #f3f7fb;
  --surface: #ffffff;
  --line: #dce5ef;
  --navy: #112a46;
  --blue: #2563eb;
  --green: #0f9f6e;
  --green-soft: #e7f8f1;
  --red: #dc3545;
  --red-soft: #fff0f1;
  --amber: #d97706;
  --shadow: 0 12px 32px rgba(30, 55, 90, .08);
}

html { font-size: 15px; }
body { margin: 0; background: var(--canvas); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
.mode-banner { position: sticky; top: 0; z-index: 1040; padding: .58rem 1rem; text-align: center; font-size: .82rem; font-weight: 800; letter-spacing: .05em; }
.mode-safe { color: #076344; background: #dff8ef; border-bottom: 1px solid #bdebdc; }
.mode-live { color: #fff; background: #b91c1c; animation: pulse-live 2s infinite; }
@keyframes pulse-live { 50% { background: #dc2626; } }
.app-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.navbar { min-height: 72px; }
.navbar-brand { display: flex; align-items: center; gap: .7rem; color: var(--navy); font-weight: 800; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: linear-gradient(145deg, #1f4f7b, #0f8f75); color: #fff; font-size: .8rem; box-shadow: 0 8px 18px rgba(24, 91, 115, .25); }
.nav-link { color: #4a5c73; font-weight: 600; border-radius: 9px; padding: .55rem .75rem !important; }
.nav-link:hover { color: var(--blue); background: #eef4ff; }
.page-shell { padding-top: 2.2rem; padding-bottom: 3rem; }
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.page-heading h1 { margin: .1rem 0 .35rem; font-size: clamp(2rem, 4vw, 3.2rem); letter-spacing: -.045em; font-weight: 800; }
.page-heading p:last-child { margin: 0; color: var(--muted); }
.eyebrow { margin: 0; color: #66809a; font-size: .72rem; font-weight: 800; letter-spacing: .13em; }
.connection-pill { display: flex; align-items: center; gap: .8rem; min-width: 205px; padding: .75rem 1rem; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.connection-pill div { display: flex; flex-direction: column; }
.connection-pill small { color: var(--muted); font-size: .65rem; font-weight: 700; letter-spacing: .08em; }
.connection-pill strong { font-size: 1rem; }
.status-dot { width: 12px; height: 12px; border-radius: 50%; box-shadow: 0 0 0 5px rgba(15, 159, 110, .12); }
.is-good .status-dot { background: var(--green); }
.is-bad .status-dot { background: var(--red); box-shadow: 0 0 0 5px rgba(220, 53, 69, .12); }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1rem; }
.metric-card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.metric-card { display: flex; flex-direction: column; min-height: 135px; padding: 1.15rem 1.25rem; }
.metric-card > span { color: var(--muted); font-size: .82rem; font-weight: 650; }
.metric-card > strong { margin: .65rem 0 .15rem; color: var(--navy); font-size: clamp(1.4rem, 2.4vw, 2rem); letter-spacing: -.035em; }
.metric-card strong small { color: var(--muted); font-size: .72rem; letter-spacing: 0; }
.metric-card em { margin-top: auto; color: #7a8ca1; font-size: .72rem; font-style: normal; }
.accent-card { background: linear-gradient(155deg, #fff, #f2fbf8); }
.help { display: inline-grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; background: #e7edf4; color: #4c647c; font-size: .67rem; cursor: help; }
.dashboard-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 1rem; }
.panel { padding: 1.4rem; }
.panel h2 { margin: .15rem 0 0; font-size: 1.4rem; font-weight: 800; }
.panel h2 small { color: var(--muted); font-size: .72rem; }
.panel-title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.robot-panel { min-height: 285px; background: linear-gradient(145deg, #102943, #174266); color: #fff; border: 0; overflow: hidden; position: relative; }
.robot-panel::after { content: ""; position: absolute; width: 240px; height: 240px; border: 44px solid rgba(255,255,255,.035); border-radius: 50%; right: -80px; bottom: -120px; }
.robot-panel .eyebrow { color: #a9c9dd; }
.robot-panel h2 { font-size: 2rem; }
.robot-orb { display: grid; place-items: center; width: 60px; height: 60px; border-radius: 20px; font-size: 1.3rem; }
.orb-running { color: #b6ffe6; background: rgba(18, 184, 134, .22); border: 1px solid rgba(182, 255, 230, .25); }
.orb-stopped { color: #d8e4ee; background: rgba(255,255,255,.08); }
.robot-speech { position: relative; z-index: 1; margin: 1.5rem 0; max-width: 630px; color: #e7f1f8; font-size: 1.08rem; line-height: 1.65; }
.action-row { position: relative; z-index: 2; display: flex; flex-wrap: wrap; gap: .75rem; }
.btn { border-radius: 10px; padding: .68rem 1rem; font-weight: 750; }
.btn-start { color: #073f2d; background: #89efc9; border: 0; }
.btn-start:hover { background: #b0f7dc; }
.btn-stop { color: #fff; background: #d97706; border: 0; }
.btn-emergency { color: #fff; background: transparent; border: 1px solid rgba(255,255,255,.35); }
.btn-emergency:hover { color: #fff; background: rgba(220,53,69,.85); }
.price-stack { display: flex; flex-direction: column; text-align: right; }
.price-stack strong { font-size: 1.45rem; }
.price-stack span { color: var(--muted); font-size: .72rem; }
.indicator-row { display: grid; grid-template-columns: repeat(3, 1fr); margin: 1.4rem 0; padding: 1rem 0; border-block: 1px solid var(--line); }
.indicator-row div { display: flex; flex-direction: column; gap: .25rem; padding-inline: .75rem; border-right: 1px solid var(--line); }
.indicator-row div:last-child { border-right: 0; }
.indicator-row span { color: var(--muted); font-size: .75rem; }
.decision-details { color: #43566c; }
.decision-details summary { color: var(--blue); font-weight: 700; cursor: pointer; }
.decision-details ul { margin: 1rem 0 0; padding-left: 1.2rem; }
.direction-badge { padding: .35rem .65rem; border-radius: 8px; background: #e8f1ff; color: #2459a9; font-size: .75rem; font-weight: 800; }
.empty-state { display: grid; place-items: center; min-height: 145px; text-align: center; color: var(--muted); }
.empty-state span { color: #9eb1c4; font-size: 2rem; }
.empty-state p { max-width: 350px; }
.position-list { margin: 1rem 0; }
.position-list div { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem 0; border-bottom: 1px solid #edf1f5; }
.position-list dt { color: var(--muted); font-weight: 500; }
.position-list dd { margin: 0; font-weight: 750; }
.health-list { list-style: none; margin: 1.2rem 0 0; padding: 0; }
.health-list li { display: flex; align-items: center; gap: .8rem; padding: .7rem 0; border-bottom: 1px solid #edf1f5; }
.health-list li:last-child { border: 0; }
.health-list div { display: flex; flex-direction: column; }
.health-list small { color: var(--muted); }
.health-icon { display: grid; place-items: center; flex: 0 0 28px; width: 28px; height: 28px; border-radius: 50%; font-weight: 800; }
.health-icon.ok { color: #087657; background: var(--green-soft); }
.health-icon.bad { color: #a51c2b; background: var(--red-soft); }
.health-icon.wait { color: #9a5b04; background: #fff4dd; }
.log-preview { margin-top: 1rem; }
.log-preview a { color: var(--blue); font-weight: 700; text-decoration: none; }
.timeline { margin-top: 1rem; }
.timeline > div { display: grid; grid-template-columns: 55px 14px 1fr; gap: .55rem; align-items: start; min-height: 38px; }
.timeline time { color: var(--muted); font-size: .78rem; font-weight: 700; }
.timeline-dot { width: 8px; height: 8px; margin-top: .28rem; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.timeline p { margin: 0 0 .65rem; color: #3d526a; }
.soft-alert { color: #234b77; background: #eaf3ff; border-color: #cfe2ff; border-radius: 13px; }
.critical-alert { border-radius: 13px; }
.data-panel { overflow: hidden; }
.data-table { margin: 0; }
.data-table th { color: var(--muted); background: #f7f9fc; font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; }
.data-table td, .data-table th { padding: .85rem 1rem; vertical-align: middle; }
.settings-grid { display: grid; grid-template-columns: 230px 1fr; gap: 1rem; }
.settings-nav { position: sticky; top: 3.7rem; align-self: start; }
.settings-nav a { display: block; padding: .6rem .75rem; color: var(--muted); text-decoration: none; border-radius: 8px; font-weight: 650; }
.settings-nav a:hover { color: var(--blue); background: #edf4ff; }
.setting-section { scroll-margin-top: 5rem; margin-bottom: 1rem; }
.form-label { color: #344a62; font-weight: 700; }
.form-control, .form-select { min-height: 43px; border-color: #cdd9e5; border-radius: 9px; }
.danger-zone { border-color: #f0b6bc; background: #fffafb; }
.connection-choice { display: flex; flex-direction: column; min-height: 84px; padding: 1rem; border: 1px solid var(--line); border-radius: 12px; background: #f7f9fc; color: var(--muted); }
.connection-choice strong { color: #344a62; }
.connection-choice span { margin-top: .25rem; font-size: .82rem; }
.connection-choice.active { border-color: #73c9ad; background: var(--green-soft); box-shadow: inset 0 0 0 1px rgba(15, 159, 110, .12); }
.connection-choice.active strong { color: #087657; }
.connection-choice.live-choice { border-color: #ed9aa3; background: var(--red-soft); }
.connection-choice.live-choice strong { color: #a51c2b; }
.setting-section details summary { color: var(--blue); font-weight: 750; cursor: pointer; }
.wizard-shell { max-width: 980px; margin: 0 auto; }
.wizard-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; }
.wizard-step { padding: 1rem; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.wizard-number { display: grid; place-items: center; width: 30px; height: 30px; margin-bottom: .65rem; border-radius: 9px; color: #fff; background: var(--navy); font-weight: 800; }
.wizard-step h3 { font-size: 1rem; font-weight: 800; }
.wizard-step p { margin: 0; color: var(--muted); font-size: .82rem; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.stat-card { padding: 1.2rem; }
.stat-card span { color: var(--muted); font-size: .78rem; }
.stat-card strong { display: block; margin-top: .35rem; font-size: 1.7rem; }
.footer-note { padding-top: 1.5rem; padding-bottom: 2rem; color: #6b7c90; font-size: .78rem; text-align: center; }
.chart-shell { min-height: 250px; padding: 1rem; background: linear-gradient(180deg, #f7fbff, #fff); border-radius: 12px; }
.equity-chart { width: 100%; height: 230px; }
.equity-chart .grid { stroke: #dfe8f1; stroke-width: 1; }
.equity-chart .line { fill: none; stroke: #167c68; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.account-body { min-height: 100vh; background: radial-gradient(circle at top, #e4f4f1 0, #eef4fa 36%, #dce7f2 100%); }
.account-shell { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; }
.account-card { width: min(100%, 460px); padding: 2rem; border: 1px solid rgba(195, 211, 226, .9); border-radius: 22px; background: rgba(255, 255, 255, .96); box-shadow: 0 24px 65px rgba(30, 55, 90, .16); }
.account-card h1 { margin: 1.7rem 0 .45rem; color: var(--navy); font-size: 1.75rem; font-weight: 800; letter-spacing: -.03em; }
.account-brand { display: flex; align-items: center; gap: .75rem; }
.account-brand div { display: flex; flex-direction: column; }
.account-brand strong { color: var(--navy); font-size: 1.05rem; }
.account-brand small { color: var(--muted); }
.account-form { display: grid; gap: 1rem; margin-top: 1.4rem; }
.account-link { display: block; margin-top: 1.1rem; color: var(--blue); text-align: center; font-weight: 700; text-decoration: none; }
.dropdown-menu form { margin: 0; }

@media (max-width: 992px) {
  .metric-grid, .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-nav { position: static; display: flex; flex-wrap: wrap; }
  .wizard-steps { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  html { font-size: 14px; }
  .page-shell { padding-top: 1.25rem; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .connection-pill { width: 100%; }
  .metric-grid, .stat-grid, .wizard-steps { grid-template-columns: 1fr; }
  .action-row form, .action-row .btn { width: 100%; }
  .panel { padding: 1.1rem; }
  .indicator-row div { padding-inline: .45rem; }
}
