:root {
  --bg: #0b0e14;
  --fg: #e8edf5;
  --muted: #8b95a7;
  --card: #12161e;
  --panel: #10151d;
  --popover: #171d27;
  --border: #242b38;
  --green: #0ecb81;
  --green-fg: #08110c;
  --red: #f6465d;
  --input: #242b38;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

#app {
  min-height: 100dvh;
}

.page {
  display: flex;
  min-height: 100dvh;
  flex-direction: column;
  background: var(--bg);
}

.header {
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: #0d1118;
}

.header-row {
  display: flex;
  height: 48px;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 4px;
}

.logo {
  display: flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--green);
  color: var(--green-fg);
  font-size: 13px;
  font-weight: 700;
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.nav {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  gap: 4px;
}

.nav a,
.nav-link {
  flex-shrink: 0;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 13px;
  color: var(--muted);
}

.nav a:hover,
.nav-link:hover,
.nav a.active,
.nav-link.active {
  color: var(--fg);
}

.nav a.active,
.nav-link.active {
  background: transparent;
}

.nav a:hover,
.nav-link:hover {
  background: rgba(255, 255, 255, 0.05);
}

.header-actions {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.status {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
}

.dot.off {
  background: var(--red);
}

.ghost,
.primary,
.danger {
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
}

.ghost:hover {
  background: rgba(255, 255, 255, 0.05);
}

.primary {
  background: var(--green);
  color: var(--green-fg);
}

.primary:hover {
  filter: brightness(0.95);
}

.danger {
  background: var(--red);
  color: #fff;
}

.mobile-nav {
  display: none;
  padding: 0 8px 8px;
}

.lang-wrap {
  position: relative;
}

.lang-menu {
  position: absolute;
  top: calc(100% + 4px);
  inset-inline-end: 0;
  z-index: 40;
  width: 196px;
  max-height: min(70vh, 420px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--popover);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.lang-menu button {
  display: block;
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  text-align: start;
  color: var(--muted);
}

.lang-menu button:hover,
.lang-menu button.active {
  color: var(--fg);
  background: rgba(255, 255, 255, 0.05);
}

.ticker {
  position: relative;
  display: flex;
  flex-shrink: 0;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  padding: 8px 16px;
}

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

.pair-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: 6px;
  padding: 2px 4px;
}

.pair-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

.pair-name {
  font-size: 16px;
  font-weight: 600;
}

.badge {
  border-radius: 4px;
  background: rgba(14, 203, 129, 0.15);
  padding: 2px 6px;
  font-size: 10px;
  color: var(--green);
}

.last {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.up {
  color: var(--green);
}

.down {
  color: var(--red);
}

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

.stats {
  display: flex;
  min-width: 0;
  flex: 1;
  gap: 16px;
  overflow-x: auto;
  font-size: 12px;
}

.stat-label {
  font-size: 11px;
  color: var(--muted);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.pulse {
  display: inline-block;
  height: 14px;
  width: 56px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.45;
  }
}

.pair-menu {
  position: absolute;
  top: 100%;
  left: 16px;
  z-index: 30;
  margin-top: 4px;
  width: 224px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--popover);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.pair-menu button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  font-size: 13px;
  text-align: left;
}

.pair-menu button:hover {
  background: rgba(255, 255, 255, 0.05);
}

.desk {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
}

.chart-wrap {
  height: 340px;
  min-width: 0;
  border-bottom: 1px solid var(--border);
}

.chart-toolbar {
  display: flex;
  height: 36px;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  font-size: 12px;
  color: var(--muted);
}

.chart-toolbar button.active {
  color: var(--fg);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  padding: 4px 8px;
}

.chart-el {
  height: calc(100% - 36px);
}

.side {
  display: flex;
  width: 100%;
  flex-direction: column;
  border-top: 1px solid var(--border);
}

.book {
  display: flex;
  height: 380px;
  min-width: 0;
  flex-direction: column;
}

.tabs {
  display: flex;
  height: 36px;
  flex-shrink: 0;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  padding: 0 8px;
  font-size: 12px;
}

.tabs button {
  border-radius: 4px;
  padding: 4px 8px;
  color: var(--muted);
}

.tabs button.active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--fg);
}

.book-body,
.trades-body {
  flex: 1;
  overflow: auto;
  font-size: 12px;
}

.book-row,
.trade-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  padding: 2px 10px;
  font-variant-numeric: tabular-nums;
}

.book-head {
  color: var(--muted);
  font-size: 11px;
}

.spread {
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 600;
}

.trade-panel {
  display: flex;
  min-height: 420px;
  flex-direction: column;
  gap: 12px;
  border-top: 1px solid var(--border);
  padding: 12px;
}

.side-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #1a2230;
  border-radius: 8px;
  padding: 3px;
}

.side-tabs button {
  border-radius: 6px;
  padding: 8px;
}

.side-tabs .buy.active {
  background: var(--green);
  color: var(--green-fg);
}

.side-tabs .sell.active {
  background: var(--red);
  color: #fff;
}

label.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

input.field,
.field input {
  width: 100%;
  border: 1px solid var(--input);
  border-radius: 6px;
  background: var(--card);
  color: var(--fg);
  padding: 8px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.pct-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.submit {
  margin-top: auto;
  width: 100%;
  height: 40px;
  border-radius: 8px;
  font-size: 14px;
}

.orders {
  border-top: 1px solid var(--border);
  padding: 12px 16px 24px;
  font-size: 13px;
  color: var(--muted);
}

.orders .tabs {
  border: 0;
  padding: 0;
  height: auto;
  margin-bottom: 16px;
}

.main {
  width: min(1152px, 100%);
  margin: 0 auto;
  padding: 20px 16px 40px;
  flex: 1;
}

.main h1 {
  margin: 0;
  font-size: 20px;
}

.lead {
  margin: 6px 0 0;
  max-width: 42rem;
  font-size: 13px;
  color: var(--muted);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 16px 0;
}

.chip {
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--muted);
}

.chip.active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--fg);
}

.search {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--fg);
  padding: 6px 10px;
  width: 176px;
}

.table {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.t-head,
.t-row {
  display: grid;
  grid-template-columns: 4fr 3fr 2fr 3fr;
  padding: 10px 12px;
  font-size: 13px;
}

.t-head {
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
}

.t-row {
  border-top: 1px solid var(--border);
  cursor: pointer;
}

.t-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.t-body {
  max-height: min(72vh, 820px);
  overflow: auto;
}

html[dir="rtl"] .pair-menu button,
html[dir="rtl"] .lang-menu button {
  text-align: right;
}

.right {
  text-align: right;
}

.grid {
  display: grid;
  gap: 12px;
}

.card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  padding: 16px;
}

.avatar {
  display: flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(14, 203, 129, 0.15);
  color: var(--green);
  font-size: 13px;
  font-weight: 600;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  padding: 16px;
}

.dialog {
  width: min(400px, 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--popover);
  padding: 20px;
}

.dialog h2 {
  margin: 0 0 8px;
  font-size: 16px;
}

.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  z-index: 60;
  transform: translateX(-50%);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--popover);
  padding: 10px 14px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.hidden {
  display: none !important;
}

@media (min-width: 768px) {
  .status {
    display: flex;
  }

  .mobile-nav {
    display: none !important;
  }
}

@media (max-width: 767px) {
  .nav.desktop {
    display: none;
  }

  .mobile-nav {
    display: flex;
  }

  .status {
    display: none;
  }
}

@media (min-width: 1280px) {
  .page.desk-page {
    height: 100dvh;
    overflow: hidden;
  }

  .desk {
    flex-direction: row;
    overflow: hidden;
  }

  .chart-col {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
  }

  .chart-wrap {
    height: auto;
    min-height: 0;
    flex: 1;
    border-bottom: 0;
  }

  .side {
    width: 560px;
    flex-direction: row;
    overflow: hidden;
    border-top: 0;
    border-left: 1px solid var(--border);
  }

  .book {
    width: 260px;
    height: auto;
    min-height: 0;
  }

  .trade-panel {
    width: 300px;
    min-height: 0;
    height: 100%;
    border-top: 0;
    border-left: 1px solid var(--border);
  }

  .orders.desktop-only {
    display: block;
  }

  .orders.mobile-only {
    display: none;
  }

  .grid.two {
    grid-template-columns: 1fr 1fr;
  }

  .grid.three {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

@media (max-width: 1279px) {
  .orders.desktop-only {
    display: none;
  }
}

@media (min-width: 768px) and (max-width: 1279px) {
  .grid.two {
    grid-template-columns: 1fr 1fr;
  }
}
