:root {
  --up: hsl(0 72% 51%);
  --down: hsl(142 71% 35%);
}

body {
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, hsl(210 80% 94%), transparent),
    linear-gradient(180deg, hsl(210 40% 98%), hsl(210 30% 96%));
  background-attachment: fixed;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  white-space: nowrap;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  height: 2.5rem;
  padding: 0 1rem;
  transition: background-color 0.15s, border-color 0.15s, opacity 0.15s, transform 0.1s;
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.btn-sm {
  height: 2rem;
  padding: 0 0.75rem;
  font-size: 0.8125rem;
}

.btn-icon {
  height: 2rem;
  width: 2rem;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
}

.btn-primary {
  background: hsl(222 47% 11%);
  color: hsl(210 40% 98%);
}

.btn-primary:hover {
  background: hsl(222 47% 18%);
}

.btn-outline {
  background: hsl(0 0% 100%);
  border-color: hsl(214 32% 91%);
  color: hsl(222 47% 11%);
}

.btn-outline:hover {
  background: hsl(210 40% 96%);
}

.btn-ghost {
  background: transparent;
  color: hsl(222 47% 11%);
}

.btn-ghost:hover {
  background: hsl(210 40% 96%);
}

.btn-destructive {
  background: hsl(0 72% 51%);
  color: white;
}

.btn-destructive:hover {
  background: hsl(0 72% 45%);
}

.select-control {
  height: 2.5rem;
  border-radius: 0.5rem;
  border: 1px solid hsl(214 32% 91%);
  background: hsl(0 0% 100%);
  color: hsl(222 47% 11%);
  padding: 0 0.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s, background-color 0.15s;
}

.select-control:hover {
  background: hsl(210 40% 96%);
}

.select-control:focus {
  border-color: hsl(222 47% 40%);
  box-shadow: 0 0 0 3px hsl(222 47% 40% / 0.15);
}

.field label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: hsl(222 47% 11%);
}

.field input,
.field textarea {
  width: 100%;
  height: 2.5rem;
  border-radius: 0.5rem;
  border: 1px solid hsl(214 32% 91%);
  background: hsl(0 0% 100%);
  padding: 0 0.75rem;
  font-size: 0.875rem;
  outline: none;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.field textarea {
  height: auto;
  min-height: 4.5rem;
  padding: 0.625rem 0.75rem;
  resize: vertical;
}

.field input:focus,
.field textarea:focus {
  border-color: hsl(222 47% 40%);
  box-shadow: 0 0 0 3px hsl(222 47% 11% / 0.08);
}

.pnl-up {
  color: var(--up);
}

.pnl-down {
  color: var(--down);
}

.pnl-flat {
  color: hsl(215 16% 47%);
}

.toast {
  position: fixed;
  left: 50%;
  top: 1rem;
  z-index: 60;
  transform: translateX(-50%);
  max-width: calc(100vw - 2rem);
  border-radius: 0.5rem;
  border: 1px solid hsl(214 32% 91%);
  background: hsl(0 0% 100%);
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  box-shadow: 0 8px 24px hsl(222 47% 11% / 0.1);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

@media (min-width: 640px) {
  .modal {
    align-items: center;
  }
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: hsl(222 47% 11% / 0.45);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 28rem;
  max-height: 90vh;
  overflow: auto;
  border-radius: 0.75rem 0.75rem 0 0;
  border: 1px solid hsl(214 32% 91%);
  background: hsl(0 0% 100%);
  padding: 1.25rem;
  box-shadow: 0 -8px 32px hsl(222 47% 11% / 0.12);
  animation: slide-up 0.2s ease-out;
}

@media (min-width: 640px) {
  .modal-panel {
    border-radius: 0.75rem;
  }
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.portfolio-summary {
  margin-bottom: 0.5rem;
  border-radius: 0.75rem;
  border: 1px solid hsl(214 32% 91%);
  background: hsl(0 0% 100%);
  padding: 0.5rem 0.75rem;
  box-shadow: 0 1px 2px hsl(222 47% 11% / 0.04);
}

.portfolio-summary-main {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.375rem 0.5rem;
}

.portfolio-summary-amount {
  font-size: 1.125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.portfolio-summary-sub {
  margin-left: auto;
}

.card-row {
  border-radius: 0.5rem;
  border: 1px solid hsl(214 32% 91%);
  background: hsl(0 0% 100%);
  padding: 0.5rem 0.75rem;
  box-shadow: 0 1px 2px hsl(222 47% 11% / 0.04);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.card-row:hover {
  border-color: hsl(214 25% 80%);
  box-shadow: 0 4px 12px hsl(222 47% 11% / 0.06);
}

.lot-card {
  border-radius: 0.75rem;
  border: 1px solid hsl(214 32% 91%);
  background: hsl(0 0% 100%);
  padding: 0.875rem 1rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 0.375rem;
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  background: hsl(210 40% 96%);
  color: hsl(215 16% 35%);
}

.badge-open {
  background: hsl(210 90% 95%);
  color: hsl(215 70% 35%);
}

.badge-closed {
  background: hsl(210 20% 94%);
  color: hsl(215 10% 45%);
}

.badge-side-buy {
  background: hsl(0 70% 95%);
  color: hsl(0 65% 40%);
}

.badge-side-sell {
  background: hsl(142 50% 93%);
  color: hsl(142 55% 28%);
}

.chart-toolbar {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.chart-tabs {
  display: flex;
  flex: 1;
  gap: 0.25rem;
  margin-bottom: 0;
  padding: 0.25rem;
  border-radius: 0.5rem;
  background: hsl(210 40% 96%);
}

.chart-tab {
  flex: 1;
  height: 1.875rem;
  border: none;
  border-radius: 0.375rem;
  background: transparent;
  color: hsl(215 16% 47%);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.chart-tab:hover {
  color: hsl(222 47% 11%);
}

.chart-tab.active {
  background: hsl(0 0% 100%);
  color: hsl(222 47% 11%);
  box-shadow: 0 1px 2px hsl(222 47% 11% / 0.06);
}

.chart-tool-group {
  display: flex;
  flex-shrink: 0;
  gap: 0.25rem;
  align-items: stretch;
}

.chart-formula-btn {
  flex-shrink: 0;
  min-width: 3rem;
  height: auto;
  padding: 0 0.75rem;
  border: none;
  border-radius: 0.5rem;
  background: hsl(210 40% 96%);
  color: hsl(215 16% 47%);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.chart-formula-btn.hidden {
  display: none;
}

.chart-formula-btn:hover:not(:disabled) {
  color: hsl(222 47% 11%);
}

.chart-formula-btn.active {
  background: hsl(222 47% 11%);
  color: hsl(0 0% 100%);
  box-shadow: 0 1px 2px hsl(222 47% 11% / 0.12);
}

.chart-formula-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.chart-body {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  min-height: 380px;
}

.chart-panel {
  flex: 1;
  min-width: 0;
  height: 380px;
}

.depth-panel {
  flex-shrink: 0;
  width: 112px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.125rem;
  padding: 0.25rem 0;
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  cursor: pointer;
  user-select: none;
}

.depth-panel[hidden] {
  display: none;
}

.depth-asks,
.depth-bids {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.depth-divider {
  height: 1px;
  margin: 0.35rem 0;
  background: hsl(214 32% 91%);
}

.depth-row {
  display: grid;
  grid-template-columns: 2.55rem minmax(2.5rem, 1fr);
  align-items: center;
  gap: 0.25rem;
  min-height: 1.15rem;
}

.depth-price {
  text-align: right;
  font-weight: 500;
}

.depth-bar-track {
  position: relative;
  height: 0.95rem;
  border-radius: 0.125rem;
  background: hsl(210 40% 96%);
  overflow: hidden;
}

.depth-bar {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  border-radius: 0.125rem;
  min-width: 0;
  transition: width 0.2s ease;
}

.depth-bar-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 0.2rem;
  font-size: 0.625rem;
  color: hsl(222 47% 20%);
  z-index: 1;
  pointer-events: none;
}

.depth-row.is-ask .depth-price {
  color: var(--up);
}

.depth-row.is-ask .depth-bar {
  background: hsl(0 72% 51% / 0.28);
}

.depth-row.is-bid .depth-price {
  color: var(--down);
}

.depth-row.is-bid .depth-bar {
  background: hsl(142 71% 35% / 0.28);
}

.chart-status {
  margin: 0.5rem 0 0;
  text-align: center;
  font-size: 0.8125rem;
  color: hsl(215 16% 47%);
}

.chart-status.is-error {
  color: hsl(0 72% 45%);
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, hsl(210 80% 94%), transparent),
    linear-gradient(180deg, hsl(210 40% 98%), hsl(210 30% 96%));
}

.auth-gate.hidden {
  display: none;
}

.auth-card {
  width: 100%;
  max-width: 22rem;
  border-radius: 0.75rem;
  border: 1px solid hsl(214 32% 91%);
  background: hsl(0 0% 100%);
  padding: 1.5rem;
  box-shadow: 0 8px 24px hsl(222 47% 11% / 0.06);
}

.auth-qr {
  border-radius: 0.5rem;
  border: 1px solid hsl(214 32% 91%);
  background: #fff;
}

.auth-secret {
  display: block;
  border-radius: 0.375rem;
  border: 1px solid hsl(214 32% 91%);
  background: hsl(210 40% 96%);
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  color: hsl(222 47% 11%);
}

.input-control {
  width: 100%;
  height: 2.5rem;
  border-radius: 0.5rem;
  border: 1px solid hsl(214 32% 91%);
  background: hsl(0 0% 100%);
  padding: 0 0.75rem;
  font-size: 0.875rem;
  outline: none;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.input-control:focus {
  border-color: hsl(222 47% 40%);
  box-shadow: 0 0 0 3px hsl(222 47% 40% / 0.15);
}

.text-destructive {
  color: hsl(0 72% 51%);
}
