:root {
    --bg: #f3f6f9;
    --panel: #ffffff;
    --ink: #111827;
    --muted: #687386;
    --line: #dfe5ec;
    --navy: #111827;
    --navy-soft: #1f2937;
    --accent: #f59e0b;
    --accent-dark: #d97706;
    --success: #138a58;
    --danger: #c43d3d;
    --shadow: 0 18px 50px rgba(20, 30, 45, 0.08);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, select { font: inherit; }

.topbar {
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px max(20px, calc((100vw - 1180px) / 2));
    background: var(--navy);
    color: white;
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark {
    width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center;
    background: var(--accent); color: var(--navy); font-weight: 900; letter-spacing: -1px;
}
.brand-copy { display: grid; line-height: 1.15; }
.brand-copy strong { font-size: 1rem; }
.brand-copy small { margin-top: 5px; color: #aeb8c6; }

.status-badge, .strategy-tag, .memory-badge {
    border-radius: 999px; padding: 7px 12px; font-size: .78rem; font-weight: 800;
}
.status-offline { background: #2b3442; color: #cbd5e1; }
.status-online { background: rgba(19, 138, 88, .18); color: #8ce0b7; }

.page-shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }
.hero {
    display: grid; grid-template-columns: 1.5fr .65fr; gap: 32px; align-items: end;
    padding: 64px 0 42px;
}
.eyebrow, .step-label { margin: 0 0 8px; font-size: .72rem; letter-spacing: .18em; font-weight: 900; color: var(--accent-dark); }
.hero h1 { margin: 0; font-size: clamp(2.6rem, 7vw, 5.8rem); letter-spacing: -.07em; line-height: .92; max-width: 800px; }
.hero-text { max-width: 690px; color: var(--muted); font-size: 1.05rem; line-height: 1.7; }
.hero-card { background: var(--navy); color: white; border-radius: 22px; padding: 26px; box-shadow: var(--shadow); }
.hero-card p { color: #bbc4d0; line-height: 1.6; margin-bottom: 0; }
.privacy-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: var(--navy); font-weight: 900; margin-bottom: 18px; }

.layout-grid { display: grid; grid-template-columns: 340px 1fr; gap: 22px; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 24px; box-shadow: var(--shadow); }
.panel-heading, .results-heading, .table-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
h2, h3 { margin-top: 0; }
.panel-heading h2 { margin-bottom: 14px; }
.connection-panel { position: sticky; top: 98px; }
.connection-panel > div > p { color: var(--muted); line-height: 1.55; }
.broker-logo { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: #5f2eea; color: white; font-weight: 900; font-size: 1.25rem; }

.button { border: 0; border-radius: 12px; min-height: 48px; padding: 0 18px; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; font-weight: 800; cursor: pointer; transition: .2s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.button-full { width: 100%; }
.button-primary { background: var(--navy); color: white; }
.button-secondary { background: #eef2f6; color: var(--ink); }
.button-accent { background: var(--accent); color: var(--navy); font-size: 1rem; margin-top: 18px; }
.button-accent:hover { background: #ffb52e; }

.connected-user { display: flex; align-items: center; gap: 12px; border: 1px solid #cfeadd; border-radius: 14px; padding: 14px; margin-bottom: 12px; background: #f2fbf7; }
.connected-user div { display: grid; gap: 3px; }
.connected-user small { color: var(--muted); }
.connected-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 5px rgba(19,138,88,.12); }

.info-list { border-top: 1px solid var(--line); margin-top: 22px; padding-top: 18px; display: grid; gap: 13px; }
.info-list div { display: flex; align-items: center; gap: 10px; }
.info-list span { width: 26px; height: 26px; border-radius: 8px; background: #eef2f6; display: grid; place-items: center; font-size: .75rem; font-weight: 900; }
.info-list p { margin: 0; color: var(--muted); font-size: .9rem; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.field { display: grid; gap: 8px; }
.field-wide { margin-bottom: 20px; }
label { font-size: .86rem; font-weight: 800; }
input, select { width: 100%; min-height: 48px; border: 1px solid #ccd5df; border-radius: 11px; padding: 0 13px; background: white; color: var(--ink); outline: none; }
input:focus, select:focus { border-color: var(--accent-dark); box-shadow: 0 0 0 3px rgba(245,158,11,.13); }
.field small { color: var(--muted); }
.instrument-field { position: relative; }
.autocomplete { position: absolute; top: 78px; left: 0; right: 0; z-index: 10; background: white; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 18px 40px rgba(15,23,42,.14); max-height: 330px; overflow: auto; }
.instrument-option { padding: 12px 14px; cursor: pointer; border-bottom: 1px solid #edf1f5; }
.instrument-option:last-child { border-bottom: 0; }
.instrument-option:hover { background: #f8fafc; }
.instrument-option strong, .instrument-option small { display: block; }
.instrument-option small { margin-top: 3px; color: var(--muted); }
.strategy-tag { background: #fff5dc; color: #9a5d00; }
.strategy-note { margin-top: 20px; border-left: 4px solid var(--accent); background: #fffaf0; padding: 14px; border-radius: 0 10px 10px 0; color: #5b6574; line-height: 1.55; }

.notice { margin-bottom: 20px; border-radius: 12px; padding: 14px 16px; font-weight: 700; }
.notice-success { background: #eaf8f1; color: #086b42; border: 1px solid #bde7d1; }
.notice-error { background: #fff0f0; color: #a12626; border: 1px solid #f2c6c6; }

.results-section { margin: 34px 0 70px; }
.results-heading { margin-bottom: 18px; align-items: center; }
.results-heading h2 { margin-bottom: 5px; }
.results-heading p { margin: 0; color: var(--muted); }
.memory-badge { background: #eaf8f1; color: #087148; }
.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.metric small { color: var(--muted); font-weight: 700; }
.metric strong { display: block; font-size: 1.6rem; margin-top: 7px; letter-spacing: -.03em; }
.metric-positive strong { color: var(--success); }
.metric-negative strong { color: var(--danger); }
.results-grid { display: grid; grid-template-columns: 1.6fr .7fr; gap: 18px; margin-bottom: 18px; }
.chart-panel canvas { width: 100%; background: #fbfcfd; border-radius: 12px; }
.summary-list { display: grid; gap: 0; }
.summary-row { display: flex; justify-content: space-between; gap: 15px; padding: 12px 0; border-bottom: 1px solid #edf1f5; }
.summary-row span { color: var(--muted); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 850px; }
th, td { text-align: left; padding: 13px 11px; border-bottom: 1px solid #edf1f5; white-space: nowrap; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
td { font-size: .88rem; }
.pnl-positive { color: var(--success); font-weight: 800; }
.pnl-negative { color: var(--danger); font-weight: 800; }

footer { background: var(--navy); color: white; text-align: center; padding: 30px 18px; }
footer p { color: #aeb8c6; margin-bottom: 0; }
.hidden { display: none !important; }

@media (max-width: 900px) {
    .hero { grid-template-columns: 1fr; padding-top: 44px; }
    .hero-card { max-width: 460px; }
    .layout-grid { grid-template-columns: 1fr; }
    .connection-panel { position: static; }
    .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .results-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
    .topbar { min-height: 68px; padding: 10px 16px; }
    .brand-mark { width: 42px; height: 42px; }
    .brand-copy small { display: none; }
    .status-badge { max-width: 120px; text-align: center; }
    .page-shell { width: min(100% - 22px, 1180px); }
    .hero { padding: 38px 2px 30px; }
    .hero h1 { font-size: 3.15rem; }
    .panel { border-radius: 16px; padding: 18px; }
    .form-grid { grid-template-columns: 1fr; gap: 15px; }
    .metrics-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
    .metric { padding: 14px; }
    .metric strong { font-size: 1.25rem; }
    .results-heading { align-items: flex-start; flex-direction: column; }
}
