/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: 'DM Sans', sans-serif;
  background: #0d0d0f;
  color: #e8e4df;
  min-height: 100vh;
  display: flex;
}

/* === CSS VARIABLES === */
:root {
  --bg: #0d0d0f;
  --bg2: #13131a;
  --bg3: #1a1a24;
  --border: rgba(255,255,255,0.08);
  --border-hover: rgba(255,255,255,0.15);
  --text: #e8e4df;
  --text-muted: #8a8490;
  --text-dim: #5c5864;
  --accent: #c4ff61;
  --accent-dim: rgba(196, 255, 97, 0.12);
  --accent-border: rgba(196, 255, 97, 0.3);
  --red: #ff5f5f;
  --orange: #ff9538;
  --yellow: #f4d03f;
  --green: #4ade80;
  --radius: 10px;
  --sidebar-w: 220px;
}

/* === LAYOUT === */
#app {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

/* === SIDEBAR === */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 28px 16px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
}

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

.logo-mark {
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: #0d0d0f;
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 18px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-text {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.3px;
}

.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.nav-btn:hover { background: var(--bg3); color: var(--text); }
.nav-btn.active { background: var(--accent-dim); color: var(--accent); border: 1px solid var(--accent-border); }
.nav-btn.active svg { stroke: var(--accent); }

.sidebar-footer {
  margin-top: auto;
  padding: 8px;
}

.version-tag {
  font-size: 11px;
  color: var(--text-dim);
  font-family: 'DM Sans', sans-serif;
  letter-spacing: 0.5px;
}

/* === MAIN === */
.main {
  flex: 1;
  padding: 36px 40px;
  overflow-y: auto;
  max-width: 1200px;
}

/* === VIEWS === */
.view { display: none; }
.view.active { display: block; }

/* === VIEW HEADER === */
.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 16px;
}

.view-header h1 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 28px;
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

.header-stats {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.stat-chip {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

.stat-chip.accent {
  background: var(--accent-dim);
  border-color: var(--accent-border);
  color: var(--accent);
}

.stat-chip span {
  font-weight: 600;
  color: var(--text);
}

.stat-chip.accent span { color: var(--accent); }

/* === BUTTONS === */
.btn {
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #0d0d0f;
}
.btn-primary:hover { background: #d4ff80; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg3); color: var(--text); border-color: var(--border-hover); }

.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid rgba(255,95,95,0.3);
  padding: 6px 12px;
  font-size: 12px;
}
.btn-danger:hover { background: rgba(255,95,95,0.1); }

.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
}

.btn-rescore {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 6px 12px;
  font-size: 12px;
}
.btn-rescore:hover { background: var(--bg3); color: var(--text); }

/* === MATCH GRID (DASHBOARD) === */
.match-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.match-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.match-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.match-card:hover { border-color: var(--border-hover); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.3); }
.match-card:hover::before { opacity: 1; }
.match-card.score-high::before { background: var(--accent); }
.match-card.score-mid::before { background: var(--yellow); }
.match-card.score-low::before { background: var(--red); }

.match-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.buyer-name {
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.2px;
}

.buyer-budget {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}

.score-badge {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 22px;
  line-height: 1;
}

.score-high .score-badge { color: var(--accent); }
.score-mid .score-badge { color: var(--yellow); }
.score-low .score-badge { color: var(--red); }

.score-label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: right;
  margin-top: 2px;
}

.match-listing {
  background: var(--bg3);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
}

.listing-address {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
}

.listing-price {
  font-family: 'Syne', sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.listing-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}

.match-explanation {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  border-left: 2px solid var(--border);
  padding-left: 10px;
}

/* === ENTITY LIST === */
.entity-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.entity-row {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: border-color 0.15s ease;
}

.entity-row:hover { border-color: var(--border-hover); }

.entity-row-left { flex: 1; min-width: 0; }

.entity-name {
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entity-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.entity-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.entity-row-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.tag {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tag-type {
  background: var(--bg3);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.tag-active { background: rgba(74, 222, 128, 0.1); color: var(--green); border: 1px solid rgba(74,222,128,0.3); }
.tag-inactive { background: var(--bg3); color: var(--text-dim); border: 1px solid var(--border); }

/* === EMPTY STATE === */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
}

.empty-icon {
  font-size: 40px;
  color: var(--text-dim);
  margin-bottom: 16px;
  animation: pulse 2s ease-in-out infinite;
}

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

.empty-state h3 {
  font-family: 'Syne', sans-serif;
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 14px;
  max-width: 320px;
  margin-bottom: 24px;
  line-height: 1.6;
}

.empty-actions {
  display: flex;
  gap: 10px;
}

.hidden { display: none !important; }

/* === MODALS === */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
}

.modal-box {
  position: relative;
  z-index: 1;
  background: var(--bg2);
  border: 1px solid var(--border-hover);
  border-radius: 16px;
  padding: 28px;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}

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

.modal-header h2 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.3px;
}

.modal-close {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.modal-close:hover { color: var(--text); border-color: var(--border-hover); }

/* === FORMS === */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-row .form-group { margin-bottom: 0; }

label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.hint {
  font-weight: 400;
  color: var(--text-dim);
  font-size: 11px;
}

input, select, textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  padding: 10px 14px;
  transition: border-color 0.15s ease;
  width: 100%;
  outline: none;
  resize: vertical;
}

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

input::placeholder, textarea::placeholder { color: var(--text-dim); }

select { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238a8490' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

option { background: var(--bg2); }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* === SIDE PANEL === */
.side-panel {
  position: fixed;
  inset: 0;
  z-index: 90;
}

.panel-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
}

.panel-content {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: min(520px, 100vw);
  background: var(--bg2);
  border-left: 1px solid var(--border-hover);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-header h2 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 18px;
}

.panel-close {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.panel-close:hover { color: var(--text); }

.panel-matches {
  overflow-y: auto;
  padding: 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-match-row {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.panel-match-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
}

.panel-match-addr {
  font-weight: 500;
  font-size: 14px;
  margin-bottom: 3px;
}

.panel-match-price {
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 15px;
}

.panel-match-score {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 20px;
  text-align: right;
}

.panel-match-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.panel-match-explanation {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  border-left: 2px solid var(--border);
  padding-left: 10px;
}

/* === PROGRESS BAR === */
.score-bar-wrap {
  height: 3px;
  background: var(--bg);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}

.score-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* === TOAST === */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  background: var(--bg2);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius);
  padding: 14px 20px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: slide-up 0.2s ease;
  max-width: 320px;
}

@keyframes slide-up {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.toast.success { border-color: rgba(74,222,128,0.4); color: var(--green); }
.toast.error { border-color: rgba(255,95,95,0.4); color: var(--red); }

/* === LOADING === */
.loading-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 14px;
  padding: 20px 0;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

/* === FILTER BAR === */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-bar select,
.filter-bar input {
  max-width: 200px;
  padding: 8px 12px;
  font-size: 13px;
}

/* === FORECLOSURE GRID === */
.foreclosure-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
}

.foreclosure-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.foreclosure-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.foreclosure-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.foreclosure-address {
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.2px;
}

.foreclosure-location {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.foreclosure-price-block {
  text-align: right;
  flex-shrink: 0;
}

.foreclosure-price {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 20px;
  color: var(--accent);
}

.foreclosure-assessed {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.foreclosure-details {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-muted);
}

.case-tag {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
  font-family: monospace;
  color: var(--text-dim);
}

.foreclosure-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.foreclosure-features {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.feature-chip {
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 12px;
}

.foreclosure-dates {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-dim);
}

.auction-date {
  color: var(--orange);
  font-weight: 500;
}

.foreclosure-actions {
  margin-top: 4px;
}

/* === INTEREST SUMMARY === */
.interest-summary {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.interest-listing-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.interest-listing-addr {
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 15px;
}

.interest-listing-price {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 18px;
  color: var(--accent);
}

/* === CHECKBOX === */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

/* === REALTOR SIGNUP === */
.signup-container {
  max-width: 680px;
}

.signup-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
}

.signup-hero {
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.signup-hero h2 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 22px;
  margin-bottom: 10px;
}

.signup-hero p {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 20px;
}

.signup-benefits {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.benefit {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text);
}

.benefit-icon {
  color: var(--accent);
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 15px;
  font-weight: 600;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .sidebar { width: 64px; padding: 20px 10px; }
  .logo-text { display: none; }
  .nav-btn span { display: none; }
  .nav-btn { justify-content: center; padding: 10px; }
  .main { padding: 24px 20px; }
  .view-header { flex-direction: column; gap: 12px; }
  .form-row { grid-template-columns: 1fr; }
  .match-grid { grid-template-columns: 1fr; }
  .foreclosure-grid { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; }
  .filter-bar select, .filter-bar input { max-width: 100%; }
}
