:root {
  --bg: #0a0d12;
  --surface: #11161e;
  --surface-2: #1c2330;
  --surface-3: #2a3343;
  --border: rgba(255,255,255,0.08);
  --border-2: rgba(255,255,255,0.14);
  --text: #e7ecf3;
  --text-2: #9aa6b8;
  --text-3: #5d6878;

  --accent: #FFAA1D;
  --accent-soft: rgba(255, 170, 29, 0.14);
  --accent-glow: rgba(255, 170, 29, 0.55);

  /* Cor quente fixa para linhas tracejadas (independe do tema/accent) */
  --warm: #FF7A1A;

  --cyan: #22d3ee;
  --cyan-soft: rgba(34, 211, 238, 0.14);

  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
  --violet: #a78bfa;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-1: 0 1px 2px rgba(0,0,0,0.4), 0 8px 24px -8px rgba(0,0,0,0.55);
  --shadow-2: 0 1px 2px rgba(0,0,0,0.4), 0 24px 48px -16px rgba(0,0,0,0.7);

  --font-ui: 'Geist', 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
}

[data-theme="light"] {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef1f6;
  --border: rgba(15,23,42,0.08);
  --border-2: rgba(15,23,42,0.14);
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
}

[data-accent="cyan"] {
  --accent: #22d3ee;
  --accent-soft: rgba(34, 211, 238, 0.14);
  --accent-glow: rgba(34, 211, 238, 0.55);
}
[data-accent="lime"] {
  --accent: #a3e635;
  --accent-soft: rgba(163, 230, 53, 0.14);
  --accent-glow: rgba(163, 230, 53, 0.55);
}
[data-accent="violet"] {
  --accent: #a78bfa;
  --accent-soft: rgba(167, 139, 250, 0.14);
  --accent-glow: rgba(167, 139, 250, 0.55);
}

* { box-sizing: border-box; }
html, body, #root { margin:0; padding:0; height:100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font-family: inherit; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

.mono { font-family: var(--font-mono); font-feature-settings: 'tnum' 1; }

/* ============ APP SHELL ============ */
.app {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.map-host {
  position: absolute; inset: 0;
  background: var(--bg);
}

/* ============ TOP BAR ============ */
.topbar {
  position: absolute;
  top: 14px; left: 14px; right: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: none;
  z-index: 500;
}
.topbar > * { pointer-events: auto; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  padding: 8px 16px 8px 10px;
  border-radius: 999px;
  box-shadow: var(--shadow-1);
}
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), color-mix(in oklch, var(--accent) 60%, #ff5e1d));
  display: grid; place-items: center;
  color: #1a0f00;
  font-weight: 700;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.06) inset, 0 0 18px var(--accent-glow);
}
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.brand-sub { color: var(--text-3); font-size: 12px; font-family: var(--font-mono); }

.nav-pills {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  box-shadow: var(--shadow-1);
}
.nav-pill {
  background: transparent;
  border: none;
  color: var(--text-2);
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex; align-items: center; gap: 7px;
  transition: all 0.15s;
}
.nav-pill:hover { color: var(--text); }
.nav-pill.active {
  background: var(--surface-3);
  color: var(--text);
}

.spacer { flex: 1; }

.live-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-2);
  font-family: var(--font-mono);
  box-shadow: var(--shadow-1);
}
.live-dot {
  width: 8px; height: 8px;
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 0 0 var(--green);
  animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: var(--shadow-1);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-2); }
.icon-btn.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

/* ============ SIDEBAR (LEFT) ============ */
.sidebar {
  position: absolute;
  top: 70px; left: 14px; bottom: 14px;
  width: 360px;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-2);
  z-index: 400;
  overflow: hidden;
}

.sb-search {
  padding: 14px;
  border-bottom: 1px solid var(--border);
}
.search-input {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 14px;
  transition: all 0.15s;
}
.search-input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-input input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
}
.search-input input::placeholder { color: var(--text-3); }
.kbd {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-3);
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
}

.sb-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 0 14px 14px;
  border-bottom: 1px solid var(--border);
}
.stat-pill {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 3px;
}
.stat-pill .num { font-family: var(--font-mono); font-size: 20px; font-weight: 600; }
.stat-pill .lab { font-size: 12px; color: var(--text-3); }
.stat-pill.green .num { color: var(--green); }
.stat-pill.amber .num { color: var(--amber); }
.stat-pill.red .num { color: var(--red); }

.sb-tabs {
  display: flex;
  padding: 12px 14px 0;
  gap: 4px;
  border-bottom: 1px solid var(--border);
}
.sb-tab {
  background: transparent;
  border: none;
  color: var(--text-3);
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
}
.sb-tab:hover { color: var(--text-2); }
.sb-tab.active { color: var(--text); border-bottom-color: var(--accent); }

.sb-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.fork-card {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
}
.fork-card:hover { background: var(--surface-2); }
.fork-card.selected {
  background: var(--surface-2);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.fork-avatar {
  position: relative;
  width: 46px; height: 46px;
  border-radius: 12px;
  background: var(--surface-3);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.fork-avatar svg { width: 28px; height: 28px; }
.fork-avatar.green { box-shadow: 0 0 0 1px rgba(52, 211, 153, 0.3) inset; background: rgba(52, 211, 153, 0.1); }
.fork-avatar.amber { box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.3) inset; background: rgba(251, 191, 36, 0.1); }
.fork-avatar.red { box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.3) inset; background: rgba(248, 113, 113, 0.1); }
.fork-avatar.gray { background: var(--surface-3); }

.fork-status-dot {
  position: absolute;
  bottom: -2px; right: -2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid var(--surface);
}
.fork-status-dot.green { background: var(--green); }
.fork-status-dot.amber { background: var(--amber); }
.fork-status-dot.red { background: var(--red); }
.fork-status-dot.gray { background: var(--text-3); }

.fork-info { flex: 1; min-width: 0; }
.fork-name {
  font-weight: 600; font-size: 15px;
  display: flex; align-items: center; gap: 6px;
}
.fork-meta {
  color: var(--text-3);
  font-size: 12px;
  font-family: var(--font-mono);
  margin-top: 2px;
  display: flex; align-items: center; gap: 8px;
}
.fork-meta .sep { opacity: 0.5; }
.fork-spd {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  text-align: right;
}
.fork-spd .unit { font-size: 11px; color: var(--text-3); font-weight: 400; }

/* ============ DETAIL PANEL (RIGHT) ============ */
.detail {
  position: absolute;
  top: 70px; right: 14px; bottom: 14px;
  width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-2);
  z-index: 400;
  overflow: hidden;
  display: flex; flex-direction: column;
  animation: slideInRight 0.25s ease;
}
@keyframes slideInRight {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.detail-header {
  padding: 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: 12px;
}
.detail-fork {
  width: 56px; height: 56px;
  border-radius: 14px;
  display: grid; place-items: center;
  background: var(--accent-soft);
  position: relative;
  flex-shrink: 0;
}
.detail-fork svg { width: 36px; height: 36px; }
.detail-title { flex: 1; }
.detail-name { font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.detail-id {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-3);
  margin-top: 3px;
}
.close-btn {
  width: 32px; height: 32px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-2);
  cursor: pointer;
  display: grid; place-items: center;
}
.close-btn:hover { color: var(--text); border-color: var(--border-2); }

.detail-status {
  padding: 0 18px 14px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border);
}
.status-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
}
.status-tag.green { background: rgba(52, 211, 153, 0.12); color: var(--green); }
.status-tag.amber { background: rgba(251, 191, 36, 0.12); color: var(--amber); }
.status-tag.red { background: rgba(248, 113, 113, 0.12); color: var(--red); }
.status-tag.gray { background: var(--surface-3); color: var(--text-3); }

.detail-kpis {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
}
.kpi {
  background: var(--surface);
  padding: 14px 18px;
  display: flex; flex-direction: column; gap: 4px;
}
.kpi-label {
  font-size: 12px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.05em;
  display: flex; align-items: center; gap: 6px;
}
.kpi-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.kpi-value .unit { font-size: 13px; color: var(--text-3); margin-left: 3px; }
.kpi-value.green { color: var(--green); }
.kpi-value.amber { color: var(--amber); }
.kpi-value.cyan { color: var(--cyan); }

.battery {
  display: flex; align-items: center; gap: 8px;
}
.battery-bar {
  width: 60px; height: 8px;
  background: var(--surface-3);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.battery-bar::after {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: var(--w, 70%);
  background: var(--green);
  border-radius: 4px;
}

.detail-section {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.detail-section:last-child { border-bottom: none; }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  font-weight: 600;
}
.section-action {
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
  padding: 0;
}
.section-action:hover { text-decoration: underline; }

.coord-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 0;
}
.coord-row .lab { color: var(--text-3); font-size: 13px; min-width: 42px; }
.coord-row .val { font-family: var(--font-mono); font-size: 14px; flex: 1; }

.event-row {
  display: flex; gap: 10px;
  padding: 9px 0;
  position: relative;
}
.event-row:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 26px; left: 7px; bottom: -2px;
  width: 2px;
  background: var(--border);
}
.event-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 3px solid var(--surface);
  flex-shrink: 0;
  z-index: 1;
  margin-top: 2px;
}
.event-dot.accent { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.event-dot.green { background: var(--green); }
.event-dot.red { background: var(--red); }
.event-dot.amber { background: var(--amber); }
.event-content { flex: 1; }
.event-title { font-size: 14px; font-weight: 500; }
.event-meta { font-size: 12px; color: var(--text-3); font-family: var(--font-mono); margin-top: 2px; }

.actions-row {
  display: flex; gap: 8px;
}
.btn {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a0f00;
  box-shadow: 0 0 24px -4px var(--accent-glow);
}
.btn.primary:hover { background: color-mix(in oklch, var(--accent) 92%, white); }

/* ============ MAP CONTROLS ============ */
.map-ctrls {
  position: absolute;
  bottom: 76px; right: 16px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 400;
}

/* Botões flutuantes Zonas/Trajeto e seus painéis — posição base (desktop).
   Abaixados em relação à topbar para não cobrir os menus. */
.map-fbtn   { top: 74px; }
.map-fpanel { top: 112px; }
.map-fbtn-zonas, .map-fpanel-zonas { right: 110px; }
.map-fbtn-traj,  .map-fpanel-traj  { right: 16px; }
.draw-hint { top: 74px; }
.map-ctrl-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-1);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.map-ctrl-group > button {
  width: 40px; height: 40px;
  background: transparent;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  display: grid; place-items: center;
  border-bottom: 1px solid var(--border);
}
.map-ctrl-group > button:last-child { border-bottom: none; }
.map-ctrl-group > button:hover { color: var(--text); background: var(--surface-2); }
.map-ctrl-group > button.active { color: var(--accent); background: var(--accent-soft); }

.legend {
  position: absolute;
  bottom: 24px; left: 388px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 16px;
  display: flex; gap: 18px;
  box-shadow: var(--shadow-1);
  z-index: 400;
  font-size: 13px;
}
.legend-item { display: flex; align-items: center; gap: 7px; color: var(--text-2); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; }

/* ============ FORKLIFT MAP MARKER ============ */
.fork-marker {
  position: relative;
  width: 56px; height: 56px;
  display: grid; place-items: center;
  pointer-events: none;
}
.fork-marker .pulse {
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--accent-glow);
  opacity: 0.4;
  animation: pulseRing 2s ease-out infinite;
}
.fork-marker .pulse.green { background: rgba(52, 211, 153, 0.5); }
.fork-marker .pulse.amber { background: rgba(251, 191, 36, 0.5); }
.fork-marker .pulse.red { background: rgba(248, 113, 113, 0.5); }
@keyframes pulseRing {
  0% { transform: scale(0.5); opacity: 0.6; }
  100% { transform: scale(1.6); opacity: 0; }
}
.fork-marker .body {
  position: relative;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--accent);
  display: grid; place-items: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4), 0 0 0 3px var(--surface);
  z-index: 2;
  transition: transform 0.4s ease;
  pointer-events: auto;
  cursor: pointer;
}
.fork-marker.green .body { background: var(--green); }
.fork-marker.amber .body { background: var(--amber); }
.fork-marker.red .body { background: var(--red); }
.fork-marker .body svg { width: 22px; height: 22px; color: #0a0d12; }
.fork-marker .heading {
  position: absolute;
  top: 0; left: 50%;
  transform: translate(-50%, -2px);
  width: 0; height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 9px solid var(--accent);
  z-index: 1;
  filter: drop-shadow(0 -2px 4px rgba(0,0,0,0.3));
}
.fork-marker.green .heading { border-bottom-color: var(--green); }
.fork-marker.amber .heading { border-bottom-color: var(--amber); }
.fork-marker.red .heading { border-bottom-color: var(--red); }

.fork-marker .label {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  pointer-events: none;
}

.fork-marker.idle .pulse { display: none; }

/* ============ POPUP ============ */
.leaflet-popup-content-wrapper {
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: 14px !important;
  box-shadow: var(--shadow-2) !important;
  padding: 0 !important;
}
.leaflet-popup-content {
  margin: 0 !important;
  width: 260px !important;
}
.leaflet-popup-tip {
  background: var(--surface) !important;
  border-left: 1px solid var(--border) !important;
  border-bottom: 1px solid var(--border) !important;
}
.leaflet-popup-close-button { color: var(--text-3) !important; }

.popup-card { padding: 14px; }
.popup-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.popup-head .av {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--accent-soft);
  display: grid; place-items: center;
}
.popup-head .av svg { width: 22px; height: 22px; color: var(--accent); }
.popup-name { font-weight: 600; font-size: 15px; }
.popup-id { font-family: var(--font-mono); font-size: 12px; color: var(--text-3); margin-top: 2px; }
.popup-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 12px;
}
.popup-grid .lab { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 2px; }
.popup-grid .val { font-family: var(--font-mono); font-weight: 600; font-size: 14px; }

/* ============ MODAL ============ */
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 600;
  display: grid; place-items: center;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
  width: min(1100px, 92vw);
  max-height: 88vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: scaleIn 0.2s ease;
}
@keyframes scaleIn { from { transform: scale(0.97); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.modal-head {
  display: flex; align-items: center; gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 19px; font-weight: 600; letter-spacing: -0.01em; flex: 1; }
.modal-sub { color: var(--text-3); font-size: 14px; margin-top: 3px; }
.modal-body { flex: 1; overflow-y: auto; }

/* History modal */
.hist-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: 600px;
}
.hist-filters {
  border-right: 1px solid var(--border);
  padding: 20px;
  display: flex; flex-direction: column; gap: 18px;
  overflow-y: auto;
}
.field-label {
  display: block;
  font-size: 12px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 7px;
  font-weight: 600;
}
.field-input, .field-select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: all 0.15s;
}
.field-input:focus, .field-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field-input[type="datetime-local"] { font-family: var(--font-mono); font-size: 13px; }

.preset-row { display: flex; gap: 6px; flex-wrap: wrap; }
.preset {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}
.preset:hover { color: var(--text); border-color: var(--border-2); }
.preset.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.hist-result {
  display: grid;
  grid-template-rows: auto 1fr;
}
.hist-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
}
.hist-kpi {
  background: var(--surface);
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 5px;
}
.hist-kpi .lab {
  font-size: 12px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.hist-kpi .val {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.hist-kpi .delta {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-3);
}

.hist-events {
  overflow-y: auto;
  padding: 16px 20px;
}
.hist-event {
  display: grid;
  grid-template-columns: 80px 28px 1fr;
  align-items: center;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}
.hist-event:last-child { border-bottom: none; }
.hist-event .time {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-2);
}
.hist-event .icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
}
.hist-event .icon.green { background: rgba(52, 211, 153, 0.15); color: var(--green); }
.hist-event .icon.amber { background: rgba(251, 191, 36, 0.15); color: var(--amber); }
.hist-event .icon.red { background: rgba(248, 113, 113, 0.15); color: var(--red); }
.hist-event .icon.cyan { background: rgba(34, 211, 238, 0.15); color: var(--cyan); }
.hist-event .icon.accent { background: var(--accent-soft); color: var(--accent); }
.hist-event .icon svg { width: 15px; height: 15px; }
.hist-event .desc { font-size: 14px; line-height: 1.4; }
.hist-event .desc small { color: var(--text-3); display: block; font-size: 12px; margin-top: 3px; }

/* Dashboard modal */
.dash-grid {
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.dash-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
}
.dash-card.span2 { grid-column: span 2; }
.dash-card.span3 { grid-column: span 3; }
.dash-card.span4 { grid-column: span 4; }
.dash-card .head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.dash-card h4 {
  margin: 0; font-size: 14px;
  color: var(--text-2);
  font-weight: 500;
}
.dash-card .big {
  font-family: var(--font-mono);
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.dash-card .delta-up { color: var(--green); font-size: 13px; font-family: var(--font-mono); margin-top: 2px; }
.dash-card .delta-down { color: var(--red); font-size: 13px; font-family: var(--font-mono); margin-top: 2px; }

.bars { display: flex; align-items: flex-end; gap: 4px; height: 100px; }
.bar {
  flex: 1;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  min-height: 4px;
  position: relative;
  transition: opacity 0.15s;
}
.bar:hover { opacity: 0.8; }
.bar-labels { display: flex; gap: 4px; margin-top: 6px; }
.bar-labels span {
  flex: 1;
  font-size: 11px;
  color: var(--text-3);
  text-align: center;
  font-family: var(--font-mono);
}

.donut {
  position: relative;
  width: 140px; height: 140px;
  margin: 0 auto;
}
.donut-center {
  position: absolute;
  inset: 0;
  display: grid; place-items: center;
  text-align: center;
}
.donut-center .v { font-family: var(--font-mono); font-size: 24px; font-weight: 600; }
.donut-center .l { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* Fleet list (modal) */
.fleet-table {
  width: 100%;
  border-collapse: collapse;
}
.fleet-table th, .fleet-table td {
  padding: 13px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.fleet-table th {
  font-size: 12px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  background: var(--surface-2);
  position: sticky; top: 0;
}
.fleet-table tr:hover td { background: var(--surface-2); }
.fleet-table .mac { font-family: var(--font-mono); font-size: 13px; color: var(--text-3); }
.fleet-table .num { font-family: var(--font-mono); font-weight: 500; }

/* Cadastro form */
.cadastro {
  padding: 24px 28px;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
}
.form-col { display: flex; flex-direction: column; gap: 16px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.preview-card {
  background: var(--surface-2);
  border: 1px dashed var(--warm);
  border-radius: 14px;
  padding: 20px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  text-align: center;
}
.preview-fork {
  width: 80px; height: 80px;
  border-radius: 18px;
  background: var(--accent-soft);
  display: grid; place-items: center;
}
.preview-fork svg { width: 56px; height: 56px; color: var(--accent); }

.swatch-row { display: flex; gap: 8px; }
.swatch {
  width: 34px; height: 34px;
  border-radius: 10px;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
}
.swatch.active {
  border-color: var(--text);
  transform: scale(1.05);
}

/* Geofence / geo-label tooltip */
.geo-label {
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  font-family: var(--font-mono) !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  padding: 4px 10px !important;
  box-shadow: var(--shadow-1) !important;
  white-space: nowrap;
}
.geo-label::before { display: none !important; }

.geofence-zone {
  stroke: var(--warm);
  stroke-width: 2;
  fill: var(--warm);
  fill-opacity: 0.06;
  stroke-dasharray: 6 4;
}
.geofence-restrict {
  stroke: var(--red);
  stroke-width: 2;
  fill: var(--red);
  fill-opacity: 0.08;
  stroke-dasharray: 6 4;
}

/* Trail polyline */
.trail {
  stroke: var(--accent);
  stroke-width: 3;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 6px var(--accent-glow));
}

/* Indoor map */
.indoor-bg {
  position: absolute; inset: 0;
  background-color: #0d1118;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 40px 40px;
}

.indoor-zone {
  position: absolute;
  border: 1px dashed var(--warm);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  pointer-events: none;
}
.indoor-zone.amber {
  border-color: var(--amber);
  background: rgba(251, 191, 36, 0.04);
  color: var(--amber);
}
.indoor-zone.red {
  border-color: var(--red);
  background: rgba(248, 113, 113, 0.06);
  color: var(--red);
}
.indoor-zone.green {
  border-color: var(--green);
  background: rgba(52, 211, 153, 0.04);
  color: var(--green);
}

/* Toast */
.toast {
  position: absolute;
  bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 20px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow-2);
  z-index: 700;
  animation: slideUp 0.3s ease;
  font-size: 14px;
}
@keyframes slideUp {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

/* Basemap picker */
.basemap-picker {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.basemap-trigger {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  padding: 0;
  background: transparent;
  color: var(--text-2);
  border: none;
  border-radius: 12px;
  cursor: pointer;
}
.basemap-trigger:hover { background: var(--surface-2); color: var(--text); }
.basemap-label { display: none; }
.basemap-caret { display: none; }
.basemap-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 190px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
  padding: 4px;
  z-index: 500;
  display: flex;
  flex-direction: column;
}
.basemap-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: transparent;
  color: var(--text);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  font-family: var(--font-mono);
}
.basemap-menu button:hover { background: var(--surface-2); }
.basemap-menu button.active { color: var(--accent); }

/* Mobile FABs */
.mobile-detail-fab {
  position: fixed;
  bottom: 16px; right: 16px;
  z-index: 440;
  display: flex; align-items: center; gap: 8px;
  padding: 11px 16px;
  background: var(--accent);
  color: #0a0d12;
  border: none;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: 0 8px 24px rgba(255, 170, 29, 0.35), 0 2px 6px rgba(0,0,0,0.4);
  cursor: pointer;
  animation: fabIn 0.25s ease-out;
}
.mobile-detail-fab .fab-arrow { font-size: 11px; opacity: 0.7; }

.sidebar-fab {
  position: fixed;
  top: 76px; left: 16px;
  z-index: 440;
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  transition: background 0.15s, border-color 0.15s;
}
.sidebar-fab:hover {
  background: var(--surface-2);
  border-color: var(--accent);
  color: var(--accent);
}

.sb-close {
  position: absolute;
  top: 12px; right: 12px;
  z-index: 11;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.sb-close:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--accent);
}

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

/* Tweaks panel */
.tweaks-panel-positioned { z-index: 1000 !important; }

/* ============ RESPONSIVE ============ */
@media (max-width: 1100px) {
  .legend { display: none; }
  .map-ctrls { right: 14px; }
  .detail { width: 320px; }
}

@media (max-width: 768px) {
  body { font-size: 14px; }

  .topbar { top: 8px; left: 8px; right: 8px; gap: 6px; flex-wrap: wrap; }
  .brand { padding: 6px 10px 6px 6px; }
  .brand-mark { width: 26px; height: 26px; }
  .brand-name { font-size: 14px; }
  .brand-sub { display: none; }

  .nav-pills { order: 3; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding: 3px; }
  .nav-pills::-webkit-scrollbar { display: none; }
  .nav-pill { padding: 7px 11px; font-size: 13px; white-space: nowrap; flex-shrink: 0; }

  .live-chip { display: none; }
  .icon-btn { width: 36px; height: 36px; }

  .sidebar { display: none; }

  .detail {
    top: auto; left: 8px; right: 8px; bottom: 8px;
    width: auto; max-height: 40vh;
    border-radius: 16px; z-index: 450; overflow-y: auto;
  }
  .detail-section:nth-of-type(n+4) { display: none; }
  .detail-kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi { padding: 12px 14px; }
  .kpi-value { font-size: 20px; }

  .map-ctrls { bottom: auto; top: 70px; right: 8px; flex-direction: column; gap: 6px; }
  .map-ctrl-group > button { width: 38px; height: 38px; }
  .legend { display: none; }

  /* Zonas/Trajeto saem do canto direito (ocupado pelos controles do mapa)
     e descem para a esquerda, abaixo da topbar e do botão de busca, para não
     cobrir nem os menus nem o toggle do Heat-map. */
  .map-fbtn   { top: 124px; }
  .map-fpanel { top: 166px; max-width: calc(100vw - 24px); }
  .map-fbtn-zonas, .map-fpanel-zonas, .map-fpanel-traj { left: 16px; right: auto; }
  .map-fbtn-traj { left: 104px; right: auto; }
  .draw-hint { top: 116px; max-width: calc(100vw - 24px); }

  .modal-backdrop { padding: 0; }
  .modal { width: 100% !important; max-width: 100% !important; height: 100vh; max-height: 100vh; border-radius: 0; border-left: none; border-right: none; }
  .modal-head { padding: 14px 16px; }
  .modal-title { font-size: 17px; }
  .modal-sub { font-size: 13px; }

  .hist-grid { grid-template-columns: 1fr; height: auto; }
  .hist-filters { border-right: none; border-bottom: 1px solid var(--border); padding: 14px; }
  .hist-kpis { grid-template-columns: repeat(2, 1fr); }
  .hist-kpi { padding: 12px 14px; }
  .hist-kpi .val { font-size: 20px; }

  .dash-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 14px; }
  .dash-card.span2, .dash-card.span3, .dash-card.span4 { grid-column: span 2; }
  .dash-card .big { font-size: 26px; }
  .donut { width: 110px; height: 110px; }

  .fleet-table th, .fleet-table td { padding: 10px 10px; font-size: 13px; }
  .fleet-table th:nth-child(2), .fleet-table td:nth-child(2),
  .fleet-table th:nth-child(4), .fleet-table td:nth-child(4),
  .fleet-table th:nth-child(8), .fleet-table td:nth-child(8) { display: none; }

  .cadastro { grid-template-columns: 1fr; padding: 16px; gap: 16px; }
  .field-row { grid-template-columns: 1fr; }

  .fork-marker { width: 48px; height: 48px; }
  .fork-marker .body { width: 32px; height: 32px; }
  .fork-marker .body svg { width: 18px; height: 18px; }
  .fork-marker .label { font-size: 10px; padding: 1px 6px; top: -18px; }
  .leaflet-popup-content { width: 220px !important; }
}

@media (max-width: 420px) {
  .nav-pill { padding: 6px 9px; font-size: 12px; }
  .brand { padding: 5px 8px 5px 5px; gap: 6px; }
  .icon-btn { width: 34px; height: 34px; border-radius: 10px; }
  .stat-pill .num { font-size: 18px; }
  .detail-kpis { grid-template-columns: 1fr 1fr; }
}
