:root {
  --bg: #0a0e17;
  --surface: #111827;
  --surface-2: #1a2234;
  --border: #243049;
  --text: #e8edf5;
  --text-muted: #8896ab;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 12px;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", monospace;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(59, 130, 246, 0.15), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(16, 185, 129, 0.08), transparent);
}

.hidden { display: none !important; }

.screen { min-height: 100vh; }

/* Auth */
.auth-card {
  max-width: 420px;
  margin: 10vh auto;
  padding: 2.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4);
}

.logo { text-align: center; margin-bottom: 2rem; }
.logo-icon { font-size: 2.5rem; color: var(--accent); }
.logo-icon.small { font-size: 1.25rem; }
.logo h1 { font-size: 1.75rem; font-weight: 700; margin-top: 0.5rem; }
.subtitle { color: var(--text-muted); font-size: 0.9rem; margin-top: 0.25rem; }

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  background: var(--surface-2);
  padding: 4px;
  border-radius: var(--radius);
}

.tab {
  flex: 1;
  padding: 0.6rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab.active { background: var(--accent); color: white; }

.auth-form label {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

.auth-form input {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.75rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
}

.auth-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Buttons */
.btn {
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn.primary {
  background: var(--accent);
  color: white;
  width: 100%;
  margin-top: 0.5rem;
}

.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn.ghost:hover { color: var(--text); border-color: var(--text-muted); }
.btn.small { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn.danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }
.btn.danger:hover { background: rgba(239, 68, 68, 0.25); }

.error { color: var(--danger); font-size: 0.85rem; margin-top: 0.75rem; }

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  background: rgba(17, 24, 39, 0.8);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-left { display: flex; align-items: center; gap: 0.5rem; }
.brand { font-weight: 700; font-size: 1.1rem; }
.header-right { display: flex; align-items: center; gap: 1rem; }
#username-display { color: var(--text-muted); font-size: 0.9rem; }

/* Main */
.main {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Banner */
.banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius);
  gap: 1rem;
}

.banner.success {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
  justify-content: center;
}

.banner-content { display: flex; align-items: center; gap: 1rem; }
.banner-icon { font-size: 1.5rem; }
.banner p { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.15rem; }
.banner .btn.primary { width: auto; margin-top: 0; white-space: nowrap; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.card h2 { font-size: 1.15rem; margin-bottom: 0.5rem; }
.hint { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 1.25rem; }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.card-header h2 { margin-bottom: 0; }

/* Alert Form */
.alert-form .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 1rem;
  align-items: end;
}

.alert-form label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

.alert-form input {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.7rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.95rem;
}

.alert-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.alert-form .btn.primary { width: auto; margin-top: 0; height: 42px; }

/* Alerts Grid */
.alerts-grid {
  display: grid;
  gap: 1rem;
}

.alert-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1.25rem;
  align-items: center;
  transition: border-color 0.2s;
}

.alert-card:hover { border-color: rgba(59, 130, 246, 0.4); }
.alert-card.inactive { opacity: 0.5; }

.alert-ticker {
  font-family: var(--mono);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
  min-width: 80px;
}

.alert-details { display: flex; flex-direction: column; gap: 0.5rem; }

.price-row {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.price-item label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

.price-item span {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 500;
}

.price-item.current span { color: var(--success); }
.price-item.basis span { color: var(--warning); }

.threshold-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.threshold-bar .lower { color: var(--danger); font-family: var(--mono); }
.threshold-bar .upper { color: var(--success); font-family: var(--mono); }

.alert-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.status-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
}

.status-badge.active { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.status-badge.paused { background: rgba(136, 150, 171, 0.15); color: var(--text-muted); }

.empty {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.75rem 1.5rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(1rem); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@media (max-width: 640px) {
  .alert-form .form-row { grid-template-columns: 1fr; }
  .alert-card { grid-template-columns: 1fr; }
  .banner { flex-direction: column; text-align: center; }
  .main { padding: 1rem; }
}
