:root {
  --bg: #0b0f14; --panel: #11161d; --panel-2: #161c25; --line: #222b37; --line-2: #2d3846;
  --text: #e8edf3; --muted: #8a96a6; --accent: #9be36d; --accent-ink: #0d1408;
  --red: #f0806f; --amber: #f3c46b; --blue: #7fb6f0; --radius: 14px;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.25);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: radial-gradient(1200px 600px at 10% -10%, #15202c 0%, var(--bg) 55%); color: var(--text);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif; min-height: 100vh; }
.hidden { display: none !important; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.01em; }
h2 { font-size: 18px; } h3 { font-size: 15px; } h4 { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 14px 0 8px; font-weight: 600; }
.muted { color: var(--muted); } .small { font-size: 12px; } .strong { font-weight: 600; } .error { color: var(--red); min-height: 1em; }
.long { color: var(--accent); } .short { color: var(--red); }
code { font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--blue); word-break: break-all; }

.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; padding: 10px 18px;
  background: rgba(11,15,20,.82); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; }
.logo-mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; font-size: 12px; font-weight: 800;
  background: linear-gradient(135deg, var(--accent), #4fc3a1); color: var(--accent-ink); }
.logo-mark.big { width: 48px; height: 48px; font-size: 18px; border-radius: 12px; margin-bottom: 6px; }
.badges { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .04em;
  border: 1px solid var(--line-2); background: var(--panel); color: var(--muted); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--accent); border-color: rgba(155,227,109,.35); background: rgba(155,227,109,.08); }
.badge.warn { color: var(--amber); border-color: rgba(243,196,107,.35); background: rgba(243,196,107,.08); }
.badge.info { color: var(--blue); border-color: rgba(127,182,240,.35); background: rgba(127,182,240,.08); }

.container { max-width: 1160px; margin: 0 auto; padding: 18px 18px 40px; display: flex; flex-direction: column; gap: 16px; }
.card { background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.grid { display: grid; gap: 16px; } .two-col { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); } .grid.tight { gap: 0 18px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }

.hero { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.kpi-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.kpi-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }

.btn { font: inherit; font-weight: 600; border-radius: 10px; padding: 9px 16px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); cursor: pointer; transition: filter .15s, transform .05s; }
.btn:hover { filter: brightness(1.12); } .btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; color: var(--red); border-color: rgba(240,128,111,.5); }
.btn.lg { padding: 11px 22px; font-size: 15px; } .btn.sm { padding: 5px 12px; font-size: 12px; } .btn.block { width: 100%; }

.keybox { background: #0a0e13; border: 1px dashed var(--line-2); border-radius: 10px; padding: 10px 12px; margin-top: 8px; }
.table, table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
tbody tr:hover td { background: rgba(255,255,255,.02); }
.scroll-x { overflow-x: auto; }

.settings .section { border-top: 1px solid var(--line); padding: 18px 0 6px; }
.settings .section:first-of-type { border-top: 0; padding-top: 4px; }
.section-title { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 12px; }
.section-title span { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: rgba(155,227,109,.12); color: var(--accent); font-size: 12px; }
.fields { display: grid; gap: 12px; } .fields.two { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); } .fields.three { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 600; }
label em { font-style: normal; font-weight: 400; opacity: .75; }
label.narrow { max-width: 260px; margin-top: 10px; }
input, select { font: inherit; font-size: 14px; color: var(--text); background: #0a0e13; border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; width: 100%; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(155,227,109,.15); }
.hint { color: var(--muted); font-size: 12px; margin: 10px 0 0; }

.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border: 1px solid var(--line-2); border-radius: 12px; background: #0a0e13; margin-bottom: 12px; }
.seg label { flex-direction: row; cursor: pointer; margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { padding: 7px 14px; border-radius: 8px; color: var(--muted); font-size: 13px; font-weight: 600; transition: background .15s, color .15s; }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); }
.leg { background: rgba(255,255,255,.015); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
.leg-title { font-weight: 700; font-size: 13px; margin-bottom: 8px; }
.leg .seg { margin-bottom: 0; }

.switch { flex-direction: row; align-items: center; gap: 10px; margin-top: 12px; color: var(--text); font-size: 13px; font-weight: 500; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { flex: none; width: 38px; height: 22px; border-radius: 999px; background: var(--line-2); position: relative; transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }

.savebar { position: sticky; bottom: 10px; display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 16px; padding: 10px 12px;
  background: rgba(17,22,29,.92); backdrop-filter: blur(8px); border: 1px solid var(--line-2); border-radius: 12px; }

.banner { padding: 12px 16px; border-radius: 12px; border: 1px solid rgba(243,196,107,.4); color: var(--amber); background: rgba(243,196,107,.08); }
.logs { max-height: 360px; overflow: auto; font: 12px/1.5 ui-monospace, Menlo, monospace; }
.log { padding: 6px 2px; border-bottom: 1px solid var(--line); } .log time { color: var(--muted); margin-right: 8px; }
.log.trade { color: var(--blue); } .log.warn { color: var(--amber); } .log.error { color: var(--red); }
footer { text-align: center; padding-top: 6px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; align-items: stretch; text-align: left;
  background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); border-radius: 18px; padding: 28px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 20px; } .login-card p { margin: 0; }

@media (max-width: 720px) {
  .container { padding: 12px 10px 30px; gap: 12px; }
  .card { padding: 14px; border-radius: 12px; }
  .kpis { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi { padding: 12px; } .kpi-value { font-size: 17px; }
  .hero-actions { width: 100%; } .hero-actions .btn { flex: 1; }
  .topbar { padding: 8px 10px; } .badges { order: 3; width: 100%; }
  .seg.four { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .seg.four span { display: block; text-align: center; }
  label.narrow { max-width: none; }
}
.fields > label { justify-content: flex-end; }
.grid > *, .card, .container > * { min-width: 0; }
.seg.four label { display: block; }
@media (max-width: 720px) { .topbar .badges { order: 3; flex-basis: 100%; } .seg.four span { width: 100%; } }
.scroll-x { max-width: 100%; }
html, body { overflow-x: hidden; }
.two-col { grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); }
.scroll-x { overflow-x: auto; width: 100%; }
.grid > div { min-width: 0; }
.trader-row { display: flex; gap: 8px; flex-wrap: wrap; }
.trader-row input { flex: 1 1 260px; }
