/* ==========================================================================
   MapZone PWA — Modern Responsive Stylesheet
   ========================================================================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  /* Dark Theme Colors (Default) */
  --bg-app: #0b1120;
  --bg-surface: #131d31;
  --bg-surface-elevated: #1e293b;
  --bg-input: #0f172a;
  --border-color: rgba(255, 255, 255, 0.12);
  --border-subtle: rgba(255, 255, 255, 0.06);

  --text-main: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: rgba(2, 132, 199, 0.18);
  --primary-glow: rgba(2, 132, 199, 0.4);

  --accent-green: #10b981;
  --accent-green-bg: rgba(16, 185, 129, 0.16);
  --accent-danger: #ef4444;
  --accent-danger-hover: #dc2626;
  --accent-danger-bg: rgba(239, 68, 68, 0.16);
  --accent-warning: #f59e0b;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.35);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 20px rgba(2, 132, 199, 0.35);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --header-height: 60px;
  --sidebar-width: 410px;
  --transition-fast: 160ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 240ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Overrides */
body.theme-light {
  --bg-app: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f8fafc;
  --bg-input: #ffffff;
  --border-color: rgba(0, 0, 0, 0.12);
  --border-subtle: rgba(0, 0, 0, 0.06);

  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: rgba(2, 132, 199, 0.12);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.15);
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  outline: none;
}

/* Layout */
.app-layout {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
}

/* ==========================================================================
   Header Bar
   ========================================================================== */
.app-header {
  height: var(--header-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
  z-index: 1000;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  user-select: none;
}

.brand-logo {
  width: 36px;
  height: 36px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #38bdf8, #0284c7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.1;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--text-secondary);
  display: block;
}

/* Search Bar */
.header-search {
  flex: 1;
  max-width: 480px;
  position: relative;
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 6px 14px;
  gap: 8px;
  transition: all var(--transition-fast);
}

.search-input-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.search-icon {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-input-wrapper input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 0.88rem;
  color: var(--text-main);
}

.search-input-wrapper input::placeholder {
  color: var(--text-muted);
}

.clear-search-btn {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 2px 4px;
  border-radius: var(--radius-full);
}
.clear-search-btn:hover {
  color: var(--text-main);
}

.search-results-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 320px;
  overflow-y: auto;
  z-index: 1050;
}

.search-result-item {
  padding: 10px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background var(--transition-fast);
}
.search-result-item:last-child {
  border-bottom: none;
}
.search-result-item:hover {
  background: var(--primary-light);
  color: var(--primary);
}

/* Header Right Actions */
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hdr-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 500;
  transition: all var(--transition-fast);
}
.hdr-btn svg {
  width: 16px;
  height: 16px;
}
.hdr-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}
.hdr-btn.icon-only {
  padding: 8px;
}
.hdr-btn.highlight-btn {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #ffffff;
  border: none;
  box-shadow: var(--shadow-sm);
}
.hdr-btn.highlight-btn:hover {
  opacity: 0.95;
  box-shadow: var(--shadow-glow);
}

.mobile-toggle {
  display: none;
}

/* ==========================================================================
   Main Area: Map + Sidebar
   ========================================================================== */
.app-main {
  display: flex;
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* Map Container: Independent flex child strictly occupying space to the left of sidebar */
.map-container {
  flex: 1;
  height: 100%;
  width: 100%;
  position: relative;
  overflow: hidden;
  min-width: 0;
}

.map-view {
  height: 100%;
  width: 100%;
  background: #0f172a;
}

/* Floating Bars on Map */
.map-floating-bar {
  position: absolute;
  z-index: 990;
  display: flex;
  gap: 8px;
  align-items: center;
}

.map-floating-bar.top-left {
  top: 14px;
  left: 14px;
}

.map-floating-bar.top-right {
  top: 14px;
  right: 14px;
  max-width: calc(100% - 28px);
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 12px;
  background: rgba(19, 29, 49, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-fast);
}
.tool-btn svg {
  width: 16px;
  height: 16px;
}
.tool-btn:hover:not(:disabled) {
  background: rgba(2, 132, 199, 0.25);
  border-color: var(--primary);
  color: var(--primary);
}
.tool-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}
.tool-btn.danger:hover:not(:disabled) {
  background: var(--accent-danger-bg);
  border-color: var(--accent-danger);
  color: var(--accent-danger);
}
.tool-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Layer Pill Button */
.layer-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  background: rgba(19, 29, 49, 0.88);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-fast);
}
.layer-pill-btn svg {
  width: 18px;
  height: 18px;
  color: var(--primary);
}
.layer-pill-btn:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

/* Layer Dropdown Card */
.layer-dropdown-card {
  position: absolute;
  top: 48px;
  right: 0;
  width: 320px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 16px;
  z-index: 1050;
  backdrop-filter: blur(16px);
  animation: fadeInDown 180ms ease-out;
}

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

.dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.dropdown-header h4 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
}
.close-card-btn {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 4px;
}
.close-card-btn:hover {
  color: var(--text-main);
}

.layer-options-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.layer-option-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px;
  background: var(--bg-surface-elevated);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: center;
  position: relative;
  transition: all var(--transition-fast);
}
.layer-option-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}
.layer-option-card.active {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 1px var(--primary);
}

.layer-thumb {
  width: 100%;
  height: 48px;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  background-size: cover;
  background-position: center;
}

/* CSS Mock previews for layer thumbnails */
.thumb-google-hybrid { background: linear-gradient(135deg, #1e3a1f 0%, #2e4a2d 50%, #405c3c 100%); border: 1px solid #5a7d55; }
.thumb-google-roads  { background: linear-gradient(135deg, #e5e7eb 0%, #cbd5e1 50%, #94a3b8 100%); }
.thumb-google-terrain{ background: linear-gradient(135deg, #d4a373 0%, #ccd5ae 50%, #e9edc9 100%); }
.thumb-osm           { background: linear-gradient(135deg, #bfdbfe 0%, #bbf7d0 50%, #fed7aa 100%); }
.thumb-esri          { background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%); border: 1px solid #475569; }
.thumb-carto-light   { background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%); }
.thumb-carto-dark    { background: linear-gradient(135deg, #020617 0%, #0f172a 100%); }
.thumb-topo          { background: linear-gradient(135deg, #bbf7d0 0%, #fef08a 50%, #fbcfe8 100%); }

.layer-name {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.2;
}

.layer-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 0.6rem;
  background: var(--primary);
  color: #fff;
  padding: 1px 4px;
  border-radius: 4px;
}

.dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: 12px 0;
}

.overlay-options h4 {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-main);
  cursor: pointer;
  margin-bottom: 8px;
}
.checkbox-label input[type="checkbox"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
}

/* Map Status Tip */
.map-status-tip {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(19, 29, 49, 0.88);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 6px 16px;
  font-size: 0.78rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-md);
  z-index: 990;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

/* ==========================================================================
   Sidebar / Drawer Panel
   ========================================================================== */
.app-sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 995;
  box-shadow: -2px 0 10px rgba(0,0,0,0.15);
  transition: transform var(--transition-normal);
}

.drawer-handle-bar {
  display: none;
  justify-content: center;
  padding: 8px 0 4px;
  cursor: grab;
}
.drawer-handle {
  width: 44px;
  height: 5px;
  background: var(--text-muted);
  border-radius: var(--radius-full);
}

.sidebar-scrollable {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-section {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px;
}

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

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title svg {
  width: 18px;
  height: 18px;
  color: var(--primary);
}
.section-title h3 {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-main);
}

.text-link-btn {
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 600;
}
.text-link-btn:hover {
  text-decoration: underline;
}

/* Primary Big CTA Button (Google Maps Share) */
.primary-action-section {
  padding: 0;
  background: transparent;
  border: none;
}

.big-cta-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  font-size: 0.95rem;
  text-align: left;
  transition: all var(--transition-fast);
}

.share-gmap-btn {
  background: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(2, 132, 199, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.share-gmap-btn:hover {
  box-shadow: 0 6px 22px rgba(2, 132, 199, 0.6);
  transform: translateY(-2px);
}

.cta-icon-wrapper {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.cta-icon-wrapper svg {
  width: 22px;
  height: 22px;
}

.cta-text {
  display: flex;
  flex-direction: column;
}
.cta-text strong {
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.cta-text span {
  font-size: 0.74rem;
  opacity: 0.88;
  margin-top: 2px;
}

/* Metrics Dashboard Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.metric-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
}
.metric-card.highlight {
  grid-column: span 2;
  border-color: var(--primary);
  background: linear-gradient(145deg, var(--bg-surface) 0%, rgba(2, 132, 199, 0.08) 100%);
  box-shadow: 0 0 0 1px var(--primary-glow);
}
.metric-card.full-width {
  grid-column: span 2;
}

.metric-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.metric-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.unit-selector {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 2px 4px;
  outline: none;
  cursor: pointer;
}

.metric-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}
.metric-card.highlight .metric-value {
  font-size: 1.6rem;
  color: #38bdf8;
}
.metric-value.mono {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 500;
  word-break: break-all;
}

.metric-sub {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 3px;
}

.tiny-copy-btn {
  font-size: 0.68rem;
  padding: 2px 6px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}
.tiny-copy-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
}

/* Accordion for Unit Conversions */
.conversions-accordion {
  margin-top: 10px;
  border-top: 1px dashed var(--border-color);
  padding-top: 8px;
}
.conversions-accordion summary {
  font-size: 0.75rem;
  color: var(--primary);
  cursor: pointer;
  font-weight: 600;
  user-select: none;
}
.conversions-table {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
  background: var(--bg-surface);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}
.conv-row {
  display: flex;
  justify-content: space-between;
  color: var(--text-secondary);
}
.conv-row strong {
  color: var(--text-main);
  font-family: var(--font-mono);
}

/* Tool Actions Buttons */
.action-buttons-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.sec-action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
  transition: all var(--transition-fast);
}
.sec-action-btn svg {
  width: 16px;
  height: 16px;
  color: var(--primary);
  flex-shrink: 0;
}
.sec-action-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}
.sec-action-btn.highlight-sec-btn {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.2) 0%, rgba(37, 99, 235, 0.15) 100%);
  border-color: var(--primary);
  color: #38bdf8;
}
.sec-action-btn.highlight-sec-btn:hover {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.35) 0%, rgba(37, 99, 235, 0.25) 100%);
  transform: translateY(-1px);
}
.sec-action-btn.highlight-import-btn {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2) 0%, rgba(5, 150, 105, 0.15) 100%);
  border-color: #10b981;
  color: #34d399;
}
.sec-action-btn.highlight-import-btn:hover {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.35) 0%, rgba(5, 150, 105, 0.25) 100%);
  transform: translateY(-1px);
}
.sec-action-btn.highlight-import-btn svg {
  color: #34d399;
}

.section-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Single Coordinate Input Form */
.single-coord-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px;
  box-sizing: border-box;
  width: 100%;
}

.form-title {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 8px;
}

.form-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  width: 100%;
  box-sizing: border-box;
}
.input-group {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.input-group label {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.input-group input, .form-row input {
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: 0.8rem;
  color: var(--text-main);
  font-family: var(--font-mono);
  outline: none;
}
.input-group input:focus, .form-row input:focus {
  border-color: var(--primary);
}

.form-row.full-paste {
  margin-bottom: 0;
  display: flex;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
}
.form-row.full-paste input {
  flex: 1 1 0;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}
.submit-coord-btn {
  flex-shrink: 0;
  white-space: nowrap;
  padding: 6px 14px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  transition: background var(--transition-fast);
}
.submit-coord-btn:hover {
  background: var(--primary-hover);
}

/* Points List */
.points-list {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.point-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.76rem;
  transition: all var(--transition-fast);
}
.point-item:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.point-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.point-badge {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}
.point-coords {
  display: flex;
  flex-direction: column;
  font-family: var(--font-mono);
}
.point-dist {
  font-size: 0.66rem;
  color: var(--text-muted);
}

.point-actions {
  display: flex;
  gap: 4px;
}
.point-act-btn {
  padding: 4px;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
}
.point-act-btn:hover {
  color: var(--text-main);
}
.point-act-btn.del-btn:hover {
  color: var(--accent-danger);
}

.empty-state {
  text-align: center;
  padding: 20px 10px;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.empty-state span {
  display: block;
  font-size: 0.72rem;
  margin-top: 4px;
}

/* Export Grid */
.export-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.export-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  text-align: center;
  transition: all var(--transition-fast);
}
.export-btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.file-ext {
  font-weight: 700;
  font-size: 0.84rem;
  color: #38bdf8;
}
.file-desc {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
  animation: fadeIn 150ms ease-out;
}

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

.modal-card {
  width: 100%;
  max-width: 560px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
  animation: scaleUp 180ms ease-out;
}
.modal-card.modal-small {
  max-width: 400px;
}

@keyframes scaleUp {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-title-group svg {
  width: 20px;
  height: 20px;
  color: var(--primary);
}
.modal-title-group h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}
.modal-close-btn {
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.modal-close-btn:hover {
  color: var(--text-main);
  background: var(--bg-surface-elevated);
}

.modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface-elevated);
}
.modal-tab {
  flex: 1;
  padding: 10px 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  text-align: center;
}
.modal-tab:hover {
  color: var(--text-main);
}
.modal-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--bg-surface);
}

.modal-body {
  padding: 18px;
  overflow-y: auto;
}

.info-alert {
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 0.8rem;
  color: var(--text-main);
}
.info-alert strong {
  display: block;
  font-size: 0.84rem;
  margin-bottom: 3px;
  color: #38bdf8;
}
.info-alert.highlight {
  background: rgba(16, 185, 129, 0.12);
  border-color: var(--accent-green);
}
.info-alert.highlight strong {
  color: var(--accent-green);
}

/* Share modal actions */
.share-actions-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.primary-gmap-link-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
  color: #ffffff;
  padding: 12px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.92rem;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
  transition: all var(--transition-fast);
}
.primary-gmap-link-btn svg {
  width: 18px;
  height: 18px;
}
.primary-gmap-link-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(2, 132, 199, 0.5);
}

.secondary-gmap-link-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 10px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.85rem;
  text-decoration: none;
  transition: all var(--transition-fast);
}
.secondary-gmap-link-btn svg {
  width: 16px;
  height: 16px;
  color: var(--accent-danger);
}
.secondary-gmap-link-btn:hover {
  border-color: var(--accent-danger);
  color: var(--accent-danger);
}

.link-copy-box {
  display: flex;
  gap: 8px;
  align-items: center;
}
.link-copy-box input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-main);
  outline: none;
}
.copy-btn {
  padding: 8px 14px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-main);
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.copy-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.divider-text {
  text-align: center;
  font-size: 0.74rem;
  color: var(--text-muted);
  position: relative;
  margin: 4px 0;
}

/* My Maps step items */
.mymaps-steps-guide {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.step-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
}
.step-num {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}
.step-body {
  flex: 1;
}
.step-body strong {
  font-size: 0.85rem;
  color: var(--text-main);
}
.step-body p {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 2px;
  margin-bottom: 8px;
}
.download-step-btn, .external-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.download-step-btn {
  background: var(--primary);
  color: #ffffff;
}
.external-link-btn {
  background: var(--accent-green);
  color: #ffffff;
}

/* QR Code tab */
.qr-share-container {
  display: flex;
  gap: 20px;
  align-items: center;
}
.qr-code-box {
  width: 160px;
  height: 160px;
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.qr-code-box canvas, .qr-code-box img {
  width: 100% !important;
  height: 100% !important;
}

.qr-instructions {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.qr-badge {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--primary-light);
  color: #38bdf8;
  padding: 2px 6px;
  border-radius: 4px;
}
.qr-instructions p {
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.native-share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  transition: all var(--transition-fast);
}
.native-share-btn svg {
  width: 16px;
  height: 16px;
  color: var(--primary);
}
.native-share-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

/* Batch modal inputs */
.field-hint {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
#batchTextarea,
#importTextarea {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px;
  font-size: 0.82rem;
  font-family: var(--font-mono);
  color: var(--text-main);
  resize: vertical;
  outline: none;
  transition: border-color var(--transition-fast);
}
#batchTextarea:focus {
  border-color: var(--primary);
}
#importTextarea:focus {
  border-color: #10b981;
}
.batch-options-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0 12px;
}
.highlight-checkbox {
  background: rgba(2, 132, 199, 0.12);
  border: 1px solid rgba(2, 132, 199, 0.3);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.highlight-checkbox span strong {
  color: #38bdf8;
}
.batch-preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.batch-progress-text {
  font-size: 0.76rem;
  color: #38bdf8;
  font-weight: 600;
}

/* ==========================================================================
   Import KML / GeoJSON Modal Styles
   ========================================================================== */
.modal-card.modal-import {
  max-width: 660px;
  width: 95%;
}
.kml-dropzone {
  border: 2px dashed rgba(16, 185, 129, 0.45);
  background: rgba(16, 185, 129, 0.05);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: 8px;
}
.kml-dropzone:hover,
.kml-dropzone.dragover {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.12);
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.2);
}
.dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.dropzone-icon {
  width: 28px !important;
  height: 28px !important;
  max-width: 28px !important;
  max-height: 28px !important;
  color: #10b981 !important;
  flex-shrink: 0;
  display: block;
  margin: 0 auto 2px;
}
.dropzone-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
}
.dropzone-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.browse-kml-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(16, 185, 129, 0.18);
  border: 1px solid #10b981;
  color: #34d399;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  margin-top: 2px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.browse-kml-btn:hover {
  background: #10b981;
  color: #ffffff;
}
.dropzone-file-name {
  margin-top: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #34d399;
  background: rgba(16, 185, 129, 0.18);
  border: 1px solid rgba(16, 185, 129, 0.35);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  display: inline-block;
  word-break: break-all;
}
.import-or-divider {
  display: flex;
  align-items: center;
  margin: 10px 0 8px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
}
.import-or-divider::before,
.import-or-divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid var(--border-color);
}
.import-or-divider span {
  padding: 0 10px;
}
.import-options-box {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin: 12px 0;
}
.radio-options-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.radio-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-main);
  cursor: pointer;
}
.radio-label input[type="radio"] {
  accent-color: #10b981;
}
.import-preview-box {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 12px;
}
.preview-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(16, 185, 129, 0.2);
}
.preview-type-badge {
  background: #10b981;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
}
.preview-zone-name {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preview-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.preview-stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.preview-stat-item .stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}
.preview-stat-item .stat-val {
  font-size: 0.82rem;
  font-weight: 700;
  color: #34d399;
}

.modal-import .modal-footer-btns {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: nowrap;
}
.modal-import .modal-footer-btns button {
  white-space: nowrap !important;
  flex: 0 0 auto;
  padding: 9px 16px;
  font-size: 0.84rem;
}

@media (max-width: 600px) {
  .preview-stats-grid {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .modal-import .modal-footer-btns {
    flex-direction: column;
    width: 100%;
  }
  .modal-import .modal-footer-btns button {
    width: 100%;
    white-space: normal !important;
  }
}

/* ==========================================================================
   Distance & Routing Modal Styles
   ========================================================================== */
.route-point-box {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
}
.point-tag {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  color: #ffffff;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.point-tag.start-tag { background: #10b981; }
.point-tag.end-tag   { background: #ef4444; }

.point-inputs {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.point-inputs label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}
.route-select {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: 0.8rem;
  color: var(--text-main);
  outline: none;
}
.route-coord-input {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-main);
  outline: none;
}

.route-swap-row {
  display: flex;
  justify-content: center;
  margin: 6px 0;
}
.swap-points-btn {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 3px 12px;
  transition: all var(--transition-fast);
}
.swap-points-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

.section-sub-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  margin-top: 14px;
  margin-bottom: 6px;
}

.vehicle-pills {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.vehicle-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-surface-elevated);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.vehicle-pill:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.vehicle-pill.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: #38bdf8;
  box-shadow: 0 0 0 1px var(--primary);
}
.vehicle-pill .v-icon {
  font-size: 1.1rem;
}

.route-calc-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  gap: 12px;
}
.unit-toggle-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.unit-btn {
  padding: 5px 10px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.unit-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.distance-result-card {
  margin-top: 14px;
  background: linear-gradient(145deg, var(--bg-surface-elevated) 0%, rgba(2, 132, 199, 0.12) 100%);
  border: 1px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 14px;
  animation: fadeInDown 200ms ease-out;
}

/* Dual Distance Display: Theoretical (Straight) vs Real Road (Avoiding obstacles) */
.dual-distance-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
.dual-dist-col {
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
}
.dual-dist-col.highlight-orange {
  border-color: rgba(245, 158, 11, 0.55);
  background: rgba(245, 158, 11, 0.12);
}
.dist-col-tag {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 2px;
}
.dual-dist-col.highlight-orange .dist-col-tag {
  color: #fbbf24;
}
.dist-col-num {
  font-size: 1.25rem;
  font-weight: 800;
  color: #38bdf8;
  line-height: 1.2;
}
.dual-dist-col.highlight-orange .dist-col-num {
  color: #f59e0b;
  text-shadow: 0 0 10px rgba(245, 158, 11, 0.35);
}
.dist-col-sub {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 2px;
}
.dual-dist-col.highlight-orange .dist-col-sub {
  color: #fcd34d;
  font-weight: 600;
}

.dist-duration-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  margin-bottom: 8px;
}
.dur-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 600;
}
.dur-val {
  font-size: 1.15rem;
  font-weight: 800;
  color: #10b981;
}

.route-color-legend {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  margin-top: 8px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.legend-dot {
  width: 14px;
  height: 4px;
  border-radius: 2px;
  flex-shrink: 0;
}
.legend-dot.orange {
  background: #ff9800;
  box-shadow: 0 0 6px rgba(255, 152, 0, 0.8);
}
.legend-dot.cyan {
  background: #38bdf8;
}

.toggle-real-road-btn {
  width: 100%;
  margin-bottom: 10px;
  padding: 8px 10px;
  background: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.toggle-real-road-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(245, 158, 11, 0.5);
}
.toggle-real-road-btn.active {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}

.edge-route-btn {
  padding: 2px 7px;
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #fbbf24;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.edge-route-btn:hover {
  background: #f59e0b;
  color: #0f172a;
}
.dist-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.dist-primary-box {
  display: flex;
  flex-direction: column;
}
.dist-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.dist-values-group {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 2px;
}
.dist-main-num {
  font-size: 1.6rem;
  font-weight: 800;
  color: #38bdf8;
  letter-spacing: -0.02em;
}
.dist-sub-num {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.dist-duration-box {
  text-align: right;
  display: flex;
  flex-direction: column;
}
.dist-duration-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent-green);
  margin-top: 2px;
}

.route-mode-desc {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border-subtle);
}

.dist-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.route-gmap-btn {
  flex: 1;
  text-align: center;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #ffffff;
  padding: 9px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}
.route-gmap-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}
.route-clear-btn {
  padding: 9px 12px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.route-clear-btn:hover {
  color: var(--accent-danger);
  border-color: var(--accent-danger);
}

.parse-preview-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-green);
  background: var(--accent-green-bg);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}
.modal-footer-btns {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.primary-btn {
  padding: 9px 18px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  transition: background var(--transition-fast);
}
.primary-btn:hover {
  background: var(--primary-hover);
}
.secondary-btn {
  padding: 9px 16px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}
.secondary-btn:hover {
  background: var(--border-subtle);
}

/* Style modal */
.form-group {
  margin-bottom: 14px;
}
.form-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-group input[type="text"] {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.85rem;
  color: var(--text-main);
  outline: none;
}
.color-presets-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.color-dot {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  transition: transform var(--transition-fast);
}
.color-dot:hover {
  transform: scale(1.15);
}
.color-dot.active {
  border-color: #ffffff;
  box-shadow: 0 0 0 2px var(--primary);
}
#customColorPicker {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  cursor: pointer;
  background: transparent;
}
.slider-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.slider-head span {
  font-weight: 700;
  color: var(--primary);
}
input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}

/* Help Modal Content */
.help-content h4 {
  font-size: 0.88rem;
  color: #38bdf8;
  margin: 12px 0 6px;
}
.help-content h4:first-child {
  margin-top: 0;
}
.help-content ul {
  padding-left: 20px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
.help-content li {
  margin-bottom: 6px;
}
.help-content strong {
  color: var(--text-main);
}

/* Leaflet Custom Marker DivIcon */
.custom-vertex-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
  font-size: 11px;
  border: 2px solid #ffffff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.45);
  cursor: grab;
  transition: transform var(--transition-fast);
}
.custom-vertex-marker:hover {
  transform: scale(1.2);
  background: #38bdf8;
}
.custom-vertex-marker:active {
  cursor: grabbing;
}
.custom-vertex-marker.first-vertex {
  background: #10b981;
}

/* Toast Notification */
.toast-notification {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 0.84rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 3000;
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition-normal);
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast-notification.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.toast-notification.success {
  border-color: var(--accent-green);
  color: var(--accent-green);
}
.toast-notification.error {
  border-color: var(--accent-danger);
  color: var(--accent-danger);
}

/* Big Deduplicate Button in Sidebar */
.big-dedup-action-btn {
  width: 100%;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.18) 0%, rgba(239, 68, 68, 0.14) 100%);
  border: 1.5px solid #f59e0b;
  border-radius: var(--radius-md);
  color: #fbbf24;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition-fast);
}
.big-dedup-action-btn:hover {
  background: #f59e0b;
  color: #0f172a;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.45);
  transform: translateY(-1px);
}

/* Embedded Live Distance Section */
.live-distance-section {
  border-color: var(--primary) !important;
  background: linear-gradient(145deg, var(--bg-surface-elevated) 0%, rgba(2, 132, 199, 0.09) 100%) !important;
  box-shadow: 0 0 0 1px var(--primary-glow);
}
.live-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  background: rgba(16, 185, 129, 0.18);
  color: #10b981;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}
.section-sub-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  margin-bottom: 6px;
}
.section-sub-head .section-sub-label {
  margin: 0;
}
.unit-toggle-mini {
  display: flex;
  gap: 3px;
}
.unit-mini-btn {
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
}
.unit-mini-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}
.vehicle-pills.four-col {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.vehicle-pills.four-col .vehicle-pill {
  flex-direction: column;
  padding: 8px 4px;
  text-align: center;
  gap: 2px;
}
.vehicle-pills.four-col .vehicle-pill .v-icon {
  font-size: 1.25rem;
}
.vehicle-pills.four-col .vehicle-pill .v-name {
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.1;
}

.vehicle-pills.five-col {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}
.vehicle-pills.five-col .vehicle-pill {
  flex-direction: column;
  padding: 7px 2px;
  text-align: center;
  gap: 2px;
}
.vehicle-pills.five-col .vehicle-pill .v-icon {
  font-size: 1.15rem;
}
.vehicle-pills.five-col .vehicle-pill .v-name {
  font-size: 0.63rem;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
}

/* ==========================================================================
   Floating Top-Right Vehicle Bar & Units
   ========================================================================== */
.floating-vehicle-bar {
  display: flex;
  align-items: center;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 3px 5px;
  gap: 3px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
}

.floating-vehicle-pills {
  display: flex;
  align-items: center;
  gap: 3px;
}

.top-vehicle-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.top-vehicle-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.top-vehicle-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 0 14px var(--primary-glow);
}

.top-vehicle-btn .v-emoji {
  font-size: 0.95rem;
  line-height: 1;
}

.top-vehicle-btn .v-text {
  line-height: 1;
}

.floating-unit-toggle {
  display: flex;
  align-items: center;
  border-left: 1px solid var(--border-color);
  padding-left: 5px;
  margin-left: 2px;
  gap: 2px;
}

.top-unit-btn {
  padding: 4px 7px;
  font-size: 0.72rem;
  font-weight: 800;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.top-unit-btn:hover {
  color: var(--text-main);
}

.top-unit-btn.active {
  background: rgba(2, 132, 199, 0.28);
  border-color: var(--primary);
  color: #38bdf8;
}

.collapse-vehicle-bar-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: 0.72rem;
  margin-left: 3px;
  transition: all var(--transition-fast);
}

.collapse-vehicle-bar-btn:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #f87171;
}

.restore-vehicle-bar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 5px 12px;
  color: var(--text-main);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  transition: all var(--transition-fast);
}

.restore-vehicle-bar-btn:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--primary);
  color: #38bdf8;
  transform: translateY(-1px);
}

/* ==========================================================================
   Edge Distance & Travel Time Badges (Leaflet Map)
   ========================================================================== */
.edge-dist-badge-container {
  background: transparent !important;
  border: none !important;
}

.edge-dist-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(56, 189, 248, 0.6);
  border-radius: var(--radius-full);
  padding: 3px 9px;
  color: #ffffff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(2, 132, 199, 0.35);
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
  transform: translate(-50%, -50%);
}

.edge-dist-badge:hover {
  transform: translate(-50%, -50%) scale(1.08);
  border-color: #38bdf8;
  box-shadow: 0 6px 18px rgba(2, 132, 199, 0.65);
}

.edge-dist-badge.only-dist {
  padding: 2px 8px;
  background: rgba(15, 23, 42, 0.88);
  border-color: rgba(56, 189, 248, 0.45);
}

.edge-dist-badge .badge-dist {
  color: #f8fafc;
  font-weight: 800;
}

.edge-dist-badge .badge-sep {
  color: #64748b;
  font-size: 0.65rem;
}

.edge-dist-badge .badge-time {
  color: #38bdf8;
  font-weight: 700;
}

.edge-popup {
  padding: 2px 4px;
  font-size: 0.82rem;
  line-height: 1.4;
  color: #0f172a;
}
.theme-dark .edge-popup {
  color: #f8fafc;
}
.edge-popup-gmap-link {
  display: inline-block;
  padding: 4px 8px;
  background: #0284c7;
  color: #ffffff !important;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
}
.edge-popup-gmap-link:hover {
  background: #0369a1;
}

/* ==========================================================================
   Sidebar: Consecutive Edges Table
   ========================================================================== */
.edges-summary-section {
  border-color: rgba(56, 189, 248, 0.3) !important;
  background: linear-gradient(145deg, var(--bg-surface-elevated) 0%, rgba(2, 132, 199, 0.08) 100%) !important;
}

.edges-summary-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.edges-table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border-subtle);
}

.edges-table-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.edges-summary-section .section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: nowrap;
}

.edges-summary-section .section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.edges-summary-section .section-title h3 {
  white-space: nowrap;
  font-size: 0.88rem;
}

.edges-vehicle-badge {
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(2, 132, 199, 0.2);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #38bdf8;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  white-space: nowrap;
  flex-shrink: 0;
}

.edges-list-scroll {
  max-height: 200px;
  overflow-y: auto;
}

.edge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  font-size: 0.78rem;
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
}
.edge-row:hover {
  background: rgba(2, 132, 199, 0.08);
}
.edge-row:last-child {
  border-bottom: none;
}

.edge-row-left {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
}

.edge-row-label {
  font-weight: 700;
  color: var(--text-main);
}

.edge-row-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.edge-row-dist {
  font-weight: 800;
  color: #38bdf8;
}

.edge-row-time {
  color: #10b981;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.12);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
}

.edges-total-footer {
  padding: 9px 12px;
  background: rgba(2, 132, 199, 0.14);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
}
.edges-total-footer strong {
  color: var(--text-main);
}
.edges-total-values {
  text-align: right;
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.edges-total-dist {
  color: #38bdf8;
  font-weight: 800;
}
.edges-total-time {
  color: #10b981;
  font-weight: 700;
}

/* ==========================================================================
   Vertices Actions: Deduplication & Smart Sort
   ========================================================================== */
.polygon-actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
  align-items: stretch;
}

.big-dedup-action-btn,
.smart-sort-btn {
  width: 100%;
  height: 40px;
  box-sizing: border-box;
  padding: 0 6px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.big-dedup-action-btn {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #0f172a;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}
.big-dedup-action-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(245, 158, 11, 0.45);
}

.smart-sort-btn {
  background: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
}
.smart-sort-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(2, 132, 199, 0.5);
}

.cross-polygon-alert {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.45);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 10px;
  animation: pulseAlert 2.2s infinite ease-in-out;
}

@keyframes pulseAlert {
  0%, 100% { border-color: rgba(239, 68, 68, 0.4); }
  50% { border-color: rgba(239, 68, 68, 0.9); box-shadow: 0 0 12px rgba(239, 68, 68, 0.35); }
}

.cross-polygon-alert .cross-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}

.cross-polygon-alert .cross-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.75rem;
  color: #fca5a5;
  line-height: 1.3;
}
.cross-polygon-alert .cross-text strong {
  color: #f87171;
  font-size: 0.8rem;
}

.quick-fix-cross-btn {
  background: #ef4444;
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}
.quick-fix-cross-btn:hover {
  background: #dc2626;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.5);
}

/* Vertex List Items & Reorder / Edit buttons */
.point-actions {
  display: flex;
  align-items: center;
  gap: 3px;
}

.point-act-btn {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 700;
  transition: all var(--transition-fast);
  padding: 0;
}

.point-act-btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.point-act-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.point-act-btn.del-btn:hover {
  border-color: var(--accent-danger);
  color: var(--accent-danger);
  background: var(--accent-danger-bg);
}

.point-act-btn.edit-btn:hover {
  border-color: #f59e0b;
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.15);
}

/* Responsive updates for Floating Vehicle Bar */
@media (max-width: 680px) {
  .map-floating-bar.top-right {
    top: 8px;
    right: 8px;
    gap: 6px;
  }
  .top-vehicle-btn {
    padding: 5px 7px;
  }
  .top-vehicle-btn .v-text {
    display: none;
  }
  .polygon-actions-row {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
@media (max-width: 900px) {
  :root {
    --sidebar-width: 350px;
  }
}

@media (max-width: 768px) {
  .app-header {
    padding: 0 10px;
  }
  .brand-subtitle {
    display: none;
  }
  .header-search {
    max-width: 200px;
  }
  .hdr-btn .btn-text {
    display: none;
  }
  .mobile-toggle {
    display: inline-flex;
  }

  .app-main {
    flex-direction: column;
  }

  /* Turn sidebar into bottom drawer on mobile */
  .app-sidebar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 60vh;
    border-left: none;
    border-top: 1px solid var(--border-color);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(calc(100% - 68px));
  }
  .app-sidebar.open {
    transform: translateY(0);
  }
  .drawer-handle-bar {
    display: flex;
  }

  .map-floating-bar.top-left {
    top: 10px;
    left: 10px;
  }
  .map-floating-bar.top-right {
    top: 10px;
    right: 10px;
  }
  .layer-dropdown-card {
    width: 280px;
  }
  .qr-share-container {
    flex-direction: column;
  }
}
