:root {
  --bg: #0b1210; --panel: #111b18; --panel2: #162320; --line: #22332e;
  --text: #e6f2ee; --muted: #8aa39b; --mint: #3ee0a1; --mint-d: #1fa877;
  --red: #ff6b6b; --amber: #ffc857; --blue: #6cb6ff;
  --r: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
a { color: var(--mint); }
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 28px 0 10px; }
h3 { font-size: 15px; margin: 0 0 10px; }
h4 { margin: 14px 0 6px; color: var(--muted); font-size: 12px; letter-spacing: .05em; }
small, .small { font-size: 12px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Consolas, monospace; word-break: break-all; }
.up { color: var(--mint); } .down { color: var(--red); }
.nowrap { white-space: nowrap; }

.boot, .loading { padding: 40px; color: var(--muted); text-align: center; }

/* header + layout */
.top { display: flex; justify-content: space-between; align-items: center; padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; gap: 10px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.brand.big { font-size: 30px; justify-content: center; }
.logo { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--mint); color: var(--bg); font-weight: 900; }
.top-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bot-status { font-size: 12px; padding: 4px 10px; border-radius: 20px; background: var(--panel2); }
.bot-status.on { color: var(--mint); } .bot-status.off { color: var(--muted); } .bot-status.warn { color: var(--amber); }
.layout { display: grid; grid-template-columns: 200px 1fr; min-height: calc(100vh - 52px); }
.side { border-right: 1px solid var(--line); padding: 14px 8px; display: flex; flex-direction: column; gap: 2px; }
.side a { color: var(--text); text-decoration: none; padding: 8px 12px; border-radius: 8px; }
.side a:hover { background: var(--panel2); }
.side a.active { background: var(--panel2); color: var(--mint); font-weight: 600; }
main { padding: 22px; max-width: 1200px; width: 100%; }
@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .side { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .side a { white-space: nowrap; }
  main { padding: 14px; }
}

/* controls */
.btn { background: var(--mint); color: #04110c; border: 0; border-radius: 8px; padding: 9px 16px; font-weight: 600; cursor: pointer; font-size: 14px; }
.btn:hover { background: #5ff0b6; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--mint); }
.btn.danger { background: var(--red); color: #fff; }
.btn.danger.ghost { background: transparent; color: var(--red); border-color: var(--red); }
.link { background: none; border: 0; color: var(--mint); cursor: pointer; margin-top: 12px; }
.chip { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 20px; padding: 4px 10px; cursor: pointer; }
input, textarea, select { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; font-size: 14px; font-family: inherit; }
input:focus, textarea:focus { outline: 2px solid var(--mint-d); border-color: transparent; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--mint); }
.sm-in { width: 110px; padding: 5px 8px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
label small { color: var(--muted); }
label .range { float: right; font-weight: normal; }
label.check { flex-direction: row; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0; }
label.check small { width: 100%; padding-left: 24px; }
label.disabled { opacity: .5; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.row.end { justify-content: flex-end; }
.row.grow { flex: 1; } .row.grow input { flex: 1; width: auto; min-width: 220px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-bottom: 12px; }

/* surfaces */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 14px; }
.card.err { border-color: var(--red); color: var(--red); }
.note { background: #14261f; border: 1px solid #1f4a3a; border-radius: var(--r); padding: 12px 14px; margin-bottom: 14px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: flex; flex-direction: column; gap: 2px; }
.tile span { color: var(--muted); font-size: 12px; }
.tile b { font-size: 22px; font-variant-numeric: tabular-nums; }
.tile small { color: var(--muted); }

.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.thumb { width: 26px; height: 26px; border-radius: 6px; object-fit: cover; vertical-align: middle; display: inline-block; background: var(--panel2); margin-right: 6px; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; background: var(--panel2); color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.pill.paper { background: var(--amber); color: #2a1f00; }
.pill.offer { color: var(--blue); } .pill.held, .pill.listed { color: var(--amber); }
.pill.sold, .pill.approved, .pill.buy { color: var(--mint); } .pill.cancelled { color: var(--muted); }
.pill.alert, .pill.sell { color: var(--red); }

/* recommendations */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; margin-top: 14px; }
.rec.approved { border-color: var(--mint-d); }
.rec-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.rec-head > div:nth-child(2) { flex: 1; display: flex; flex-direction: column; }
.rec-head .thumb { width: 42px; height: 42px; }
.score { font-size: 22px; font-weight: 800; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; border: 3px solid; }
.score.hi { color: var(--mint); } .score.mid { color: var(--amber); } .score.lo { color: var(--red); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 13px; margin-bottom: 8px; }
.kv span { color: var(--muted); } .kv b { text-align: right; font-weight: 500; }
.reasons { margin: 8px 0; padding-left: 18px; color: var(--muted); font-size: 12px; }

/* auth */
.auth { max-width: 380px; margin: 8vh auto; padding: 0 16px; text-align: center; }
.auth form { text-align: left; display: flex; flex-direction: column; gap: 12px; }

/* modal + toast */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 20; padding: 16px; }
.modal[hidden] { display: none; }
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; width: 100%; max-width: 460px; display: flex; flex-direction: column; gap: 10px; }
.phrase { background: var(--bg); border: 1px dashed var(--mint-d); border-radius: 8px; padding: 14px; font-size: 16px; line-height: 1.8; text-align: center; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--mint-d); padding: 10px 18px; border-radius: 10px; z-index: 30; max-width: 90vw; }
.toast.err { border-color: var(--red); color: #ffd0d0; }
.toast[hidden] { display: none; }
