/* ============================================================
   OASIS Irrigation Control — CSS
   Themes: dark (default) + light
   Responsive: mobile-first → tablet → desktop
   ============================================================ */

/* ---- CSS Custom Properties ---- */
:root {
  /* Accent */
  --accent: #00d4ff;
  --accent-dim: #00d4ff30;
  --accent-glow: #00d4ff60;

  /* Zone states */
  --zone-active: #0088ff;
  --zone-active-bg: #0088ff20;
  --zone-active-glow: #0088ff60;
  --zone-inactive: #00b8a9;
  --zone-inactive-bg: #00b8a920;
  --zone-error: #ff4444;
  --zone-error-bg: #ff444420;
  --zone-error-glow: #ff444460;

  /* Irrigation types */
  --type-drip: #00aaff;
  --type-mist: #cc88ff;
  --type-sprinkler: #00ff88;

  /* Status */
  --online: #00ff88;
  --offline: #ff4444;
  --warning: #ffaa44;

  /* Sizing */
  --header-h: 56px;
  --tabs-h: 44px;
  --bnav-h: 60px;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
}

/* Dark theme */
[data-theme="dark"] {
  --bg-0: #060a14;
  --bg-1: #0a0e1a;
  --bg-2: #0d1525;
  --bg-3: #131d30;
  --bg-card: #0d1525;
  --bg-card-hover: #111b2e;
  --border: #1e3050;
  --border-light: #1a2840;
  --text-1: #eef2f7;
  --text-2: #c9d1e0;
  --text-3: #6b8aad;
  --text-muted: #3a5070;
  --shadow: rgba(0,0,0,0.5);
  --modal-bg: rgba(0,0,0,0.7);
}

/* Light theme */
[data-theme="light"] {
  --bg-0: #f0f4f8;
  --bg-1: #f8fafc;
  --bg-2: #ffffff;
  --bg-3: #e8ecf2;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --border: #d0d8e4;
  --border-light: #e2e8f0;
  --text-1: #0f172a;
  --text-2: #334155;
  --text-3: #64748b;
  --text-muted: #94a3b8;
  --shadow: rgba(0,0,0,0.1);
  --modal-bg: rgba(0,0,0,0.4);
  --accent: #0088cc;
  --accent-dim: #0088cc20;
  --accent-glow: #0088cc40;
  --zone-active: #0066dd;
  --zone-active-bg: #0066dd15;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; -webkit-tap-highlight-color: transparent; }
body {
  background: var(--bg-1);
  color: var(--text-2);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
button { cursor: pointer; border: none; background: none; color: inherit; font: inherit; }
input, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }

/* ---- Screens ---- */
.screen { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }

/* ---- SPLASH ---- */
.splash {
  background: var(--bg-0);
  flex-direction: column;
  animation: splashIn 0.5s ease-out;
}
.splash-content { text-align: center; }
.splash-logo-text { user-select: none; }
.logo-icon { font-size: 64px; margin-bottom: 12px; filter: drop-shadow(0 0 20px var(--accent-glow)); }
.logo-title { font-size: 42px; font-weight: 800; letter-spacing: 8px; color: var(--accent); text-shadow: 0 0 30px var(--accent-glow); }
.logo-subtitle { color: var(--text-3); font-size: 13px; letter-spacing: 3px; text-transform: uppercase; margin-top: 4px; }
.splash-loader { width: 200px; margin-top: 40px; }
.loader-bar { height: 3px; background: var(--border); border-radius: 3px; overflow: hidden; }
.loader-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--type-mist)); border-radius: 3px; animation: loaderGrow 2s ease-in-out forwards; }
@keyframes loaderGrow { 0%{width:0} 100%{width:100%} }
@keyframes splashIn { 0%{opacity:0;transform:scale(1.05)} 100%{opacity:1;transform:scale(1)} }

/* ---- LOGIN ---- */
.login {
  background: var(--bg-0);
  overflow-y: auto;
}
.login-bg-pattern {
  position: absolute; inset: 0;
  background: radial-gradient(circle at 30% 20%, var(--accent-dim) 0%, transparent 60%),
              radial-gradient(circle at 70% 80%, #cc88ff15 0%, transparent 60%);
  pointer-events: none;
}
.login-card {
  position: relative;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  width: 92%;
  max-width: 380px;
  box-shadow: 0 20px 60px var(--shadow);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { color: var(--accent); font-size: 28px; letter-spacing: 4px; font-weight: 800; }
.logo-icon-sm { font-size: 36px; margin-bottom: 4px; }
.login-label { color: var(--text-3); font-size: 13px; text-align: center; margin-bottom: 16px; }
.login-greeting { color: var(--accent); font-size: 15px; text-align: center; margin-bottom: 8px; font-weight: 600; }

/* User cards */
.user-cards { display: flex; flex-direction: column; gap: 10px; }
.user-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}
.user-card:hover { border-color: var(--accent); background: var(--accent-dim); }
.user-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 2px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; color: var(--accent);
}
.user-card-info h3 { color: var(--text-1); font-size: 15px; font-weight: 600; }
.user-card-info p { color: var(--text-3); font-size: 12px; }

/* PIN pad */
.pin-display { display: flex; gap: 14px; justify-content: center; margin-bottom: 20px; }
.pin-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  transition: all 0.2s;
}
.pin-dot.filled { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 10px var(--accent-glow); }
.pin-error { color: var(--zone-error); text-align: center; font-size: 13px; margin-bottom: 10px; animation: shake 0.4s; }
@keyframes shake { 10%,90%{transform:translateX(-2px)} 20%,80%{transform:translateX(4px)} 30%,50%,70%{transform:translateX(-6px)} 40%,60%{transform:translateX(6px)} }

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-width: 260px;
  margin: 0 auto;
}
.pin-key {
  height: 54px;
  border-radius: var(--radius);
  background: var(--bg-3);
  border: 1px solid var(--border);
  font-size: 22px;
  font-weight: 600;
  color: var(--text-1);
  transition: all 0.15s;
  user-select: none;
  -webkit-user-select: none;
}
.pin-key:active { background: var(--accent-dim); border-color: var(--accent); transform: scale(0.95); }
.pin-key-empty { visibility: hidden; }
.pin-key-back { font-size: 20px; color: var(--text-3); }
.btn-text { color: var(--text-3); font-size: 13px; margin-top: 16px; display: block; text-align: center; }
.btn-text:hover { color: var(--accent); }

/* ---- MAIN APP ---- */
.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 16px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 10px; }
.header-logo-icon { font-size: 24px; }
.header-logo img { height: 32px; width: auto; border-radius: 4px; }
.header-title { font-size: 16px; font-weight: 800; color: var(--accent); letter-spacing: 2px; }
.header-greeting { font-size: 12px; color: var(--text-3); }
.header-right { display: flex; align-items: center; gap: 4px; }
.header-status { display: flex; align-items: center; gap: 6px; margin-right: 8px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-dot.online { background: var(--online); box-shadow: 0 0 6px var(--online); }
.status-dot.offline { background: var(--offline); box-shadow: 0 0 6px var(--offline); }
.status-label { font-size: 11px; color: var(--text-3); }
.header-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  transition: background 0.2s;
}
.header-btn:hover { background: var(--accent-dim); }
#btn-lang { font-size: 12px; font-weight: 700; color: var(--accent); }

/* Top Tabs */
.top-tabs {
  display: flex;
  gap: 2px;
  padding: 0 12px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.top-tabs::-webkit-scrollbar { display: none; }
.tab {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  position: relative;
}
.tab:hover { color: var(--text-2); background: var(--accent-dim); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-icon { font-size: 14px; }
.tab-badge {
  position: absolute; top: 4px; right: 4px;
  background: var(--zone-error);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 10px;
  min-width: 16px;
  text-align: center;
}

/* Alert banner */
.alert-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: var(--zone-error-bg);
  border-bottom: 1px solid var(--zone-error);
  color: var(--zone-error);
  font-size: 13px;
  flex-shrink: 0;
  animation: slideBannerIn 0.3s;
}
@keyframes slideBannerIn { 0%{transform:translateY(-100%)} 100%{transform:translateY(0)} }
.alert-banner-close { color: var(--zone-error); font-size: 16px; margin-left: auto; }

/* Content area */
.app-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Bottom Nav */
.bottom-nav {
  display: none;
  flex-shrink: 0;
  height: var(--bnav-h);
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bnav {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--text-3);
  font-size: 10px;
  transition: color 0.2s;
  position: relative;
}
.bnav.active { color: var(--accent); }
.bnav-icon { font-size: 20px; }
.bnav-label { font-size: 10px; }
.bnav-badge {
  position: absolute; top: 4px; right: 50%; transform: translateX(14px);
  background: var(--zone-error); color: #fff; font-size: 9px; font-weight: 700;
  padding: 1px 4px; border-radius: 8px; min-width: 14px; text-align: center;
}

/* More menu */
.more-menu-backdrop { position: fixed; inset: 0; background: var(--modal-bg); z-index: 200; }
.more-menu-panel {
  position: fixed; bottom: var(--bnav-h); left: 0; right: 0;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 8px 0;
  z-index: 201;
  animation: slideUp 0.2s;
}
@keyframes slideUp { 0%{transform:translateY(100%)} 100%{transform:translateY(0)} }
.more-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 14px 20px;
  font-size: 14px; color: var(--text-2);
  transition: background 0.2s;
}
.more-item:hover { background: var(--accent-dim); }
.more-badge { background: var(--zone-error); color:#fff; font-size:10px; padding:1px 5px; border-radius:8px; margin-left:auto; }

/* FAB */
.fab {
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 20px var(--accent-glow);
  z-index: 50;
  transition: all 0.2s;
}
.fab:hover { transform: scale(1.1); box-shadow: 0 6px 30px var(--accent-glow); }
.fab:active { transform: scale(0.95); }

/* ---- MODALS ---- */
.modal { position: fixed; inset: 0; z-index: 300; display: flex; align-items: flex-end; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: var(--modal-bg); }
.modal-card {
  position: relative;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.25s;
}
.modal-large { max-width: 560px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 16px; color: var(--text-1); }
.modal-close { font-size: 18px; color: var(--text-3); width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); }
.modal-close:hover { background: var(--zone-error-bg); color: var(--zone-error); }
.modal-body { padding: 16px 20px 24px; }

/* Search input */
.search-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-1);
  font-size: 14px;
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.2s;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-muted); }

/* Quick irrigation zones list */
.quick-zones { max-height: 50vh; overflow-y: auto; }
.quick-zone-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}
.quick-zone-item:hover { background: var(--accent-dim); }
.quick-zone-item .zone-name { font-weight: 600; color: var(--text-1); }
.quick-zone-item .zone-esp { font-size: 11px; color: var(--text-3); }
.quick-zone-item .zone-type-tag { font-size: 10px; padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.type-drip { background: var(--type-drip); color: #000; }
.type-mist { background: var(--type-mist); color: #000; }
.type-sprinkler { background: var(--type-sprinkler); color: #000; }

/* Duration presets */
.quick-zone-name { font-size: 18px; font-weight: 700; color: var(--accent); text-align: center; margin-bottom: 16px; }
.duration-presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.dur-btn {
  padding: 12px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  transition: all 0.15s;
}
.dur-btn:hover, .dur-btn.selected { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }
.duration-custom { margin-bottom: 20px; }
.duration-custom label { display: block; font-size: 12px; color: var(--text-3); margin-bottom: 6px; }
.duration-custom input {
  width: 100%; padding: 10px 14px;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-1); text-align: center; font-size: 18px;
}

/* Buttons */
.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: #000;
  font-size: 15px;
  font-weight: 700;
  border-radius: var(--radius);
  letter-spacing: 1px;
  transition: all 0.2s;
}
.btn-primary:hover { filter: brightness(1.1); box-shadow: 0 4px 20px var(--accent-glow); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary.btn-danger { background: var(--zone-error); }
.btn-large { padding: 16px; font-size: 16px; }
.btn-outline {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 12px;
  transition: all 0.2s;
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-outline.btn-danger { border-color: var(--zone-error); color: var(--zone-error); }
.btn-sm { padding: 6px 10px; font-size: 11px; }

/* Toggle switch */
.toggle { position: relative; display: inline-block; width: 42px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 24px;
  cursor: pointer;
  transition: 0.3s;
}
.toggle-slider::before {
  content: '';
  position: absolute; top: 2px; left: 3px;
  width: 18px; height: 18px;
  background: var(--text-3);
  border-radius: 50%;
  transition: 0.3s;
}
.toggle input:checked + .toggle-slider { background: var(--accent-dim); border-color: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(17px); background: var(--accent); }

/* Settings */
.setting-group { margin-bottom: 24px; }
.setting-group h3 { font-size: 13px; color: var(--accent); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.setting-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border-light); }
.setting-row span { color: var(--text-2); font-size: 13px; }
.setting-row select, .setting-input {
  padding: 6px 10px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-size: 13px;
}
.logo-upload { display: flex; gap: 8px; }

/* ============================================================
   VIEW: Dashboard
   ============================================================ */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.dash-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: all 0.2s;
}
.dash-card:hover { border-color: var(--accent); }
.dash-card-label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }
.dash-card-value { font-size: 28px; font-weight: 800; color: var(--accent); }
.dash-card-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.dash-card.active .dash-card-value { color: var(--zone-active); }
.dash-card.error .dash-card-value { color: var(--zone-error); }

.dash-section-title { font-size: 13px; color: var(--accent); text-transform: uppercase; letter-spacing: 1px; margin: 20px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }

/* Active zones list in dashboard */
.active-zone-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--zone-active-bg);
  border-left: 3px solid var(--zone-active);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  animation: pulseGlow 2s infinite;
}
@keyframes pulseGlow {
  0%,100% { box-shadow: none; }
  50% { box-shadow: 0 0 10px var(--zone-active-bg); }
}
.active-zone-row .az-name { font-weight: 600; color: var(--text-1); flex: 1; }
.active-zone-row .az-timer { font-family: monospace; font-size: 16px; color: var(--zone-active); font-weight: 700; }
.active-zone-row .az-stop {
  padding: 4px 10px;
  background: var(--zone-error-bg);
  border: 1px solid var(--zone-error);
  border-radius: var(--radius-sm);
  color: var(--zone-error);
  font-size: 11px;
  font-weight: 600;
}
.active-zone-row .az-stop:hover { background: var(--zone-error); color: #fff; }

/* ============================================================
   VIEW: Zones Grid
   ============================================================ */
.zones-toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.zones-toolbar .search-input { flex: 1; min-width: 200px; margin-bottom: 0; }
.filter-btn {
  padding: 6px 12px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-3);
  transition: all 0.2s;
}
.filter-btn.active, .filter-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

.zones-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.zone-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: all 0.25s;
  position: relative;
  overflow: hidden;
}
.zone-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 4px 15px var(--shadow); }
.zone-card.active {
  border-color: var(--zone-active);
  background: var(--zone-active-bg);
  animation: zoneActivePulse 2s infinite;
}
@keyframes zoneActivePulse {
  0%,100% { box-shadow: 0 0 0 0 transparent; }
  50% { box-shadow: 0 0 15px var(--zone-active-bg); border-color: var(--zone-active-glow); }
}
.zone-card.error { border-color: var(--zone-error); background: var(--zone-error-bg); }

.zone-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.zone-card-name { font-size: 14px; font-weight: 700; color: var(--text-1); }
.zone-card-led {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--zone-inactive);
  flex-shrink: 0;
}
.zone-card.active .zone-card-led { background: var(--zone-active); box-shadow: 0 0 8px var(--zone-active-glow); animation: ledBlink 1s infinite; }
.zone-card.error .zone-card-led { background: var(--zone-error); box-shadow: 0 0 8px var(--zone-error-glow); }
@keyframes ledBlink { 0%,100%{opacity:1} 50%{opacity:0.4} }

.zone-card-type { font-size: 10px; padding: 2px 6px; border-radius: 8px; font-weight: 600; display: inline-block; margin-bottom: 6px; }
.zone-card-esp { font-size: 11px; color: var(--text-3); }
.zone-card-timer { font-family: monospace; font-size: 15px; font-weight: 700; color: var(--zone-active); margin-top: 6px; }

/* ============================================================
   VIEW: Interactive Map v2 — Professional
   ============================================================ */

/* When map view is active, parent must not scroll */
.app-content:has(.m) { overflow: hidden; display: flex; flex-direction: column; padding: 0 !important; max-width: none !important; }

/* ── Root container — fills ALL remaining space ── */
.m { position: relative; flex: 1; min-height: 0; overflow: hidden; }

/* ── Map wrapper — absolute fill, IS the map canvas ── */
.m-wrap {
  position: absolute; inset: 0;
  overflow: hidden; background: #0b1017;
  touch-action: none; cursor: grab;
}
.m-wrap:active { cursor: grabbing; }

/* ── Floating toolbar top-left ── */
.m-bar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 15;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 8px 12px;
  background: rgba(var(--bg-2-rgb, 10,14,20), 0.82);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  pointer-events: auto;
}
.m-bar-l { display: flex; align-items: center; gap: 8px; }
.m-bar-r { display: flex; align-items: center; gap: 6px; }
.m-title { font-size: 15px; font-weight: 700; color: var(--text-1); margin: 0; white-space: nowrap; }
.m-chip {
  font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 20px;
  background: var(--bg-3); color: var(--text-3); white-space: nowrap;
}
.m-chip-on { background: var(--zone-active-bg); color: var(--zone-active); }

/* ── Buttons ── */
.m-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text-2); font-size: 11px; font-weight: 600;
  cursor: pointer; transition: all .15s; white-space: nowrap;
  line-height: 1.3;
}
.m-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--bg-card-hover); }
.m-btn:active { transform: scale(0.97); }
.m-btn svg { flex-shrink: 0; }
.m-btn-txt { }
.m-btn-edit { border-color: var(--accent-dim); color: var(--accent); }
.m-btn-cy { border-color: var(--accent); color: var(--accent); }
.m-btn-gn { border-color: var(--online); color: var(--online); }
.m-btn-gn:hover { background: rgba(0,255,136,0.08); }
.m-btn-rd { border-color: var(--zone-error); color: var(--zone-error); }
.m-btn-rd:hover { background: rgba(255,68,68,0.08); }

/* ── Zoom group — floating top-right ── */
.m-zgrp {
  position: absolute; top: 52px; right: 12px; z-index: 15;
  display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; background: rgba(var(--bg-card-rgb, 18,22,30), 0.9);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 2px 8px var(--shadow);
}
.m-zbtn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border: none; background: none;
  color: var(--text-2); cursor: pointer; transition: all .15s;
  border-bottom: 1px solid var(--border);
}
.m-zbtn:last-child { border-bottom: none; }
.m-zbtn:hover { background: var(--bg-card-hover); color: var(--accent); }
.m-zbtn:active { background: var(--accent-dim); }

/* ── Zoom level indicator ── */
.m-zlvl {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  font-size: 10px; font-weight: 600; color: var(--text-3);
  background: rgba(var(--bg-2-rgb, 10,14,20), 0.85);
  border: 1px solid var(--border); backdrop-filter: blur(6px);
  border-radius: 10px; padding: 2px 10px; z-index: 12;
  pointer-events: none; opacity: 0; transition: opacity .3s;
}
.m-zlvl.m-zlvl-show { opacity: 1; }

/* ── Edit bar — floating overlay below toolbar ── */
.m-ebar {
  position: absolute; top: 44px; left: 0; right: 0; z-index: 14;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(var(--bg-3-rgb, 20,24,32), 0.92);
  border-bottom: 1px solid var(--accent-dim);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  padding: 5px 12px; gap: 8px; flex-wrap: wrap;
}
.m-ehint { font-size: 11px; color: var(--accent); font-weight: 500; flex: 1; margin: 0; }
.m-ebtns { display: flex; gap: 5px; flex-wrap: wrap; }

/* ── Viewport — sized by JS, transform for zoom/pan ── */
.m-vp {
  transform-origin: 0 0;
  will-change: transform;
}
.m-vp.m-smooth {
  transition: transform .22s cubic-bezier(.33,1,.68,1);
}

/* ── Background image ── */
.m-img {
  display: block; width: 100%; height: 100%;
  user-select: none; -webkit-user-drag: none;
  pointer-events: none;
}

/* ── Empty state ── */
.m-empty {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%; padding: 40px;
}
.m-empty-lbl {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  cursor: pointer; text-align: center; color: var(--text-3);
  padding: 32px; border: 2px dashed var(--border); border-radius: var(--radius);
  transition: border-color .2s, color .2s;
}
.m-empty-lbl:hover { border-color: var(--accent); color: var(--accent); }
.m-empty-t { font-size: 15px; color: var(--text-1); font-weight: 600; }
.m-empty-s { font-size: 12px; color: var(--text-3); }

/* ── SVG layers ── */
.m-svg {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
}
.m-dsv { pointer-events: none; }

/* ── Zone elements ── */
.mz { cursor: pointer; transition: opacity .15s; }
.mz:hover { opacity: 0.85; }
.mz:hover rect, .mz:hover polygon { stroke-width: 3 !important; }
.mz-on rect, .mz-on polygon { animation: mPulse 2.2s ease-in-out infinite; }
@keyframes mPulse { 0%,100%{opacity:1} 50%{opacity:0.55} }
.m-led { animation: mLed 1s infinite; }
@keyframes mLed { 0%,100%{opacity:1} 50%{opacity:0.3} }
.m-vtx { cursor: move; transition: r .12s; }
.m-vtx:hover { r: 7.5; }

/* ── Minimap ── */
.m-mini {
  display: none;
  position: absolute; bottom: 10px; left: 10px; z-index: 15;
  width: 120px; height: 80px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 4px;
  opacity: 0.8; transition: opacity .2s;
  box-shadow: 0 2px 8px var(--shadow);
}
.m-mini:hover { opacity: 1; }
.m-mini svg { width: 100%; height: 100%; }

/* ── Detail panel — always absolute overlay ── */
.m-panel {
  position: absolute; top: 8px; right: 8px;
  width: 280px; max-height: calc(100% - 16px);
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  box-shadow: 0 4px 24px var(--shadow);
  z-index: 20;
  animation: mSlide .2s ease;
  overflow-y: auto;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  background: rgba(var(--bg-2-rgb, 10,14,20), 0.92);
}
@keyframes mSlide { 0%{opacity:0;transform:translateY(12px)} 100%{opacity:1;transform:translateY(0)} }

.m-panel-hd { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.m-panel-id { font-weight: 700; color: var(--text-1); font-size: 15px; }
.m-panel-tp {
  font-size: 10px; padding: 2px 8px; border-radius: 20px; font-weight: 700;
  letter-spacing: 0.5px;
}
.m-panel-x {
  margin-left: auto; background: none; border: none;
  color: var(--text-3); font-size: 20px; cursor: pointer; padding: 2px 6px;
  border-radius: 4px; transition: all .15s;
}
.m-panel-x:hover { background: var(--bg-3); color: var(--text-1); }

.mp-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--text-3); padding: 5px 0;
  border-bottom: 1px solid var(--border-light);
}
.mp-row:last-child { border-bottom: none; }
.mp-v { color: var(--text-1); font-weight: 600; }
.mp-timer { font-family: 'SF Mono',Consolas,monospace; font-size: 17px; color: var(--zone-active); }

.mp-act {
  display: block; width: 100%; margin-top: 12px; padding: 10px;
  border-radius: var(--radius-sm); font-weight: 700; font-size: 13px;
  cursor: pointer; text-align: center; border: 1px solid; transition: all .15s;
}

.mp-dur {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 12px;
}
.mp-d {
  padding: 10px 6px; font-size: 13px; font-weight: 700;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-card); color: var(--accent);
  cursor: pointer; transition: all .15s; text-align: center;
}
.mp-d:hover { background: var(--accent-dim); border-color: var(--accent); }
.mp-d:active { transform: scale(0.95); }

/* ── Legend (positioned inside the map area) ── */
.m-leg {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; flex-wrap: nowrap;
  padding: 4px 12px;
  background: rgba(var(--bg-2-rgb, 10,14,20), 0.85);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: 20px; font-size: 10px; color: var(--text-3);
  z-index: 12; white-space: nowrap;
}
.m-leg-g { display: flex; align-items: center; gap: 6px; }
.m-li { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.m-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.m-leg-bar { width: 1px; height: 12px; background: var(--border); }

/* ============================================================
   VIEW: ESP Nodes
   ============================================================ */
.esp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.esp-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: all 0.2s;
}
.esp-card.online { border-left: 3px solid var(--online); }
.esp-card.offline { border-left: 3px solid var(--offline); }
.esp-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.esp-card-id { background: var(--accent); color: #000; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.esp-card-label { font-weight: 600; color: var(--text-1); font-size: 14px; }
.esp-card-status { margin-left: auto; font-size: 11px; font-weight: 600; }
.esp-card-status.online { color: var(--online); }
.esp-card-status.offline { color: var(--offline); }
.esp-detail { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-3); padding: 3px 0; }
.esp-detail-val { color: var(--text-2); font-weight: 500; }
.esp-signal-bar { display: flex; gap: 2px; align-items: flex-end; height: 16px; }
.esp-signal-bar span { width: 4px; background: var(--border); border-radius: 1px; }
.esp-signal-bar.excellent span { background: var(--online); }
.esp-signal-bar.good span:nth-child(-n+3) { background: var(--online); }
.esp-signal-bar.fair span:nth-child(-n+2) { background: var(--warning); }
.esp-signal-bar.poor span:first-child { background: var(--offline); }

/* ============================================================
   VIEW: Schedules
   ============================================================ */
.sched-list { display: flex; flex-direction: column; gap: 8px; }
.sched-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 14px;
}
.sched-time { font-size: 20px; font-weight: 700; color: var(--accent); font-family: monospace; min-width: 60px; }
.sched-info { flex: 1; }
.sched-zone { font-weight: 600; color: var(--text-1); font-size: 14px; }
.sched-days { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.sched-days span { display: inline-block; width: 22px; height: 22px; text-align: center; line-height: 22px; border-radius: 50%; font-size: 10px; font-weight: 600; }
.sched-days span.active-day { background: var(--accent-dim); color: var(--accent); border: 1px solid var(--accent); }
.sched-duration { font-size: 12px; color: var(--text-3); }
.sched-toggle { margin-left: auto; }

/* ============================================================
   VIEW: Logs
   ============================================================ */
.logs-table { width: 100%; border-collapse: collapse; }
.logs-table th {
  text-align: left; padding: 8px 12px;
  background: var(--bg-3);
  color: var(--accent);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
}
.logs-table td {
  padding: 8px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--border-light);
}
.logs-table tr:hover td { background: var(--bg-card-hover); }
.log-status { font-size: 11px; padding: 2px 8px; border-radius: 8px; font-weight: 600; }
.log-status.completed { background: var(--online); color: #000; }
.log-status.interrupted { background: var(--warning); color: #000; }
.log-status.failed { background: var(--zone-error); color: #fff; }

/* ============================================================
   VIEW: Alerts
   ============================================================ */
.alert-card {
  background: var(--bg-card);
  border: 1px solid var(--zone-error);
  border-left: 3px solid var(--zone-error);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  animation: alertSlideIn 0.3s;
}
@keyframes alertSlideIn { 0%{opacity:0;transform:translateX(-10px)} 100%{opacity:1;transform:translateX(0)} }
.alert-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.alert-type { font-size: 12px; font-weight: 700; color: var(--zone-error); text-transform: uppercase; }
.alert-time { font-size: 11px; color: var(--text-3); }
.alert-msg { font-size: 13px; color: var(--text-2); }
.alert-dismiss { margin-top: 8px; }

/* No data */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-3); }
.empty-state-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.empty-state-text { font-size: 14px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Mobile: show bottom nav, hide top tabs */
@media (max-width: 768px) {
  .top-tabs { display: none; }
  .bottom-nav { display: flex; }
  .fab { bottom: calc(var(--bnav-h) + 20px); }
  .app-content { padding: 10px; }
  .dash-grid { grid-template-columns: repeat(2, 1fr); }
  .zones-grid { grid-template-columns: repeat(2, 1fr); }
  .esp-grid { grid-template-columns: 1fr; }
  .header-greeting { display: none; }
  .modal-card { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }

  /* Map mobile */
  .m-bar { padding: 6px 8px; gap: 5px; }
  .m-title { font-size: 13px; }
  .m-btn-txt { display: none; }
  .m-btn { padding: 4px 7px; font-size: 10px; }
  .m-mini { display: none !important; }
  .m-panel {
    position: fixed; bottom: var(--bnav-h); left: 0; right: 0;
    top: auto; width: auto; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 45vh; padding: 14px;
  }
  .m-ebar { flex-direction: column; gap: 5px; padding: 5px 8px; }
  .m-ebtns { width: 100%; }
  .m-leg { font-size: 9px; padding: 3px 10px; }
  .m-leg-bar { display: none; }
  .m-zgrp { top: 44px; right: 8px; }

  .logs-table-wrap { overflow-x: auto; }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
  .bottom-nav { display: flex; }
  .top-tabs { display: none; }
  .fab { bottom: calc(var(--bnav-h) + 20px); }
  .dash-grid { grid-template-columns: repeat(3, 1fr); }
  .zones-grid { grid-template-columns: repeat(3, 1fr); }

  /* Map tablet */
  .m-mini { display: block; width: 110px; height: 75px; }
  .m-panel { width: 280px; }
}

/* Desktop: show top tabs, hide bottom nav */
@media (min-width: 1025px) {
  .top-tabs { display: flex; }
  .bottom-nav { display: none; }
  .fab { bottom: 24px; right: 24px; }
  .modal-card { border-radius: var(--radius-lg); max-height: 80vh; }
  .modal { align-items: center; }
  .zones-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

  /* Map desktop */
  .m-mini { display: block; width: 140px; height: 95px; }
  .m-panel { width: 320px; }
}

/* Large desktop */
@media (min-width: 1400px) {
  .app-content { max-width: 1300px; margin: 0 auto; }
  .m-panel { width: 360px; }
  .m-mini { width: 160px; height: 110px; }
}
