/* ============================================================
   Freehouses — global styles
   ============================================================ */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: #222; background: #f7f7f8; }
a { color: #1976d2; text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #eef; padding: 1px 4px; border-radius: 3px; font-size: 90%; }

/* ---------- top nav ---------- */
#topnav {
  position: sticky; top: 0; z-index: 1000;
  background: #263238; color: white;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; height: 48px;
  border-bottom: 1px solid #1c272b;
}
#topnav .brand { font-weight: 700; font-size: 16px; }
#topnav .brand-link { color: #fff; text-decoration: none; }
#topnav .brand-sub { font-weight: 400; font-size: 11px; color: #90a4ae; margin-left: 8px; }
#topnav nav { display: flex; gap: 4px; }
#topnav nav a {
  color: #cfd8dc; padding: 8px 12px; font-size: 13px;
  border-radius: 4px; text-decoration: none;
}
#topnav nav a:hover { background: #37474f; color: white; text-decoration: none; }
#topnav nav a.active { background: #1976d2; color: white; }

/* ---------- main content container ---------- */
#content { position: relative; min-height: calc(100vh - 48px); }
#content .loading { padding: 40px; text-align: center; color: #888; }

/* ---------- map view layout (used by all three maps) ---------- */
.mapview { position: absolute; top: 0; left: 0; right: 0; bottom: 0; }
.mapview .map { position: absolute; top: 0; bottom: 0; left: 0; right: 360px; }
.mapview .sidebar {
  position: absolute; top: 0; right: 0; bottom: 0; width: 360px;
  background: #fafafa; border-left: 1px solid #ddd;
  overflow-y: auto; padding: 14px; box-sizing: border-box;
}
.mapview .sidebar h1 { font-size: 15px; margin: 0 0 4px; }
.mapview .sidebar h2 { font-size: 12px; margin: 14px 0 6px; color: #333; text-transform: uppercase; letter-spacing: 0.5px; padding-bottom: 4px; border-bottom: 1px solid #e0e0e0; }
.mapview .sidebar .small { font-size: 11px; color: #666; }
.mapview .row { font-size: 13px; margin: 4px 0; display: flex; align-items: center; }
.mapview .row input[type=radio], .mapview .row input[type=checkbox] { margin-right: 6px; }
.mapview .row label { cursor: pointer; flex: 1; }
.mapview .legend-item { display: flex; align-items: center; margin: 3px 0; font-size: 12px; }
.mapview .swatch { width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; border: 1.5px solid white; box-shadow: 0 0 0 1px #999; }
.mapview input[type=range] { width: 100%; }
.mapview input[type=number], .mapview input[type=text] { width: 100%; box-sizing: border-box; padding: 4px 6px; border: 1px solid #ccc; border-radius: 3px; font-size: 12px; }
.mapview .deeplinks a { display: inline-block; padding: 4px 8px; margin: 2px 2px; background: #1976d2; color: white; text-decoration: none; border-radius: 3px; font-size: 11px; }
.mapview .deeplinks a:hover { background: #1565c0; text-decoration: none; }
.mapview .stats { font-size: 11px; color: #666; margin-top: 8px; padding-top: 8px; border-top: 1px solid #ddd; }
.mapview .stats div { margin: 1px 0; }
.mapview .export-bar {
  position: absolute; bottom: 0; left: 0; right: 360px; padding: 6px 12px;
  background: #263238; color: white; font-size: 12px;
  display: flex; justify-content: space-between; align-items: center; z-index: 1000;
}
.mapview .export-bar button {
  background: #4caf50; color: white; border: none; padding: 5px 12px;
  border-radius: 3px; cursor: pointer; font-size: 12px; margin-left: 6px;
}
.mapview .export-bar button:hover { background: #43a047; }
.mapview .export-bar button.warn { background: #f57c00; }
.mapview .export-bar button.warn:hover { background: #ef6c00; }

/* ---------- popup ---------- */
.popup { font-size: 13px; line-height: 1.4; min-width: 280px; max-width: 360px; }
.popup h3 { margin: 0 0 6px; font-size: 14px; }
.popup .badge { display: inline-block; padding: 2px 6px; border-radius: 3px; font-size: 11px; font-weight: bold; color: white; }
.popup table { width: 100%; border-collapse: collapse; margin: 6px 0; font-size: 12px; }
.popup table td { padding: 3px 4px; border-bottom: 1px solid #eee; vertical-align: top; }
.popup table td:first-child { color: #666; width: 40%; }
.popup .links { margin-top: 8px; font-size: 12px; line-height: 1.8; }
.popup .links a { display: inline-block; margin-right: 6px; color: #0066cc; padding: 2px 6px; background: #eef; border-radius: 3px; }
.popup .links a:hover { background: #dde; }
.popup .note { font-size: 11px; color: #888; margin-top: 6px; font-style: italic; }
.popup .editable {
  font-size: 12px; padding: 6px; background: #f5f5f5;
  border: 1px dashed #aaa; border-radius: 3px; margin: 6px 0;
  cursor: text; min-height: 18px;
}
.popup .editable:focus { background: #fff; border: 1px solid #1976d2; outline: none; }
.popup .editable:empty:before { content: attr(data-placeholder); color: #aaa; font-style: italic; }
.popup .field-label { font-size: 11px; color: #666; text-transform: uppercase; letter-spacing: 0.5px; margin: 8px 0 2px; font-weight: bold; }
.popup .save-btn {
  background: #1976d2; color: white; border: none; padding: 4px 10px;
  border-radius: 3px; cursor: pointer; font-size: 11px; margin-top: 6px;
}
.popup .save-btn:hover { background: #1565c0; }
.popup .save-btn.saved { background: #388e3c; }
.popup .actions a { display: inline-block; margin: 3px 4px 3px 0; padding: 3px 7px; background: #eef; color: #0066cc; border-radius: 3px; font-size: 11px; }
.popup .actions a:hover { background: #dde; text-decoration: none; }
.score-badge { display: inline-block; padding: 3px 8px; font-weight: bold; color: white; border-radius: 3px; font-size: 11px; }

/* ---------- docview ---------- */
.docview { max-width: 900px; margin: 0 auto; padding: 24px 32px 80px; line-height: 1.55; }
.docview .breadcrumb { font-size: 12px; color: #888; margin-bottom: 12px; }
.docview .breadcrumb a { color: #1976d2; }
.docview h1 { font-size: 28px; margin-top: 0; }
.docview h2 { font-size: 22px; margin-top: 28px; border-bottom: 1px solid #ddd; padding-bottom: 4px; }
.docview h3 { font-size: 17px; margin-top: 22px; }
.docview table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 14px; }
.docview table th, .docview table td { border: 1px solid #ddd; padding: 6px 10px; text-align: left; vertical-align: top; }
.docview table th { background: #eef; }
.docview pre { background: #1e1e1e; color: #f0f0f0; padding: 12px; border-radius: 4px; overflow-x: auto; font-size: 13px; line-height: 1.4; }
.docview pre code { background: transparent; color: inherit; padding: 0; }
.docview blockquote { border-left: 4px solid #1976d2; margin: 12px 0; padding: 6px 14px; background: #f0f4ff; color: #333; }
.docview img { max-width: 100%; }
.docview .docerror { background: #ffebee; border: 1px solid #ef9a9a; padding: 12px; border-radius: 4px; color: #c62828; }

/* ---------- overview ---------- */
.overview { max-width: 1200px; margin: 0 auto; padding: 24px 32px 80px; }
.overview h1 { font-size: 28px; margin-top: 0; }
.overview .cards { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 20px 0 32px; }
.overview .card {
  background: white; border: 1px solid #e0e0e0; border-radius: 8px;
  padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.overview .card h2 { margin-top: 0; font-size: 20px; }
.overview .card .stat { font-size: 13px; color: #555; margin: 4px 0; }
.overview .card .stat b { color: #222; font-size: 16px; }
.overview .card .actions { margin-top: 14px; display: flex; gap: 6px; flex-wrap: wrap; }
.overview .card .actions a {
  display: inline-block; padding: 6px 12px; background: #1976d2; color: white;
  border-radius: 4px; font-size: 13px;
}
.overview .card .actions a.alt { background: #607d8b; }
.overview .card .actions a:hover { text-decoration: none; opacity: 0.9; }
.overview .scoring-teaser { background: #fff3e0; border: 1px solid #ffcc80; border-radius: 8px; padding: 20px; margin-top: 20px; }
.overview .scoring-teaser h2 { margin-top: 0; }

/* ---------- dashboard ---------- */
.dashview { padding: 16px 24px 60px; max-width: 1400px; margin: 0 auto; }
.dashview h1 { font-size: 22px; margin: 0 0 12px; }
.dashview .filters { display: flex; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; font-size: 13px; }
.dashview .filters select, .dashview .filters input { padding: 4px 8px; border: 1px solid #ccc; border-radius: 3px; font-size: 13px; }
.dashview table { border-collapse: collapse; width: 100%; font-size: 13px; background: white; }
.dashview table th, .dashview table td { border: 1px solid #ddd; padding: 6px 8px; text-align: left; vertical-align: top; }
.dashview table th { background: #eceff1; cursor: pointer; user-select: none; position: sticky; top: 48px; }
.dashview table th:hover { background: #cfd8dc; }
.dashview table tr:hover { background: #f5faff; }
.dashview .pri-high { background: #ffebee !important; }
.dashview .pri-medium-high { background: #fff3e0 !important; }
.dashview .pri-medium { background: #fffde7 !important; }
.dashview .pri-low { background: #f1f8e9 !important; }
.dashview .grade-badge { display: inline-block; padding: 2px 8px; font-weight: bold; color: white; border-radius: 3px; font-size: 12px; min-width: 18px; text-align: center; }
.dashview .summary-stats { display: flex; gap: 24px; margin-bottom: 12px; font-size: 13px; }
.dashview .summary-stats div b { color: #1976d2; font-size: 18px; }

/* ---------- scoring view ---------- */
.scoringview { padding: 16px 24px 60px; max-width: 1400px; margin: 0 auto; }
.scoringview h1 { font-size: 22px; margin: 0 0 6px; }
.scoringview .rubric-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin: 14px 0 24px; }
.scoringview .rubric-card { background: white; border: 1px solid #e0e0e0; border-left: 4px solid #1976d2; border-radius: 4px; padding: 12px 14px; }
.scoringview .rubric-card .w { font-weight: 700; color: #1976d2; font-size: 18px; }
.scoringview .rubric-card h3 { margin: 4px 0; font-size: 14px; }
.scoringview .rubric-card ul { margin: 6px 0 0; padding-left: 18px; font-size: 12px; color: #555; }
.scoringview .listings-table { border-collapse: collapse; width: 100%; font-size: 12px; background: white; }
.scoringview .listings-table th, .scoringview .listings-table td { border: 1px solid #ddd; padding: 5px 8px; }
.scoringview .listings-table th { background: #eceff1; }
.scoringview .listings-table tr.expand-row td { background: #fafafa; padding: 12px; font-size: 12px; }
.scoringview .listings-table .reasons-list { margin: 0; padding-left: 18px; }
.scoringview .controls { display: flex; gap: 16px; margin: 12px 0; font-size: 13px; flex-wrap: wrap; align-items: center; }
.scoringview .controls label { display: flex; align-items: center; gap: 6px; }
.scoringview .controls input[type=number], .scoringview .controls input[type=range] { padding: 3px 6px; border: 1px solid #ccc; border-radius: 3px; font-size: 12px; }
.scoringview .controls input[type=range] { width: 120px; }

/* ---------- helpers ---------- */
.hidden { display: none !important; }
.small { font-size: 11px; color: #666; }

/* ---------- responsive (very basic; the maps assume desktop width) ---------- */
@media (max-width: 800px) {
  #topnav nav a { padding: 8px 6px; font-size: 11px; }
  .mapview .map { right: 0; bottom: 50vh; }
  .mapview .sidebar { left: 0; width: auto; top: 50vh; }
  .mapview .export-bar { right: 0; }
  .overview .cards { grid-template-columns: 1fr; }
}
