:root {
  --bg: #0b1020; --panel: #121a2e; --panel2: #18223a; --line: #24304b; --text: #e6ecf7; --muted: #8a97b2;
  --accent: #4f8cff; --accent2: #3a6fd8; --green: #2fbf71; --red: #ef5b5b; --amber: #f0ad3c; --violet: #9b7bff;
  --radius: 10px; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; }
.hidden { display: none !important; }

/* layout */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: #0e1528; border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { font-weight: 700; font-size: 18px; letter-spacing: .3px; padding: 4px 10px 18px; display: flex; gap: 8px; align-items: center; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); }
.nav a { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 9px 12px; border-radius: 8px; margin-bottom: 2px; }
.nav a:hover { background: var(--panel); color: var(--text); }
.nav a.active { background: var(--panel2); color: var(--text); }
.side .foot { margin-top: auto; color: var(--muted); font-size: 12px; padding: 10px; }
.main { padding: 22px 28px 60px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 10px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }

/* cards */
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; overflow-x: auto; }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 1100px) { .two { grid-template-columns: 1fr; } }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; background: var(--panel2); position: sticky; top: 0; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #151f36; }
td.wrap { white-space: normal; min-width: 220px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); padding: 26px; text-align: center; }
.legs { display: grid; gap: 4px; }
.leg { display: flex; gap: 6px 8px; align-items: baseline; font-size: 13px; flex-wrap: wrap; white-space: normal; min-width: 260px; }
.leg .src { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--panel2); color: var(--muted); min-width: 74px; text-align: center; }
.src-pinnacle { color: #ffb86b !important; }
.src-polymarket { color: #7fb2ff !important; }
.src-kalshi { color: #62e3b0 !important; }

/* badges & buttons */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; background: var(--panel2); color: var(--muted); border: 1px solid var(--line); }
.badge.green { color: var(--green); border-color: #1f5a3c; background: #10271b; }
.badge.red { color: var(--red); border-color: #5c2626; background: #2a1414; }
.badge.amber { color: var(--amber); border-color: #5b4520; background: #291f0e; }
.badge.blue { color: #8db4ff; border-color: #2a4274; background: #121f3a; }
.badge.violet { color: var(--violet); border-color: #3f3470; background: #1b1633; }
.roi { font-weight: 700; color: var(--green); }
.neg { color: var(--red); }
.pos { color: var(--green); }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); padding: 7px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #3a4a6d; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent2); }
.btn.green { background: #1e7d4b; border-color: #1e7d4b; color: #fff; }
.btn.red { background: #8a2c2c; border-color: #8a2c2c; color: #fff; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--text); border-color: var(--accent); }

/* forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; color: #c3cde2; }
.field .help { font-size: 12px; color: var(--muted); }
input, select, textarea { background: #0d1426; border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 8px 10px; font: inherit; width: 100%; }
textarea { min-height: 90px; font-family: var(--mono); font-size: 12px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
.check { flex-direction: row; align-items: center; gap: 10px; }
.check input, input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); cursor: pointer; color: var(--muted); user-select: none; font-size: 13px; }
.chip.on { background: #16274a; border-color: var(--accent); color: var(--text); }
.section { margin-bottom: 16px; }
.section > h2 { display: flex; align-items: center; gap: 8px; }
.sticky-save { position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 35%); display: flex; gap: 8px; justify-content: flex-end; }

/* login */
.center { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: 100%; max-width: 380px; }
.login h1 { margin-bottom: 4px; }
.login .field { margin-bottom: 12px; }

/* modal & toast */
.modal-bg { position: fixed; inset: 0; background: rgba(3, 6, 14, .7); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; width: 100%; max-width: 640px; max-height: 90vh; overflow: auto; padding: 20px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--panel2); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 8px; max-width: 420px; box-shadow: 0 8px 30px rgba(0,0,0,.4); }
.toast.err { border-left-color: var(--red); }
.toast.ok { border-left-color: var(--green); }
.pre { white-space: pre-wrap; font-family: var(--mono); font-size: 12px; background: #0d1426; border: 1px solid var(--line); border-radius: 8px; padding: 10px; max-height: 360px; overflow: auto; }
.log-info { color: var(--text); } .log-warn { color: var(--amber); } .log-error { color: var(--red); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); }
.status-dot.running, .status-dot.ok { background: var(--green); box-shadow: 0 0 8px var(--green); }
.status-dot.error { background: var(--red); }
.status-dot.login, .status-dot.starting { background: var(--amber); }
.acc-card .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.banner { padding: 10px 14px; border-radius: 8px; border: 1px solid #5b4520; background: #291f0e; color: #f5cf8a; margin-bottom: 14px; }
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; padding: 10px; }
  .brand { padding: 0 10px 0 0; }
  .nav { display: flex; }
  .side .foot { display: none; }
  .main { padding: 16px; }
}

.err-text { white-space: normal; word-break: break-word; max-width: 420px; }

.note-clamp{display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;max-width:360px}

/* settings: group pills + per-sport table */
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 14px; position: sticky; top: 0; z-index: 3; padding: 8px 0; background: var(--bg, #0b1220); }
.pill { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line, #243049); cursor: pointer; font-size: 13px; color: var(--muted, #9aa7bd); user-select: none; }
.pill:hover { color: var(--text, #e6edf7); }
.pill.active { background: var(--accent, #3b82f6); border-color: transparent; color: #fff; }
.sport-table td, .sport-table th { padding: 6px 8px; white-space: nowrap; vertical-align: middle; }
.sport-table input[type=number] { padding: 6px 8px; }
.sport-table .c { text-align: center; }
.sport-table tr.off td:not(:first-child):not(:nth-child(2)) { opacity: .35; }
.sport-table input[type=checkbox] { width: 18px; height: 18px; }
