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

:root {
  --navy: #0a1628;
  --deep: #111d33;
  --surface: #162040;
  --orange: #ff6b2b;
  --orange-glow: rgba(255, 107, 43, 0.15);
  --orange-hover: #ff8548;
  --amber: #ffb347;
  --slate: #8a9bb5;
  --light: #c8d6e5;
  --white: #f0f4f8;
  --green: #2ed573;
  --red: #ff4757;
  --sidebar-w: 240px;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--navy);
  color: var(--light);
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3, h4, h5 {
  font-family: 'Space Grotesk', sans-serif;
  color: var(--white);
}

/* Grain overlay */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 1;
}

/* ========== AUTH VIEW ========== */
.auth-container {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  background: var(--deep);
  border: 1px solid rgba(255, 107, 43, 0.12);
  border-radius: 16px;
  padding: 48px;
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--white);
  text-align: center;
  margin-bottom: 8px;
}

.auth-logo span { color: var(--orange); }

.auth-subtitle {
  text-align: center;
  color: var(--slate);
  font-size: 0.9rem;
  margin-bottom: 32px;
}

.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 28px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(138, 155, 181, 0.15);
}

.auth-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  background: transparent;
  border: none;
  color: var(--slate);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

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

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--slate);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid rgba(138, 155, 181, 0.15);
  border-radius: 8px;
  color: var(--white);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus {
  border-color: var(--orange);
}

.form-input::placeholder {
  color: rgba(138, 155, 181, 0.5);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--orange);
  color: white;
  width: 100%;
}

.btn-primary:hover {
  background: var(--orange-hover);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--surface);
  color: var(--light);
  border: 1px solid rgba(138, 155, 181, 0.15);
}

.btn-secondary:hover {
  border-color: var(--orange);
  color: var(--white);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.85rem;
}

.btn-ghost {
  background: transparent;
  color: var(--slate);
  padding: 8px 12px;
}

.btn-ghost:hover {
  color: var(--white);
}

.auth-error {
  background: rgba(255, 71, 87, 0.1);
  border: 1px solid rgba(255, 71, 87, 0.3);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 20px;
  color: var(--red);
  font-size: 0.9rem;
  display: none;
}

.auth-error.visible { display: block; }

/* ========== DASHBOARD LAYOUT ========== */
.dashboard {
  position: relative;
  z-index: 2;
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--deep);
  border-right: 1px solid rgba(138, 155, 181, 0.08);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 10;
}

.sidebar-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--white);
  padding: 0 8px 24px;
  border-bottom: 1px solid rgba(138, 155, 181, 0.08);
  margin-bottom: 24px;
}

.sidebar-logo span { color: var(--orange); }

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--slate);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: 'DM Sans', sans-serif;
}

.nav-item:hover {
  background: var(--surface);
  color: var(--light);
}

.nav-item.active {
  background: var(--orange-glow);
  color: var(--orange);
}

.nav-item .icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
}

.nav-badge {
  margin-left: auto;
  background: var(--orange);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid rgba(138, 155, 181, 0.08);
}

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

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--orange-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--orange);
  font-weight: 700;
  font-size: 0.85rem;
}

.user-name {
  font-size: 0.85rem;
  color: var(--white);
}

.user-email {
  font-size: 0.75rem;
  color: var(--slate);
}

/* Main content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 32px 40px;
  max-width: calc(100vw - var(--sidebar-w));
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}

.page-title {
  font-size: 1.6rem;
  letter-spacing: -0.5px;
}

.page-subtitle {
  color: var(--slate);
  font-size: 0.9rem;
  margin-top: 4px;
}

/* ========== STATS GRID ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--deep);
  border: 1px solid rgba(138, 155, 181, 0.06);
  border-radius: 12px;
  padding: 20px 24px;
  transition: border-color 0.2s;
}

.stat-card:hover {
  border-color: rgba(255, 107, 43, 0.15);
}

.stat-card .label {
  font-size: 0.75rem;
  color: var(--slate);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.stat-card .value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--white);
}

.stat-card .value.orange { color: var(--orange); }
.stat-card .value.green { color: var(--green); }
.stat-card .value.amber { color: var(--amber); }

/* ========== LISTINGS GRID ========== */
.listings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.listing-card {
  background: var(--deep);
  border: 1px solid rgba(138, 155, 181, 0.06);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.2s;
}

.listing-card:hover {
  border-color: rgba(255, 107, 43, 0.2);
  transform: translateY(-2px);
}

.listing-image {
  width: 100%;
  height: 180px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--slate);
  font-size: 2rem;
  overflow: hidden;
}

.listing-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.listing-body {
  padding: 20px;
}

.listing-source {
  display: inline-block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 3px 10px;
  border-radius: 4px;
  margin-bottom: 10px;
  font-weight: 600;
}

.listing-source.pararius {
  background: rgba(52, 152, 219, 0.15);
  color: #3498db;
}

.listing-source.funda {
  background: rgba(255, 179, 71, 0.15);
  color: var(--amber);
}

.listing-title {
  font-size: 1rem;
  margin-bottom: 8px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.listing-price {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--orange);
  margin-bottom: 12px;
}

.listing-features {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
}

.listing-feature {
  font-size: 0.85rem;
  color: var(--slate);
  display: flex;
  align-items: center;
  gap: 4px;
}

.listing-neighborhood {
  font-size: 0.85rem;
  color: var(--slate);
  margin-bottom: 16px;
}

.listing-actions {
  display: flex;
  gap: 8px;
}

/* ========== ALERTS LIST ========== */
.alerts-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.alert-item {
  background: var(--deep);
  border: 1px solid rgba(138, 155, 181, 0.06);
  border-radius: 12px;
  padding: 20px 24px;
  display: flex;
  gap: 20px;
  align-items: center;
  transition: all 0.2s;
  cursor: pointer;
}

.alert-item:hover {
  border-color: rgba(255, 107, 43, 0.15);
}

.alert-item.unread {
  border-left: 3px solid var(--orange);
}

.alert-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
  flex-shrink: 0;
}

.alert-item.read .alert-dot {
  background: var(--surface);
}

.alert-content {
  flex: 1;
  min-width: 0;
}

.alert-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--white);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.alert-meta {
  font-size: 0.8rem;
  color: var(--slate);
  display: flex;
  gap: 12px;
}

.alert-price {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  color: var(--orange);
  white-space: nowrap;
}

.alert-time {
  font-size: 0.8rem;
  color: var(--slate);
  white-space: nowrap;
}

/* ========== SEARCH CRITERIA FORM ========== */
.criteria-form {
  background: var(--deep);
  border: 1px solid rgba(138, 155, 181, 0.06);
  border-radius: 16px;
  padding: 32px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.form-row.three-col {
  grid-template-columns: 1fr 1fr 1fr;
}

.neighborhoods-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.hood-tag {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(138, 155, 181, 0.2);
  background: transparent;
  color: var(--slate);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'DM Sans', sans-serif;
}

.hood-tag:hover {
  border-color: var(--orange);
  color: var(--light);
}

.hood-tag.selected {
  background: var(--orange-glow);
  border-color: var(--orange);
  color: var(--orange);
}

/* Current criteria display */
.current-criteria {
  background: var(--surface);
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 24px;
}

.criteria-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.criteria-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  background: var(--deep);
  border: 1px solid rgba(138, 155, 181, 0.1);
  font-size: 0.85rem;
  color: var(--light);
}

.criteria-chip .chip-label {
  color: var(--slate);
  font-size: 0.75rem;
}

/* ========== EMPTY STATES ========== */
.empty-state {
  text-align: center;
  padding: 60px 24px;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.empty-title {
  font-size: 1.2rem;
  margin-bottom: 8px;
}

.empty-text {
  color: var(--slate);
  font-size: 0.9rem;
  margin-bottom: 24px;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

/* ========== MONITOR STATUS ========== */
.monitor-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--surface);
  border-radius: 8px;
  margin-bottom: 24px;
  font-size: 0.85rem;
}

.monitor-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.monitor-text {
  color: var(--slate);
}

.monitor-text strong {
  color: var(--white);
}

/* ========== LOADING ========== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--slate);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--surface);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========== TOAST ========== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--deep);
  border: 1px solid rgba(255, 107, 43, 0.3);
  border-radius: 10px;
  padding: 14px 24px;
  color: var(--white);
  font-size: 0.9rem;
  z-index: 100;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
  .main-content {
    margin-left: 0;
    padding: 20px;
    max-width: 100vw;
  }
  .form-row, .form-row.three-col {
    grid-template-columns: 1fr;
  }
  .listings-grid {
    grid-template-columns: 1fr;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  .auth-card {
    padding: 32px 24px;
  }
  /* Mobile nav */
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--deep);
    border-top: 1px solid rgba(138, 155, 181, 0.1);
    padding: 8px 0;
    z-index: 20;
    justify-content: space-around;
  }
  .mobile-nav .nav-item {
    flex-direction: column;
    gap: 2px;
    padding: 6px 8px;
    font-size: 0.7rem;
  }
  .mobile-nav .icon { font-size: 1.2rem; }
  .main-content {
    padding-bottom: 80px;
  }
}

@media (min-width: 769px) {
  .mobile-nav { display: none; }
}
