:root {
      --bg: #17202b;

    --surface: #223044;
    --surface2: #2c3b52;
    --border: #40536d;
    --accent: #ff6b3d;
    --accent2: #ff8a65;
    --user-color: #4aa3ff;
    --text: #f1f5f9;
    --text-muted: #b6c2d1;
    --success: #2ecc71;
    --panel-w: 320px;
    --tab-h: 50px;
    }

    body.light {
      --bg: #f0f4f8; --surface: #ffffff; --surface2: #e8edf5;
      --border: #cdd6e3; --accent: #d63a1f; --accent2: #e8472a;
      --user-color: #1a7fd4; --text: #1a2236; --text-muted: #5a6a82; --success: #1a9e55;
    }
    * { box-sizing: border-box; margin: 0; padding: 0; }
    body { font-family: "Heebo", sans-serif; background: var(--bg); color: var(--text); height: 100vh; overflow: hidden; display: flex; flex-direction: column; }

    /* HEADER */
    header {
  position: relative;
  z-index: 1000;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 20px rgba(0,0,0,.4);
  flex-shrink: 0;

  display: grid;
  grid-template-columns: 1fr auto auto;
  grid-template-areas:
    "brand type actions"
    "areas areas areas";
  gap: 8px 12px;
  align-items: center;
  padding: 10px 16px;
}
    header h1 { font-size: 17px; font-weight: 800; letter-spacing: -0.3px; white-space: nowrap; }
    header p  { font-size: 11px; color: var(--text-muted); margin-top: 1px; white-space: nowrap; }
    #status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  padding: 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

#status-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9aa6b2;
}

#status-badge.located {
  color: var(--success);
}

#status-badge.located::before {
  background: var(--success);
  box-shadow: 0 0 8px rgba(46, 204, 113, 0.7);
}
    #theme-toggle { background: var(--surface2); border: 1px solid var(--border); border-radius: 20px; padding: 6px 12px; color: var(--text); font-family: "Heebo", sans-serif; font-size: 12px; cursor: pointer; white-space: nowrap; flex-shrink: 0; transition: border-color .2s, color .2s; }
    #theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

    /* AREA SWITCHER */
    #area-switcher { display: flex; gap: 5px; flex-shrink: 0; }
    .area-btn { background: var(--surface2); border: 1px solid var(--border); border-radius: 20px; padding: 6px 12px; color: var(--text-muted); font-family: "Heebo", sans-serif; font-size: 12px; font-weight: 600; cursor: pointer; transition: all .2s; white-space: nowrap; }
    .area-btn:hover { border-color: var(--accent); color: var(--accent); }
    .area-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 0 10px rgba(232,71,42,.4); }
    .area-btn.loading { opacity: .6; pointer-events: none; }

    /* LAYOUT */
    .app-body { flex: 1; display: flex; overflow: hidden; position: relative; }
    #map { flex: 1; background: #0d1421; position: relative; z-index: 1; }

    /* PANEL */
    #panel { width: var(--panel-w); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; flex-shrink: 0; z-index: 10; }
    #panel-tab { display: none; }
    .panel-header { padding: 16px 18px 12px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
    .panel-header h2 { font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
    #shelter-count { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
    #shelter-list { flex: 1; overflow-y: auto; padding: 8px 0; }
    #shelter-list::-webkit-scrollbar { width: 4px; }
    #shelter-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

    /* Loading state for list */
    .list-loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 30px; color: var(--text-muted); font-size: 13px; }
    .list-loading::before { content: ""; width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; flex-shrink: 0; }
    @keyframes spin { to { transform: rotate(360deg); } }

    .shelter-item { padding: 12px 18px; cursor: pointer; border-bottom: 1px solid rgba(31,45,69,.5); transition: background .15s; display: flex; align-items: center; gap: 12px; }
    .shelter-item:hover { background: var(--surface2); }
    .shelter-item.active { background: rgba(232,71,42,.08); border-right: 3px solid var(--accent); }
    .shelter-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex-shrink: 0; box-shadow: 0 0 6px rgba(232,71,42,.5); }
    .shelter-info { flex: 1; min-width: 0; }
    .shelter-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .shelter-dist { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
    .shelter-arrow { color: var(--text-muted); font-size: 14px; transition: color .15s, transform .15s; }
    .shelter-item:hover .shelter-arrow, .shelter-item.active .shelter-arrow { color: var(--accent); transform: translateX(-3px); }

    /* ROUTE CARD */
    #route-card { margin: 12px; background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; display: none; flex-shrink: 0; animation: slideUp .25s ease; }
    @keyframes slideUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
    #route-card.visible { display: block; }
    .route-card-title { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px; }
    .route-stats { display: flex; gap: 12px; margin-bottom: 12px; }
    .route-stat { flex: 1; background: var(--surface); border-radius: 8px; padding: 10px; text-align: center; }
    .route-stat .val { font-size: 18px; font-weight: 800; color: var(--accent2); }
    .route-stat .lbl { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
    #clear-btn { width: 100%; padding: 9px; border: 1px solid var(--border); border-radius: 8px; background: transparent; color: var(--text-muted); font-family: "Heebo", sans-serif; font-size: 12px; cursor: pointer; transition: all .2s; }
    #clear-btn:hover { border-color: var(--accent); color: var(--accent); }

    /* MAP BUTTONS */
    .map-btn { position: absolute; z-index: 800; background: var(--accent); border: none; border-radius: 10px; padding: 12px 20px; color: #fff; font-family: "Heebo", sans-serif; font-size: 14px; font-weight: 700; cursor: pointer; display: flex; align-items: center; gap: 8px; box-shadow: 0 4px 18px rgba(232,71,42,.5); transition: transform .15s, box-shadow .15s; white-space: nowrap; }
    .map-btn:hover { transform: scale(1.04); box-shadow: 0 6px 24px rgba(232,71,42,.65); }
    #locate-btn { bottom: 90px; left: 50%; transform: translateX(-50%); }
    #locate-btn:hover { transform: translateX(-50%) scale(1.04); }

    /* GPS HINT */
    #loc-hint { display: none; position: absolute; bottom: 160px; left: 50%; transform: translateX(-50%); z-index: 800; background: var(--surface); border: 1px solid var(--accent); border-radius: 12px; padding: 14px 18px; font-size: 13px; line-height: 1.8; color: var(--text); white-space: nowrap; box-shadow: 0 6px 24px rgba(0,0,0,.4); text-align: right; }

    /* TOAST */
    #toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px); background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 20px; font-size: 13px; z-index: 2000; transition: transform .3s ease; white-space: nowrap; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
    #toast.show  { transform: translateX(-50%) translateY(0); }
    #toast.error { border-color: var(--accent); color: var(--accent2); }

    /* LEAFLET */
    .leaflet-tile-pane { filter: brightness(0.75) saturate(0.6) hue-rotate(180deg) invert(1) hue-rotate(180deg) brightness(0.55) saturate(1.4); }
    body.light .leaflet-tile-pane { filter: none; }
    .user-marker-icon { width: 16px; height: 16px; background: var(--user-color); border-radius: 50%; border: 3px solid white; box-shadow: 0 0 0 4px rgba(59,158,255,.35), 0 0 20px rgba(59,158,255,.6); animation: pulse 2s infinite; }
    @keyframes pulse { 0%,100% { box-shadow: 0 0 0 4px rgba(59,158,255,.35), 0 0 20px rgba(59,158,255,.6); } 50% { box-shadow: 0 0 0 8px rgba(59,158,255,.15), 0 0 30px rgba(59,158,255,.4); } }
    .shelter-marker-icon { width: 14px; height: 14px; background: var(--accent); border-radius: 50%; border: 2px solid rgba(255,255,255,.6); box-shadow: 0 0 10px rgba(232,71,42,.7); }
    .shelter-marker-icon.selected { width: 18px; height: 18px; background: var(--accent2); box-shadow: 0 0 18px rgba(255,107,74,.9); }
    .leaflet-popup-content-wrapper { background: var(--surface2) !important; border: 1px solid var(--border) !important; border-radius: 10px !important; box-shadow: 0 8px 30px rgba(0,0,0,.5) !important; color: var(--text) !important; font-family: "Heebo", sans-serif !important; }
    .leaflet-popup-tip { background: var(--surface2) !important; }
    .leaflet-popup-close-button { color: var(--text-muted) !important; }

    /* LOADING */
    #loading { position: fixed; inset: 0; background: var(--bg); z-index: 3000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; transition: opacity .5s; }
    #loading.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .3s ease;
}
    .loader-icon { font-size: 48px; animation: bounce 1s infinite alternate; }
    @keyframes bounce { from { transform: translateY(0); } to { transform: translateY(-12px); } }
    #loading p { font-size: 14px; color: var(--text-muted); }

    /* MOBILE */
    

    /* ========= TYPE TOGGLE ========= */

#type-toggle {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #dfe6ef;
  border: 1px solid #bfc9d8;
  border-radius: 24px;
  flex-shrink: 0;
}

.type-btn {
  background: #f8fafc;
  color: #394150;
  border: 1px solid #d0d8e5;
  border-radius: 18px;
  padding: 8px 14px;
  cursor: pointer;
  font-family: "Heebo", sans-serif;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  transition: all 0.25s ease;
}

.type-btn:hover {
  background: #eef3f8;
  border-color: #aeb9c8;
}

.type-btn.active {
  color: #fff;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.25);
}

/* מצב מרחבים מוגנים */
.type-btn[data-type="shelters"].active {
  background: var(--accent);
  border-color: var(--accent);
}

/* מצב דפיברילטורים */
.type-btn[data-type="defibrillators"].active {
  background: #1fae5b;
  border-color: #1fae5b;
}

.defib-marker-icon {
  width: 14px;
  height: 14px;
  background: #1fae5b;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.6);
  box-shadow: 0 0 10px rgba(31,174,91,.7);
}

.defib-marker-icon.selected {
  width: 18px;
  height: 18px;
  background: #2ecc71;
  box-shadow: 0 0 18px rgba(46,204,113,.9);
}

/* ========= HEADER LAYOUT ========= */

header {
  position: relative;
  z-index: 1000;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 20px rgba(0,0,0,.4);
  flex-shrink: 0;

  display: grid;
  grid-template-columns: 1fr auto auto;
  grid-template-areas:
    "brand type actions"
    "areas areas areas";
  gap: 8px 12px;
  align-items: center;
  padding: 10px 16px;
}

.header-main {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo-img {
  height: 42px;
  width: 42px;
  object-fit: contain;
  display: block;
}

.header-title {
  min-width: 0;
}

#app-title {
  font-size: 16px;
  line-height: 1.2;
  transition: color 0.25s ease;
}

#app-subtitle {
  font-size: 11px;
  line-height: 1.2;
  color: var(--text-muted);
}

body.mode-shelters #app-title {
  color: var(--accent);
}

body.mode-defibrillators #app-title {
  color: #1fae5b;
}

#type-toggle {
  grid-area: type;
  justify-self: end;
}

#area-switcher {
  grid-area: areas;
  display: flex;
  gap: 6px;
  min-width: 0;
}

.header-actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* ========= MOBILE HEADER ========= */

@media (max-width: 600px) {
  header {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand actions"
      "type type"
      "areas areas";
    gap: 8px;
    padding: 10px 12px;
  }

  .header-main {
    width: auto;
    min-width: 0;
  }

  .header-actions {
    width: auto;
    justify-content: flex-end;
    gap: 6px;
  }

  #type-toggle {
    width: 100%;
    justify-self: stretch;
  }

  #area-switcher {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 4px 0;
  }

  .type-btn {
    flex: 1;
    text-align: center;
  }

  .area-btn {
    flex: 0 0 auto;
  }

  #app-title {
    font-size: 14px;
  }

  #app-subtitle {
    display: none;
  }

  .logo-img {
    width: 36px;
    height: 36px;
  }

  .header-icon-btn {
    height: 36px;
    min-width: 40px;
    padding: 0 8px;
  }
    .app-body {
    position: relative;
    overflow: hidden;
  }

  #map {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
  }

  #panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;

    width: 100%;
    height: 58vh;

    border-right: none;
    border-top: 1px solid var(--border);
    border-radius: 20px 20px 0 0;

    box-shadow: 0 -8px 40px rgba(0,0,0,.55);
    z-index: 500;

    transform: translateY(calc(100% - var(--tab-h)));
    transition: transform .38s cubic-bezier(.4, 0, .2, 1);
  }

  #panel.open {
    transform: translateY(0);
  }

  #panel-tab {
    display: flex;
    align-items: center;
    justify-content: space-between;

    height: 58px;          /* במקום var(--tab-h) */
    padding: 0 18px;

    background: var(--surface);
    border-radius: 20px 20px 0 0;
    border-bottom: 1px solid var(--border);

    position: relative;
  }

  #tab-label {
    display: flex;
    align-items: center;
    gap: 6px;

    font-size: 15px;
    font-weight: 700;
    line-height: 1;
}

#tab-arrow {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 28px;
    height: 28px;

    font-size: 18px;
    line-height: 1;
    color: var(--accent);
}
}

/* ========= HEADER TOP ACTIONS ========= */

.header-actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.header-icon-btn {
  min-width: 42px;
  height: 38px;
  padding: 0 10px;
  border-radius: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: "Heebo", sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.header-icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}