:root {
  --bg: #080b12;
  --panel: #10141f;
  --panel-2: #131722;
  --line: #2a2e39;
  --text: #edf3fb;
  --muted: #8592a6;
  --green: #089981;
  --red: #f23645;
  --amber: #f0b90b;
  --blue: #2962ff;
  --cyan: #31c8d8;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  background:
    radial-gradient(circle at 16% -20%, rgba(75,141,255,.13), transparent 36%),
    radial-gradient(circle at 95% 0%, rgba(38,199,122,.07), transparent 28%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .16em; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(26px, 4vw, 42px); line-height: 1.05; }
h2 { font-size: 18px; margin-bottom: 0; }

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(440px, 100%); display: grid; gap: 18px; padding: 34px; border: 1px solid var(--line); border-radius: 22px; background: rgba(12,18,29,.94); box-shadow: var(--shadow); }
.brand-mark { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; color: #06100b; background: linear-gradient(145deg, #72ffb2, var(--green)); font-size: 27px; font-weight: 1000; box-shadow: 0 10px 32px rgba(38,199,122,.24); }
.brand-mark.small { width: 38px; height: 38px; border-radius: 11px; font-size: 19px; }

.app-shell { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 20; min-height: 72px; padding: 14px 24px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 20px; background: rgba(7,11,18,.88); backdrop-filter: blur(18px); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand strong { display: block; font-size: 16px; letter-spacing: .08em; }
.brand span { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; letter-spacing: .18em; }
.top-controls { display: flex; align-items: end; gap: 12px; }
.compact-field { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.compact-field select { display: block; min-width: 175px; margin-top: 4px; padding: 8px 30px 8px 10px; }
.status-pill { align-self: center; padding: 8px 11px; border: 1px solid rgba(255,194,71,.3); border-radius: 999px; color: var(--amber); background: rgba(255,194,71,.08); font-size: 10px; font-weight: 900; letter-spacing: .08em; }
.status-pill.live { color: var(--green); border-color: rgba(38,199,122,.35); background: rgba(38,199,122,.09); }
.icon-btn { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 11px; color: var(--muted); background: var(--panel); font-size: 19px; }

.nav-tabs { display: flex; gap: 4px; padding: 10px 24px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.nav-tab { border: 0; border-bottom: 2px solid transparent; padding: 12px 16px; color: var(--muted); background: transparent; font-weight: 750; white-space: nowrap; }
.nav-tab.active { color: var(--text); border-bottom-color: var(--green); }
main { padding: 22px 24px 48px; max-width: 1700px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

.panel { border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(180deg, rgba(16,24,39,.94), rgba(10,16,26,.96)); box-shadow: 0 12px 40px rgba(0,0,0,.16); overflow: hidden; }
.panel-head { min-height: 68px; padding: 16px 18px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); }
.metric-row { display: grid; grid-template-columns: repeat(5, minmax(145px, 1fr)); gap: 12px; margin-bottom: 14px; }
.metric { padding: 15px 16px; border: 1px solid var(--line); border-radius: 14px; background: rgba(13,20,32,.86); }
.metric span { display: block; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.metric strong { display: block; margin-top: 8px; font-size: 20px; }
.metric small { display: block; margin-top: 5px; color: var(--muted); }
.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }
.warning { color: var(--amber) !important; }

.live-grid { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(360px, .8fr); gap: 14px; }
.right-stack { display: grid; align-content: start; gap: 14px; }
.chart-panel { min-height: 720px; background:#131722; }
.chart { height: 620px; width: 100%; }
.small-chart { height: 360px; }
.inline-actions { display: flex; gap: 6px; }
.chip { padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: rgba(8,13,21,.8); font-size: 11px; font-weight: 800; }
.chip.active { color: var(--text); border-color: rgba(75,141,255,.45); background: rgba(75,141,255,.13); }
.legend { display: flex; gap: 18px; padding: 11px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.dot { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; }
.dot.vwap { background: var(--green); }.dot.normal { background: var(--blue); }.dot.aplus { background: var(--amber); }

.signal-panel, .ai-panel { min-height: 250px; }
.signal-body, .ai-body { padding: 18px; }
.signal-state { display: flex; align-items: center; justify-content: space-between; padding: 14px; border: 1px solid rgba(38,199,122,.26); border-radius: 12px; background: rgba(38,199,122,.07); }
.signal-state.blocked { border-color: rgba(255,73,104,.3); background: rgba(255,73,104,.06); }
.signal-state strong { font-size: 18px; }
.signal-state span { color: var(--muted); font-size: 11px; }
.trade-levels { margin: 14px 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.level { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: rgba(6,10,17,.46); }
.level span { display: block; color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.level strong { display: block; margin-top: 5px; font-size: 15px; }
.detail-list { display: grid; gap: 8px; margin: 12px 0; }
.detail { display: flex; justify-content: space-between; gap: 16px; padding-bottom: 7px; border-bottom: 1px dashed rgba(133,146,166,.17); color: var(--muted); font-size: 12px; }
.detail strong { color: var(--text); text-align: right; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { min-height: 40px; border: 1px solid transparent; border-radius: 10px; padding: 10px 14px; font-weight: 850; }
.btn.primary { color: #05100a; background: var(--green); }
.btn.secondary { color: white; background: var(--blue); }
.btn.ghost { color: var(--text); border-color: var(--line); background: transparent; }
.btn.danger { color: white; border-color: rgba(255,73,104,.3); background: rgba(255,73,104,.14); }
.ai-decision { display: inline-flex; padding: 7px 10px; border-radius: 8px; color: var(--amber); background: rgba(255,194,71,.1); font-size: 12px; font-weight: 900; }
.factor-list { margin: 12px 0; padding-left: 18px; color: var(--muted); font-size: 12px; }
.factor-list li { margin: 6px 0; }

.open-trades-panel { margin-top: 14px; }
.empty-state { padding: 28px 18px; color: var(--muted); text-align: center; }
.open-trade { display: grid; grid-template-columns: 1.1fr repeat(5, .8fr) auto; gap: 12px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.open-trade:last-child { border-bottom: 0; }
.open-trade span { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.open-trade strong { display: block; margin-top: 4px; }

.two-column { display: grid; grid-template-columns: minmax(420px, 1fr) minmax(420px, 1fr); gap: 14px; }
.form-grid { padding: 18px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.form-grid label, .login-card label { display: grid; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 750; }
.form-grid .full { grid-column: 1 / -1; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 10px 11px; color: var(--text); background: #080d15; outline: none; }
input:focus, select:focus, textarea:focus { border-color: rgba(75,141,255,.72); box-shadow: 0 0 0 3px rgba(75,141,255,.1); }
select[multiple] { min-height: 72px; }
.form-actions { display: flex; gap: 9px; align-items: center; }
.account-list { padding: 12px; display: grid; gap: 10px; }
.account-card { padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: rgba(7,12,20,.5); }
.account-card.active { border-color: rgba(38,199,122,.48); box-shadow: inset 3px 0 0 var(--green); }
.account-card-head { display: flex; align-items: start; justify-content: space-between; gap: 10px; }
.account-card-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 13px; }
.account-card-grid div { padding: 8px; border-radius: 8px; background: rgba(16,24,39,.78); }
.account-card-grid span { display: block; color: var(--muted); font-size: 9px; text-transform: uppercase; }
.account-card-grid strong { display: block; margin-top: 4px; font-size: 13px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 960px; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; font-size: 12px; }
th { color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; background: rgba(6,10,16,.5); }
.status-tag { display: inline-block; padding: 5px 8px; border-radius: 999px; color: var(--muted); background: rgba(133,146,166,.12); font-size: 10px; font-weight: 900; text-transform: uppercase; }
.status-tag.open { color: var(--blue); background: rgba(75,141,255,.12); }
.status-tag.closed { color: var(--green); background: rgba(38,199,122,.12); }

.performance-grid { grid-template-columns: 1.35fr .65fr; }
#attribution { padding: 18px; display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 90px 1fr 72px; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.bar-track { height: 9px; border-radius: 99px; background: #070b12; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; background: var(--blue); }
.setup-list { padding: 18px; display: grid; gap: 10px; }
.setup-item { display: flex; justify-content: space-between; gap: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: rgba(7,12,20,.5); }
.setup-item span { color: var(--muted); }
.setup-item strong.ready { color: var(--green); }.setup-item strong.todo { color: var(--amber); }
pre { margin: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; color: #b7d0ff; background: #060a10; white-space: pre-wrap; word-break: break-all; }

form-message { min-height: 18px; }
.form-message { color: var(--red); font-size: 12px; }
dialog { width: min(790px, calc(100% - 30px)); max-height: 92vh; padding: 0; border: 1px solid var(--line); border-radius: 16px; color: var(--text); background: var(--panel); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(5px); }
.dialog-card { overflow-y: auto; max-height: 92vh; }
.plan-summary { margin: 16px 18px 0; padding: 12px; border: 1px solid rgba(75,141,255,.28); border-radius: 10px; background: rgba(75,141,255,.07); }
.dialog-card > .form-actions { padding: 0 18px 18px; }

@media (max-width: 1050px) {
  .metric-row { grid-template-columns: repeat(3, 1fr); }
  .live-grid, .two-column, .performance-grid { grid-template-columns: 1fr; }
  .right-stack { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .topbar { align-items: flex-start; padding: 12px; }
  .top-controls { flex-wrap: wrap; justify-content: flex-end; }
  .compact-field select { min-width: 130px; }
  main { padding: 14px 12px 34px; }
  .nav-tabs { padding-left: 10px; }
  .metric-row { grid-template-columns: repeat(2, 1fr); }
  .right-stack { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .chart { height: 390px; }
  .chart-panel { min-height: auto; }
  .open-trade { grid-template-columns: repeat(2, 1fr); }
  .account-card-grid { grid-template-columns: repeat(2, 1fr); }
}

/* v0.2 chart workspace */
.chart-panel-head { align-items: flex-start; }
.chart-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chart-source { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; letter-spacing: .03em; }
.chart-toolbar { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.timeframe-actions { padding-right: 4px; border-right: 1px solid var(--line); }
.chart-stage { position: relative; min-height: 620px; background: #131722; }
.chart-stage .chart { position: relative; z-index: 1; }
.chart-ohlc { position: absolute; z-index: 4; top: 10px; left: 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; max-width: calc(100% - 100px); padding: 7px 9px; border: 1px solid rgba(38,49,66,.72); border-radius: 8px; color: var(--muted); background: rgba(8,14,23,.78); backdrop-filter: blur(7px); pointer-events: none; font-size: 10px; box-shadow: 0 8px 22px rgba(0,0,0,.18); }
.chart-ohlc strong { color: var(--text); font-size: 11px; }
.chart-ohlc b { color: #d7e0ec; font-weight: 800; }
.chart-empty { position: absolute; z-index: 5; inset: 0; display: grid; place-content: center; gap: 8px; padding: 40px; text-align: center; color: var(--muted); background: radial-gradient(circle at center, rgba(19,29,44,.72), rgba(9,15,24,.96)); }
.chart-empty strong { color: var(--text); font-size: 18px; }
.chart-empty span { max-width: 520px; line-height: 1.55; }
.chart-status { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 999px; font-size: 9px; font-weight: 900; letter-spacing: .08em; }
.chart-status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 10px currentColor; }
.chart-status.live { color: var(--green); border-color: rgba(38,199,122,.35); background: rgba(38,199,122,.08); }
.chart-status.stale { color: var(--red); border-color: rgba(255,73,104,.35); background: rgba(255,73,104,.08); }
.chart-status.waiting, .chart-status.demo { color: var(--amber); border-color: rgba(255,194,71,.35); background: rgba(255,194,71,.08); }
.dot.volume { background: #637186; }
.legend-note { margin-left: auto; }
.chart-panel:fullscreen { width: 100vw; height: 100vh; border: 0; border-radius: 0; background: #070b12; }
.chart-panel:fullscreen .chart-stage, .chart-panel:fullscreen .chart { height: calc(100vh - 132px); }
.chart-panel:fullscreen .legend { background: #090f18; }

@media (max-width: 720px) {
  .chart-panel-head { align-items: stretch; }
  .chart-toolbar { justify-content: flex-start; }
  .chart-stage { min-height: 390px; }
  .chart-ohlc { max-width: calc(100% - 24px); gap: 7px; }
  .legend-note { width: 100%; margin-left: 0; }
}


/* v0.4 professional chart treatment */
.chart-panel { border-color:#2a2e39; border-radius:12px; box-shadow:0 18px 48px rgba(0,0,0,.26); }
.chart-panel .panel-head { background:#131722; border-bottom-color:#2a2e39; padding:13px 16px; min-height:66px; }
.chart-panel .eyebrow { color:#787b86; letter-spacing:.12em; }
.chart-panel h2 { font-size:18px; letter-spacing:-.01em; }
.chart-toolbar .chip { min-width:36px; padding:7px 10px; border-color:#363a45; border-radius:6px; color:#b2b5be; background:#1e222d; }
.chart-toolbar .chip:hover { color:#fff; border-color:#434651; background:#252a36; }
.chart-toolbar .chip.active { color:#fff; border-color:#2962ff; background:#2962ff; box-shadow:none; }
.chart-stage { border-left:0; border-right:0; }
.chart-ohlc { top:9px; left:10px; padding:5px 8px; border-color:rgba(54,58,69,.88); border-radius:5px; color:#787b86; background:rgba(19,23,34,.86); box-shadow:none; }
.chart-ohlc strong { color:#d1d4dc; }
.chart-ohlc b { color:#b2b5be; }
.chart-status { border-radius:5px; letter-spacing:.055em; }
.chart-status::before { box-shadow:none; }
.legend { background:#131722; border-top-color:#2a2e39; color:#787b86; padding:10px 16px; }
.legend .dot { border-radius:2px; }
.dot.vwap { background:#f0b90b; }
.dot.normal { background:#2962ff; }
.dot.aplus { background:#f0b90b; }
.dot.volume { background:#787b86; }
.chart-empty { background:#131722; }
.chart-empty strong { color:#d1d4dc; }
.btn:disabled, .chip:disabled { opacity:.52; cursor:not-allowed; }

@media (max-width: 720px) {
  .chart-panel { min-height:auto; }
  .chart-stage, .chart { min-height:430px; height:430px; }
}
