/* ======================================================
   Design System — 深色战术地图风格
   ====================================================== */
:root {
  --bg: #0b0d12;
  --bg-alt: #111318;
  --surface: #171a21;
  --surface-hover: #1d212a;
  --border: rgba(255,255,255,0.06);
  --border-light: rgba(255,255,255,0.10);
  --text: #e4e6eb;
  --text-secondary: #8a8f9a;
  --text-tertiary: #5a5f6a;
  --accent: #6366f1;
  --accent-glow: rgba(99,102,241,0.3);
  --accent-dim: rgba(99,102,241,0.12);
  --green: #22c55e;
  --green-dim: rgba(34,197,94,0.15);
  --amber: #f59e0b;
  --amber-dim: rgba(245,158,11,0.15);
  --red: #ef4444;
  --red-dim: rgba(239,68,68,0.15);
  --radius: 8px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --font: 'Inter',-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",sans-serif;
  --mono: "SF Mono","Cascadia Code","Menlo","Consolas",monospace;
}

/* ========== Reset ========== */
*,:before,:after{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%;overflow:hidden}
body{
  font-family:var(--font);font-size:14px;color:var(--text);
  background:var(--bg);-webkit-font-smoothing:antialiased;
  -webkit-tap-highlight-color:transparent;user-select:none;
}
.app{display:flex;flex-direction:column;height:100%}
button,input,select{font:inherit;color:inherit}
button{cursor:pointer;background:none;border:none;touch-action:manipulation}
input,select{background:var(--bg);border:1px solid var(--border);border-radius:var(--radius);padding:10px 12px}

/* ========== Header ========== */
.header{
  flex-shrink:0;z-index:100;
  background:color-mix(in srgb,var(--surface) 90%,transparent);
  backdrop-filter:blur(20px);-webkit-backdrop-filter:blur(20px);
  border-bottom:1px solid var(--border);
}
.header-inner{
  display:flex;align-items:center;justify-content:space-between;
  height:52px;padding:0 16px;
}
.brand{display:flex;align-items:center;gap:10px}
.brand-dot{
  width:10px;height:10px;border-radius:50%;
  background:var(--accent);box-shadow:0 0 8px var(--accent-glow);
}
.brand-text{font-size:15px;font-weight:700;letter-spacing:-0.01em}
.header-stats{display:flex;gap:8px}
.stat{
  display:flex;flex-direction:column;align-items:center;
  min-width:48px;padding:4px 10px;border-radius:var(--radius);
  background:var(--bg-alt);
}
.stat-value{font-size:16px;font-weight:800;line-height:1.2}
.stat-label{font-size:10px;font-weight:600;color:var(--text-tertiary);text-transform:uppercase;letter-spacing:0.06em}
.stat-accent .stat-value{color:var(--green)}
.stat-accent{background:var(--green-dim)}

/* ========== Map ========== */
.map{
  flex:1;overflow:auto;position:relative;
  background:var(--bg);
}
.map svg{display:block;width:100%;height:auto;min-height:100%}
.map-placeholder{
  position:absolute;inset:0;
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  gap:12px;color:var(--text-tertiary);font-size:13px;
}
.spinner{
  width:32px;height:32px;border:2px solid var(--border);border-top-color:var(--accent);
  border-radius:50%;animation:spin .7s linear infinite;
}
@keyframes spin{to{transform:rotate(360deg)}}

/* === SVG slot states === */
.map .stall{transition:all .15s ease}
.map .stall:hover{filter:brightness(1.4)}
.map .stall.svg-empty{fill:#166534;stroke:#22c55e;stroke-width:1;opacity:.65}
.map .stall.svg-occupied{fill:#312e81;stroke:#6366f1;stroke-width:1.2;opacity:1}
.map .stall.svg-highlight{
  fill:#92400e;stroke:#f59e0b;stroke-width:2.5;opacity:1;
  animation:glow 1.2s ease-in-out infinite;
}
@keyframes glow{
  0%,100%{filter:drop-shadow(0 0 4px rgba(245,158,11,.5))}
  50%{filter:drop-shadow(0 0 14px rgba(245,158,11,.85))}
}

/* ========== Search Layer ========== */
.search-layer{
  position:fixed;top:62px;left:12px;right:12px;z-index:90;
}
.search-box{
  display:flex;align-items:center;gap:8px;
  height:44px;padding:0 14px;
  background:color-mix(in srgb,var(--surface) 92%,transparent);
  backdrop-filter:blur(24px);-webkit-backdrop-filter:blur(24px);
  border:1px solid var(--border-light);border-radius:22px;
  box-shadow:0 8px 32px rgba(0,0,0,.4);
}
.search-box:focus-within{border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-dim)}
.search-icon{color:var(--text-tertiary);flex-shrink:0}
.search-box input{
  flex:1;min-width:0;border:none;outline:none;background:transparent;
  font-size:14px;color:var(--text);
}
.search-box input::placeholder{color:var(--text-tertiary)}
.btn-search{
  height:30px;padding:0 14px;border-radius:15px;
  background:var(--accent);color:#fff;font-size:13px;font-weight:600;
}
.btn-search:active{opacity:.8}
.search-results{
  display:none;margin-top:6px;
  background:color-mix(in srgb,var(--surface) 96%,transparent);
  backdrop-filter:blur(24px);-webkit-backdrop-filter:blur(24px);
  border:1px solid var(--border-light);border-radius:var(--radius-lg);
  box-shadow:0 12px 40px rgba(0,0,0,.5);
  max-height:240px;overflow-y:auto;
}
.search-results.show{display:block}
.result-item{
  display:flex;align-items:center;justify-content:space-between;
  padding:10px 14px;border-bottom:1px solid var(--border);cursor:pointer;
}
.result-item:last-child{border-bottom:none}
.result-item:active{background:var(--surface-hover)}
.result-item .vin-text{font:13px var(--mono);font-weight:600;color:var(--text)}
.result-item .slot-text{
  font-size:11px;font-weight:600;color:var(--accent);background:var(--accent-dim);
  padding:2px 8px;border-radius:10px;
}

/* ========== Legend ========== */
.legend-layer{
  position:fixed;bottom:80px;right:12px;z-index:80;
  display:flex;flex-direction:column;gap:6px;
  padding:8px 12px;
  background:color-mix(in srgb,var(--surface) 90%,transparent);
  backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px);
  border:1px solid var(--border);border-radius:var(--radius-lg);
  box-shadow:0 4px 16px rgba(0,0,0,.3);
}
.legend-item{display:flex;align-items:center;gap:6px;font-size:11px;font-weight:600;color:var(--text-tertiary)}
.dot{display:inline-block;width:10px;height:10px;border-radius:50%}
.dot-empty{background:#166534;border:1px solid #22c55e}
.dot-occupied{background:#312e81;border:1px solid #6366f1}
.dot-highlight{background:#92400e;border:1px solid #f59e0b}

/* ========== Bottom Nav ========== */
.nav{
  flex-shrink:0;z-index:100;
  display:flex;align-items:center;justify-content:space-around;
  height:64px;padding:0 8px;
  background:color-mix(in srgb,var(--surface) 92%,transparent);
  backdrop-filter:blur(20px);-webkit-backdrop-filter:blur(20px);
  border-top:1px solid var(--border);
}
.nav-item{
  display:flex;flex-direction:column;align-items:center;gap:2px;
  padding:6px 16px;border-radius:var(--radius);
  color:var(--text-tertiary);font-size:10px;font-weight:600;
  transition:color .15s,background .15s;
}
.nav-item.active{color:var(--accent);background:var(--accent-dim)}
.nav-item:active{background:var(--surface-hover)}
.nav-primary{
  position:relative;top:-16px;
  width:52px;height:52px;padding:0;border-radius:50%;
  background:var(--accent);color:#fff!important;
  box-shadow:0 4px 20px var(--accent-glow);
  justify-content:center;
}
.nav-primary:active{transform:scale(.95)}

/* ========== Detail Panel ========== */
.panel{
  position:fixed;bottom:64px;left:0;right:0;z-index:85;
  background:color-mix(in srgb,var(--surface) 97%,transparent);
  backdrop-filter:blur(30px);-webkit-backdrop-filter:blur(30px);
  border-top:1px solid var(--border-light);
  border-radius:var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow:0 -12px 40px rgba(0,0,0,.5);
  transform:translateY(100%);transition:transform .25s cubic-bezier(.4,0,.2,1);
  max-height:55vh;overflow-y:auto;
}
.panel.show{transform:translateY(0)}
.panel-head{
  display:flex;align-items:center;justify-content:space-between;
  padding:16px 20px 12px;
}
.panel-title{font-size:16px;font-weight:700}
.panel-close{
  width:32px;height:32px;display:flex;align-items:center;justify-content:center;
  border-radius:50%;background:var(--bg-alt);color:var(--text-secondary);
}
.panel-close:active{background:var(--surface-hover)}
.panel-body{padding:0 20px 16px}
.panel-body .detail-vin{
  font:13px var(--mono);font-weight:700;color:var(--accent);
  padding:8px 14px;background:var(--accent-dim);border-radius:var(--radius);
  margin-bottom:14px;
}
.panel-body .detail-row{
  display:flex;justify-content:space-between;align-items:center;
  padding:10px 0;border-bottom:1px solid var(--border);
}
.panel-body .detail-row:last-child{border-bottom:none}
.panel-body .detail-label{font-size:13px;color:var(--text-secondary)}
.panel-body .detail-val{font-size:13px;font-weight:600}
.detail-section-title{
  margin:16px 0 8px;font-size:12px;font-weight:800;
  color:var(--text-secondary);letter-spacing:.08em;text-transform:uppercase;
}
.panel-body .empty-panel{
  text-align:center;padding:20px 16px;
}
.panel-body .empty-panel .ep-icon{
  display:inline-flex;align-items:center;justify-content:center;
  width:56px;height:56px;border-radius:50%;
  background:var(--green-dim);color:var(--green);font-size:20px;font-weight:800;
  margin-bottom:12px;
}
.panel-body .empty-panel .ep-title{font-size:15px;font-weight:700;margin-bottom:4px}
.panel-body .empty-panel .ep-desc{font-size:13px;color:var(--text-secondary);margin-bottom:16px}
.panel-foot{
  display:flex;gap:10px;padding:12px 20px;border-top:1px solid var(--border);
  background:var(--bg-alt);
}
.panel-foot .btn{flex:1}

/* ========== Buttons ========== */
.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:6px;
  height:42px;padding:0 18px;border-radius:var(--radius);
  font-size:14px;font-weight:600;background:var(--bg);border:1px solid var(--border);
  color:var(--text);transition:background .15s,border .15s;
}
.btn:active{background:var(--surface-hover)}
.btn-primary{background:var(--accent);color:#fff;border-color:var(--accent)}
.btn-primary:active{opacity:.85}
.btn-ghost{background:transparent;border:none;color:var(--text-secondary)}
.btn-ghost:active{color:var(--text)}
.btn-full{width:100%}

/* ========== Modal Sheets ========== */
.modal-overlay{
  position:fixed;inset:0;z-index:200;
  background:rgba(0,0,0,.6);backdrop-filter:blur(4px);-webkit-backdrop-filter:blur(4px);
  display:flex;align-items:flex-end;justify-content:center;
}
.modal-sheet{
  width:100%;max-width:480px;max-height:85vh;overflow-y:auto;
  background:var(--surface);border:1px solid var(--border-light);
  border-radius:var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow:0 -12px 48px rgba(0,0,0,.5);
}
.qr-modal{align-items:center;padding:16px}
.qr-sheet{
  border-radius:var(--radius-xl);
  overflow:hidden;
}
.sheet-head{
  display:flex;align-items:center;justify-content:space-between;
  padding:16px 20px;border-bottom:1px solid var(--border);
  position:sticky;top:0;background:var(--surface);z-index:1;
}
.sheet-head h3{font-size:16px;font-weight:700}
.sheet-close{
  width:32px;height:32px;display:flex;align-items:center;justify-content:center;
  border-radius:50%;background:var(--bg-alt);color:var(--text-secondary);
}
.sheet-close:active{background:var(--surface-hover)}
.sheet-body{padding:16px 20px}
.sheet-foot{
  display:flex;padding:12px 20px;border-top:1px solid var(--border);
  background:var(--bg-alt);
}
.sheet-foot.gap{gap:10px}
.sheet-foot .btn{flex:1}
.sheet-desc{color:var(--text-secondary);font-size:13px;margin-bottom:14px}
.data-section h4{font-size:14px;font-weight:800;margin-bottom:6px}
.inventory-status{
  padding:12px;margin-bottom:12px;border-radius:var(--radius);
  background:var(--bg-alt);border:1px solid var(--border);
  color:var(--text-secondary);font-size:12px;line-height:1.55;
}

/* === Form fields === */
.field{margin-bottom:16px}
.field label{
  display:block;font-size:12px;font-weight:600;color:var(--text-secondary);
  text-transform:uppercase;letter-spacing:0.05em;margin-bottom:6px;
}
.field input,.field select{
  width:100%;height:44px;padding:0 12px;
  background:var(--bg);border:1px solid var(--border);border-radius:var(--radius);
  font-size:14px;transition:border .15s,box-shadow .15s;
}
.field input:focus,.field select:focus{
  outline:none;border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-dim);
}
.field input::placeholder{color:var(--text-tertiary)}
.field input[readonly]{color:var(--text-secondary);background:var(--bg-alt)}

.ocr-trigger{
  display:flex;align-items:center;gap:12px;width:100%;
  padding:14px;margin-bottom:16px;
  background:var(--bg-alt);border:1px dashed var(--border-light);border-radius:var(--radius);
  transition:border .15s,background .15s;
}
.ocr-trigger.secondary{margin-top:-6px;background:rgba(99,102,241,.08)}
.ocr-trigger:active{border-color:var(--accent);background:var(--accent-dim)}
.ocr-trigger svg{flex-shrink:0;color:var(--text-tertiary)}
.ocr-text{text-align:left}
.ocr-text strong{display:block;font-size:13px;font-weight:600;margin-bottom:2px}
.ocr-text small{font-size:11px;color:var(--text-tertiary)}
.ocr-preview{margin-bottom:16px;border-radius:var(--radius);overflow:hidden;border:1px solid var(--border)}
.ocr-preview img{width:100%;display:block}
.qr-video-wrap{
  position:relative;overflow:hidden;border-radius:var(--radius-xl);
  background:#020617;border:1px solid var(--border-light);
  aspect-ratio:3/4;margin-bottom:12px;
}
.qr-video-wrap video{
  width:100%;height:100%;object-fit:cover;display:block;
}
.qr-scan-frame{
  position:absolute;inset:16%;border:1px solid rgba(255,255,255,.35);
  border-radius:18px;box-shadow:0 0 0 999px rgba(0,0,0,.24);
}
.qr-scan-frame span{position:absolute;width:26px;height:26px;border-color:var(--accent);border-style:solid}
.qr-scan-frame span:nth-child(1){left:-1px;top:-1px;border-width:3px 0 0 3px;border-top-left-radius:12px}
.qr-scan-frame span:nth-child(2){right:-1px;top:-1px;border-width:3px 3px 0 0;border-top-right-radius:12px}
.qr-scan-frame span:nth-child(3){right:-1px;bottom:-1px;border-width:0 3px 3px 0;border-bottom-right-radius:12px}
.qr-scan-frame span:nth-child(4){left:-1px;bottom:-1px;border-width:0 0 3px 3px;border-bottom-left-radius:12px}
.qr-status{
  padding:10px 12px;margin-bottom:10px;border-radius:var(--radius);
  background:var(--bg-alt);border:1px solid var(--border);
  color:var(--text-secondary);font-size:12px;line-height:1.45;text-align:center;
}
.info-card{padding:14px;background:var(--bg-alt);border:1px solid var(--border);border-radius:var(--radius);font-size:13px;color:var(--text-secondary)}
.inventory-match-card{margin-bottom:16px}
.inventory-card{
  padding:12px 14px;border-radius:var(--radius);
  background:color-mix(in srgb,var(--accent) 10%,var(--bg-alt));
  border:1px solid color-mix(in srgb,var(--accent) 35%,var(--border));
}
.inventory-card.muted{
  background:var(--bg-alt);border-color:var(--border);color:var(--text-secondary);
}
.inventory-card.compact{margin-top:4px}
.inventory-title{font-size:13px;font-weight:800;color:var(--text);margin-bottom:4px}
.inventory-vin{
  display:inline-flex;margin-bottom:8px;padding:4px 8px;border-radius:8px;
  font:12px var(--mono);font-weight:800;color:var(--accent);
  background:var(--accent-dim);
}
.inventory-desc{font-size:12px;line-height:1.5}
.inventory-row{
  display:flex;justify-content:space-between;gap:10px;
  padding:6px 0;border-top:1px solid var(--border);
  font-size:12px;line-height:1.35;
}
.inventory-row span{color:var(--text-secondary);flex-shrink:0}
.inventory-row strong{text-align:right;font-weight:700;color:var(--text)}
.divider{height:1px;background:var(--border);border:none;margin:16px 0}

/* ========== Toast ========== */
.toast{
  position:fixed;bottom:90px;left:50%;z-index:250;
  transform:translateX(-50%) translateY(20px);
  padding:8px 20px;border-radius:20px;
  background:var(--surface);border:1px solid var(--border-light);
  color:var(--text);font-size:13px;font-weight:600;
  box-shadow:0 8px 24px rgba(0,0,0,.5);
  opacity:0;transition:all .25s;pointer-events:none;
}
.toast.show{opacity:1;transform:translateX(-50%) translateY(0)}
.toast.success{background:#166534;border-color:#22c55e}
.toast.error{background:#7f1d1d;border-color:#ef4444}

/* ========== Tooltip ========== */
.svg-tooltip{
  position:fixed;z-index:250;padding:6px 10px;
  background:var(--surface);border:1px solid var(--border-light);
  border-radius:var(--radius);font-size:12px;font-weight:500;
  box-shadow:0 4px 16px rgba(0,0,0,.5);
  pointer-events:none;max-width:200px;
}
.svg-tooltip strong{display:block;font-weight:700;margin-bottom:2px;font-size:13px}

/* ========== Scrollbar ========== */
::-webkit-scrollbar{width:3px;height:3px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:rgba(255,255,255,.1);border-radius:2px}
::-webkit-scrollbar-thumb:hover{background:rgba(255,255,255,.2)}

/* ========== Responsive ========== */
@media (min-width:768px){
  .app{max-width:480px;margin:0 auto;border-left:1px solid var(--border);border-right:1px solid var(--border)}
}

/* 车辆模型由前端按车位占用状态动态注入；空车位只显示编号 */
.map .slot-car{
  pointer-events:none;
  filter:drop-shadow(0 2px 3px rgba(0,0,0,.35));
}
.map .slot-label{
  transition:opacity .15s ease;
}

/* 按“已生成图像 1”改：车位不再用绿色/紫色状态底色，保持灰底白线，靠车模表示占用 */
.map .stall.svg-empty,
.map .stall.svg-occupied{
  fill:#bfc0bc !important;
  stroke:#ffffff !important;
  stroke-width:2.2 !important;
  opacity:1 !important;
}
.map .stall.svg-highlight{
  fill:#d6c38a !important;
  stroke:#f59e0b !important;
  stroke-width:3 !important;
  opacity:1 !important;
}
.map .slot-car{
  pointer-events:none;
  filter:drop-shadow(0 1px 1.5px rgba(0,0,0,.45));
}

/* 竖版俯瞰图按“已生成图像 1”查看：不把整张图缩成小图，按高度铺满并允许滚动 */
.map{
  display:flex;
  justify-content:center;
  align-items:flex-start;
}
.map svg{
  width:auto !important;
  height:max(100%, 1120px) !important;
  min-height:1120px !important;
  max-width:none !important;
}
@media (max-width: 520px){
  .map svg{
    width:100% !important;
    height:auto !important;
    min-height:100% !important;
  }
}

/* 覆盖上一版缩放：按“图像 1”原图宽度显示，桌面不再按高度压缩 */
.map svg{
  width:min(100vw, 1024px) !important;
  height:auto !important;
  min-height:unset !important;
  max-width:none !important;
}

/* 顶部 VIN 搜索、底部菜单与底图统一宽度 */
.app{
  width:min(100vw, 1024px);
  margin:0 auto;
  position:relative;
}
.search-layer{
  left:50% !important;
  right:auto !important;
  width:min(100vw, 1024px) !important;
  transform:translateX(-50%);
  padding:0 12px;
}
.nav{
  width:100%;
  align-self:center;
}
.map svg{
  width:100% !important;
  height:auto !important;
}
.map .slot-label{
  fill:#111827 !important;
  stroke:#f5f5f0 !important;
  stroke-width:.9 !important;
  font-weight:900 !important;
}

/* 最终对齐修正：搜索框与底图/底部菜单同宽，不再横向铺满桌面 */
.search-layer{
  width:min(100vw, 480px) !important;
  max-width:480px !important;
  left:50% !important;
  right:auto !important;
  transform:translateX(-50%) !important;
  padding:0 12px !important;
  box-sizing:border-box !important;
}
.search-box{width:100% !important;}
.search-results{width:calc(100% - 24px) !important;margin-left:12px;margin-right:12px;}

/* 车模精准居中：纯 SVG 俯视车模，按车位框居中显示 */
.map .slot-car{
  pointer-events:none;
  image-rendering:auto;
  filter:drop-shadow(0 .8px .7px rgba(0,0,0,.34));
}
