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

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  min-height: 100vh;
}

/* HEADER */
header {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  color: white;
  padding: 24px 32px;
  text-align: center;
}
header h1 {
  font-size: 28px;
  font-weight: 700;
}
header .subtitle {
  font-size: 16px;
  opacity: 0.7;
  margin-top: 4px;
}

/* COUNTY TABS */
.county-tabs {
  display: flex;
  gap: 0;
  background: #16213e;
  padding: 0 24px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tab {
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 15px;
  font-weight: 500;
  padding: 14px 20px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: all 0.2s;
  font-family: inherit;
}
.tab:hover {
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.05);
}
.tab.active {
  color: white;
  border-bottom-color: #4fc3f7;
}

/* CONTROLS */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  padding: 12px 20px;
  margin: 0 20px 15px;
  background: #f0f4f8;
  border-radius: 10px;
  border: 1px solid #e0e4e8;
}
.filters-bar .filter-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.filters-bar .filter-group label {
  font-size: 11px;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.filters-bar input[type="date"],
.filters-bar input[type="number"] {
  padding: 6px 10px;
  border: 1px solid #d0d4d8;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  width: 140px;
}
.filters-bar select {
  padding: 6px 10px;
  border: 1px solid #d0d4d8;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
}
.clear-filters-btn {
  padding: 6px 14px;
  background: #e0e0e0;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  color: #555;
  align-self: flex-end;
}
.clear-filters-btn:hover { background: #d0d0d0; }

.controls {
  display: flex;
  gap: 16px;
  padding: 16px 24px;
  align-items: center;
  flex-wrap: wrap;
  background: white;
  border-bottom: 1px solid #e0e0e0;
}
.search-box {
  flex: 1;
  min-width: 200px;
}
.search-box input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
  transition: border-color 0.2s;
}
.search-box input:focus {
  outline: none;
  border-color: #4fc3f7;
}
.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.filter-group label {
  font-weight: 600;
  font-size: 14px;
  color: #666;
}
.filter-group select {
  padding: 10px 14px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  background: white;
  cursor: pointer;
}
.stats {
  font-size: 14px;
  color: #888;
  font-weight: 500;
}

/* TABLE */
.table-container {
  padding: 16px 24px;
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
thead {
  background: #f8f9fa;
}
th {
  padding: 14px 16px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid #e0e0e0;
  white-space: nowrap;
}
th.sortable {
  cursor: pointer;
  user-select: none;
}
th.sortable:hover {
  color: #1a1a2e;
  background: #eee;
}
th.sortable::after {
  content: ' ↕';
  opacity: 0.3;
}
th.sort-asc::after { content: ' ↑'; opacity: 1; }
th.sort-desc::after { content: ' ↓'; opacity: 1; }

td {
  padding: 14px 16px;
  font-size: 15px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}
tr:hover {
  background: #f8fbff;
}
tr.clickable {
  cursor: pointer;
}

/* STATUS BADGES */
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-new { background: #e3f2fd; color: #1565c0; }
.badge-auction { background: #fff3e0; color: #e65100; }
.badge-contacted { background: #e8f5e9; color: #2e7d32; }
.badge-interested { background: #f3e5f5; color: #7b1fa2; }
.badge-passed { background: #f5f5f5; color: #757575; }
.badge-sold { background: #ffebee; color: #c62828; }

/* MONEY */
.money {
  font-weight: 600;
  color: #2e7d32;
}
.money-large {
  font-size: 18px;
}

/* ACTION BUTTONS */
.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  color: white;
  transition: opacity 0.2s;
  font-family: inherit;
}
.action-btn:hover { opacity: 0.85; }
.btn-view { background: #1a73e8; }
.btn-zillow { background: #006aff; }
.btn-realtor { background: #d92228; }

/* MODAL */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99999;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 20px;
  overflow-y: auto;
}
.modal-overlay.open {
  display: flex;
}
.modal {
  background: white;
  border-radius: 16px;
  max-width: 700px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  position: relative;
  animation: slideUp 0.2s ease-out;
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: #999;
  line-height: 1;
}
.modal-close:hover { color: #333; }
.modal-header {
  padding: 24px 28px;
  border-bottom: 1px solid #eee;
  display: flex;
  align-items: center;
  gap: 12px;
}
.modal-header h2 {
  font-size: 20px;
}
.modal-body {
  padding: 24px 28px;
}
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.detail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.detail-item.full-width {
  grid-column: 1 / -1;
}
.legal-notice-section {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid #eee;
}
.legal-notice-text {
  margin-top: 10px;
  padding: 15px;
  background: #f8f9fa;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.6;
  color: #333;
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.section-header {
  grid-column: 1 / -1;
  font-size: 14px;
  font-weight: 700;
  color: #555;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #eee;
}
.detail-label {
  font-size: 12px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.detail-value {
  font-size: 17px;
  font-weight: 500;
  color: #1a1a2e;
}
.detail-links {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #eee;
  flex-wrap: wrap;
}
.detail-links a {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  color: white;
}
.detail-notes {
  margin-top: 20px;
  padding: 16px;
  background: #f8f9fa;
  border-radius: 8px;
  font-size: 15px;
  line-height: 1.5;
  color: #555;
}

.loading {
  text-align: center;
  padding: 60px;
  color: #999;
  font-size: 16px;
}

.no-results {
  text-align: center;
  padding: 60px;
  color: #999;
}

footer {
  text-align: center;
  padding: 20px;
  color: #999;
  font-size: 13px;
}

/* STATUS SELECT */
.status-select {
  padding: 8px 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  background: white;
}
.status-select:focus { border-color: #4fc3f7; outline: none; }

/* NOTES */
.notes-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #eee;
}
.notes-textarea {
  width: 100%;
  min-height: 100px;
  padding: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  resize: vertical;
  margin-top: 8px;
}
.notes-textarea:focus { border-color: #4fc3f7; outline: none; }
.save-notes-btn {
  margin-top: 10px;
  padding: 10px 24px;
  background: #1a73e8;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.save-notes-btn:hover { background: #1557b0; }
.save-status {
  margin-left: 12px;
  color: #2e7d32;
  font-weight: 600;
}

/* RESPONSIVE - Uncle-proof on mobile */
@media (max-width: 768px) {
  header { padding: 16px; }
  header h1 { font-size: 20px; }
  header .subtitle { font-size: 13px; }

  .county-tabs { padding: 0 4px; }
  .tab { padding: 10px 12px; font-size: 13px; }

  .controls { padding: 12px; flex-direction: column; align-items: stretch; gap: 10px; }
  .controls .filter-group { width: 100%; }
  .controls .filter-group select { width: 100%; padding: 12px; font-size: 16px; }
  .search-box input { font-size: 16px; padding: 14px; }

  .filters-bar { margin: 0 8px 12px; padding: 10px; flex-direction: column; }
  .filters-bar .filter-group { width: 100%; }
  .filters-bar input[type="date"],
  .filters-bar input[type="number"],
  .filters-bar select { width: 100%; padding: 10px; font-size: 16px; }
  .clear-filters-btn { width: 100%; padding: 12px; font-size: 15px; }

  /* TABLE → CARD LAYOUT */
  .table-container { padding: 8px; overflow-x: visible; }
  table { box-shadow: none; background: transparent; }
  thead { display: none; }
  tbody { display: flex; flex-direction: column; gap: 10px; }

  tr {
    display: flex;
    flex-wrap: wrap;
    background: white;
    border-radius: 12px;
    padding: 14px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    gap: 6px 12px;
    align-items: center;
    position: relative;
  }
  tr:hover { background: white; }

  /* Status badge — top left */
  td:nth-child(1) {
    order: 1;
    border: none;
    padding: 0;
  }

  /* Address — full width, prominent */
  td:nth-child(2) {
    order: 2;
    width: 100%;
    border: none;
    padding: 4px 0;
    font-size: 16px;
  }

  /* County */
  td:nth-child(3) {
    order: 3;
    border: none;
    padding: 0;
    font-size: 13px;
    color: #888;
  }
  td:nth-child(3)::before {
    content: '📍 ';
  }

  /* Name on Loan */
  td:nth-child(4) {
    order: 4;
    border: none;
    padding: 0;
    font-size: 13px;
    color: #555;
  }
  td:nth-child(4)::before {
    content: '👤 ';
  }

  /* Amount Owed */
  td:nth-child(5) {
    order: 5;
    border: none;
    padding: 0;
    font-size: 15px;
  }
  td:nth-child(5)::before {
    content: '💰 ';
  }

  /* Auction Date */
  td:nth-child(6) {
    order: 6;
    border: none;
    padding: 0;
    font-size: 13px;
    color: #888;
  }
  td:nth-child(6)::before {
    content: '📅 ';
  }

  /* View button — hide on mobile, whole card is clickable */
  td:nth-child(7) {
    display: none;
  }

  /* No results / loading spans full width */
  tr td[colspan] {
    width: 100%;
    text-align: center;
  }

  /* MODAL — full screen on mobile */
  .modal-overlay {
    padding: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: white;
  }
  .modal-overlay.open {
    display: block;
  }
  .modal {
    margin: 0;
    border-radius: 0;
    min-height: 100%;
    max-width: 100%;
    box-shadow: none;
  }
  body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
  }
  .modal-header { padding: 18px 16px; }
  .modal-header h2 { font-size: 18px; }
  .modal-body { padding: 16px; }
  .detail-grid { grid-template-columns: 1fr; gap: 14px; }
  .detail-value { font-size: 15px; }
  .detail-links { flex-direction: column; }
  .detail-links a { text-align: center; padding: 14px; font-size: 16px; }
  .notes-textarea { font-size: 16px; min-height: 120px; }
  .save-notes-btn { width: 100%; padding: 14px; font-size: 16px; }
  .status-select { width: 100%; padding: 12px; font-size: 16px; }

  footer { font-size: 12px; }
}
