:root {
  color-scheme: dark;
  --bg: #020505;
  --panel: rgba(9, 17, 17, 0.94);
  --line: rgba(120, 143, 138, 0.18);
  --text: #f2f6f4;
  --muted: #8a9893;
  --green: #00ef8b;
  --green-soft: rgba(0, 239, 139, 0.14);
  --red: #ff4f78;
  --red-soft: rgba(255, 79, 120, 0.16);
  --gold: #ffd24d;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 85% 100%, rgba(95, 71, 0, 0.18), transparent 28%),
    linear-gradient(180deg, #080909 0%, #010202 48%, #000000 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(0, 255, 163, 0.035), transparent 14%, transparent 86%, rgba(255, 200, 0, 0.03));
}

button,
input,
select {
  font: inherit;
  border: 1px solid var(--line);
  background: rgba(18, 22, 22, 0.95);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
}

input:focus,
select:focus,
button:focus {
  outline: 2px solid rgba(0, 239, 139, 0.25);
  outline-offset: 1px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 18px 28px;
  padding: 14px 18px 10px;
  background: rgba(7, 8, 8, 0.96);
  border-bottom: 1px solid rgba(120, 143, 138, 0.1);
  backdrop-filter: blur(12px);
}

.topbar.is-hidden {
  display: none;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(3, 8px);
  gap: 4px;
  padding: 8px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.03));
}

.brand-mark span {
  width: 8px;
  border-radius: 999px;
}

.brand-mark span:nth-child(1) {
  height: 28px;
  background: #9ef;
}

.brand-mark span:nth-child(2) {
  height: 22px;
  background: #b7ff7d;
}

.brand-mark span:nth-child(3) {
  height: 32px;
  background: #ff8fb2;
}

.brand h1,
.section-header h2,
.book-title-row h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.brand p,
.section-header p,
.detail-empty p,
.modal-header p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.83rem;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(160px, 180px) 120px 110px 110px;
  gap: 12px;
  align-items: end;
}

.toolbar-field,
.toolbar-metric,
.modal-field {
  display: grid;
  gap: 6px;
  position: relative;
}

.toolbar-field span,
.toolbar-metric span,
.modal-field span,
.summary-item span,
.book-row span {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.toolbar-button,
.ghost-button {
  cursor: pointer;
}

.toolbar-button {
  height: 42px;
  background: linear-gradient(180deg, rgba(18, 35, 28, 0.95), rgba(10, 18, 15, 0.95));
}

.restore-topbar {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 40;
  background: rgba(10, 18, 15, 0.96);
}

.restore-topbar.hidden {
  display: none;
}

.toolbar-metric {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(12, 16, 16, 0.95);
}

.statusbar {
  grid-column: 1 / -1;
  display: flex;
  gap: 20px;
  align-items: center;
  color: var(--muted);
  font-size: 0.82rem;
}

.statusbar strong {
  color: var(--text);
}

.connection-pill {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
}

.connection-pill i {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 12px rgba(0, 239, 139, 0.65);
}

.workspace {
  min-height: calc(100vh - 104px);
}

.feed-stage {
  padding: 12px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.candidate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.candidate-card,
.empty-card,
.detail-panel,
.book-panel,
.modal-panel {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(14, 21, 21, 0.98), rgba(7, 11, 11, 0.98));
}

.candidate-card,
.empty-card {
  border-radius: 18px;
  overflow: hidden;
}

.candidate-card {
  cursor: pointer;
}

.candidate-card:hover,
.candidate-card.is-active {
  border-color: rgba(0, 239, 139, 0.32);
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 12px;
  background: linear-gradient(180deg, rgba(20, 35, 35, 0.95), rgba(13, 20, 20, 0.95));
}

.card-symbol-row,
.card-meta,
.card-order-row,
.book-row {
  display: flex;
  align-items: center;
}

.card-head-right {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.card-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.card-symbol-row {
  gap: 8px;
  margin-bottom: 6px;
}

.card-symbol {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.tag {
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}

.tag.bid {
  background: var(--green-soft);
  color: var(--green);
}

.tag.ask {
  background: var(--red-soft);
  color: var(--red);
}

.tag.alpha {
  background: rgba(255, 210, 77, 0.12);
  color: var(--gold);
}

.card-meta {
  gap: 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.card-meta strong {
  color: #51f0d3;
}

.card-body {
  display: grid;
  gap: 1px;
  background: rgba(120, 143, 138, 0.08);
}

.card-order-row {
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(8, 11, 11, 0.98);
  font-size: 0.92rem;
}

.card-order-row.bid {
  border-left: 3px solid var(--green);
}

.card-order-row.ask {
  border-left: 3px solid var(--red);
}

.card-order-rows {
  display: grid;
  gap: 1px;
}

.order-main {
  display: flex;
  gap: 10px;
  align-items: center;
}

.close-coin {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
}

.coin-action {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
}

.coin-action:hover,
.close-coin:hover {
  border-color: rgba(255, 79, 120, 0.4);
  color: var(--text);
}

.card-time {
  color: var(--muted);
  font-size: 0.8rem;
}

.detail-summary {
  margin-bottom: 16px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.summary-item {
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(120, 143, 138, 0.12);
  background: rgba(9, 15, 15, 0.9);
}

.summary-item strong {
  display: block;
  margin-top: 6px;
  font-size: 1rem;
}

.detail-empty {
  min-height: 120px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  border: 1px dashed rgba(120, 143, 138, 0.18);
  background: rgba(5, 8, 8, 0.55);
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.book-panel {
  border-radius: 16px;
  padding: 12px;
  background: rgba(7, 12, 12, 0.92);
}

.book-title-row {
  margin-bottom: 10px;
}

.book-list {
  display: grid;
  gap: 8px;
}

.book-row {
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(11, 17, 17, 0.95);
  border: 1px solid rgba(120, 143, 138, 0.1);
}

.book-row.highlight-bid {
  border-color: rgba(0, 239, 139, 0.4);
  background: rgba(0, 239, 139, 0.08);
}

.book-row.highlight-ask {
  border-color: rgba(255, 79, 120, 0.4);
  background: rgba(255, 79, 120, 0.08);
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 30;
}

.modal-shell.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(4px);
}

.modal-panel {
  position: absolute;
  top: 88px;
  right: 18px;
  width: min(520px, calc(100vw - 36px));
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.modal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.detail-modal-panel {
  width: min(980px, calc(100vw - 36px));
}

.modal-field-wide {
  grid-column: 1 / -1;
}

.blacklist-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 44px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(10, 16, 16, 0.8);
}

.blacklist-chip {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 79, 120, 0.22);
  background: rgba(255, 79, 120, 0.08);
  color: var(--text);
  font-size: 0.82rem;
}

.blacklist-chip button {
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.blacklist-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 20;
  display: grid;
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(10, 16, 16, 0.98);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

.suggestions.hidden {
  display: none;
}

.suggestion-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
}

.suggestion-item:hover,
.suggestion-item.is-active {
  background: rgba(0, 239, 139, 0.1);
}

.suggestion-meta {
  color: var(--muted);
  font-size: 0.8rem;
}

@media (max-width: 1100px) {
  .topbar,
  .toolbar,
  .book-grid,
  .summary-grid,
  .modal-grid {
    grid-template-columns: 1fr;
  }

  .statusbar {
    flex-wrap: wrap;
  }

  .connection-pill {
    margin-left: 0;
  }
}
