:root {
  --bg: #0a0f16;
  --surface: rgba(17, 24, 39, 0.92);
  --surface-strong: #121a27;
  --ink: #f3f6fb;
  --muted: #93a4bd;
  --line: rgba(148, 163, 184, 0.14);
  --accent: #f08c2e;
  --accent-strong: #ff9f43;
  --positive: #4ade80;
  --danger: #ff6b6b;
  --shadow: 0 24px 70px rgba(2, 6, 23, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(240, 140, 46, 0.16), transparent 22%),
    radial-gradient(circle at top right, rgba(59, 130, 246, 0.16), transparent 20%),
    linear-gradient(180deg, #09111b 0%, #0d1522 100%);
}

.page-shell {
  width: min(1040px, calc(100% - 12px));
  margin: 0 auto;
  padding: 8px 0 12px;
}

.test-banner {
  display: inline-flex;
  margin-top: 6px;
  padding: 4px 8px;
  border: 1px solid rgba(240, 140, 46, 0.2);
  border-radius: 999px;
  background: rgba(240, 140, 46, 0.1);
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 600;
}

h1,
h2,
strong {
  margin: 0;
  font-weight: 600;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 5px 9px;
  font: inherit;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.primary-button {
  color: #1b140b;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.secondary-button {
  color: var(--ink);
  background: rgba(30, 41, 59, 0.82);
  border: 1px solid var(--line);
}

.dashboard {
  display: grid;
  gap: 8px;
  margin-top: 6px;
}

.stat-label,
.panel-meta {
  color: var(--muted);
}

.stats-grid {
  display: grid;
  gap: 8px;
}

.top-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.bottom-stats {
  grid-template-columns: 1fr;
}

.stat-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 9px 10px;
}

.stat-card strong {
  display: block;
  margin-top: 3px;
  font-size: clamp(0.92rem, 1.3vw, 1.2rem);
  transition: color 140ms ease;
}

.inline-stat {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 3px;
  flex-wrap: wrap;
}

.inline-stat strong {
  margin-top: 0;
}

#pnlBreakdown {
  white-space: nowrap;
}

.stat-subinfo {
  display: inline-block;
  margin-top: 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.action-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.action-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 5px;
}

.connection-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
}

.meta-inline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
}

.meta-sync {
  grid-column: 2;
}

.meta-expiry {
  grid-column: 3;
  justify-content: flex-end;
  text-align: right;
}

.meta-chip {
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.meta-chip strong {
  display: inline;
  margin: 0 0 0 4px;
  color: #7f8896;
  font-size: inherit;
  font-weight: 500;
}

.price-up {
  color: var(--positive);
}

.price-down {
  color: var(--danger);
}

.panel {
  padding: 9px 10px;
}

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

.dim-title {
  color: var(--muted);
  font-weight: 500;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 4px 4px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 0.78rem;
}

th {
  color: var(--muted);
  font-weight: 600;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.price-input {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.9);
  color: #8e9aab;
  font: inherit;
  text-align: center;
  appearance: textfield;
  -moz-appearance: textfield;
}

.price-input::-webkit-outer-spin-button,
.price-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.buy-button {
  color: #4ade80;
  background: transparent;
  border: 1px solid rgba(74, 222, 128, 0.35);
  white-space: nowrap;
  font-size: 0.72rem;
}

.sell-button {
  color: #ff6b6b;
  background: transparent;
  border: 1px solid rgba(255, 107, 107, 0.35);
  white-space: nowrap;
  font-size: 0.72rem;
}

.chain-table th,
.chain-table td {
  vertical-align: middle;
  text-align: center;
}

.mobile-chain {
  display: none;
  gap: 10px;
}

.mobile-chain-panel {
  display: grid;
  gap: 6px;
}

.mobile-chain-title {
  color: var(--muted);
  font-size: 0.72rem;
}

.atm-row td {
  background: rgba(240, 140, 46, 0.08);
}

.chain-table td {
  min-width: 52px;
}

.strike-col {
  text-align: center;
  font-weight: 500;
  color: #9ec5ff;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  min-width: 70px;
  background: rgba(37, 99, 235, 0.12);
}

.chain-price-cell {
  display: flex;
  align-items: center;
  gap: 0;
  justify-content: center;
}

.mobile-price-stack {
  display: grid;
  justify-items: center;
  gap: 2px;
}

.mobile-price-hint {
  font-size: 0.6rem;
  line-height: 1;
  color: #8fa3bf;
  white-space: nowrap;
}

.chain-qty-cell {
  display: flex;
  align-items: center;
  justify-content: center;
}

.chain-price-input {
  width: 68px;
  min-width: 68px;
  max-width: 68px;
  padding: 4px 6px;
}

.chain-qty-input {
  width: 56px;
  min-width: 56px;
  max-width: 56px;
  padding: 4px 6px;
}

.chain-empty-cell {
  color: var(--muted);
}

.suggested-col {
  color: #7f8896;
}

.suggested-main {
  color: #586273;
}

.suggested-diff {
  font-weight: 500;
}

.suggested-diff.price-down {
  color: #8fa3bf;
}

.center-col {
  text-align: center;
}

.empty-state {
  padding: 10px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.78);
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 10px;
  bottom: 10px;
  max-width: 360px;
  padding: 10px 12px;
  border-radius: 12px;
  color: #fff;
  background: rgba(15, 23, 42, 0.95);
  box-shadow: var(--shadow);
}

.hidden {
  display: none;
}

@media (max-width: 1100px) {
  .bottom-stats {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .top-stats {
    gap: 6px;
  }

  .stat-card {
    padding: 7px 8px;
  }

  .stat-card strong {
    font-size: 0.88rem;
  }

  .stat-label {
    font-size: 0.7rem;
  }

  .inline-stat {
    gap: 4px;
  }

  .stat-subinfo {
    font-size: 0.66rem;
  }
}

@media (max-width: 620px) {
  .top-stats {
    gap: 4px;
  }

  .stat-card {
    padding: 6px;
  }

  .stat-card strong {
    font-size: 0.8rem;
  }

  .stat-label,
  .stat-subinfo {
    font-size: 0.62rem;
  }

  .connection-row {
    grid-template-columns: 1fr;
    align-items: flex-start;
  }

  .meta-inline {
    width: 100%;
    justify-content: flex-start;
    grid-column: auto;
  }

  .chain-table {
    display: none;
  }

  .mobile-chain {
    display: grid;
  }

  .mobile-chain-table {
    display: table;
  }

  .mobile-chain-table .strike-col {
    min-width: 58px;
    font-size: 0.78rem;
  }

  .mobile-chain-table th,
  .mobile-chain-table td {
    padding: 4px 3px;
    font-size: 0.68rem;
  }

  .mobile-chain-table .chain-price-input {
    width: 58px;
    min-width: 58px;
    max-width: 58px;
  }

  .mobile-chain-table .chain-qty-input {
    width: 46px;
    min-width: 46px;
    max-width: 46px;
  }

  .mobile-chain-table .mobile-price-hint {
    font-size: 0.56rem;
  }
}
