:root {
  /* --- DESIGN TOKENS (Light Mode) --- */
  --bg-app:         #EEF2F7;
  --bg-surface:     #FFFFFF;
  --bg-elevated:    #F8FAFC;
  --bg-sidebar:     #F4F6FA;
  --bg-input:       #FAFBFC;

  --glass-surface:       rgba(255, 255, 255, 0.72);
  --glass-surface-hover: rgba(241, 245, 249, 0.92);
  --glass-border:        rgba(213, 221, 232, 1);

  --text-primary:   #0D1526;
  --text-secondary: #5C6B7A;
  --text-tertiary:  #8B9BB2;
  --text-muted:     #5C6B7A;
  --text-inverse:   #FFFFFF;

  --primary-600:    #1B3A5C;
  --primary-hover:  #0F2740;
  --primary-subtle: #E8EEF5;

  --color-success: #0EA569;
  --color-warning: #E8930A;
  --color-danger:  #E53E5C;
  --color-info:    #2B7FE8;
  --rose-500:      #E53E5C;

  --border-default: rgba(213, 221, 232, 1);
  --border-strong:  rgba(180, 192, 207, 1);

  --shadow-sm:  0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:  0 10px 30px rgba(0,0,0,0.10), 0 4px 8px rgba(0,0,0,0.05);

  --aurora-1: #DDE5FF;
  --aurora-2: #F5E8FF;
  --aurora-3: #D1F5EA;

  /* === SGS LAND DESIGN TOKENS === */
  --sgs-bg:             #FAFAF8;
  --sgs-surface:        #FFFFFF;
  --sgs-primary:        #1B3A5C;
  --sgs-primary-deep:   #0F2740;
  --sgs-accent:         #C8963E;
  --sgs-accent-text:    #8C6420;
  --sgs-text:           #16202B;
  --sgs-text-muted:     #5C6B7A;
  --sgs-text-heading:   #1B3A5C;
  --sgs-verified:       #1E7F5C;
  --sgs-hero-deep:      #0A1E33;
  --sgs-champagne:      #F5EAD5;
  --sgs-on-dark-muted:  #93A6B8;
  --sgs-subtle-bg:      #F5EAD5;
  --sgs-border:         rgba(27,58,92,0.12);
}

.dark {
  --bg-app:         #0B1120;
  --bg-surface:     #161F2E;
  --bg-elevated:    #1E2B3F;
  --bg-sidebar:     #111827;
  --bg-input:       #1A2336;

  --glass-surface:       rgba(22, 31, 46, 0.82);
  --glass-surface-hover: rgba(40, 55, 78, 0.92);
  --glass-border:        rgba(45, 60, 82, 1);

  --text-primary:   #EEF2F8;
  --text-secondary: #8EA4BF;
  --text-tertiary:  #516278;
  --text-muted:     #364559;
  --text-inverse:   #0D1526;

  --primary-600:    #1B3A5C;
  --primary-hover:  #7FA8D0;
  --primary-subtle: #E8EEF5;

  --color-success: #34D399;
  --color-warning: #FBBF24;
  --color-danger:  #FB7185;
  --color-info:    #60A5FA;
  --rose-500:      #FB7185;

  --border-default: rgba(45, 60, 82, 1);
  --border-strong:  rgba(65, 85, 110, 1);

  --shadow-sm:  0 1px 3px rgba(0,0,0,0.25), 0 1px 2px rgba(0,0,0,0.15);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.30), 0 2px 4px rgba(0,0,0,0.15);
  --shadow-lg:  0 10px 30px rgba(0,0,0,0.40), 0 4px 8px rgba(0,0,0,0.20);

  --aurora-1: #1e1b4b;
  --aurora-2: #312e81;
  --aurora-3: #0f172a;

  /* === SGS LAND DARK MODE TOKENS === */
  --sgs-bg:             #0E1620;
  --sgs-surface:        #16222F;
  --sgs-primary:        #7FA8D0;
  --sgs-primary-deep:   #1B3A5C;
  --sgs-accent:         #D4A855;
  --sgs-accent-text:    #D4A855;
  --sgs-text:           #E8ECF1;
  --sgs-text-muted:     #9AAAB8;
  --sgs-text-heading:   #7FA8D0;
  --sgs-verified:       #3FB389;
  --sgs-hero-deep:      #0A1E33;
  --sgs-champagne:      #1B2A3A;
  --sgs-on-dark-muted:  #93A6B8;
  --sgs-subtle-bg:      #1E2D3D;
  --sgs-border:         rgba(127,168,208,0.15);
}

/* --- CORE LAYOUT --- */
@media print {
  body { font-family: 'Noto Serif', 'Times New Roman', Times, serif !important; background: #fff !important; overflow: auto !important; }
  .print\:hidden { display: none !important; }
}
html, body {
  height: 100%;
  width: 100%;
  margin: 0; padding: 0;
  overflow: hidden;
  font-family: var(--custom-font, 'Inter', sans-serif);
  font-size: var(--custom-font-size, 15px);
  background-color: var(--sgs-bg);
  color: var(--sgs-text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* --- OPTIMIZED AURORA BACKGROUND (GPU Accelerated) --- */
#app-background {
  position: fixed;
  inset: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(circle at center, transparent 0%, var(--sgs-bg) 70%),
              conic-gradient(from 0deg at 50% 50%, var(--aurora-1), var(--aurora-2), var(--aurora-3), var(--aurora-1));
  filter: blur(80px);
  opacity: 0.4;
  z-index: -1;
  animation: aurora-spin 60s linear infinite;
  pointer-events: none;
  will-change: transform;
  transform: translateZ(0);
  contain: strict;
}

@keyframes aurora-spin {
  from { transform: rotate(0deg) translateZ(0); }
  to { transform: rotate(360deg) translateZ(0); }
}

/* Disable expensive aurora animation on mobile — big FCP/LCP win */
@media (max-width: 768px), (prefers-reduced-motion: reduce) {
  #app-background {
    animation: none;
    filter: none;
    opacity: 0.15;
    background: var(--sgs-bg);
    inset: 0;
    width: 100%; height: 100%;
  }
}

/* --- UTILITIES — hide all scrollbars globally --- */
*, *::before, *::after { -ms-overflow-style: none; scrollbar-width: none; }
*::-webkit-scrollbar { display: none; }
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* Show scrollbar on customer-facing public pages (microsite, proposal, contract).
   Marketing pages need scroll affordance so visitors on small laptops realize
   the page extends below the fold. Overrides the global hide rule. */
.show-scrollbar { -ms-overflow-style: auto !important; scrollbar-width: thin !important; }
.show-scrollbar::-webkit-scrollbar { display: block !important; width: 10px; height: 10px; }
.show-scrollbar::-webkit-scrollbar-track { background: rgba(15,23,42,0.05); }
.show-scrollbar::-webkit-scrollbar-thumb { background: rgba(15,23,42,0.25); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
.show-scrollbar::-webkit-scrollbar-thumb:hover { background: rgba(15,23,42,0.45); background-clip: padding-box; border: 2px solid transparent; }

@layer components {
  .glass-card {
    background: var(--glass-surface);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-sm);
  }
}

/* --- COMPACT BUTTON SYSTEM --- */
.card-surface {
  background: var(--sgs-surface);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-sm);
}
.card-elevated {
  background: var(--sgs-surface);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-md);
}

.animate-enter { animation: soft-enter 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
@keyframes soft-enter { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* --- ENHANCED LOADER --- */
.initial-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 24px;
  color: var(--sgs-text-muted);
  z-index: 50;
  position: relative;
}
.loader-logo {
  width: 64px; height: 64px;
  background: var(--sgs-surface);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: breathe 2s infinite ease-in-out;
}
.loader-bar {
  width: 120px;
  height: 4px;
  background: rgba(125,125,125,0.1);
  border-radius: 2px;
  overflow: hidden;
}
.loader-progress {
  height: 100%;
  width: 50%;
  background: var(--sgs-primary);
  border-radius: 2px;
  animation: progress 1.5s infinite ease-in-out;
}
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes progress { 0% { transform: translateX(-100%); } 100% { transform: translateX(200%); } }

/* --- ADAPTIVE LOGO: navy on light bg, white on dark bg --- */
.logo-adaptive { filter: none; }
html.dark .logo-adaptive { filter: brightness(0) invert(1); }

/* --- ENTERPRISE MAP OVERRIDES (White Labeling & Fixes) --- */
.leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.7) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  border-radius: 12px !important;
  padding: 2px 8px !important;
  margin: 0 8px 8px 0 !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 9px !important;
  color: #94a3b8 !important;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05) !important;
  border: 1px solid rgba(255,255,255,0.5) !important;
  pointer-events: auto !important;
  z-index: 500 !important;
}
.leaflet-control-attribution a {
  color: #64748b !important;
  text-decoration: none !important;
  font-weight: 600 !important;
}
.leaflet-control-zoom { display: none !important; }
.leaflet-container {
  background: #e2e8f0;
}

/* --- CUSTOM PIN FIX --- */
.custom-map-pin,
.custom-map-pin-container {
  background: transparent !important;
  border: none !important;
  overflow: visible !important;
}
.leaflet-marker-icon.custom-map-pin-container {
  overflow: visible !important;
}

/* --- MAP PIN STYLES (CSS-class-based, production-safe) --- */
/* Outer wrapper — positions bubble above anchor point */
.sgs-pin-outer {
  display: inline-flex !important;
  flex-direction: column !important;
  align-items: center !important;
  transform: translate(-50%, -100%) scale(1) !important;
  transform-origin: bottom center !important;
  transition: transform 0.18s cubic-bezier(0.34,1.56,0.64,1), filter 0.18s ease !important;
  will-change: transform, filter !important;
  pointer-events: auto !important;
}
.sgs-pin-outer.sgs-pin-active {
  transform: translate(-50%, -100%) scale(1.12) !important;
}
/* Bubble shared styles */
.sgs-pin-bubble {
  color: #fff !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  padding: 5px 11px !important;
  border-radius: 10px 10px 0 0 !important;
  border: 2px solid rgba(255,255,255,0.92) !important;
  border-bottom: none !important;
  white-space: nowrap !important;
  letter-spacing: 0.2px !important;
  line-height: 1.4 !important;
  font-family: system-ui,-apple-system,sans-serif !important;
  cursor: pointer !important;
  display: inline-block !important;
  background-image: linear-gradient(160deg,rgba(255,255,255,0.15) 0%,transparent 60%) !important;
}
.sgs-pin-bubble.sgs-pin-active {
  border-color: rgba(255,255,255,1) !important;
  border-bottom: none !important;
}
/* Three pin colors */
.sgs-pin-sale    { background-color: #1b3a5c !important; }
.sgs-pin-rent    { background-color: #7c3aed !important; }
.sgs-pin-project { background-color: #2563eb !important; }
/* Tail triangles — box-sizing:content-box is critical: Leaflet's .leaflet-container*
   rule sets box-sizing:border-box globally, which collapses width:0/height:0 borders
   to nothing, breaking the CSS border-trick triangle. content-box overrides this. */
.sgs-pin-tail {
  box-sizing: content-box !important;
  width: 0 !important; height: 0 !important;
  border-left: 10px solid transparent !important;
  border-right: 10px solid transparent !important;
  margin-top: -1px !important;
}
.sgs-pin-tail.sgs-pin-sale    { border-top: 11px solid #1b3a5c !important; }
.sgs-pin-tail.sgs-pin-rent    { border-top: 11px solid #7c3aed !important; }
.sgs-pin-tail.sgs-pin-project { border-top: 11px solid #2563eb !important; }
/* Cluster outer wrapper — inline-flex so it self-sizes inside the 0×0 Leaflet marker */
.sgs-cluster-outer {
  display: inline-flex !important;
  transform: translate(-50%, -50%) !important;
  transform-origin: center !important;
  pointer-events: auto !important;
  cursor: pointer !important;
}
/* Cluster pill badge (no tail — centred on cluster coordinate) */
.sgs-cluster-pill {
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
  color: #fff !important;
  font-size: 13px !important;
  font-weight: 800 !important;
  padding: 9px 16px !important;
  border-radius: 20px !important;
  border: 2.5px solid rgba(255,255,255,0.96) !important;
  white-space: nowrap !important;
  letter-spacing: 0.2px !important;
  line-height: 1 !important;
  font-family: system-ui,-apple-system,sans-serif !important;
  background-image: linear-gradient(135deg,rgba(255,255,255,0.22) 0%,transparent 55%) !important;
}
.sgs-cluster-pill.sgs-pin-sale    { background-color: #1b3a5c !important; }
.sgs-cluster-pill.sgs-pin-rent    { background-color: #7c3aed !important; }
.sgs-cluster-pill.sgs-pin-project { background-color: #2563eb !important; }
/* Legacy cluster bubble + tail (kept for safety, not used by current clusterIcon) */
.sgs-cluster-bubble {
  color: #fff !important;
  font-size: 12.5px !important;
  font-weight: 800 !important;
  padding: 7px 16px !important;
  border-radius: 12px 12px 0 0 !important;
  border: 2.5px solid rgba(255,255,255,0.95) !important;
  border-bottom: none !important;
  white-space: nowrap !important;
  letter-spacing: 0.3px !important;
  line-height: 1.4 !important;
  font-family: system-ui,-apple-system,sans-serif !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  position: relative !important;
  background-image: linear-gradient(135deg,rgba(255,255,255,0.18) 0%,transparent 55%) !important;
}
.sgs-cluster-bubble.sgs-pin-sale    { background-color: #1b3a5c !important; }
.sgs-cluster-bubble.sgs-pin-rent    { background-color: #7c3aed !important; }
.sgs-cluster-bubble.sgs-pin-project { background-color: #2563eb !important; }
.sgs-cluster-tail {
  box-sizing: content-box !important;
  width: 0 !important; height: 0 !important;
  border-left: 12px solid transparent !important;
  border-right: 12px solid transparent !important;
  margin-top: -1px !important;
}
.sgs-cluster-tail.sgs-pin-sale    { border-top: 13px solid #1b3a5c !important; }
.sgs-cluster-tail.sgs-pin-rent    { border-top: 13px solid #7c3aed !important; }
.sgs-cluster-tail.sgs-pin-project { border-top: 13px solid #2563eb !important; }

/* --- LANDING PAGE ANIMATIONS --- */
@keyframes scroll-x {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}
.animate-scroll-x {
  animation: scroll-x 25s linear infinite;
  width: max-content;
}
.mask-linear-fade {
  mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent);
  -webkit-mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent);
}
@keyframes blink { 50% { opacity: 0; } }
.animate-blink { animation: blink 1s step-end infinite; }

/* --- SKELETON LOADER TEXT --- */
.loader-status-text {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  opacity: 0.5;
}

/* --- NOSCRIPT FALLBACK --- */
.noscript-wrapper {
  padding: 40px;
  text-align: center;
  color: var(--sgs-text);
}
.noscript-wrapper h2 {
  font-weight: 800;
  margin-bottom: 10px;
}

/* --- MARKDOWN STYLES --- */
.markdown-body {
  font-family: inherit;
}
.markdown-body p { margin-bottom: 0.75em; }
.markdown-body p:last-child { margin-bottom: 0; }
.markdown-body strong { font-weight: 700; }
.markdown-body em { font-style: italic; }
.markdown-body ul { list-style-type: disc; padding-left: 1.5em; margin-bottom: 0.75em; }
.markdown-body ol { list-style-type: decimal; padding-left: 1.5em; margin-bottom: 0.75em; }
.markdown-body li { margin-bottom: 0.25em; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 { font-weight: 700; margin-top: 1em; margin-bottom: 0.5em; }
.markdown-body h1 { font-size: 1.5em; }
.markdown-body h2 { font-size: 1.25em; }
.markdown-body h3 { font-size: 1.125em; }
.markdown-body code { background-color: rgba(0,0,0,0.05); padding: 0.1em 0.3em; border-radius: 0.25em; font-family: var(--font-mono); font-size: 0.9em; }
.dark .markdown-body code { background-color: rgba(255,255,255,0.1); }
.markdown-body pre { background-color: rgba(0,0,0,0.05); padding: 0.75em; border-radius: 0.5em; overflow-x: auto; margin-bottom: 0.75em; }
.dark .markdown-body pre { background-color: rgba(255,255,255,0.05); }
.markdown-body pre code { background-color: transparent; padding: 0; }
.markdown-body blockquote { border-left: 3px solid rgba(0,0,0,0.1); padding-left: 1em; margin-left: 0; color: var(--sgs-text-muted); font-style: italic; }
.dark .markdown-body blockquote { border-left-color: rgba(255,255,255,0.1); }
.markdown-body a { color: var(--sgs-primary); text-decoration: underline; text-underline-offset: 2px; }
