:root {
  --bg: #0b0e14; --panel: #131824; --panel-2: #182031; --line: #232c40; --line-2: #2e3950;
  --text: #e8ecf4; --muted: #8893a8; --dim: #5d6880;
  --accent: #6c8cff; --accent-2: #8fa8ff;
  --green: #2fbf8f; --green-bg: rgba(47,191,143,.12);
  --red: #f0616d; --red-bg: rgba(240,97,109,.12);
  --amber: #e9b44c; --amber-bg: rgba(233,180,76,.12);
  --radius: 14px;
  font-family: Inter, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
body { min-height: 100vh; }
a { color: var(--accent-2); text-decoration: none; }
h1 { font-size: 22px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
h3 { font-size: 13px; margin: 0; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.muted { color: var(--muted); } .small { font-size: 13px; } .center { text-align: center; }
.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--green); } .neg { color: var(--red); }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 28px; padding: 0 24px;
  height: 60px; background: rgba(11,14,20,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
body.live .topbar { border-bottom: 2px solid var(--red); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.brand.big { justify-content: center; font-size: 24px; }
.logo { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; color: #fff; font-size: 16px;
  background: linear-gradient(135deg, #6c8cff, #9b6cff); }
nav { display: flex; gap: 4px; flex: 1; }
nav a { padding: 8px 14px; border-radius: 9px; color: var(--muted); font-weight: 500; }
nav a:hover { color: var(--text); background: var(--panel); }
nav a.active { color: var(--text); background: var(--panel-2); }
.top-right { display: flex; align-items: center; gap: 12px; }
.clock { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 64px; text-align: right; }
.pill { padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .08em; }
.pill.paper { background: rgba(108,140,255,.16); color: var(--accent-2); }
.pill.live { background: var(--red); color: #fff; }
.chip { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.chip.ok::before { background: var(--green); box-shadow: 0 0 0 3px var(--green-bg); }
.chip.bad::before { background: var(--red); box-shadow: 0 0 0 3px var(--red-bg); }
.demo-banner { background: var(--amber-bg); color: var(--amber); text-align: center; padding: 7px; font-size: 13px; font-weight: 600; }

/* layout */
main#view { max-width: 1240px; margin: 0 auto; padding: 26px 24px 80px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, 1fr); } .g3 { grid-template-columns: repeat(3, 1fr); } .g2 { grid-template-columns: 1fr 1fr; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card + .card, .grid + .card, .card + .grid, .grid + .grid, .status + .grid, .status + .card { margin-top: 16px; }
.grid > .card { margin-top: 0; }
.kpi .value { font-size: 26px; font-weight: 650; margin-top: 6px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.meter { height: 6px; border-radius: 4px; background: var(--line); margin-top: 12px; overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 4px; background: var(--green); transition: width .4s; }
.meter > i.warn { background: var(--amber); } .meter > i.bad { background: var(--red); }

/* status strip */
.status { display: flex; align-items: center; gap: 16px; padding: 16px 20px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--panel); }
.status .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--dim); flex: none; }
.status.on { border-color: rgba(47,191,143,.45); background: linear-gradient(90deg, var(--green-bg), var(--panel) 60%); }
.status.on .dot { background: var(--green); box-shadow: 0 0 0 5px var(--green-bg); animation: pulse 2s infinite; }
.status.wait .dot { background: var(--amber); box-shadow: 0 0 0 5px var(--amber-bg); }
.status.stop { border-color: rgba(240,97,109,.5); background: linear-gradient(90deg, var(--red-bg), var(--panel) 60%); }
.status.stop .dot { background: var(--red); }
.status .text { flex: 1; min-width: 0; }
.status .title { font-weight: 600; font-size: 16px; }
.status .actions { display: flex; gap: 10px; }
@keyframes pulse { 50% { box-shadow: 0 0 0 9px rgba(47,191,143,0); } }

/* buttons & forms */
.btn { border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); padding: 9px 16px; border-radius: 10px;
  font: inherit; font-weight: 600; cursor: pointer; transition: filter .15s, background .15s; white-space: nowrap; }
.btn:hover { filter: brightness(1.15); } .btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.go { background: var(--green); border-color: var(--green); color: #06281d; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { background: transparent; } .btn.small { padding: 5px 11px; font-size: 13px; } .btn.wide { width: 100%; padding: 12px; }
label { display: block; font-size: 13px; color: var(--muted); font-weight: 500; }
input, select { display: block; width: 100%; margin-top: 6px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--bg); color: var(--text); font: inherit; font-variant-numeric: tabular-nums; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.field { margin-bottom: 16px; } .field .hint { color: var(--dim); font-size: 12.5px; margin-top: 5px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 11px 0; border-top: 1px solid var(--line); }
.switch-row:first-of-type { border-top: 0; }
.switch-row b { font-weight: 550; } .switch-row .hint { color: var(--dim); font-size: 12.5px; }
.switch { position: relative; width: 44px; height: 25px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 20px; background: var(--line-2); transition: .2s; }
.switch i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 19px; height: 19px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + i { background: var(--accent); } .switch input:checked + i::after { transform: translateX(19px); }
.error { color: var(--red); font-size: 13.5px; }
.savebar { position: fixed; left: 0; right: 0; bottom: 0; padding: 14px 24px; background: var(--panel-2); border-top: 1px solid var(--line-2);
  display: flex; justify-content: center; align-items: center; gap: 16px; z-index: 15; }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 -8px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; padding: 8px; white-space: nowrap; }
td { padding: 10px 8px; border-top: 1px solid var(--line); white-space: nowrap; }
th.r, td.r { text-align: right; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--panel-2); color: var(--muted); }
.tag.buy { background: var(--green-bg); color: var(--green); } .tag.sell { background: var(--red-bg); color: var(--red); }
.tag.warn { background: var(--amber-bg); color: var(--amber); } .tag.bad { background: var(--red-bg); color: var(--red); }
.empty { color: var(--dim); padding: 22px 0; text-align: center; }

/* feeds */
.feed { list-style: none; margin: 0; padding: 0; max-height: 330px; overflow-y: auto; }
.feed li { padding: 9px 0; border-top: 1px solid var(--line); font-size: 13.5px; display: flex; gap: 10px; }
.feed li:first-child { border-top: 0; }
.feed time { color: var(--dim); flex: none; font-variant-numeric: tabular-nums; }
.feed .alert { color: var(--red); } .feed .warn { color: var(--amber); } .feed .trade { color: var(--text); font-weight: 550; }
.feed .skipped { color: var(--muted); }

/* steps */
.steps { display: grid; gap: 10px; }
.step { display: flex; gap: 14px; align-items: center; padding: 12px 14px; border-radius: 10px; background: var(--panel-2); }
.step .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; background: var(--line-2); flex: none; }
.step.done .n { background: var(--green); color: #06281d; } .step.done { color: var(--muted); }
.step .grow { flex: 1; }

/* chart */
.chart { width: 100%; height: 220px; display: block; }
.chart text { fill: var(--dim); font-size: 11px; }

/* modal & toast */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(4,6,10,.7); display: grid; place-items: center; padding: 20px; }
.modal[hidden], .toast[hidden] { display: none; }
.dialog { width: 100%; max-width: 460px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 16px; padding: 24px; }
.dialog h2 { font-size: 18px; } .dialog .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.dialog ul { padding-left: 18px; color: var(--muted); font-size: 14px; }
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); z-index: 60; padding: 12px 20px; border-radius: 12px;
  background: var(--panel-2); border: 1px solid var(--line-2); box-shadow: 0 10px 40px rgba(0,0,0,.5); max-width: 90vw; }
.toast.bad { border-color: var(--red); color: #ffd5d8; }
.note { padding: 12px 14px; border-radius: 10px; background: var(--amber-bg); color: #f0d59a; font-size: 13.5px; }
.note.info { background: rgba(108,140,255,.1); color: #c3d0ff; }
code { background: var(--bg); border: 1px solid var(--line); padding: 2px 7px; border-radius: 6px; font-size: 13px; word-break: break-all; }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line-2); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 6px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; }
.seg button.active { background: var(--panel-2); color: var(--text); }
progress { width: 100%; height: 8px; accent-color: var(--accent); }

/* login */
.login-body { display: grid; place-items: center; padding: 20px;
  background: radial-gradient(900px 500px at 50% -10%, rgba(108,140,255,.16), transparent), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 32px 28px; }
.login-card form { margin: 22px 0 14px; display: grid; gap: 14px; }

@media (max-width: 900px) {
  .g4 { grid-template-columns: 1fr 1fr; } .g3, .g2, .fields { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 10px; }
  nav { order: 3; flex-basis: 100%; overflow-x: auto; } #broker-chip, .clock { display: none; }
  main#view { padding: 18px 14px 90px; } .status { flex-wrap: wrap; }
}
