:root {
  --bg: #07080c;
  --panel: #0d0f16;
  --panel-2: #12151f;
  --border: #1d2130;
  --border-hi: #2a3045;
  --text: #e6e8ef;
  --muted: #7d8597;
  --dim: #4f5668;
  --green: #14f195;
  --green-dim: rgba(20, 241, 149, 0.12);
  --red: #ff4d6d;
  --red-dim: rgba(255, 77, 109, 0.12);
  --purple: #9945ff;
  --purple-dim: rgba(153, 69, 255, 0.15);
  --yellow: #ffd23f;
  --blue: #4da3ff;
  --mono: ui-monospace, 'JetBrains Mono', 'SFMono-Regular', Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.4;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(153, 69, 255, 0.10), transparent 60%),
    radial-gradient(900px 400px at 100% 0%, rgba(20, 241, 149, 0.06), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
}
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 12px; background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 12px; }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.up { color: var(--green); }
.down { color: var(--red); }
.err { color: var(--red); font-size: 13px; min-height: 1em; }

input, select, button { font: inherit; color: inherit; }
input, select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  outline: none;
  min-width: 0;
}
input:focus, select:focus { border-color: var(--purple); box-shadow: 0 0 0 3px var(--purple-dim); }
input[type=number] { font-family: var(--mono); }
label { display: block; color: var(--muted); font-size: 12px; margin: 10px 0 4px; text-transform: uppercase; letter-spacing: .05em; }
label.inline { display: inline-flex; gap: 8px; align-items: center; text-transform: none; letter-spacing: 0; font-size: 13px; margin: 0; }

button { cursor: pointer; border-radius: 8px; border: 1px solid var(--border-hi); background: var(--panel-2); padding: 8px 14px; white-space: nowrap; }
button:hover { border-color: var(--purple); }
button:disabled { opacity: .45; cursor: not-allowed; }
.btn { }
.btn-neon {
  background: linear-gradient(135deg, var(--green), #0fd88a);
  color: #04130c; border: none; font-weight: 700; letter-spacing: .02em;
  box-shadow: 0 0 18px rgba(20, 241, 149, 0.35);
}
.btn-neon:hover { box-shadow: 0 0 26px rgba(20, 241, 149, 0.55); }
.btn-red { background: var(--red-dim); color: var(--red); border-color: rgba(255, 77, 109, .4); font-weight: 600; }
.btn-red:hover { background: rgba(255, 77, 109, .22); border-color: var(--red); }
.btn-ghost { background: transparent; }
.btn-xs { padding: 3px 9px; font-size: 12px; border-radius: 6px; }
.wide { width: 100%; padding: 12px; margin-top: 16px; font-size: 15px; }
.muted-ink { opacity: .6; font-weight: 500; }

.chip { display: inline-block; font-family: var(--mono); font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); vertical-align: middle; }
.chip.paper { color: var(--yellow); border-color: rgba(255, 210, 63, .35); margin-left: 8px; }
.chip.green { color: var(--green); border-color: rgba(20, 241, 149, .35); background: var(--green-dim); }
.chip.red { color: var(--red); border-color: rgba(255, 77, 109, .35); background: var(--red-dim); }
.chip.purple { color: #c39bff; border-color: rgba(153, 69, 255, .4); background: var(--purple-dim); }
.chip.yellow { color: var(--yellow); border-color: rgba(255, 210, 63, .35); }
.chip-btn { font-family: var(--mono); font-size: 12px; padding: 5px 10px; border-radius: 999px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 380px; padding: 28px 24px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 0 60px rgba(153, 69, 255, 0.15);
}
.login-card input { width: 100%; }
.tagline { color: var(--muted); margin: 6px 0 14px; font-family: var(--mono); font-size: 12px; }

/* ---------- top bar ---------- */
.brand { font-family: var(--mono); font-weight: 800; letter-spacing: .08em; font-size: 15px; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.brand.big { font-size: 20px; flex-wrap: wrap; }
.brand-mark {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, var(--purple), var(--green)); color: #07080c; font-size: 16px;
}
.brand-sub { width: 100%; font-size: 11px; color: var(--muted); letter-spacing: .3em; text-transform: uppercase; font-weight: 500; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 16px; background: rgba(7, 8, 12, 0.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.tabs { display: flex; gap: 2px; }
.tabs a { color: var(--muted); padding: 6px 12px; border-radius: 8px; font-weight: 600; }
.tabs a:hover { color: var(--text); text-decoration: none; background: var(--panel-2); }
.tabs a.on { color: var(--text); background: var(--panel-2); box-shadow: inset 0 -2px 0 var(--green); }
.topbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ticker { font-family: var(--mono); font-size: 12px; color: var(--muted); padding: 4px 8px; border: 1px solid var(--border); border-radius: 999px; }
.topbar select { padding: 4px 8px; font-size: 12px; border-radius: 999px; }

main { max-width: 1400px; margin: 0 auto; padding: 16px 16px 64px; }
.banner { margin: 12px 16px 0; padding: 10px 14px; border-radius: 10px; background: var(--purple-dim); border: 1px solid rgba(153, 69, 255, .35); }
.banner.bad { background: var(--red-dim); border-color: rgba(255, 77, 109, .4); color: #ffb3c0; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 14px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; margin: 0; color: var(--muted); display: inline; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }
.fineprint { color: var(--dim); font-size: 12px; line-height: 1.6; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: none; border-radius: 0; background: transparent; padding: 5px 11px; font-size: 12px; color: var(--muted); }
.seg button.on { background: var(--panel-2); color: var(--text); box-shadow: inset 0 -2px 0 var(--green); }

/* ---------- pulse ---------- */
.pulse-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.quickbuy { display: flex; align-items: center; gap: 6px; padding: 4px 4px 4px 10px; border: 1px solid rgba(20, 241, 149, .3); border-radius: 10px; background: var(--green-dim); }
.qb-label { color: var(--green); font-weight: 700; font-size: 13px; }
.quickbuy input { width: 80px; padding: 5px 8px; }
.quickbuy select { padding: 5px 6px; }
.pulse-search { flex: 1 1 220px; }
.col-switch { display: none; gap: 6px; margin-bottom: 10px; }
.col-switch button { flex: 1; font-size: 13px; padding: 7px; }
.col-switch button.on { border-color: var(--green); color: var(--green); }
.pulse-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.pcol { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; display: flex; flex-direction: column; min-height: 300px; max-height: calc(100vh - 170px); }
.pcol-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.pcol-head h3 { margin: 0; font-size: 14px; }
.pcol-head .spacer { flex: 1; }
.pcol-head select { padding: 3px 6px; font-size: 12px; }
.pcol-body { overflow-y: auto; padding: 6px; }
.pcol-note { padding: 18px; color: var(--muted); text-align: center; font-size: 13px; }
.filter-btn.active { color: var(--yellow); border-color: rgba(255, 210, 63, .5); }

.card {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center;
  padding: 9px 8px; border-radius: 10px; border: 1px solid transparent; cursor: pointer;
}
.card:hover { background: var(--panel-2); border-color: var(--border-hi); }
.avatar { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: var(--panel-2); border: 1px solid var(--border); }
.avatar.ph { display: grid; place-items: center; font-weight: 800; font-family: var(--mono); color: #c39bff; background: var(--purple-dim); }
.avatar.sm { width: 28px; height: 28px; border-radius: 7px; font-size: 12px; }
.avatar.lg { width: 56px; height: 56px; border-radius: 12px; font-size: 20px; }
.card-main { min-width: 0; }
.card-l1 { display: flex; gap: 6px; align-items: baseline; min-width: 0; }
.card-l1 b { font-size: 14px; }
.card-l1 .name { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.age { font-family: var(--mono); font-size: 11px; color: var(--green); }
.card-l2, .card-l3 { display: flex; gap: 10px; font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 3px; flex-wrap: wrap; }
.card-l2 span b { color: var(--text); font-weight: 600; }
.bs { display: inline-flex; width: 42px; height: 4px; border-radius: 2px; overflow: hidden; background: var(--red); vertical-align: middle; margin-left: 4px; }
.bs i { display: block; background: var(--green); height: 100%; }
.ape {
  font-family: var(--mono); font-weight: 700; font-size: 12px; padding: 6px 10px; border-radius: 999px;
  background: var(--green-dim); color: var(--green); border: 1px solid rgba(20, 241, 149, .4);
}
.ape:hover { background: var(--green); color: #04130c; box-shadow: 0 0 16px rgba(20, 241, 149, .5); }

/* ---------- trade ---------- */
.search-row { display: flex; gap: 8px; margin-bottom: 10px; }
.search-row input { flex: 1; }
.search-results { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 6px; margin-bottom: 14px; max-height: 420px; overflow-y: auto; }
.coin-head { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.coin-title { min-width: 0; }
.coin-title h1 { font-size: 22px; margin: 0; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.coin-title h1 .name { font-size: 14px; color: var(--muted); font-weight: 500; }
.coin-links { display: flex; gap: 10px; font-size: 12px; margin-top: 4px; flex-wrap: wrap; align-items: center; }
.coin-stats { display: flex; gap: 18px; flex-wrap: wrap; margin-left: auto; }
.stat .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat .v { font-family: var(--mono); font-size: 15px; font-weight: 600; }
.trade-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; }
.chart-panel { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.chart-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.tf { display: flex; gap: 2px; }
.tf button { border: none; background: transparent; padding: 4px 9px; font-family: var(--mono); font-size: 12px; color: var(--muted); border-radius: 6px; }
.tf button.on { background: var(--panel-2); color: var(--green); }
.chart { height: 440px; width: 100%; }
.chart-bar { flex-wrap: wrap; }
.chart-toggles { display: flex; gap: 6px; }
.chart-toggles .seg button { padding: 4px 9px; font-family: var(--mono); }
.chart-wrap { position: relative; }
.chart-legend { position: absolute; top: 10px; left: 12px; z-index: 3; pointer-events: none; font-family: var(--mono); }
.chart-legend .lg-top { display: flex; align-items: baseline; gap: 8px; }
.chart-legend .lg-k { color: var(--muted); font-size: 12px; }
.chart-legend .lg-v { font-size: 22px; font-weight: 700; text-shadow: 0 0 18px rgba(20, 241, 149, .25); }
.chart-legend .lg-hl { display: flex; gap: 12px; font-size: 11px; margin-top: 2px; }
.chart-status { position: absolute; bottom: 36px; left: 12px; z-index: 3; }
.small-chart { height: 240px; }

.ticket h3 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.ticket .amount-row { display: flex; gap: 6px; }
.ticket .amount-row input { flex: 1; font-size: 18px; padding: 10px 12px; }
.ticket .amount-row .seg { width: auto; flex: none; }
.ticket .amount-row .seg button { padding: 7px 10px; }
.presets { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.presets button { flex: 1; font-family: var(--mono); font-size: 12px; padding: 5px 4px; }
.ticket .seg { width: 100%; }
.ticket .seg button { flex: 1; padding: 7px; }
.ticket input[type=datetime-local] { width: 100%; margin-top: 6px; }
.ticket .summary { margin-top: 12px; font-family: var(--mono); font-size: 12px; color: var(--muted); display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; }
.ticket .summary b { color: var(--text); font-weight: 600; text-align: right; }
.ticket .note { font-size: 12px; color: var(--dim); margin-top: 10px; line-height: 1.5; }
.ape-big { width: 100%; margin-top: 14px; padding: 13px; font-size: 16px; }

/* ---------- portfolio ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.tile .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.tile .v { font-family: var(--mono); font-size: 20px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .s { font-size: 12px; color: var(--muted); margin-top: 2px; font-family: var(--mono); }
.tile.hero { border-color: var(--border-hi); }
.tile.hero.up { box-shadow: 0 0 24px rgba(20, 241, 149, .15); border-color: rgba(20, 241, 149, .4); }
.tile.hero.down { box-shadow: 0 0 24px rgba(255, 77, 109, .15); border-color: rgba(255, 77, 109, .4); }
.tile.hero .v { font-size: 26px; }

.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th { text-align: left; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.grid td { padding: 9px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.grid tr:last-child td { border-bottom: none; }
table.grid .num { text-align: right; }
table.grid td .sub { color: var(--muted); font-size: 11px; font-family: var(--mono); margin-top: 2px; }
.tok { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.tok b:hover { color: var(--green); }
.acts { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.warn { color: var(--yellow); font-size: 11px; margin-top: 3px; }
#activity-panel summary { cursor: pointer; list-style: none; display: flex; gap: 4px 10px; align-items: baseline; flex-wrap: wrap; }
#activity-panel[open] summary { margin-bottom: 10px; }

/* ---------- modal, toasts ---------- */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal-card { width: 100%; max-width: 460px; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--panel); border: 1px solid var(--border-hi); border-radius: 14px; padding: 18px; }
.modal-card h3 { margin: 0 0 8px; }
.modal-card .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.modal-card input, .modal-card select { width: 100%; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--panel-2); border: 1px solid var(--border-hi); border-left: 3px solid var(--green); border-radius: 10px; padding: 10px 12px; font-size: 13px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); }
.toast.bad { border-left-color: var(--red); }

/* ---------- phones ---------- */
@media (max-width: 700px) {
  /* Positions become stacked cards: label on the left, value on the right. */
  table.cards-on-phone thead { display: none; }
  table.cards-on-phone, table.cards-on-phone tbody, table.cards-on-phone tr, table.cards-on-phone td { display: block; width: 100%; }
  table.cards-on-phone tr { border: 1px solid var(--border); border-radius: 12px; padding: 8px 10px; margin-bottom: 10px; background: var(--panel-2); }
  table.cards-on-phone td { border: none; padding: 5px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.cards-on-phone td::before { content: attr(data-label); color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; text-align: left; flex: none; }
  table.cards-on-phone td[data-label="Coin"]::before, table.cards-on-phone td[data-label=""]::before { content: none; }
  table.cards-on-phone td[data-label="Coin"] { justify-content: flex-start; font-size: 15px; border-bottom: 1px solid var(--border); padding-bottom: 8px; margin-bottom: 4px; }
  table.cards-on-phone td > div, table.cards-on-phone td > span { margin-left: auto; }
  table.cards-on-phone td[data-label="Coin"] > div { margin-left: 0; }
  table.cards-on-phone .acts { justify-content: stretch; width: 100%; }
  table.cards-on-phone .acts button { flex: 1; padding: 9px; font-size: 13px; }
  .coin-stats { gap: 10px 16px; }
  .stat .v { font-size: 13px; }
  .topbar-right { margin-left: 0; width: 100%; }
  .ticker { font-size: 11px; }
  .chart { height: 320px; }
  .chart-legend .lg-v { font-size: 18px; }
  .chart-bar { gap: 6px; }
  .tile .v { font-size: 17px; }
  .tile.hero .v { font-size: 21px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tiles .tile.hero { grid-column: span 2; }
}
@media (max-width: 1000px) {
  .trade-grid { grid-template-columns: 1fr; }
  .chart { height: 340px; }
  .coin-stats { margin-left: 0; }
}
@media (max-width: 820px) {
  .col-switch { display: flex; }
  .pulse-cols { grid-template-columns: 1fr; }
  .pcol { display: none; max-height: none; }
  .pcol.on { display: flex; }
  .topbar { gap: 8px; padding: 8px 12px; }
  .tabs { order: 3; width: 100%; }
  .tabs a { flex: 1; text-align: center; }
  main { padding: 12px 12px 64px; }
}
