/* Immersive 3D US install map overlay. Deep navy/teal to match the dashboard; glowing teal columns and
   warm amber warehouses are drawn on the canvas. Works in Agua/Día/Noche themes (colors come from the same
   --pt / --wh custom properties the flat atlas uses). Respects reduced motion (handled in JS: no orbit, plain fade). */

.m3-root {
  position: fixed; inset: 0; z-index: 2147483000;
  opacity: 0; transition: opacity .34s ease; will-change: opacity;
}
.m3-root.m3-in { opacity: 1; }

.m3-backdrop {
  position: absolute; inset: 0; cursor: pointer;
  background: radial-gradient(130% 120% at 50% 18%, rgba(8, 24, 36, .72), rgba(3, 11, 20, .92));
  -webkit-backdrop-filter: blur(16px) saturate(1.1); backdrop-filter: blur(16px) saturate(1.1);
}
[data-theme="light"] .m3-backdrop {
  background: radial-gradient(130% 120% at 50% 18%, rgba(224, 240, 248, .78), rgba(180, 206, 222, .92));
}

.m3-stage {
  position: absolute; inset: 0; overflow: hidden; will-change: transform;
  transition: inset .34s cubic-bezier(.22, .61, .36, 1);
  background: radial-gradient(120% 90% at 50% 120%, rgba(16, 70, 92, .5), transparent 62%),
    radial-gradient(90% 80% at 50% -10%, rgba(10, 40, 60, .4), transparent 60%);
}
[data-theme="light"] .m3-stage {
  background: radial-gradient(120% 90% at 50% 120%, rgba(150, 200, 224, .5), transparent 62%);
}
.m3-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.m3-canvas:active { cursor: grabbing; }

.m3-labels { position: absolute; inset: 0; pointer-events: none; }
.m3-label {
  position: absolute; top: 0; left: 0; white-space: nowrap;
  padding: 2px 9px; border-radius: 999px; font: 600 12px/1.4 "DM Sans", system-ui, sans-serif;
  color: #e8fbff; background: rgba(6, 26, 38, .62); border: 1px solid rgba(110, 240, 255, .28);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  box-shadow: 0 2px 14px rgba(0, 0, 0, .35); will-change: transform;
}
[data-theme="light"] .m3-label { color: #073043; background: rgba(240, 250, 254, .82); border-color: rgba(12, 110, 150, .3); }
.m3-label[hidden] { display: none; }

.m3-hud { position: absolute; top: 22px; left: 26px; right: 72px; pointer-events: none; }
.m3-title {
  font: 700 clamp(18px, 2.4vw, 28px)/1.1 "Raleway", system-ui, sans-serif; letter-spacing: .2px;
  color: #eafdff; text-shadow: 0 2px 20px rgba(0, 0, 0, .5);
}
[data-theme="light"] .m3-title { color: #06303f; text-shadow: none; }
.m3-status { margin-top: 6px; font: 500 13px/1.4 "DM Sans", system-ui, sans-serif; color: rgba(190, 236, 248, .82); max-width: 60ch; }
[data-theme="light"] .m3-status { color: rgba(10, 70, 96, .82); }
.m3-fit {
  pointer-events: auto; margin-top: 12px; height: 34px; padding: 0 15px; border-radius: 999px; cursor: pointer;
  font: 600 13px/1 "DM Sans", system-ui, sans-serif; color: #dff8ff;
  background: rgba(8, 28, 40, .55); border: 1px solid rgba(120, 220, 240, .32);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); transition: background .16s, transform .16s;
}
.m3-fit:hover { background: rgba(14, 44, 62, .82); transform: translateY(-1px); }
.m3-fit:focus-visible { outline: 2px solid var(--pt, #6ff0ff); outline-offset: 2px; }
[data-theme="light"] .m3-fit { color: #073043; background: rgba(240, 250, 254, .82); border-color: rgba(12, 110, 150, .3); }

.m3-close {
  position: absolute; top: 18px; right: 20px; width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center; font-size: 17px; cursor: pointer;
  color: #dff8ff; background: rgba(8, 28, 40, .55); border: 1px solid rgba(120, 220, 240, .3);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); transition: background .18s, transform .18s;
}
.m3-close:hover { background: rgba(14, 44, 62, .8); transform: scale(1.06); }
[data-theme="light"] .m3-close { color: #073043; background: rgba(240, 250, 254, .8); border-color: rgba(12, 110, 150, .3); }

/* Side panel: right rail on wide screens, bottom sheet on narrow. */
.m3-panelwrap {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(360px, 90vw); padding: 74px 18px 18px;
  box-sizing: border-box; display: flex; pointer-events: none;
  transform: translateX(16px); opacity: 0; transition: transform .3s cubic-bezier(.22, .61, .36, 1), opacity .3s;
}
.m3-root.m3-has-panel .m3-panelwrap { transform: none; opacity: 1; }
.m3-root.m3-has-panel .m3-stage { inset: 0 min(360px, 90vw) 0 0; }
.m3-panel {
  pointer-events: auto; width: 100%; align-self: stretch; overflow: auto;
  padding: 20px 20px 24px; border-radius: 20px; box-sizing: border-box;
  color: #e8fbff; background: linear-gradient(180deg, rgba(10, 34, 48, .82), rgba(6, 22, 34, .88));
  border: 1px solid rgba(110, 230, 250, .22); box-shadow: 0 24px 70px rgba(0, 0, 0, .5);
  -webkit-backdrop-filter: blur(22px) saturate(1.2); backdrop-filter: blur(22px) saturate(1.2);
}
[data-theme="light"] .m3-panel {
  color: #072e3f; background: linear-gradient(180deg, rgba(248, 253, 255, .92), rgba(232, 246, 252, .95));
  border-color: rgba(12, 110, 150, .22);
}
.m3-panel h3 { margin: 0 0 2px; font: 700 20px/1.2 "Raleway", system-ui, sans-serif; }
.m3-sub { margin: 0 0 14px; font: 600 13px/1.4 "DM Sans", system-ui, sans-serif; color: rgba(130, 236, 255, .9); }
[data-theme="light"] .m3-sub { color: #0a7bab; }
.m3-sec {
  margin: 14px 0 6px; font: 700 11px/1 "DM Sans", system-ui, sans-serif; letter-spacing: .09em; text-transform: uppercase;
  color: rgba(150, 220, 240, .7);
}
.m3-note { margin: 12px 0 0; font: 500 12.5px/1.5 "DM Sans", system-ui, sans-serif; color: rgba(180, 222, 236, .72); }
[data-theme="light"] .m3-note { color: rgba(12, 80, 108, .78); }
.m3-row { display: flex; justify-content: space-between; gap: 14px; padding: 7px 0; border-bottom: 1px solid rgba(130, 220, 240, .12); }
.m3-row:last-of-type { border-bottom: 0; }
.m3-rk { font: 500 13px/1.4 "DM Sans", system-ui, sans-serif; color: rgba(190, 232, 244, .7); }
[data-theme="light"] .m3-rk { color: rgba(12, 80, 108, .72); }
.m3-rv { font: 600 13.5px/1.4 "DM Mono", "DM Sans", monospace; text-align: right; }
.m3-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 16px; }
.m3-file {
  display: inline-flex; align-items: center; justify-content: center; padding: 10px 18px; border: 0; border-radius: 12px;
  cursor: pointer; text-decoration: none;
  font: 600 13.5px/1 "DM Sans", system-ui, sans-serif; color: #04232f;
  background: linear-gradient(180deg, #8ff0ff, #46c6e6); box-shadow: 0 8px 22px rgba(70, 198, 230, .4);
  transition: transform .16s, box-shadow .16s;
}
.m3-file:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 12px 28px rgba(70, 198, 230, .5); }
.m3-file:disabled { opacity: .68; cursor: default; }
.m3-file-sec {
  display: inline-flex; align-items: center; justify-content: center; padding: 9px 14px; border-radius: 12px;
  text-decoration: none; font: 600 12.5px/1 "DM Sans", system-ui, sans-serif; color: #c8f4ff;
  background: rgba(110, 230, 250, .12); border: 1px solid rgba(110, 230, 250, .34);
  transition: background .16s;
}
.m3-file-sec:hover { background: rgba(110, 230, 250, .22); }
[data-theme="light"] .m3-file-sec { color: #07445d; background: rgba(10, 118, 150, .1); border-color: rgba(10, 118, 150, .3); }
.m3-back {
  display: inline-flex; align-items: center; gap: 4px; margin: 0 0 10px; padding: 5px 11px; border-radius: 999px;
  cursor: pointer; font: 600 12px/1 "DM Sans", system-ui, sans-serif; color: #b8f1ff;
  background: rgba(110, 230, 250, .1); border: 1px solid rgba(110, 230, 250, .26);
}
[data-theme="light"] .m3-back { color: #07445d; background: rgba(10, 118, 150, .08); border-color: rgba(10, 118, 150, .24); }
.m3-search {
  width: 100%; box-sizing: border-box; margin: 4px 0 8px; padding: 8px 12px; border-radius: 10px;
  font: 500 13px/1.2 "DM Sans", system-ui, sans-serif; color: #eafcff;
  background: rgba(4, 18, 28, .65); border: 1px solid rgba(110, 230, 250, .26);
}
[data-theme="light"] .m3-search { color: #072e3f; background: rgba(255, 255, 255, .92); border-color: rgba(12, 110, 150, .28); }
.m3-cust-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; max-height: 300px; overflow-y: auto; padding-right: 2px; }
.m3-customer {
  width: 100%; text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 9px 12px; border-radius: 12px;
  cursor: pointer; color: inherit; background: rgba(110, 230, 250, .08); border: 1px solid rgba(110, 230, 250, .2);
  transition: background .15s, border-color .15s;
}
.m3-customer:hover { background: rgba(110, 230, 250, .18); border-color: rgba(110, 230, 250, .48); }
.m3-customer strong { font: 600 13.5px/1.25 "DM Sans", system-ui, sans-serif; }
.m3-customer span { font: 500 11.5px/1.25 "DM Sans", system-ui, sans-serif; opacity: .76; }
[data-theme="light"] .m3-customer { background: rgba(10, 118, 150, .06); border-color: rgba(10, 118, 150, .2); }
.m3-dossier { margin-top: 14px; padding-top: 10px; border-top: 1px solid rgba(110, 230, 250, .22); }

/* Selected-vehicle card (the only place a 3D van renders). */
.m3-vanhead { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.m3-avatar {
  flex: 0 0 46px; width: 46px; height: 46px; border-radius: 50%; overflow: hidden; display: grid; place-items: center;
  font: 700 16px/1 "Raleway", system-ui, sans-serif; color: #04232f;
  background: linear-gradient(180deg, #8ff0ff, #46c6e6); box-shadow: 0 6px 16px rgba(70, 198, 230, .35);
}
.m3-avatar img { width: 100%; height: 100%; object-fit: cover; }
.m3-chip {
  display: inline-block; margin-top: 3px; padding: 2px 9px; border-radius: 999px;
  font: 700 10.5px/1.4 "DM Sans", system-ui, sans-serif; letter-spacing: .04em; text-transform: uppercase;
  color: #06202c; background: linear-gradient(180deg, #ffd98a, #ffc44a);
}
.m3-vanstage {
  position: relative; width: 100%; height: 150px; margin: 4px 0 12px; border-radius: 14px;
  background: radial-gradient(120% 90% at 50% 20%, rgba(110, 240, 255, .14), rgba(6, 20, 30, .6));
  border: 1px solid rgba(130, 220, 240, .16); overflow: hidden;
}
.m3-vanstage canvas { display: block; width: 100% !important; height: 100% !important; }
[data-theme="light"] .m3-vanstage { background: radial-gradient(120% 90% at 50% 20%, rgba(70, 198, 230, .14), rgba(226, 244, 250, .8)); }

@media (max-width: 760px) {
  .m3-panelwrap { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: min(52vh, 420px); padding: 0; transform: translateY(16px); }
  .m3-root.m3-has-panel .m3-stage { inset: 0 0 min(52vh, 420px) 0; }
  .m3-panel { border-radius: 20px 20px 0 0; }
}

/* The flat map card invites the lift: a subtle affordance + the Expand button. */
.card.atlas[aria-disabled="false"] .map { cursor: zoom-in; }
.atlas-expand {
  position: absolute; top: 10px; right: 10px; z-index: 3; width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center; cursor: pointer; color: var(--pt, #6ff0ff);
  background: rgba(6, 26, 38, .45); border: 1px solid rgba(110, 230, 250, .28);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); transition: background .16s, transform .16s;
}
.atlas-expand:hover { background: rgba(12, 42, 60, .7); transform: scale(1.06); }
.atlas-expand svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[data-theme="light"] .atlas-expand { color: #0a7bab; background: rgba(240, 250, 254, .7); border-color: rgba(12, 110, 150, .28); }

/* Static atlas pixels and interaction targets share one viewBox; the moving layer has no filters. */
#amap[data-raster-ready] > [data-raster-source] { visibility: hidden; }
#amap[data-raster-ready] .pt { visibility: visible; opacity: 0; }
/* The install pulses breathe ONLY on this overlaid, filter-free canvas; the baked SVG itself never animates. */
.atlas-motion { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.card.atlas[aria-disabled="false"] { cursor: zoom-in; }
.card.atlas[aria-disabled="false"]:hover { border-color: var(--pt); }
.card.atlas[role="button"]:focus-visible { outline: 2px solid var(--pt); outline-offset: 3px; }
.atlas-expand[hidden], .m3-panelwrap[hidden] { display: none; }
/* Leave an actual clickable backdrop around the stage. */
.m3-stage { inset: 12px; border-radius: 20px; }
.m3-root.m3-has-panel .m3-stage { inset: 12px min(360px, 90vw) 12px 12px; }
@media (prefers-reduced-motion: reduce) {
  .m3-root, .m3-stage, .m3-panelwrap { transition: none; }
}
@media (max-width: 760px) {
  .m3-root.m3-has-panel .m3-stage { inset: 12px 12px min(52vh, 420px) 12px; }
}
/* The expensive, filtered #amap SVG never animates — only the .atlas-motion canvas breathes. */
.m3-customer { display: block; margin-top: 8px; width: 100%; padding: 10px; text-align: left; cursor: pointer; color: inherit; background: var(--glass-solid); border: 1px solid var(--line); border-radius: 8px; }

.atlas-expand { width: auto; gap: 6px; grid-auto-flow: column; padding: 0 9px; font: 600 12px var(--font); }

/* Existing map camera, with visible and touch-sized controls. */
.m3-controls { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; max-width: calc(100vw - 80px); pointer-events: auto; }
.m3-controls .m3-fit, .m3-control { min-height: 44px; height: auto; margin: 0; padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: 12px; font: 600 13px/1.2 var(--platform-font-ui); cursor: pointer; }
.m3-control { min-width: 44px; }
.m3-control:focus-visible, .m3-canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }

/* Night mode obsidian + warm #f47920 amber tokens for expanded US map overlay */
[data-theme="dark"] .m3-backdrop { background: radial-gradient(130% 120% at 50% 18%, rgba(22, 15, 11, .80), rgba(10, 8, 7, .95)); }
[data-theme="dark"] .m3-stage { background: radial-gradient(120% 90% at 50% 120%, rgba(120, 58, 18, .26), transparent 62%), radial-gradient(90% 80% at 50% -10%, rgba(44, 24, 14, .42), transparent 60%); }
[data-theme="dark"] .m3-title { color: #fff4ea; }
[data-theme="dark"] .m3-status { color: rgba(244, 214, 190, .82); }
[data-theme="dark"] .m3-label { color: #fff3e6; background: rgba(22, 14, 10, .78); border-color: rgba(244, 121, 32, .42); }
[data-theme="dark"] .m3-fit,
[data-theme="dark"] .m3-control,
[data-theme="dark"] .m3-close { color: #fff3e6; background: rgba(26, 17, 12, .76); border-color: rgba(244, 121, 32, .36); }
[data-theme="dark"] .m3-panel { color: #fff3e6; background: linear-gradient(180deg, rgba(24, 17, 13, .94), rgba(14, 10, 8, .97)); border-color: rgba(244, 121, 32, .28); }
[data-theme="dark"] .m3-sub { color: #ff9a4d; }
[data-theme="dark"] .m3-file { color: #1a0b02; background: linear-gradient(180deg, #ffab66, #f47920); box-shadow: 0 8px 22px rgba(244, 121, 32, .38); }
[data-theme="dark"] .atlas-expand { color: #ff9a4d; background: rgba(24, 16, 11, .68); border-color: rgba(244, 121, 32, .34); }

/* Mobile (iOS + Android, <= 768px): compact HUD & labels so full continental US fits with zero crop (Scrawl 19). */
@media (max-width: 768px) {
  .m3-stage { inset: calc(8px + env(safe-area-inset-top, 0px)) 8px calc(8px + env(safe-area-inset-bottom, 0px)) 8px; border-radius: 18px; }
  .m3-root.m3-has-panel .m3-stage { inset: calc(8px + env(safe-area-inset-top, 0px)) 8px min(52vh, 420px) 8px; }
  .m3-hud { top: 12px; left: 14px; right: 64px; }
  .m3-title { font-size: 18px; line-height: 1.15; }
  .m3-status { margin-top: 4px; font-size: 11.5px; line-height: 1.3; }
  .m3-close { top: 10px; right: 10px; width: 44px; height: 44px; font-size: 18px; }
  .m3-controls { gap: 6px; margin-top: 8px; max-width: 100%; }
  .m3-controls .m3-fit, .m3-control { min-height: 44px; padding: 6px 11px; font-size: 12px; border-radius: 10px; }
  .m3-control { min-width: 44px; }
  .m3-label { font-size: 10.5px; padding: 2px 7px; }
}
