:root {
  --pine: #1F4D3A;
  --pine-dark: #123326;
  --pine-soft: #E7EFEA;
  --ground: #F4F6F3;
  --surface: #FFFFFF;
  --ink: #17221C;
  --ink-2: #2E3B34;
  --muted: #4B5A52;
  --line: #DDE3DE;
  --line-2: #EEF1EE;
  --money: #A84A14;
  --orange: #D9772B;
  --warm-bg: #FFF6EC;
  --warm-line: #F1D6B8;
  --warm-ink: #6B2F0C;
  --danger-bg: #FDEBDD;
  --c-move: #1F4D3A;
  --c-stay: #6FA88C;
  --c-food: #D9772B;
  --c-fun: #F5C48A;
  --c-shop: #7A5A3A;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { scroll-padding-top: 16px; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  min-height: 100vh; display: flex; flex-direction: column;
  font-family: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px; line-height: 1.55;
}
a { color: var(--pine); }
a:hover { color: var(--pine-dark); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; }
p, li { text-wrap: pretty; }
p { margin: 0; }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 20px; }
.skip { position: absolute; left: -9999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding-top: 10px; padding-bottom: 10px; }
.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 800; font-size: 20px; letter-spacing: -0.02em; min-height: 44px; }
.logo svg { color: var(--pine); }
.nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.nav a, .nav button.linklike { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; color: var(--ink-2); font-weight: 600; text-decoration: none; border-radius: 10px; background: none; border: 0; }
.nav a:hover, .nav button.linklike:hover { background: var(--pine-soft); color: var(--pine-dark); }
.nav a[aria-current="page"] { color: var(--pine); text-decoration: underline; text-underline-offset: 6px; }
#app { flex: 1 0 auto; width: 100%; }
#app:focus { outline: none; }
.site-footer { border-top: 1px solid var(--line); background: var(--surface); margin-top: 48px; flex-shrink: 0; }
.site-footer p { padding: 20px 0; font-size: 13px; color: var(--muted); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 10px; font-weight: 700; font-size: 15px; text-decoration: none; border: 1.5px solid var(--pine); background: var(--surface); color: var(--pine); }
.btn:hover { background: var(--pine-soft); color: var(--pine-dark); }
.btn-primary { background: var(--pine); color: #fff; }
.btn-primary:hover { background: var(--pine-dark); color: #fff; }
.btn-danger { border-color: var(--money); color: var(--money); }
.btn-danger:hover { background: var(--danger-bg); color: var(--money); }
.btn-small { min-height: 40px; padding: 0 12px; font-size: 14px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-link { background: none; border: 0; padding: 0; min-height: 44px; color: var(--pine); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.icon-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: none; border-radius: 8px; color: var(--money); }
.icon-btn:hover { background: var(--danger-bg); }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid #C9D3CC; background: var(--surface); color: var(--ink-2); font-weight: 600; font-size: 14px; }
.chip:hover { border-color: var(--pine); }
.chip[aria-pressed="true"] { background: var(--pine); border-color: var(--pine); color: #fff; }
.chip .dot { width: 10px; height: 10px; border-radius: 50%; border: 1px solid #fff; }
.tag { display: inline-flex; align-items: center; font-size: 13px; font-weight: 700; color: var(--pine); background: var(--pine-soft); padding: 3px 10px; border-radius: 999px; }
.tag-grey { color: var(--ink-2); background: #F1F3F1; font-weight: 600; }
.tag-warn { color: var(--warm-ink); background: var(--warm-bg); }
.tag-bad { color: #7A2E0C; background: var(--danger-bg); }

/* Layout pieces */
.page { padding-top: 32px; padding-bottom: 32px; display: flex; flex-direction: column; gap: 24px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.panel-head h2 { font-size: 20px; font-weight: 800; }
.sub { color: var(--muted); font-size: 14px; }
.cols { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.cols > .main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.cols > .side { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.empty { border: 1px dashed #B9C6BE; border-radius: 16px; padding: 32px; text-align: center; color: var(--muted); background: var(--surface); }
.loading { padding: 40px 0; color: var(--muted); }

/* Hero */
.hero { display: flex; flex-direction: column; gap: 12px; max-width: 900px; padding-top: 12px; }
.hero h1 { font-size: clamp(32px, 5.4vw, 52px); font-weight: 800; letter-spacing: -0.035em; line-height: 1.08; }
.hero p { font-size: 17px; color: var(--muted); max-width: 62ch; }

/* Filters */
.filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.filter-row > .label { font-size: 13px; font-weight: 600; color: var(--muted); min-width: 120px; }

/* Trip cards */
.trip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 18px; }
.trip-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.trip-card h3 { font-size: 18px; font-weight: 700; line-height: 1.35; }
.trip-card h3 a { color: var(--ink); text-decoration: none; }
.trip-card h3 a:hover { text-decoration: underline; }
.trip-card .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.trip-card .btn { margin-top: auto; }
.author { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink-2); }
.avatar { width: 34px; height: 34px; flex: none; border-radius: 50%; background: var(--pine); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.avatar.lg { width: 44px; height: 44px; font-size: 17px; }
.mini-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; background: #F7F9F7; border-radius: 12px; padding: 12px 14px; }
.mini-stats span { display: block; }
.mini-stats .k { font-size: 12px; color: var(--muted); }
.mini-stats .v { font-size: 17px; font-weight: 800; }
.money { color: var(--money); }

/* Cost bar */
.bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--line-2); }
.bar.lg { height: 16px; }
.bar span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 14px; }
.legend > span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend b { font-weight: 700; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat { background: #F7F9F7; border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 20px; font-weight: 800; }
.stat.good { background: var(--pine-soft); }
.stat.good .v { color: var(--pine); }
.stat.bad { background: var(--danger-bg); }
.stat.bad .v { color: var(--money); }

/* Maps */
.map-wrap { display: flex; flex-wrap: wrap; gap: 18px; align-items: stretch; }
.map { flex: 999 1 520px; min-width: 0; height: 420px; border-radius: 14px; border: 1px solid #D3DDD6; background: #E8F0EA; z-index: 0; }
.map-side { flex: 1 1 280px; min-width: 0; display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; padding-right: 4px; }
.map-side > * { flex-shrink: 0; }
.map-msg { display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; color: var(--ink-2); }
.pin { display: flex; align-items: center; justify-content: center; border-radius: 50%; border: 3px solid #fff; color: #fff; font-weight: 800; font-size: 13px; box-shadow: 0 2px 6px rgba(23, 34, 28, .3); font-family: 'Be Vietnam Pro', system-ui, sans-serif; }
.pin.active { background: var(--orange) !important; border-color: var(--ink); }
.pin.light { color: #3A2410; }
.place-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: left; background: var(--surface); border: 1px solid #E3E8E4; border-radius: 10px; padding: 8px 10px; min-height: 44px; }
.place-row:hover { border-color: var(--pine); }
.place-row[aria-current="true"] { background: var(--warm-bg); border-color: var(--warm-line); }
.place-row .name { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 600; font-size: 14px; line-height: 1.35; }
.place-row .name > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.place-row { padding: 10px 12px; }
.place-row .num { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--pine); color: #fff; font-weight: 800; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; }
.place-row .dot { flex: none; width: 10px; height: 10px; border-radius: 50%; }
.place-row .price { font-size: 13px; font-weight: 700; color: var(--money); white-space: nowrap; }
.callout { background: var(--warm-bg); border: 1px solid var(--warm-line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 6px; color: #4A2A12; }
.callout h3 { font-size: 16px; font-weight: 800; color: var(--warm-ink); }
.callout .small { font-size: 13px; }
.leaflet-popup-content { font-family: 'Be Vietnam Pro', system-ui, sans-serif; font-size: 14px; }

/* Timeline */
.day-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; display: flex; flex-direction: column; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; padding-bottom: 10px; border-bottom: 1px solid var(--line-2); }
.day-head h2 { font-size: 18px; font-weight: 800; }
.tl-row { display: grid; grid-template-columns: 52px 26px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 12px 6px; border: 0; border-bottom: 1px solid #F1F3F1; background: none; text-align: left; border-radius: 8px; width: 100%; }
.tl-row:hover { background: #F7F9F7; }
.tl-row[aria-current="true"] { background: var(--warm-bg); }
.tl-row .time { font-size: 14px; font-weight: 700; color: var(--ink-2); padding-top: 2px; }
.tl-row .n { width: 24px; height: 24px; border-radius: 50%; background: var(--line-2); color: var(--muted); font-size: 12px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.tl-row .n.on { background: var(--pine); color: #fff; }
.tl-row .what { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tl-row .what b { font-weight: 600; }
.tl-row .meta { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tl-row .meta i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.tl-row .cost { font-weight: 700; white-space: nowrap; }
.tl-row .cost.free { color: #2E6B4F; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input, .field input, .field select, .field textarea { min-height: 44px; padding: 0 12px; border: 1px solid #B9C6BE; border-radius: 10px; font-size: 15px; font-weight: 400; background: #fff; color: var(--ink); width: 100%; }
.field textarea { padding: 10px 12px; min-height: 96px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.form-narrow { max-width: 440px; width: 100%; }
.error { background: var(--danger-bg); border: 1px solid #F0C3A0; color: #5A240A; border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.error ul { margin: 6px 0 0; padding-left: 18px; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); }
.tabs button { min-height: 44px; padding: 0 16px; background: none; border: 0; border-bottom: 3px solid transparent; font-weight: 700; color: var(--muted); }
.tabs button[aria-selected="true"] { color: var(--pine); border-bottom-color: var(--pine); }

/* Editor */
.ed-scroll { overflow-x: auto; }
.ed-table { min-width: 760px; display: flex; flex-direction: column; gap: 8px; }
.ed-row { display: grid; grid-template-columns: 76px minmax(0, 1.8fr) minmax(0, 1.6fr) 130px 124px 44px; gap: 8px; align-items: start; }
.ed-head { font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 2px; }
.ed-row input, .ed-row select { min-height: 42px; padding: 0 8px; border: 1px solid #C9D3CC; border-radius: 8px; font-size: 14px; background: #fff; width: 100%; min-width: 0; }
.ed-row input.cost { text-align: right; }
.place-cell { display: flex; flex-direction: column; gap: 4px; }
.place-cell .line { display: flex; gap: 6px; }
.place-cell .line input { flex: 1; }
.place-cell .find { flex: none; min-height: 42px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--pine); background: #fff; color: var(--pine); font-weight: 600; font-size: 13px; }
.pinned { font-size: 12px; color: var(--pine); display: inline-flex; align-items: center; gap: 4px; }
.pinned button { border: 0; background: none; color: var(--muted); text-decoration: underline; font-size: 12px; padding: 0 2px; min-height: 28px; }
.geo-list { display: flex; flex-direction: column; gap: 4px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 6px; }
.geo-list button { text-align: left; border: 0; background: none; padding: 8px; border-radius: 6px; font-size: 13px; min-height: 40px; }
.geo-list button:hover { background: var(--pine-soft); }
.day-label { min-height: 44px; padding: 0 10px; border: 1px solid transparent; border-radius: 8px; font-size: 18px; font-weight: 800; background: #F7F9F7; max-width: 280px; }
.day-label:hover { border-color: #C9D3CC; }
.add-line { align-self: flex-start; border: 1px dashed #8FA69A; background: none; border-radius: 10px; padding: 0 14px; min-height: 44px; color: var(--pine); font-weight: 600; }

/* Lists */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-item { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.list-item .info { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 320px; }
.list-item .actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 12px; font-weight: 600; font-size: 14px; max-width: calc(100% - 40px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 1000; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 640px) {
  .panel { padding: 18px; }
  .filter-row > .label { min-width: 100%; }
  .map, .map-side { height: 340px; max-height: none; }
  .map-side { height: auto; }
  .tl-row { grid-template-columns: 46px 24px minmax(0, 1fr); }
  .tl-row .cost { grid-column: 3; }
}
.btn-link { display: inline-flex; align-items: center; align-self: flex-start; }
.nav a.btn-primary { color: #fff; background: var(--pine); padding: 0 18px; }
.nav a.btn-primary:hover { color: #fff; background: var(--pine-dark); }

.nav a.btn-primary[aria-current="page"] { text-decoration: none; }

/* Gợi ý zoom bản đồ */
.map { position: relative; }
.map-hint { position: absolute; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 24px; text-align: center; background: rgba(23, 34, 28, .55); color: #fff; font-weight: 700; font-size: 16px; opacity: 0; pointer-events: none; transition: opacity .25s; border-radius: inherit; }
.map-hint.show { opacity: 1; }
.map.map-active { box-shadow: 0 0 0 3px var(--pine-soft); }

/* Ô nhập có gợi ý (điểm đến) */
.combo-box { position: relative; }
.sug { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(23, 34, 28, .12); padding: 4px; display: flex; flex-direction: column; max-height: 280px; overflow-y: auto; }
.sug[hidden] { display: none; }
.sug button { text-align: left; border: 0; background: none; padding: 10px 12px; min-height: 44px; border-radius: 6px; font-size: 15px; font-weight: 500; }
.sug button:hover, .sug button:focus-visible { background: var(--pine-soft); outline: none; }
.combo-note { color: var(--pine); min-height: 1em; }

/* Ước tính cho nhóm */
.estimate { background: #F7F9F7; border: 1px solid var(--line-2); border-radius: 14px; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.estimate .stat { background: var(--surface); }
.est-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.est-head h2 { font-size: 17px; font-weight: 800; }
.stepper { display: inline-flex; align-items: center; border: 1px solid #B9C6BE; border-radius: 999px; background: var(--surface); overflow: hidden; }
.stepper button { width: 44px; height: 44px; border: 0; background: none; font-size: 22px; font-weight: 700; color: var(--pine); }
.stepper button:hover { background: var(--pine-soft); }
.stepper output { min-width: 44px; text-align: center; font-size: 18px; font-weight: 800; }
.stats-panel h2 { font-size: 20px; font-weight: 800; }
.btn[aria-pressed="true"] { background: var(--pine-soft); }
.print-only { display: none; }

/* In / lưu PDF */
@media print {
  @page { margin: 14mm; }
  body { background: #fff; font-size: 12pt; display: block; }
  .site-header, .site-footer, .toast, .skip, .no-print, #map-panel, .side .panel, #report-box, .btn-link, .tl-row .n { display: none !important; }
  .print-only { display: block; }
  .wrap { max-width: none; padding: 0; }
  .page { padding: 0; gap: 12px; }
  .panel, .day-card, .callout, .estimate { border: 1px solid #ccc; box-shadow: none; break-inside: avoid; }
  .day-card { break-inside: auto; }
  .tl-row { break-inside: avoid; grid-template-columns: 52px minmax(0, 1fr) auto; padding: 6px 0; }
  .cols { display: block; }
  .cols > .side { margin-top: 12px; }
  .bar span, .legend i, .tl-row .meta i { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { color: inherit; text-decoration: none; }
}
