:root {
  --bg: #eef2f7;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #dfe5ec;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-soft: #eff6ff;
  --green: #15803d;
  --green-soft: #ecfdf5;
  --orange: #c2410c;
  --orange-soft: #fff7ed;
  --red: #dc2626;
  --shadow: 0 14px 40px rgba(15, 23, 42, .10);
  --shadow-soft: 0 6px 20px rgba(15, 23, 42, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif; color: var(--ink); background: var(--bg); }
body { min-height: 100vh; }
button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.fatal { max-width: 760px; margin: 60px auto; padding: 20px; border-radius: 14px; background: #fff; border: 1px solid var(--line); }
.app-shell { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }
.topbar { min-height: 72px; padding: 12px 18px; display: flex; justify-content: space-between; align-items: center; gap: 18px; color: #fff; background: linear-gradient(115deg, #0b1220 0%, #102a56 55%, #173d7a 100%); box-shadow: 0 2px 16px rgba(15, 23, 42, .24); z-index: 1200; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 12px; background: linear-gradient(145deg, #3b82f6, #22c55e); color: #fff; font-size: 23px; font-weight: 900; box-shadow: inset 0 0 0 1px rgba(255,255,255,.24); }
.brand-title { font-size: 19px; font-weight: 800; letter-spacing: .2px; line-height: 1.2; }
.brand-subtitle { margin-top: 4px; font-size: 12px; color: #cbd5e1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-status { display: flex; align-items: center; justify-content: flex-end; gap: 7px; flex-wrap: wrap; }
.status-pill, .version-pill { display: inline-flex; align-items: center; min-height: 28px; padding: 4px 9px; border-radius: 999px; font-size: 11px; line-height: 1; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.12); color: #fff; white-space: nowrap; }
.status-pill-muted { color: #dbeafe; }
.status-pill.ok { color: #dcfce7; background: rgba(22, 163, 74, .18); border-color: rgba(134,239,172,.25); }
.status-pill.warn { color: #ffedd5; background: rgba(194, 65, 12, .18); border-color: rgba(253,186,116,.25); }
.version-pill { font-weight: 700; color: #bfdbfe; }
.workspace { min-height: 0; display: grid; grid-template-columns: 370px minmax(0, 1fr); gap: 14px; padding: 14px; }
.sidebar, .map-stage { min-height: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 17px; box-shadow: var(--shadow); overflow: hidden; }
.sidebar { display: flex; flex-direction: column; }
.search-card { padding: 15px; border-bottom: 1px solid var(--line); background: #fff; }
.field-label { display: block; margin-bottom: 8px; font-size: 12px; font-weight: 700; color: #475569; }
.search-row { display: grid; grid-template-columns: minmax(0, 1fr) 72px; gap: 8px; }
.search-input-wrap { position: relative; }
.search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-53%); color: #64748b; font-size: 20px; pointer-events: none; }
#searchInput { width: 100%; height: 42px; padding: 0 34px 0 36px; border: 1px solid #cbd5e1; border-radius: 10px; outline: none; color: var(--ink); background: #fff; }
#searchInput:focus { border-color: #60a5fa; box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.input-clear { position: absolute; right: 7px; top: 7px; width: 28px; height: 28px; border: 0; border-radius: 7px; background: transparent; color: #94a3b8; font-size: 18px; cursor: pointer; }
.input-clear:hover { background: #f1f5f9; color: #475569; }
.primary-btn { border: 0; border-radius: 10px; background: var(--blue); color: #fff; font-weight: 700; cursor: pointer; }
.primary-btn:hover { background: var(--blue-dark); }
.filter-row { display: grid; grid-template-columns: minmax(0, 1fr) 72px; gap: 8px; margin-top: 8px; }
#stateSelect { height: 36px; padding: 0 10px; border: 1px solid #d7dee8; border-radius: 9px; color: #334155; background: #fff; outline: none; }
.ghost-btn { border: 1px solid #d7dee8; border-radius: 9px; background: #fff; color: #475569; cursor: pointer; }
.ghost-btn:hover { background: #f8fafc; }
.search-hint { margin-top: 9px; font-size: 11px; line-height: 1.55; color: #64748b; }
.stats-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--panel-soft); }
.stat { padding: 8px 7px; border-radius: 10px; border: 1px solid #e8edf3; background: #fff; text-align: center; }
.stat-value { font-size: 18px; line-height: 1.1; font-weight: 850; color: #1e3a8a; }
.stat-label { margin-top: 3px; font-size: 10px; color: var(--muted); }
.quick-states { padding: 10px 12px 9px; border-bottom: 1px solid var(--line); }
.section-head { min-height: 28px; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; font-weight: 700; color: #334155; }
.text-btn { border: 0; background: transparent; color: var(--blue); font-size: 11px; cursor: pointer; padding: 4px; }
.state-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.state-chip { height: 27px; padding: 0 9px; display: inline-flex; align-items: center; gap: 5px; border: 1px solid #dbeafe; border-radius: 999px; background: #f8fbff; color: #1e40af; font-size: 11px; cursor: pointer; }
.state-chip b { font-size: 10px; color: #64748b; }
.state-chip:hover, .state-chip.active { border-color: #93c5fd; background: var(--blue-soft); }
.results-panel { min-height: 0; display: flex; flex-direction: column; flex: 1; }
.result-head { padding: 9px 12px 6px; }
.result-count { font-weight: 500; color: var(--muted); }
.results { min-height: 0; overflow: auto; padding: 0 8px 10px; }
.result-item { width: 100%; display: grid; grid-template-columns: 70px minmax(0,1fr) auto; gap: 8px; align-items: center; padding: 10px; margin: 0 0 5px; border: 1px solid transparent; border-radius: 11px; background: #fff; text-align: left; cursor: pointer; }
.result-item:hover { background: #f8fbff; border-color: #dbeafe; }
.result-item.active { background: #eff6ff; border-color: #93c5fd; box-shadow: inset 3px 0 0 var(--blue); }
.result-code { min-width: 0; font-size: 14px; font-weight: 850; color: #0f172a; letter-spacing: .2px; }
.result-main { min-width: 0; }
.result-city, .result-address { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.result-city { font-size: 11px; color: #334155; }
.result-address { margin-top: 2px; font-size: 10px; color: #94a3b8; }
.result-state { padding: 3px 6px; border-radius: 7px; background: #f1f5f9; color: #475569; font-size: 10px; font-weight: 750; }
.empty-results { padding: 30px 12px; text-align: center; color: #64748b; font-size: 12px; line-height: 1.6; }
.map-stage { position: relative; min-height: 660px; background: #dce6ef; }
.map { position: absolute; inset: 0; z-index: 1; }
.map-fallback { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; background: linear-gradient(145deg,#dbe8f3,#eef4f8); }
.map-fallback-card { max-width: 430px; padding: 18px; display: grid; gap: 7px; border: 1px solid #cbd5e1; border-radius: 14px; background: rgba(255,255,255,.94); box-shadow: var(--shadow-soft); color: #475569; font-size: 12px; }
.map-fallback-card strong { color: #0f172a; font-size: 15px; }
.map-toolbar { position: absolute; right: 12px; top: 12px; z-index: 500; display: flex; gap: 7px; }
.map-tool { min-height: 34px; padding: 0 10px; border: 1px solid rgba(148,163,184,.75); border-radius: 9px; background: rgba(255,255,255,.96); box-shadow: var(--shadow-soft); color: #334155; font-size: 11px; cursor: pointer; }
.map-tool:hover { background: #fff; color: #0f172a; }
.map-legend { position: absolute; left: 12px; bottom: 12px; z-index: 450; display: grid; gap: 5px; padding: 8px 10px; border: 1px solid rgba(148,163,184,.55); border-radius: 10px; background: rgba(255,255,255,.94); box-shadow: var(--shadow-soft); color: #475569; font-size: 10px; }
.map-legend > div { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.state-dot { background: #1d4ed8; box-shadow: 0 0 0 3px rgba(37,99,235,.14); }
.zip-dot { background: #16a34a; }
.legend-pin { color: var(--red); font-size: 12px; }
.detail-drawer { position: absolute; z-index: 550; top: 58px; right: 12px; width: min(390px, calc(100% - 24px)); max-height: calc(100% - 82px); overflow: auto; border: 1px solid #d7dee8; border-radius: 15px; background: rgba(255,255,255,.98); box-shadow: 0 18px 48px rgba(15,23,42,.20); backdrop-filter: blur(8px); }
.detail-head { padding: 15px 15px 11px; border-bottom: 1px solid #e7ecf2; }
.detail-topline { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.detail-code { font-size: 25px; font-weight: 900; letter-spacing: .5px; color: #0f172a; }
.detail-location { margin-top: 4px; color: #64748b; font-size: 12px; }
.detail-close { width: 29px; height: 29px; flex: 0 0 auto; border: 0; border-radius: 8px; background: #f1f5f9; color: #64748b; font-size: 18px; cursor: pointer; }
.detail-body { padding: 13px 15px 15px; }
.detail-grid { display: grid; grid-template-columns: 60px minmax(0, 1fr); gap: 7px 9px; font-size: 12px; line-height: 1.55; }
.detail-grid .k { color: #94a3b8; }
.detail-grid .v { color: #1f2937; word-break: break-word; }
.precision { margin-top: 11px; display: flex; align-items: flex-start; gap: 8px; padding: 9px 10px; border-radius: 10px; background: #f8fafc; border: 1px solid #e5eaf0; color: #475569; font-size: 11px; line-height: 1.45; }
.precision.ok { background: var(--green-soft); border-color: #bbf7d0; color: #166534; }
.precision.warn { background: var(--orange-soft); border-color: #fed7aa; color: #9a3412; }
.detail-actions { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 7px; margin-top: 11px; }
.detail-action { min-height: 35px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid #d7dee8; border-radius: 9px; background: #fff; color: #334155; font-size: 11px; text-decoration: none; cursor: pointer; }
.detail-action:hover { background: #f8fafc; }
.detail-action.strong { border-color: #93c5fd; background: #eff6ff; color: #1d4ed8; font-weight: 750; }
.detail-action.loading { opacity: .7; cursor: wait; }
.detail-note { margin-top: 10px; padding: 8px 9px; border-radius: 9px; background: #fff7ed; color: #9a3412; font-size: 10px; line-height: 1.45; }
.warehouse-label { display: inline-flex; align-items: center; gap: 5px; transform: translate(-8px,-13px); white-space: nowrap; }
.warehouse-label .pin { width: 16px; height: 16px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: #2563eb; border: 2px solid #fff; box-shadow: 0 3px 10px rgba(15,23,42,.3); }
.warehouse-label .code { margin-left: -2px; padding: 3px 6px; border-radius: 6px; background: #0f172a; color: #fff; font-size: 10px; font-weight: 800; box-shadow: 0 3px 10px rgba(15,23,42,.18); }
.exact-marker { width: 26px; height: 26px; display: grid; place-items: center; transform: translate(-13px,-13px); border-radius: 50%; border: 3px solid #fff; background: #dc2626; color: #fff; font-size: 12px; font-weight: 900; box-shadow: 0 5px 16px rgba(127,29,29,.35); }
.state-bubble { display: grid; place-items: center; border-radius: 999px; border: 2px solid rgba(255,255,255,.92); background: rgba(29,78,216,.88); color: #fff; font-weight: 850; font-size: 10px; box-shadow: 0 4px 14px rgba(15,23,42,.25); }
.leaflet-control-attribution { font-size: 9px !important; }
.leaflet-popup-content-wrapper { border-radius: 11px; }
.leaflet-popup-content { margin: 10px 12px; font-size: 11px; line-height: 1.4; }
.footer { min-height: 32px; padding: 6px 15px; display: flex; justify-content: space-between; gap: 12px; color: #64748b; font-size: 10px; }
@media (max-width: 980px) {
  .workspace { grid-template-columns: 330px minmax(0,1fr); }
  .top-status .status-pill:nth-child(2) { display: none; }
}
@media (max-width: 820px) {
  .topbar { min-height: 62px; padding: 10px 12px; }
  .brand-mark { width: 36px; height: 36px; border-radius: 10px; }
  .brand-title { font-size: 16px; }
  .brand-subtitle { display: none; }
  .top-status { gap: 5px; }
  .top-status .status-pill { display: none; }
  .top-status #envBadge, .top-status .version-pill { display: inline-flex; }
  .workspace { grid-template-columns: 1fr; grid-template-rows: auto minmax(500px, 60vh); padding: 8px; gap: 8px; }
  .sidebar { max-height: 52vh; min-height: 390px; }
  .quick-states { display: none; }
  .stats-grid { padding: 8px; }
  .map-stage { min-height: 60vh; }
  .detail-drawer { top: auto; bottom: 10px; right: 10px; width: calc(100% - 20px); max-height: 68%; }
  .map-legend { display: none; }
  .map-toolbar { top: 10px; right: 10px; }
  .footer { flex-direction: column; gap: 2px; }
}
@media (max-width: 480px) {
  .workspace { grid-template-rows: auto minmax(470px, 58vh); }
  .sidebar { max-height: 55vh; }
  .result-item { grid-template-columns: 62px minmax(0,1fr) auto; }
  .detail-actions { grid-template-columns: 1fr 1fr; }
}
.toast { position: fixed; left: 50%; bottom: 34px; z-index: 3000; transform: translate(-50%, 14px); opacity: 0; pointer-events: none; padding: 9px 13px; border-radius: 10px; background: rgba(15,23,42,.94); color: #fff; box-shadow: 0 10px 28px rgba(15,23,42,.28); font-size: 12px; transition: .18s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* v2.5: state business-region overlay + stronger search highlight */
:root {
  --region-west: #f59e0b;
  --region-central: #22c55e;
  --region-east: #3b82f6;
}
.legend-title { font-weight: 800; color: #334155; margin-bottom: 3px; }
.legend-swatch { width: 13px; height: 13px; border-radius: 4px; display: inline-block; border: 1px solid rgba(15,23,42,.14); }
.legend-swatch.west { background: rgba(245,158,11,.30); border-color: #f59e0b; }
.legend-swatch.central { background: rgba(34,197,94,.28); border-color: #22c55e; }
.legend-swatch.east { background: rgba(59,130,246,.26); border-color: #3b82f6; }
.legend-sep { height: 1px; background: #e2e8f0; margin: 5px 0; }
.state-region-tooltip { font-weight: 700; }
.warehouse-label .pin { position: relative; background: #ef4444; }
.warehouse-label .pin::after {
  content: ''; position: absolute; inset: -7px; border: 3px solid rgba(239,68,68,.42);
  border-radius: 50%; animation: fbaPulse 1.25s ease-out infinite;
}
.warehouse-label .code { background: #b91c1c; font-size: 11px; }
@keyframes fbaPulse { 0% { transform: scale(.65); opacity: .95; } 75%,100% { transform: scale(1.65); opacity: 0; } }
.leaflet-interactive.state-region-shape { transition: fill-opacity .15s ease, stroke-width .15s ease; }
