/* entropy-arb webui — shared styles (engine page + console).
   Dark, dense, information-first. No framework. */

:root {
  --bg: #0b0f14;
  --panel: #111820;
  --panel-2: #0e141b;
  --border: #1e2a36;
  --text: #d7e2ec;
  --dim: #7a8b9c;
  --accent: #35c4dc;
  --green: #2ecc71;
  --red: #e74c3c;
  --yellow: #f1c40f;
  --blue: #4aa3ff;
  --mono: "SFMono-Regular", ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
a { color: var(--accent); text-decoration: none; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  position: sticky; top: 0; z-index: 10;
}
.topbar .brand { font-weight: 700; font-size: 15px; }
.topbar .brand .pair { color: var(--accent); }
.topbar .spacer { flex: 1; }

.wrap { padding: 14px 16px; max-width: 1500px; margin: 0 auto; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 3px;
  font-size: 12px; font-weight: 700; letter-spacing: .4px;
  background: #22303d; color: var(--text); white-space: nowrap;
}
.badge.live     { background: #14532d; color: #d9f7e4; }
.badge.rec      { background: #4d3c00; color: #fff3c4; }
.badge.running  { background: #14532d; color: #d9f7e4; }
.badge.recording{ background: #14532d; color: #d9f7e4; }
.badge.halted   { background: #7f1d1d; color: #ffe1e1; }
.badge.venue_down { background: #7f1d1d; color: #ffe1e1; }
.badge.stale    { background: #6b5500; color: #fff3c4; }
.badge.rate_limited { background: #6b5500; color: #fff3c4; }
.badge.starting { background: #31435a; color: #cfe4ff; }
.badge.stopped  { background: #22303d; color: var(--dim); }
.badge.errored  { background: #7f1d1d; color: #ffe1e1; }
.badge.dim      { background: #22303d; color: var(--dim); font-weight: 500; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.card h3 {
  margin: 0 0 10px; font-size: 13px; font-weight: 700;
  color: var(--dim); text-transform: none; letter-spacing: .3px;
}
.card h3 .right { float: right; font-weight: 400; }

.grid-2 { display: grid; grid-template-columns: 3fr 2fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 1000px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td {
  padding: 4px 8px; text-align: right; white-space: nowrap;
  border-bottom: 1px solid #16202b;
}
table.data th { color: var(--dim); font-weight: 600; font-size: 12px; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data tr:last-child td { border-bottom: none; }
.num { font-family: var(--mono); font-size: 12.5px; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.zero, .muted { color: var(--dim); }
.warn { color: var(--yellow); }
.err  { color: var(--red); font-weight: 700; }

.kv { display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; font-size: 13px; }
.kv .k { color: var(--dim); }
.kv .v { text-align: right; font-family: var(--mono); font-size: 12.5px; }

.evlog {
  font-family: var(--mono); font-size: 11.5px; line-height: 1.55;
  max-height: 160px; overflow-y: auto; white-space: nowrap;
  color: var(--dim);
}
.evlog .l-w { color: var(--yellow); }
.evlog .l-e { color: var(--red); font-weight: 700; }
.evlog .l-c { background: #7f1d1d; color: #fff; }
.evlog .l-i { color: #5f7f8f; }

canvas.chart { width: 100%; height: 220px; display: block; }
canvas.chart.tall { height: 300px; }

button, .btn {
  background: #1c2a38; color: var(--text);
  border: 1px solid #2b3d4f; border-radius: 6px;
  padding: 6px 14px; font-size: 13px; cursor: pointer;
}
button:hover { background: #24374a; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: #0e5a6b; border-color: #1587a0; }
button.primary:hover { background: #137089; }
button.danger { background: #6e2020; border-color: #9c3030; }
button.danger:hover { background: #8a2a2a; }

input[type=text], input[type=number], input[type=password], select, textarea {
  background: #0d141b; color: var(--text);
  border: 1px solid #26374a; border-radius: 6px;
  padding: 6px 9px; font-size: 13px; width: 100%;
  font-family: var(--mono);
}
input:focus, select:focus, textarea:focus { outline: 1px solid var(--accent); }
textarea { min-height: 220px; resize: vertical; white-space: pre; }

.form-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.form-row label { flex: 0 0 260px; color: var(--text); font-size: 13px; }
.form-row label .hint { color: var(--dim); font-size: 12px; display: block; }
.form-row input, .form-row select { flex: 1; max-width: 320px; }
.form-row .msg { flex: 1; font-size: 12px; }
.form-row .msg.bad { color: var(--red); }
.form-row .msg.ok  { color: var(--green); }

.tabs { display: flex; gap: 4px; padding: 0 16px; background: var(--panel-2);
        border-bottom: 1px solid var(--border); position: sticky; top: 41px; z-index: 9; }
.tabs button {
  border: none; border-radius: 6px 6px 0 0; background: transparent;
  padding: 9px 16px; color: var(--dim); font-size: 13.5px;
}
.tabs button.active { color: var(--accent); background: var(--bg);
                      border: 1px solid var(--border); border-bottom-color: var(--bg); }
.tabpane { display: none; }
.tabpane.active { display: block; }

.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.62);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: var(--panel); border: 1px solid #2b3d4f; border-radius: 10px;
  padding: 20px 22px; width: 520px; max-width: 94vw; max-height: 88vh;
  overflow-y: auto;
}
.modal h2 { margin: 0 0 14px; font-size: 16px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: #14324a; border: 1px solid #1f5a7a; color: #cfeaff;
  padding: 9px 18px; border-radius: 8px; font-size: 13px; z-index: 200;
  opacity: 0; transition: opacity .25s; pointer-events: none;
}
.toast.show { opacity: 1; }
.toast.bad { background: #4a1420; border-color: #7a2032; color: #ffd9df; }

.note { color: var(--dim); font-size: 12.5px; line-height: 1.6; }
.hl { color: var(--accent); }
.section-title { font-size: 13px; color: var(--dim); margin: 18px 0 8px;
                 border-bottom: 1px dashed #22303d; padding-bottom: 4px; }

.list-nav { display: flex; flex-direction: column; gap: 4px; }
.list-nav button {
  text-align: left; background: transparent; border: 1px solid transparent;
  padding: 8px 10px; border-radius: 6px;
}
.list-nav button.active { background: #16222e; border-color: #2b3d4f; color: var(--accent); }
.list-nav button:hover { background: #16222e; }

.stat-strip { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.stat {
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 14px; min-width: 130px;
}
.stat .label { color: var(--dim); font-size: 11.5px; margin-bottom: 2px; }
.stat .value { font-family: var(--mono); font-size: 15px; }

.flag { display: inline-block; width: 10px; height: 10px; border-radius: 2px;
        margin-right: 6px; vertical-align: baseline; }
.flag.ok  { background: var(--green); }
.flag.bad { background: #5b2630; border: 1px solid var(--red); }
