* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
body { font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif; background:#f0f4f0; }

/* ── Topbar ── */
.topbar {
  background:linear-gradient(135deg,#1a1a2e,#16213e);
  color:white; padding:12px 16px;
  display:flex; align-items:center; justify-content:space-between;
  position:relative; z-index:1002;
  box-shadow:0 2px 12px rgba(0,0,0,0.3);
}
.topbar h1 {
  font-size:22px; font-weight:700; letter-spacing:-0.5px;
  background:linear-gradient(90deg,#fff,#22c55e);
  background-clip:text; -webkit-background-clip:text;
  -webkit-text-fill-color:transparent;
}
.topbar p { font-size:11px; color:rgba(255,255,255,0.5); margin-top:1px; }
.topbar-right { display:flex; align-items:center; gap:8px; }

.live-badge {
  display:flex; align-items:center; gap:5px;
  background:rgba(34,197,94,0.15); border:1px solid rgba(34,197,94,0.3);
  padding:4px 10px; border-radius:20px;
  font-size:11px; color:#22c55e; font-weight:600;
}
.live-dot {
  width:6px; height:6px; border-radius:50%; background:#22c55e;
  animation:pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%,100% { opacity:1; transform:scale(1); }
  50%      { opacity:0.5; transform:scale(1.3); }
}
@keyframes spin { to { transform:rotate(360deg); } }
.spinning { display:inline-block; animation:spin 0.7s linear infinite; }

.btn-topbar {
  background:rgba(255,255,255,0.1); border:1px solid rgba(255,255,255,0.15);
  color:white; border-radius:10px; padding:5px 11px; font-size:12px;
  cursor:pointer; display:flex; align-items:center; gap:4px;
  transition:all 0.2s; font-family:inherit;
}
.btn-topbar:hover { background:rgba(255,255,255,0.2); }
.countdown-text { font-size:11px; color:rgba(255,255,255,0.35); }

/* ── Searchbar ── */
.searchbar {
  background:rgba(255,255,255,0.98); padding:10px 14px;
  display:flex; gap:8px; border-bottom:1px solid rgba(0,0,0,0.08);
  box-shadow:0 2px 8px rgba(0,0,0,0.06);
  position:relative; z-index:1001;
}
.search-wrapper { position:relative; flex:1; }
.search-wrapper input {
  width:100%; padding:10px 14px 10px 38px;
  border:1.5px solid #e5e7eb; border-radius:12px;
  font-size:14px; outline:none; background:#f9fafb;
  transition:all 0.2s; font-family:inherit;
}
.search-wrapper input:focus {
  border-color:#22c55e; background:#fff;
  box-shadow:0 0 0 3px rgba(34,197,94,0.1);
}
.search-wrapper::before {
  content:'🔍'; font-size:13px;
  position:absolute; left:12px; top:50%;
  transform:translateY(-50%); z-index:1; pointer-events:none;
}

.suggestions {
  position:absolute; top:calc(100% + 6px); left:0; right:0;
  background:white; border:1px solid #e5e7eb; border-radius:14px;
  box-shadow:0 8px 32px rgba(0,0,0,0.12); z-index:9999;
  max-height:260px; overflow-y:auto; display:none;
}
.suggestions.open { display:block; }
.sug-item {
  padding:10px 14px; cursor:pointer; display:flex;
  align-items:center; gap:10px; font-size:13px;
  border-bottom:1px solid #f5f5f5; transition:background 0.1s;
}
.sug-item:last-child { border:none; }
.sug-item:hover, .sug-item.active { background:#f0fdf4; }
.sug-icon {
  width:28px; height:28px; border-radius:50%; flex-shrink:0;
  display:flex; align-items:center; justify-content:center; font-size:13px;
}
.sug-icon.known   { background:#dcfce7; }
.sug-icon.search  { background:#eff6ff; }
.sug-icon.loading { background:#f3f4f6; }
.sug-main { font-weight:600; color:#111; font-size:13px; }
.sug-sub  { font-size:11px; color:#9ca3af; margin-top:1px; }
.sug-badge {
  margin-left:auto; font-size:10px; padding:3px 8px;
  border-radius:20px; font-weight:600; flex-shrink:0;
}
.bg-green  { background:#dcfce7; color:#15803d; }
.bg-yellow { background:#fef9c3; color:#b45309; }
.bg-red    { background:#fee2e2; color:#b91c1c; }
.bg-blue   { background:#eff6ff; color:#1d4ed8; }

.btn-search {
  padding:10px 18px;
  background:linear-gradient(135deg,#22c55e,#16a34a);
  color:white; border:none; border-radius:12px;
  font-size:14px; font-weight:600; cursor:pointer;
  box-shadow:0 2px 8px rgba(34,197,94,0.3);
  font-family:inherit; transition:all 0.2s;
}
.btn-search:hover { transform:translateY(-1px); }

/* ── Main layout ── */
.main {
  display:flex;
  height:calc(100vh - 108px);
  position:relative; z-index:1;
}
#map { flex:1; }

/* ── Sidebar (desktop) ── */
.sidebar {
  width:280px; background:#fff;
  border-left:1px solid #e5e7eb;
  display:flex; flex-direction:column; overflow:hidden;
}
.sheet-handle { display:none; }
.sidebar-head {
  padding:12px 16px; font-size:13px; font-weight:600;
  color:#374151; border-bottom:1px solid #f3f4f6;
  background:linear-gradient(135deg,#f8faff,#f0fdf4);
  flex-shrink:0; display:flex; align-items:center; justify-content:space-between;
}
.btn-back { display:none; }
.street-list { flex:1; overflow-y:auto; }
.street-list::-webkit-scrollbar { width:4px; }
.street-list::-webkit-scrollbar-thumb { background:#d1d5db; border-radius:2px; }

/* ── Street items ── */
.street-item {
  padding:12px 14px; border-bottom:1px solid #f3f4f6;
  cursor:pointer; display:flex; align-items:flex-start; gap:10px;
  transition:all 0.15s;
}
.street-item:hover { background:#f0fdf4; transform:translateX(2px); }
.street-item:active { transform:none; }

.dot {
  width:12px; height:12px; border-radius:50%;
  flex-shrink:0; margin-top:3px;
}
.dot.green   { background:#22c55e; box-shadow:0 0 6px #22c55e; }
.dot.yellow  { background:#fbbf24; box-shadow:0 0 6px #fbbf24; }
.dot.red     { background:#ef4444; box-shadow:0 0 6px #ef4444; }
.dot.expired { background:#94a3b8; }
.dot.unknown { background:#94a3b8; }

.s-name { font-size:13px; font-weight:600; color:#111; }
.s-info { font-size:12px; color:#6b7280; margin-top:2px; }
.s-time { font-size:11px; color:#d1d5db; margin-top:2px; }

.fresh-bar { height:3px; background:#f3f4f6; border-radius:2px; margin-top:4px; overflow:hidden; }
.fresh-fill { height:100%; border-radius:2px; transition:width 1s; }
.fresh-fill.fresh   { background:linear-gradient(90deg,#22c55e,#86efac); }
.fresh-fill.aging   { background:linear-gradient(90deg,#fbbf24,#fde68a); }
.fresh-fill.stale   { background:linear-gradient(90deg,#f97316,#fdba74); }
.fresh-fill.expired { background:#e5e7eb; width:0 !important; }

.conf-row { display:flex; justify-content:space-between; font-size:10px; color:#9ca3af; margin-top:4px; }
.conf-bar { height:3px; background:#f3f4f6; border-radius:2px; margin-top:2px; overflow:hidden; }
.conf-fill { height:100%; background:linear-gradient(90deg,#3b82f6,#93c5fd); border-radius:2px; }

.c-bubble {
  font-size:11px; color:#6b7280; font-style:italic;
  background:#f8fafc; border:1px solid #e2e8f0;
  border-radius:8px; padding:5px 9px; margin-top:5px;
}

/* ── Report panel ── */
.report-panel {
  border-top:1px solid #f3f4f6; padding:12px 14px;
  overflow-y:auto; flex-shrink:0; max-height:46vh;
  background:linear-gradient(180deg,#fff,#f8faff);
}
.rp-header {
  display:flex; align-items:center;
  justify-content:space-between; margin-bottom:10px;
}
.rp-title { font-size:12px; color:#6b7280; font-weight:500; }
.btn-update {
  background:linear-gradient(135deg,#f0fdf4,#dcfce7);
  border:1px solid #86efac; color:#15803d;
  border-radius:8px; padding:4px 10px; font-size:12px;
  cursor:pointer; display:flex; align-items:center; gap:4px;
  font-weight:600; font-family:inherit; transition:all 0.2s;
}
.selected-label {
  font-size:12px; font-weight:600; color:#15803d;
  background:linear-gradient(135deg,#f0fdf4,#dcfce7);
  border:1px solid #86efac; border-radius:10px;
  padding:7px 12px; margin-bottom:10px;
}
.adj-btn {
  width:32px; height:32px; border-radius:50%;
  border:1.5px solid #e5e7eb; background:white;
  font-size:16px; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  transition:all 0.15s; font-family:inherit;
}
.adj-btn:hover { border-color:#22c55e; color:#22c55e; transform:scale(1.1); }

.comment-input {
  width:100%; padding:8px 12px; border:1.5px solid #e5e7eb;
  border-radius:10px; font-size:13px; font-family:inherit;
  resize:none; height:42px; outline:none;
  background:#f9fafb; transition:all 0.2s;
}
.comment-input:focus { border-color:#22c55e; background:#fff; }

/* ── Action buttons ── */
.btn-free {
  width:100%; padding:12px; margin-bottom:7px;
  background:linear-gradient(135deg,#22c55e,#16a34a);
  color:white; border:none; border-radius:12px;
  font-size:14px; font-weight:700; cursor:pointer;
  font-family:inherit; transition:all 0.2s;
  box-shadow:0 3px 10px rgba(34,197,94,0.3);
}
.btn-taken {
  width:100%; padding:12px; margin-bottom:7px;
  background:linear-gradient(135deg,#f87171,#ef4444);
  color:white; border:none; border-radius:12px;
  font-size:14px; font-weight:700; cursor:pointer;
  font-family:inherit; transition:all 0.2s;
  box-shadow:0 3px 10px rgba(239,68,68,0.25);
}
.btn-confirm {
  width:100%; padding:11px; margin-bottom:7px;
  background:linear-gradient(135deg,#eff6ff,#dbeafe);
  color:#1d4ed8; border:1.5px solid #93c5fd;
  border-radius:12px; font-size:13px; font-weight:600;
  cursor:pointer; display:none; font-family:inherit;
}
.btn-free:hover    { transform:translateY(-2px); box-shadow:0 6px 16px rgba(34,197,94,0.4); }
.btn-taken:hover   { transform:translateY(-2px); box-shadow:0 6px 16px rgba(239,68,68,0.35); }
.btn-confirm:hover { transform:translateY(-1px); }
.btn-free:disabled, .btn-taken:disabled { opacity:0.5; cursor:not-allowed; transform:none; }

/* ── Toast ── */
.toast {
  position:fixed; bottom:24px; left:50%; transform:translateX(-50%);
  background:linear-gradient(135deg,#1a1a2e,#16213e);
  color:white; padding:10px 20px; border-radius:12px;
  font-size:13px; font-weight:500; z-index:99999;
  opacity:0; transition:all 0.3s; pointer-events:none;
  white-space:nowrap; box-shadow:0 4px 20px rgba(0,0,0,0.25);
}
.toast.show { opacity:1; transform:translateX(-50%) translateY(-4px); }

/* ══════════════════════════════════
   MOBILE LAYOUT
══════════════════════════════════ */
@media (max-width: 768px) {

  body {
    height:100vh; overflow:hidden;
    display:flex; flex-direction:column;
  }

  .topbar { flex-shrink:0; padding:10px 14px; position:relative; z-index:1002; }
  .topbar h1 { font-size:18px; }
  .countdown-text { display:none; }

  .searchbar { flex-shrink:0; padding:8px 12px; gap:7px; position:relative; z-index:1001; }
  .search-wrapper input { font-size:16px; }
  .btn-search { padding:10px 14px; }

  .main { flex:1; position:relative; min-height:0; overflow:hidden; }

  #map { position:absolute; top:0; left:0; right:0; bottom:0; z-index:10; }

  .sidebar {
    position:absolute; bottom:0; left:0; right:0;
    border-left:none; border-radius:20px 20px 0 0;
    box-shadow:0 -6px 24px rgba(0,0,0,0.2);
    z-index:200; background:white;
    display:flex; flex-direction:column;
    max-height:56px; overflow:hidden; width:100%;
    transition:max-height 0.4s cubic-bezier(0.4,0,0.2,1);
  }
  .sidebar.expanded { max-height:88vh; overflow-y:auto; }

  .sheet-handle {
    display:block; width:40px; height:4px; background:#d1d5db;
    border-radius:2px; margin:8px auto 0; flex-shrink:0; cursor:pointer;
  }

  .sidebar-head {
    flex-shrink:0; padding:8px 16px 10px;
    font-size:14px; font-weight:700;
    cursor:pointer; user-select:none;
    border-bottom:1px solid #f3f4f6;
    background:transparent;
    display:flex; align-items:center; justify-content:space-between;
    min-height:40px;
  }

  .btn-back {
    display:block !important;
    background:#1a1a2e; color:white;
    border:none; border-radius:20px;
    padding:5px 12px; font-size:12px;
    font-weight:600; cursor:pointer; font-family:inherit;
  }

  .street-list {
    max-height:160px; overflow-y:auto;
    -webkit-overflow-scrolling:touch; flex-shrink:0;
  }

  .street-item { padding:14px 16px; }
  .street-item:hover { transform:none; }
  .street-item:active { background:#f0fdf4; }

  .dot { width:13px; height:13px; }
  .s-name { font-size:14px; }
  .s-info { font-size:13px; }

  .report-panel {
    max-height:none; padding:14px 16px 32px;
    border-top:1px solid #f3f4f6; flex-shrink:0;
  }

  #free-val { font-size:52px !important; }

  .adj-btn { width:40px !important; height:40px !important; font-size:20px !important; }

  .btn-free, .btn-taken { padding:16px; font-size:16px; border-radius:14px; margin-bottom:8px; }
  .btn-confirm { padding:14px; font-size:14px; }
  .btn-free:hover, .btn-taken:hover { transform:none; box-shadow:none; }
  .btn-free:active  { opacity:0.85; }
  .btn-taken:active { opacity:0.85; }

  .toast { bottom:80px; }
}

/* ── Small phones ── */
@media (max-width: 380px) {
  #free-val { font-size:44px !important; }
  .btn-free, .btn-taken { font-size:15px; padding:14px; }
}

/* ── Leaflet custom ── */
.leaflet-control-zoom a {
  border-radius:10px !important;
  width:32px !important; height:32px !important;
  line-height:32px !important;
}
.leaflet-popup-content-wrapper {
  border-radius:14px !important;
  box-shadow:0 4px 20px rgba(0,0,0,0.15) !important;
}
.leaflet-popup-content {
  font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif !important;
  font-size:13px !important; margin:10px 14px !important;
}