:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1f2530;
  --text-muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --danger-dark: #b91c1c;
  --ok: #15803d;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --radius: 10px;
  --space: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 var(--space);
}

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.header-logo {
  height: 36px;
  width: auto;
  margin-right: 12px;
  flex-shrink: 0;
}
.brand {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.2px;
}
.admin-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}
.admin-link:hover {
  text-decoration: underline;
}

/* Map */
.map-canvas {
  width: 100%;
  height: 72vh;
  min-height: 420px;
  margin: var(--space) 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  background: #e9edf2;
}

.status-banner {
  margin: var(--space) 0 0;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 15px;
}
.status-banner.status-error {
  border-color: #f1c0c0;
  background: #fdf3f3;
  color: var(--danger-dark);
}

/* Cards & forms */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin: var(--space) 0;
}
.form {
  display: block;
}
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-wide {
  grid-column: 1 / -1;
}
.label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.req {
  color: var(--danger);
}
.hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
input[type="text"],
input[type="number"],
input[type="url"],
input[type="password"] {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}
input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
input[type="file"] {
  font-size: 13px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-dark);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: var(--danger-dark);
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover {
  background: #f0f2f5;
}
.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* Admin console */
.admin-console {
  padding: var(--space) 0;
}
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space);
}
.toolbar h2 {
  margin: 0;
  font-size: 18px;
}
.toolbar-list {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 8px;
}
.reparse-status {
  font-size: 13px;
  color: var(--text-muted);
}
.list-heading {
  font-size: 18px;
  margin: 24px 0 8px;
}

/* Messages */
.message {
  margin: 12px 0 0;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
}
.message-error {
  background: #fdf3f3;
  color: var(--danger-dark);
  border: 1px solid #f1c0c0;
}
.message-ok {
  background: #f0fbf3;
  color: var(--ok);
  border: 1px solid #bfe6cb;
}

/* Empty state */
.empty-state {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* Table */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 14px;
}
.table th,
.table td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
}
.table th {
  background: #f8f9fb;
  font-weight: 600;
  color: var(--text-muted);
}
.table tr:last-child td {
  border-bottom: none;
}
.table-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}
.table-link:hover {
  text-decoration: underline;
}
.muted {
  color: var(--text-muted);
}
.row-actions {
  display: flex;
  gap: 8px;
  white-space: nowrap;
}

/* Google Maps InfoWindow content */
.info-window {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  font-size: 13px;
  color: var(--text);
  min-width: 160px;
  max-width: 240px;
  /* Reduce top padding so more content fits without scrolling */
  padding: 6px 10px 8px;
}
/* Shrink Google's default InfoWindow close button */
.gm-style-iw-chr {
  width: 18px !important;
  height: 18px !important;
}
.gm-style-iw-chr span {
  font-size: 14px !important;
}
.info-ref {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--primary);
  text-transform: uppercase;
}
.info-title {
  font-size: 15px;
  font-weight: 700;
  margin: 1px 0 4px;
}
.info-row {
  margin: 1px 0;
}
.info-label {
  color: var(--text-muted);
  font-weight: 600;
}
.info-pdf {
  display: inline-block;
  margin-top: 4px;
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}
.info-pdf:hover {
  text-decoration: underline;
}
.info-pdfs {
  margin-top: 4px;
  line-height: 1.7;
}

/* Small ref_no label rendered above each map pin */
.pin-label {
  font-size: 11px;
  font-weight: 600;
  color: #111827;
  background: rgba(255, 255, 255, 0.92);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.12);
}

/* Front-end marker label (shortname above the pin) — black name + a colored
   availability dot. Rendered as an OverlayView so we can mix black text with a
   colored dot. The white halo keeps the text readable on any map background. */
.pin-label-marker {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  cursor: pointer;
}
.label-text {
  font-weight: 700;
  color: #111827; /* black short name */
  text-shadow:
    0 0 2px #fff,
    0 0 2px #fff,
    0 0 2px #fff,
    1px 1px 0 #fff,
    -1px -1px 0 #fff,
    1px -1px 0 #fff,
    -1px 1px 0 #fff;
}
/* Small availability dot — used in the map label and the InfoWindow row. */
.avail-dot {
  display: inline-block;
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.18);
  vertical-align: middle;
}

/* Download-log monitoring section (admin) */
.logs-section {
  margin: 28px 0 var(--space);
}
.logs-section .toolbar-list {
  margin: 10px 0 0;
}
.logs-status {
  font-size: 13px;
  color: var(--text-muted);
}
.logs-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Header actions (map view) */
.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Filter bar above the map */
.filter-bar {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin: 0 0 12px;
}
.filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.filter-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.filter-field select {
  min-width: 150px;
  padding: 7px 10px;
  border: 1px solid var(--border, #cbd5e1);
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
  color: var(--text);
}

/* Legend bar under the map */
.legend-bar {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin: 0 0 var(--space);
  font-size: 13px;
  color: var(--text-muted);
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend-sep {
  width: 1px;
  align-self: stretch;
  background: var(--border, #d6dbe1);
  margin: 0 2px;
}
.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid rgba(0, 0, 0, 0.15);
}
/* Pin-shaped legend icon — inline SVG teardrop matching the map marker */
.legend-pin {
  display: inline-flex;
  align-items: flex-end;
  flex-shrink: 0;
  line-height: 0;
}

/* InfoWindow building image */
.info-image {
  width: 75px; /* smaller to save vertical space in the overlay */
  height: auto;
  object-fit: contain;
  border-radius: 6px;
  margin-bottom: 5px;
  display: block;
}
.info-image--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 75px;
  min-height: 52px;
  background: #eef1f5;
  color: var(--text-muted);
  font-size: 13px;
  border-radius: 8px;
  margin-bottom: 8px;
}
.info-status {
  display: inline-block;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}

/* Status badge (admin table) */
.status-badge {
  display: inline-block;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
}

/* Image thumbnail in admin table */
.thumb {
  width: 56px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  vertical-align: middle;
}

/* Layout rows in admin form */
.layout-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.layout-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.layout-row select,
.layout-row input {
  width: auto;
  flex: 1;
}
.layout-row .tilde {
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .grid {
    grid-template-columns: 1fr;
  }
  .map-canvas {
    height: 60vh;
  }
}
