:root {
  --bg: #0c1018;
  --surface: #151b26;
  --surface-2: #1d2533;
  --border: #2b3548;
  --text: #eef3fb;
  --muted: #93a1b6;
  --accent: #7c8cff;
  --green: #22c55e;
  --red: #ef4444;
  --orange: #f59e0b;
  --blue: #38bdf8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(124, 140, 255, 0.18), transparent 32rem),
    radial-gradient(circle at top right, rgba(56, 189, 248, 0.12), transparent 28rem),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  color: white;
  background: var(--accent);
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  filter: brightness(1.08);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

button.secondary {
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

input {
  width: 100%;
  margin-top: 8px;
  color: var(--text);
  background: #0f1520;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

input:focus {
  outline: 2px solid rgba(124, 140, 255, 0.35);
  border-color: var(--accent);
}

.app {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 24px;
}

.hero h1,
.card h2 {
  margin: 0;
}

.hero h1 {
  font-size: clamp(32px, 5vw, 56px);
  line-height: 1;
  letter-spacing: -0.04em;
}

.subtitle {
  max-width: 760px;
  color: var(--muted);
  font-size: 17px;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.muted {
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.card,
.status-card {
  background: rgba(21, 27, 38, 0.9);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.24);
}

.card {
  padding: 20px;
  margin-bottom: 18px;
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 16px;
  align-items: end;
}

.controls label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.checkbox {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 43px;
}

.checkbox input {
  width: auto;
  margin: 0;
}

.status-card {
  padding: 14px 16px;
  margin-bottom: 18px;
}

.status-card.loading {
  border-color: rgba(56, 189, 248, 0.55);
}

.status-card.error {
  border-color: rgba(239, 68, 68, 0.65);
  background: rgba(127, 29, 29, 0.26);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.summary-item {
  padding: 18px;
  background: rgba(21, 27, 38, 0.78);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.summary-item .label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.summary-item .value {
  margin-top: 8px;
  font-size: 28px;
  font-weight: 850;
}

.selected-card {
  display: flex;
  justify-content: space-between;
  gap: 24px;
}

.selected-metrics {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.metric {
  min-width: 120px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.metric .label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.metric .value {
  margin-top: 4px;
  font-weight: 800;
}

.table-card {
  padding-top: 0;
}

.table-page-title {
  margin: 0;
  padding: 20px 0;
  text-align: center;
  font-size: clamp(24px, 3vw, 32px);
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.table-filters {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  justify-self: start;
}

.table-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}

.table-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  justify-self: end;
}

.investment-control {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}

.investment-control input {
  width: 120px;
  margin: 0;
  padding: 7px 10px;
}

.filter-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.filter-checkbox input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.filter-checkbox .filter-number-input {
  width: 64px;
  height: 32px;
  margin: 0;
  padding: 5px 8px;
  text-align: right;
}

.updated-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}

.meta-icon,
.action-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn.is-loading .action-icon {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.center-pagination {
  justify-self: center;
  margin: 0;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 1400px;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: var(--surface);
  font-size: 11px;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

th,
td {
  padding: 10px 7px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td.market-cell {
  min-width: 440px;
  white-space: normal;
}

td.price-cell {
  min-width: 135px;
  white-space: normal;
  line-height: 1.45;
}

.price-pills {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.price-outcome-pill {
  display: inline-flex;
  width: fit-content;
  padding: 4px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

.price-outcome-pill.yes {
  background: rgba(34, 197, 94, 0.16);
  border-color: rgba(34, 197, 94, 0.42);
  color: #86efac;
}

.price-outcome-pill.no {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.42);
  color: #fca5a5;
}

td.spread-cell {
  min-width: 105px;
  white-space: normal;
  line-height: 1.45;
}

td.comp-cell {
  min-width: 58px;
}

td.end-time-cell {
  min-width: 135px;
  white-space: normal;
  line-height: 1.4;
}

td.apy-cell {
  min-width: 82px;
}

.apy-value {
  color: #bbf7d0;
  font-weight: 800;
}

.apy-range {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  line-height: 1.1;
}

.apy-separator {
  color: var(--muted);
  font-weight: 700;
}

.comp-meter {
  position: relative;
  display: inline-flex;
  width: fit-content;
}

.comp-bars {
  display: flex;
  gap: 2px;
}

.comp-bar {
  width: 6px;
  height: 16px;
  border-radius: 2px;
}

.comp-bar-empty {
  background: #4b5563;
}

.comp-zero-badge {
  position: absolute;
  right: -10px;
  bottom: -6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: 2px solid var(--bg);
  border-radius: 999px;
  background: #00b955;
  color: #ffffff;
}

.stacked-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: rgba(124, 140, 255, 0.08);
}

tbody tr.market-row.expanded {
  background: rgba(56, 189, 248, 0.12);
}

tbody tr.orderbook-inline-row {
  cursor: default;
}

tbody tr.orderbook-inline-row:hover {
  background: transparent;
}

.orderbook-inline-row > td {
  padding: 0 0 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.orderbook-inline-host,
.orderbook-inline {
  width: 100%;
}

.orderbook-inline {
  padding: 14px 16px 6px;
  background: rgba(15, 21, 32, 0.45);
  border-top: 1px solid rgba(56, 189, 248, 0.18);
}

.orderbook-inline .orderbook-panel {
  padding: 0;
}

.orderbook-inline .status-card {
  margin-bottom: 12px;
}

.market-title {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 450px;
}

.market-icon-wrap {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 10px;
  background: var(--surface-2);
}

.market-icon {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.market-icon-fallback {
  width: 100%;
  height: 100%;
  border: 1px solid var(--border);
}

.market-name {
  display: -webkit-box;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.market-title-toggle {
  display: -webkit-box;
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  overflow: hidden;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.market-title-toggle:hover,
.market-title-toggle.expanded {
  color: var(--blue);
  text-decoration: underline;
}

.market-external-link {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}

.market-external-link:hover {
  color: var(--blue);
  background: rgba(124, 140, 255, 0.12);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.bottom-pagination {
  margin-top: 16px;
}

.page-nav,
.page-num {
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.page-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.page-nav svg {
  width: 18px;
  height: 18px;
}

.page-nav:hover:not(:disabled),
.page-num:hover:not(.active) {
  background: rgba(124, 140, 255, 0.1);
}

.page-nav:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.page-num.active {
  background: var(--accent);
  color: #ffffff;
}

.page-ellipsis {
  min-width: 20px;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
  user-select: none;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.green {
  color: #bbf7d0;
  background: rgba(34, 197, 94, 0.15);
}

.red {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.16);
}

.orange {
  color: #fed7aa;
  background: rgba(245, 158, 11, 0.16);
}

.gray {
  color: #d1d5db;
  background: rgba(148, 163, 184, 0.14);
}

@media (max-width: 900px) {
  .table-head {
    grid-template-columns: 1fr;
  }

  .table-filters,
  .center-pagination,
  .table-actions {
    justify-self: stretch;
  }

  .table-filters,
  .table-actions,
  .center-pagination,
  .bottom-pagination {
    justify-content: center;
  }
}

.orderbook-app {
  width: min(1320px, calc(100% - 32px));
}

.orderbook-card {
  padding: 0;
  overflow: hidden;
}

.orderbook-header {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.back-btn {
  position: absolute;
  left: 22px;
  top: 18px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.back-btn svg {
  width: 18px;
  height: 18px;
}

.back-btn:hover {
  background: rgba(124, 140, 255, 0.12);
  border-color: rgba(124, 140, 255, 0.35);
}

.orderbook-header-main {
  width: min(760px, calc(100% - 96px));
  text-align: center;
}

.orderbook-header h1 {
  margin: 0 0 8px;
  font-size: 20px;
  line-height: 1.35;
}

.orderbook-title {
  margin: 0;
}

.orderbook-meta {
  margin: 0;
  text-align: center;
  line-height: 1.5;
}

.orderbook-title-link {
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

.orderbook-title-link:hover {
  color: var(--blue);
  text-decoration: underline;
}

.orderbook-title-link:not([href]) {
  cursor: default;
  color: var(--text);
}

.orderbook-title-link:not([href]):hover {
  color: var(--text);
  text-decoration: none;
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--muted);
}

.connection-dot.connected {
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55);
  animation: connection-pulse 2s ease-in-out infinite;
}

.connection-dot.connecting {
  background: var(--orange);
  animation: connection-pulse 1.2s ease-in-out infinite;
}

.connection-dot.disconnected {
  background: var(--red);
  animation: none;
}

@keyframes connection-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.45);
    opacity: 1;
  }
  50% {
    box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
    opacity: 0.75;
  }
}

.orderbook-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.orderbook-actions button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.orderbook-panel {
  padding: 18px 22px 22px;
}

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

.book-side-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.orderbook-table-wrap {
  position: relative;
  max-height: 520px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(15, 21, 32, 0.55);
}

.section-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.section-badge.asks {
  background: #e04e4e;
}

.section-badge.bids {
  background: #4caf50;
}

.section-label-cell {
  width: 56px;
  min-width: 56px;
  padding: 0 8px;
  vertical-align: middle;
  text-align: center;
  border-right: 0;
}

.section-label-row td {
  border-bottom: 1px solid var(--border);
}

.section-label-row .depth-cell {
  padding: 0 14px;
}

.orderbook-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(15, 21, 32, 0.98);
}

.orderbook-table {
  min-width: 980px;
}

.orderbook-table th.depth-col,
.orderbook-table td.depth-cell {
  width: 240px;
  min-width: 240px;
  padding: 0 14px;
}

.depth-bar-track {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  min-height: 34px;
}

.depth-bar {
  height: 22px;
  min-width: 4px;
  border-radius: 2px;
}

.depth-bar.ask {
  background: rgba(139, 92, 246, 0.42);
}

.depth-bar.bid {
  background: rgba(34, 197, 94, 0.38);
}

.orderbook-table th.label-col,
.orderbook-table th.depth-col,
.orderbook-table td.section-label-cell,
.orderbook-table td.depth-cell {
  text-align: left;
}

.orderbook-table th:not(.label-col):not(.depth-col),
.orderbook-table td:not(.section-label-cell):not(.depth-cell) {
  padding: 10px 14px;
  text-align: right;
}

.orderbook-table th:nth-child(3),
.orderbook-table td.price-cell {
  text-align: left;
}

.orderbook-table tbody tr:hover {
  background: rgba(124, 140, 255, 0.06);
}

.ask-text {
  color: #fca5a5;
}

.bid-text {
  color: #86efac;
}

.spread-row td {
  color: var(--muted);
  font-size: 12px;
  text-align: left !important;
  background: rgba(148, 163, 184, 0.06);
  padding: 10px 14px !important;
}

@media (max-width: 900px) {
  .orderbook-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .orderbook-actions {
    justify-content: flex-start;
  }

  .orderbook-header-main {
    width: calc(100% - 56px);
    margin-left: 44px;
  }

  .back-btn {
    left: 16px;
    top: 16px;
  }
}
