:root {
  --bg: #0b0f14;
  --panel: #121820;
  --panel2: #171e28;
  --line: #222b37;
  --text: #e4e8ee;
  --muted: #8a95a5;
  --green: #3ddc97;
  --amber: #f3b443;
  --red: #ff6464;
  --blue: #5aa9ff;
  --purple: #b48cff;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { 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(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h2 { font-size: 17px; margin: 0; }
h3 { font-size: 14px; margin: 18px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
button {
  font: inherit; color: #06120c; background: var(--green); border: 0; border-radius: 8px; padding: 7px 14px;
  cursor: pointer; font-weight: 600;
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: .5; cursor: default; }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 500; }
button.ghost:hover { background: var(--panel2); }
button.danger { background: transparent; color: var(--red); border: 1px solid #4a2626; font-weight: 500; }
input {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; width: 100%;
}
input:focus { outline: 1px solid var(--green); border-color: var(--green); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); margin: 6px 0 14px; max-width: 900px; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

/* header */
.top {
  display: flex; align-items: center; gap: 18px; padding: 12px 22px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(11, 15, 20, .94); backdrop-filter: blur(6px); z-index: 5;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; }
.pill { display: inline-block; font-size: 11.5px; font-weight: 600; border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.pill.watchonly { background: #13261d; color: var(--green); border: 1px solid #1d4532; text-transform: uppercase; letter-spacing: .05em; }
.conn { display: flex; align-items: center; gap: 8px; color: var(--muted); margin-left: auto; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.conn.ok .dot { background: var(--green); box-shadow: 0 0 0 3px rgba(61, 220, 151, .18); }
.conn.bad .dot { background: var(--red); }
.toggles { display: flex; gap: 8px; }
.toggles button.on { border-color: var(--green); color: var(--green); }
.toggles button.off { border-color: var(--amber); color: var(--amber); }
.conn.sleep .dot { background: var(--amber); }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; padding: 16px 22px 4px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.stat .v { font-size: 20px; font-weight: 700; }
.stat .k { color: var(--muted); font-size: 12px; }
.stat.good .v { color: var(--green); }

/* tabs */
.tabs { display: flex; gap: 4px; padding: 12px 22px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button {
  background: transparent; color: var(--muted); border-radius: 8px 8px 0 0; font-weight: 500; padding: 8px 14px;
  border-bottom: 2px solid transparent;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--green); }
.badge { background: var(--red); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; margin-left: 4px; font-weight: 700; }
main { padding: 16px 22px 60px; max-width: 1400px; }
.tab { display: none; }
.tab.active { display: block; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { background: var(--panel); color: var(--muted); border: 1px solid var(--line); font-weight: 500; padding: 5px 11px; }
.chips button.active { color: var(--text); border-color: var(--green); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.more { display: block; margin: 14px auto; }

/* tables */
.tablewrap { overflow-x: auto; margin-top: 12px; }
table.grid { width: 100%; border-collapse: collapse; }
.grid th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid td { padding: 8px 10px; border-bottom: 1px solid #18202a; white-space: nowrap; }
.grid tbody tr.click { cursor: pointer; }
.grid tbody tr.click:hover { background: var(--panel); }
.grid tr.flash { animation: flash 2.5s ease-out; }
@keyframes flash { from { background: #1b3a2c; } to { background: transparent; } }

/* verdict pills */
.v-linked { background: #143326; color: var(--green); }
.v-checked { background: #1a212b; color: #c3cad5; }
.v-launchpad { background: #241c38; color: var(--purple); }
.v-junk { background: #161a20; color: #67717e; }
.v-new { background: #14243a; color: var(--blue); }
.v-error { background: #3a1818; color: var(--red); }
.v-ll { background: #10263f; color: #7cc4ff; margin-right: 4px; }
.pfimg { width: 20px; height: 20px; border-radius: 5px; vertical-align: -4px; margin-right: 6px; object-fit: cover; }
.v-watch { background: #3a2f12; color: var(--amber); margin-left: 4px; }
.warncount { font-weight: 600; }
.coinlater { color: var(--amber); font-size: 12.5px; }
.warncount.high { color: var(--red); }
.warncount.warn { color: var(--amber); }

/* alerts */
.list { display: flex; flex-direction: column; gap: 8px; }
.alert {
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--muted); border-radius: 10px;
  padding: 10px 14px; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px;
}
.alert.unread { background: var(--panel2); }
.alert.k-linked { border-left-color: var(--green); }
.alert.k-coin { border-left-color: var(--amber); }
.alert.k-graduated { border-left-color: var(--blue); }
.alert .t { font-weight: 650; }
.alert .when { color: var(--muted); font-size: 12px; text-align: right; }
.alert .b { color: #c3cad5; grid-column: 1 / -1; }
.alert .act { grid-column: 1 / -1; }
.alert .act button { padding: 4px 10px; font-size: 12.5px; }
.alert .when { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.alert .remove {
  background: transparent; color: var(--muted); border: 0; padding: 0 4px; font-weight: 400; font-size: 13px; line-height: 1;
}
.alert .remove:hover { color: var(--red); filter: none; }
button.small { padding: 3px 10px; font-size: 12.5px; }
.links .push { margin-left: auto; }
.links { align-items: center; }

/* coins */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.coin { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.coin .head { display: flex; gap: 10px; align-items: center; }
.coin img, .coin .ph { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: var(--panel2); flex: none; }
.coin .ph { display: grid; place-items: center; color: var(--muted); font-weight: 700; }
.coin .name { font-weight: 700; font-size: 15px; }
.coin .why { color: #c3cad5; }
.progress { height: 8px; background: var(--panel2); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, #2bb47a, var(--green)); width: 0; transition: width .6s; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.links { display: flex; gap: 12px; flex-wrap: wrap; }

/* warnings / reasons */
.risks, .reasons { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.risks li { padding: 6px 10px; border-radius: 8px; background: var(--panel2); border-left: 3px solid var(--muted); }
.risks li.high { border-left-color: var(--red); }
.risks li.warn { border-left-color: var(--amber); }
.risks li.info { border-left-color: var(--blue); }
.reasons li { display: grid; grid-template-columns: 48px 1fr; gap: 8px; }
.reasons .pts { font-family: var(--mono); font-weight: 700; text-align: right; color: var(--muted); }
.reasons .pts.plus { color: var(--green); }
.reasons .pts.minus { color: var(--red); }

/* forms */
.form-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.form-row label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12.5px; min-width: 200px; }
.form-row label.grow { flex: 1; }
.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px 24px; }
.settings label { display: flex; flex-direction: column; gap: 5px; }
.settings label b { font-weight: 600; }
.settings label span { color: var(--muted); font-size: 12.5px; }
.settings .actions { grid-column: 1 / -1; display: flex; gap: 10px; align-items: center; }
.prose { max-width: 860px; }
.prose li { margin: 4px 0; }

/* detail dialog */
dialog {
  width: min(920px, 94vw); max-height: 90vh; background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 14px; padding: 0;
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dlg-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg);
}
#detailBody { padding: 4px 18px 20px; }
.addr { display: inline-flex; align-items: center; gap: 6px; }
.copy { background: transparent; border: 0; color: var(--muted); padding: 0 2px; font-weight: 400; cursor: pointer; }
.copy:hover { color: var(--text); }
.copy.done, .copy-ico.done { color: var(--green); }
.chip-copy {
  display: inline-flex; align-items: center; gap: 6px; background: transparent; color: var(--text); border: 1px solid transparent;
  border-radius: 6px; padding: 2px 6px; margin: -3px 0; font-weight: 400; font-size: 12.5px; cursor: copy;
}
.chip-copy .copy-ico { color: var(--muted); }
.chip-copy:hover { background: var(--panel2); border-color: var(--line); filter: none; }
.chip-copy:hover .copy-ico { color: var(--text); }
.ext-ico {
  display: inline-block; color: var(--muted); border: 1px solid transparent; border-radius: 6px; padding: 0 5px;
  margin-left: 2px; line-height: 1.5;
}
.ext-ico:hover { color: var(--blue); border-color: var(--line); background: var(--panel2); text-decoration: none; }
.section-gap { margin-top: 34px; }
.offscreen { position: fixed; left: -9999px; top: 0; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 4px; }

/* toasts */
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 20; }
.toast {
  background: var(--panel2); border: 1px solid var(--line); border-left: 3px solid var(--green); border-radius: 10px;
  padding: 10px 14px; max-width: 380px; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); cursor: pointer;
}
.toast.err { border-left-color: var(--red); }
.toast b { display: block; }

@media (max-width: 700px) {
  .top { flex-wrap: wrap; padding: 10px 14px; }
  .conn { margin-left: 0; }
  main, .stats, .tabs { padding-left: 14px; padding-right: 14px; }
}

/* login page */
body.loginpage { min-height: 100vh; display: grid; place-items: center; }
.login { width: min(360px, 92vw); display: flex; flex-direction: column; gap: 14px; padding: 24px; }
.login label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.loginerr { color: var(--red); margin: 0; }

/* telegram */
#tgStatus { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
#tgStatus ol { margin: 4px 0; padding-left: 20px; color: var(--muted); }
.tg-switches { display: flex; flex-direction: column; gap: 8px; }
.tg-switches label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.tg-switches input { width: auto; margin-top: 3px; accent-color: var(--green); }
.tg-switches span { color: var(--muted); }
.tg-switches b { color: var(--text); font-weight: 600; }
.okdot { color: var(--green); font-weight: 600; }
.pausedot { color: var(--amber); }
.tglink { background: #1d3b5c; color: #cfe6ff; padding: 7px 14px; border-radius: 8px; font-weight: 600; }
.tglink:hover { text-decoration: none; filter: brightness(1.15); }
