/* Hyperliquid Tracker — Dark Theme */
:root {
  --bg: #0b0e11;
  --bg-elevated: #161b22;
  --bg-card: rgba(22, 27, 34, 0.92);
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.14);
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #00d4aa;
  --accent-dim: rgba(0, 212, 170, 0.12);
  --danger: #f85149;
  --danger-dim: rgba(248, 81, 73, 0.12);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ─── Auth ─────────────────────────────────────────────────────────────────── */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(0, 212, 170, 0.08), transparent),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 32px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.logo-mark {
  font-size: 1.4rem;
  color: var(--accent);
}

.logo-text {
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

.error-banner {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid rgba(248, 81, 73, 0.25);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.875rem;
  margin-bottom: 18px;
}

.hidden { display: none !important; }

.label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.input {
  width: 100%;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  margin-bottom: 16px;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.code-input {
  letter-spacing: 0.35em;
  font-size: 1.25rem;
  font-weight: 600;
  text-align: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  text-decoration: none;
  color: inherit;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #0b0e11;
}
.btn-primary:hover:not(:disabled) {
  background: #00e6b8;
}

.btn-google {
  background: #fff;
  color: #1f1f1f;
  margin-bottom: 4px;
}
.btn-google:hover {
  background: #f5f5f5;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  margin-top: 8px;
}
.btn-ghost:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.btn-sm {
  width: auto;
  padding: 6px 12px;
  font-size: 0.85rem;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.code-hint {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.code-hint strong { color: var(--text); }

.auth-footer {
  margin-top: 28px;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.4;
}

/* ─── App shell ────────────────────────────────────────────────────────────── */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 14, 17, 0.85);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-email {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.main {
  flex: 1;
  padding: 32px 24px;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

.welcome-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  box-shadow: var(--shadow);
}

.welcome-card h1 {
  font-size: 1.35rem;
  font-weight: 600;
  margin-bottom: 12px;
  background: linear-gradient(90deg, #00d4aa, #00a3ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-card p {
  color: var(--text-muted);
  margin-bottom: 12px;
}

.welcome-card ul {
  margin: 0 0 24px 18px;
  color: var(--text-muted);
  font-size: 0.95rem;
}
.welcome-card li { margin-bottom: 6px; }

.status-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.badge-ok {
  background: var(--accent-dim);
  color: var(--accent);
}

/* ─── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .auth-card { padding: 32px 22px; }
  .header { padding: 12px 16px; }
  .main { padding: 20px 16px; }
  .welcome-card { padding: 28px 20px; }
}

/* ─── Panels ───────────────────────────────────────────────────────────────── */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
}

.panel-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.placeholder-panel h2 {
  font-size: 1.05rem;
  margin-bottom: 8px;
}
.muted { color: var(--text-muted); font-size: 0.9rem; }

.wallets-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wallet-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s;
}
.wallet-card:hover { border-color: var(--border-hover); }

.wallet-emoji {
  font-size: 1.5rem;
  line-height: 1;
  width: 36px;
  text-align: center;
}

.wallet-info {
  flex: 1;
  min-width: 0;
}
.wallet-name {
  font-weight: 500;
  font-size: 0.95rem;
}
.wallet-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 28px 12px;
  line-height: 1.55;
}

.skeleton-card {
  height: 64px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── Modal ────────────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

.modal-dialog {
  position: relative;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.55);
  animation: slideUp 0.25s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 600;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.modal-close:hover { color: var(--text); background: rgba(255,255,255,0.06); }

.modal-body {
  padding: 20px 22px 24px;
}

.modal-wallets {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.modal-wallet-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.22);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.modal-wallet-row .wallet-emoji { font-size: 1.25rem; width: 28px; }
.modal-wallet-row .wallet-name { flex: 1; font-size: 0.9rem; }
.btn-delete {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.85rem;
}
.btn-delete:hover {
  color: var(--danger);
  background: var(--danger-dim);
}

.form-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--text);
}

.emoji-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.emoji-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  font-size: 1.2rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.emoji-btn:hover { border-color: var(--border-hover); }
.emoji-btn.active {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.input-sm {
  padding: 8px 12px;
  font-size: 0.875rem;
  margin-bottom: 14px;
}

.limit-msg {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 12px 0 4px;
}

@media (max-width: 480px) {
  .panel { padding: 18px 16px; }
  .modal-dialog { max-height: 95vh; }
  .modal-body { padding: 16px 16px 20px; }
}

/* ─── Select & Positions ───────────────────────────────────────────────────── */
.select {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 12px;
  font-size: 0.9rem;
  outline: none;
  min-width: 120px;
  cursor: pointer;
}
.select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.small { font-size: 0.8rem; }
.small code {
  background: rgba(255,255,255,0.06);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.75rem;
}

.positions-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.position-card {
  padding: 14px 16px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.position-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.position-coin {
  font-weight: 600;
  font-size: 1rem;
}
.position-side {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  text-transform: uppercase;
}
.position-side.long {
  background: rgba(0, 212, 170, 0.15);
  color: var(--accent);
}
.position-side.short {
  background: var(--danger-dim);
  color: var(--danger);
}
.position-wallet {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.position-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px 12px;
  font-size: 0.8rem;
}
.position-grid .label {
  color: var(--text-muted);
  font-size: 0.72rem;
  margin-bottom: 1px;
}
.position-grid .value {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.pnl-pos { color: var(--accent); }
.pnl-neg { color: var(--danger); }

/* ─── Dashboard layout ─────────────────────────────────────────────────────── */
.dashboard {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 20px 32px;
  align-items: start;
}
@media (max-width: 960px) {
  .dashboard {
    grid-template-columns: 1fr;
  }
  .side { order: -1; }
}

.chart-panel { min-height: 420px; }
.chart-container {
  width: 100%;
  height: 420px;
  position: relative;
}
.chart-toolbar { flex-wrap: wrap; gap: 10px; }
.toolbar-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.tf-group {
  display: flex;
  gap: 4px;
  background: rgba(0,0,0,0.25);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.tf-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 5px 9px;
  border-radius: 7px;
  cursor: pointer;
}
.tf-btn:hover { color: var(--text); }
.tf-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.side { display: flex; flex-direction: column; gap: 16px; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.btn-row .btn { width: auto; }

/* Marker tooltip */
.marker-tooltip {
  position: fixed;
  z-index: 200;
  min-width: 200px;
  max-width: 280px;
  background: rgba(22, 27, 34, 0.97);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
  pointer-events: none;
  font-size: 0.82rem;
  line-height: 1.45;
}
.marker-tooltip .tt-title {
  font-weight: 600;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.marker-tooltip .tt-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-muted);
}
.marker-tooltip .tt-row span:last-child {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
