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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 13px;
  color: #1a2a3a;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* ===== MAP LAYER (always behind) ===== */
#map {
  position: fixed;
  inset: 0;
  z-index: 0;
}

/* ===== SCREENS ===== */
.screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  display: none;
}
.screen.active { display: block; }
.screen * { pointer-events: auto; }

/* ===== SHARED COMPONENTS ===== */
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #1a3c6e;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-back:hover { background: #122d54; }

.search-bar {
  position: relative;
  flex: 1;
  max-width: 420px;
}
.search-bar input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1px solid #d0dae8;
  border-radius: 4px;
  font-size: 12px;
  background: #fff;
  outline: none;
}
.search-bar input:focus { border-color: #1976D2; }
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.5;
}

/* ===== SCREEN 1: LANDING ===== */
#screen-landing {
  background: rgba(255,255,255,0.0);
}

.landing-header {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 24px;
  z-index: 20;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
  cursor: pointer;
  opacity: 1;
  transition: opacity .15s;
}
.logo:hover { opacity: 0.8; }
.logo-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}
.logo-texts {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.logo-text {
  font-size: 13px;
  font-weight: 600;
  color: #1a3c6e;
  white-space: nowrap;
}
.logo-subtext {
  font-size: 11px;
  font-weight: 500;
  color: #4a6e9e;
  white-space: nowrap;
}

.landing-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
  flex-wrap: nowrap;
  overflow: hidden;
}
.landing-nav a {
  font-size: 12px;
  color: #4a5568;
  text-decoration: none;
  white-space: nowrap;
}
.landing-nav a:hover { color: #1976D2; }


.btn-enter {
  background: #1976D2;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 8px 20px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-enter:hover { background: #1565C0; }


/* Region labels on landing map */
.region-label-marker {
  background: transparent;
  border: none;
  pointer-events: auto;
}
.region-label-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  font-size: 10px;
  font-weight: 700;
  color: #1a3c6e;
  letter-spacing: 0.5px;
  text-shadow: 1px 1px 2px rgba(255,255,255,0.9), -1px -1px 2px rgba(255,255,255,0.9);
  white-space: nowrap;
  transition: color 0.2s;
  line-height: 1.4;
  text-align: center;
}
.region-label-btn:hover { color: #1976D2; text-decoration: underline; }

.region-dot-marker {
  background: transparent;
  border: none;
}
.region-dot {
  width: 18px;
  height: 18px;
  background: #1976D2;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  cursor: pointer;
  transition: transform 0.15s;
}
.region-dot:hover { transform: scale(1.2); }

/* ===== SCREEN 2: MAP VIEW ===== */
#screen-map {
  pointer-events: none;
}

.map-topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  z-index: 20;
  pointer-events: auto;
}

.region-tabs-bar {
  position: absolute;
  top: 52px; left: 0; right: 0;
  height: 40px;
  background: #1a3c6e;
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  z-index: 20;
  pointer-events: auto;
}
.region-tabs-bar::-webkit-scrollbar { display: none; }

.rtab {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.75);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  padding: 0 14px;
  height: 40px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  border-right: 1px solid rgba(255,255,255,0.1);
}
.rtab:hover { background: rgba(255,255,255,0.1); color: #fff; }
.rtab.active { background: #1976D2; color: #fff; }

/* Left sidebar */
.map-sidebar {
  position: absolute;
  top: 92px;
  left: 16px;
  width: 220px;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  overflow: hidden;
  z-index: 20;
  pointer-events: auto;
  max-height: calc(100vh - 110px);
  display: flex;
  flex-direction: column;
}

.sidebar-select {
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-bottom: 1px solid #e2e8f0;
  font-size: 12px;
  color: #1a3c6e;
  background: #f7faff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%231a3c6e'/%3E%3C/svg%3E") no-repeat right 10px center;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  outline: none;
  font-weight: 600;
}

.sidebar-list {
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: #d0dae8 transparent;
}
.sidebar-list-item {
  padding: 9px 14px;
  font-size: 12px;
  color: #2d4a6e;
  cursor: pointer;
  border-bottom: 1px solid #f0f4fa;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.12s;
}
.sidebar-list-item:hover { background: #edf2fb; }
.sidebar-list-item.active { background: #dce9f8; font-weight: 600; color: #1a3c6e; }
.sidebar-item-count {
  font-size: 10px;
  background: #1976D2;
  color: #fff;
  border-radius: 10px;
  padding: 1px 7px;
  font-weight: 700;
}

.sidebar-total {
  padding: 10px 14px;
  font-size: 12px;
  color: #4a6080;
  border-top: 1px solid #e2e8f0;
  background: #f7faff;
  flex-shrink: 0;
}
.sidebar-total strong {
  color: #1976D2;
  font-size: 14px;
}

/* Project markers */
.proj-marker {
  background: transparent;
  border: none;
}
.proj-dot {
  width: 14px;
  height: 14px;
  background: #1976D2; /* overridden by inline style */
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0,0,0,0.35);
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
}
.proj-dot:hover { transform: scale(1.4); }
.proj-dot.selected { background: #e53935 !important; transform: scale(1.3); }
.proj-dot.mismatch { box-shadow: 0 0 0 3px rgba(239,68,68,0.7), 0 2px 5px rgba(0,0,0,0.25); }

/* ===== SCREEN 3/4: CITY VIEW ===== */
#screen-city {
  pointer-events: none;
}

.city-topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  z-index: 20;
  pointer-events: auto;
}
.city-topbar-title {
  font-size: 13px;
  font-weight: 700;
  color: #1a3c6e;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}
.city-count-badge {
  margin-left: auto;
  font-size: 12px;
  color: #4a6080;
  flex-shrink: 0;
  white-space: nowrap;
}
.city-count-badge strong {
  color: #1976D2;
  font-weight: 700;
}

/* Passport side panel */
.passport-panel {
  position: absolute;
  top: 52px;
  right: 0;
  width: 320px;
  bottom: 0;
  background: #fff;
  box-shadow: -4px 0 16px rgba(0,0,0,0.12);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 20;
  pointer-events: auto;
  transition: transform 0.3s ease;
  scrollbar-width: thin;
}
.passport-panel.hidden { transform: translateX(100%); }

.passport-header {
  padding: 14px 16px 10px;
  border-bottom: 2px solid #1976D2;
}
.passport-header h3 {
  font-size: 13px;
  font-weight: 700;
  color: #1a3c6e;
  letter-spacing: 0.5px;
}

.passport-address {
  padding: 10px 16px;
  font-size: 12px;
  color: #2d4a6e;
  font-weight: 600;
  background: #f0f5ff;
  border-bottom: 1px solid #dce9f8;
}

.passport-fields {
  padding: 12px 16px;
  flex: 1;
}
.passport-field {
  margin-bottom: 12px;
}
.passport-field-label {
  font-size: 11px;
  color: #7a8fa6;
  font-weight: 600;
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.passport-field-value {
  font-size: 12px;
  color: #1a2a3a;
  font-weight: 500;
  padding: 5px 8px;
  background: #f7faff;
  border-radius: 4px;
  border-left: 3px solid #1976D2;
}
.passport-field-value.empty {
  background: #f5f5f5;
  border-left-color: #d0dae8;
  color: #bcc8d8;
  font-style: italic;
}
.passport-field-value.empty::after { content: '—'; }

.passport-qr-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 16px;
  border-top: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
}
.passport-qr-block img {
  width: 80px;
  height: 80px;
}
.passport-qr-label {
  font-size: 10px;
  color: #7a8fa6;
  font-weight: 600;
  margin-top: 4px;
  letter-spacing: 0.5px;
}

.passport-actions {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.btn-passport {
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}
.btn-passport.primary {
  background: #1976D2;
  color: #fff;
}
.btn-passport.primary:hover { background: #1565C0; }
.btn-passport.secondary {
  background: #e3edf8;
  color: #1a3c6e;
}
.btn-passport.secondary:hover { background: #d0dff2; }
.btn-passport:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ===== SCREEN 5: FULL PASSPORT ===== */
#screen-passport {
  pointer-events: none;
}

.passport-full-wrap {
  position: absolute;
  top: 0;
  right: 0;
  width: 480px;
  bottom: 0;
  background: #fff;
  box-shadow: -4px 0 24px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  z-index: 20;
  pointer-events: auto;
}

.passport-full-topbar {
  height: 52px;
  background: #1a3c6e;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  flex-shrink: 0;
}
.passport-full-topbar .city-topbar-title {
  color: #fff;
  font-size: 12px;
}

.passport-full-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  scrollbar-width: thin;
}

.passport-full-address {
  font-size: 14px;
  font-weight: 700;
  color: #1a3c6e;
  padding: 10px 16px;
  background: #f0f5ff;
  border-bottom: 2px solid #1976D2;
  flex-shrink: 0;
}

.passport-participant {
  background: #f7faff;
  border: 1px solid #dce9f8;
  border-radius: 6px;
  margin-bottom: 12px;
  overflow: hidden;
}
.passport-participant-header {
  background: #1a3c6e;
  color: #fff;
  padding: 8px 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.passport-participant-body {
  padding: 10px 14px;
}
.passport-participant-name {
  font-size: 13px;
  font-weight: 600;
  color: #1a2a3a;
  margin-bottom: 6px;
}
.passport-participant-detail {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 4px;
}
.pdetail-label {
  font-size: 11px;
  font-weight: 600;
  color: #7a8fa6;
  min-width: 60px;
  flex-shrink: 0;
}
.pdetail-val {
  font-size: 11px;
  color: #2d4a6e;
}

.passport-doc-section {
  background: #eef5ff;
  border: 1px solid #dce9f8;
  border-radius: 6px;
  margin-bottom: 12px;
  overflow: hidden;
}
.passport-doc-header {
  background: #2d6bc4;
  color: #fff;
  padding: 8px 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.passport-doc-body {
  padding: 10px 14px;
  display: flex;
  gap: 24px;
}
.doc-field { }
.doc-label {
  font-size: 10px;
  color: #7a8fa6;
  font-weight: 600;
  text-transform: uppercase;
}
.doc-value {
  font-size: 12px;
  color: #1a2a3a;
  font-weight: 500;
}

.passport-full-actions {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid #e2e8f0;
  flex-shrink: 0;
}
.btn-full {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-full.primary { background: #1976D2; color: #fff; }
.btn-full.primary:hover { background: #1565C0; }
.btn-full.download { background: #e53935; color: #fff; }
.btn-full.download:hover { background: #c62828; }
.btn-full.print { background: #37474f; color: #fff; }
.btn-full.print:hover { background: #263238; }
.btn-full img { width: 18px; height: 18px; object-fit: contain; }

/* ===== LEAFLET CUSTOM ===== */
.leaflet-control-zoom a {
  color: #1a3c6e !important;
}
.leaflet-popup-content-wrapper {
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
}
.leaflet-popup-content {
  margin: 10px 14px;
  font-size: 12px;
  line-height: 1.5;
}
.popup-address {
  font-weight: 600;
  color: #1a3c6e;
  margin-bottom: 4px;
}
.popup-customer {
  color: #4a6080;
}

/* ===== BUILDING NUMBER MARKERS ===== */
.bldg-num-marker {
  background: transparent;
  border: none;
}
.bldg-num {
  width: 22px;
  height: 22px;
  background: #1976D2; /* overridden by inline style */
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
}
.bldg-num:hover { transform: scale(1.2); filter: brightness(1.15); }
.bldg-num.selected { background: #e53935 !important; transform: scale(1.25); }
.bldg-num.mismatch { border: 3px solid #ef4444 !important; }

/* ===== MAP LEGEND ===== */
.map-legend {
  position: absolute;
  bottom: 36px;
  left: 12px;
  background: rgba(255,255,255,0.95);
  border: 1px solid #dce9f8;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 10px;
  color: #1a2a3a;
  z-index: 20;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  pointer-events: none;
  min-width: 168px;
}
.map-legend-title {
  font-weight: 700;
  font-size: 10px;
  color: #4a6080;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.map-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  line-height: 1.2;
}
.map-legend-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1.5px solid rgba(255,255,255,0.7);
}
.map-legend-mismatch {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #43a047;
  border: 2px solid #ef4444;
  box-shadow: 0 0 0 2px rgba(239,68,68,0.4);
}

/* ===== PASSPORT EXTENDED BLOCKS ===== */

/* Unique ID */
.passport-uid-block {
  background: #1a3c6e;
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.passport-uid-label {
  font-size: 10px;
  color: #a8c4e8;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.passport-uid-value {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 1px;
  font-family: monospace;
}

/* Shared section header */
.passport-section-header {
  background: #2d6bc4;
  color: #fff;
  padding: 8px 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Land purpose */
.passport-land-block {
  background: #f7faff;
  border: 1px solid #dce9f8;
  border-radius: 6px;
  margin-bottom: 12px;
  overflow: hidden;
}
.passport-land-block.land-mismatch {
  border-color: #e74c3c;
}
.passport-land-block.land-mismatch .passport-section-header {
  background: #c0392b;
}
.passport-land-body {
  padding: 10px 14px;
}
.land-row {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
  align-items: flex-start;
}
.land-label {
  font-size: 11px;
  color: #7a8fa6;
  font-weight: 600;
  min-width: 150px;
  flex-shrink: 0;
}
.land-val {
  font-size: 11px;
  color: #1a2a3a;
}
.land-warning {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-top: 8px;
  padding: 8px 10px;
  background: #fff0ed;
  border: 1px solid #e74c3c;
  border-radius: 4px;
  font-size: 11px;
  color: #c0392b;
  font-weight: 600;
  line-height: 1.4;
}

/* Technical specs */
.passport-tech-block {
  background: #f7faff;
  border: 1px solid #dce9f8;
  border-radius: 6px;
  margin-bottom: 12px;
  overflow: hidden;
}
.passport-tech-body {
  padding: 10px 14px;
}
.tech-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid #eef3fa;
}
.tech-row:last-child { border-bottom: none; }
.tech-label {
  font-size: 11px;
  color: #7a8fa6;
  font-weight: 600;
}
.tech-val {
  font-size: 11px;
  color: #1a2a3a;
  font-weight: 500;
  text-align: right;
}

/* Shares permit */
.passport-shares-block {
  background: #f0fff4;
  border: 1px solid #a8d5b5;
  border-radius: 6px;
  margin-bottom: 12px;
  overflow: hidden;
}
.passport-shares-block .passport-section-header {
  background: #27ae60;
}
.passport-shares-body {
  padding: 10px 14px;
}
.shares-status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 8px;
}
.permit-active  { background: #d4efdf; color: #1e8449; }
.permit-expired { background: #fde9e9; color: #c0392b; }
.shares-row {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
  align-items: flex-start;
}
.shares-label {
  font-size: 11px;
  color: #7a8fa6;
  font-weight: 600;
  min-width: 130px;
  flex-shrink: 0;
}
.shares-val {
  font-size: 11px;
  color: #1a2a3a;
}

/* Timeline */
.passport-timeline-block {
  background: #f7faff;
  border: 1px solid #dce9f8;
  border-radius: 6px;
  margin-bottom: 12px;
  overflow: hidden;
}
.passport-timeline-body {
  padding: 14px 14px 8px;
}
.tl-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 0;
}
.tl-icon-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  width: 16px;
}
.tl-connector {
  width: 2px;
  height: 24px;
  background: #d0dff0;
  margin-top: 2px;
}
.tl-connector-done {
  background: #1976D2;
}
.tl-content {
  padding-bottom: 16px;
  flex: 1;
}
.tl-stage {
  font-size: 11px;
  font-weight: 600;
  color: #1a2a3a;
  line-height: 1.3;
}
.tl-done .tl-stage  { color: #1565C0; }
.tl-active .tl-stage { color: #e67e22; font-weight: 700; }
.tl-pending .tl-stage { color: #9ab0c8; }
.tl-date {
  font-size: 10px;
  color: #7a8fa6;
  display: block;
  margin-top: 2px;
}

/* ===== PRINT ===== */
@media print {
  #map, .passport-full-topbar .btn-back, .passport-full-actions { display: none; }
  .passport-full-wrap { width: 100%; box-shadow: none; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #b0c4de; border-radius: 3px; }
