:root {
  --bg: #08111f;
  --bg-soft: rgba(15, 24, 41, 0.94);
  --bg-panel: rgba(18, 27, 46, 0.96);
  --bg-sidebar: rgba(10, 18, 32, 0.94);
  --border: rgba(255, 255, 255, 0.14);
  --border-strong: rgba(255, 255, 255, 0.2);
  --text: #edf3fb;
  --text-soft: #c8d3e0;
  --muted: rgba(237, 243, 251, 0.72);
  --blue: #4d7cff;
  --blue-soft: rgba(77, 124, 255, 0.2);
  --green: #22c55e;
  --red: #ef4444;
  --danger: rgba(239, 68, 68, 0.95);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  position: relative;
  display: grid;
  grid-template-columns: auto 350px;
  grid-template-rows: auto 1fr;
  width: 100%;
  height: 100vh;
  background: radial-gradient(circle at top right, rgba(77, 124, 255, 0.12), transparent 18%), var(--bg);
}

.chart-container {
  grid-column: 1;
  grid-row: 2;
  overflow: hidden;
  position: relative;
  height: 100%;
}

.hud-shell {
  grid-column: 1;
  grid-row: 1;
  z-index: 35;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.trade-sidebar {
  position: relative;
  grid-column: 2;
  grid-row: span 2;
}

.ohlc-strip {
  position: absolute;
  top: 0;
  z-index: 30;
}

.indicator-chips {
  position: absolute;
  top: 30px;
  z-index: 30;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
}

.top-toolbar,
.ohlc-strip,
.indicator-chips {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border-radius: 12px;
}

.toolbar-pill {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: 0.16s ease;
}

.toolbar-pill:hover {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
}

.toolbar-pill.is-active,
.toolbar-pill-strong {
  background: linear-gradient(180deg, rgba(77, 124, 255, 0.48), rgba(77, 124, 255, 0.28));
  border-color: rgba(113, 150, 255, 0.55);
}

.timeframe-group {
  display: inline-flex;
  gap: 8px;
}

.ohlc-strip {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.indicator-chips {
  user-select: none;
  min-height: 48px;
}

.indicator-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(79, 118, 181, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.indicator-chip button {
  appearance: none;
  border: none;
  cursor: pointer;
}

.indicator-chip-open {
  background: transparent;
  color: inherit;
  padding: 0;
  font-weight: inherit;
}

.indicator-chip-length,
.indicator-chip-remove {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.indicator-empty {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.trade-sidebar {
  z-index: 36;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(10, 18, 32, 0.98), rgba(14, 22, 38, 0.94));
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.trade-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.trade-sidebar-eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.trade-sidebar-title {
  margin-top: 3px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.trade-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.025));
}

.trade-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.trade-label {
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.trade-input,
.trade-select {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  outline: none;
  transition:
    border-color 0.16s ease,
    background 0.16s ease,
    box-shadow 0.16s ease;
}

.trade-input:focus,
.trade-select:focus {
  border-color: rgba(113, 150, 255, 0.55);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(77, 124, 255, 0.12);
}

.trade-button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.trade-action {
  appearance: none;
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: 14px;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    transform 0.14s ease,
    box-shadow 0.16s ease,
    filter 0.16s ease,
    opacity 0.16s ease;
}

.trade-action:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.trade-action:active {
  transform: translateY(0);
}

.trade-action:disabled {
  opacity: 0.6;
  cursor: wait;
}

.trade-action-long {
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.95), rgba(22, 163, 74, 0.88));
  box-shadow: 0 12px 26px rgba(34, 197, 94, 0.22);
}

.trade-action-short {
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.95), rgba(220, 38, 38, 0.88));
  box-shadow: 0 12px 26px rgba(239, 68, 68, 0.22);
}

.trade-action-close {
  background: linear-gradient(180deg, rgba(71, 85, 105, 0.92), rgba(51, 65, 85, 0.9));
  color: var(--text);
}

.trade-status-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.trade-status-card {
  min-height: 52px;
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

.trade-status-card-muted {
  color: var(--text-soft);
}

#order-status:empty {
  display: none;
}

#order-status.is-success {
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.08);
}

#order-status.is-error {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.08);
}

.countdown {
  position: absolute;
  top: 6px;
  z-index: 99;
  right: 80px;
  pointer-events: none;
  background: var(--danger);
  color: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.overlay-backdrop {
  position: absolute;
  inset: 0;
  z-index: 38;
  background: rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(2px);
}

.modal-card {
  position: absolute;
  z-index: 40;
  left: 50%;
  top: 86px;
  transform: translateX(-50%);
  width: min(720px, calc(100vw - 40px));
  border-radius: 18px;
  border: 1px solid var(--border-strong);
  background: var(--bg-panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-strong);
}

.modal-title {
  color: var(--text);
  font-size: 20px;
  font-weight: 800;
}

.modal-close {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
}

.modal-search-row {
  padding: 14px 22px;
  border-bottom: 1px solid var(--border-strong);
}

.modal-search-input,
.settings-input {
  width: 100%;
  min-height: 52px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 0 16px;
}

.modal-search-input::placeholder {
  color: var(--muted);
}

.modal-list {
  display: flex;
  flex-direction: column;
}

.modal-list-item {
  appearance: none;
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 20px 22px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.modal-list-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.settings-body {
  padding: 18px 22px 10px;
}

.settings-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}

.settings-label {
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  text-transform: lowercase;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 22px 22px;
}

.settings-button {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  min-width: 112px;
  padding: 12px 18px;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}

.settings-button-muted {
  background: rgba(255, 255, 255, 0.05);
}

.settings-button-primary {
  background: linear-gradient(180deg, rgba(77, 124, 255, 0.52), rgba(77, 124, 255, 0.3));
}

.hidden {
  display: none !important;
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto auto;
  }

  .chart-container {
    grid-row: 1;
    height: 90vh;
  }

  .hud-shell {
    grid-row: 2;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .trade-sidebar {
    grid-row: 3;
    grid-column: 1;
  }

  .trade-sidebar {
    border: none;
  }

  .ohlc-strip {
    font-size: 8px;
  }

  .top-toolbar,
  .ohlc-strip,
  .indicator-chips {
    padding: 8px;
  }

  .toolbar-pill {
    padding: 9px 12px;
    font-size: 12px;
  }

  .settings-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}
