/* ============================================================
   mapFTTH — app.css
   ============================================================ */

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

:root {
  --sidebar-w: 250px;
  --topbar-h: 60px;
  --bg-sidebar: #0f172a;
  --bg-sidebar-hover: #1e293b;
  --bg-sidebar-active: #2563eb;
  --text-sidebar: #94a3b8;
  --text-sidebar-active: #fff;
  --bg-content: #f1f5f9;
  --bg-card: #fff;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0891b2;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --radius: 8px;
  --radius-sm: 4px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-content);
  line-height: 1.5;
}

/* ── Layout ───────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

.main-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin-left: var(--sidebar-w);
  transition: margin-left .25s;
}

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  z-index: 1100;
  transition: transform .25s;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 44px 16px 16px; /* right pad leaves room for close btn */
  border-bottom: 1px solid #1e293b;
  text-decoration: none;
  position: relative;
}
.sidebar-logo svg { flex-shrink: 0; }
.sidebar-logo span {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.3px;
}
.sidebar-logo small {
  display: block;
  font-size: 10px;
  font-weight: 400;
  color: var(--text-sidebar);
  letter-spacing: .5px;
  text-transform: uppercase;
}

.sidebar-nav { flex: 1; padding: 12px 0; }

.nav-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #475569;
  padding: 12px 16px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text-sidebar);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 0;
  transition: background .15s, color .15s;
  position: relative;
}
.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: #fff;
}
.nav-item.active {
  background: var(--bg-sidebar-active);
  color: var(--text-sidebar-active);
}
.nav-item svg { flex-shrink: 0; opacity: .8; }
.nav-item.active svg { opacity: 1; }

.nav-group-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--text-sidebar);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-group-toggle:hover { background: var(--bg-sidebar-hover); color: #fff; }
.nav-group-toggle span { flex: 1; text-align: left; }
.nav-group-toggle svg { flex-shrink: 0; opacity: .8; }
.nav-group-chevron { margin-left: auto; transition: transform .15s; }
.nav-group.open .nav-group-chevron { transform: rotate(90deg); }

.nav-group-items {
  max-height: 0;
  overflow: hidden;
  transition: max-height .2s ease;
}
.nav-group.open .nav-group-items { max-height: 500px; }

.dash-collapsible-header {
  width: 100%;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font: inherit;
  text-align: left;
}
.dash-collapsible-chevron { transition: transform .15s; opacity: .6; }
.dash-collapsible.open .dash-collapsible-chevron { transform: rotate(90deg); }
.dash-collapsible-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height .2s ease;
}
.dash-collapsible.open .dash-collapsible-body { max-height: 2000px; }
#massivos-live-dot { background: #dc2626; animation: massivos-pulse 1.8s ease-in-out infinite; }
@keyframes massivos-pulse {
  0%, 100% { opacity: .35; }
  50%      { opacity: 1; }
}

.sidebar-project {
  margin: 0 12px 8px;
  padding: 10px 12px;
  background: rgba(37,99,235,.15);
  border: 1px solid rgba(37,99,235,.35);
  border-radius: 8px;
}
.sidebar-project-label { font-size: 10px; color: #94a3b8; text-transform: uppercase; letter-spacing: .05em; }
.sidebar-project-name  { font-size: 13px; color: #fff; font-weight: 600; margin: 2px 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-project-switch { font-size: 11px; color: #93c5fd; text-decoration: none; display: flex; align-items: center; gap: 4px; }
.sidebar-project-switch:hover { color: #fff; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid #1e293b;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.sidebar-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;align-items: center;justify-content: center;
  font-size: 13px;font-weight: 700;color: #fff;
  flex-shrink: 0;
}
.sidebar-user-info { min-width: 0; }
.sidebar-user-info strong { display: block; font-size: 12.5px; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-info span { font-size: 11px; color: var(--text-sidebar); text-transform: capitalize; }

.btn-logout {
  display: flex;align-items: center;gap: 8px;
  width: 100%;padding: 8px 10px;
  background: #1e293b;border: none;border-radius: var(--radius-sm);
  color: var(--text-sidebar);font-size: 12.5px;cursor: pointer;
  transition: background .15s, color .15s;text-decoration: none;
}
.btn-logout:hover { background: #dc2626;color: #fff; }

/* ── Topbar ───────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 1050;
  box-shadow: var(--shadow);
}

.topbar-menu-btn {
  display: none;
  background: none;border: none;cursor: pointer;
  padding: 4px;color: var(--text-muted);
}

.topbar-title { font-size: 16px;font-weight: 600;color: var(--text); }
.topbar-spacer { flex: 1; }

.badge-perfil {
  font-size: 11px;font-weight: 600;
  padding: 3px 8px;border-radius: 20px;
  background: #dbeafe;color: var(--primary);
  text-transform: uppercase;letter-spacing: .5px;
}
.badge-perfil.admin   { background: #fee2e2;color: var(--danger); }
.badge-perfil.tecnico { background: #dcfce7;color: var(--success); }

/* ── Page Content ─────────────────────────────────────── */
.content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* Map page — no padding, full height */
.page-mapa .main-wrap {
  height: 100vh;
  overflow: hidden;
}
.page-mapa .content {
  padding: 0;
  overflow: hidden;
  flex: 1;
  min-height: 0;
}

/* ── Cards ────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card-header {
  display: flex;align-items: center;justify-content: space-between;
  margin-bottom: 16px;padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 15px;font-weight: 600;color: var(--text); }
.card-body { }

/* ── Stat Cards ───────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  border-left: 4px solid transparent;
}
.stat-card.blue   { border-color: var(--primary); }
.stat-card.green  { border-color: var(--success); }
.stat-card.orange { border-color: var(--warning); }
.stat-card.red    { border-color: var(--danger); }
.stat-card.teal   { border-color: var(--info); }
.stat-card.purple { border-color: #7c3aed; }

.stat-icon {
  width: 42px;height: 42px;border-radius: var(--radius-sm);
  display: flex;align-items: center;justify-content: center;
  flex-shrink: 0;
}
.stat-card.blue   .stat-icon { background: #dbeafe;color: var(--primary); }
.stat-card.green  .stat-icon { background: #dcfce7;color: var(--success); }
.stat-card.orange .stat-icon { background: #fef3c7;color: var(--warning); }
.stat-card.red    .stat-icon { background: #fee2e2;color: var(--danger); }
.stat-card.teal   .stat-icon { background: #cffafe;color: var(--info); }
.stat-card.purple .stat-icon { background: #ede9fe;color: #7c3aed; }

.stat-info { }
.stat-value { font-size: 26px;font-weight: 700;line-height: 1;color: var(--text); }
.stat-label { font-size: 12px;color: var(--text-muted);margin-top: 4px; }

/* ── Tables ───────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;border-collapse: collapse;font-size: 13.5px;
}
thead th {
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  text-transform: uppercase;letter-spacing: .5px;
}
tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

/* ── Buttons ──────────────────────────────────────────── */
.btn {
  display: inline-flex;align-items: center;gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;font-weight: 500;
  border: none;cursor: pointer;
  transition: background .15s, opacity .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary   { background: var(--primary);color: #fff; }
.btn-primary:hover   { background: var(--primary-dark); }
.btn-success   { background: var(--success);color: #fff; }
.btn-success:hover   { background: #15803d; }
.btn-danger    { background: var(--danger);color: #fff; }
.btn-danger:hover    { background: #b91c1c; }
.btn-warning   { background: var(--warning);color: #fff; }
.btn-warning:hover   { background: #b45309; }
.btn-secondary { background: #e2e8f0;color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-sm { padding: 5px 10px;font-size: 12px; }
.btn-icon { padding: 6px;width: 30px;height: 30px;justify-content: center; }
.btn:disabled { opacity: .5;cursor: not-allowed; }

/* ── Forms ────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;font-size: 12.5px;font-weight: 600;
  color: var(--text);margin-bottom: 5px;
}
.form-label .req { color: var(--danger); }
.form-control {
  width: 100%;padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-control.error { border-color: var(--danger); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical;min-height: 72px; }
.form-row { display: grid;grid-template-columns: 1fr 1fr;gap: 12px; }
.form-hint { font-size: 11.5px;color: var(--text-muted);margin-top: 3px; }

/* ── Modal ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;align-items: center;justify-content: center;
  z-index: 1200;
  padding: 16px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  width: 100%;max-width: 560px;
  max-height: 90vh;
  display: flex;flex-direction: column;
}
.modal-lg { max-width: 760px; }
.modal-header {
  display: flex;align-items: center;justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 15px;font-weight: 600; }
.modal-close {
  background: none;border: none;cursor: pointer;
  color: var(--text-muted);padding: 4px;
  border-radius: 4px;
  display: flex;align-items: center;
}
.modal-close:hover { background: #f1f5f9;color: var(--text); }
.modal-body { padding: 20px;overflow-y: auto; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;justify-content: flex-end;gap: 10px;
}

/* ── Badges ───────────────────────────────────────────── */
.badge {
  display: inline-flex;align-items: center;
  padding: 2px 8px;border-radius: 20px;
  font-size: 11px;font-weight: 600;
  white-space: nowrap;
}
.badge-success  { background: #dcfce7;color: var(--success); }
.badge-warning  { background: #fef3c7;color: #92400e; }
.badge-danger   { background: #fee2e2;color: var(--danger); }
.badge-info     { background: #cffafe;color: var(--info); }
.badge-secondary{ background: #f1f5f9;color: var(--text-muted); }

/* ── Progress / Capacity Bar ─────────────────────────── */
.capacity-bar {
  height: 8px;background: #e2e8f0;border-radius: 4px;overflow: hidden;
  margin-top: 4px;
}
.capacity-fill {
  height: 100%;border-radius: 4px;
  background: var(--success);
  transition: width .3s;
}
.capacity-fill.warn  { background: var(--warning); }
.capacity-fill.full  { background: var(--danger); }

/* ── Fiber colors ─────────────────────────────────────── */
.fiber-dot {
  display: inline-block;width: 12px;height: 12px;
  border-radius: 50%;border: 1px solid rgba(0,0,0,.15);
  flex-shrink: 0;
}

/* ── Alerts ───────────────────────────────────────────── */
.alert {
  padding: 10px 14px;border-radius: var(--radius-sm);
  font-size: 13px;margin-bottom: 14px;
  display: flex;align-items: center;gap: 8px;
}
.alert-danger  { background: #fee2e2;color: #991b1b;border: 1px solid #fecaca; }
.alert-success { background: #dcfce7;color: #166534;border: 1px solid #bbf7d0; }
.alert-info    { background: #e0f2fe;color: #0c4a6e;border: 1px solid #bae6fd; }

/* ── Login Page ───────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;align-items: center;justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  padding: 20px;
}
.login-box {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 36px;
  width: 100%;max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo {
  text-align: center;margin-bottom: 24px;
}
.login-logo h1 { font-size: 28px;font-weight: 800;color: var(--primary); }
.login-logo p  { font-size: 12px;color: var(--text-muted);margin-top: 2px; }

/* ── Map Controls ─────────────────────────────────────── */
#map { height: 100%;width: 100%; }

.map-toolbar {
  position: absolute;
  bottom: 12px; left: 60px;
  z-index: 500;
  display: flex; gap: 6px; flex-wrap: wrap;
}
/* Desktop: keep icon+text inline */
.map-toolbar .btn { display: inline-flex; align-items: center; gap: 4px; }

/* ── Map Search Bar ────────────────────────────────────── */
.map-search {
  position: absolute;
  top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 500;
  display: flex; align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 2px 14px rgba(0,0,0,.16);
  width: 360px; max-width: calc(100vw - 140px);
}
.map-search-modes {
  display: flex;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}
.map-search-mode {
  width: 36px; height: 36px;
  border: none; background: none; cursor: pointer;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; transition: background .12s, color .12s;
}
.map-search-mode:first-child { border-radius: 8px 0 0 8px; }
.map-search-mode.active { color: var(--primary); background: rgba(37,99,235,.08); }
.map-search-mode:hover:not(.active) { background: var(--bg-content); color: var(--text); }
.map-search-field {
  flex: 1; display: flex; align-items: center; min-width: 0;
}
.map-search-icon { color: var(--text-muted); font-size: 12px; padding-left: 10px; flex-shrink: 0; }
.map-search-inp {
  flex: 1; border: none; outline: none; background: none;
  padding: 8px 6px; font-size: 13px; color: var(--text); min-width: 0;
}
.map-search-inp::placeholder { color: var(--text-muted); }
.map-search-clear {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 0 8px; font-size: 12px; flex-shrink: 0;
}
.map-search-clear:hover { color: var(--text); }
.map-search-results {
  position: absolute;
  top: calc(100% + 5px); left: 0; right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0,0,0,.2);
  overflow-y: auto; max-height: 300px;
  z-index: 501;
}
.map-search-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 12px; cursor: pointer; font-size: 13px;
  border-bottom: 1px solid rgba(0,0,0,.04); transition: background .1s;
}
.map-search-item:last-child { border-bottom: none; }
.map-search-item:hover { background: var(--bg-content); }
.map-search-item-icon { color: var(--primary); font-size: 13px; flex-shrink: 0; width: 18px; text-align: center; }
.map-search-item-text { flex: 1; min-width: 0; }
.map-search-item-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-search-item-sub { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-search-status { padding: 12px; text-align: center; color: var(--text-muted); font-size: 12px; }
.map-panel {
  position: absolute;
  top: 12px; right: 12px;
  z-index: 500;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.22), 0 2px 8px rgba(0,0,0,.12);
  border: 1px solid var(--border);
  width: 300px;
  max-height: calc(100vh - 90px);
  overflow-y: auto;
  display: none;
  animation: mapPanelIn .12s ease;
}
.map-panel.visible { display: block; }
@keyframes mapPanelIn {
  from { opacity: 0; transform: scale(.96) translateY(4px); }
  to   { opacity: 1; transform: none; }
}
.map-panel-header {
  display: flex;align-items: center;justify-content: space-between;
  padding: 12px 14px;border-bottom: 1px solid var(--border);
  font-size: 13px;font-weight: 600;
}
.map-panel-body { padding: 14px; }
.map-panel-body dl { display: grid;grid-template-columns: 40% 60%;gap: 4px 8px;font-size: 12.5px; }
.map-panel-body dt { color: var(--text-muted);font-weight: 500; }
.map-panel-body dd { color: var(--text); word-break: break-word; }

.map-import-bar {
  position: absolute;
  bottom: 30px;left: 50%;transform: translateX(-50%);
  z-index: 500;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 8px 14px;
  display: flex;align-items: center;gap: 10px;
  font-size: 12.5px;
}

/* ── Pagination ───────────────────────────────────────── */
.pagination {
  display: flex;align-items: center;gap: 4px;
  margin-top: 16px;justify-content: flex-end;flex-wrap: wrap;
}
.pagination button {
  padding: 5px 10px;border: 1px solid var(--border);border-radius: 4px;
  background: var(--bg-card);color: var(--text);
  font-size: 12.5px;cursor: pointer;min-width: 32px;
}
.pagination button.active,
.pagination button:hover { background: var(--primary);color: #fff;border-color: var(--primary); }
.pagination button:disabled { opacity: .4;cursor: not-allowed; }
.pagination button.ellipsis { border-color: transparent;background: transparent;pointer-events: none; }

/* ── Utilities ────────────────────────────────────────── */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.font-bold { font-weight: 700; }
.text-right { text-align: right; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.truncate { white-space: nowrap;overflow: hidden;text-overflow: ellipsis;max-width: 200px; }

/* ── Toast ────────────────────────────────────────────── */
#toast-container {
  position: fixed;bottom: 20px;right: 20px;
  z-index: 9999;display: flex;flex-direction: column;gap: 8px;
}
.toast {
  padding: 12px 16px;border-radius: var(--radius-sm);
  font-size: 13px;font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: slideIn .25s ease;
  min-width: 240px;max-width: 340px;
  display: flex;align-items: center;gap: 8px;
}
.toast-success { background: #166534;color: #fff; }
.toast-error   { background: #991b1b;color: #fff; }
.toast-info    { background: #1e3a5f;color: #fff; }
@keyframes slideIn { from { transform: translateX(110%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slideOut { to { transform: translateX(110%); opacity: 0; } }

/* ── Loader ───────────────────────────────────────────── */
.spinner {
  width: 18px;height: 18px;border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Sidebar overlay (mobile backdrop) ────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1045;
  -webkit-tap-highlight-color: transparent;
}
.sidebar-overlay.visible { display: block; }

/* Close button inside sidebar (mobile only) */
.sidebar-close-btn {
  display: none;
  position: absolute;
  top: 14px; right: 14px;
  background: rgba(255,255,255,.1);
  border: none;
  border-radius: 6px;
  color: #94a3b8;
  cursor: pointer;
  padding: 6px 8px;
  line-height: 1;
}
.sidebar-close-btn:hover { background: rgba(255,255,255,.2); color: #fff; }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: none;
    box-shadow: 4px 0 24px rgba(0,0,0,.35);
  }
  .sidebar-close-btn { display: block; }
  .main-wrap { margin-left: 0; }
  .topbar-menu-btn { display: flex; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .map-panel {
    width: calc(100vw - 24px);
    max-height: 50vh;
    right: 12px;
  }
  .map-toolbar {
    position: fixed !important;
    bottom: 0; left: 0; right: 0;
    top: auto !important;
    max-width: 100% !important;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    padding: 20px 16px calc(16px + env(safe-area-inset-bottom, 0px));
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    z-index: 999;
    box-shadow: 0 -6px 32px rgba(0,0,0,.18);
    transform: translateY(105%);
    transition: transform .28s cubic-bezier(0.32, 0.72, 0, 1);
  }
  .map-toolbar::before {
    content: '';
    position: absolute;
    top: 8px; left: 50%;
    transform: translateX(-50%);
    width: 36px; height: 4px;
    background: var(--border);
    border-radius: 2px;
  }
  .map-toolbar.mbs-open { transform: translateY(0); }
  .map-toolbar .btn {
    font-size: 12px;
    padding: 10px 14px;
    min-width: 80px;
    height: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
  }
  .map-toolbar .btn i { font-size: 18px; }
  /* Cancel-draw button lives in elem-place-bar on mobile */
  .map-toolbar #btn-cancel-draw { display: none !important; }
  .modal { margin: 0; max-height: 95vh; border-radius: 12px 12px 0 0; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  /* Search bar: full width on mobile */
  .map-search {
    left: 50px; right: 12px;
    transform: none; width: auto; max-width: none;
  }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .map-search { left: 46px; right: 8px; }
}

/* ── Mobile FAB ────────────────────────────────────────── */
.map-fab {
  display: none;
  position: fixed;
  bottom: 24px; right: 20px;
  z-index: 1000;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  align-items: center; justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 20px rgba(37,99,235,.45);
  transition: background .15s, transform .15s;
}
.map-fab:active { transform: scale(.93); }
.map-fab-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 998;
  background: rgba(0,0,0,.28);
}
.map-fab-backdrop.visible { display: block; }
@media (max-width: 768px) {
  .map-fab { display: flex; }
}
