
  :root {
    --bg:      #f0f4f8;
    --surface: #ffffff;
    --panel:   #1a2744;
    --panel2:  #243154;
    --accent:  #f59e0b;
    --blue:    #2563eb;
    --purple:  #7c3aed;
    --orange:  #ea580c;
    --red:     #ef4444;
    --text:    #1e293b;
    --muted:   #64748b;
    --border:  #e2e8f0;
    --radius:  12px;
    --shadow:  0 4px 24px rgba(0,0,0,0.10);
  }


  #sf-widget {
    font-family: 'Be Vietnam Pro', sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 80vh;
    min-height: 480px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
  }
  #sf-widget *, #sf-widget *::before, #sf-widget *::after { box-sizing: border-box; margin: 0; padding: 0; }

  /* ── HEADER ── */
  .app-header {
    background: var(--panel);
    color: white;
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 12px rgba(0,0,0,0.25);
    z-index: 1000;
    position: relative;
    flex-shrink: 0;
  }
  .app-header .logo { display: flex; align-items: center; gap: 10px; }
  .app-header .logo-icon { width: 36px; height: 36px; border-radius: 8px; background: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 18px; }
  .app-header .logo-text { font-family: 'Lexend', sans-serif; font-weight: 700; font-size: 15px; letter-spacing: -0.3px; line-height: 1.2; }
  .app-header .logo-sub { font-size: 11px; font-weight: 300; opacity: 0.7; letter-spacing: 0.3px; }
  .app-header .header-badge { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); border-radius: 99px; padding: 4px 12px; font-size: 11px; font-weight: 500; color: rgba(255,255,255,0.8); white-space: nowrap; }

  /* ── LAYOUT ── */
  .app-body { flex: 1; display: flex; overflow: hidden; min-height: 0; }

  /* ── SIDEBAR ── */
  .sidebar { width: 360px; min-width: 320px; background: var(--surface); display: flex; flex-direction: column; border-right: 1px solid var(--border); z-index: 10; overflow: hidden; min-height: 0; }

  /* Search area */
  .search-area { padding: 9px 12px; background: var(--panel); flex-shrink: 0; }
  .search-label { font-size: 10px; font-weight: 600; letter-spacing: 0.8px; text-transform: uppercase; color: rgba(255,255,255,0.5); margin-bottom: 5px; }
  .search-box { position: relative; }
  .search-input { width: 100%; background: rgba(255,255,255,0.1); border: 1.5px solid rgba(255,255,255,0.15); border-radius: 9px; padding: 8px 36px 8px 12px; color: white; font-family: 'Be Vietnam Pro', sans-serif; font-size: 12.5px; outline: none; transition: border-color 0.2s; }
  .search-input::placeholder { color: rgba(255,255,255,0.4); }
  .search-input:focus { border-color: var(--accent); background: rgba(255,255,255,0.15); }
  .search-icon { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: rgba(255,255,255,0.4); font-size: 14px; pointer-events: none; }
  .search-spinner { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; border: 2px solid rgba(255,255,255,0.3); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; display: none; }
  .search-spinner.show { display: block; }

  .autocomplete-list { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--panel2); border: 1px solid rgba(255,255,255,0.1); border-radius: 10px; overflow: hidden; box-shadow: 0 8px 32px rgba(0,0,0,0.4); z-index: 9999; display: none; max-height: 280px; overflow-y: auto; }
  .autocomplete-list.show { display: block; }
  .ac-item { padding: 10px 14px; cursor: pointer; font-size: 12.5px; color: rgba(255,255,255,0.85); border-bottom: 1px solid rgba(255,255,255,0.07); display: flex; align-items: flex-start; gap: 8px; transition: background 0.15s; }
  .ac-item:last-child { border-bottom: none; }
  .ac-item:hover { background: rgba(255,255,255,0.1); }
  .ac-item-icon { color: var(--accent); font-size: 14px; margin-top: 1px; flex-shrink: 0; }
  .ac-item-main { font-weight: 500; }
  .ac-item-sub { font-size: 11px; color: rgba(255,255,255,0.45); margin-top: 1px; }

  .search-btn { margin-top: 7px; width: 100%; background: var(--accent); color: #1a1a1a; border: none; border-radius: 9px; padding: 8px; font-family: 'Lexend', sans-serif; font-size: 12.5px; font-weight: 600; letter-spacing: 0.3px; cursor: pointer; transition: opacity 0.2s, transform 0.1s; display: flex; align-items: center; justify-content: center; gap: 5px; }
  .search-btn:hover { opacity: 0.9; }
  .search-btn:active { transform: scale(0.98); }
  .search-btn:disabled { opacity: 0.6; cursor: not-allowed; }

  /* Nút bao gồm "Tìm" + "Lọc" */
  .search-actions { display: flex; gap: 6px; margin-top: 7px; }
  .filter-toggle-btn {
    background: rgba(255,255,255,0.1); border: 1.5px solid rgba(255,255,255,0.2);
    border-radius: 9px; padding: 8px 11px; color: white; cursor: pointer;
    font-family: 'Be Vietnam Pro', sans-serif; font-size: 12px; font-weight: 500;
    display: flex; align-items: center; gap: 4px; position: relative;
    transition: background 0.2s; white-space: nowrap; flex-shrink: 0;
  }
  .filter-toggle-btn:hover { background: rgba(255,255,255,0.18); }
  .filter-toggle-btn.active { background: rgba(245,158,11,0.25); border-color: var(--accent); color: var(--accent); }
  .filter-badge {
    position: absolute; top: -5px; right: -5px;
    background: var(--accent); color: #1a1a1a;
    border-radius: 99px; font-size: 9px; font-weight: 700;
    min-width: 15px; height: 15px; padding: 0 3px;
    display: flex; align-items: center; justify-content: center;
  }

  /* Active filter tags trong results meta */
  .filter-tag {
    display: inline-block; background: #f0f4f8; color: var(--muted);
    border-radius: 99px; padding: 1px 7px; font-size: 10px; font-weight: 500;
    margin-left: 4px;
  }

  /* ── FILTER BAR ── */
  .filter-bar { padding: 6px 12px; background: #f8fafc; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 5px; flex-shrink: 0; }
  .filter-row { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
  .filter-label { font-size: 10px; font-weight: 600; color: var(--muted); letter-spacing: 0.3px; white-space: nowrap; min-width: 26px; }
  .chip { padding: 2px 9px; border-radius: 99px; border: 1px solid var(--border); background: white; font-family: 'Be Vietnam Pro', sans-serif; font-size: 10.5px; font-weight: 500; color: var(--muted); cursor: pointer; transition: all 0.15s; white-space: nowrap; }
  .chip:hover { border-color: var(--blue); color: var(--blue); }
  .chip.active { background: var(--blue); color: white; border-color: var(--blue); }

  /* ── RESULTS HEADER ── */
  .results-header { padding: 8px 12px 6px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
  .results-header-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2px; }
  .results-title { font-family: 'Lexend', sans-serif; font-size: 12px; font-weight: 600; color: var(--text); }
  .results-meta { font-size: 10.5px; color: var(--muted); }
  .back-btn { font-size: 11px; color: var(--blue); background: none; border: none; cursor: pointer; font-family: 'Be Vietnam Pro', sans-serif; font-weight: 500; padding: 0; display: flex; align-items: center; gap: 4px; }
  .back-btn:hover { text-decoration: underline; }
  .print-btn { font-size: 11px; color: var(--muted); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; cursor: pointer; font-family: 'Be Vietnam Pro', sans-serif; font-weight: 500; display: flex; align-items: center; gap: 3px; transition: all 0.15s; }
  .print-btn:hover { border-color: var(--blue); color: var(--blue); background: #eff6ff; }

  /* ── SCHOOL CARDS ── */
  .results-list { padding: 10px; }

  .school-card { background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius); padding: 13px 13px 13px 17px; margin-bottom: 10px; cursor: pointer; transition: all 0.2s; position: relative; overflow: hidden; }
  .school-card::before { content: ''; position: absolute; top: 0; left: 0; bottom: 0; width: 4px; border-radius: 4px 0 0 4px; }
  .school-card.cong-lap::before { background: var(--purple); }
  .school-card.dan-lap::before { background: var(--orange); }
  .school-card:hover { border-color: var(--blue); box-shadow: 0 4px 16px rgba(37,99,235,0.12); transform: translateY(-1px); }
  .school-card.active { border-color: var(--blue); background: #eff6ff; box-shadow: 0 4px 16px rgba(37,99,235,0.15); }

  .card-top { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 7px; }
  .card-rank { width: 24px; height: 24px; border-radius: 6px; background: var(--blue); color: white; font-family: 'Lexend', sans-serif; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
  .card-rank.rank-1 { background: #f59e0b; color: #1a1a1a; }
  .card-rank.rank-2 { background: #94a3b8; }
  .card-rank.rank-3 { background: #b45309; }
  .card-rank.rank-4 { background: #6366f1; }
  .card-rank.rank-5 { background: #0891b2; }
  .card-name { font-family: 'Lexend', sans-serif; font-size: 13px; font-weight: 600; line-height: 1.35; color: var(--text); flex: 1; }

  /* Badge row */
  .badge-row { display: flex; gap: 5px; align-items: center; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; margin-left: auto; }
  .card-type { font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 99px; white-space: nowrap; }
  .card-type.cong-lap { background: #f3e8ff; color: var(--purple); }
  .card-type.dan-lap  { background: #fff7ed; color: var(--orange); }
  .cap-badge { font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 99px; white-space: nowrap; }
  .cap-mamnon  { background: #fce7f3; color: #be185d; }
  .cap-tieuhoc { background: #dbeafe; color: #1d4ed8; }
  .cap-thcs    { background: #ccfbf1; color: #0f766e; }
  .cap-thpt    { background: #dcfce7; color: #15803d; }

  .card-stats { display: flex; gap: 10px; flex-wrap: wrap; }
  .card-stat { display: flex; align-items: flex-start; gap: 4px; font-size: 11.5px; color: var(--muted); }
  .card-stat b { color: var(--text); font-weight: 600; }
  .dist-note { font-size: 10px; color: var(--muted); opacity: 0.7; }
  .card-addr { font-size: 11px; color: var(--muted); margin: 5px 0; line-height: 1.4; display: flex; gap: 4px; }

  .card-actions { margin-top: 9px; display: flex; gap: 6px; }
  .card-btn { flex: 1; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--muted); font-family: 'Be Vietnam Pro', sans-serif; font-size: 11.5px; font-weight: 500; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 5px; transition: all 0.15s; }
  .card-btn:hover { border-color: var(--blue); color: var(--blue); background: #eff6ff; }
  .card-btn.primary { background: var(--blue); color: white; border-color: var(--blue); }
  .card-btn.primary:hover { background: #1d4ed8; }

  /* No results */
  .no-results { text-align: center; padding: 30px 16px; color: var(--muted); font-size: 13px; }

  /* Legend */
  .legend { padding: 10px 16px; border-top: 1px solid var(--border); display: flex; gap: 14px; flex-shrink: 0; flex-wrap: wrap; }
  .legend-item { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
  .legend-dot { width: 11px; height: 11px; border-radius: 50%; border: 2px solid white; box-shadow: 0 1px 4px rgba(0,0,0,0.2); }
  .legend-dot.purple { background: var(--purple); }
  .legend-dot.orange { background: var(--orange); }
  .rotate-hint { display: none; font-size: 11px; color: var(--muted); align-items: center; gap: 6px; }

  /* ── MAP ── */
  #map { flex: 1; z-index: 1; }

  /* Popup */
  .leaflet-popup-content-wrapper { border-radius: 12px !important; box-shadow: 0 8px 32px rgba(0,0,0,0.15) !important; border: none !important; padding: 0 !important; overflow: hidden; }
  .leaflet-popup-content { margin: 0 !important; width: auto !important; min-width: 230px; }
  .leaflet-popup-tip { display: none; }
  .leaflet-popup-close-button { color: white !important; right: 8px !important; top: 8px !important; font-size: 16px !important; }
  .popup-inner { font-family: 'Be Vietnam Pro', sans-serif; }
  .popup-header { padding: 11px 13px 9px; color: white; }
  .popup-header.cong-lap { background: var(--purple); }
  .popup-header.dan-lap  { background: var(--orange); }
  .popup-school-name { font-weight: 700; font-size: 13.5px; line-height: 1.3; margin-bottom: 3px; padding-right: 22px; /* tránh chồng nút ✕ */ }
  .popup-badges { display: flex; gap: 5px; }
  .popup-badge { font-size: 10px; background: rgba(255,255,255,0.25); border-radius: 99px; padding: 1px 7px; }
  .popup-body { padding: 10px 13px 12px; }
  .popup-row { display: flex; align-items: flex-start; gap: 6px; font-size: 12px; color: #374151; margin-bottom: 5px; }
  .popup-row:last-child { margin-bottom: 0; }
  .popup-row-icon { color: #9ca3af; flex-shrink: 0; margin-top: 1px; }

  /* Loading */
  .loading-overlay { position: absolute; inset: 0; background: rgba(240,244,248,0.85); display: flex; align-items: center; justify-content: center; z-index: 999; backdrop-filter: blur(4px); opacity: 0; pointer-events: none; transition: opacity 0.3s; }
  .loading-overlay.show { opacity: 1; pointer-events: all; }
  .loading-spinner { width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--blue); border-radius: 50%; animation: spin 0.7s linear infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }

  /* Scrollbar — đã chuyển sang .results-scroll */

  /* Toast */
  .toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(80px); background: var(--panel); color: white; padding: 10px 20px; border-radius: 99px; font-size: 13px; font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,0.3); z-index: 9999; transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1); white-space: nowrap; }
  .toast.show { transform: translateX(-50%) translateY(0); }

  /* Map click hint */
  .map-hint { font-size: 10px; color: rgba(255,255,255,0.35); text-align: left; margin-top: 4px; letter-spacing: 0.2px; }

  /* Home beacon pulse */
  @keyframes beacon-pulse {
    0%   { transform: scale(1);   opacity: 0.7; }
    100% { transform: scale(2.6); opacity: 0; }
  }

  /* Tooltip của icon góc ranh giới */
  .ward-corner-tip {
    background: white !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12) !important;
    padding: 7px 10px !important;
  }
  .ward-corner-tip::before { display: none !important; }

  /* Ward boundary tooltip */
  .ward-label {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: #1a2744;
    font-family: 'Lexend', sans-serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    opacity: 0.5;
    white-space: nowrap;
    pointer-events: none;
  }
  .ward-label::before { display: none !important; }

  /* ── SEARCH COMPACT BAR (mobile, sau khi tìm) ── */
  /* Compact bar nằm trong .search-actions để cùng hàng với nút lọc */
  .search-compact-bar {
    display: none;          /* ẩn mặc định, chỉ hiện khi .collapsed trên mobile */
    flex: 1; align-items: center; gap: 8px;
    background: rgba(255,255,255,0.1);
    border: 1.5px solid rgba(255,255,255,0.15);
    border-radius: 9px; padding: 7px 10px;
    cursor: pointer; min-width: 0;
    transition: background 0.2s;
  }
  .search-compact-bar:hover { background: rgba(255,255,255,0.16); }
  .search-compact-addr {
    flex: 1; font-size: 13px; color: white;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .search-compact-edit {
    font-size: 16px; color: rgba(255,255,255,0.45);
    flex-shrink: 0; line-height: 1;
  }

  /* Card layout cải tiến: header row gộp tên + badges */
  .card-header-row { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 7px; }
  .card-header-row .card-name { flex: 1; min-width: 0; }
  .card-header-row .badge-row { flex-shrink: 0; justify-content: flex-end; flex-wrap: wrap; }

  /* Hàng stats + nút Chỉ đường (dòng 2 của card kết quả) */
  .card-stats-row {
    display: flex; align-items: center;
    justify-content: space-between; gap: 8px; margin-top: 5px;
  }
  .stats-group { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

  /* Nút Chỉ đường nhỏ gọn */
  .card-route-btn {
    background: var(--blue); color: white; border: none;
    border-radius: 8px; padding: 5px 11px;
    font-family: 'Be Vietnam Pro', sans-serif;
    font-size: 11px; font-weight: 600; cursor: pointer;
    white-space: nowrap; flex-shrink: 0;
    display: flex; align-items: center; gap: 4px;
    transition: background 0.15s;
  }
  .card-route-btn:hover { background: #1d4ed8; }

  /* Khu vực cuộn: results header + danh sách cuộn cùng nhau */
  .results-scroll { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
  .results-scroll .results-header { flex-shrink: 0; }
  .results-scroll::-webkit-scrollbar { width: 6px; }
  .results-scroll::-webkit-scrollbar-track { background: var(--bg); border-radius: 99px; }
  .results-scroll::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }
  .results-scroll::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

  /* ── MOBILE — áp dụng cả 2 chiều (font, spacing, card compact) ── */
  @media (max-width: 768px) {
    .app-header { padding: 0 12px; height: 52px; }
    .app-header .logo-icon { width: 30px; height: 30px; font-size: 15px; }
    .app-header .logo-text { font-size: 13px; }
    .app-header .logo-sub { display: none; }
    .app-header .header-badge { font-size: 10px; padding: 3px 8px; }

    .search-area { padding: 8px 10px; }
    .search-input { font-size: 14px; } /* 14px ngăn iOS zoom khi focus */
    .search-actions { gap: 5px; }
    .search-btn { font-size: 12px; padding: 9px 8px; }
    .filter-toggle-btn { font-size: 11px; padding: 9px 8px; }

    .search-area.collapsed .search-label { display: none !important; }
    .search-area.collapsed .search-box   { display: none !important; }
    .search-area.collapsed .map-hint     { display: none !important; }
    .search-area.collapsed .search-btn   { display: none !important; }
    .search-area.collapsed .search-actions { margin-top: 0; }
    .search-area.collapsed .search-compact-bar { display: flex !important; }

    .school-card { padding: 9px 9px 9px 13px; margin-bottom: 7px; }
    .card-name   { font-size: 12.5px; }
    .card-btn    { padding: 6px 8px; font-size: 11px; }
    .card-stat   { font-size: 11px; }
    .card-phone-row { display: none; }
    .card-addr-row  { display: none; }
    .card-actions   { margin-top: 7px; }

    .legend { padding: 7px 10px; }
    .toast  { white-space: normal; text-align: center; max-width: 88vw; }
  }

  /* ── PORTRAIT ONLY — layout dọc ── */
  @media (max-width: 768px) and (orientation: portrait) {
    .app-body { flex-direction: column; }
    .sidebar  { width: 100%; min-width: unset; height: 50%; border-right: none; border-bottom: 1px solid var(--border); flex-shrink: 0; }
    .app-body.map-expanded .sidebar { height: 45%; }
    .legend .legend-item { display: none; }
    .rotate-hint { display: flex; }
  }

  @media (max-width: 400px) and (orientation: portrait) {
    .sidebar { height: 55%; }
    .app-body.map-expanded .sidebar { height: 45%; }
  }

/* ==================================================
   WordPress theme override — #sf-widget + !important
   ================================================== */

/* Layout root */
#sf-widget { display:flex !important; flex-direction:column !important; height:80vh !important; min-height:480px !important; overflow:hidden !important; box-sizing:border-box !important; font-family:'Be Vietnam Pro',sans-serif !important; background:var(--bg) !important; color:var(--text) !important; }
#sf-widget .app-body { flex:1 !important; display:flex !important; overflow:hidden !important; min-height:0 !important; }

/* Header */
#sf-widget .app-header { display:flex !important; align-items:center !important; justify-content:space-between !important; padding:0 24px !important; height:60px !important; background:var(--panel) !important; color:white !important; flex-shrink:0 !important; position:relative !important; }
#sf-widget .app-header .logo { display:flex !important; align-items:center !important; gap:10px !important; }
#sf-widget .app-header .logo-icon { width:36px !important; height:36px !important; border-radius:8px !important; background:var(--accent) !important; display:flex !important; align-items:center !important; justify-content:center !important; font-size:18px !important; flex-shrink:0 !important; }
#sf-widget .app-header .logo-text { font-family:'Lexend',sans-serif !important; font-weight:700 !important; font-size:15px !important; line-height:1.2 !important; color:white !important; }
#sf-widget .app-header .logo-sub  { font-size:11px !important; font-weight:300 !important; opacity:.7 !important; color:white !important; }
#sf-widget .app-header .header-badge { background:rgba(255,255,255,.1) !important; border:1px solid rgba(255,255,255,.2) !important; border-radius:99px !important; padding:4px 12px !important; font-size:11px !important; font-weight:500 !important; color:rgba(255,255,255,.8) !important; white-space:nowrap !important; display:inline-block !important; }

/* Sidebar */
#sf-widget .sidebar { display:flex !important; flex-direction:column !important; width:360px !important; min-width:320px !important; background:#fff !important; overflow:hidden !important; min-height:0 !important; border-right:1px solid var(--border) !important; }

/* Search area */
#sf-widget .search-area { padding:9px 12px !important; background:var(--panel) !important; flex-shrink:0 !important; }
#sf-widget .search-label { font-size:10px !important; font-weight:600 !important; letter-spacing:.8px !important; text-transform:uppercase !important; color:rgba(255,255,255,.5) !important; margin-bottom:5px !important; display:block !important; }
#sf-widget .search-input { width:100% !important; background:rgba(255,255,255,.1) !important; border:1.5px solid rgba(255,255,255,.15) !important; border-radius:9px !important; padding:8px 36px 8px 12px !important; color:white !important; font-size:12.5px !important; outline:none !important; }
#sf-widget .search-actions { display:flex !important; gap:6px !important; margin-top:7px !important; }
#sf-widget .search-btn { background:var(--accent) !important; color:#1a1a1a !important; border:none !important; border-radius:9px !important; padding:8px !important; font-size:12.5px !important; font-weight:600 !important; display:flex !important; align-items:center !important; justify-content:center !important; gap:5px !important; }
#sf-widget .map-hint { font-size:10px !important; color:rgba(255,255,255,.35) !important; text-align:left !important; margin-top:4px !important; display:block !important; }

/* Filter bar */
/* display managed by JS toggleFilterBar() — no display !important here */
#sf-widget .filter-bar { padding:6px 12px !important; background:#f8fafc !important; border-bottom:1px solid var(--border) !important; flex-direction:column !important; gap:5px !important; flex-shrink:0 !important; }
#sf-widget .filter-row { display:flex !important; align-items:center !important; gap:5px !important; flex-wrap:wrap !important; }
#sf-widget .chip { display:inline-flex !important; align-items:center !important; padding:2px 9px !important; border-radius:99px !important; border:1px solid var(--border) !important; background:white !important; font-size:10.5px !important; font-weight:500 !important; color:var(--muted) !important; white-space:nowrap !important; line-height:1.6 !important; text-decoration:none !important; box-shadow:none !important; cursor:pointer !important; }
#sf-widget .chip.active { background:var(--blue) !important; color:white !important; border-color:var(--blue) !important; }

/* Results header */
#sf-widget .results-header { padding:8px 12px 6px !important; border-bottom:1px solid var(--border) !important; flex-shrink:0 !important; }
#sf-widget .results-header-top { display:flex !important; align-items:center !important; justify-content:space-between !important; margin-bottom:2px !important; }
#sf-widget .results-title { font-family:'Lexend',sans-serif !important; font-size:12px !important; font-weight:600 !important; color:var(--text) !important; }
#sf-widget .results-meta  { font-size:10.5px !important; color:var(--muted) !important; }
#sf-widget .filter-tag { display:inline-block !important; background:#e2e8f0 !important; color:var(--muted) !important; border-radius:99px !important; padding:1px 7px !important; font-size:10px !important; font-weight:500 !important; margin-left:5px !important; vertical-align:middle !important; }
#sf-widget .back-btn  { display:inline-flex !important; align-items:center !important; gap:4px !important; font-size:11px !important; color:var(--blue) !important; background:none !important; border:none !important; padding:0 !important; font-weight:500 !important; text-decoration:none !important; }
#sf-widget .print-btn { display:inline-flex !important; align-items:center !important; gap:3px !important; font-size:11px !important; color:var(--muted) !important; background:var(--bg) !important; border:1px solid var(--border) !important; border-radius:6px !important; padding:3px 8px !important; font-weight:500 !important; text-decoration:none !important; }

/* School cards */
#sf-widget .school-card { display:block !important; list-style:none !important; margin-bottom:10px !important; padding:13px 13px 13px 17px !important; border:1.5px solid var(--border) !important; border-radius:12px !important; background:#fff !important; position:relative !important; overflow:hidden !important; cursor:pointer !important; }
#sf-widget .school-card::before { content:'' !important; position:absolute !important; top:0 !important; left:0 !important; bottom:0 !important; width:4px !important; border-radius:4px 0 0 4px !important; }
#sf-widget .school-card.cong-lap::before { background:var(--purple) !important; }
#sf-widget .school-card.dan-lap::before  { background:var(--orange) !important; }

/* Card internal layout */
#sf-widget .card-top        { display:flex !important; align-items:flex-start !important; gap:8px !important; margin-bottom:7px !important; }
#sf-widget .card-header-row { display:flex !important; align-items:flex-start !important; gap:8px !important; margin-bottom:7px !important; }
#sf-widget .card-name  { font-size:13px !important; font-weight:600 !important; line-height:1.35 !important; color:var(--text) !important; flex:1 !important; min-width:0 !important; }
#sf-widget .card-rank  { width:24px !important; height:24px !important; border-radius:6px !important; background:var(--blue) !important; color:white !important; font-size:12px !important; font-weight:700 !important; display:flex !important; align-items:center !important; justify-content:center !important; flex-shrink:0 !important; }
#sf-widget .card-rank.rank-1 { background:#f59e0b !important; color:#1a1a1a !important; }
#sf-widget .card-rank.rank-2 { background:#94a3b8 !important; color:white !important; }
#sf-widget .card-rank.rank-3 { background:#b45309 !important; color:white !important; }
#sf-widget .badge-row { display:flex !important; gap:5px !important; align-items:center !important; flex-wrap:wrap !important; margin-left:auto !important; }
#sf-widget .card-stats-row  { display:flex !important; align-items:center !important; justify-content:space-between !important; gap:8px !important; margin-top:5px !important; }
#sf-widget .stats-group { display:flex !important; gap:10px !important; flex-wrap:wrap !important; align-items:center !important; }
#sf-widget .card-stats { display:flex !important; gap:10px !important; flex-wrap:wrap !important; }
#sf-widget .card-stat  { display:flex !important; align-items:flex-start !important; gap:4px !important; font-size:11.5px !important; color:var(--muted) !important; }
#sf-widget .card-addr  { font-size:11px !important; color:var(--muted) !important; margin:5px 0 !important; line-height:1.4 !important; display:flex !important; gap:4px !important; }

/* Badge colours */
#sf-widget .card-type,
#sf-widget .cap-badge { font-size:10px !important; font-weight:600 !important; padding:2px 7px !important; border-radius:99px !important; white-space:nowrap !important; display:inline-block !important; }
#sf-widget .card-type.cong-lap { background:#f3e8ff !important; color:var(--purple) !important; }
#sf-widget .card-type.dan-lap  { background:#fff7ed !important; color:var(--orange) !important; }
#sf-widget .cap-mamnon  { background:#fce7f3 !important; color:#be185d !important; }
#sf-widget .cap-tieuhoc { background:#dbeafe !important; color:#1d4ed8 !important; }
#sf-widget .cap-thcs    { background:#ccfbf1 !important; color:#0f766e !important; }
#sf-widget .cap-thpt    { background:#dcfce7 !important; color:#15803d !important; }

/* Route button */
#sf-widget .card-route-btn { background:var(--blue) !important; color:#fff !important; border:none !important; border-radius:8px !important; padding:5px 11px !important; font-size:11px !important; font-weight:600 !important; white-space:nowrap !important; flex-shrink:0 !important; display:inline-flex !important; align-items:center !important; gap:4px !important; }

/* Toast — position:absolute scoped trong widget, tránh vỡ layout do WP transform */
#sf-widget { position:relative !important; }
#toast {
  position:absolute !important;
  bottom:20px !important;
  left:50% !important;
  transform:translateX(-50%) translateY(80px) !important;
  background:#1a2744 !important;
  color:#ffffff !important;
  text-decoration:none !important;
  padding:10px 20px !important;
  border-radius:99px !important;
  font-size:13px !important;
  font-weight:500 !important;
  box-shadow:0 8px 24px rgba(0,0,0,0.3) !important;
  z-index:9999 !important;
  white-space:nowrap !important;
  transition:transform 0.35s cubic-bezier(0.34,1.56,0.64,1) !important;
  pointer-events:none !important;
}
#toast.show {
  transform:translateX(-50%) translateY(0) !important;
}

/* Legend */
#sf-widget .legend { display:flex !important; gap:14px !important; padding:10px 16px !important; flex-wrap:wrap !important; border-top:1px solid var(--border) !important; flex-shrink:0 !important; }
#sf-widget .legend-item { display:flex !important; align-items:center !important; gap:6px !important; font-size:11px !important; color:var(--muted) !important; }
#sf-widget .legend-dot { width:11px !important; height:11px !important; border-radius:50% !important; border:2px solid white !important; display:inline-block !important; }
#sf-widget .legend-dot.purple { background:var(--purple) !important; }
#sf-widget .legend-dot.orange { background:var(--orange) !important; }
#sf-widget .rotate-hint { display:none; font-size:11px !important; color:var(--muted) !important; }
@media (max-width: 768px) and (orientation: portrait) {
  #sf-widget .legend .legend-item { display:none !important; }
  #sf-widget .rotate-hint { display:flex !important; }
}

/* Map + scroll */
#sf-widget #map { width:100% !important; height:100% !important; }
#sf-widget .results-scroll { flex:1 !important; min-height:0 !important; overflow-y:auto !important; display:flex !important; flex-direction:column !important; }
/* Popup map — scoped under sf-widget map container */
#sf-widget .leaflet-popup-content-wrapper { border-radius:12px !important; box-shadow:0 8px 32px rgba(0,0,0,.15) !important; border:none !important; padding:0 !important; overflow:hidden !important; }
#sf-widget .leaflet-popup-content { margin:0 !important; min-width:230px !important; }
#sf-widget .leaflet-popup-tip { display:none !important; }
#sf-widget .leaflet-popup-close-button { color:white !important; right:8px !important; top:8px !important; font-size:16px !important; }
#sf-widget .popup-inner { font-family:'Be Vietnam Pro',sans-serif !important; }
#sf-widget .popup-header { padding:11px 13px 9px !important; color:white !important; }
#sf-widget .popup-header.cong-lap { background:var(--purple) !important; }
#sf-widget .popup-header.dan-lap  { background:var(--orange) !important; }
#sf-widget .popup-school-name { font-weight:700 !important; font-size:13.5px !important; line-height:1.3 !important; margin-bottom:3px !important; padding-right:22px !important; color:white !important; }
#sf-widget .popup-school-name a { color:inherit !important; }
#sf-widget .popup-badges { display:flex !important; gap:5px !important; flex-wrap:wrap !important; }
#sf-widget .popup-badge { font-size:10px !important; background:rgba(255,255,255,.25) !important; border-radius:99px !important; padding:1px 7px !important; color:white !important; }
#sf-widget .popup-body { padding:10px 13px 12px !important; background:white !important; }
#sf-widget .popup-row { display:flex !important; align-items:flex-start !important; gap:6px !important; font-size:12px !important; color:#374151 !important; margin-bottom:5px !important; }
#sf-widget .popup-row:last-child { margin-bottom:0 !important; }
#sf-widget .popup-row-icon { color:#9ca3af !important; flex-shrink:0 !important; margin-top:1px !important; }
/* Card hover + active highlight */
#sf-widget .school-card:hover { border-color:var(--blue) !important; box-shadow:0 4px 16px rgba(37,99,235,.12) !important; transform:translateY(-1px) !important; }
#sf-widget .school-card.active { border-color:var(--blue) !important; background:#eff6ff !important; box-shadow:0 4px 16px rgba(37,99,235,.15) !important; }
/* Filter toggle button — icon only, compact */
#sf-widget .filter-toggle-btn { padding:8px 10px !important; min-width:36px !important; flex-shrink:0 !important; }

/* Collapsed mobile: override #sf-widget .search-btn { display:flex !important } */
@media (max-width: 768px) {
  #sf-widget .search-area.collapsed .search-label { display:none !important; }
  #sf-widget .search-area.collapsed .search-box   { display:none !important; }
  #sf-widget .search-area.collapsed .map-hint     { display:none !important; }
  #sf-widget .search-area.collapsed .search-btn   { display:none !important; }
  #sf-widget .search-area.collapsed .search-actions { margin-top:0 !important; }
  #sf-widget .search-area.collapsed .search-compact-bar { display:flex !important; }
  #sf-widget .app-body.map-expanded .sidebar { height:45% !important; }
}
/* ── MOBILE LANDSCAPE — bố cục ngang giống desktop ── */
/* max-width: 1024px: điện thoại landscape 600-900px; không ảnh hưởng desktop >1024px */
@media (orientation: landscape) and (max-width: 1024px) {
  /* Toast: dời lên đỉnh phần bản đồ — luôn thấy được dù browser chrome có hiện */
  #toast {
    left:calc(50% + 150px) !important;   /* giữa phần bản đồ (sidebar=300px) */
    top:56px !important;                 /* ngay dưới header 48px */
    bottom:auto !important;
    transform:translateX(-50%) translateY(-80px) !important; /* ẩn: trượt lên trên */
  }
  #toast.show { transform:translateX(-50%) translateY(0) !important; }
  #sf-widget .app-body  { flex-direction:row !important; }
  #sf-widget .sidebar   { width:300px !important; min-width:260px !important;
                           height:100% !important; flex-shrink:0 !important;
                           border-right:1px solid var(--border) !important;
                           border-bottom:none !important; }
  #sf-widget #map       { height:100% !important; }
  #sf-widget .app-header { height:48px !important; padding:0 16px !important; }
  #sf-widget .app-header .logo-sub { display:none !important; }
  #sf-widget .search-area { padding:6px 10px !important; }
  /* Không dùng collapsed state trong landscape */
  #sf-widget .search-area.collapsed .search-label { display:block !important; }
  #sf-widget .search-area.collapsed .search-box   { display:block !important; }
  #sf-widget .search-area.collapsed .map-hint     { display:block !important; }
  #sf-widget .search-area.collapsed .search-btn   { display:flex  !important; }
  #sf-widget .search-area.collapsed .search-compact-bar { display:none !important; }
  #sf-widget .app-body.map-expanded .sidebar { height:100% !important; width:300px !important; }
}
/* Leaflet Routing Machine — panel chi tiết đường đi */
.leaflet-routing-container { z-index:2000; font-family:'Be Vietnam Pro',sans-serif; font-size:12px; }
.leaflet-routing-container.leaflet-routing-container-hide { background:transparent !important; box-shadow:none !important; min-width:0 !important; max-width:none !important; }
.leaflet-routing-container:not(.leaflet-routing-container-hide) { background:white; box-shadow:-2px 2px 16px rgba(0,0,0,.18); border-radius:10px; max-height:60vh; overflow-y:auto; min-width:240px; max-width:320px; }
.leaflet-routing-alt { padding:10px 14px; }
.leaflet-routing-alt h2 { font-size:13px; font-weight:600; color:#1e293b; margin-bottom:3px; }
.leaflet-routing-alt h3 { font-size:11px; color:#64748b; font-weight:400; margin-bottom:8px; }
.leaflet-routing-alt table { width:100%; border-collapse:collapse; }
.leaflet-routing-alt td { padding:4px 6px; font-size:11px; color:#374151; border-bottom:1px solid #f1f5f9; vertical-align:middle; }
.leaflet-routing-alt tr:last-child td { border-bottom:none; }

/* ── ROUTE PANEL ── */
  /* ── ROUTE PANEL ── */
  .route-panel {
    border-top: 2px solid #2563eb;
    background: #eff6ff;
    padding: 12px 16px 14px;
    flex-shrink: 0;
  }
  .route-panel-top {
    display: flex; align-items: flex-start;
    justify-content: space-between; gap: 8px; margin-bottom: 8px;
  }
  .route-panel-label {
    font-size: 10px; text-transform: uppercase; letter-spacing: .07em;
    color: #2563eb; font-weight: 700; margin-bottom: 3px;
  }
  .route-school-name {
    font-size: 13px; font-weight: 600; color: var(--panel); line-height: 1.35;
  }
  .route-close-btn {
    background: none; border: none; cursor: pointer;
    color: #94a3b8; font-size: 20px; line-height: 1;
    padding: 0; flex-shrink: 0; margin-top: -2px;
  }
  .route-close-btn:hover { color: var(--panel); }
  .route-stats { display: flex; gap: 18px; margin-bottom: 10px; }
  .route-stat  { font-size: 13px; color: var(--panel); }
  .route-stat b { font-weight: 700; }




  /* ── ROUTE FLOATING PANEL ── */
  .route-panel {
    position: absolute; top: 10px; right: 10px; z-index: 500;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.22), 0 0 0 1px rgba(0,0,0,0.06);
    width: 272px;
    max-height: 400px;
    display: flex; flex-direction: column;
    overflow: hidden;
    font-size: 13px;
    pointer-events: all;
  }
  .route-panel-head {
    background: #1a2744; color: #fff;
    padding: 9px 12px 8px;
    display: flex; align-items: flex-start; gap: 8px; flex-shrink: 0;
  }
  .route-panel-info { flex: 1; min-width: 0; }
  .route-school-name {
    font-size: 13px; font-weight: 700; line-height: 1.35;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .route-panel-stats { font-size: 11px; opacity: .8; margin-top: 2px; }
  .route-close-btn {
    background: rgba(255,255,255,.15); border: none; cursor: pointer;
    color: #fff; font-size: 16px; line-height: 1;
    width: 24px; height: 24px; border-radius: 4px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
  }
  .route-close-btn:hover { background: rgba(255,255,255,.3); }
  .route-steps {
    overflow-y: auto; flex: 1;
    scrollbar-width: thin;
    padding: 4px 0;
  }
  .route-steps::-webkit-scrollbar { width: 4px; }
  .route-steps::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }
  .route-step {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 12px; border-bottom: 1px solid #f1f5f9; line-height: 1.35;
  }
  .route-step:last-child { border-bottom: none; }
  .route-step-icon {
    flex-shrink: 0; width: 22px; height: 22px;
    background: #eff6ff; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; color: #2563eb;
  }
  .route-step-text { flex: 1; font-size: 12px; color: #1e3a5f; }
  .route-step-dist { flex-shrink: 0; font-size: 11px; color: #94a3b8; white-space: nowrap; }
  .route-panel-foot {
    border-top: 1px solid #e2e8f0; padding: 6px 12px;
    flex-shrink: 0;
  }
  .route-panel-foot a {
    font-size: 11px; color: #2563eb; text-decoration: none;
  }
  .route-panel-foot a:hover { text-decoration: underline; }
  @media (max-width: 768px) {
    .route-panel { width: 240px; max-height: 280px; top: 8px; right: 8px; }
  }

  /* ── Route panel: collapsed / expanded ── */
  .route-toggle-icon {
    background: #1a2744; border: none; cursor: pointer; color: #fff;
    border-radius: 10px; padding: 10px 14px 8px; pointer-events: all;
    box-shadow: 0 3px 14px rgba(0,0,0,0.38);
    display: flex; flex-direction: column; align-items: center; gap: 5px;
    min-width: 52px; transition: transform .15s, box-shadow .15s, background .15s;
  }
  .route-toggle-icon:hover {
    background: #2d3e5e;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.42);
  }
  .route-icon-label {
    font-size: 9px; font-weight: 700; letter-spacing: .05em;
    color: rgba(255,255,255,.85); line-height: 1; white-space: nowrap;
  }
  .route-panel .route-toggle-icon { display: none; } /* ẩn khi expanded */
  .route-panel.collapsed {
    background: transparent; box-shadow: none; border-radius: 0;
    width: auto; max-height: none; overflow: visible;
  }
  .route-panel.collapsed .route-panel-head,
  .route-panel.collapsed .route-steps,
  .route-panel.collapsed .route-panel-foot { display: none; }
  .route-panel.collapsed .route-toggle-icon { display: flex; }
  /* Step hover & active */
  .route-step { cursor: pointer; transition: background .1s; }
  .route-step:hover { background: #f0f7ff; }
  .route-step.active { background: #dbeafe; }
  /* Step dot on map — không cần CSS, dùng Leaflet circleMarker */
  /* Minimize button trong header */
  .route-minimize-btn {
    background: rgba(255,255,255,.15); border: none; cursor: pointer;
    color: #fff; font-size: 14px; line-height: 1;
    width: 24px; height: 24px; border-radius: 4px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    margin-right: 2px;
  }
  .route-minimize-btn:hover { background: rgba(255,255,255,.3); }

/* ── Route panel: fix display + header text trong WP theme ── */

/* Route panel container: xóa border/outline từ WP theme */
#sf-widget .route-panel,
#sf-widget .route-panel.collapsed {
  border: none !important;
  outline: none !important;
  text-decoration: none !important;
}
#sf-widget .route-panel::before,
#sf-widget .route-panel::after { display: none !important; }

/* Toggle icon: kích thước cố định, xóa theme override */
#sf-widget .route-toggle-icon {
  width: auto !important;
  min-width: unset !important;
  max-width: 68px !important;
  padding: 10px 14px 8px !important;
  border: none !important;
  outline: none !important;
  text-decoration: none !important;
  box-sizing: border-box !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 5px !important;
  line-height: 1 !important;
}
#sf-widget .route-toggle-icon svg {
  width: 24px !important;
  height: 24px !important;
  display: block !important;
  flex-shrink: 0 !important;
}
#sf-widget .route-icon-label {
  display: block !important;
  font-size: 9px !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  white-space: nowrap !important;
  color: rgba(255,255,255,0.85) !important;
}
#sf-widget .route-toggle-icon::before,
#sf-widget .route-toggle-icon::after { display: none !important; }
#sf-widget .route-panel .route-toggle-icon       { display: none !important; }
#sf-widget .route-panel.collapsed .route-toggle-icon { display: flex !important; }

/* Header + steps + footer: hiện khi expanded, ẩn khi collapsed */
#sf-widget .route-panel:not(.collapsed) .route-panel-head { display: flex !important; }
#sf-widget .route-panel:not(.collapsed) .route-steps      { display: block !important; }
#sf-widget .route-panel:not(.collapsed) .route-panel-foot { display: block !important; }
#sf-widget .route-panel.collapsed .route-panel-head       { display: none !important; }
#sf-widget .route-panel.collapsed .route-steps            { display: none !important; }
#sf-widget .route-panel.collapsed .route-panel-foot       { display: none !important; }

/* Panel: đảm bảo absolute positioning + tách collapsed/expanded */
#sf-widget .route-panel {
  position: absolute !important;
  top: 10px !important;
  right: 10px !important;
  z-index: 500 !important;
  pointer-events: all !important;
  font-family: 'Be Vietnam Pro', 'Lexend', sans-serif !important;
  font-size: 13px !important;
  line-height: 1.4 !important;
  box-sizing: border-box !important;
}
/* Collapsed: chỉ hiện icon nhỏ */
#sf-widget .route-panel.collapsed {
  width: auto !important;
  max-height: none !important;
  overflow: visible !important;
  background: transparent !important;
  box-shadow: none !important;
}
/* Expanded: panel đầy đủ */
#sf-widget .route-panel:not(.collapsed) {
  width: 272px !important;
  max-height: 420px !important;
  overflow: hidden !important;
  background: #fff !important;
  box-shadow: 0 2px 16px rgba(0,0,0,0.22) !important;
  border-radius: 8px !important;
}
#sf-widget .route-steps {
  max-height: 230px !important;
  overflow-y: auto !important;
}

/* Header */
#sf-widget .route-panel-head {
  background: #1a2744 !important;
  color: #fff !important;
  padding: 9px 12px 8px !important;
  gap: 8px !important;
  align-items: flex-start !important;
  flex-wrap: nowrap !important;
}
#sf-widget .route-panel-head .route-school-name {
  color: #fff !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  line-height: 1.35 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}
#sf-widget .route-panel-head .route-panel-stats {
  color: rgba(255,255,255,0.82) !important;
  font-size: 11px !important;
  margin-top: 2px !important;
  white-space: nowrap !important;
}
#sf-widget .route-minimize-btn,
#sf-widget .route-close-btn {
  color: #fff !important;
  flex-shrink: 0 !important;
}

/* Step items */
#sf-widget .route-step {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 5px 12px !important;
  border-bottom: 1px solid #f1f5f9 !important;
}
#sf-widget .route-step-icon {
  flex-shrink: 0 !important;
  width: 22px !important;
  height: 22px !important;
  font-size: 11px !important;
}
#sf-widget .route-step-text {
  flex: 1 !important;
  font-size: 12px !important;
  color: #1e3a5f !important;
  min-width: 0 !important;
  word-break: break-word !important;
}
#sf-widget .route-step-dist {
  flex-shrink: 0 !important;
  font-size: 11px !important;
  color: #94a3b8 !important;
  white-space: nowrap !important;
  margin-left: 4px !important;
}

/* Footer link */
#sf-widget .route-panel-foot {
  border-top: 1px solid #e2e8f0 !important;
  padding: 6px 12px !important;
}
#sf-widget .route-panel-foot a {
  font-size: 11px !important;
  color: #2563eb !important;
  text-decoration: none !important;
}


@media (max-width: 768px) {
  #sf-widget .route-panel {
    top: 8px !important;
    right: 8px !important;
    z-index: 1000 !important;
  }
  #sf-widget .route-panel:not(.collapsed) {
    width: 240px !important;
    max-height: 280px !important;
  }
  #sf-widget .route-steps {
    max-height: 140px !important;
  }
}

/* ── Mobile: fix overflow + card — áp dụng cả 2 chiều ── */
@media (max-width: 768px) {
  #sf-widget,
  #sf-widget .app-body,
  #sf-widget .sidebar {
    max-width: 100vw !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }
  #sf-widget .search-area,
  #sf-widget .search-actions,
  #sf-widget .filter-bar,
  #sf-widget .results-list,
  #sf-widget .results-scroll {
    box-sizing: border-box !important;
    max-width: 100% !important;
  }
  #sf-widget .school-card {
    box-sizing: border-box !important;
    overflow: hidden !important;
    max-width: 100% !important;
  }
  #sf-widget .card-header-row { flex-wrap: wrap !important; gap: 5px !important; }
  #sf-widget .badge-row { flex-shrink: 1 !important; max-width: 100% !important; }
  #sf-widget .card-stats-row { flex-wrap: nowrap !important; gap: 6px !important; }
  #sf-widget .card-route-btn { flex-shrink: 0 !important; white-space: nowrap !important; font-size: 11px !important; padding: 5px 9px !important; }
  #sf-widget .filter-row { flex-wrap: wrap !important; }
}

/* ── Portrait ONLY: layout dọc ── */
@media (max-width: 768px) and (orientation: portrait) {
  #sf-widget .app-body { flex-direction: column !important; }
  #sf-widget .sidebar  { width: 100% !important; height: 50% !important; border-right: none !important; border-bottom: 1px solid var(--border) !important; }
  #sf-widget .app-body.map-expanded .sidebar { height: 45% !important; }
}
@media (max-width: 400px) and (orientation: portrait) {
  #sf-widget .sidebar { height: 55% !important; }
}
