:root {
  --bg: #101318;
  --surface: #181d24;
  --surface-2: #202731;
  --line: #303946;
  --text: #eff4f8;
  --muted: #94a3b8;
  --green: #37c986;
  --red: #ff6464;
  --yellow: #f3bf4f;
  --blue: #5ea2ff;
  --teal: #4fd1c5;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.28);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(79, 209, 197, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(243, 191, 79, 0.1), transparent 36%),
    var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 28px clamp(18px, 4vw, 48px) 18px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(32px, 6vw, 68px);
  line-height: 1;
}

h2 {
  font-size: 22px;
}

.market-status {
  display: inline-flex;
  min-width: 132px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  background: rgba(24, 29, 36, 0.78);
  color: var(--muted);
  box-shadow: var(--shadow);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 18px rgba(55, 201, 134, 0.9);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(260px, 0.92fr) minmax(280px, 0.72fr);
  gap: 18px;
  padding: 0 clamp(18px, 4vw, 48px) 42px;
}

.panel,
.market-board {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(32, 39, 49, 0.94), rgba(18, 22, 28, 0.92)),
    rgba(24, 29, 36, 0.88);
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.panel-head,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.account-panel,
.trade-panel {
  min-height: 332px;
}

label,
.select-label {
  display: block;
  margin: 14px 0 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.field-row label {
  margin: 0;
}

.switch-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.switch-control input {
  width: 38px;
  min-height: 20px;
  accent-color: var(--blue);
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #10151c;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(94, 162, 255, 0.18);
}

.inline-control {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.auth-area,
.auth-form {
  display: grid;
}

.auth-area {
  gap: 14px;
}

.auth-tabs {
  width: 100%;
}

.account-summary {
  display: grid;
  min-height: 70px;
  align-content: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-2);
}

.account-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.account-summary strong {
  overflow-wrap: anywhere;
  font-size: 24px;
}

.primary-button,
.ghost-button,
.segment {
  min-height: 40px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0 14px;
  color: var(--text);
  font-weight: 800;
  transition:
    transform 160ms ease,
    background 160ms ease,
    border-color 160ms ease;
}

.primary-button {
  background: var(--blue);
  color: #07111f;
}

.ghost-button {
  background: transparent;
  border-color: var(--line);
}

.primary-button:hover,
.ghost-button:hover,
.segment:hover {
  transform: translateY(-1px);
}

.ghost-button:hover {
  border-color: var(--yellow);
}

.full-width {
  width: 100%;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 76px);
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  background: #10151c;
}

.segment {
  background: transparent;
  color: var(--muted);
}

.segment.active {
  background: var(--surface-2);
  color: var(--text);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.metric {
  min-height: 88px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-2);
}

.metric span,
.order-preview span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: clamp(19px, 2.6vw, 30px);
  line-height: 1.05;
}

.trade-form {
  display: grid;
}

.order-preview,
.risk-strip {
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--surface-2);
}

.risk-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0 0 16px;
  gap: 10px;
}

.risk-strip div {
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #111821;
}

.risk-strip span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.risk-strip strong {
  font-size: 20px;
}

.order-preview span {
  margin: 0;
}

.order-preview strong {
  font-size: 22px;
}

.form-message {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.form-message.error {
  color: var(--red);
}

.form-message.success {
  color: var(--green);
}

.quote-status {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: right;
}

.market-board,
.data-layout,
.table-panel:last-child {
  grid-column: 1 / -1;
}

.market-board {
  padding: 18px;
}

.chart-terminal {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 14px;
  background:
    linear-gradient(180deg, rgba(7, 14, 22, 0.96), rgba(12, 18, 26, 0.94)),
    #0b1118;
}

.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
}

.chart-head div:first-child {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.chart-head span {
  color: var(--teal);
  font-size: 20px;
  font-weight: 900;
}

.chart-head strong {
  font-size: 24px;
}

.chart-meta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: right;
}

#klineCanvas {
  display: block;
  width: 100%;
  height: min(42vh, 420px);
  min-height: 280px;
}

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

.market-card {
  display: grid;
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent),
    var(--surface-2);
}

.market-card button {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.symbol-row,
.price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.symbol {
  font-size: 22px;
  font-weight: 900;
}

.company {
  color: var(--muted);
  font-size: 13px;
}

.price {
  font-size: 24px;
  font-weight: 900;
}

.change {
  border-radius: 999px;
  padding: 5px 8px;
  background: rgba(55, 201, 134, 0.12);
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
}

.change.down {
  background: rgba(255, 100, 100, 0.13);
  color: var(--red);
}

.data-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.68fr);
  gap: 18px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 10px;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  color: var(--text);
}

.empty-row td {
  color: var(--muted);
}

.ranking-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ranking-item {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 66px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
}

.rank {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 6px;
  background: rgba(94, 162, 255, 0.16);
  color: var(--blue);
  font-weight: 900;
}

.ranking-name {
  display: block;
  font-weight: 900;
}

.ranking-return {
  color: var(--muted);
  font-size: 13px;
}

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

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

@media (max-width: 980px) {
  .app-shell,
  .data-layout {
    grid-template-columns: 1fr;
  }

  .market-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chart-head {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 620px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
  }

  .market-status {
    flex: 1;
  }

  .inline-control,
  .metrics-grid,
  .market-grid {
    grid-template-columns: 1fr;
  }

  .segmented {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
