@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&display=swap');

  :root{
    --bg: #111a13;
    --panel: #19241b;
    --panel-2: #222f24;
    --border: #334436;
    --border-soft: #222f24;
    --text: #f1f5eb;
    --text-dim: #b5c0b2;
    --text-faint: #8fa091;
    --accent: #c2d7a3;
    --accent-ink: #1e2a21;
    --accent-dim: #afc49a;
    --accent-soft: rgba(194,215,163,.12);
    --info: #7fa8bd;
    --info-soft: rgba(63,112,130,.30);
    --ok-bg: rgba(51,118,82,.38);
    --warn-bg: rgba(151,103,25,.42);
    --fail-bg: rgba(180,71,67,.42);
    --ok-tx: #f1f5eb;
    --warn-tx: #f1f5eb;
    --fail-tx: #f1f5eb;
    --focus: #c2d7a3;
    --font-display: "Space Grotesk", "Inter", sans-serif;
    --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --radius: 16px;
    --radius-s: 12px;
    --radius-pill: 999px;
    --shadow-soft: 0 1px 2px rgba(0,0,0,.25);
    --shadow-card: 0 1px 2px rgba(0,0,0,.30), 0 8px 24px rgba(0,0,0,.28);
    --shadow-float: 0 4px 12px rgba(0,0,0,.40), 0 16px 40px rgba(0,0,0,.35);
    --z-map: 0;
    --z-sticky-th: 1;
    --z-pick-banner: 800;
    --z-modal: 2000;
  }

  body.light{
    --bg: #f7f8f1;
    --panel: #ffffff;
    --panel-2: #eef2e8;
    --border: #d9e2d5;
    --border-soft: #d9e2d5;
    --text: #1e2a21;
    --text-dim: #5e6e5f;
    --text-faint: #8a978b;
    --accent: #294635;
    --accent-ink: #ffffff;
    --accent-dim: #4f7256;
    --accent-soft: rgba(79,114,86,.12);
    --info: #3f7082;
    --info-soft: rgba(63,112,130,.10);
    --ok-bg: rgba(51,118,82,.10);
    --warn-bg: rgba(151,103,25,.12);
    --fail-bg: rgba(180,71,67,.10);
    --ok-tx: #337652;
    --warn-tx: #976719;
    --fail-tx: #b44743;
    --focus: #567b3b;
    --shadow-soft: 0 1px 2px rgba(30,42,33,.06);
    --shadow-card: 0 1px 2px rgba(30,42,33,.06), 0 8px 24px rgba(30,42,33,.08);
    --shadow-float: 0 4px 12px rgba(30,42,33,.12), 0 16px 40px rgba(30,42,33,.14);
  }

  *{box-sizing:border-box;}
  html,body{margin:0;padding:0;}
  body{
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
  }
  body.light{ background-image: linear-gradient(180deg, #f7f8f1, #e8efdf 480px, #f7f8f1 900px); background-attachment:fixed; }
  ::selection{ background: var(--accent-soft); }
  ::-webkit-scrollbar{ width:8px; height:8px; }
  ::-webkit-scrollbar-track{ background:transparent; }
  ::-webkit-scrollbar-thumb{ background:var(--border); border-radius:8px; }
  ::-webkit-scrollbar-thumb:hover{ background:var(--accent-dim); }

  button{ font-family:inherit; cursor:pointer; }
  input, select, textarea{ font-family:inherit; }
  :focus-visible{ outline:2px solid var(--focus); outline-offset:2px; border-radius:4px; }

  .app{ max-width:1400px; margin:0 auto; padding:20px 24px 40px; }

  /* ---------- HEADER ---------- */
  .header{
    display:flex; flex-wrap:wrap; align-items:flex-end; gap:20px;
    padding-bottom:20px; margin-bottom:20px;
    border-bottom:1px solid var(--border);
  }
  .brand{ margin-right:auto; }
  .brand h1{
    margin:0; font-family:var(--font-display); font-weight:700;
    font-size:30px; line-height:1.15; letter-spacing:-.01em; color:var(--text);
    text-wrap:balance;
  }
  .brand p{ margin:8px 0 0; color:var(--text-dim); font-size:13px; max-width:60ch; line-height:1.5; }

  .control-group{ display:flex; flex-direction:column; gap:4px; }
  .control-group label{ font-size:12px; color:var(--text-faint); font-weight:500; }
  .control-group select, .control-group input{
    background:var(--panel); border:1px solid var(--border); color:var(--text);
    padding:8px 12px; border-radius:var(--radius-s); font-size:13px; min-width:120px;
    font-variant-numeric:tabular-nums;
    transition:border-color .15s;
  }
  .control-group select:focus, .control-group input:focus{ outline:none; border-color:var(--accent-dim); }
  .controls-row{ display:flex; gap:16px; flex-wrap:wrap; align-items:flex-end; }

  .btn{
    border-radius:var(--radius-pill); border:1px solid var(--border); background:var(--panel);
    color:var(--text); padding:9px 18px; font-size:13px; font-weight:500;
    display:inline-flex; align-items:center; gap:8px; white-space:nowrap;
    box-shadow:var(--shadow-soft);
    transition:background .15s, opacity .15s, transform .05s;
  }
  .btn:hover{ background:var(--panel-2); }
  .btn:active{ transform:translateY(1px); }
  .btn-primary{ background:var(--accent); border-color:var(--accent); color:var(--accent-ink); font-weight:600; }
  .btn-primary:hover{ background:var(--accent-dim); border-color:var(--accent-dim); }
  body.light .btn-primary:hover{ background:var(--accent-dim); border-color:var(--accent-dim); }
  .btn-ghost{ background:transparent; }
  .btn-danger-ghost{ background:transparent; color:var(--fail-tx); border-color:var(--border); }
  .btn-danger-ghost:hover{ background:var(--fail-bg); }
  .btn-sm{ padding:8px 16px; font-size:12px; }
  .btn:disabled{ opacity:.45; cursor:not-allowed; box-shadow:none; }

  .actions-row{ display:flex; gap:12px; flex-wrap:wrap; margin-bottom:20px; }

  /* ---------- LAYOUT ---------- */
  .layout{ display:grid; grid-template-columns:430px 1fr; gap:20px; align-items:start; }
  @media (max-width: 1024px){ .layout{ grid-template-columns:1fr; } .map-col{ position:static !important; } }

  .left-col{ display:flex; flex-direction:column; gap:20px; min-width:0; }
  .map-col{ position:sticky; top:20px; min-width:0; }

  .panel{
    background:var(--panel); border:1px solid var(--border); border-radius:var(--radius);
    box-shadow:var(--shadow-card);
    overflow:hidden;
  }
  .panel-head{
    display:flex; align-items:center; justify-content:space-between; gap:12px;
    padding:12px 16px; border-bottom:1px solid var(--border);
  }
  .panel-head h3{
    margin:0; font-family:var(--font-display); font-weight:600; font-size:19px; line-height:1.2;
    color:var(--text); display:flex; align-items:center; gap:8px;
  }
  .panel-head h3 .count{
    font-family:var(--font-ui); font-size:12px; font-weight:500; color:var(--text-dim);
    background:var(--panel-2); border:1px solid var(--border);
    padding:4px 12px; border-radius:var(--radius-pill); font-variant-numeric:tabular-nums;
  }
  .panel-body{ padding:16px; }

  /* Tabs */
  .tabs{ display:flex; gap:4px; padding:4px; background:var(--panel-2); margin:16px 16px 0; border-radius:var(--radius-pill); }
  .tab{
    flex:1; text-align:center; padding:8px 12px; border-radius:var(--radius-pill); font-size:13px; font-weight:500;
    color:var(--text-dim); background:transparent; border:none;
    transition:color .15s, background .15s;
  }
  .tab:hover{ color:var(--text); }
  .tab.active{ background:var(--accent); color:var(--accent-ink); font-weight:600; }

  .table-wrap{ max-height:260px; overflow:auto; margin-top:12px; border:1px solid var(--border); border-radius:var(--radius-s); background:var(--panel); }
  table{ width:100%; border-collapse:collapse; font-size:13px; }
  thead th{
    position:sticky; top:0; background:var(--panel-2); color:var(--text-faint); text-align:left;
    padding:8px 12px; font-weight:500; font-size:12px; border-bottom:1px solid var(--border); z-index:var(--z-sticky-th);
  }
  tbody td{ padding:8px 12px; border-bottom:1px solid var(--border-soft); color:var(--text); font-size:13px; font-variant-numeric:tabular-nums; }
  tbody tr:last-child td{ border-bottom:none; }
  tbody tr:hover{ background:var(--panel-2); }
  td.name-cell{ font-weight:500; }
  .swatch{ width:10px; height:10px; border-radius:4px; display:inline-block; margin-right:8px; vertical-align:middle; flex-shrink:0; box-shadow:inset 0 0 0 1px rgba(0,0,0,.15); }
  .row-actions{ display:flex; gap:4px; }
  .icon-btn{
    border:none; background:transparent; color:var(--text-faint); padding:6px 8px; border-radius:8px; font-size:12px;
    min-width:32px; min-height:32px;
    display:inline-flex; align-items:center; justify-content:center;
    transition:background .15s, color .15s;
  }
  .icon-btn:hover{ background:var(--panel-2); color:var(--text); }
  .icon-btn.del:hover{ color:var(--fail-tx); }
  .empty-row td{ text-align:center; color:var(--text-faint); padding:24px 12px; }

  .status-pill{ font-size:12px; padding:4px 12px; border-radius:var(--radius-pill); font-weight:500; white-space:nowrap; }
  .status-active{ background:var(--accent); color:var(--accent-ink); font-weight:600; }
  .status-inactive{ background:var(--panel-2); color:var(--text-faint); border:1px solid var(--border-soft); }

  /* ---------- MAP PANEL ---------- */
  .map-panel .panel-body{ padding:16px; }
  .map-search-row{ display:flex; gap:8px; margin-bottom:12px; }
  .map-search-row input{
    flex:1; background:var(--panel); border:1px solid var(--border); color:var(--text);
    padding:9px 18px; border-radius:var(--radius-pill); font-size:13px;
  }
  .map-search-row input::placeholder{ color:var(--text-faint); }
  .map-search-row input:focus{ outline:none; border-color:var(--accent-dim); }
  #map{
    width:100%; height:640px; height:min(640px, calc(100dvh - 220px)); min-height:420px;
    border-radius:var(--radius-s); border:1px solid var(--border);
    background:var(--panel-2); position:relative; z-index:var(--z-map);
  }
  .map-wrap{ position:relative; }

  .pick-banner{
    position:absolute; top:16px; left:50%; transform:translateX(-50%);
    background:var(--panel); border:1px solid var(--border); color:var(--text);
    padding:8px 8px 8px 16px; border-radius:var(--radius-pill); font-size:13px; display:none;
    align-items:center; gap:12px; z-index:var(--z-pick-banner); box-shadow:var(--shadow-float);
    white-space:nowrap;
  }
  /* Toggle de vista de mapa 3D / 2D */
  .map-view-toggle{
    display:flex; background:var(--panel); border:1px solid var(--border); border-radius:var(--radius-pill);
    overflow:hidden; box-shadow:var(--shadow-soft); padding:3px; gap:3px;
  }
  .map-view-toggle .mvt-btn{
    border:none; background:transparent; color:var(--text-dim);
    font-size:12px; font-weight:600; letter-spacing:.03em; padding:8px 16px; line-height:1; border-radius:var(--radius-pill);
    transition:background .15s, color .15s;
  }
  .map-view-toggle .mvt-btn:hover{ color:var(--text); }
  .map-view-toggle .mvt-btn.active{ background:var(--accent); color:var(--accent-ink); }

  .pick-banner.show{ display:flex; }
  .pick-banner .pulse-dot{ width:8px; height:8px; border-radius:50%; background:var(--accent-dim); animation:pulse 1.1s infinite; flex-shrink:0; }
  @keyframes pulse{ 0%,100%{opacity:1} 50%{opacity:.25} }
  .pick-banner button{
    background:var(--panel-2); border:1px solid var(--border); color:var(--text-dim);
    padding:8px 16px; border-radius:var(--radius-pill); font-size:12px; font-weight:500;
  }
  .pick-banner button:hover{ color:var(--text); }

  .routing-status{
    display:none; align-items:center; gap:8px; font-size:12px; color:var(--text); font-weight:500;
    padding:8px 12px; background:var(--info-soft); border:1px solid var(--border); border-radius:var(--radius-s); margin-top:12px;
  }
  .routing-status.show{ display:flex; }
  .routing-status .spin{
    width:12px; height:12px; border-radius:50%; border:2px solid var(--border); border-top-color:var(--info);
    animation:spin .7s linear infinite; flex-shrink:0;
  }
  @keyframes spin{ to{ transform:rotate(360deg); } }
  .routing-status-main{ flex:1; display:flex; flex-direction:column; gap:8px; min-width:0; }
  .routing-status-text-row{ display:flex; justify-content:space-between; gap:12px; font-variant-numeric:tabular-nums; }
  .routing-status-text-row span:last-child{ color:var(--text-dim); flex-shrink:0; }
  .progress-bar-wrap{ width:100%; background:var(--panel-2); border:1px solid var(--border-soft); border-radius:20px; height:8px; overflow:hidden; }
  .progress-bar-fill{ height:100%; width:0%; background:var(--info); border-radius:20px; transition:width .2s linear; }
  .btn-cancel-op{ flex-shrink:0; }

  .icon-svg{ width:14px; height:14px; display:block; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
  .btn .icon-svg{ width:13px; height:13px; }

  .field-warning{
    font-size:12px; font-weight:500; margin-top:4px; display:none;
    background:var(--warn-bg); color:var(--warn-tx); border-radius:var(--radius-pill); padding:4px 12px;
  }
  .field-warning.show{ display:block; }
  .field input.field-invalid{ border-color:var(--warn-tx); }

  /* ---------- THEME TOGGLE (claro/oscuro) ---------- */
  .theme-toggle-wrap{ align-self:center; }
  .theme-toggle-btn{
    border-radius:50%; border:1px solid var(--border); background:var(--panel); color:var(--text-dim);
    width:36px; height:36px; padding:0; display:inline-flex; align-items:center; justify-content:center;
    box-shadow:var(--shadow-soft);
    transition:background .15s, color .15s;
  }
  .theme-toggle-btn:hover{ background:var(--panel-2); color:var(--text); }
  .theme-toggle-btn .icon-svg{ width:16px; height:16px; }
  .theme-toggle-btn .icon-moon{ display:none; }
  body.light .theme-toggle-btn .icon-sun{ display:none; }
  body.light .theme-toggle-btn .icon-moon{ display:block; }

  .legend{ display:flex; gap:16px; padding:12px 4px 0; font-size:12px; color:var(--text-dim); flex-wrap:wrap; }
  .legend span{ display:inline-flex; align-items:center; gap:8px; }
  .legend .lg-swatch{ width:10px; height:10px; border-radius:4px; flex-shrink:0; box-shadow:inset 0 0 0 1px rgba(0,0,0,.15); }
  .legend .lg-line{ width:16px; height:3px; border-radius:2px; flex-shrink:0; }

  /* Leaflet overrides */
  .leaflet-tooltip.lf-tt{
    background:var(--panel); border:1px solid var(--border); color:var(--text);
    font-family:var(--font-ui); font-size:12px; border-radius:var(--radius-s); padding:8px 12px;
    box-shadow:var(--shadow-float);
  }
  .leaflet-tooltip.lf-tt::before{ border-top-color:var(--panel) !important; }
  .lf-tt .tt-title{ font-weight:600; margin-bottom:4px; color:var(--text); }
  .lf-tt .tt-row{ font-size:11px; color:var(--text-dim); font-variant-numeric:tabular-nums; }
  .leaflet-control-attribution{ background:rgba(17,26,19,.75) !important; color:var(--text-faint) !important; font-size:10px !important; }
  body.light .leaflet-control-attribution{ background:rgba(255,255,255,.85) !important; }
  .leaflet-control-attribution a{ color:var(--text-dim) !important; }
  .leaflet-control-zoom a{ background:var(--panel) !important; color:var(--text) !important; border-color:var(--border) !important; }
  .leaflet-control-zoom a:hover{ background:var(--panel-2) !important; }

  /* KPI cards */
  .kpi-row{ display:grid; grid-template-columns:repeat(2,1fr); gap:12px; }
  .kpi-card{
    background:var(--panel); border:1px solid var(--border); border-radius:var(--radius);
    padding:16px; position:relative; overflow:hidden; box-shadow:var(--shadow-card);
  }
  .kpi-card::before{
    content:""; position:absolute; top:0; left:0; width:4px; height:100%; background:var(--accent-dim);
  }
  .kpi-label{ font-size:12px; color:var(--text-faint); font-weight:500; text-transform:uppercase; letter-spacing:.05em; margin-bottom:8px; }
  .kpi-value{ font-family:var(--font-display); font-size:26px; font-weight:700; line-height:1.15; color:var(--text); font-variant-numeric:tabular-nums; }
  .kpi-value small{ font-family:var(--font-ui); font-size:12px; color:var(--text-dim); font-weight:500; margin-left:4px; }

  /* Results section */
  .util-bar-wrap{ width:100%; background:var(--panel-2); border:1px solid var(--border-soft); border-radius:20px; height:8px; overflow:hidden; margin-top:8px; min-width:60px; }
  .util-bar{ height:100%; border-radius:20px; transition:width .3s; }
  .warehouse-util-row{ display:flex; align-items:center; gap:12px; padding:12px 0; border-bottom:1px solid var(--border-soft); }
  .warehouse-util-row:last-child{ border-bottom:none; }
  .wu-name{ width:120px; font-size:13px; font-weight:500; flex-shrink:0; display:flex; align-items:center; gap:8px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .wu-bar-col{ flex:1; }
  .wu-pct{ font-size:12px; width:44px; text-align:right; color:var(--text-dim); flex-shrink:0; font-variant-numeric:tabular-nums; }

  .assign-status{ font-size:12px; padding:4px 12px; border-radius:var(--radius-pill); font-weight:500; white-space:nowrap; }
  .assign-ok{ background:var(--ok-bg); color:var(--ok-tx); }
  .assign-partial{ background:var(--warn-bg); color:var(--warn-tx); }
  .assign-fail{ background:var(--fail-bg); color:var(--fail-tx); }
  .approx-tag{ color:var(--text-faint); font-size:11px; }

  /* ---------- MODALS ---------- */
  .modal-overlay{
    display:none; position:fixed; inset:0; background:rgba(17,26,19,.55);
    align-items:center; justify-content:center; z-index:var(--z-modal); padding:20px;
    animation:overlayShow .2s ease-out;
  }
  body.light .modal-overlay{ background:rgba(30,42,33,.45); }
  @keyframes overlayShow{ from{ opacity:0; } to{ opacity:1; } }
  .modal-overlay.open{ display:flex; }
  .modal{
    background:var(--panel); border:1px solid var(--border); border-radius:var(--radius);
    width:100%; max-width:480px; box-shadow:var(--shadow-float);
    animation:contentShow .3s ease-out;
  }
  @keyframes contentShow{ from{ opacity:0; transform:translateY(8px) scale(.98); } to{ opacity:1; transform:none; } }
  .modal.modal-wide{ max-width:560px; }
  .modal-head{ padding:16px 20px; border-bottom:1px solid var(--border); display:flex; justify-content:space-between; align-items:center; }
  .modal-head h4{ margin:0; font-family:var(--font-display); font-size:22px; font-weight:600; line-height:1.2; }
  .modal-close{ background:none; border:none; color:var(--text-faint); font-size:18px; line-height:1; padding:8px; border-radius:8px; min-width:32px; min-height:32px; }
  .modal-close:hover{ background:var(--panel-2); color:var(--text); }
  .modal-body{ padding:20px; display:flex; flex-direction:column; gap:16px; max-height:65vh; overflow-y:auto; }
  .modal-foot{ padding:16px 20px; border-top:1px solid var(--border); display:flex; justify-content:flex-end; gap:12px; }
  .field{ display:flex; flex-direction:column; gap:8px; }
  .field label{ font-size:12px; color:var(--text-dim); font-weight:500; }
  .field input, .field select, .field textarea{
    background:var(--bg); border:1px solid var(--border); color:var(--text);
    padding:9px 12px; border-radius:var(--radius-s); font-size:14px; width:100%;
  }
  body.light .field input, body.light .field select, body.light .field textarea{ background:#ffffff; }
  .field input:focus, .field select:focus, .field textarea:focus{ outline:none; border-color:var(--accent-dim); }
  .field textarea{ font-size:13px; min-height:130px; resize:vertical; }
  .field-row{ display:flex; gap:12px; }
  .field-row .field{ flex:1; }
  .radio-row{ display:flex; gap:16px; }
  .radio-row label{ display:flex; align-items:center; gap:8px; font-size:13px; color:var(--text); }
  .hint{ font-size:12px; color:var(--text-faint); }
  .alert-box{
    background:var(--fail-bg); border:1px solid var(--border); color:var(--fail-tx);
    padding:12px 16px; border-radius:var(--radius-s); font-size:13px; display:flex; gap:8px; align-items:flex-start;
  }
  .alert-box.warn{ background:var(--warn-bg); color:var(--warn-tx); }
  .alert-list{ margin:0; padding-left:20px; }
  .alert-list li{ margin-bottom:4px; }

  .location-box{
    background:var(--panel-2); border:1px solid var(--border); border-radius:var(--radius-s);
    padding:12px; display:flex; align-items:center; justify-content:space-between; gap:12px;
  }
  .location-box .loc-text{ font-size:12px; color:var(--text-dim); font-variant-numeric:tabular-nums; }
  .location-box .loc-text b{ display:block; font-size:12px; color:var(--text-faint); font-weight:500; margin-bottom:4px; }

  .footer-note{ text-align:center; color:var(--text-faint); font-size:12px; margin-top:32px; padding-top:16px; border-top:1px solid var(--border-soft); }
  .footer-note code{ background:var(--panel-2); border:1px solid var(--border-soft); padding:4px 8px; border-radius:8px; }

  @media (prefers-reduced-motion: reduce){
    *, *::before, *::after{ animation-duration:.01ms !important; transition-duration:.01ms !important; }
  }
