/*
 * Terragraph Suite - Professional GIS Web Application Styles
 * Copyright (c) 2025 Eric Guldenstern / Terragraph Cartography LLC
 * A Florida Limited Liability Company
 * All Rights Reserved - Proprietary and Confidential
 * 
 * This software and its documentation are the proprietary information of 
 * Terragraph Cartography LLC and are protected by copyright law.
 * Unauthorized reproduction or distribution is prohibited.
 * 
 * Developer: Eric Guldenstern
 * Operations Manager, Atlas Apex Roofing USA
 * Founder & CEO, Terragraph Cartography LLC
 */

/* ===============================
   PROFESSIONAL THEME SYSTEM
   Dark & Light Modes Only
   =============================== */

:root, html[data-theme="dark"] {
  /* Enhanced Dark Theme - Professional & Modern */
  --bg: #0a0e13;
  --bg-rgb: 10, 14, 19;
  --panel: #111827;
  --panel-secondary: #1f2937;
  --muted: #9ca3af;
  --text: #f9fafb;
  --text-muted: #d1d5db;
  --line: #374151;
  --border: #4b5563;
  --hover: rgba(55, 65, 81, 0.5);
  --btn: #1f2937;
  --btn-hover: #374151;
  --accent: #3b82f6;
  --accent-light: #60a5fa;
  --accent-dark: #2563eb;
  --accent-shadow: rgba(59, 130, 246, 0.4);
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #06b6d4;
  
  /* Typography */
  --font: "Inter", "SF Pro Display", "Segoe UI", "Roboto", system-ui, -apple-system, sans-serif;
  --font-mono: "SF Mono", "Monaco", "Cascadia Code", "Roboto Mono", monospace;
  --font-size-base: 16px;
  --font-size-small: 14px;
  --font-size-large: 18px;
  --line-height: 1.5;
  
  /* Shadows & Effects */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.5);
  
  /* Layout */
  --leftbar-width: 80px;
  --border-radius: 8px;
  --border-radius-sm: 6px;
  --border-radius-lg: 12px;
}

html[data-theme="light"] {
  /* Rugged Mountaineer Light Theme - Warm Tan & Earth Tones */
  --bg: #f5f0e8; /* Warm light tan background */
  --bg-rgb: 245, 240, 232;
  --panel: #faf7f2; /* Soft cream panel */
  --panel-secondary: #ede7dd; /* Light sandstone */
  --muted: #78716c; /* Warm gray-brown */
  --text: #292524; /* Deep brown text */
  --text-muted: #57534e; /* Medium brown */
  --line: #d6d3d1; /* Light stone border */
  --border: #a8a29e; /* Warm gray border */
  --hover: rgba(217, 211, 206, 0.5); /* Soft hover */
  --btn: #f5f2ed; /* Light button background */
  --btn-hover: #e7e2db; /* Hover state */
  --accent: #0369a1; /* Deep sky blue */
  --accent-light: #0284c7; /* Mountain lake blue */
  --accent-dark: #075985; /* Deep mountain blue */
  --accent-shadow: rgba(3, 105, 161, 0.2);
  --success: #16a34a; /* Forest green */
  --warning: #ca8a04; /* Sunset gold */
  --error: #dc2626; /* Trail marker red */
  --info: #0891b2; /* Alpine blue */
  
  /* Typography */
  --font: "Inter", "SF Pro Display", "Segoe UI", "Roboto", system-ui, -apple-system, sans-serif;
  --font-mono: "SF Mono", "Monaco", "Cascadia Code", "Roboto Mono", monospace;
  --font-size-base: 16px;
  --font-size-small: 14px;
  --font-size-large: 18px;
  --line-height: 1.5;
  
  /* Shadows & Effects */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15);
  
  /* Layout */
  --leftbar-width: 80px;
  --border-radius: 8px;
  --border-radius-sm: 6px;
  --border-radius-lg: 12px;
}
*{box-sizing:border-box}
/* Global theme transition for smooth switching */
*{transition:background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1)}
html,body{height:100%}
body{margin:0;background:var(--bg);color:var(--text);font:var(--font-size-base)/var(--line-height) var(--font);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;transition:background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1), color 0.3s cubic-bezier(0.4, 0, 0.2, 1);overflow-x:hidden}

.hamburger{display:none;font-size:20px;line-height:1;padding:8px 10px;border:1px solid var(--line);background:var(--btn);color:var(--text);border-radius:10px}
#topbar .toolbar{display:flex;gap:14px;flex-wrap:wrap}
#topbar .group{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.lbl{font-size:var(--font-size-small);color:var(--muted);font-weight:500;letter-spacing:0.02em}
/* Clear, separated sidebar definitions for debugging */
#app{position:relative;height:100vh;margin-top:var(--tg-top-inset);background:transparent}
#map{position:absolute!important;top:0;left:0;right:0;bottom:0;width:100%!important;height:100%!important;z-index:1}

/* Left sidebar - locked to topbar bottom and window bottom */
#leftbar{
  position:fixed !important;
  top:var(--tg-topbar-h) !important; /* Match topbar height for consistent alignment */
  left:0 !important;
  bottom:0 !important; /* Locked to window bottom */
  border-right:1px solid var(--line) !important;
  z-index: 9998 !important; /* Below loading screen */
  display: none; /* Completely hidden during initial load */
  overflow:auto;
  /* resize:horizontal; REMOVED - prevents layout issues with toggle button positioning */
  min-width:320px !important;
  max-width:600px;
  width:600px !important;
  padding:12px;
  background: var(--panel) !important;
  color: var(--text) !important;
  display:block !important;
  z-index:50;
}

#leftbar:not(.collapsed){
  min-width:320px !important;
  max-width:600px;
  width:600px !important;
  padding:12px;
}

/* Right sidebar - connected to topbar */  
#rightbar{
  position:fixed !important;
  top:var(--tg-topbar-h) !important; /* Updated to match topbar height */
  right:0 !important;
  bottom:0 !important; /* Locked to window bottom */
  border-left:1px solid var(--line) !important;
  padding-bottom: 180px !important; /* Prevent content overlap with bottom logo */
  z-index: 9998 !important; /* Below loading screen */
  display: none; /* Completely hidden during initial load */
  overflow:auto;
  /* resize:horizontal; REMOVED - prevents layout issues and maintains consistent sidebar behavior */
  min-width:320px !important;
  max-width:600px;
  width:400px !important;
  padding:12px;
  background: var(--panel) !important;
  color: var(--text) !important;
  display:block !important;
  visibility:visible !important;
  z-index:9999 !important;
}

/* Position Leaflet controls relative to leftbar for collapse functionality */
.leaflet-top.leaflet-left { 
  margin-top: 64px !important;
  /* margin-left removed - basemap controls stay in default position */
}

button:hover{border-color:var(--accent)}
.togglebtn.active{outline:2px solid var(--accent)}
/* Old conflicting styles removed - using unified styles below */
input[type="text"]{min-width:220px}
#layersPanel .layer{display:flex;align-items:flex-start;justify-content:space-between;padding:8px;border:1px solid var(--line);border-radius:10px;margin-bottom:8px;background:var(--btn);gap:8px}
#layersPanel .meta{display:flex;flex-direction:column;min-width:0}
#layersPanel .actions{display:flex;flex-direction:column;gap:6px}
#layersPanel .actions-row{display:grid;grid-template-columns:repeat(3,42px);grid-auto-rows:42px;gap:6px}
#layersPanel .actions-row.export-row{grid-template-columns:repeat(4,42px)}
.iconbtn{width:42px;height:42px;display:inline-flex;align-items:center;justify-content:center;border-radius:10px;font-size:18px;background:var(--btn);padding:2px}
.iconbtn:hover{background:var(--accent)}
.toggle{appearance:none;width:42px;height:42px;border-radius:10px;background:var(--btn);position:relative;outline:none;cursor:pointer;padding:2px}
.toggle:checked{background:var(--accent)}
/* Eye icon removed - handled by layers panel specific styling */
.status{color:var(--muted);font-size:12px;min-height:16px;margin-top:6px}
.leaflet-container{background:var(--bg)}
#map{position:relative;overflow:hidden}
  #map{position:relative;overflow:hidden;width:100%;height:100%;background:var(--bg)}.leaflet-pane,.leaflet-control-container{position:relative;z-index:150}

/* Ensure all Leaflet controls appear above sidebars and popups */
.leaflet-control-container,
.leaflet-control-zoom,
.leaflet-control-layers,
.leaflet-control-attribution,
.leaflet-bar,
.leaflet-control {
  z-index: 100001 !important;
}

/* Make sure Leaflet controls are positioned above sidebars */
.leaflet-top.leaflet-left,
.leaflet-top.leaflet-right,
.leaflet-bottom.leaflet-left,
.leaflet-bottom.leaflet-right {
  z-index: 200 !important;
}

/* Force all Leaflet controls above everything */
.leaflet-control-container * {
  z-index: 200 !important;
}

/* Specifically target basemap controls */
.leaflet-control-layers,
.leaflet-control-layers-expanded {
  z-index: 200 !important;
  position: relative !important;
}

/* Converted Files Modal - Elegant and Classy Design */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.3s ease;
}

.modal-overlay.show {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

.modal-container {
  background: var(--panel);
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.3),
    0 8px 25px rgba(0, 0, 0, 0.2);
  max-width: 600px;
  width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s ease;
  overflow: hidden;
}

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, var(--panel) 0%, rgba(78, 161, 255, 0.03) 100%);
}

.modal-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-icon {
  font-size: 24px;
  filter: drop-shadow(0 2px 4px rgba(78, 161, 255, 0.3));
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--btn);
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: var(--accent);
  color: white;
  transform: scale(1.05);
}

.modal-body {
  flex: 1;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.converted-files-header {
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(78, 161, 255, 0.02);
}

.files-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

.separator {
  opacity: 0.5;
}

.btn-refresh {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--btn);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-refresh:hover {
  background: var(--accent);
  color: white;
  transform: rotate(180deg);
}

.refresh-icon {
  font-size: 16px;
  transition: transform 0.3s ease;
}

.converted-files-list {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  max-height: 400px;
}

.files-loading {
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--line);
  border-top: 2px solid var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.file-item {
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: background 0.2s ease;
  cursor: pointer;
}

.file-item:hover {
  background: rgba(78, 161, 255, 0.05);
}

.file-item:last-child {
  border-bottom: none;
}

.file-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent) 0%, #3b82f6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(78, 161, 255, 0.3);
}

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

.file-name {
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
  word-break: break-word;
}

.file-meta {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.file-size {
  font-weight: 500;
}

.file-date {
  opacity: 0.8;
}

.file-actions {
  display: flex;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.file-item:hover .file-actions {
  opacity: 1;
}

.file-action {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--btn);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.2s ease;
}

.file-action.load:hover {
  background: var(--accent);
  color: white;
}

.file-action.delete:hover {
  background: #ef4444;
  color: white;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(78, 161, 255, 0.02);
}

.footer-info {
  font-size: 12px;
  color: var(--muted);
}

.footer-info code {
  background: var(--btn);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.footer-actions {
  display: flex;
  gap: 12px;
}

.btn-secondary, .btn-danger {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid var(--line);
}

.btn-secondary {
  background: var(--btn);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--accent);
  color: white;
}

.btn-danger {
  background: #ef4444;
  color: white;
  border-color: #dc2626;
}

.btn-danger:hover {
  background: #dc2626;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.empty-state {
  padding: 60px 24px;
  text-align: center;
  color: var(--muted);
}

.empty-icon {
  font-size: 48px;
  opacity: 0.3;
  margin-bottom: 16px;
}

.empty-title {
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text);
}

.empty-description {
  font-size: 14px;
  line-height: 1.5;
}

/* Responsive design */
@media (max-width: 600px) {
  .modal-container {
    width: 95vw;
    max-height: 90vh;
  }
  
  .modal-header, .converted-files-header, .modal-footer {
    padding: 12px 16px;
  }
  
  .file-item {
    padding: 12px 16px;
  }
  
  .footer-actions {
    flex-direction: column;
    gap: 8px;
  }
}

#map.capturing #cornerLogo{opacity:0}
#cornerLogo{position:absolute;right:14px;bottom:58px;height:216px;opacity:.98;pointer-events:none;z-index:10000;display:block}

/* Mobile pop-out */
@media (max-width: 900px){
  .hamburger{display:inline-flex}
  #app{grid-template-columns:1fr;grid-template-rows:auto 1fr}
  body.sidebar-open #leftbar{transform:translateX(0);opacity:1}
  #topbar .toolbar .group{gap:6px}
  input[type="text"]{min-width:160px}
  #cornerLogo{height:162px;bottom:52px}
  #map::before{background-size:420px}
  #layersPanel .actions-row{grid-template-columns:repeat(3,38px)}
  #layersPanel .actions-row.export-row{grid-template-columns:repeat(3,38px)}
}

#topbar{display:flex;align-items:center;justify-content:center;gap:.75rem;flex-wrap:wrap}
@media (max-width:768px){#topbar{justify-content:center}}

/* Center top bar contents */
#topbar{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:.75rem;
  flex-wrap:wrap;
}
@media (max-width:768px){
  #topbar{ justify-content:center; }
}

/* TG brand box: top-left title + logo */
#tg-brand .tg-logo{width:28px;height:28px;display:block;object-fit:contain}
#tg-brand .tg-title{font-weight:700;letter-spacing:.2px;font-size:18px;line-height:1;color:var(--text);white-space:nowrap}

/* Nudge existing topbar so brand can sit left cleanly */
#topbar{padding-top:44px}

/* Make centered contents stay centered, brand at left */

/* Lower the left toolbar/drawer so it starts below the brand/topbar */
#sidebar, .sidebar, [data-role="sidebar"], [data-ui="sidebar"]{top:64px}

/* Ensure map controls don't overlap the brand too much */
.leaflet-top.leaflet-left{margin-top:64px}

/* Bottom-right logo positioning - REMOVED (consolidated below) */

/* Mobile: brand becomes a compact button; text hides, icon toggles drawer */
@media (max-width:768px){
  #tg-brand{top:6px;left:8px;padding:6px 8px;border-radius:12px}
  #tg-brand .tg-title{display:none}
  #tg-brand .tg-logo{width:32px;height:32px}
  #topbar{padding-top:52px}
  #sidebar, .sidebar, [data-role="sidebar"], [data-ui="sidebar"]{top:56px}
}

  #tg-brand{top:6px;left:8px;padding:6px 8px}
  #tg-brand .tg-title{display:none}
  #tg-brand .tg-logo{width:32px;height:32px}
  /* Bottom-right logo mobile positioning - REMOVED (consolidated below) */
}

/* --- Refined TG brand (top-left) --- */
#tg-brand{
  position:fixed;
  top:50%;
  left:14px;
  transform:translateY(-50%);
  z-index:1001;
  display:flex;
  align-items:center;
  gap:8px;
  padding:6px 12px;
  border-radius:12px;
  background:var(--panel);
  backdrop-filter:saturate(140%) blur(6px);
  -webkit-backdrop-filter:saturate(140%) blur(6px);
}
#tg-brand .tg-logo{
  width:32px;
  height:32px;
  display:block;
  object-fit:contain;
}
#tg-brand .tg-title{
  font-family:"Avenir Next","Avenir",system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  font-weight:700;
  font-size:20px;
  line-height:1.1;
  color:#fff;
  white-space:nowrap;
}

/* Adjust for mobile */
@media (max-width:768px){
  #tg-brand{
    top:8px;
    left:8px;
    transform:none;
    padding:8px;
    border-radius:50%;
  }
  #tg-brand .tg-title{display:none}
  #tg-brand .tg-logo{
    width:36px;
    height:36px;
  }
}
#sidebar,.sidebar,[data-role="sidebar"],[data-ui="sidebar"]{top:calc(var(--tg-top-inset,64px) + 28px)}
.leaflet-top.leaflet-left{margin-top:calc(var(--tg-top-inset,64px) + 28px)}
@media (max-width:768px){
  #sidebar,.sidebar,[data-role="sidebar"],[data-ui="sidebar"]{top:calc(var(--tg-top-inset,64px) + 32px)}
  .leaflet-top.leaflet-left{margin-top:calc(var(--tg-top-inset,64px) + 32px)}
}
/* === TG Mobile/Header overrides v2 (append-only) === */
:root{--tg-top-inset:64px}
#tg-brand-v2 .tg-title{
  font-family:"Avenir Next","Avenir",system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  font-weight:800; font-size:20px; line-height:1.1; color:#fff; white-space:nowrap
}

/* Push Leaflet controls and left sidebar below header */
.leaflet-top.leaflet-left{ margin-top:calc(var(--tg-top-inset) + 8px) }
#sidebar,.sidebar,[data-role="sidebar"],[data-ui="sidebar"]{ top:calc(var(--tg-top-inset) + 8px) }

/* Bottom-right logo positioning - REMOVED (consolidated below) */

@media (max-width:768px){
  :root{ --tg-top-inset:64px }
  #tg-brand-v2{ left:8px; top:8px; padding:8px 10px }
  #tg-brand-v2 .tg-title{ display:none }
  #tg-brand-v2 .tg-logo{ width:36px; height:36px }
  /* Bottom-right logo mobile positioning - REMOVED (consolidated below) */
}
/* === TG Explorer Theme (append-only) - DISABLED === */
/* Swap these hexes if you have exact values */
/* DISABLED: :root.theme-explorer{
  --tg-font-ui: "Avenir Next","Avenir",system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  --tg-font-display: "League Spartan", "Avenir Next", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Palette (adjust to taste) */
  --tg-navy: #1b2838;        /* Deep Terrain Navy */
  --tg-clay: #d18647;        /* Earth Clay */
  --tg-olive: #556648;       /* Olive Ridge */
  --tg-sand: #dfe6cf;        /* Sand Tan */
  --tg-ink: #e8ede6;         /* High-contrast ink on dark */
  --tg-bg: #0f1418;          /* App background (very dark) */
  --tg-panel: #121820;       /* Panels/drawers */
  --tg-panel-2: #0d131a;     /* Deeper panel */
  --tg-border: rgba(255,255,255,.08);
  --tg-muted: rgba(255,255,255,.6);

  --tg-radius: 14px;
  --tg-shadow: 0 6px 20px rgba(0,0,0,.35);
}

/* Prefer variable fonts locally if you add them later:
@font-face{
  font-family:"League Spartan";
  src:url("assets/fonts/LeagueSpartan-Variable.woff2") format("woff2-variations");
  font-weight:100 900; font-style:normal; font-display:swap;
}
*/


/* === Branding & layout final overrides (append-only) === */
#tg-brand, #tg-brand-v2 { display:none; visibility:hidden }
#cornerLogo{ display:none } /* retire the old in-map logo to prevent doubles */

/* Removed conflicting tg-brand-v3 definition */

/* Always push UI below computed header */
:root{ --tg-top-inset:64px }
#sidebar,.sidebar,[data-role="sidebar"],[data-ui="sidebar"]{ top:calc(var(--tg-top-inset) + 12px) }
.leaflet-top.leaflet-left{ margin-top:calc(var(--tg-top-inset) + 12px) }
/* === Basemap Emoji Picker (append-only) === */
#tg-basemap-picker .bm img{ width:100%; height:100%; display:block; object-fit:cover }
#tg-basemap-picker .bm span{ position:absolute; left:6px; right:6px; bottom:6px; font:800 11px/1.1 "Avenir Next","Avenir",system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif; color:#fff; text-shadow:0 1px 3px rgba(0,0,0,.8); letter-spacing:.2px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis }
#tg-basemap-picker .bm.active{ outline:2px solid #d18647; outline-offset:2px }
@media (max-width:768px){ #tg-basemap-picker{ left:8px; bottom:8px; gap:6px; padding:5px } #tg-basemap-picker .bm{ width:58px; height:58px; border-radius:12px } #tg-basemap-picker .bm span{ font-size:10px } }
/* --- Mobile brand chip (bottom center) --- */
#mobileBrandChip{
  position:fixed; left:50%; bottom:16px; transform:translateX(-50%);
  z-index:1100; padding:8px 14px; border-radius:14px;
  background:rgba(18,24,32,.78);
  -webkit-backdrop-filter:saturate(140%) blur(8px); backdrop-filter:saturate(140%) blur(8px);
  border:1px solid rgba(255,255,255,.10);
  font:800 14px/1 "Avenir Next","Avenir",system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  color:#fff; letter-spacing:.2px; display:none;
}
@media (max-width:768px){
  #mobileBrandChip{ display:block }
  /* Bottom-right logo mobile transform - REMOVED (consolidated below) */
}

/* Ensure left drawer clears header (explicit #leftbar) */

/* Slightly smaller top-left brand on small phones so it doesn't cover controls */
@media (max-width:480px){
  #tg-brand-v3{ left:8px; top:8px; padding:8px 12px; border-radius:12px; }
  #tg-brand-v3 .tg-title{ display:none }
  #tg-brand-v3 .tg-logo{ width:48px; height:48px; } /* Larger mobile size but smaller than desktop */
  #leftbar{ top:64px !important; bottom:0 !important; } /* Adjusted for mobile topbar height, locked to window bottom */
}
/* === Brand Consolidation: Only #tg-brand-v3 Visible === */
#cornerLogo, #tg-brand, #tg-brand-v2, #mobileBrandPill { 
  display:none !important; 
  visibility:hidden !important; 
}

/* Enhanced top-left brand with matching topbar gradient */
#tg-brand-v3{ 
  position:fixed;
  top:12px; /* Properly centered in 110px top bar */
  left:16px; /* Slightly more spacing */
  z-index:1001; 
  display:flex !important;
  align-items:center;
  gap:14px; /* Optimized spacing for alignment */
  padding:12px 18px; /* Reduced padding to fit within topbar height */
  border-radius:18px; /* Proportional to reduced padding */
  
  /* Match topbar gradient exactly */
  background: linear-gradient(to bottom, var(--panel), rgba(21, 25, 34, 0.6) 60%, transparent);
  backdrop-filter:saturate(140%) blur(6px);
  -webkit-backdrop-filter:saturate(140%) blur(6px);
  border: 1px solid var(--line);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}
#tg-brand-v3 .tg-logo{
  width:72px; /* Optimized size to fit within topbar height */
  height:72px; /* Optimized size to fit within topbar height */
  display:block;
  object-fit:contain;
  cursor:pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius:14px; /* Proportional border radius */
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
}
#tg-brand-v3 .tg-logo:hover{
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
}
#tg-brand-v3 .tg-logo.shell-active{
  animation: shellPulse 2s ease-in-out infinite;
  box-shadow: 0 0 25px rgba(59, 130, 246, 0.5);
}

@keyframes shellPulse {
  0%, 100% { 
    box-shadow: 0 0 25px rgba(59, 130, 246, 0.5);
    transform: scale(1);
  }
  50% { 
    box-shadow: 0 0 35px rgba(59, 130, 246, 0.7);
    transform: scale(1.02);
  }
}
#tg-brand-v3 .tg-title{
  font-family: "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: 600;
  font-size: 22px; /* Adjusted to match optimized logo size */
  line-height: 1.2;
  letter-spacing: 0.025em;
  white-space: nowrap;
  margin-left: 10px; /* Proportional margin */
  
  /* Theme-aware colors */
  color: var(--text);
  opacity: 0.95;
  
  /* Subtle text shadow for better readability */
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  
  /* Smooth color transition between themes */
  transition: color 0.2s ease, opacity 0.2s ease;
}

/* Theme-specific enhancements for brand title */
html[data-theme="dark"] #tg-brand-v3 .tg-title,
:root #tg-brand-v3 .tg-title {
  color: var(--text);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  font-weight: 600;
}

html[data-theme="light"] #tg-brand-v3 .tg-title {
  color: var(--text);
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
  font-weight: 600;
}

/* ===== PROFESSIONAL SHELL POP-OUT SYSTEM ===== */

/* Professional suite tools container - click to toggle */
.shell-popout-container {
  position: fixed;
  left: 380px; /* Adjusted for bigger brand container */
  top: 20px; /* Aligned with enhanced top bar height */
  transform: translateX(-20px) scale(0.9);
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 1002;
  perspective: 1000px;
}

/* Show when active */
.shell-popout-container.active {
  transform: translateX(0) scale(1);
  opacity: 1;
  visibility: visible;
}

/* Enhanced interaction effects */
.shell-popout-container:hover {
  transform: translateX(0) scale(1.02);
}

/* Enhanced always-visible suite tools container */
.shell-popout-options {
  display: flex;
  gap: 6px;
  background: linear-gradient(145deg, var(--panel), rgba(255, 255, 255, 0.02));
  padding: 16px; /* Increased padding for always-visible design */
  border-radius: 24px; /* Increased border radius to match bigger brand */
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 
    0 12px 32px rgba(0, 0, 0, 0.12),
    0 4px 12px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  min-width: 560px; /* Increased for always-visible professional appearance */
  position: relative;
}

/* Animated background highlight */
.shell-popout-options::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, 
    rgba(59, 130, 246, 0.05),
    rgba(16, 185, 129, 0.05),
    rgba(239, 68, 68, 0.05));
  border-radius: 20px;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.shell-popout-container:hover .shell-popout-options::before {
  opacity: 1;
}

/* Enhanced professional suite tool cards */
.shell-popout-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 20px; /* Increased padding for always-visible design */
  border-radius: 20px; /* Increased border radius */
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 2px solid transparent;
  flex: 1;
  text-align: center;
  position: relative;
  background: rgba(255, 255, 255, 0.03); /* Slightly more visible base */
  min-height: 160px; /* Increased height for bigger design */
  justify-content: center;
}

/* Stagger animation for options */
.shell-popout-option:nth-child(1) { animation-delay: 0.1s; }
.shell-popout-option:nth-child(2) { animation-delay: 0.15s; }
.shell-popout-option:nth-child(3) { animation-delay: 0.2s; }

/* Enhanced hover effects */
.shell-popout-option:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent);
  transform: translateY(-4px) scale(1.02);
  box-shadow: 
    0 12px 24px rgba(59, 130, 246, 0.15),
    0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Professional active state */
.shell-popout-option.active {
  background: linear-gradient(135deg, var(--accent), rgba(59, 130, 246, 0.8));
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 
    0 8px 32px rgba(59, 130, 246, 0.3),
    0 4px 16px rgba(59, 130, 246, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

/* Focus states for accessibility */
.shell-popout-option:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Enhanced large professional icons for always-visible suite */
.shell-icon-container {
  margin-bottom: 16px; /* Increased spacing */
  position: relative;
}

.shell-icon {
  width: 48px; /* Increased icon size */
  height: 48px; /* Increased icon size */
  stroke-width: 1.5;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.12)); /* Enhanced shadow */
}

.shell-popout-option:hover .shell-icon {
  transform: scale(1.1);
  stroke-width: 2;
}

.shell-popout-option.active .shell-icon {
  transform: scale(1.05);
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

/* Enhanced typography hierarchy for always-visible suite */
.shell-info {
  text-align: center;
  width: 100%;
}

.shell-name {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: 600;
  font-size: 16px; /* Increased for better visibility */
  line-height: 1.3;
  margin-bottom: 8px; /* Increased spacing */
  color: var(--text);
  letter-spacing: 0.025em;
}

.shell-popout-option.active .shell-name {
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.shell-desc {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 11px;
  font-weight: 400;
  opacity: 0.85;
  line-height: 1.4;
  color: var(--text-muted);
  white-space: normal;
  word-wrap: break-word;
  max-width: 110px;
  margin-bottom: 8px;
}

.shell-popout-option.active .shell-desc {
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Professional status indicators */
.shell-status {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 9px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 10px;
  background: rgba(156, 163, 175, 0.2);
  color: var(--text-muted);
  border: 1px solid rgba(156, 163, 175, 0.3);
  margin-top: 4px;
  display: inline-block;
}

.shell-status.active-indicator {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(22, 163, 74, 0.2));
  color: #22c55e;
  border-color: rgba(34, 197, 94, 0.4);
  animation: statusPulse 2s ease-in-out infinite;
}

.shell-popout-option.active .shell-status {
  background: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.9);
  border-color: rgba(255, 255, 255, 0.3);
}

/* Subtle status pulse animation */
@keyframes statusPulse {
  0%, 100% { 
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4);
  }
  50% { 
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.1);
  }
}

/* Enhanced responsive design for bigger layout */
@media (max-width: 1400px) {
  .shell-popout-container {
    left: 340px; /* Adjusted for medium screens */
  }
  
  .shell-popout-options {
    min-width: 480px;
    padding: 14px;
  }
  
  .shell-popout-option {
    padding: 20px 16px;
    min-height: 140px;
  }
  
  .shell-icon {
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 1200px) {
  #tg-brand-v3 {
    padding: 12px 16px; /* Reduced padding */
    gap: 14px;
  }
  
  #tg-brand-v3 .tg-logo {
    width: 76px; /* Slightly smaller */
    height: 76px;
  }
  
  #tg-brand-v3 .tg-title {
    font-size: 22px; /* Slightly smaller */
  }
  
  .shell-popout-container {
    left: 320px;
  }
  
  .shell-popout-options {
    min-width: 440px;
    padding: 12px;
  }
  
  .shell-popout-option {
    padding: 18px 14px;
    min-height: 130px;
  }
  
  .shell-icon {
    width: 40px;
    height: 40px;
  }
}

@media (max-width: 768px) {
  :root {
    --tg-topbar-h: 80px; /* Reduced for mobile */
    --tg-top-inset: 64px;
  }
  
  #tg-brand-v3 {
    top: 8px;
    left: 8px;
    padding: 8px 12px;
    gap: 8px;
  }
  
  #tg-brand-v3 .tg-logo {
    width: 48px;
    height: 48px;
  }
  
  #tg-brand-v3 .tg-title {
    display: none; /* Hide title on mobile */
  }
  
  .shell-popout-container {
    display: none; /* Hide suite tools on mobile */
  }
}

/* Theme CSS removed - replaced with Shell Pop-Out System */

/* Shell Selector Styling */
#tg-brand-v3 .shell-selector {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 100002;
}

#tg-brand-v3 .shell-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: shellDropdownIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100003;
}

@keyframes shellDropdownIn {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Enhanced Search Container */
.search-container {
  position: relative;
  min-width: 280px;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.3s ease;
}

.search-input-wrapper:focus-within {
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-container #searchBox {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 12px;
  font-size: 14px;
  min-width: 0;
  outline: none;
}

.search-container #searchBox::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.search-btn, .clear-btn {
  background: none;
  border: none;
  padding: 8px 10px;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.2s ease;
  border-radius: 6px;
  margin: 2px;
}

.search-btn:hover, .clear-btn:hover {
  background: var(--accent);
  color: var(--text);
}

.search-icon, .clear-icon {
  font-size: 14px;
  display: block;
}

/* Search Suggestions Dropdown */
.search-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  max-height: 320px;
  overflow-y: auto;
  z-index: 1020;
  margin-top: 4px;
  animation: searchDropdownIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes searchDropdownIn {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.search-suggestion {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background-color 0.2s ease;
}

.search-suggestion:last-child {
  border-bottom: none;
}

.search-suggestion:hover,
.search-suggestion.highlighted {
  background: var(--accent);
}

.suggestion-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  margin-top: 2px;
  opacity: 0.7;
}

.suggestion-content {
  flex: 1;
  min-width: 0;
}

.suggestion-title {
  font-weight: 500;
  color: var(--text);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.suggestion-subtitle {
  font-size: 12px;
  color: var(--muted);
  opacity: 0.8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.suggestion-type {
  font-size: 10px;
  padding: 2px 6px;
  background: var(--border);
  color: var(--muted);
  border-radius: 4px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* Search History */
.search-history-header {
  padding: 8px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.05);
}

/* Loading state */
.search-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  color: var(--muted);
  font-size: 14px;
}

.search-loading::before {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top: 2px solid var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-right: 8px;
}

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

#tg-brand-v3 .shell-dropdown {
  min-width: 200px;
}

#tg-brand-v3 .shell-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.2s;
  border-bottom: 1px solid var(--border);
}

#tg-brand-v3 .shell-option:last-child {
  border-bottom: none;
}

#tg-brand-v3 .shell-option:hover {
  background: var(--hover);
}

#tg-brand-v3 .shell-option.active {
  background: var(--accent);
  color: #fff;
}

#tg-brand-v3 .option-icon {
  font-size: 18px;
  flex-shrink: 0;
}

#tg-brand-v3 .option-info {
  flex: 1;
}

#tg-brand-v3 .option-name {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
}

#tg-brand-v3 .option-desc {
  font-size: 12px;
  opacity: 0.8;
  line-height: 1.2;
  margin-top: 2px;
}

/* Bottom-right logo positioning - REMOVED (consolidated below) */


/* Mobile positioning - REMOVED (consolidated below) */
}

/* Ensure sidebar/controls always start below header */
:root{ --tg-top-inset:64px }
#sidebar,.sidebar,[data-role="sidebar"],[data-ui="sidebar"]{ top:calc(var(--tg-top-inset) + 12px) }
.leaflet-top.leaflet-left{ margin-top:calc(var(--tg-top-inset) + 12px) }
/* Mobile name pill (robot • name • shield) */
#mobileBrandPill{
  position:fixed; left:50%; bottom:16px; transform:translateX(-50%);
  display:none; align-items:center; gap:10px;
  padding:10px 14px; border-radius:999px;
  background:rgba(18,24,32,.85);
  -webkit-backdrop-filter:saturate(140%) blur(8px); backdrop-filter:saturate(140%) blur(8px);
  border:1px solid rgba(255,255,255,.12);
  color:#fff; z-index:1201;
  box-shadow:0 6px 18px rgba(0,0,0,.35);
}
#mobileBrandPill .title{
  font-family:"Avenir Next","Avenir",system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  font-weight:800; letter-spacing:.2px; font-size:18px; line-height:1;
}
#mobileBrandPill img.left,
#mobileBrandPill img.right{
  width:26px; height:26px; object-fit:contain; display:block;
  filter:grayscale(1) saturate(0) brightness(1.05);
}

/* Show pill on mobile, hide the standalone bottom-right badge there */
@media (max-width:768px){
  #mobileBrandPill{ display:flex; }
  /* Bottom-right logo mobile display - REMOVED (consolidated below) */
}


/* Layers flyout */
@media (max-width:768px){
}


#tg-basemap-picker{display:none; visibility:hidden}
@media (max-width:768px){
}


@media (max-width:768px){
  #tg-brand-v3{ display:none; visibility:hidden }
  
  /* Hide shell selector on mobile since brand is hidden */
  #tg-brand-v3 .shell-selector { display: none; }
}
/* Desktop scaling - REMOVED (consolidated below) */


/* === Leftbar lock under topbar (final overrides) === */
:root{ --tg-top-inset: var(--tg-top-inset,90px) } /* Updated to align with topbar height */
#app{ margin-top: var(--tg-top-inset) }
/* Leftbar connects to topbar with minimal gap - original behavior restored */
/* Mobile-first responsive design for Terragraph Clips */
@media (max-width: 900px) {
  /* Mobile sidebar styling temporarily disabled - using desktop layout */
  /*
  #leftbar, #rightbar {
    position: fixed;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 8000;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
  }
  */
  
  /* Mobile sidebar positioning temporarily disabled */
  /*
  #leftbar {
    left: 8px;
    right: 50%;
    bottom: 0;
    height: 60vh;
    max-height: 500px;
    margin-right: 4px;
    border-right: 1px solid var(--line);
  }
  
  #rightbar {
    left: 50%;
    right: 8px;
    bottom: 0;
    height: 60vh;
    max-height: 500px;
    margin-left: 4px;
    border-left: 1px solid var(--line);
  }
  */
  
  /* Mobile show/hide rules temporarily disabled */
  /*
  body.sidebar-open #leftbar:not(.collapsed) {
    transform: translateY(0);
  }
  
  body.inspector-open #rightbar:not(.collapsed) {
    transform: translateY(0);
  }
  
  #leftbar.collapsed,
  #rightbar.collapsed {
    height: 50px;
    transform: translateY(0);
    border-radius: 8px;
  }
  */
  
  /* Adjust map area to not conflict with mobile controls */
  #map {
    top: calc(var(--tg-top-inset) + 8px);
    bottom: 60px; /* Space for mobile controls */
  }
}
.leaflet-top.leaflet-left{ margin-top: calc(var(--tg-top-inset) + 12px) }


/* === UNIFIED BOTTOM RIGHT LOGO POSITIONING === */
#bottomRightLogo {
  position: fixed;
  bottom: 20px; /* Increased bottom padding */
  z-index: 10000; /* Above all UI layers */
  display: block;
  opacity: 0.96;
  pointer-events: none;
  max-width: 156px; /* 25% bigger than 125px */
  max-height: 156px; /* 25% bigger than 125px */
  transition: right 0.3s ease;
  
  /* Position to account for collapsed right sidebar (80px) + padding (12px) */
  right: calc(80px + 12px);
}

/* Mobile adjustments */
@media (max-width:768px) {
  #mobileBrandPill img { display: none; }
  #bottomRightLogo {
    max-width: 125px; /* 25% bigger than 100px */
    max-height: 125px; /* 25% bigger than 100px */
    right: calc(80px + 8px); /* Smaller padding on mobile */
    bottom: 18px; /* Increased bottom padding on mobile */
  }
}

/* Ensure logo is always visible on small screens */
@media (max-width:480px) {
  #bottomRightLogo { 
    display: block;
    right: calc(80px + 6px); /* Even smaller padding on very small screens */
  }
}
.section-title{font-weight:bold}
#map{position:relative;overflow:hidden;width:100%;height:100%;background:var(--bg)}



  /* Keep section bubbles with enhanced styling */
  .section {
    margin-bottom: 20px;
    padding: 16px;
    background: var(--panel);
    border-radius: 12px;
    border: 1px solid var(--line);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }

  /* Section titles */
  .section-title {
    font-weight: 800;
    font-size: 14px;
    letter-spacing: 0.3px;
    margin-bottom: 12px;
    color: var(--text);
    text-transform: uppercase;
  }
  

  /* === Unified Topbar with Dark Mode Gradient === */
  #topbar {
    background: linear-gradient(to bottom, 
      rgba(var(--bg-rgb), 0.98) 0%, 
      rgba(var(--bg-rgb), 0.85) 30%, 
      rgba(var(--bg-rgb), 0.65) 60%, 
      rgba(var(--bg-rgb), 0.3) 80%,
      transparent 100%);
    backdrop-filter: saturate(120%) blur(10px);
    -webkit-backdrop-filter: saturate(120%) blur(10px);
    border-bottom: none;
  }
  

  

  }

  #app {
    grid-template-columns: 380px 1fr;
    gap: 0 !important;
  }
  


  /* === Fixed Topbar with Theme Support === */
  #topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 8px 12px;
    background: linear-gradient(to bottom, rgba(20, 27, 36, .95), rgba(20, 27, 36, .65) 60%, transparent);
    backdrop-filter: saturate(140%) blur(6px);
    -webkit-backdrop-filter: saturate(140%) blur(6px);
    border-bottom: 1px solid var(--line);
  }

.leaflet-container,
#map{
  background: var(--bg) !important;
}
#topbar,
#leftbar,
#sidebar,
.sidebar,
[data-role="sidebar"],
[data-ui="sidebar"]{
  background: var(--panel);
  color: var(--text);
  border-color: var(--line);
}
button,
.btn,
.iconbtn,
.toggle{
  background: var(--btn);
  color: var(--text);
  border-color: var(--line);
}
.lbl,
.status{ color: var(--muted); }
select,
input[type="text"],
input[type="search"],
input[type="number"],
input[type="range"]{
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}

/* === THEME SYSTEM WITH ZERO LAYOUT SHIFT ============ */
.theme{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:64px;
  width:64px; /* Fixed width prevents reflow */
  height:var(--tg-btn-h);
  padding:0;
  box-sizing:border-box;
  border:var(--tg-btn-bw) solid transparent;
  border-radius:var(--tg-radius);
  background:var(--btn);
  color:var(--text);
  font-weight:600;
  font-size:12px;
  cursor:pointer;
  transition:background .15s ease, color .15s ease, border-color .15s ease;
  flex-shrink:0; /* Prevent flex compression */
}
.theme.is-active,
.theme:focus{
  border-color:var(--accent);
  outline:none;
}
.theme:hover{
  background:var(--accent);
  color:var(--bg);
}

/* === UI FIX PASS (final overrides) ======================================= */

/* === Header Clearance System (aligned with branding bubble) === */
:root{ 
  --tg-topbar-h: 110px; /* Enhanced to accommodate bigger logo and always-visible suite tools */
  --tg-top-inset: 84px; /* Increased to match new topbar height */
  --leftbar-width: 540px;
}
#topbar{
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 900;
  height: var(--tg-topbar-h); /* Fixed height, not min-height */
  padding: 10px 14px;
  line-height: 1;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(to bottom, var(--panel), rgba(21, 25, 34, 0.6) 60%, transparent);
  backdrop-filter: saturate(140%) blur(6px);
  -webkit-backdrop-filter: saturate(140%) blur(6px);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
}
#app{ 
  margin-top: var(--tg-topbar-h); 
}
.leaflet-top.leaflet-left{ 
  margin-top: calc(var(--tg-topbar-h) + 12px); 
}
#sidebar,.sidebar,[data-role="sidebar"],[data-ui="sidebar"]{ 
  top: calc(var(--tg-topbar-h) + 12px); 
}

/* 3) Uniform button sizing across themes + no size jump on active/focus */
:root{
  --tg-btn-h: 32px;
  --tg-btn-px: 12px;
  --tg-btn-bw: 2px;     /* reserve border so active state doesn't grow */
  --tg-radius: 10px;
}
button,.btn,.togglebtn{
  display:inline-flex;
  align-items:center; justify-content:center;
  height: var(--tg-btn-h);
  padding: 0 var(--tg-btn-px);
  box-sizing: border-box;
  font-weight:600; font-size:12px;
  border: var(--tg-btn-bw) solid transparent;
  border-radius: var(--tg-radius);
  background: var(--btn);
  color: var(--text);
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

/* Ensure theme buttons also follow 32px rhythm */
.theme{
  height: var(--tg-btn-h);
  border: var(--tg-btn-bw) solid transparent;
}
button.is-active,
.btn.is-active,
button:focus{
  border-color: var(--accent);
  outline: none;
}
button:hover,.btn:hover{ background: var(--accent); color: var(--bg); }

/* Keep icon buttons square but with same border model */
.iconbtn{
  width:38px; height:38px;
  border: var(--tg-btn-bw) solid transparent;
  box-sizing: border-box;
}

/* 4) Left sidebar button alignment (tight, consistent gaps) */
#leftbar .section .actions,
#leftbar .section .btnrow,
#leftbar .section{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
#leftbar .section{ align-items: flex-start; }

/* 5) Opacity slider layout & full-width alignment */
#leftbar input[type="range"]{
  width:100%;
  margin: 0;                 /* remove browser default offsets */
  height: 26px;              /* consistent track area */
  background: transparent;
}
#leftbar .range-row,
#leftbar .opacity-row{
  display:grid;
  grid-template-columns: 28px 1fr 40px;  /* "0%" | slider | "100%" or value */
  align-items:center;
  gap:8px;
}
#leftbar .range-min{ justify-self:start; color: var(--muted); font-size:12px; }
#leftbar .range-max{ justify-self:end;   color: var(--muted); font-size:12px; }

/* Fixed opacity slider - perfect alignment and sync across themes */
input[type="range"]{
  -webkit-appearance: none;
  appearance: none;
  height: 20px;
  background: transparent;
  border: none;
  outline: none;
  margin: 0;
  cursor: pointer;
}

/* WebKit track */
input[type="range"]::-webkit-slider-runnable-track{
  height: 4px;
  background: 
    linear-gradient(to right, var(--accent) 0%, var(--accent) var(--val, 100%)) 0 0 / var(--val, 100%) 100% no-repeat,
    var(--line);
  border-radius: 2px;
  border: none;
}

/* WebKit thumb */
input[type="range"]::-webkit-slider-thumb{
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  background: var(--accent);
  border: 2px solid var(--bg);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Firefox track */
input[type="range"]::-moz-range-track{
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  border: none;
}

/* Firefox progress (fill) */
input[type="range"]::-moz-range-progress{
  height: 4px;
  background: var(--accent);
  border-radius: 2px;
  border: none;
}

/* Firefox thumb */
input[type="range"]::-moz-range-thumb{
  width: 16px;
  height: 16px;
  background: var(--accent);
  border: 2px solid var(--bg);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Slightly larger state/county controls and full-width layout */
#stateMaskSelect, #stateSelect, #countySelect{ width:100%; min-height:180px }


/* 7) Prevent layout jitter from outlines anywhere */
*:focus{ outline: none; }

/* ======================================================================= */
/* === Leftbar layout & control sizing — final overrides ==================== */
/* 1) The section itself should not be flex; rows handle layout */
#leftbar:not(.collapsed) .section{ display:block !important; }

/* 2) Each row is flex with consistent gap and alignment */
#leftbar .section .row{
  display:flex; flex-wrap:wrap; align-items:center; gap:8px;
}
#leftbar .section .row + .row{ margin-top:8px; }
#leftbar .section .status{ margin-top:8px; }

/* Subsection styling for better organization */
.subsection {
  margin-bottom: 12px;
}

.subsection-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* 3) Unify control heights so theme switch never changes size */
:root{ --tg-btn-h: 32px; --tg-btn-px:12px; --tg-btn-bw:2px; }
button, .btn, .togglebtn{
  height: var(--tg-btn-h); padding:0 var(--tg-btn-px);
  border: var(--tg-btn-bw) solid transparent; line-height:1 !important;
}
button.small, .btn.small{
  height: var(--tg-btn-h); padding:0 10px; font-size:12px; line-height:1 !important;
}

/* 4) Inputs/selects align with buttons - uniform 32px height with better contrast */
select,
input[type="text"],
input[type="search"],
input[type="number"],
input[type="file"]{
  height: var(--tg-btn-h); 
  padding: 0 10px; 
  line-height: var(--tg-btn-h);
  border: 1px solid var(--line); 
  border-radius: var(--tg-radius); 
  background: var(--btn); /* Use button background for better contrast */
  color: var(--text);
  box-sizing: border-box;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  transition: background .15s ease, border-color .15s ease;
}

select:focus,
input:focus{
  border-color: var(--accent);
  outline: none;
  background: var(--panel); /* Slightly different background on focus */
}

/* Enhanced dropdown styling with better contrast */
select{
  cursor: pointer;
  background-color: var(--btn);
  border: 1px solid var(--line);
  appearance: auto; /* Use browser's native dropdown arrow */
}

select:hover{
  background-color: var(--panel);
  border-color: var(--accent);
}

select:focus{
  background-color: var(--panel);
  border-color: var(--accent);
}

/* Multi-select dropdowns get special treatment */
select[multiple]{
  background-image: none;
  background-color: var(--btn);
  padding-right: 10px;
  min-height: 120px;
  border: 1px solid var(--line);
}

select[multiple]:hover{
  background-color: var(--panel);
  border-color: var(--accent);
}

select[multiple]:focus{
  background-color: var(--panel);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-shadow);
}

/* 5) Range slider: keep previous visual fill, but align vertically */
input[type="range"]{
  height: 6px; margin: 0;
  background:
    linear-gradient(var(--accent), var(--accent)) 0/ var(--val,0%) 100% no-repeat,
    var(--line);
  border-radius:999px;
}
input[type="range"]::-webkit-slider-thumb{
  width:16px; height:16px; margin-top:-5px; border-radius:50%;
  background:var(--accent); border:2px solid var(--panel); -webkit-appearance:none; appearance:none;
}
input[type="range"]::-moz-range-track{ height:6px; background:transparent; }
input[type="range"]::-moz-range-progress{ height:6px; background:var(--accent); border-radius:999px; }
input[type="range"]::-moz-range-thumb{
  width:16px; height:16px; border-radius:50%;
  background:var(--accent); border:2px solid var(--panel);
}
/* ======================================================================== */
/* REST layer select box sizing */
#restLayerSelect {
  min-height: 140px !important;
  width: 100% !important;
  font-size: 13px;
  line-height: 1.4;
}

#restLayerSelect option {
  padding: 6px 8px;
  white-space: normal;
  word-wrap: break-word;
}

/* Layer style controls */
.style-controls {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.style-controls label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.style-select {
  padding: 4px 8px !important;
  font-size: 12px !important;
  min-width: 120px;
  background: var(--panel);
  border: 1px solid var(--line);
}

/* Loading Overlay */
#loadingOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(3px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#loadingOverlay.show {
  display: flex;
  opacity: 1;
}

.loading-content {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 60px 50px;
  text-align: center;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
  min-width: 500px;
  max-width: 650px;
}

.loading-logo {
  width: 400px !important;
  height: 400px !important;
  margin: 0 auto 30px;
  opacity: 0.8;
  animation: pulse 2s ease-in-out infinite alternate;
}

.loading-text {
  color: var(--text);
  font-size: 22px;
  font-weight: 500;
  margin-bottom: 12px;
}

.loading-status {
  color: var(--muted);
  font-size: 16px;
  min-height: 24px;
  margin-bottom: 18px;
}

.loading-progress {
  width: 100%;
  height: 12px;
  background: var(--line);
  border-radius: 6px;
  overflow: hidden;
  margin: 20px 0;
  position: relative;
}

.loading-percentage {
  position: absolute;
  top: -20px;
  right: 0;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.loading-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light, #60a5fa));
  border-radius: 6px;
  transition: width 0.4s ease-out;
  width: 0%;
  position: relative;
  overflow: hidden;
}

.loading-progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, 
    transparent, 
    rgba(255,255,255,0.3), 
    transparent
  );
  animation: shimmer 2s ease-in-out infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.loading-actions {
  margin-top: 20px;
  display: flex;
  justify-content: center;
  gap: 12px;
}

.loading-cancel-btn {
  background: var(--btn);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 100px;
  justify-content: center;
}

.loading-cancel-btn:hover {
  background: #dc2626;
  border-color: #dc2626;
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.loading-cancel-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.2);
}

.cancel-icon {
  font-size: 16px;
  font-weight: bold;
  line-height: 1;
}

.loading-progress.indeterminate .loading-progress-bar {
  width: 40%;
  animation: indeterminate 2s ease-in-out infinite;
}

@keyframes indeterminate {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(0%); }
  100% { transform: translateX(100%); }
}

@keyframes pulse {
  0% { opacity: 0.4; transform: scale(0.95); }
  100% { opacity: 0.9; transform: scale(1.05); }
}

/* ===== COLLAPSIBLE SIDEBARS ===== */

/* Sidebar toggle buttons */
.sidebar-toggle {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 64px;
  border: 2px solid var(--accent);
  background: var(--accent);
  color: var(--bg);
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  z-index: 200;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.sidebar-toggle.left {
  left: 80px; /* Start at collapsed position - updated by JS */
  border-radius: 0 8px 8px 0;
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
}

.sidebar-toggle.right {
  right: 80px !important; /* Force collapsed position initially */
  border-radius: 8px 0 0 8px;
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  transition: right 0.3s ease; /* Smooth transition when JS updates */
}

.sidebar-toggle:hover {
  background: var(--accent);
  color: var(--bg);
}

/* Sidebar collapse functionality temporarily removed - only tool collapse remains */


/* ===== POP-OUT / DOCKABLE TOOLS ===== */

/* Pop-out buttons in section headers */
.pop-out-btn {
  float: right;
  width: 20px;
  height: 20px;
  padding: 0;
  margin-left: 8px;
  border: 1px solid var(--line);
  background: var(--btn);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.pop-out-btn:hover {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

/* Floating window container */
#floatingWindows {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 500;
}

/* Individual floating window */
.floating-window {
  position: absolute;
  min-width: 280px;
  max-width: 600px;
  min-height: 200px;
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  pointer-events: auto;
  z-index: 501;
  transition: transform 0.15s ease;
  resize: both;
  overflow: auto;
}

.floating-window.dragging {
  transform: scale(1.02);
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
}

/* Floating window header */
.floating-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--accent);
  color: var(--bg);
  font-size: 12px;
  font-weight: 600;
  cursor: move;
  user-select: none;
  border-radius: 6px 6px 0 0;
}

.floating-header .title {
  flex: 1;
}

.floating-header .controls {
  display: flex;
  gap: 4px;
}

.floating-header button {
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  background: rgba(255,255,255,0.2);
  color: var(--bg);
  font-size: 10px;
  cursor: pointer;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.floating-header button:hover {
  background: rgba(255,255,255,0.3);
}

/* Floating window content */
.floating-content {
  padding: 12px;
  height: calc(100% - 50px); /* Fill window minus header */
  overflow-y: auto;
}

.floating-content .section {
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
}

.floating-content .section-title {
  display: none; /* Hide duplicate title in floating window */
}

/* Hidden state for popped-out sections */
.section.popped-out {
  display: none;
}

/* Hidden state for popped-out inspector - temporarily disabled */
#rightbar.popped-out {
  transform: translateX(100%);
}

/* Right sidebar collapse functionality */
#rightbar.collapsed {
  width: 80px !important;
  min-width: 80px !important;
  max-width: 80px !important;
  overflow: hidden;
  transition: width 0.3s ease;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#rightbar.collapsed .tab-content,
#rightbar.collapsed .tab-btn,
#rightbar.collapsed .inspector-content,
#rightbar.collapsed .inspector-title,
#rightbar.collapsed .pop-out-btn {
  display: none;
}

/* Show inspector as icon when collapsed */
#rightbar.collapsed .inspector-header {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  padding: 0;
  margin: 0 auto 8px auto;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: var(--btn);
  border: 2px solid var(--line);
  transition: all 0.3s ease;
  box-sizing: border-box;
  cursor: pointer;
}

#rightbar.collapsed .inspector-header:hover {
  background: var(--accent);
  border-color: var(--accent);
  transform: translateX(-4px) scale(1.05);
  box-shadow: -4px 4px 16px var(--accent-shadow);
}

#rightbar.collapsed .inspector-header::before {
  content: '🔍';
  font-size: 26px;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1;
  margin: 0;
  padding: 0;
}

/* Tooltip for collapsed inspector */
#rightbar.collapsed .inspector-header {
  position: relative;
}

#rightbar.collapsed .inspector-header::after {
  content: 'Inspector';
  position: absolute;
  right: 80px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--panel);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: var(--font-size-small);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, right 0.2s;
  z-index: 1000;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#rightbar.collapsed .inspector-header:hover::after {
  opacity: 1;
  right: 84px;
}

/* Special styling for inspector floating window */
.floating-window.inspector-window {
  min-width: 400px;
  max-width: 600px;
  min-height: 300px;
  width: 450px;
  height: 500px;
}

.floating-window.inspector-window .floating-content {
  padding: 0;
  height: calc(100% - 40px); /* Account for header */
  overflow-y: auto;
}

.floating-window.inspector-window .inspector-header {
  display: none; /* Hide duplicate header in floating window */
}

.floating-window.inspector-window .data-table {
  max-height: 300px;
}

/* ===== DOCKABLE INSPECTOR (RIGHT RAIL) ===== */

/* Inspector header */
.inspector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.inspector-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* Inspector tabs */
.inspector-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}

.tab-btn {
  flex: 1;
  height: 32px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  color: var(--text);
  background: var(--btn);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: transparent;
}

/* Tab content */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Inspector content */
.inspector-content {
  max-height: calc(100vh - 400px); /* Use available space minus logo area */
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: var(--btn);
  font-size: 12px;
  color: var(--text);
}

.inspector-status {
  font-size: 12px;
  color: var(--muted);
  padding: 8px;
  text-align: center;
  font-style: italic;
}

/* Style controls */
.style-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.style-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.style-group label.lbl {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}

.style-group input[type="color"] {
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--btn);
  cursor: pointer;
}

.style-group input[type="range"] {
  margin: 0;
}

.style-group span {
  font-size: 11px;
  color: var(--text);
  font-weight: 500;
  align-self: flex-end;
}

/* Data table */
.data-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.data-table {
  max-height: 500px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--btn);
}

.data-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.data-table th {
  background: var(--panel);
  color: var(--text);
  padding: 8px 6px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  position: sticky;
  top: 0;
}

.data-table td {
  padding: 6px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  word-break: break-word;
  max-width: 150px;
}

.data-table tr:hover {
  background: var(--panel);
}

/* Mobile UI enhancements - enhanced bottom drawer system */
@media (max-width: 900px) {
  /* Improved hamburger menu styling */
  .hamburger {
    position: fixed;
    top: calc(var(--tg-top-inset) + 12px);
    right: 12px;
    z-index: 9000;
    background: var(--panel);
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 18px;
    color: var(--accent);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  }
  
  .hamburger:hover {
    background: var(--accent);
    color: var(--panel);
    transform: scale(1.05);
  }
  
  /* Mobile toggle buttons for drawers */
  .mobile-drawer-toggles {
    position: fixed;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 9000;
  }
  
  .mobile-toggle-btn {
    background: var(--panel);
    border: 1px solid var(--accent);
    border-radius: 20px;
    padding: 8px 16px;
    color: var(--accent);
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
  }
  
  .mobile-toggle-btn:hover,
  .mobile-toggle-btn.active {
    background: var(--accent);
    color: var(--panel);
    transform: translateY(-2px);
  }
  
  /* Show mobile drawer toggles only on mobile */
  .mobile-drawer-toggles {
    display: flex !important;
  }
  
  /* Hide hamburger when using drawer system */
  .hamburger {
    display: none !important;
  }
  
  /* Adjust topbar for mobile */
  #topbar {
    padding: 8px 16px;
  }
  
  #topbar .toolbar {
    gap: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
  }
  
  #topbar .group {
    gap: 4px;
    min-width: fit-content;
  }
}
  
  .inspector-tabs {
    gap: 0;
  }
  
  .tab-btn {
    font-size: 11px;
    padding: 0 4px;
  }
  
  /* Mobile sidebar toggle adjustments */
  .sidebar-toggle {
    width: 24px;
    height: 50px;
    font-size: 14px;
  }
  
  .sidebar-toggle.left {
    top: 50%;
    transform: translateY(-50%);
    /* Left position will be set by JavaScript */
  }
  
  .sidebar-toggle.right {
    /* Keep normal right positioning on mobile too */
    right: 400px;
    top: 50%;
    left: auto;
    transform: translateY(-50%);
  }
}

/* Professional AOI/Drawing Tool Styling */
.leaflet-draw-toolbar {
  background: var(--panel) !important;
  border: 1px solid var(--line) !important;
  border-radius: 10px !important;
  padding: 4px !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2) !important;
}

.leaflet-draw-toolbar a {
  background: var(--btn) !important;
  border: 1px solid var(--line) !important;
  border-radius: 6px !important;
  margin: 0 2px !important;
  color: var(--text) !important;
  transition: all 0.2s ease !important;
}

.leaflet-draw-toolbar a:hover {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: white !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 2px 8px var(--accent-shadow) !important;
}

.leaflet-draw-toolbar a.leaflet-disabled {
  background: var(--btn) !important;
  opacity: 0.4 !important;
  border-color: var(--line) !important;
  color: var(--muted) !important;
}

/* Professional drawing guide styling */
.leaflet-draw-guide-dash {
  stroke: #2563eb !important;
  stroke-width: 2 !important;
  stroke-dasharray: 5,5 !important;
  stroke-opacity: 0.6 !important;
}

/* Professional tooltip styling */
.leaflet-draw-tooltip {
  background: var(--panel) !important;
  border: 1px solid var(--line) !important;
  border-radius: 8px !important;
  color: var(--text) !important;
  font-size: 12px !important;
  padding: 8px 12px !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2) !important;
}

.leaflet-draw-tooltip:before {
  border-top-color: var(--line) !important;
}

.leaflet-draw-tooltip:after {
  border-top-color: var(--panel) !important;
}

/* Professional vertex markers */
.leaflet-editing-icon {
  background: var(--accent) !important;
  border: 1px solid white !important;
  border-radius: 50% !important;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4) !important;
  transition: all 0.1s ease !important;
}

/* Enhanced precision for high magnification */
.leaflet-editing-icon:hover {
  transform: scale(1.5) !important;
  border-width: 2px !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5) !important;
}

/* QGIS-like ultra-precision vertex styling */
.leaflet-precision-vertex {
  background: #ff4444 !important;
  border: 1px solid white !important;
  border-radius: 50% !important;
  box-shadow: 0 0 3px rgba(0,0,0,0.8) !important;
  opacity: 0.9 !important;
}

.leaflet-precision-vertex:hover {
  background: #ff6666 !important;
  transform: scale(2) !important;
  border-width: 2px !important;
  opacity: 1 !important;
}

/* Ultra-precise touch icons */
.leaflet-precision-touch {
  background: rgba(59, 130, 246, 0.8) !important;
  border: 1px solid rgba(255, 255, 255, 0.9) !important;
  border-radius: 50% !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.6) !important;
}

.leaflet-precision-touch:hover {
  transform: scale(1.8) !important;
  background: rgba(59, 130, 246, 1) !important;
}

/* Precision crosshair cursor for drawing tools */
.leaflet-draw-container,
.leaflet-container.leaflet-draw-crosshair {
  cursor: crosshair !important;
}

/* Finer guide lines for precision drawing */
.leaflet-draw-guide-dash {
  background-color: rgba(59, 130, 246, 0.6) !important;
  width: 1px !important;
  height: 1px !important;
}

/* Professional measurement display styling */
.leaflet-draw-tooltip-single {
  background: rgba(37, 99, 235, 0.9) !important;
  color: white !important;
  font-weight: 500 !important;
}

/* Enhanced measurement results styling */
.measurement-result {
  background: var(--btn);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-top: 8px;
  font-size: 12px;
}

.measurement-label {
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 4px;
}

.measurement-value {
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
}

.btn-save-measurement {
  background: var(--accent) !important;
  color: white !important;
  border: none !important;
  padding: 6px 12px !important;
  border-radius: 6px !important;
  font-size: 11px !important;
  font-weight: 500 !important;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  margin-top: 4px;
}

.btn-save-measurement:hover {
  background: var(--accent) !important;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px var(--accent-shadow);
}

.save-success {
  background: #059669;
  color: white;
  padding: 8px;
  border-radius: 6px;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  animation: fadeInOut 3s ease-in-out;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translateY(-10px); }
  10% { opacity: 1; transform: translateY(0); }
  90% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-10px); }
}

/* Enhanced File Import Section */
.file-import-container {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  background: var(--btn);
  margin-bottom: 12px;
}

.file-input-wrapper {
  position: relative;
  margin-bottom: 16px;
}

.file-input-wrapper input[type="file"] {
  opacity: 0;
  position: absolute;
  pointer-events: none;
  width: 0;
  height: 0;
}

.file-input-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  border: 2px dashed var(--line);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.file-input-label:hover {
  border-color: var(--accent);
  background: var(--btn);
  transform: translateY(-1px);
}

.file-icon {
  font-size: 20px;
}

.file-text {
  color: var(--text);
  font-weight: 500;
  font-size: 14px;
}

.supported-formats {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.formats-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 8px;
}

.format-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.format-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: var(--panel);
  border-radius: 6px;
  border: 1px solid var(--line);
  font-size: 11px;
}

.format-icon {
  font-size: 14px;
  width: 16px;
  text-align: center;
}

.format-name {
  color: var(--text);
  font-weight: 500;
  flex: 1;
}

.format-ext {
  color: var(--muted);
  font-size: 10px;
}

/* Drag and drop enhancement */
.file-input-label.dragover {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.file-input-label.dragover .file-text {
  color: white;
}

/* Professional Clip Layers Panel */
.clip-panel {
  background: var(--btn);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  margin-top: 8px;
}

.aoi-status {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
}

.status-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  margin-bottom: 4px;
}

.status-value {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.status-value.has-aoi {
  color: var(--accent);
}

.layer-selection {
  margin-bottom: 16px;
}

.selection-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.selection-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.select-all-btn {
  background: var(--panel) !important;
  border: 1px solid var(--line) !important;
  color: var(--text) !important;
  padding: 4px 8px !important;
  border-radius: 4px !important;
  font-size: 10px !important;
  cursor: pointer;
  transition: all 0.2s ease;
}

.select-all-btn:hover {
  background: var(--accent) !important;
  color: white !important;
}

.layer-checklist {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.no-layers {
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
}

.clip-layer-item {
  border-bottom: 1px solid var(--line);
  transition: background-color 0.2s ease;
}

.clip-layer-item:last-child {
  border-bottom: none;
}

.clip-layer-item:hover {
  background: var(--btn);
}

.clip-layer-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  cursor: pointer;
  width: 100%;
}

.clip-layer-checkbox input[type="checkbox"] {
  margin: 0;
  accent-color: var(--accent);
}

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

.layer-name {
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  display: block;
  margin-bottom: 2px;
}

.layer-details {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}

.feature-count {
  font-weight: 500;
}

.clipped-badge {
  background: var(--accent);
  color: white;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 600;
}

.clip-options {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
}

.option-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.option-row:last-child {
  margin-bottom: 0;
}

.option-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.option-select {
  background: var(--btn) !important;
  border: 1px solid var(--line) !important;
  color: var(--text) !important;
  padding: 4px 8px !important;
  border-radius: 4px !important;
  font-size: 11px !important;
}

.crs-display {
  color: var(--text);
  font-size: 11px;
  font-weight: 500;
  font-family: monospace;
}

.clip-actions {
  text-align: center;
}

.clip-action-btn {
  background: linear-gradient(135deg, var(--accent), #3b82f6) !important;
  border: none !important;
  color: white !important;
  padding: 12px 24px !important;
  border-radius: 8px !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
  box-shadow: 0 2px 8px rgba(78, 161, 255, 0.3);
}

.clip-action-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(78, 161, 255, 0.4);
  background: linear-gradient(135deg, #3b82f6, var(--accent)) !important;
}

.clip-action-btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(78, 161, 255, 0.3);
}

.clip-action-btn:disabled {
  background: var(--btn) !important;
  color: var(--muted) !important;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
  text-shadow: none !important;
}

.btn-icon {
  font-size: 16px;
}

.btn-text {
  font-size: 14px;
}

.info-icon {
  color: var(--muted);
  cursor: help;
  margin-left: 4px;
  font-size: 12px;
}

/* Status value styling for clip panel */
.status-value.status-ready {
  color: var(--success) !important;
  font-weight: 500;
}

.status-value.status-missing {
  color: var(--warning) !important;
  font-style: italic;
}

/* =====================================================
   LAYERS PANEL STYLING - PROFESSIONAL REDESIGN
   ===================================================== */

.layers-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.layers-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--btn) 0%, rgba(78, 161, 255, 0.1) 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  gap: 12px;
}

.layers-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.layers-actions {
  display: flex;
  gap: 8px;
}

.header-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--btn);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
  cursor: pointer;
}

.header-btn:hover {
  background: var(--accent);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(78, 161, 255, 0.3);
}

.header-btn .btn-icon {
  font-size: 14px;
}

.header-btn .btn-text {
  font-size: 13px;
}

.layers-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  padding: 4px;
}

/* Enhanced layer item styling */
.layers-list .layer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 12px;
  background: var(--btn);
  border: 1px solid var(--line);
  border-radius: 10px;
  gap: 12px;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.layers-list .layer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.layers-list .layer:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(78, 161, 255, 0.2);
  transform: translateY(-1px);
}

.layers-list .layer:hover::before {
  opacity: 1;
}

.layers-list .meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  gap: 4px;
}

.layers-list .meta > div:first-child {
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
  line-height: 1.3;
  margin-bottom: 2px;
}

.layers-list .meta .status {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  background: rgba(78, 161, 255, 0.1);
  border-radius: 4px;
  display: inline-block;
  width: fit-content;
}

.layers-list .actions {
  display: grid;
  grid-template-columns: repeat(3, 32px);
  grid-auto-rows: 32px;
  gap: 4px;
  flex-shrink: 0;
}

.layers-list .iconbtn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 14px;
  background: var(--btn);
  border: 1px solid var(--line);
  color: var(--text);
  transition: all 0.2s ease;
  cursor: pointer;
}

.layers-list .iconbtn:hover {
  background: var(--accent);
  color: white;
  transform: scale(1.05);
  box-shadow: 0 2px 4px rgba(78, 161, 255, 0.3);
}

.layers-list .toggle {
  appearance: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--btn);
  border: 1px solid var(--line);
  position: relative;
  cursor: pointer;
  transition: all 0.2s ease;
}

.layers-list .toggle:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.layers-list .toggle::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
  transition: all 0.2s ease;
}

.layers-list .toggle:checked::before {
  opacity: 1;
  color: white;
}

.layers-list .toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 4px rgba(78, 161, 255, 0.3);
}

/* No layers state */
.no-layers {
  text-align: center;
  padding: 24px 16px;
  color: var(--muted);
  font-style: italic;
  background: var(--btn);
  border: 1px dashed var(--line);
  border-radius: 8px;
  font-size: 14px;
}

/* Scrollbar styling for layers list */
.layers-list::-webkit-scrollbar {
  width: 6px;
}

.layers-list::-webkit-scrollbar-track {
  background: var(--btn);
  border-radius: 3px;
}

.layers-list::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 3px;
}

.layers-list::-webkit-scrollbar-thumb:hover {
  background: #3b82f6;
}

/* =====================================================
   IDENTIFY/SELECT PANEL STYLING - PROFESSIONAL REDESIGN
   ===================================================== */

.identify-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tool-section, .actions-section {
  background: var(--btn);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  transition: all 0.2s ease;
}

.tool-section:hover, .actions-section:hover {
  border-color: rgba(78, 161, 255, 0.3);
  box-shadow: 0 2px 8px rgba(78, 161, 255, 0.1);
}

.tool-header, .actions-header {
  margin-bottom: 12px;
}

.tool-title, .actions-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tool-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.tool-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.tool-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.tool-btn:hover {
  background: var(--btn);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(78, 161, 255, 0.2);
}

.tool-btn:hover::before {
  opacity: 1;
}

.tool-btn.active {
  background: linear-gradient(135deg, var(--accent) 0%, #3b82f6 100%);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(78, 161, 255, 0.3);
}

.tool-btn.active::before {
  opacity: 0;
}

.tool-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.tool-label {
  font-size: 14px;
  flex: 1;
}

.actions-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
  cursor: pointer;
}

.action-btn:hover {
  background: var(--accent);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(78, 161, 255, 0.3);
}

.action-btn.secondary {
  background: var(--bg);
  border-color: var(--warning);
}

.action-btn.secondary:hover {
  background: var(--warning);
  color: white;
  border-color: var(--warning);
  box-shadow: 0 2px 8px rgba(255, 193, 7, 0.3);
}

.status-section {
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--btn) 0%, rgba(78, 161, 255, 0.05) 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.selection-status {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  font-style: italic;
}

/* =====================================================
   REST LOADER PANEL STYLING - PROFESSIONAL REDESIGN
   ===================================================== */

.rest-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.connection-section, .catalog-section, .layers-section, .query-section, .actions-section, .demo-section {
  background: var(--btn);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  transition: all 0.2s ease;
}

.connection-section:hover, .catalog-section:hover, .layers-section:hover, .query-section:hover {
  border-color: rgba(78, 161, 255, 0.3);
  box-shadow: 0 2px 8px rgba(78, 161, 255, 0.1);
}

.connection-header, .layers-header, .query-header, .demo-header {
  margin-bottom: 12px;
}

.connection-title, .layers-title, .query-title, .demo-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.connection-form, .query-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.input-group.flex-1 {
  flex: 1;
}

.input-row {
  display: flex;
  gap: 12px;
  align-items: end;
}

.input-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}

.form-input {
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  transition: all 0.2s ease;
  width: 100%;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(78, 161, 255, 0.2);
}

.form-input::placeholder {
  color: var(--muted);
  font-style: italic;
}

.number-input {
  max-width: 120px;
}

.connect-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: linear-gradient(135deg, var(--accent) 0%, #3b82f6 100%);
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.connect-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(78, 161, 255, 0.4);
  background: linear-gradient(135deg, #3b82f6 0%, var(--accent) 100%);
}

.layer-select {
  width: 100%;
  min-height: 100px;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  transition: all 0.2s ease;
}

.layer-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(78, 161, 255, 0.2);
}

.layer-select option {
  padding: 4px 8px;
  background: var(--bg);
  color: var(--text);
}

.layer-select option:checked {
  background: var(--accent);
  color: white;
}

.checkbox-group {
  display: flex;
  align-items: center;
  flex: 1;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}

.form-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.checkbox-text {
  user-select: none;
}

.actions-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.primary-actions {
  display: flex;
  justify-content: center;
}

.secondary-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.primary-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: linear-gradient(135deg, var(--accent) 0%, #3b82f6 100%);
  border: none;
  border-radius: 10px;
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(78, 161, 255, 0.4);
  background: linear-gradient(135deg, #3b82f6 0%, var(--accent) 100%);
}

.secondary-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.secondary-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(78, 161, 255, 0.3);
}

.demo-buttons {
  display: flex;
  gap: 8px;
}

.demo-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  flex: 1;
}

.demo-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(78, 161, 255, 0.3);
}

.status-section {
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--btn) 0%, rgba(78, 161, 255, 0.05) 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.rest-status {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  font-style: italic;
}

/* =====================================================
   SERVER CATALOG BROWSER STYLING
   ===================================================== */

.catalog-section {
  background: var(--btn);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  transition: all 0.3s ease;
}

.catalog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.catalog-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.catalog-toggle {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.catalog-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(78, 161, 255, 0.3);
}

.catalog-browser {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 12px;
  overflow: hidden;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.catalog-tabs {
  display: flex;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.catalog-tab {
  flex: 1;
  background: none;
  border: none;
  padding: 12px 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  border-bottom: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
}

.catalog-tab.active {
  background: var(--primary);
  color: white;
  border-bottom-color: var(--accent);
}

.catalog-tab:not(.active):hover {
  background: var(--hover);
}

.tab-icon {
  font-size: 14px;
}

.tab-text {
  font-weight: 500;
}

.catalog-content {
  padding: 16px;
}

.catalog-filters {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.filter-group {
  flex: 1;
}

.filter-select, .filter-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-bg);
  color: var(--text);
  font-size: 12px;
  transition: border-color 0.2s ease;
}

.filter-select:focus, .filter-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(78, 161, 255, 0.1);
}

.catalog-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  margin-bottom: 16px;
}

.catalog-item {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background-color 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.catalog-item:last-child {
  border-bottom: none;
}

.catalog-item:hover {
  background: var(--hover);
}

.catalog-item.selected {
  background: rgba(78, 161, 255, 0.1);
  border-left: 3px solid var(--primary);
}

.catalog-item-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.catalog-item-url {
  font-size: 11px;
  color: var(--muted);
  font-family: monospace;
  word-break: break-all;
}

.catalog-item-category {
  font-size: 10px;
  background: var(--primary);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  align-self: flex-start;
  margin-top: 4px;
}

.catalog-loading {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-style: italic;
}

.catalog-actions {
  display: flex;
  gap: 8px;
}

.catalog-btn {
  background: linear-gradient(135deg, var(--btn) 0%, var(--hover) 100%);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  justify-content: center;
}

.catalog-btn.primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: white;
  border-color: var(--primary);
}

.catalog-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.catalog-btn:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.catalog-btn.primary:not(:disabled):hover {
  box-shadow: 0 2px 8px rgba(78, 161, 255, 0.3);
}

/* =====================================================
   INSPECTOR STYLE TAB - PROFESSIONAL REDESIGN
   ===================================================== */

.styling-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 8px;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}

.styling-section {
  background: var(--btn);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  transition: all 0.2s ease;
}

.styling-section:hover {
  border-color: rgba(78, 161, 255, 0.3);
  box-shadow: 0 2px 8px rgba(78, 161, 255, 0.1);
}

.section-header {
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.control-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

.style-select {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  transition: all 0.2s ease;
}

.style-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(78, 161, 255, 0.2);
}

.layer-info {
  margin-top: 8px;
  padding: 6px 10px;
  background: rgba(78, 161, 255, 0.1);
  border-radius: 6px;
  text-align: center;
}

.feature-count {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

.fill-controls, .stroke-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.advanced-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.control-row {
  display: flex;
  gap: 12px;
}

.control-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.color-control, .opacity-control, .width-control {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.color-input-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.color-picker {
  width: 40px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  background: none;
  padding: 0;
}

.color-picker::-webkit-color-swatch-wrapper {
  padding: 0;
  border: none;
  border-radius: 4px;
}

.color-picker::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}

.hex-input {
  flex: 1;
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  font-family: monospace;
  transition: all 0.2s ease;
}

.hex-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(78, 161, 255, 0.2);
}

.slider-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.opacity-slider, .width-slider, .radius-slider {
  flex: 1;
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  outline: none;
  transition: all 0.2s ease;
  -webkit-appearance: none;
}

.opacity-slider::-webkit-slider-thumb,
.width-slider::-webkit-slider-thumb,
.radius-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
}

.opacity-slider::-webkit-slider-thumb:hover,
.width-slider::-webkit-slider-thumb:hover,
.radius-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 0 4px rgba(78, 161, 255, 0.2);
}

.slider-value {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  min-width: 40px;
  text-align: right;
}

.styling-actions {
  background: var(--btn);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-top: 8px;
}

.action-buttons {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.apply-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: linear-gradient(135deg, var(--accent) 0%, #3b82f6 100%);
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  flex: 2;
}

.apply-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(78, 161, 255, 0.4);
}

.reset-btn, .copy-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  flex: 1;
}

.reset-btn:hover, .copy-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  transform: translateY(-1px);
}

.style-status {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  font-style: italic;
  padding: 8px;
  background: rgba(78, 161, 255, 0.05);
  border-radius: 6px;
  transition: all 0.2s ease;
}

.style-status.success {
  color: var(--success);
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.style-status.error {
  color: var(--warning);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.style-status.info {
  color: var(--accent);
  background: rgba(78, 161, 255, 0.1);
  border: 1px solid rgba(78, 161, 255, 0.2);
}

/* Scrollbar styling for styling panel */
.styling-panel::-webkit-scrollbar {
  width: 6px;
}

.styling-panel::-webkit-scrollbar-track {
  background: var(--btn);
  border-radius: 3px;
}

.styling-panel::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 3px;
}

.styling-panel::-webkit-scrollbar-thumb:hover {
  background: #3b82f6;
}

/* =====================================================
   LAYER CONFIG POPUP - COMPREHENSIVE INTERFACE
   ===================================================== */

.layer-config-popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeInPopup 0.3s ease;
}

@keyframes fadeInPopup {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.popup-content {
  background: var(--bg);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 800px;
  max-height: 90vh;
  width: 90%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
}

.popup-header {
  background: linear-gradient(135deg, var(--btn) 0%, rgba(78, 161, 255, 0.1) 100%);
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.popup-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.popup-icon {
  font-size: 20px;
}

.popup-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--btn);
  color: var(--text);
  border-radius: 50%;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.popup-close:hover {
  background: var(--warning);
  color: white;
  transform: scale(1.1);
}

.popup-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.config-section {
  background: var(--btn);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  transition: all 0.2s ease;
}

.config-section:hover {
  border-color: rgba(78, 161, 255, 0.3);
  box-shadow: 0 2px 8px rgba(78, 161, 255, 0.1);
}

.section-header {
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.layer-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.info-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}

.info-input {
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  transition: all 0.2s ease;
}

.info-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(78, 161, 255, 0.2);
}

.info-value {
  padding: 8px 12px;
  background: rgba(78, 161, 255, 0.1);
  border-radius: 6px;
  font-size: 13px;
  color: var(--muted);
  font-family: monospace;
}

.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.quick-action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.quick-action-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(78, 161, 255, 0.3);
}

.action-icon {
  font-size: 16px;
}

.action-text {
  font-size: 13px;
}

.style-group {
  margin-bottom: 16px;
}

.style-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

.style-control {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  transition: all 0.2s ease;
}

.style-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(78, 161, 255, 0.2);
}

.color-controls-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.color-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.color-input-pair {
  display: flex;
  gap: 8px;
}

.color-picker-compact {
  width: 40px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
}

.hex-input-compact {
  flex: 1;
  padding: 6px 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-size: 11px;
  font-family: monospace;
}

.slider-controls-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.slider-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slider-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.opacity-slider-compact,
.width-slider-compact,
.radius-slider-compact {
  flex: 1;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  outline: none;
  -webkit-appearance: none;
}

.opacity-slider-compact::-webkit-slider-thumb,
.width-slider-compact::-webkit-slider-thumb,
.radius-slider-compact::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
}

.slider-value-compact {
  font-size: 10px;
  color: var(--muted);
  min-width: 35px;
  text-align: right;
  font-weight: 500;
}

.advanced-controls-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.style-control-compact {
  padding: 6px 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
}

.popup-footer {
  background: var(--btn);
  padding: 20px 24px;
  border-top: 1px solid var(--line);
}

.footer-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.popup-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.popup-btn.secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
}

.popup-btn.secondary:hover {
  background: var(--btn);
  border-color: var(--accent);
}

.popup-btn.primary {
  background: linear-gradient(135deg, var(--accent) 0%, #3b82f6 100%);
  color: white;
}

.popup-btn.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(78, 161, 255, 0.4);
}

.popup-btn.accent {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
}

.popup-btn.accent:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

/* Responsive design for smaller screens */
@media (max-width: 768px) {
  .popup-content {
    width: 95%;
    max-height: 95vh;
  }
  
  .layer-info-grid,
  .color-controls-row {
    grid-template-columns: 1fr;
  }
  
  .slider-controls-row {
    grid-template-columns: 1fr;
  }
  
  .quick-actions-grid {
    grid-template-columns: 1fr;
  }
  
  .footer-actions {
    flex-direction: column;
  }
}

/* =====================================================
   LAYER PREVIEW WINDOW STYLING
   ===================================================== */

.layer-preview-window {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 350px;
  height: 300px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  border-radius: 12px;
  z-index: 9999;
  animation: fadeInPreview 0.3s ease;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.preview-content {
  width: 100%;
  height: 100%;
  background: var(--panel-bg);
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.preview-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: white;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: between;
  border-radius: 12px 12px 0 0;
  cursor: move;
  user-select: none;
}

.preview-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  flex: 1;
  margin: 0;
}

.preview-icon {
  font-size: 16px;
}

.preview-close {
  background: none;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.preview-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.preview-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.preview-map-container {
  flex: 1;
  background: var(--bg);
  border: none;
  position: relative;
  min-height: 200px;
}

.preview-info {
  padding: 8px 12px;
  background: var(--panel-bg);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.preview-layer-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.preview-feature-count {
  font-size: 11px;
  color: var(--muted);
}

@keyframes fadeInPreview {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* =====================================================
   DRAG FUNCTIONALITY STYLING
   ===================================================== */

.drag-handle {
  cursor: move !important;
}

.popup-content.dragging,
.preview-content.dragging {
  transform: translateZ(0);
  transition: none !important;
}

.layer-config-popup.dragging,
.layer-preview-window.dragging {
  pointer-events: none;
}

.layer-config-popup.dragging .popup-content,
.layer-preview-window.dragging .preview-content {
  pointer-events: all;
}

/* =====================================================
   AOI & MEASURE PANEL STYLING - PROFESSIONAL REDESIGN
   ===================================================== */

.aoi-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Drawing Tools Section */
.drawing-tools {
  background: rgba(var(--accent-rgb), 0.05);
  border: 1px solid rgba(var(--accent-rgb), 0.15);
  border-radius: 12px;
  padding: 16px;
}

.tool-header {
  margin-bottom: 12px;
}

.tool-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 60px;
  justify-content: center;
}

.tool-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.3);
}

.tool-icon {
  font-size: 18px;
  margin-bottom: 4px;
  line-height: 1;
}

.tool-label {
  font-size: 11px;
  font-weight: 500;
  text-align: center;
}

/* AOI Scratch Layers Section */
.aoi-scratch-layers {
  background: rgba(var(--warning-rgb), 0.05);
  border: 1px solid rgba(var(--warning-rgb), 0.15);
  border-radius: 12px;
  padding: 16px;
}

.scratch-header {
  margin-bottom: 12px;
}

.scratch-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--warning);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.scratch-selector {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scratch-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--input);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.scratch-select:focus {
  outline: none;
  border-color: var(--warning);
  box-shadow: 0 0 0 2px rgba(var(--warning-rgb), 0.2);
}

.scratch-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-secondary);
}

.layer-count {
  font-weight: 500;
}

/* AOI Management Section */
.aoi-management {
  background: rgba(var(--success-rgb), 0.05);
  border: 1px solid rgba(var(--success-rgb), 0.15);
  border-radius: 12px;
  padding: 16px;
}

.management-header {
  margin-bottom: 12px;
}

.management-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--success);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.management-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-row {
  display: flex;
  gap: 8px;
}

.management-btn {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  justify-content: center;
}

.management-btn.primary {
  background: var(--success);
  color: white;
}

.management-btn.primary:hover {
  background: var(--success-dark, #16a34a);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(var(--success-rgb), 0.3);
}

.management-btn.secondary {
  background: var(--btn);
  color: var(--text);
  border: 1px solid var(--line);
}

.management-btn.secondary:hover {
  background: var(--error);
  color: white;
  border-color: var(--error);
  transform: translateY(-1px);
}

.management-btn.accent {
  background: var(--accent);
  color: white;
}

.management-btn.accent:hover {
  background: var(--accent-dark, #2563eb);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.3);
}

/* Masking Section */
.masking-options {
  background: rgba(var(--warning-rgb), 0.05);
  border: 1px solid rgba(var(--warning-rgb), 0.15);
  border-radius: 12px;
  padding: 16px;
}

.masking-header {
  margin-bottom: 12px;
}

.masking-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--warning);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.masking-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mask-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  justify-content: flex-start;
  width: 100%;
  min-height: 44px;
}

.mask-btn .btn-icon {
  font-size: 16px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mask-btn .btn-text {
  flex: 1;
  text-align: left;
  line-height: 1.2;
}

.mask-btn.apply {
  background: var(--warning);
  color: white;
}

.mask-btn.apply:hover {
  background: var(--warning-dark, #f59e0b);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(var(--warning-rgb), 0.3);
}

.mask-btn.toggle {
  background: var(--btn);
  color: var(--text);
  border: 1px solid var(--line);
}

.mask-btn.toggle:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  transform: translateY(-1px);
}

/* Measurement Display */
.measurement-display {
  background: var(--panel-alt, var(--panel));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  min-height: 60px;
}

.measure-status {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
}

.measure-status:empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-style: italic;
}

.measure-status:empty::before {
  content: "Draw an AOI to see measurements";
}

/* ===============================
   COLLAPSIBLE SECTIONS STYLING
   =============================== */

.section-title.collapsible {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  padding: 14px 16px; /* Increased padding for better hit area */
  border-radius: 8px;
  background: var(--btn);
  border: 1px solid var(--line);
  margin-bottom: 12px;
  transition: all 0.2s ease;
  position: relative;
  min-height: 48px; /* Ensure minimum clickable height */
}

.section-title.collapsible:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--accent-shadow);
}

.section-icon {
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
}

.section-text {
  font-weight: 600;
  font-size: var(--font-size-base);
  flex: 1;
  letter-spacing: 0.025em;
}

.info-icon {
  font-size: 14px;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.section-title.collapsible:hover .info-icon {
  opacity: 1;
}

.pop-out-btn {
  background: none;
  border: none;
  color: inherit;
  font-size: 14px;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.7;
  transition: all 0.2s ease;
}

.pop-out-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}

.collapse-btn {
  background: none;
  border: none;
  color: inherit;
  font-size: 18px;
  padding: 12px 16px; /* Increased padding for much larger hit area */
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  transform-origin: center;
  opacity: 0.8;
  min-width: 44px; /* Ensure larger minimum clickable area */
  min-height: 44px; /* Ensure larger minimum clickable area */
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 3; /* Ensure button is above other elements */
  margin-left: auto; /* Push to right side */
}

.collapse-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.collapse-btn:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.3);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.section.collapsed .collapse-btn {
  transform: rotate(180deg);
}

.section.collapsed .collapse-btn:hover {
  transform: rotate(180deg) scale(1.1);
  background: rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.section.collapsed .collapse-btn:active {
  transform: rotate(180deg) scale(0.95);
  background: rgba(255, 255, 255, 0.3);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Section content hiding */
.section.collapsed > *:not(.section-title) {
  display: none !important;
}

.section {
  transition: all 0.3s ease;
  margin-bottom: 16px;
}

.section.collapsed {
  margin-bottom: 8px;
}

/* START FRESH - LEFTBAR COLLAPSED */
#leftbar.collapsed {
  width: 80px !important;
  min-width: 80px !important;
  max-width: 80px !important;
  overflow: hidden !important;
  transition: width 0.3s ease;
  padding: 10px !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
}
#leftbar.collapsed .section {
  display: block !important;
  margin-bottom: 8px !important;
}
#leftbar.collapsed .section > *:not(.section-title) {
  display: none !important;
}
#leftbar.collapsed .section-title.collapsible {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  padding: 0;
  margin: 0 auto 8px auto;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: var(--btn);
  border: 2px solid var(--line);
  transition: all 0.3s ease;
  box-sizing: border-box;
  cursor: pointer;
}
#leftbar.collapsed .section-title.collapsible > * {
  display: none !important;
}
#leftbar.collapsed .section-title.collapsible::before {
  content: '📁' !important;
  font-size: 28px !important;
  width: 60px !important;
  height: 60px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  line-height: 60px !important;
  margin: 0 !important;
  padding: 0 !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
}
#leftbar.collapsed .section-title.collapsible[data-section="aoi-measure"]::before { content: '📐' !important; }
#leftbar.collapsed .section-title.collapsible[data-section="clip-layers"]::before { content: '✂️' !important; }
#leftbar.collapsed .section-title.collapsible[data-section="geographic-mask"]::before { content: '🗺️' !important; }
#leftbar.collapsed .section-title.collapsible[data-section="identify-select"]::before { content: '🎯' !important; }
#leftbar.collapsed .section-title.collapsible[data-section="layers"]::before { content: '🗂️' !important; }
#leftbar.collapsed .section-title.collapsible[data-section="rest-loader"]::before { content: '🌐' !important; }
#leftbar.collapsed .section-title.collapsible:hover {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  transform: translateX(4px) scale(1.05) !important;
  box-shadow: 4px 4px 16px var(--accent-shadow) !important;
}

/* Tooltips for collapsed icons - matching rightbar */
#leftbar.collapsed .section-title.collapsible::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 80px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--panel);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: var(--font-size-small);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, left 0.2s;
  z-index: 1000;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#leftbar.collapsed .section-title.collapsible:hover::after {
  opacity: 1;
  left: 84px;
}

/* Fix JUST the collapse button - simpler approach */
#leftbar:not(.collapsed) .section-title.collapsible {
  justify-content: space-between !important; /* Push collapse button to right */
}

/* Keep the collapse button inside the title block */
#leftbar:not(.collapsed) .section-title.collapsible .collapse-btn {
  margin-right: 0 !important; /* Keep button inside the title block */
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 8px 12px; /* Larger padding for easier clicking */
  min-width: 36px;
  min-height: 36px;
}

/* Add pseudo-element for much larger extended click area */
.collapse-btn::after {
  content: '';
  position: absolute;
  top: -16px;
  left: -16px;
  right: -16px;
  bottom: -16px;
  z-index: 1; /* Above the button content */
  background: transparent;
  border-radius: 12px;
  cursor: pointer;
}

/* Make entire section title more clickable when expanded */
.section-title.collapsible {
  position: relative;
  cursor: pointer;
}

/* Enhance click area for the entire section title */
.section-title.collapsible::before {
  content: '';
  position: absolute;
  top: -8px;
  left: -8px;
  right: -8px;
  bottom: -8px;
  z-index: 1;
  background: transparent;
  border-radius: 12px;
}

/* Enhanced click area for better UX */

/* ===============================
   PROFESSIONAL THEME SWITCHING
   =============================== */

.theme {
  background: var(--btn) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--border-radius-sm) !important;
  padding: 8px 16px !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  min-width: 80px !important;
  justify-content: center !important;
  box-shadow: var(--shadow-sm) !important;
}

.theme:hover {
  background: var(--btn-hover) !important;
  border-color: var(--accent) !important;
  transform: translateY(-1px) !important;
  box-shadow: var(--shadow-md) !important;
}

.theme:active {
  transform: translateY(0) !important;
  box-shadow: var(--shadow-sm) !important;
}

/* Active theme indicator */
html[data-theme="dark"] .theme[data-theme="dark"],
html[data-theme="light"] .theme[data-theme="light"] {
  background: var(--accent) !important;
  color: white !important;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--accent-shadow) !important;
}

/* Smooth theme transition */
html {
  transition: background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

/* Right sidebar uses simple transform approach above */

/* ===============================
   TOAST NOTIFICATION SYSTEM
   =============================== */

.toast-container {
  position: relative;
  margin-left: auto; /* Push to right end of topbar */
}

.toast-system {
  position: fixed;
  top: 70px; /* Below topbar */
  right: 20px;
  z-index: 10001; /* Above all other elements including bottom logo */
  pointer-events: none; /* Allow clicks through container */
  max-width: 400px;
  width: 100%;
}

.toast {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  pointer-events: auto;
  transform: translateX(120%);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast.hide {
  transform: translateX(120%);
  opacity: 0;
}

.toast-icon {
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 2px;
  line-height: 1.3;
}

.toast-message {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
  word-wrap: break-word;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.toast-close:hover {
  background: var(--hover);
  color: var(--text);
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--accent);
  border-radius: 0 0 12px 12px;
  transition: width 0.1s linear;
}

/* Toast type styling using theme variables */
.toast.success {
  border-left: 4px solid var(--success);
}

.toast.success .toast-icon {
  color: var(--success);
}

.toast.error {
  border-left: 4px solid var(--error);
}

.toast.error .toast-icon {
  color: var(--error);
}

.toast.warning {
  border-left: 4px solid var(--warning);
}

.toast.warning .toast-icon {
  color: var(--warning);
}

.toast.info {
  border-left: 4px solid var(--info);
}

.toast.info .toast-icon {
  color: var(--info);
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .toast-system {
    top: 60px;
    right: 10px;
    left: 10px;
    max-width: none;
  }
  
  .toast {
    margin-bottom: 6px;
    padding: 10px 12px;
  }
  
  .toast-title {
    font-size: 13px;
  }
  
  .toast-message {
    font-size: 12px;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .toast {
    border-width: 2px;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--bg);
  }
}

/* ===============================
   ENHANCED BUTTON STATES & INTERACTIONS
   =============================== */

/* Global button state improvements */
button, .btn, input[type="button"], input[type="submit"] {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

/* Loading state for buttons */
button.loading, .btn.loading {
  pointer-events: none;
  opacity: 0.7;
}

button.loading::after, .btn.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: buttonSpin 0.8s linear infinite;
}

@keyframes buttonSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Disabled state consistency */
button:disabled, .btn:disabled, button[disabled], .btn[disabled] {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
  filter: grayscale(0.5);
}

/* Focus states for accessibility */
button:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  z-index: 1;
}

/* Active/pressed states */
button:active:not(:disabled), .btn:active:not(:disabled) {
  transform: translateY(1px);
  transition-duration: 0.1s;
}

/* Success state for buttons */
button.success, .btn.success {
  background: #10b981 !important;
  color: white !important;
  border-color: #10b981 !important;
}

button.success::before, .btn.success::before {
  content: '✓';
  margin-right: 6px;
}

/* Error state for buttons */
button.error, .btn.error {
  background: #ef4444 !important;
  color: white !important;
  border-color: #ef4444 !important;
}

button.error::before, .btn.error::before {
  content: '✕';
  margin-right: 6px;
}

/* Warning state for buttons */
button.warning, .btn.warning {
  background: #f59e0b !important;
  color: white !important;
  border-color: #f59e0b !important;
}

button.warning::before, .btn.warning::before {
  content: '⚠';
  margin-right: 6px;
}

/* Ripple effect for buttons */
.ripple {
  position: relative;
  overflow: hidden;
}

.ripple::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.ripple:active::before {
  width: 300px;
  height: 300px;
}

/* Enhanced tool button states */
.tool-btn {
  position: relative;
}

.tool-btn.active {
  background: var(--accent) !important;
  color: white !important;
  box-shadow: 0 0 0 2px var(--accent-shadow);
}

.tool-btn.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
}

/* Form validation states */
input.valid, select.valid {
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

input.invalid, select.invalid {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Loading skeleton for content areas */
.skeleton {
  background: linear-gradient(90deg, var(--line) 25%, var(--hover) 50%, var(--line) 75%);
  background-size: 200% 100%;
  animation: skeletonLoading 1.5s infinite;
}

@keyframes skeletonLoading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Pulse animation for important elements */
.pulse {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Bounce animation for notifications */
.bounce {
  animation: bounce 0.6s ease-out;
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-10px); }
  60% { transform: translateY(-5px); }
}

/* Animation for collapsing/expanding */
@keyframes collapseSection {
  from {
    opacity: 1;
    max-height: 1000px;
  }
  to {
    opacity: 0;
    max-height: 0;
  }
}

@keyframes expandSection {
  from {
    opacity: 0;
    max-height: 0;
  }
  to {
    opacity: 1;
    max-height: 1000px;
  }
}

/* AOI Measurement Popup System */
.aoi-measurement-popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

/* Contextual positioning - no overlay background */
.aoi-measurement-popup.contextual {
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  pointer-events: none;
  position: relative;
  width: auto;
  height: auto;
  display: block;
}

.aoi-measurement-popup.visible {
  opacity: 1;
  visibility: visible;
}

.measurement-popup-content {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 
    0 25px 50px -12px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.1);
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.3s ease;
  width: 90%;
  max-width: 500px;
  pointer-events: auto;
}

/* Contextual popup content styling - auto-resize to fit content */
.aoi-measurement-popup.contextual .measurement-popup-content {
  width: auto;
  min-width: 320px;
  max-width: min(600px, 90vw);
  box-shadow: 
    0 10px 30px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(59, 130, 246, 0.3);
}

.aoi-measurement-popup.visible .measurement-popup-content {
  transform: scale(1);
}

.measurement-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 32px;
  background: linear-gradient(135deg, var(--panel-secondary), var(--panel));
  border-bottom: 1px solid var(--line);
}

.measurement-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.measurement-icon {
  font-size: 24px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.measurement-title-text {
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(135deg, #3b82f6, #10b981);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}

.measurement-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.measurement-close:hover {
  background: rgba(255, 59, 48, 0.2);
  border-color: rgba(255, 59, 48, 0.4);
  color: #ff3b30;
  transform: scale(1.1);
}

.measurement-body {
  padding: 32px;
}

.measurement-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.measurement-stat {
  padding: 16px;
  background: var(--btn);
  border: 1px solid var(--line);
  border-radius: 12px;
  text-align: center;
  transition: all 0.3s ease;
  position: relative;
}

.measurement-stat:hover {
  background: var(--btn-hover);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.measurement-stat.clickable {
  cursor: pointer;
}

.measurement-stat.clickable:hover {
  background: var(--accent);
  color: white;
}

.measurement-stat.clickable:active {
  transform: translateY(0px);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.copy-hint {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 10px;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.measurement-stat.clickable:hover .copy-hint,
.measurement-coordinates.clickable:hover .copy-hint {
  opacity: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-mono);
}

.measurement-coordinates {
  padding: 16px;
  background: var(--panel-secondary);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 24px;
}

.coordinates-title {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.coordinates-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
  font-family: var(--font-mono);
}

.measurement-actions {
  display: flex;
  gap: 16px;
  justify-content: flex-end;
  padding: 24px 32px;
  background: var(--panel-secondary);
  border-top: 1px solid var(--line);
}

.measurement-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid var(--border);
}

.measurement-btn.secondary {
  background: var(--btn);
  color: var(--text);
}

.measurement-btn.secondary:hover {
  background: var(--btn-hover);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.measurement-btn.primary {
  background: linear-gradient(135deg, #3b82f6, #10b981);
  border-color: transparent;
  color: white;
}

.measurement-btn.primary:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.btn-icon {
  font-size: 16px;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .measurement-popup-content {
    width: 95%;
    margin: 20px;
  }
  
  .measurement-header {
    padding: 20px 24px;
  }
  
  .measurement-body {
    padding: 24px;
  }
  
  .measurement-stats {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  /* Mobile contextual popup adjustments */
  .aoi-measurement-popup.contextual .measurement-popup-content {
    min-width: 280px;
    max-width: 95vw;
  }
  
  .aoi-measurement-popup.contextual .measurement-stats {
    grid-template-columns: 1fr;
  }
  
  .measurement-actions {
    padding: 20px 24px;
    flex-direction: column;
  }
  
  .measurement-btn {
    width: 100%;
    justify-content: center;
  }
}

/* Popup Arrow for Contextual Positioning */
.popup-arrow {
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  background: var(--panel);
  border-left: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  transform: translateY(-50%) rotate(45deg);
  z-index: -1;
}

/* Hide arrow for non-contextual popups */
.aoi-measurement-popup:not(.contextual) .popup-arrow {
  display: none;
}

/* Adjust stats grid for contextual popup with auto-sizing */
.aoi-measurement-popup.contextual .measurement-stats {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.aoi-measurement-popup.contextual .measurement-stat {
  padding: 12px;
}

.aoi-measurement-popup.contextual .measurement-coordinates {
  margin-bottom: 16px;
  padding: 12px;
}

.aoi-measurement-popup.contextual .measurement-header {
  padding: 16px 20px;
}

.aoi-measurement-popup.contextual .measurement-body {
  padding: 20px;
}

.aoi-measurement-popup.contextual .measurement-actions {
  padding: 16px 20px;
  justify-content: center;
}

.aoi-measurement-popup.contextual .measurement-actions .measurement-btn {
  width: auto;
  min-width: 140px;
}

/* Custom Zoom Controls in Toolbar */
.zoom-controls {
  display: flex;
  gap: 4px;
}

.zoom-btn {
  width: 32px;
  height: 32px;
  background: var(--btn);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.zoom-btn:hover {
  background: var(--btn-hover);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.zoom-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(59, 130, 246, 0.2);
}

.zoom-icon {
  font-size: 16px;
  line-height: 1;
  user-select: none;
}

/* Rotate Controls */
.rotate-controls {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 8px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}

.rotate-btn {
  width: 28px;
  height: 28px;
  background: var(--btn);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 14px;
}

.rotate-btn:hover {
  background: var(--btn-hover);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.2);
}

.rotate-btn:active {
  transform: translateY(0);
}

.rotation-input {
  width: 50px;
  height: 28px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 12px;
  text-align: center;
  margin: 0 2px;
}

.rotation-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.rotate-icon {
  font-size: 14px;
  line-height: 1;
  user-select: none;
}

/* ============================================================================ */
/* === EXPORT CENTER POPUP =================================================== */
/* ============================================================================ */

/* Export Center Button Styling */
.export-center-trigger {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 10px 16px !important;
  background: linear-gradient(135deg, var(--accent), #4f46e5) !important;
  color: white !important;
  border: none !important;
  border-radius: 8px !important;
  font-weight: 600 !important;
  font-size: 14px !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3) !important;
}

.export-center-trigger:hover {
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4) !important;
  background: linear-gradient(135deg, #4f46e5, var(--accent)) !important;
}

.export-center-trigger .btn-icon {
  font-size: 16px !important;
}

/* Export Center Popup */
.export-center-popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  transition: all 0.3s ease;
}

.export-center-popup.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.95);
}

.export-center-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.export-center-content {
  position: relative;
  width: 100%;
  max-width: 2400px;
  width: 90vw;
  max-height: 95vh;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Enhanced dark mode polish for export center */
html[data-theme="dark"] .export-center-content {
  background: linear-gradient(135deg, var(--panel) 0%, var(--panel-secondary) 100%);
  border: 1px solid var(--border);
  box-shadow: 
    0 25px 50px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(59, 130, 246, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

html[data-theme="light"] .export-center-content {
  background: linear-gradient(135deg, var(--panel) 0%, rgba(248, 250, 252, 0.8) 100%);
  box-shadow: 
    0 25px 50px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(0, 0, 0, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

/* Enhanced dark mode button styling */
html[data-theme="dark"] .format-btn {
  background: linear-gradient(135deg, var(--btn) 0%, var(--panel) 100%);
  border: 1px solid var(--border);
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .format-btn:hover {
  background: linear-gradient(135deg, var(--btn-hover) 0%, var(--panel-secondary) 100%);
  border-color: var(--accent);
  box-shadow: 
    0 4px 16px rgba(59, 130, 246, 0.2),
    0 0 0 1px var(--accent-light),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

html[data-theme="dark"] .format-btn.active {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  border-color: var(--accent-light);
  color: white;
  box-shadow: 
    0 6px 20px rgba(59, 130, 246, 0.4),
    0 0 0 2px rgba(59, 130, 246, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Enhanced dark mode orientation buttons */
html[data-theme="dark"] .orientation-btn {
  background: linear-gradient(135deg, var(--btn) 0%, var(--panel) 100%);
  border: 1px solid var(--border);
  box-shadow: 
    0 2px 6px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .orientation-btn:hover {
  background: linear-gradient(135deg, var(--btn-hover) 0%, var(--panel-secondary) 100%);
  border-color: var(--accent);
  box-shadow: 
    0 3px 12px rgba(59, 130, 246, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .orientation-btn.active {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  border-color: var(--accent-light);
  color: white;
  box-shadow: 
    0 4px 16px rgba(59, 130, 246, 0.3),
    0 0 0 1px rgba(59, 130, 246, 0.4);
}

/* Header */
.export-center-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px;
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  color: white;
}

.export-center-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.header-icon {
  font-size: 24px;
}

.export-center-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 24px;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.export-center-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

/* Body - Two Column Layout */
.export-center-body {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
  display: grid;
  grid-template-columns: 580px 1fr 320px;
  gap: 32px;
}

/* Left Panel: Options */
.export-options-panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
}

/* Right Panel: Preview */
.export-preview-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 850px;
}

/* Large Preview Layout */
.export-preview-large {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.preview-controls {
  display: flex;
  gap: 16px;
  align-items: center;
}

.scale-control {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--card-bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.scale-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.scale-control label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.scale-display {
  font-family: monospace;
  font-weight: 700;
  color: var(--accent);
  background: var(--input-bg);
  padding: 6px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  min-width: 80px;
  text-align: center;
}

.scale-select,
.custom-scale-input {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  background: var(--bg);
  color: var(--text);
  min-width: 100px;
}

.scale-select:focus,
.custom-scale-input:focus {
  outline: none;
  border-color: var(--accent);
}

.direct-scale-input {
  width: 100px;
  font-family: monospace;
  font-weight: 600;
}

.scale-presets {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preset-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.preset-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 60px;
}

.scale-preset-btn {
  background: var(--btn);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.scale-preset-btn:hover {
  background: var(--btn-hover);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

.scale-preset-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.scale-slider-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.scale-slider {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  outline: none;
  appearance: none;
  cursor: pointer;
}

.scale-slider::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
}

.scale-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 0 4px;
}

.preview-title {
  margin: 0;
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 600;
}

.preview-container-large {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.map-preview-area-large {
  position: relative;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  height: 700px;
  min-height: 700px;
  flex-shrink: 0;
  width: 100%;
}

.preview-canvas-large {
  width: 100%;
  height: 100%;
  display: block;
}

/* Cartographic Elements Below Map */
.cartographic-elements {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-top: 16px;
  position: relative;
  z-index: 1;
}

/* Preview Title Block Scaling - Make elements smaller in preview to match export */
.cartographic-elements .title-block-section {
  padding: 8px 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  transform: scale(0.7);
  transform-origin: left top;
  width: 142.8%; /* Compensate for scale */
}

.cartographic-elements .title-project-name-input {
  font-size: 14px !important;
  font-weight: 600;
  padding: 4px 6px;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
}

.cartographic-elements .title-description-input {
  font-size: 11px !important;
  color: var(--text-muted);
  padding: 2px 4px;
  background: transparent;
  border: 1px solid transparent;
}

.cartographic-elements .title-logo {
  font-size: 12px !important;
  color: var(--accent);
  font-weight: 500;
}

.cartographic-elements .title-meta {
  font-size: 10px !important;
  color: var(--text-muted);
}

.cartographic-elements .map-elements-bar {
  transform: scale(0.7);
  transform-origin: left top;
  margin-top: -4px;
  width: 142.8%; /* Compensate for scale */
}

.cartographic-elements .scale-bar-section,
.cartographic-elements .north-arrow-section,
.cartographic-elements .coords-section {
  font-size: 10px !important;
  color: var(--text-muted);
}

.title-block-section {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #eee;
}

.title-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.title-project-name {
  font-weight: bold;
  font-size: 1.1em;
  color: #333;
}

.title-project-name-input {
  background: transparent;
  border: 1px solid transparent;
  font-weight: bold;
  font-size: 1.1em;
  color: #333;
  padding: 2px 4px;
  border-radius: 4px;
  flex: 1;
}

.title-project-name-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg);
  color: var(--text);
}

.title-description-input {
  background: transparent;
  border: 1px solid transparent;
  font-size: 0.9em;
  color: #666;
  padding: 2px 4px;
  border-radius: 4px;
  flex: 1;
}

.title-description-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg);
  color: var(--text);
}

.title-logo {
  font-size: 1em;
  color: #666;
}

.title-block-details {
  display: flex;
  gap: 16px;
  font-size: 0.9em;
  color: #666;
}

.map-elements-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  font-size: 0.9em;
  color: #666;
}

.scale-bar-section,
.north-arrow-section,
.coords-section {
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 4px;
}

/* Right Panel: Legend & Layer Control */
.export-legend-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
}

.legend-section,
.layer-control-section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.legend-header,
.layer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.legend-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.legend-add-btn {
  background: var(--success, #10b981);
  color: white;
  border: none;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.legend-add-btn:hover {
  background: var(--success-hover, #059669);
  transform: translateY(-1px);
}

.legend-title,
.layer-title {
  margin: 0;
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 600;
}

.legend-toggle-btn,
.layer-refresh-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.legend-toggle-btn:hover,
.layer-refresh-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.legend-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.02);
  border-radius: 6px;
}

.legend-symbol {
  width: 20px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
}

.point-symbol {
  background: #ff6b6b;
  border-radius: 50%;
  height: 12px;
}

.line-symbol {
  background: linear-gradient(90deg, #4ecdc4 0%, #4ecdc4 100%);
  height: 3px;
}

.polygon-symbol {
  background: rgba(74, 144, 226, 0.3);
  border: 2px solid #4a90e2;
}

.basemap-symbol {
  background: linear-gradient(45deg, #e8e8e8 25%, transparent 25%),
              linear-gradient(-45deg, #e8e8e8 25%, transparent 25%),
              linear-gradient(45deg, transparent 75%, #e8e8e8 75%),
              linear-gradient(-45deg, transparent 75%, #e8e8e8 75%);
  background-size: 4px 4px;
  background-position: 0 0, 0 2px, 2px -2px, -2px 0px;
}

.legend-label {
  font-size: 0.9rem;
  color: var(--text);
}

.legend-empty {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-style: italic;
}

.legend-empty p {
  margin: 0;
  font-size: 0.9rem;
}

/* Legend Editor */
.legend-editor {
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 12px;
  padding: 16px;
  margin-top: 16px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.editor-header h4 {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
}

.editor-close-btn {
  background: var(--danger, #ef4444);
  color: white;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.editor-close-btn:hover {
  background: var(--danger-hover, #dc2626);
}

.editor-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.editor-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.editor-field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.editor-field input,
.editor-field select {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--text);
}

.editor-field input:focus,
.editor-field select:focus {
  outline: none;
  border-color: var(--accent);
}

.editor-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.editor-save-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  flex: 1;
}

.editor-save-btn:hover {
  background: var(--accent-hover);
}

.editor-cancel-btn {
  background: var(--text-muted);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  flex: 1;
}

.editor-cancel-btn:hover {
  background: var(--text);
}

/* Dynamic Legend Items */
.legend-item {
  position: relative;
}

.legend-item:hover .legend-item-actions {
  opacity: 1;
}

.legend-item-actions {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.legend-edit-btn,
.legend-delete-btn {
  background: rgba(0, 0, 0, 0.1);
  border: none;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.legend-edit-btn:hover {
  background: var(--accent);
  color: white;
}

.legend-delete-btn:hover {
  background: var(--danger, #ef4444);
  color: white;
}

.layer-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.layer-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.02);
  border-radius: 8px;
}

.layer-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.layer-name {
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 500;
}

.layer-opacity {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 28px;
}

.opacity-slider {
  flex: 1;
  height: 4px;
  background: #ddd;
  outline: none;
  border-radius: 2px;
}

.opacity-slider::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
}

.opacity-value {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 35px;
  text-align: right;
}

/* Professional Title Block Editor */
.title-block-editor {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.editor-header-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.title-block-refresh-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.title-block-refresh-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.title-block-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.form-field input,
.form-field textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.2s ease;
}

.form-field input:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-field textarea {
  resize: vertical;
  min-height: 60px;
}

/* Export Sections */
.export-section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  transition: all 0.2s ease;
}

.export-section:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.1);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 20px 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.section-icon {
  font-size: 20px;
}

/* Export Grid */
.export-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  margin-bottom: 24px;
}

.export-option-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.export-label {
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Format Selector */
.format-selector {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.format-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 16px;
  min-width: 120px;
  min-height: 110px;
  border: 2px solid var(--border);
  background: var(--btn);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: center;
  overflow: visible;
  position: relative;
}

.format-btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.format-btn.active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
}

.format-icon {
  font-size: 28px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 32px;
  margin: 0;
  padding: 0;
}

.format-name {
  font-weight: 600;
  font-size: 12px;
  text-align: center;
}

.format-desc {
  font-size: 10px;
  opacity: 0.8;
  margin-bottom: 1px;
}

.format-use {
  font-size: 9px;
  opacity: 0.6;
  font-style: italic;
  color: var(--accent);
}

/* Enhanced Page Size Indicator */
.page-layout-guide {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-top: 8px;
  font-size: 11px;
}

.page-size-indicator {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.page-name {
  font-weight: 600;
  color: var(--text);
}

.page-orientation {
  font-size: 10px;
  color: var(--accent);
  font-weight: 500;
}

.page-pixels {
  font-size: 9px;
  color: var(--text-secondary);
  font-family: monospace;
}

.preview-refresh-btn {
  padding: 4px 8px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 10px;
  transition: all 0.2s ease;
}

.preview-refresh-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

/* DPI Selector */
.dpi-selector {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 8px;
}

.dpi-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 12px;
  font-weight: 600;
}

.dpi-btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.dpi-btn.active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.dpi-desc {
  font-size: 10px;
  opacity: 0.8;
  font-weight: 400;
}

/* Page Size Controls */
.page-size-selector {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.page-size-dropdown {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.page-size-dropdown:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.orientation-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.orientation-btn {
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 11px;
  text-align: center;
}

.orientation-btn:hover {
  border-color: var(--accent);
}

.orientation-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Title Block Configuration */
.title-block-config {
  margin: 20px 0;
  padding: 20px;
  background: rgba(59, 130, 246, 0.05);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 8px;
}

.config-title {
  margin: 0 0 16px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.title-block-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.title-input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.title-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.title-input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  transition: all 0.2s ease;
}

.title-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.cartographic-elements {
  margin-top: 16px;
}

.element-checkboxes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

/* Export Options */
.export-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-checkbox {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text) !important;
  background: transparent !important;
  padding: 8px;
  border-radius: 6px;
  transition: background 0.2s ease;
}

.option-checkbox:hover {
  background: var(--hover) !important;
}

.option-checkbox input[type="checkbox"] {
  display: none;
}

.checkmark {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  background: var(--btn);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.option-checkbox input[type="checkbox"]:checked + .checkmark {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.option-checkbox input[type="checkbox"]:checked + .checkmark::after {
  content: '✓';
  font-size: 12px;
  font-weight: bold;
}

.option-checkbox:hover .checkmark {
  border-color: var(--accent);
}

/* Preview Canvas Smooth Transitions */
.preview-canvas, #mapPreviewCanvas {
  transition: opacity 0.2s ease;
}

/* Professional Loading Spinner for Export Center */
.preview-loading-spinner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(var(--bg-rgb), 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 8px;
  z-index: 10;
  padding: 30px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(8px);
  z-index: 1000;
  border: 2px solid #e9ecef;
}

.preview-loading-spinner.active {
  display: flex;
}

.preview-loading-spinner::before {
  content: '';
  width: 48px;
  height: 48px;
  border: 4px solid rgba(var(--bg-rgb), 0.2);
  border-top: 4px solid var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

.preview-loading-spinner::after {
  content: 'Updating Map Preview...';
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  opacity: 0.9;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}


/* Orientation Button Enhancements */
.orientation-btn {
  min-width: 80px;
  min-height: 80px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  background: var(--btn);
  transition: all 0.2s ease;
  cursor: pointer;
}

.orientation-btn:hover {
  border-color: #4a90e2;
  transform: scale(1.02);
}

.orientation-btn.active {
  border-color: var(--accent);
  background: var(--btn-hover);
  box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.1);
}

.orientation-btn .orientation-icon {
  margin-bottom: 6px;
}

.orientation-btn .orientation-label {
  font-size: 12px;
  font-weight: 500;
  color: #6c757d;
  text-transform: capitalize;
}

/* Professional Title Block Preview - Based on cartographic best practices */
.title-block-preview {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: 2px solid #333;
  border-radius: 10px;
  padding: 24px 30px; /* Increased padding */
  max-width: 85%; /* Slightly wider */
  min-height: 120px; /* Ensure minimum height */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  font-family: 'Arial', sans-serif;
}

.title-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  border-bottom: 1px solid #ddd;
  padding-bottom: 8px;
}

.title-project-name {
  font-size: 22px; /* Increased from 16px */
  font-weight: 700;
  color: #333;
  letter-spacing: 0.5px;
  margin-bottom: 8px; /* Add spacing */
}

.title-logo {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}

.title-block-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #666;
}

.title-description {
  font-style: italic;
  color: #555;
  font-size: 16px; /* Increased from default */
  margin-bottom: 6px; /* Add spacing */
}

.title-meta {
  font-size: 14px; /* Increased from 11px */
  color: #777;
}

/* Other preview elements */
.scale-bar-preview, .north-arrow-preview {
  position: absolute;
  background: rgba(255, 255, 255, 0.9);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.scale-bar-preview {
  bottom: 20px;
  left: 20px;
}

.north-arrow-preview {
  top: 20px;
  right: 20px;
}

/* Map Preview Area - Professional layout container */
.map-preview-area {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8f9fa;
  border: 2px dashed #dee2e6;
  border-radius: 8px;
  overflow: hidden;
}

.preview-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 10;
  /* Hide overlay elements - canvas handles all rendering */
  display: none;
}

/* Mini Loading Spinner */
.preview-loading-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 32px;
  border: 3px solid rgba(59, 130, 246, 0.2);
  border-top: 3px solid var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  z-index: 10;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.preview-loading-spinner.active {
  opacity: 1;
}

@keyframes spin {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Export Preview */
.export-preview {
  margin: 24px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.preview-container {
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  max-height: 650px;
  padding: 20px;
  /* Responsive layout that adapts to orientation */
  border: 2px solid var(--border);
  /* Auto-adjust aspect ratio based on content */
  width: 100%;
  flex: 1;
  border-radius: 8px;
  overflow: auto; /* Allow scrolling for very large previews */
}

.preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}

.preview-icon {
  font-size: 48px;
  opacity: 0.5;
}

.preview-text {
  font-size: 14px;
}

/* Project Export Styling */
.project-export-options {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.project-format {
  margin-bottom: 20px;
}

.format-highlight {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.05), rgba(79, 70, 229, 0.05));
  border: 1px solid var(--accent);
  border-radius: 12px;
}

.format-details {
  flex: 1;
}

.format-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 8px 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.format-badge {
  background: var(--accent);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.format-description {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 12px 0;
}

.format-features {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.feature-tag {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
}

.format-icon-large {
  font-size: 48px;
  color: var(--accent);
  opacity: 0.8;
}

.project-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Title Block Refresh Button - Fix alignment */
.title-block-refresh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--btn);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.title-block-refresh-btn:hover {
  background: var(--accent);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--accent-shadow);
}

/* Execute Buttons */
.export-execute-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px 24px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 8px;
}

.export-execute-btn:hover {
  background: #4f46e5;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
}

.export-execute-btn:active {
  transform: translateY(0);
}

.export-execute-btn .btn-icon {
  font-size: 18px;
  margin-right: 8px;
  background: transparent !important;
}

/* Ensure all icons have transparent backgrounds */
.btn-icon,
.format-icon,
.orientation-icon,
.action-icon,
.header-icon,
.section-icon,
.label-icon {
  background: transparent !important;
}

/* SVG Icon System - Transparent backgrounds */
.tg-icon {
  background: transparent !important;
}

.tg-icon svg {
  background: transparent !important;
  fill: none;
  stroke: currentColor;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .export-center-content {
    max-width: 95vw;
    max-height: 95vh;
    margin: 10px;
  }
  
  .export-center-header {
    padding: 20px;
  }
  
  .export-center-body {
    padding: 20px;
    gap: 24px;
  }
  
  .export-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  
  .format-selector {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .dpi-selector {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .format-highlight {
    flex-direction: column;
    text-align: center;
    gap: 16px;
  }
}



/* ===============================
   COMPREHENSIVE QA/QC ENHANCEMENTS
   Mobile, Accessibility & Error Handling
   =============================== */

/* Enhanced Mobile Touch Targets */
@media (max-width: 768px) {
  button:not(.export-center-close), .btn, .iconbtn, .toggle, 
  .format-btn, .orientation-btn {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 16px;
  }
  
  input[type="text"], input[type="number"], input[type="email"], 
  input[type="tel"], select, textarea {
    min-height: 44px;
    font-size: 16px;
    padding: 12px 16px;
  }
}

/* Accessibility Focus Indicators */
button:focus-visible, .btn:focus-visible, 
input:focus-visible, select:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.2);
}

/* Error States */
.error-state {
  border-color: var(--error) !important;
  background-color: rgba(239, 68, 68, 0.1);
}

/* Loading States */
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top: 3px solid var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}


/* ===============================
   PERFORMANCE OPTIMIZATION SUITE
   Industry-Standard Web Performance
   =============================== */

/* GPU Acceleration for Smooth Animations */
.gpu-accelerated, .export-center-popup, .toast, 
.floating-window, .sidebar-toggle {
  transform: translateZ(0);
  will-change: transform;
  backface-visibility: hidden;
  perspective: 1000px;
}

/* Optimize Reflows & Repaints */
.no-reflow {
  contain: layout style paint;
}

.repaint-boundary {
  contain: paint;
  isolation: isolate;
}

/* Efficient Transforms */
.smooth-transform {
  will-change: transform;
  transform: translate3d(0, 0, 0);
}

/* Critical Resource Hints */
.preload-content {
  content-visibility: auto;
  contain-intrinsic-size: 300px;
}

/* Lazy Loading Optimization */
.lazy-content {
  content-visibility: auto;
  contain-intrinsic-size: 200px 300px;
}

/* Efficient Scrolling */
.smooth-scroll {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Memory-Efficient Animations */
@keyframes optimizedFadeIn {
  from { opacity: 0; transform: translate3d(0, 10px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

@keyframes optimizedSlideIn {
  from { transform: translate3d(-100%, 0, 0); }
  to { transform: translate3d(0, 0, 0); }
}

/* High-Performance Transitions */
.fast-transition {
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Optimize Font Loading */
@font-face {
  font-family: "InterVariable";
  src: url("https://rsms.me/inter/font-files/InterVariable.woff2") format("woff2");
  font-display: swap;
  font-weight: 100 900;
}

/* Container Queries for Responsive Components */
@container (min-width: 400px) {
  .export-center-body {
    grid-template-columns: 1fr 2fr;
  }
}

/* Reduce Paint Complexity */
.simple-borders {
  border-image: none;
  border-radius: 0;
}

/* Optimize Layer Management */
.composite-layer {
  will-change: transform;
  transform: translateZ(0);
  position: relative;
  z-index: 0;
}

/* Memory Management */
.memory-efficient {
  contain: layout style;
  content-visibility: auto;
}

/* Critical CSS Above-the-Fold */
.above-fold {
  contain: layout;
  content-visibility: visible;
}

/* Defer Non-Critical Styles */
.below-fold {
  content-visibility: auto;
  contain-intrinsic-size: 1px 1000px;
}

/* Efficient Event Handling */
.passive-scroll {
  touch-action: pan-y;
  overscroll-behavior: contain;
}

/* Reduce JavaScript Main Thread Work */
.async-content {
  contain: size layout style paint;
}

/* Optimize for 60fps */
.sixty-fps {
  animation-fill-mode: both;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Network Performance Hints */
.dns-prefetch { }
.preconnect { }
.prefetch { }

/* Service Worker Ready */
.sw-cacheable {
  cache-control: public, max-age=31536000;
}

/* Web Vitals Optimization */

/* Largest Contentful Paint (LCP) */
.lcp-element {
  content-visibility: visible;
  contain: none;
}

/* First Input Delay (FID) */
.fid-optimized {
  pointer-events: auto;
  user-select: auto;
}

/* Cumulative Layout Shift (CLS) */
.cls-stable {
  contain: layout;
  height: auto;
  min-height: 1px;
}

/* Core Web Vitals Improvements */
.vitals-optimized {
  contain: layout style paint;
  content-visibility: auto;
  will-change: auto;
}

/* Bundle Splitting Optimization */
.dynamic-import-ready {
  loading: lazy;
}

/* Memory Leak Prevention */
.memory-safe {
  contain: strict;
  isolation: isolate;
}

/* Critical Path Optimization */
.critical-resource {
  importance: high;
  loading: eager;
}

/* Progressive Enhancement */
.progressive-content {
  content-visibility: auto;
  contain-intrinsic-size: auto 500px;
}

/* WebP/AVIF Image Optimization */
.optimized-image {
  object-fit: cover;
  loading: lazy;
  decoding: async;
}

/* Intersection Observer Ready */
.io-target {
  content-visibility: auto;
  contain-intrinsic-size: 1px 300px;
}

/* Tree Shaking Friendly */
.tree-shake-safe {
  contain: layout style;
}

/* Code Splitting Boundaries */
.chunk-boundary {
  contain: layout;
  isolation: isolate;
}

/* Performance Budget Compliance */
.budget-compliant {
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

/* ===============================
   ADVANCED PERFORMANCE PATTERNS
   =============================== */

/* Virtualization Support */
.virtual-scroll {
  contain: strict;
  overflow: auto;
  scroll-behavior: auto;
}

/* Efficient Re-rendering */
.stable-layout {
  contain: layout size;
  transform: translateZ(0);
}

/* Micro-optimization for Frequent Updates */
.hot-path {
  will-change: transform, opacity;
  contain: layout style paint;
}

/* Debounced Interactions */
.debounced {
  pointer-events: none;
  transition: pointer-events 0.1s;
}

.debounced:not(:hover) {
  pointer-events: auto;
}

/* Efficient Modal Management */
.modal-performance {
  contain: layout style paint;
  will-change: transform, opacity;
  isolation: isolate;
}

/* Bundle Analysis Ready */
.analyzable {
  /* Webpack Bundle Analyzer markers */
  /* Lighthouse performance markers */
  /* Chrome DevTools markers */
}
