:root {
  --bg-dark: #0a0e1a;
  --bg-card: #111827;
  --bg-card2: #1a2235;
  --primary: #00d4ff;
  --primary-dim: rgba(0, 212, 255, 0.12);
  --accent: #7c3aed;
  --accent-dim: rgba(124, 58, 237, 0.15);
  --green: #10b981;
  --green-dim: rgba(16, 185, 129, 0.12);
  --orange: #f59e0b;
  --orange-dim: rgba(245, 158, 11, 0.12);
  --red: #ef4444;
  --error: #ef4444;
  --text: #e2e8f0;
  --text-dim: #64748b;
  --text-muted: #94a3b8;
  --border: rgba(255, 255, 255, 0.07);
  --glass: rgba(255, 255, 255, 0.04);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
  --glow: 0 0 30px rgba(0, 212, 255, 0.15);
}

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

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Background gradient blobs */
body::before {
  content: '';
  position: fixed;
  top: -200px;
  right: -200px;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.12) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  bottom: -200px;
  left: -200px;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(0, 212, 255, 0.08) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ===== GLASS CARD ===== */
.glass {
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ===== VIEWS ===== */
.view {
  display: none;
  animation: fadeIn 0.3s ease;
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== LOGIN PAGE ===== */
#login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  position: relative;
  z-index: 1;
}

#register-page {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  position: relative;
  z-index: 1;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  padding: 48px 40px;
  border-radius: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.logo {
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.auth-subtitle {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 32px;
}

.input-group {
  margin-bottom: 18px;
}

.input-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}

.input-group input,
.input-group select,
.input-group textarea {
  width: 100%;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  transition: all 0.2s ease;
  outline: none;
}

.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
  border-color: var(--primary);
  background: rgba(0, 212, 255, 0.05);
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

.input-group select option {
  background: var(--bg-card);
}

.input-group textarea {
  resize: vertical;
  min-height: 100px;
}

.btn {
  width: 100%;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--glow);
}

.btn-secondary {
  background: var(--glass);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

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

.btn-sm {
  width: auto;
  padding: 8px 18px;
  font-size: 13px;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--red);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.3);
}

.auth-link {
  text-align: center;
  margin-top: 20px;
  color: var(--text-dim);
  font-size: 14px;
}

.auth-link a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.auth-link a:hover {
  text-decoration: underline;
}

.error-msg {
  color: var(--error);
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
  padding: 10px 14px;
  background: rgba(239, 68, 68, 0.1);
  border-radius: 8px;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.success-msg {
  color: var(--green);
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
  padding: 10px 14px;
  background: rgba(16, 185, 129, 0.1);
  border-radius: 8px;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

/* ===== MAIN LAYOUT ===== */
#app {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ===== HEADER ===== */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  height: 64px;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

nav {
  display: flex;
  gap: 4px;
}

.nav-item {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-item:hover {
  color: var(--text);
  background: var(--glass);
}

.nav-item.active {
  color: var(--primary);
  background: var(--primary-dim);
}

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

#user-info {
  font-size: 13px;
  color: var(--text-dim);
  background: var(--glass);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 8px;
}

#logout-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Outfit', sans-serif;
}

#logout-btn:hover {
  border-color: var(--red);
  color: var(--red);
}

/* ===== MAIN CONTENT ===== */
main {
  flex: 1;
  padding: 32px;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}

/* ===== HERO ===== */
.hero {
  margin-bottom: 32px;
}

.hero h1 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 8px;
}

.hero p {
  color: var(--text-dim);
  font-size: 16px;
}

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

.stat-card {
  padding: 24px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}

.stat-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

/* ===== SECTION HEADER ===== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.section-header h2 {
  font-size: 20px;
  font-weight: 600;
}

/* ===== SEARCH ===== */
.search-wrap {
  position: relative;
}

.search-wrap input {
  padding: 10px 16px 10px 40px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-family: 'Outfit', sans-serif;
  width: 260px;
  outline: none;
  transition: all 0.2s;
}

.search-wrap input:focus {
  border-color: var(--primary);
  width: 320px;
}

.search-wrap::before {
  content: '🔍';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  pointer-events: none;
}

/* ===== ENTITY CARDS ===== */
.entities-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

.entity-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all 0.25s ease;
  cursor: pointer;
}

.entity-card:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: var(--glow);
}

.entity-tag {
  display: inline-block;
  padding: 4px 10px;
  background: var(--primary-dim);
  color: var(--primary);
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  align-self: flex-start;
}

.entity-tag.green {
  background: var(--green-dim);
  color: var(--green);
}

.entity-tag.orange {
  background: var(--orange-dim);
  color: var(--orange);
}

.entity-tag.purple {
  background: var(--accent-dim);
  color: #a78bfa;
}

.entity-title {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
}

.entity-desc {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  line-clamp: 3;
}

.entity-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
}

/* ===== MATCH CARDS ===== */
.matches-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.match-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  transition: all 0.2s;
}

.match-card:hover {
  border-color: var(--accent);
}

.match-info h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}

.match-meta {
  font-size: 13px;
  color: var(--text-dim);
}

.match-score-wrap {
  text-align: center;
}

.match-score {
  font-size: 32px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--green), var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.match-score-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.match-status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  margin-top: 8px;
}

.match-status.suggested {
  background: var(--accent-dim);
  color: #a78bfa;
}

.match-status.interested {
  background: var(--green-dim);
  color: var(--green);
}

.match-status.declined {
  background: rgba(239, 68, 68, 0.1);
  color: var(--red);
}

/* ===== MESSAGES ===== */
.conversations-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  height: calc(100vh - 200px);
}

.conv-list {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-y: auto;
}

.conv-item {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.conv-item:hover {
  background: var(--primary-dim);
}

.conv-item.active {
  background: var(--primary-dim);
  border-left: 3px solid var(--primary);
}

.conv-item h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.conv-item p {
  font-size: 12px;
  color: var(--text-dim);
}

.conv-placeholder {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 14px;
}

.chat-area {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-msg {
  max-width: 70%;
}

.chat-msg.mine {
  align-self: flex-end;
}

.chat-msg .bubble {
  padding: 10px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
}

.chat-msg.mine .bubble {
  background: var(--primary);
  color: #000;
  border-bottom-right-radius: 4px;
}

.chat-msg.theirs .bubble {
  background: var(--bg-card2);
  border-bottom-left-radius: 4px;
}

.chat-msg .time {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}

.chat-input-row {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
}

.chat-input-row input {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-family: 'Outfit', sans-serif;
  outline: none;
}

.chat-input-row input:focus {
  border-color: var(--primary);
}

/* ===== LOADING ===== */
.loading-wrap {
  text-align: center;
  padding: 60px;
}

.spinner {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-wrap p {
  margin-top: 16px;
  color: var(--text-dim);
  font-size: 14px;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
}

.empty-state h3 {
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--text);
}

.empty-state p {
  font-size: 14px;
  margin-bottom: 20px;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 32px;
  animation: fadeIn 0.25s ease;
}

.modal h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
}

.modal .modal-subtitle {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 24px;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--glass);
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  position: relative;
}

/* ===== TABS ===== */
.tab-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
}

.tab-btn {
  padding: 8px 20px;
  border-radius: 8px;
  background: none;
  border: 1px solid transparent;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Outfit', sans-serif;
}

.tab-btn.active {
  background: var(--primary-dim);
  border-color: var(--primary);
  color: var(--primary);
}

.tab-btn:hover:not(.active) {
  background: var(--glass);
  color: var(--text);
}

/* ===== NO PROFILE WARNING ===== */
.no-profile-banner {
  background: var(--accent-dim);
  border: 1px solid rgba(124, 58, 237, 0.3);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 20px;
  display: none;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: #c4b5fd;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .conversations-layout {
    grid-template-columns: 1fr;
  }

  header {
    padding: 0 16px;
  }

  main {
    padding: 16px;
  }
}

@media (max-width: 600px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .auth-card {
    padding: 32px 24px;
  }

  .entities-grid {
    grid-template-columns: 1fr;
  }
}