:root {
  --bg: #0f1720;
  --bg-soft: #16212e;
  --panel: #ffffff;
  --ink: #1b2430;
  --ink-soft: #5b6877;
  --line: #e6e9ee;
  --accent: #da251d;        /* Vietnam flag red */
  --accent-star: #ffcd00;   /* flag star yellow */
  --see: #2563eb;
  --eat: #ef4444;
  --drink: #8b5cf6;
  --stay: #10b981;
  --do: #f59e0b;
  --shadow: 0 6px 24px rgba(16, 24, 40, 0.12);
  --radius: 14px;
  --header-h: 60px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { color: var(--ink); background: var(--bg); overflow: hidden; }

/* ---------- top bar ---------- */
.topbar {
  height: var(--header-h);
  display: flex; align-items: center; gap: 20px;
  padding: 0 18px;
  background: linear-gradient(100deg, #b91c1c 0%, #da251d 55%, #e85d4a 100%);
  color: #fff;
  position: relative; z-index: 1200;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
}
.brand { display: flex; align-items: center; gap: 10px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.brand:hover { opacity: .92; }
.brand:focus-visible { outline: 2px solid #fff; outline-offset: 3px; border-radius: 8px; }
.brand .flag { font-size: 26px; line-height: 1; }
.brand-text h1 { margin: 0; font-size: 19px; letter-spacing: .3px; font-weight: 700; }
.brand-text p { margin: 0; font-size: 11.5px; opacity: .82; }

.views { display: flex; gap: 4px; margin-left: 6px; }
.view-btn {
  appearance: none; border: 0; cursor: pointer;
  background: rgba(255,255,255,.12); color: #fff;
  padding: 8px 14px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  transition: background .15s ease;
}
.view-btn:hover { background: rgba(255,255,255,.22); }
.view-btn.is-active { background: #fff; color: var(--accent); }
.view-btn { display: inline-flex; align-items: center; gap: 6px; }
.vb-ico { display: none; line-height: 0; }
.vb-ico svg { width: 18px; height: 18px; display: block; }
.menu-toggle {
  margin-left: auto; display: none; place-items: center; appearance: none; border: 0;
  background: rgba(255,255,255,.2); color: #fff;
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer;
}
.menu-toggle svg { width: 21px; height: 21px; display: block; }

/* ---------- layout ---------- */
.layout {
  position: absolute; inset: var(--header-h) 0 0 0;
  display: grid; grid-template-columns: 380px 1fr;
}
body[data-view="map"] .page { display: none; }
body:not([data-view="map"]) .sidebar,
body:not([data-view="map"]) .map-wrap { display: none; }
body:not([data-view="map"]) .layout { grid-template-columns: 1fr; }

/* ---------- sidebar ---------- */
.sidebar {
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.sheet-handle { display: none; }
.search-wrap { padding: 14px 14px 8px; }
#search {
  width: 100%; padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; outline: none; background: #f7f8fa;
}
#search:focus { border-color: var(--accent); background: #fff; }

.filters { padding: 4px 14px 10px; border-bottom: 1px solid var(--line); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 9px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 6px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  border: 1.5px solid var(--line); background: #fff; color: var(--ink-soft);
  user-select: none; transition: all .12s ease;
}
.chip .dot { width: 9px; height: 9px; border-radius: 50%; }
.chip.is-on { color: #fff; border-color: transparent; }
.chip[data-cat="see"].is-on { background: var(--see); }
.chip[data-cat="eat"].is-on { background: var(--eat); }
.chip[data-cat="drink"].is-on { background: var(--drink); }
.chip[data-cat="stay"].is-on { background: var(--stay); }
.chip[data-cat="do"].is-on { background: var(--do); }
.chip.is-on .dot { background: rgba(255,255,255,.9); }

.control-row { display: flex; gap: 8px; }
.control-row select {
  flex: 1; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px;
  font-size: 13px; background: #fff; color: var(--ink); cursor: pointer;
}

.rating-row { display: flex; gap: 6px; margin-bottom: 9px; }
.rbtn {
  flex: 1; appearance: none; cursor: pointer; padding: 7px 4px; border-radius: 8px;
  border: 1.5px solid var(--line); background: #fff; color: var(--ink-soft);
  font-size: 12px; font-weight: 700; transition: all .12s ease; white-space: nowrap;
}
.rbtn:hover { border-color: #f5a623; color: var(--ink); }
.rbtn.is-on { background: #f5a623; border-color: #f5a623; color: #fff; }

.stars { color: #f5a623; font-size: 12px; letter-spacing: .5px; }
.card .why { font-size: 11.5px; color: #6b7787; font-style: italic; margin-top: 5px; line-height: 1.35; }
.card .why b { font-style: normal; color: #475260; }

.result-meta { padding: 9px 16px; font-size: 12px; color: var(--ink-soft); border-bottom: 1px solid var(--line); }
.result-meta span { font-weight: 700; color: var(--ink); }
.result-meta .must-count { color: #cf8a00; }

.results { overflow-y: auto; flex: 1; min-height: 0; }
.card {
  display: grid; grid-template-columns: 34px 1fr; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer;
  transition: background .12s ease;
}
.card:hover { background: #f6f8fb; }
.card.is-active { background: #fff4f3; box-shadow: inset 3px 0 0 var(--accent); }
.card .pin {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  font-size: 15px; color: #fff;
}
.card h3 { margin: 0 0 2px; font-size: 14px; line-height: 1.25; }
.card .meta { font-size: 11.5px; color: var(--ink-soft); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.card .price { font-weight: 700; color: var(--ink); }
.card .blurb { margin: 5px 0 0; font-size: 12.5px; color: #3c4654; line-height: 1.4; }
.tagrow { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 10.5px; background: #eef1f5; color: #5b6877; padding: 2px 7px; border-radius: 999px; }

/* ---------- map ---------- */
.map-wrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: #aadaff; }
.reset-view {
  position: absolute; top: 12px; right: 12px; z-index: 600;
  background: #fff; border: 1px solid var(--line); border-radius: 9px;
  padding: 8px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer; box-shadow: var(--shadow);
}

/* marker pins */
.pin-marker {
  width: 30px; height: 30px; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg); display: grid; place-items: center;
  box-shadow: 0 3px 6px rgba(0,0,0,.35); border: 2px solid #fff;
}
.pin-marker span { transform: rotate(45deg); font-size: 14px; line-height: 1; }
.pin-see { background: var(--see); }
.pin-eat { background: var(--eat); }
.pin-drink { background: var(--drink); }
.pin-stay { background: var(--stay); }
.pin-do { background: var(--do); }

/* rating emphasis */
.pinwrap { position: relative; width: 30px; height: 30px; }
.pinwrap.is-must { z-index: 1000; }
.pin-marker.pin-top { box-shadow: 0 0 0 2.5px #f5a623, 0 3px 6px rgba(0,0,0,.4); }
.pin-marker.pin-low { transform: rotate(-45deg) scale(.8); opacity: .72; }
.pin-badge {
  position: absolute; top: -5px; right: -5px; width: 16px; height: 16px;
  background: #f5a623; color: #fff; border: 1.5px solid #fff; border-radius: 50%;
  font-size: 9px; line-height: 1; display: grid; place-items: center;
  box-shadow: 0 1px 2px rgba(0,0,0,.3); z-index: 2;
}

/* popups */
.leaflet-popup-content-wrapper { border-radius: 12px; }
.leaflet-popup-content { margin: 13px 15px; }
.pop h3 { margin: 0 0 4px; font-size: 15px; }
.pop .meta { font-size: 11.5px; color: var(--ink-soft); margin-bottom: 7px; }
.pop .cat-badge { display: inline-block; color: #fff; padding: 1px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 700; margin-right: 6px; }
.pop p { margin: 0 0 7px; font-size: 13px; line-height: 1.45; max-width: 260px; }
.pop .why { font-size: 12px; color: #475260; font-style: italic; margin: 0 0 7px; max-width: 260px; line-height: 1.4; }
.pop .why b { font-style: normal; }
.pop .tip { background: #fff7ed; border-left: 3px solid var(--do); padding: 7px 9px; border-radius: 6px; font-size: 12px; color: #7c5212; }
.pop .gmaps { display: inline-flex; align-items: center; gap: 5px; margin-top: 10px; font-size: 12.5px; font-weight: 700; color: var(--see); text-decoration: none; }
.pop .gmaps:hover { text-decoration: underline; }

/* ---------- dashboard pages ---------- */
.page { overflow-y: auto; padding: 28px clamp(18px, 5vw, 60px) 80px; background: #f3f5f8; }
.page-head { max-width: 1100px; margin: 0 auto 22px; }
.page-head h2 { font-size: 26px; margin: 0 0 6px; }
.page-head p { color: var(--ink-soft); margin: 0; font-size: 14.5px; max-width: 720px; line-height: 1.5; }

.stat-grid { max-width: 1100px; margin: 0 auto 26px; display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .n { font-size: 26px; font-weight: 800; }
.stat .l { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }

.grid { max-width: 1100px; margin: 0 auto; display: grid; gap: 16px; }
.grid.cols { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

.region-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.region-card h3 { margin: 0 0 6px; font-size: 18px; }
.region-card .days { font-size: 12px; color: var(--accent); font-weight: 700; }
.region-card .rmust { display: inline-block; background: #fff7e6; color: #9a6a00; font-weight: 700; font-size: 11.5px; padding: 2px 9px; border-radius: 999px; margin-bottom: 4px; }
.region-card p { font-size: 13.5px; color: #3c4654; line-height: 1.5; margin: 8px 0; }
.region-card .bestfor { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0 10px; }
.region-card .counts { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; color: var(--ink-soft); border-top: 1px solid var(--line); padding-top: 10px; }
.region-card .counts b { color: var(--ink); }
.region-card .open-map { margin-top: 12px; appearance: none; border: 1px solid var(--accent); color: var(--accent); background: #fff; border-radius: 9px; padding: 8px 12px; font-weight: 700; font-size: 12.5px; cursor: pointer; }
.region-card .open-map:hover { background: var(--accent); color: #fff; }

/* itineraries */
.itin { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); }
.itin h3 { margin: 0 0 2px; font-size: 19px; }
.itin .sub { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 4px; }
.itin .focus { font-size: 13px; color: #3c4654; margin: 6px 0 14px; line-height: 1.5; }
.timeline { border-left: 2px solid var(--line); margin-left: 6px; padding-left: 16px; }
.stop { position: relative; padding-bottom: 16px; }
.stop:last-child { padding-bottom: 0; }
.stop::before { content: ""; position: absolute; left: -23px; top: 3px; width: 11px; height: 11px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--accent); }
.stop .days { font-size: 11.5px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .4px; }
.stop .loc { font-size: 15px; font-weight: 700; margin: 1px 0 3px; }
.stop .hl { font-size: 13px; color: #3c4654; line-height: 1.45; }
.itin .notes { margin-top: 14px; background: #f7f9fc; border-radius: 9px; padding: 11px 13px; font-size: 12.5px; color: var(--ink-soft); line-height: 1.5; }

/* essentials */
.acc { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.acc + .acc { margin-top: 12px; }
.acc summary { cursor: pointer; padding: 16px 20px; font-weight: 700; font-size: 15px; list-style: none; display: flex; align-items: center; gap: 10px; }
.acc summary::-webkit-details-marker { display: none; }
.acc summary::before { content: "+"; color: var(--accent); font-weight: 800; font-size: 18px; }
.acc[open] summary::before { content: "−"; }
.acc .body { padding: 0 20px 18px; font-size: 13.5px; line-height: 1.6; color: #3c4654; }
.acc .body ul { margin: 6px 0; padding-left: 18px; }
.phrase-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 8px; }
.phrase { background: #f7f9fc; border-radius: 8px; padding: 8px 11px; font-size: 12.5px; }
.phrase b { display: block; font-size: 14px; color: var(--ink); }
.budget-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0; }
.budget { flex: 1; min-width: 160px; background: #f7f9fc; border-radius: 10px; padding: 12px 14px; }
.budget .tier { font-weight: 700; font-size: 13px; }

/* ---------- loading ---------- */
.loading { position: fixed; inset: 0; background: var(--bg); color: #fff; display: grid; place-items: center; z-index: 2000; transition: opacity .3s; }
.loading.hidden { opacity: 0; pointer-events: none; }
.loading p { margin-top: 14px; font-size: 14px; opacity: .8; }
.spinner { width: 38px; height: 38px; border: 3px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- responsive ---------- */
@media (max-width: 820px) {
  :root { --header-h: 56px; }
  .brand-text p { display: none; }
  .views { gap: 2px; margin-left: 0; }
  .view-btn { padding: 7px 10px; font-size: 12px; }
  .menu-toggle { display: grid; }
  .layout { grid-template-columns: 1fr; }

  /* Sidebar becomes a draggable bottom sheet over the map */
  body[data-view="map"] .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    height: 88vh; max-height: 88vh; z-index: 700;
    border-right: none; border-radius: 18px 18px 0 0;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, .2);
    transform: translateY(var(--sheet-y, 100%));
    transition: transform .32s cubic-bezier(.32, .72, 0, 1);
    will-change: transform;
  }
  body[data-view="map"] .sidebar.dragging { transition: none; }
  .sheet-handle {
    display: flex; justify-content: center; align-items: center;
    padding: 10px 0 7px; cursor: grab; touch-action: none; flex: 0 0 auto;
  }
  .sheet-handle:active { cursor: grabbing; }
  .sheet-handle span { width: 42px; height: 5px; border-radius: 999px; background: #ccd3db; display: block; }
  .search-wrap { padding-top: 4px; }
  .reset-view { top: 12px; right: 12px; }
}

/* Narrow phones: collapse the nav to icons so the list toggle still fits */
@media (max-width: 540px) {
  .topbar { gap: 5px; padding: 0 7px; }
  .brand { gap: 6px; flex: 0 0 auto; }
  .brand .flag { font-size: 20px; }
  .brand-text h1 { font-size: 15px; }
  .views { gap: 2px; flex: 0 1 auto; }
  .view-btn { padding: 6px 8px; }
  .vb-ico { display: inline-flex; align-items: center; }
  .vb-label { display: none; }
  .menu-toggle { width: 34px; height: 34px; flex: 0 0 auto; margin-left: auto; }
  body:not([data-view="map"]) .menu-toggle { display: none; }
}
