/* Copenhagen Flat Finder - Style Sheet */

/* ===== RESET & BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f8fafc;
  color: #1e293b;
  line-height: 1.5;
  min-height: 100vh;
}

/* ===== LOGIN SCREEN ===== */
#login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 50%, #ec4899 100%);
  z-index: 1000;
}

.login-card {
  background: white;
  border-radius: 20px;
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.3);
  text-align: center;
}

.login-card h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 0.25rem;
}

.login-subtitle {
  color: #94a3b8;
  font-size: 0.95rem;
  margin-bottom: 2rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

#login-form input {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #f8fafc;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

#login-form input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
  background: white;
}

#login-form button {
  display: block;
  width: 100%;
  padding: 0.75rem;
  margin-top: 0.5rem;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

#login-form button:hover { background: #1d4ed8; }
#login-form button:active { transform: scale(0.98); }

.error-msg {
  color: #ef4444;
  font-size: 0.85rem;
  margin-top: 0.75rem;
  min-height: 1.2em;
}

/* ===== HEADER ===== */
header {
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  border-bottom: 1px solid #475569;
  padding: 0.7rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.header-left h1 { font-size: 1.15rem; font-weight: 700; color: white; }
.header-right { display: flex; align-items: center; gap: 0.75rem; }
#current-user { font-size: 0.85rem; color: rgba(255,255,255,0.7); font-weight: 500; }

/* ===== BUTTONS ===== */
.btn-primary {
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}

.btn-primary:hover { background: #1d4ed8; }
.btn-primary:active { transform: scale(0.97); }

.btn-ghost {
  background: transparent;
  color: #64748b;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-ghost:hover {
  border-color: #cbd5e1;
  color: #1e293b;
  background: #f8fafc;
}

.btn-danger {
  color: #ef4444 !important;
  border-color: #fca5a5 !important;
}
.btn-danger:hover {
  background: #fef2f2 !important;
  color: #dc2626 !important;
  border-color: #ef4444 !important;
}

/* ===== ADD BAR ===== */
.add-bar {
  background: white;
  margin: 1rem 1.5rem 0;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

.url-input-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.url-input-row input {
  flex: 1;
  padding: 0.6rem 1rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  background: #f8fafc;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.url-input-row input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
  background: white;
}

/* ===== FLAT FORM ===== */
.flat-form {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #f1f5f9;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.form-group.full-width { grid-column: 1 / -1; }

.form-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group input,
.form-group select {
  padding: 0.55rem 0.75rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  background: #f8fafc;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
  background: white;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  justify-content: flex-end;
}

/* ===== MAIN CONTENT (PICKS + MAP) ===== */
.main-content {
  display: flex;
  gap: 1rem;
  padding: 1rem 1.5rem;
}

.picks-column {
  width: 40%;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.map-column {
  flex: 1;
  min-width: 0;
}

#map {
  height: 500px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  border: 1px solid #e2e8f0;
  background: #e2e8f0;
}

/* ===== PICKS SECTIONS ===== */
.picks-section {
  background: white;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

.picks-section h2 {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: #334155;
}

#our-top { border-left: 3px solid #ec4899; }
#gigi-top { border-left: 3px solid #2563eb; }
#ili-top { border-left: 3px solid #7c3aed; }

.picks-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.pick-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  background: #f8fafc;
  transition: background 0.15s, box-shadow 0.2s, border-color 0.2s;
  cursor: pointer;
  border: 2px solid transparent;
}

.pick-card:hover { background: #f1f5f9; }

.pick-card.pick-active {
  background: #fffbeb;
  border-color: #facc15;
  box-shadow: 0 0 8px rgba(250, 204, 21, 0.4);
}

.pick-card.pick-active:hover {
  background: #fef9c3;
}

.pick-rank {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

#our-top .pick-rank { background: #ec4899; }
#gigi-top .pick-rank { background: #2563eb; }
#ili-top .pick-rank { background: #7c3aed; }

.pick-info { flex: 1; min-width: 0; }

.pick-address {
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pick-meta {
  font-size: 0.72rem;
  color: #94a3b8;
}

.pick-empty {
  font-size: 0.8rem;
  color: #cbd5e1;
  padding: 0.35rem 0;
  font-style: italic;
}

/* ===== FILTERS BAR ===== */
.filters-bar {
  display: flex;
  gap: 0.75rem;
  padding: 0 1.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.filter-group label {
  font-size: 0.72rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.filter-group input,
.filter-group select {
  padding: 0.4rem 0.6rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 7px;
  font-size: 0.82rem;
  font-family: inherit;
  outline: none;
  background: white;
  min-width: 80px;
  max-width: 120px;
  transition: border-color 0.2s;
}

.filter-group input:focus,
.filter-group select:focus {
  border-color: #2563eb;
}

/* ===== FLAT LIST TABLE ===== */
.flat-list {
  padding: 0 1.5rem 2rem;
}

.table-wrapper {
  position: relative;
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

.table-top-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  border-bottom: 1px solid #e2e8f0;
}
.table-top-scroll::-webkit-scrollbar { height: 14px; }
.table-top-scroll::-webkit-scrollbar-track { background: #f1f5f9; }
.table-top-scroll::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 7px; border: 2px solid #f1f5f9; }
.table-top-scroll::-webkit-scrollbar-thumb:hover { background: #64748b; }
.table-top-scroll-inner { height: 1px; }

.table-scroll {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 60vh;
  -webkit-overflow-scrolling: touch;
}
.table-scroll::-webkit-scrollbar { height: 14px; width: 14px; }
.table-scroll::-webkit-scrollbar-track { background: #f1f5f9; }
.table-scroll::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 7px; border: 2px solid #f1f5f9; }
.table-scroll::-webkit-scrollbar-thumb:hover { background: #64748b; }
.table-scroll::-webkit-scrollbar-corner { background: #f1f5f9; }

#flats-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 1600px;
}

#flats-table thead th {
  background: #f8fafc;
  padding: 0.65rem 0.75rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}

#flats-table tbody tr { transition: background 0.15s; }
#flats-table tbody tr:hover { background: #f8fafc; }
#flats-table tbody tr:nth-child(even) { background: #fafbfd; }
#flats-table tbody tr:nth-child(even):hover { background: #f1f5f9; }

#flats-table tbody td {
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  color: #334155;
  border-bottom: 1px solid #f1f5f9;
  white-space: nowrap;
}

#flats-table tbody td:first-child {
  font-weight: 600;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

#flats-table tbody td a {
  color: #2563eb;
  text-decoration: none;
  font-weight: 600;
}

#flats-table tbody td a:hover { text-decoration: underline; }

.rank-select {
  padding: 0.3rem 0.4rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 6px;
  font-size: 0.82rem;
  font-family: inherit;
  background: white;
  cursor: pointer;
  outline: none;
  min-width: 52px;
}

.rank-select:focus { border-color: #2563eb; }

.btn-delete {
  background: none;
  border: none;
  color: #ef4444;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}

.btn-delete:hover {
  background: #fef2f2;
  color: #dc2626;
}

/* ===== LOADING & EMPTY STATES ===== */
.loading-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2.5px solid #e2e8f0;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 0.4rem;
}

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

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: #1e293b;
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  z-index: 9999;
  animation: slideUp 0.3s ease;
}

.toast.error { background: #ef4444; }

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

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .main-content { flex-direction: column; }
  .picks-column { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .picks-section { flex: 1; min-width: 200px; }
  #map { height: 350px; }
  .contract-viewer { flex-direction: column !important; height: auto !important; }
  .contract-pdf-panel { width: 100% !important; height: 50vh !important; }
  .contract-doc-list { grid-template-columns: 1fr !important; }
}

@media (max-width: 600px) {
  header { padding: 0.6rem 1rem; }
  .header-left h1 { font-size: 0.95rem; }
  .add-bar { margin: 0.75rem 0.75rem 0; }
  .url-input-row { flex-direction: column; }
  .url-input-row input { width: 100%; }
  .main-content { padding: 0.75rem; }
  .picks-column { flex-direction: column; }
  .filters-bar { padding: 0 0.75rem; }
  .flat-list { padding: 0 0.75rem 1.5rem; }
  #flats-table { font-size: 0.8rem; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .contract-doc-list-header { flex-direction: column; gap: 0.5rem; }
}

/* ===== SCROLLBAR (global default) ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ===== MISC ===== */
::placeholder { color: #94a3b8; }

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  opacity: 0.5;
}

.leaflet-popup-content-wrapper {
  border-radius: 10px !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12) !important;
}

.leaflet-popup-content {
  margin: 0.75rem 1rem !important;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif !important;
  font-size: 0.85rem !important;
  line-height: 1.5 !important;
}

.leaflet-popup-content b { color: #1e293b; }

/* ===== CALENDAR ===== */
.calendar-section {
  margin: 1rem 1.5rem 0;
  background: white;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.calendar-header h2 {
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
  min-width: 160px;
  text-align: center;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cal-day-header {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  padding: 0.3rem 0;
}

.cal-day {
  text-align: center;
  padding: 0.4rem 0.2rem;
  border-radius: 8px;
  font-size: 0.82rem;
  color: #64748b;
  min-height: 52px;
  position: relative;
  cursor: default;
  transition: background 0.15s;
}

.cal-day:hover { background: #f8fafc; }
.cal-day.other-month { color: #cbd5e1; }

.cal-day.today {
  background: #eff6ff;
  font-weight: 700;
  color: #2563eb;
}

.cal-day .day-num {
  display: block;
  font-weight: 600;
  margin-bottom: 2px;
}

.cal-day .cal-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  justify-content: center;
}

.cal-dot { width: 7px; height: 7px; border-radius: 50%; background: #2563eb; }
.cal-dot.viewing { background: #10b981; }
.cal-dot.contacted { background: #f59e0b; }

.cal-viewing-label {
  display: block;
  font-size: 0.62rem;
  color: #10b981;
  font-weight: 600;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.cal-contacted-label {
  display: block;
  font-size: 0.62rem;
  color: #f59e0b;
  font-weight: 600;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* ===== STATUS CELL ===== */
.status-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 120px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}

.status-badge.contacted { background: #fef3c7; color: #92400e; }
.status-badge.viewing { background: #d1fae5; color: #065f46; }
.status-badge.none { background: #f1f5f9; color: #94a3b8; }
.status-badge:hover { filter: brightness(0.95); }

/* ===== TEXTAREA IN FORM ===== */
.form-group textarea {
  padding: 0.55rem 0.75rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  background: #f8fafc;
  transition: border-color 0.2s, box-shadow 0.2s;
  resize: vertical;
}

.form-group textarea:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
  background: white;
}

/* ===== DETAIL PANEL ===== */
.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.detail-panel {
  background: white;
  border-radius: 16px;
  padding: 2rem;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px rgba(0,0,0,0.2);
}

.detail-panel h2 { font-size: 1.1rem; margin-bottom: 1rem; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 1.5rem;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 0.3rem 0;
  border-bottom: 1px solid #f1f5f9;
}

.detail-label { font-size: 0.8rem; color: #64748b; font-weight: 600; }
.detail-value { font-size: 0.85rem; color: #1e293b; font-weight: 500; }

.detail-desc {
  grid-column: 1 / -1;
  margin-top: 0.5rem;
  padding: 0.75rem;
  background: #f8fafc;
  border-radius: 8px;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #334155;
  white-space: pre-wrap;
}

/* ===== PASTE SECTION ===== */
.paste-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #f1f5f9;
}

.paste-section label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.5rem;
}

.paste-section textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  background: #f8fafc;
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.paste-section textarea:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
  background: white;
}

.paste-section .form-actions { margin-top: 0.75rem; }

/* ===== IMAGE GALLERY ===== */
.detail-gallery { margin-bottom: 1rem; }

.gallery-main {
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  background: #f1f5f9;
  margin-bottom: 0.5rem;
}

.gallery-main img {
  width: 100%;
  max-height: 350px;
  object-fit: cover;
  display: block;
}

.gallery-thumbs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.gallery-thumb {
  width: 64px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  opacity: 0.6;
  transition: opacity 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.gallery-thumb:hover { opacity: 0.85; }
.gallery-thumb.active { opacity: 1; border-color: #2563eb; }

/* ===== MAP TOOLBAR ===== */
.map-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.4rem;
}

/* ===== ROW THUMBNAILS ===== */
.row-num-col, .row-num-cell {
  width: 36px;
  min-width: 36px;
  text-align: center;
  color: #94a3b8;
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.thumb-cell { width: 80px; padding: 4px !important; }

.row-thumb {
  width: 72px;
  height: 54px;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  display: block;
}

.row-thumb:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.row-thumb-empty {
  width: 72px;
  height: 54px;
  border-radius: 6px;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: #cbd5e1;
}

.btn-check {
  background: none;
  border: 1.5px solid #e2e8f0;
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
}

.btn-check:hover { border-color: #2563eb; color: #2563eb; }

.btn-rescrape {
  background: none;
  border: 1.5px solid #e2e8f0;
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
}

.btn-rescrape:hover { border-color: #f59e0b; color: #f59e0b; }
.btn-rescrape:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-sm { font-size: 0.78rem; padding: 0.3rem 0.75rem; }

/* ===== ROW HIGHLIGHT ===== */
.row-highlight {
  background: #eff6ff !important;
  outline: 2px solid #3b82f6;
  outline-offset: -2px;
  transition: background 0.2s, outline 0.2s;
}
tr[data-id] { cursor: pointer; }
tr[data-id]:hover { background: #f8fafc; }

.station-label {
  background: rgba(0,0,0,0.75) !important;
  color: white !important;
  border: none !important;
  border-radius: 4px !important;
  padding: 2px 6px !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3) !important;
}
.station-label::before { display: none !important; }

/* ===== NAVIGATION TABS ===== */
#main-nav {
  display: flex;
  gap: 0.25rem;
  background: rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 3px;
}
.nav-tab {
  padding: 0.45rem 1.1rem;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.7);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
  font-family: inherit;
  white-space: nowrap;
}
.nav-tab:hover { color: white; background: rgba(255,255,255,0.1); }
.nav-tab.active {
  background: white;
  color: #1e293b;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

header .btn-ghost {
  color: rgba(255,255,255,0.7);
  border-color: rgba(255,255,255,0.2);
}
header .btn-ghost:hover {
  color: white;
  border-color: rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.1);
}

/* ===== ORIGINALS PAGE ===== */
.originals-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: white;
  border-bottom: 1px solid #e2e8f0;
}
.originals-selector { flex: 1; position: relative; text-align: center; }
.originals-current-btn {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  padding: 0.5rem 1.5rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  color: #1e293b;
  max-width: 600px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
}
.originals-current-btn:hover { background: #e2e8f0; }
.originals-dropdown {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  max-height: 400px;
  overflow-y: auto;
  z-index: 100;
  min-width: 350px;
  max-width: 600px;
  margin-top: 4px;
}
.orig-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.1s;
}
.orig-item:hover { background: #f1f5f9; }
.orig-item.active { background: #eff6ff; border-left: 3px solid #3b82f6; }
.orig-item-title {
  font-size: 0.85rem;
  font-weight: 500;
  color: #1e293b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 350px;
}
.orig-item-rent {
  font-size: 0.78rem;
  color: #64748b;
  font-weight: 600;
  white-space: nowrap;
  margin-left: 1rem;
}

.originals-nav .btn-ghost {
  font-size: 1.3rem;
  padding: 0.3rem 0.8rem;
  min-width: 40px;
  color: #64748b;
  border-color: #e2e8f0;
}
.originals-nav .btn-ghost:hover {
  color: #1e293b;
  border-color: #cbd5e1;
  background: #f8fafc;
}

.originals-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  padding: 1.5rem 2rem;
  max-width: 1400px;
  margin: 0 auto;
  height: calc(100vh - 130px);
  overflow-y: auto;
}
.orig-gallery { display: flex; flex-direction: column; gap: 0.75rem; }
.orig-main-image-wrap {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #f1f5f9;
  aspect-ratio: 16/10;
}
.orig-main-img { width: 100%; height: 100%; object-fit: cover; }
.orig-open-btn {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  background: rgba(0,0,0,0.75);
  color: white;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.2s;
  backdrop-filter: blur(4px);
}
.orig-open-btn:hover { background: #2563eb; }
.orig-thumbs { display: flex; gap: 0.5rem; overflow-x: auto; padding-bottom: 0.5rem; }
.orig-thumb {
  width: 80px;
  height: 56px;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  opacity: 0.7;
  transition: all 0.15s;
  flex-shrink: 0;
}
.orig-thumb:hover { opacity: 1; }
.orig-thumb.active { border-color: #3b82f6; opacity: 1; }
.orig-details { overflow-y: auto; }
.orig-title { font-size: 1.4rem; font-weight: 700; color: #1e293b; margin-bottom: 0.3rem; }
.orig-address { color: #64748b; font-size: 0.95rem; margin-bottom: 1.2rem; }
.orig-stats { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem; }
.orig-stat { background: #f1f5f9; border-radius: 10px; padding: 0.8rem 1rem; text-align: center; min-width: 90px; }
.orig-stat-value { display: block; font-size: 1.15rem; font-weight: 700; color: #1e293b; }
.orig-stat-label { display: block; font-size: 0.72rem; color: #64748b; margin-top: 0.15rem; }
.orig-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 1.5rem; margin-bottom: 1.5rem; }
.orig-meta-item { display: flex; justify-content: space-between; padding: 0.35rem 0; border-bottom: 1px solid #f1f5f9; }
.orig-meta-label { font-size: 0.82rem; color: #64748b; }
.orig-meta-val { font-size: 0.82rem; font-weight: 600; color: #1e293b; }
.orig-desc-text { font-size: 0.88rem; color: #475569; line-height: 1.6; white-space: pre-wrap; }

/* ===== SOURCES PAGE ===== */
.sources-title { text-align: center; font-size: 1.6rem; font-weight: 700; color: #1e293b; margin: 2rem 0 0.5rem; }
.sources-subtitle { text-align: center; color: #64748b; margin-bottom: 2rem; font-size: 0.95rem; }
.sources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.2rem;
  padding: 0 2rem 3rem;
  max-width: 1100px;
  margin: 0 auto;
}
.source-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 1.8rem 1.5rem;
  text-decoration: none;
  transition: all 0.2s;
  display: block;
}
.source-card:hover {
  border-color: #3b82f6;
  box-shadow: 0 4px 16px rgba(37,99,235,0.12);
  transform: translateY(-2px);
}
.source-name { font-size: 1.15rem; font-weight: 700; color: #1e293b; margin-bottom: 0.4rem; }
.source-desc { font-size: 0.85rem; color: #64748b; line-height: 1.4; }

/* ===== NOTES ===== */
.notes-cell { max-width: 120px; }
.notes-badge {
  cursor: pointer;
  font-size: 0.78rem;
  color: #64748b;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  transition: background 0.15s;
  display: inline-block;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.notes-badge:hover { background: #f1f5f9; color: #1e293b; }
.notes-icon { font-size: 0.85rem; }
.notes-icon-empty { color: #cbd5e1; font-style: italic; font-size: 0.75rem; }
.notes-icon-empty:hover { color: #3b82f6; }

.notes-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2), 0 0 0 1px rgba(0,0,0,0.05);
  z-index: 2000;
  width: 480px;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
.notes-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid #e2e8f0;
}
.notes-popup-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: #1e293b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 380px;
}
.notes-close-btn {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: #94a3b8;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.notes-close-btn:hover { color: #1e293b; }
.notes-textarea {
  flex: 1;
  border: none;
  padding: 1rem 1.2rem;
  font-size: 0.9rem;
  font-family: inherit;
  resize: none;
  min-height: 200px;
  line-height: 1.6;
  color: #1e293b;
  outline: none;
}
.notes-textarea::placeholder { color: #cbd5e1; }
.notes-popup-footer {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  padding: 0.8rem 1.2rem;
  border-top: 1px solid #e2e8f0;
}

/* ===== CONTRACT PAGE ===== */
.contract-page {
  padding: 1rem 1.5rem 2rem;
  max-width: 1600px;
  margin: 0 auto;
}

/* Email Draft Section */
.email-draft-section {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.email-draft-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.email-draft-icon {
  font-size: 1.3rem;
}

.email-draft-title {
  font-size: 1rem;
  font-weight: 700;
  color: #92400e;
  margin: 0;
  flex: 1;
}

.email-draft-status {
  font-size: 0.8rem;
  color: #059669;
  font-weight: 600;
}

.email-draft-fields {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.email-draft-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.email-draft-row-body {
  align-items: flex-start;
}

.email-draft-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #78350f;
  min-width: 55px;
  flex-shrink: 0;
}

.email-draft-input {
  flex: 1;
  padding: 0.4rem 0.6rem;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 0.88rem;
  background: white;
  color: #1e293b;
}

.email-draft-input[readonly] {
  background: #f9fafb;
  color: #6b7280;
}

.email-draft-textarea {
  flex: 1;
  padding: 0.5rem 0.6rem;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 0.88rem;
  font-family: inherit;
  background: white;
  color: #1e293b;
  resize: vertical;
  min-height: 100px;
}

.email-draft-footer {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.email-draft-info {
  font-size: 0.78rem;
  color: #92400e;
  font-style: italic;
}

/* Document List Section */
.contract-doc-list-section {
  margin-bottom: 1rem;
}

.contract-doc-list-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 0.75rem;
}

/* Document Row List - 8 full-width rows */
.contract-doc-list {
  display: flex;
  flex-direction: column;
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

.doc-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: background 0.15s;
}

.doc-row:last-child { border-bottom: none; }
.doc-row:hover { background: #f8fafc; }

.doc-row.active {
  background: #eff6ff;
  border-left: 3px solid #2563eb;
}

.doc-row-num {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: #e2e8f0;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}

.doc-row.active .doc-row-num {
  background: #2563eb;
  color: white;
}

.doc-row-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  line-height: 1;
}

.doc-row-info {
  flex: 1;
  min-width: 0;
}

.doc-row-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.doc-row-type {
  font-size: 0.72rem;
  color: #94a3b8;
  font-weight: 500;
}

.doc-row-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
  align-items: center;
}

.doc-action {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 5px;
  text-decoration: none;
  white-space: nowrap;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.doc-action-ok {
  background: #dcfce7;
  color: #166534;
}

.doc-action-ok:hover {
  background: #bbf7d0;
}

.doc-action-missing {
  background: #fef2f2;
  color: #991b1b;
}

.doc-action-missing:hover {
  background: #fecaca;
  color: #7f1d1d;
}

.doc-list-empty {
  text-align: center;
  color: #94a3b8;
  font-style: italic;
  padding: 2rem;
}

/* Split viewer - dual PDF panels */
.contract-viewer {
  display: flex;
  gap: 1rem;
  height: calc(100vh - 260px);
  min-height: 500px;
  margin-bottom: 1rem;
}

.contract-pdf-panel {
  flex: 1;
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  flex-shrink: 0;
}

.panel-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #334155;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pdf-page-info {
  font-size: 0.78rem;
  color: #64748b;
  font-weight: 500;
}

/* PDF scroll container - continuous vertical scroll of all pages */
/* PDF Text Layer - selectable text overlay */
.pdf-text-layer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  opacity: 1;
  line-height: 1;
  z-index: 2;
}

.pdf-text-layer br {
  display: none;
}

.pdf-text-layer > span,
.pdf-text-layer > br ~ span {
  color: transparent;
  position: absolute;
  white-space: pre;
  transform-origin: 0% 0%;
  cursor: text;
}

.pdf-text-layer > span::selection {
  background: rgba(0, 100, 200, 0.35);
  color: transparent;
}

.pdf-text-layer > span::-moz-selection {
  background: rgba(0, 100, 200, 0.35);
  color: transparent;
}

.pdf-page-wrap {
  position: relative;
  margin: 0 auto 8px;
  overflow: hidden;
}

.pdf-page-wrap .pdf-page-canvas {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}

.pdf-scroll-container {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: #e2e8f0;
  position: relative;
}

.pdf-scroll-container::-webkit-scrollbar { width: 8px; }
.pdf-scroll-container::-webkit-scrollbar-track { background: #d1d5db; }
.pdf-scroll-container::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 4px; }
.pdf-scroll-container::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* Individual PDF page canvases stacked vertically */
.pdf-page-canvas {
  display: block;
  max-width: 100%;
  margin: 0 auto 12px auto;
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
  background: white;
}

.pdf-page-canvas:last-child {
  margin-bottom: 0;
}

/* Empty state for EN panel when no PDF uploaded */
.pdf-empty-msg {
  color: #94a3b8;
  font-style: italic;
  text-align: center;
  padding: 3rem 1rem;
  font-size: 0.95rem;
}

/* Empty state */
.contract-empty {
  background: white;
  border-radius: 12px;
  padding: 4rem 2rem;
  text-align: center;
  color: #94a3b8;
  font-size: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* Comments */
.contract-comments {
  background: white;
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  margin-bottom: 1rem;
}

.contract-comments h3 {
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 0.75rem;
}

.comment-input-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.comment-input-row input {
  flex: 1;
  padding: 0.6rem 1rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  background: #f8fafc;
  transition: border-color 0.2s;
}

.comment-input-row input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
  background: white;
}

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.comment-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  background: #f8fafc;
}

.comment-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  color: white;
  flex-shrink: 0;
  text-transform: uppercase;
}

.comment-avatar.gigi { background: #2563eb; }
.comment-avatar.ili { background: #7c3aed; }

.comment-body { flex: 1; min-width: 0; }

.comment-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.15rem;
}

.comment-username {
  font-size: 0.78rem;
  font-weight: 700;
  color: #334155;
  text-transform: capitalize;
}

.comment-date {
  font-size: 0.7rem;
  color: #94a3b8;
}

.comment-text {
  font-size: 0.85rem;
  color: #475569;
  line-height: 1.5;
}

.comment-delete-btn {
  background: none;
  border: none;
  color: #cbd5e1;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.2rem;
  line-height: 1;
  transition: color 0.15s;
  flex-shrink: 0;
}

.comment-delete-btn:hover { color: #ef4444; }

.comments-empty {
  text-align: center;
  color: #cbd5e1;
  font-size: 0.85rem;
  padding: 1rem;
  font-style: italic;
}

/* Legal Evaluation */
.contract-evaluation {
  background: white;
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  border-left: 4px solid #f59e0b;
}

.contract-evaluation h3 {
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.evaluation-content {
  font-size: 0.88rem;
  line-height: 1.7;
  color: #334155;
}

.evaluation-content h4 {
  font-size: 0.92rem;
  font-weight: 700;
  color: #1e293b;
  margin: 1.25rem 0 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid #f1f5f9;
}

.evaluation-content h4:first-child {
  margin-top: 0;
}

.evaluation-content ul {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.evaluation-content li {
  margin-bottom: 0.35rem;
}

.evaluation-content strong {
  color: #1e293b;
}

.evaluation-content .eval-flag {
  background: #fef3c7;
  border-left: 3px solid #f59e0b;
  padding: 0.5rem 0.75rem;
  border-radius: 0 6px 6px 0;
  margin: 0.5rem 0;
  font-size: 0.85rem;
}

.evaluation-content .eval-tip {
  background: #ecfdf5;
  border-left: 3px solid #10b981;
  padding: 0.5rem 0.75rem;
  border-radius: 0 6px 6px 0;
  margin: 0.5rem 0;
  font-size: 0.85rem;
}

.evaluation-empty {
  color: #94a3b8;
  font-style: italic;
  text-align: center;
  padding: 2rem;
}
