:root {
  --bg: #0f1419;
  --panel: #1a2332;
  --border: #2d3a4f;
  --text: #e7ecf3;
  --muted: #8b9bb4;
  --accent: #3b82f6;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --ro: #64748b;
}
* { box-sizing: border-box; }
body {
  margin: 0; padding: 1.25rem;
  font-family: "SF Pro Text", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  line-height: 1.45;
}
h1 { margin: 0 0 .25rem; font-size: 1.4rem; }
h2 { margin: 0 0 .75rem; font-size: 1.1rem; }
h3 { margin: .5rem 0; font-size: .95rem; color: var(--muted); }
.sub { margin: 0; color: var(--muted); font-size: .85rem; }
.top { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.meta { text-align: right; font-size: .9rem; }
.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 1rem; margin-bottom: 1rem;
}
.badge { padding: .15rem .55rem; border-radius: 999px; font-weight: 600; font-size: .85rem; }
.badge.ro { background: #334155; color: #cbd5e1; }
.badge.auth { background: #14532d; color: #86efac; }
.row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.gap { gap: .5rem; margin-top: .75rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th, td { border-bottom: 1px solid var(--border); padding: .4rem .35rem; text-align: left; }
th { color: var(--muted); font-weight: 600; }
button, input {
  font: inherit; border-radius: 8px; border: 1px solid var(--border);
  padding: .45rem .7rem; background: #0b1220; color: var(--text);
}
button { cursor: pointer; background: var(--accent); border-color: transparent; font-weight: 600; }
button.secondary { background: #243044; }
button.danger { background: var(--danger); }
button:disabled { opacity: .5; cursor: not-allowed; }
input[type=password] { min-width: 220px; }
.msg { min-height: 1.2em; font-size: .85rem; margin-top: .4rem; }
.msg.err { color: #fca5a5; }
.ok { color: var(--ok); }
dialog {
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--panel); color: var(--text); padding: 1rem 1.2rem; max-width: 420px;
}
dialog::backdrop { background: rgba(0,0,0,.55); }
.flat { color: var(--muted); }
.long { color: #4ade80; }
.short { color: #f87171; }

/* outer gate */
.gate-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #0f1419;
}
.gate-card {
  width: min(420px, 100%);
  background: #1a222c;
  border: 1px solid #2a3542;
  border-radius: 12px;
  padding: 28px 24px;
  box-shadow: 0 12px 40px rgba(0,0,0,.35);
}
.gate-card h1 { margin: 0 0 8px; font-size: 1.4rem; }
.gate-card .sub { margin: 0 0 20px; color: #9aa7b5; font-size: .92rem; line-height: 1.45; }
.gate-card label { display: block; margin-bottom: 14px; color: #c5d0db; }
.gate-card input[type=password] {
  display: block; width: 100%; margin-top: 6px; box-sizing: border-box;
  min-width: 0; padding: 10px 12px; border-radius: 8px;
  border: 1px solid #3a4654; background: #0f1419; color: #e8eef4;
}
.gate-card button { width: 100%; margin-top: 4px; }
.gate-card .hint { margin: 18px 0 0; color: #7d8b99; font-size: .85rem; }

.table-wrap { overflow: auto; max-height: 420px; margin-bottom: .75rem; border: 1px solid var(--border); border-radius: 8px; }
.table-wrap table { margin: 0; }
.panel label { display: inline-block; margin: .25rem .5rem .25rem 0; font-size: .85rem; color: var(--muted); }
.panel label input, .panel label select { display: block; margin-top: .25rem; min-width: 160px; }
.pnl-pos { color: #4ade80; }
.pnl-neg { color: #f87171; }
details summary { cursor: pointer; color: var(--muted); }

.nav { margin-top: .55rem; display: flex; gap: .75rem; }
.nav a { color: var(--muted); text-decoration: none; font-size: .9rem; padding: .2rem .55rem; border-radius: 999px; border: 1px solid transparent; }
.nav a.active, .nav a:hover { color: var(--text); border-color: var(--border); background: #243044; }
.mkt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 1000px) { .mkt-grid { grid-template-columns: 1fr; } }
.mkt-prices { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin: .75rem 0 1rem; }
.mkt-prices .lbl { color: var(--muted); font-size: .78rem; }
.mkt-prices .val { font-weight: 650; }
.mkt-prices .val.big { font-size: 1.55rem; }
.mkt-prices .val.small { font-size: .85rem; font-weight: 500; }
.mkt-prices small { color: var(--muted); font-weight: 500; }

.chart-wrap { width: 100%; overflow: hidden; background: #0b1220; border: 1px solid var(--border); border-radius: 8px; }
.chart-wrap canvas { width: 100%; height: 360px; display: block; }

/* conditional / algo orders */
tr.algo-order td { background: rgba(255, 180, 60, 0.08); }

.pager { display:flex; gap:.5rem; align-items:center; flex-wrap:wrap; margin:-.25rem 0 1rem; }
.pager span { color: var(--muted, #888); font-size:.9rem; }
.table-wrap { max-height: none; }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .6rem; margin: .6rem 0 1rem; }
.kpi { background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08); border-radius: 8px; padding: .55rem .7rem; }
.kpi .k { font-size: .78rem; color: var(--muted); }
.kpi .v { font-size: 1.02rem; margin-top: .2rem; font-weight: 600; }
.module-grid { border-left: 4px solid #38bdf8; }
.module-vote { border-left: 4px solid #f59e0b; }
.badge.warn { background: #7f1d1d; color: #fecaca; }
