:root {
  --bg: #0b0f14;
  --panel: #121820;
  --border: #243041;
  --text: #e8edf4;
  --muted: #8b9bb0;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.15);
  --up: #22c55e;
  --down: #ef4444;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: 8px;
}

.brand-mark {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.6);
}

.brand-text {
  font-weight: 600;
  letter-spacing: 0.02em;
}

.live-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.live-badge.on {
  color: #86efac;
  border-color: #166534;
  background: rgba(34, 197, 94, 0.15);
  animation: pulse 1.5s ease-in-out infinite;
}

.live-badge.connecting {
  color: #fde68a;
  border-color: #854d0e;
  background: rgba(234, 179, 8, 0.12);
}

.live-badge.offline {
  color: var(--muted);
}

@keyframes pulse {
  50% {
    opacity: 0.65;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.field select,
.field input {
  min-width: 180px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f141c;
  color: var(--text);
  font-size: 14px;
}

.symbol-field {
  min-width: 200px;
}

.symbol-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 200px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f141c;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}

.symbol-trigger:hover {
  border-color: var(--accent);
}

.symbol-trigger-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a2330;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
}

.symbol-trigger-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.symbol-trigger-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.symbol-trigger-chevron {
  flex-shrink: 0;
  color: var(--muted);
}

.asset-picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.55);
}

.asset-picker {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  width: calc(100% - 2rem);
  max-width: 800px;
  max-height: calc(100vh - 6rem);
  background: #121820;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.asset-picker-inner {
  display: flex;
  height: min(520px, calc(100vh - 7rem));
  max-height: calc(100vh - 7rem);
}

.asset-picker-sidebar {
  width: 200px;
  flex-shrink: 0;
  background: #0f141c;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.asset-picker-sidebar-title {
  margin: 0;
  padding: 12px 14px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.asset-picker-cats {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.asset-cat-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 4px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.asset-cat-btn:hover {
  background: #1a2330;
  color: var(--text);
}

.asset-cat-btn.active {
  background: var(--accent-soft);
  color: #bfdbfe;
  border-color: rgba(59, 130, 246, 0.25);
}

.asset-cat-btn.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 16px;
  border-radius: 0 4px 4px 0;
  background: var(--accent);
  box-shadow: 0 0 6px rgba(59, 130, 246, 0.45);
}

.asset-cat-count {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 6px;
  background: #1a2330;
  color: var(--muted);
}

.asset-cat-btn.active .asset-cat-count {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}

.asset-picker-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.asset-picker-search-wrap {
  position: relative;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.asset-picker-search-icon {
  position: absolute;
  left: 22px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.asset-picker-search {
  width: 100%;
  padding: 10px 12px 10px 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f141c;
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.asset-picker-search:focus {
  border-color: rgba(59, 130, 246, 0.45);
}

.asset-picker-list-head {
  display: grid;
  grid-template-columns: 1fr 72px 72px 32px;
  gap: 8px;
  align-items: center;
  height: 32px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: #0f141c;
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
}

.asset-picker-list-head .col-change,
.asset-picker-list-head .col-profit,
.asset-picker-list-head .col-star {
  text-align: center;
}

.asset-picker-list {
  flex: 1;
  overflow-y: auto;
}

.asset-picker-empty {
  margin: 24px 16px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.asset-row {
  display: grid;
  grid-template-columns: 1fr 72px 72px 32px;
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 10px 16px;
  border: none;
  border-bottom: 1px solid rgba(36, 48, 65, 0.5);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}

.asset-row:hover {
  background: #1a2330;
}

.asset-row.selected {
  background: var(--accent-soft);
}

.asset-row-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.asset-row-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.asset-flags {
  position: relative;
  width: 36px;
  height: 28px;
}

.asset-flag {
  position: absolute;
  width: 24px;
  height: 18px;
  border-radius: 3px;
  overflow: hidden;
}

.asset-flag .fi {
  display: block;
  width: 100%;
  height: 100%;
  background-size: cover;
}

.asset-flag-top {
  top: 0;
  left: 0;
  z-index: 0;
}

.asset-flag-bottom {
  right: 0;
  bottom: 0;
  z-index: 1;
  border: 1px solid rgba(11, 15, 20, 0.55);
}

.symbol-trigger-icon .asset-flags {
  width: 30px;
  height: 22px;
}

.symbol-trigger-icon .asset-flag {
  width: 20px;
  height: 14px;
}

.asset-icon-img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: contain;
  background: #1a2330;
}

.asset-row-name {
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-added-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  margin-left: auto;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid #166534;
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
  font-size: 10px;
  font-weight: 600;
}

.asset-added-badge svg {
  flex-shrink: 0;
}

.asset-col-change {
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.asset-col-change.up {
  color: #4ade80;
}

.asset-col-change.down {
  color: #f87171;
}

.asset-col-profit {
  display: flex;
  justify-content: center;
}

.asset-profit-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid #166534;
  background: #22c55e;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.asset-col-star {
  display: flex;
  justify-content: center;
}

.asset-star-icon {
  color: #4b5563;
  transition: color 0.15s;
}

.asset-row:hover .asset-star-icon {
  color: #9ca3af;
}

.tf-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tf-group button {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f141c;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.tf-group button:hover {
  border-color: var(--accent);
}

.tf-group button.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: #bfdbfe;
}

.toolbar-meta-wrap {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  position: relative;
}

.tz-settings-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f141c;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.tz-settings-btn:hover,
.tz-settings-btn[aria-expanded="true"] {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.tz-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 200;
  min-width: 200px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #121820;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

.tz-popover-title {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.tz-popover-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
}

.tz-popover-field select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f141c;
  color: var(--text);
  font-size: 13px;
}

.meta-panel {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  line-height: 1;
  color: #8e8e93;
  user-select: none;
}

.meta-live {
  display: inline-flex;
  align-items: center;
}

.meta-dot-wrap {
  position: relative;
  display: flex;
  width: 8px;
  height: 8px;
}

.meta-dot-ping {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #34d399;
  opacity: 0.75;
  animation: meta-ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.meta-dot {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
}

@keyframes meta-ping {
  75%,
  100% {
    transform: scale(2);
    opacity: 0;
  }
}

.meta-countdown {
  display: inline-flex;
  align-items: center;
  font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: #8e8e93;
}

.meta-countdown .digit-sep {
  padding: 0 1px;
}

.meta-countdown .digit-slot {
  position: relative;
  display: inline-block;
  overflow: hidden;
  width: 0.6em;
  height: 1.2em;
  line-height: 1.2em;
  text-align: center;
}

.meta-countdown .digit-cell {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.meta-countdown .digit-out-up {
  animation: digit-out-up 200ms ease-out forwards;
}

.meta-countdown .digit-in-up {
  animation: digit-in-up 200ms ease-out forwards;
}

@keyframes digit-out-up {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(-100%);
    opacity: 0;
  }
}

@keyframes digit-in-up {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.meta-tz-label {
  font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;
  font-size: 11px;
  color: #8e8e93;
}

.meta-panel.offline .meta-countdown {
  opacity: 0.55;
}

main {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 72px);
  min-height: 400px;
}

.chart-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
}

#chart {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
}

.chart-markers {
  position: absolute;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  overflow: visible;
}

.candle-vline {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  margin-left: -0.5px;
  background: repeating-linear-gradient(
    to bottom,
    rgba(148, 163, 184, 0.5) 0,
    rgba(148, 163, 184, 0.5) 3px,
    transparent 3px,
    transparent 6px
  );
}

.live-hline {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-top: 1px solid rgba(59, 130, 246, 0.92);
  transform: translateY(-50%);
  pointer-events: none;
  z-index: 18;
}

.chart-markers.up .live-hline {
  border-top-color: rgba(34, 197, 94, 0.95);
}

.chart-markers.down .live-hline {
  border-top-color: rgba(239, 68, 68, 0.95);
}

.lpt-pill {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #3b82f6;
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.5), 0 2px 8px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  z-index: 40;
}

.chart-markers.up .lpt-pill {
  background: #22c55e;
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.5), 0 2px 8px rgba(0, 0, 0, 0.35);
}

.chart-markers.down .lpt-pill {
  background: #ef4444;
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.5), 0 2px 8px rgba(0, 0, 0, 0.35);
}

#chart a[href*="tradingview.com"],
main a[href*="tradingview.com"] {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.hint {
  margin: 0;
  padding: 6px 16px 12px;
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 720px) {
  .toolbar-meta-wrap {
    margin-left: 0;
    width: 100%;
    justify-content: flex-end;
  }
}
