:root {
  color-scheme: dark;
  --bg: #111311;
  --panel: #191c19;
  --panel-2: #202420;
  --panel-3: #272c27;
  --line: #343a34;
  --line-soft: #292e29;
  --text: #f2f5f0;
  --muted: #929b92;
  --muted-2: #687068;
  --green: #a7e82e;
  --green-soft: #25351d;
  --amber: #f5b942;
  --amber-soft: #382d18;
  --red: #ff6b63;
  --red-soft: #3a211f;
  --cyan: #63d5ce;
  --cyan-soft: #1d3331;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  letter-spacing: 0;
}

button, input, select { font: inherit; letter-spacing: 0; }
button { color: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 64px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(17, 19, 17, 0.96);
  backdrop-filter: blur(14px);
}

.brand, .topbar-actions, .connection, .panel-heading, .token-identity, .token-title,
.scan-meta, .row-actions, .trading-lock, .event-item { display: flex; align-items: center; }

.brand { gap: 12px; }
.brand-mark {
  width: 28px;
  height: 28px;
  border: 2px solid var(--green);
  border-radius: 50%;
  position: relative;
}
.brand-mark::before, .brand-mark::after {
  content: "";
  position: absolute;
  background: var(--green);
}
.brand-mark::before { width: 2px; height: 10px; left: 12px; top: 2px; }
.brand-mark::after { width: 8px; height: 2px; left: 12px; top: 12px; }
.brand h1, .panel-heading h2, .table-head h2 { margin: 0; font-weight: 700; letter-spacing: 0; }
.brand h1 { font-size: 16px; }
.brand p { margin: 3px 0 0; color: var(--green); font-size: 10px; font-weight: 800; }
.topbar-actions { gap: 10px; }
.connection { gap: 7px; color: var(--muted); font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted-2); }
.connection.connected .status-dot { background: var(--green); box-shadow: 0 0 0 3px rgba(167, 232, 46, 0.12); }
.connection.error .status-dot { background: var(--red); }
.readonly-badge, .wallet-state, .status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}
.readonly-badge { color: var(--green); background: var(--green-soft); border: 1px solid #3b5825; }
.readonly-badge.live { color: #10160c; background: var(--green); border-color: var(--green); }
.readonly-badge.paused { color: var(--amber); background: var(--amber-soft); border-color: #66502a; }
.icon-button, .command-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}
.command-button {
  width: auto;
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-color: #455f32;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}
.icon-button:hover { border-color: var(--green); color: var(--green); }
.command-button:hover { border-color: var(--green); background: var(--green-soft); }
.icon-button:disabled { opacity: 0.45; cursor: wait; }

main { width: min(1680px, 100%); margin: 0 auto; }
.overview-band {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}
.metric { min-height: 112px; padding: 20px 24px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric-label { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin: 7px 0 5px; font-size: 30px; line-height: 1; font-variant-numeric: tabular-nums; }
.metric small { color: var(--muted-2); font-size: 11px; }
.metric-reached strong { color: var(--cyan); }
.metric-track strong { color: var(--green); }
.metric-breakout strong { color: var(--green); }
.metric-invalidated strong { color: var(--amber); }

.control-band {
  min-height: 58px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}
.tabs { display: flex; align-items: stretch; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  height: 58px;
  padding: 0 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
}
.tab span { margin-left: 5px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--green); }
.tab.active span { color: var(--green); }
.scan-meta { gap: 9px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.separator { width: 3px; height: 3px; border-radius: 50%; background: var(--muted-2); }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 320px; min-height: calc(100vh - 235px); }
.token-panel { min-width: 0; border-right: 1px solid var(--line); }
.table-head { min-height: 76px; padding: 15px 20px 14px 24px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.table-head h2 { font-size: 15px; }
.table-head p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.table-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; }
.active-filters { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.active-filters[hidden] { display: none; }
.filter-group { min-height: 32px; display: flex; align-items: center; gap: 6px; }
.filter-group > span { color: var(--muted-2); font-size: 9px; white-space: nowrap; }
.filter-segments { display: flex; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.filter-segments button { min-width: 38px; height: 30px; padding: 0 7px; border: 0; border-right: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: 9px; cursor: pointer; white-space: nowrap; }
.filter-segments button:last-child { border-right: 0; }
.filter-segments button:hover { color: var(--text); background: var(--panel-3); }
.filter-segments button.selected { color: #10160c; background: var(--green); }
.chain-filter select {
  width: 116px;
  height: 36px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: 0;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}
.chain-filter select:focus { border-color: #596559; }
.search-field {
  width: min(260px, 40%);
  height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
}
.search-field input { min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); }
.search-field:focus-within { border-color: #596559; }

.table-scroll { overflow-x: auto; }
table { width: 100%; min-width: 1620px; border-collapse: collapse; table-layout: fixed; }
th, td { padding: 13px 12px; border-top: 1px solid var(--line-soft); text-align: left; vertical-align: middle; }
th { height: 40px; color: var(--muted-2); background: #151815; font-size: 10px; font-weight: 700; text-transform: uppercase; }
th:first-child, td:first-child { width: 15%; padding-left: 24px; }
th:nth-child(2) { width: 5%; }
th:nth-child(3), th:nth-child(4) { width: 8%; }
th:nth-child(5) { width: 10%; }
th:nth-child(6) { width: 7%; }
th:nth-child(7) { width: 12%; }
th:nth-child(8) { width: 7%; }
th:nth-child(9) { width: 9%; }
th:nth-child(10) { width: 9%; }
th:nth-child(11) { width: 9%; }
th:last-child { width: 68px; }
tbody tr { transition: background 120ms ease; }
tbody tr:hover { background: #171a17; }
.token-identity { min-width: 0; gap: 10px; }
.token-link { color: inherit; text-decoration: none; border-radius: 4px; }
.token-link:hover .token-title strong, .token-link:focus-visible .token-title strong { color: var(--green); }
.token-link:focus-visible { outline: 1px solid var(--green); outline-offset: 4px; }
.token-open { color: var(--muted-2); font-size: 12px; line-height: 1; }
.token-link:hover .token-open, .token-link:focus-visible .token-open { color: var(--green); }
.token-logo, .token-fallback { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); object-fit: cover; background: var(--panel-3); }
.token-fallback { display: grid; place-items: center; color: var(--green); font-weight: 800; }
.token-copy { min-width: 0; }
.token-title { min-width: 0; gap: 7px; }
.token-title strong { max-width: 128px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chain-tag { padding: 2px 5px; border: 1px solid #425042; border-radius: 3px; color: #b7c1b7; font-size: 9px; font-weight: 700; }
.token-ca { margin-top: 4px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; }
.numeric { font-variant-numeric: tabular-nums; }
.numeric strong { display: block; font-size: 13px; }
.numeric small { display: block; margin-top: 4px; color: var(--muted-2); font-size: 10px; }
.mention-count { font-size: 15px; font-weight: 750; font-variant-numeric: tabular-nums; }
.mention-count.ready { color: var(--green); }
.kol-count { color: var(--green); font-size: 15px; font-weight: 750; font-variant-numeric: tabular-nums; }
.kol-cell small { display: block; margin-top: 4px; color: var(--muted-2); font-size: 9px; white-space: nowrap; }
.box-range strong { white-space: nowrap; }
.pnl-value { font-weight: 750; font-variant-numeric: tabular-nums; }
.pnl-value.positive { color: var(--green); }
.pnl-value.negative { color: var(--red); }
.protection-copy strong, .protection-copy span { display: block; }
.protection-copy strong { font-size: 12px; }
.protection-copy span { margin-top: 4px; color: var(--muted-2); font-size: 10px; }
.protection-copy.active strong { color: var(--green); }
.protection-copy.warning strong { color: var(--red); }
.progress-track { width: 100%; height: 5px; margin-bottom: 6px; border-radius: 3px; background: var(--panel-3); overflow: hidden; }
.progress-bar { height: 100%; border-radius: inherit; background: var(--cyan); }
.progress-bar.breakout { background: var(--green); }
.progress-bar.deadline { background: var(--green); }
.progress-bar.kol { background: var(--amber); }
.progress-copy { color: var(--muted); font-size: 10px; }
.status-waiting_kol { color: var(--amber); background: var(--amber-soft); }
.status-waiting_high { color: var(--muted); background: #292c29; }
.status-waiting_pullback { color: var(--amber); background: var(--amber-soft); }
.status-observing_low { color: var(--green); background: var(--green-soft); }
.status-sideways_candidate { color: var(--green); background: var(--green-soft); }
.status-sideways_confirmed { color: var(--cyan); background: var(--cyan-soft); }
.status-breakout { color: var(--green); background: var(--green-soft); }
.status-sideways_invalidated { color: var(--amber); background: var(--amber-soft); }
.status-deep_drop { color: var(--red); background: var(--red-soft); }
.status-expired, .status-kol_expired, .status-legacy_archived, .status-abandoned_manual, .status-excluded, .status-trade_failed { color: var(--muted); background: #292c29; }
.status-holding { color: var(--cyan); background: var(--cyan-soft); }
.status-completed { color: var(--green); background: var(--green-soft); }
.status-manual_review { color: var(--red); background: var(--red-soft); }
.status-error { color: var(--red); background: var(--red-soft); }
.status-stack > div { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 5px; }
.status-age { display: block; margin-top: 4px; color: var(--muted-2); font-size: 9px; font-variant-numeric: tabular-nums; }
.today-badge { display: inline-flex; align-items: center; min-height: 20px; padding: 0 6px; border: 1px solid #54762f; border-radius: 3px; color: #dfffad; background: #26371c; font-size: 9px; font-weight: 800; white-space: nowrap; }
.received-badge { display: inline-flex; align-items: center; min-height: 20px; padding: 0 6px; border: 1px solid var(--line); border-radius: 3px; font-size: 9px; font-weight: 800; white-space: nowrap; }
.received-badge.today { color: #10160c; border-color: var(--green); background: var(--green); }
.received-badge.yesterday { color: #d7ded7; border-color: #4d574d; background: #292e29; }
.row-actions { justify-content: flex-end; gap: 5px; }
.row-button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  display: grid;
  place-items: center;
}
.row-button:hover { background: var(--panel-3); color: var(--text); }
.empty-state { padding: 90px 24px; text-align: center; color: var(--muted); }
.empty-state strong, .empty-state span { display: block; }
.empty-state strong { color: var(--text); margin-bottom: 7px; }

.side-rail { background: #141714; }
.side-rail section { padding: 20px; border-bottom: 1px solid var(--line); }
.panel-heading { justify-content: space-between; gap: 10px; margin-bottom: 17px; }
.panel-heading h2 { margin-top: 4px; font-size: 14px; }
.eyebrow { color: var(--muted-2); font-size: 9px; font-weight: 800; text-transform: uppercase; }
.service-state { min-height: 24px; padding: 0 8px; display: inline-flex; align-items: center; border-radius: 4px; color: var(--muted); background: var(--panel-3); font-size: 10px; font-weight: 750; }
.service-state.ok { color: var(--green); background: var(--green-soft); }
.service-state.error { color: var(--red); background: var(--red-soft); }
.service-summary { padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.service-summary strong, .service-summary span { display: block; }
.service-summary strong { font-size: 12px; }
.service-summary span { margin-top: 5px; color: var(--muted); font-size: 10px; line-height: 1.45; overflow-wrap: anywhere; }
.wallet-address {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  cursor: pointer;
}
.wallet-address:hover { color: var(--text); }
.wallet-balance { margin: 18px 0; }
.wallet-balance span { color: var(--muted); font-size: 11px; }
.wallet-balance strong { display: block; margin-top: 5px; font-size: 26px; font-variant-numeric: tabular-nums; }
.wallet-balance small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.wallet-grid { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.wallet-grid div { padding: 11px 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.wallet-grid div:nth-child(2n) { border-right: 0; }
.wallet-grid div:nth-child(n+3) { border-bottom: 0; }
.wallet-grid span, .wallet-grid strong { display: block; }
.wallet-grid span { color: var(--muted-2); font-size: 9px; }
.wallet-grid strong { margin-top: 4px; font-size: 12px; }
.trading-lock { gap: 10px; margin-top: 14px; padding: 11px; border-radius: 6px; background: var(--red-soft); color: #ffd1cd; }
.trading-lock > div { min-width: 0; flex: 1; }
.trading-lock.active { background: var(--green-soft); color: #dfffb8; }
.trading-lock.paused { background: var(--amber-soft); color: #ffe2a6; }
.lock-mark { width: 16px; height: 13px; border: 2px solid var(--red); border-radius: 3px; position: relative; }
.lock-mark::before { content: ""; position: absolute; width: 8px; height: 7px; left: 2px; top: -8px; border: 2px solid var(--red); border-bottom: 0; border-radius: 6px 6px 0 0; }
.trading-lock strong, .trading-lock span { display: block; }
.trading-lock strong { font-size: 11px; }
.trading-lock span { margin-top: 3px; color: #ba8d89; font-size: 9px; }
.trading-lock.active span { color: #91b86d; }
.trading-lock.paused span { color: #b89a63; }
.pause-button { min-height: 28px; padding: 0 9px; border: 1px solid currentColor; border-radius: 5px; background: transparent; color: inherit; cursor: pointer; font-size: 10px; font-weight: 750; }
.pause-button:hover { background: rgba(255,255,255,.06); }
.pause-button:disabled { opacity: .5; cursor: wait; }
.rule-line { min-height: 42px; display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 9px; border-top: 1px solid var(--line-soft); }
.rule-line > span { color: var(--muted-2); font-family: ui-monospace, monospace; font-size: 9px; }
.rule-line p { margin: 0; color: var(--muted); font-size: 11px; }
.rule-line strong { font-size: 11px; }
.event-list { display: grid; gap: 12px; }
.event-item { gap: 9px; min-width: 0; }
.event-mark { flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%; background: var(--muted-2); }
.event-item.confirmed .event-mark { background: var(--cyan); }
.event-item.breakout .event-mark { background: var(--green); }
.event-item.invalidated .event-mark { background: var(--amber); }
.event-copy { min-width: 0; }
.event-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.event-copy span { display: block; margin-top: 3px; color: var(--muted-2); font-size: 9px; }
.muted-copy { color: var(--muted); font-size: 11px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 40; min-width: 190px; max-width: 340px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-3); box-shadow: 0 12px 32px rgba(0,0,0,.35); opacity: 0; transform: translateY(8px); pointer-events: none; transition: 160ms ease; }
.toast.show { opacity: 1; transform: translateY(0); }

.add-dialog {
  width: min(460px, calc(100vw - 28px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 70px rgba(0,0,0,.55);
}
.add-dialog::backdrop { background: rgba(5, 7, 5, .72); backdrop-filter: blur(3px); }
.add-dialog form { padding: 20px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.dialog-heading h2 { margin: 4px 0 0; font-size: 17px; }
.dialog-close { width: 30px; height: 30px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); cursor: pointer; font-size: 22px; line-height: 1; }
.dialog-close:hover { background: var(--panel-3); color: var(--text); }
.dialog-field { display: block; margin-top: 22px; }
.dialog-field span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 11px; }
.dialog-field input, .dialog-field select { width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; outline: 0; background: #121512; color: var(--text); font-size: 12px; }
.dialog-field input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.dialog-field input:focus, .dialog-field select:focus { border-color: var(--green); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.primary-button, .secondary-button { min-height: 36px; padding: 0 13px; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; font-weight: 700; }
.secondary-button { background: transparent; color: var(--muted); }
.secondary-button:hover { color: var(--text); background: var(--panel-3); }
.primary-button { border-color: var(--green); background: var(--green); color: #11170c; }
.primary-button:hover { background: #b4f23e; }
.primary-button:disabled { opacity: .55; cursor: wait; }

[data-tooltip] { position: relative; }
[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  z-index: 60;
  right: 0;
  top: calc(100% + 7px);
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #080a08;
  color: var(--text);
  font-size: 10px;
  white-space: nowrap;
  pointer-events: none;
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 1080px) {
  .workspace { grid-template-columns: 1fr; }
  .token-panel { border-right: 0; }
  .side-rail { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); }
  .event-panel { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .topbar { height: 58px; padding: 0 14px; }
  .brand h1 { font-size: 14px; }
  .brand-mark { width: 24px; height: 24px; }
  .brand-mark::before { left: 10px; }
  .brand-mark::after { left: 10px; top: 11px; }
  .connection span:last-child { display: none; }
  .overview-band { grid-template-columns: repeat(9, minmax(105px, 1fr)); overflow-x: auto; }
  .metric { min-height: 94px; padding: 15px 14px; }
  .metric strong { font-size: 24px; }
  .control-band { padding: 0; display: block; }
  .tabs { padding: 0 10px; }
  .tab { height: 50px; padding: 0 10px; }
  .scan-meta { min-height: 36px; padding: 0 14px; border-top: 1px solid var(--line-soft); }
  .table-head { min-height: auto; padding: 14px; display: block; }
  .table-tools { margin-top: 12px; }
  .active-filters { width: 100%; justify-content: flex-start; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
  .filter-group { flex: 0 0 auto; }
  .chain-filter { flex: 0 0 auto; }
  .search-field { width: 100%; max-width: none; margin-top: 0; }
  table, tbody { display: block; }
  thead { display: none; }
  tbody { padding: 0 10px 10px; }
  table { min-width: 0; }
  tbody tr { position: relative; display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); overflow: hidden; }
  tbody td { display: block; width: auto !important; min-width: 0; padding: 11px 12px; border-top: 1px solid var(--line-soft); }
  tbody td:first-child { grid-column: 1 / -1; padding-left: 12px; border-top: 0; }
  tbody td:nth-child(2) { border-right: 1px solid var(--line-soft); }
  tbody td:last-child { position: absolute; right: 18px; margin-top: 7px; border: 0; }
  tbody td:nth-child(n+4):not(:last-child) { grid-column: 1 / -1; }
  .token-title strong { max-width: 190px; }
  .side-rail { grid-template-columns: 1fr; }
  .event-panel { grid-column: auto; }
  .side-rail section { padding: 18px 14px; }
}

@media (max-width: 420px) {
  .readonly-badge { display: none; }
  .command-button { width: 34px; padding: 0; justify-content: center; }
  .command-button span:last-child { display: none; }
  .metric { min-width: 98px; }
  tbody td { padding: 10px; }
  .token-title strong { max-width: 142px; }
}
