:root {
  --pri: #0f766e; --pri-2: #14b8a6; --pri-soft: #ccfbf1; --acc: #f97316;
  --ink: #0f172a; --mut: #64748b; --line: #e2e8f0; --bg: #f6f8f7; --card: #fff;
  --ok: #15803d; --warn: #b45309; --bad: #b91c1c; --r: 14px;
  --sh: 0 1px 2px rgba(15, 23, 42, .06), 0 6px 20px rgba(15, 23, 42, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'Be Vietnam Pro', system-ui, -apple-system, Segoe UI, sans-serif; color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.5; }
body.no-scroll { overflow: hidden; }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.25; }
h1 { font-size: 22px; } h2 { font-size: 20px; } h3 { font-size: 16px; } h4 { font-size: 14px; margin-top: 18px; }
a { color: var(--pri); }
.muted { color: var(--mut); } .small { font-size: 13px; }
code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: 13px; }

/* ===== Thanh trên ===== */
.topbar { height: 60px; display: flex; align-items: center; gap: 24px; padding: 0 20px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1000; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; color: var(--ink); text-decoration: none; }
.logo { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--pri), var(--pri-2)); font-size: 18px; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { padding: 8px 12px; border-radius: 9px; color: var(--mut); text-decoration: none; font-weight: 500; }
.topbar nav a:hover { background: #f1f5f9; color: var(--ink); }
.topbar nav a.on { color: var(--pri); background: var(--pri-soft); }
.hotline { margin-left: auto; color: var(--mut); font-size: 14px; }

/* ===== Nút, ô nhập ===== */
.btn { appearance: none; border: 0; background: var(--pri); color: #fff; font: inherit; font-weight: 600; padding: 10px 16px; border-radius: 10px; cursor: pointer; }
.btn:hover { background: #0d635c; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: #f8fafc; }
.btn.acc { background: var(--acc); } .btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.danger { background: #fff; color: var(--bad); border: 1px solid #fecaca; }
.btn.full { width: 100%; padding: 13px; font-size: 16px; margin-top: 10px; }
.link { background: none; border: 0; color: var(--pri); cursor: pointer; font: inherit; font-size: 13px; padding: 0 4px; text-decoration: underline; }
label { display: block; font-size: 13px; color: var(--mut); font-weight: 500; margin-bottom: 8px; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; font: inherit; color: var(--ink); padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--pri-2); outline-offset: -1px; border-color: transparent; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 14px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 14px; cursor: pointer; color: var(--ink); }
.chip:hover { border-color: var(--pri-2); }
.chip.on { background: var(--pri); border-color: var(--pri); color: #fff; }
.chip.light { box-shadow: var(--sh); border-color: transparent; font-weight: 500; }

/* ===== Trang tìm kiếm ===== */
.search-layout { display: grid; grid-template-columns: 420px 1fr; height: calc(100vh - 60px); }
.panel { overflow-y: auto; background: #fff; border-right: 1px solid var(--line); }
.filters { padding: 20px 20px 8px; border-bottom: 1px solid var(--line); }
.results-head { padding: 12px 20px 4px; font-size: 14px; }
.results { padding: 8px 14px 24px; display: grid; gap: 10px; }
.card { display: grid; grid-template-columns: 110px 1fr; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; cursor: pointer; transition: box-shadow .15s, border-color .15s; }
.card:hover { box-shadow: var(--sh); border-color: #99f6e4; }
.card h3 { margin: 0 0 2px; font-size: 15px; }
.thumb { border-radius: 10px; min-height: 100px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff; }
.thumb span { font-size: 36px; } .thumb em { font-style: normal; font-size: 12px; opacity: .9; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.tags span { font-size: 12px; background: #f1f5f9; border-radius: 999px; padding: 2px 8px; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.price { font-size: 15px; color: var(--ink); } .price small { color: var(--mut); font-weight: 400; }
.badge { font-size: 12px; border-radius: 6px; padding: 2px 7px; font-weight: 500; }
.badge.ok { background: #dcfce7; color: var(--ok); } .badge.warn { background: #fef3c7; color: var(--warn); }
.empty { text-align: center; padding: 40px 10px; }

/* Màu theo loại hình */
.t-villa { background: linear-gradient(135deg, #0f766e, #2dd4bf); }
.t-resort { background: linear-gradient(135deg, #0369a1, #38bdf8); }
.t-hotel { background: linear-gradient(135deg, #4338ca, #818cf8); }
.t-homestay { background: linear-gradient(135deg, #c2410c, #fb923c); }
.t-nhanghi { background: linear-gradient(135deg, #a16207, #facc15); }

/* ===== Bản đồ ===== */
.map-wrap { position: relative; }
#map { position: absolute; inset: 0; background: #e5ebe9; }
#map.drawing { cursor: crosshair; touch-action: none; }
#map.drawing .leaflet-marker-icon { pointer-events: none; }
.map-dests { position: absolute; top: 14px; left: 14px; right: 14px; z-index: 500; display: flex; gap: 6px; flex-wrap: wrap; pointer-events: none; }
.map-dests .chip { pointer-events: auto; }
.map-tools { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 500; display: flex; gap: 8px; background: #fff; padding: 6px; border-radius: 14px; box-shadow: 0 8px 30px rgba(15, 23, 42, .18); }
.tool { border: 0; background: #f1f5f9; font: inherit; font-weight: 600; padding: 10px 14px; border-radius: 10px; cursor: pointer; white-space: nowrap; }
.tool:hover { background: #e2e8f0; }
.tool.on { background: var(--pri); color: #fff; animation: pulse 1.6s infinite; }
.tool.ghost { background: #fff; color: var(--bad); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(20, 184, 166, .5); } 50% { box-shadow: 0 0 0 6px rgba(20, 184, 166, 0); } }
.map-hint { position: absolute; left: 50%; bottom: 86px; transform: translateX(-50%); z-index: 500; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 10px; font-size: 14px; white-space: nowrap; }

.mk { background: none; border: 0; }
.dot { display: block; width: 16px; height: 16px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .35); cursor: pointer; }
.dot.faded { opacity: .45; transform: scale(.75); }
.tag { position: absolute; left: 0; top: 0; transform: translate(-50%, calc(-100% - 6px)); }
.tag-in { color: #fff; font-weight: 700; font-size: 13px; padding: 4px 9px; border-radius: 999px; white-space: nowrap; box-shadow: 0 3px 10px rgba(0, 0, 0, .3); border: 2px solid #fff; cursor: pointer; position: relative; animation: pop .45s cubic-bezier(.2, 1.6, .4, 1) both; transition: transform .15s; }
.tag-in::after { content: ''; position: absolute; left: 50%; bottom: -7px; width: 10px; height: 10px; background: inherit; border-right: 2px solid #fff; border-bottom: 2px solid #fff; transform: translateX(-50%) rotate(45deg); z-index: -1; }
.tag-in:hover, .tag-in.hl { transform: scale(1.18); z-index: 10; }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.3); } to { opacity: 1; transform: none; } }

/* ===== Modal ===== */
.modal { position: fixed; inset: 0; z-index: 2000; background: rgba(15, 23, 42, .5); display: flex; align-items: flex-start; justify-content: center; padding: 30px 14px; overflow-y: auto; }
.modal[hidden] { display: none; }
.modal-box { background: #fff; border-radius: 18px; width: 100%; max-width: 560px; position: relative; padding: 24px; box-shadow: 0 30px 80px rgba(0, 0, 0, .3); }
.modal-box.wide { max-width: 1000px; padding: 0; overflow: hidden; }
.modal-x { position: absolute; top: 10px; right: 12px; z-index: 3; width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .9); font-size: 22px; cursor: pointer; }
.detail-hero { display: flex; align-items: center; gap: 16px; padding: 28px 24px; color: #fff; }
.detail-hero > span { font-size: 54px; }
.detail-hero h2 { font-size: 24px; margin: 0; }
.detail-grid { display: grid; grid-template-columns: 1fr 380px; gap: 24px; padding: 20px 24px 24px; }
.amen { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; margin: 8px 0 16px; color: #334155; }
.bk { background: #f8fafc; border: 1px solid var(--line); border-radius: var(--r); padding: 16px; align-self: start; }
.bk-price { font-size: 15px; margin-bottom: 10px; } .bk-price b { font-size: 22px; }
.svc { display: grid; grid-template-columns: 20px 1fr auto 52px; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-bottom: 6px; color: var(--ink); font-weight: 400; font-size: 14px; cursor: pointer; }
.svc input[type=checkbox] { width: 18px; height: 18px; margin: 0; accent-color: var(--pri); }
.svc-name small { display: block; color: var(--mut); font-size: 12px; }
.svc-price { font-weight: 600; font-size: 13px; text-align: right; } .svc-price small { color: var(--mut); font-weight: 400; }
.svc .qty { margin: 0; padding: 5px 6px; text-align: center; }
.pill { font-size: 11px; background: var(--acc); color: #fff; border-radius: 999px; padding: 1px 8px; vertical-align: middle; font-weight: 600; }
.sum { margin-top: 14px; border-top: 1px dashed #cbd5e1; padding-top: 10px; font-size: 14px; }
.sum > div { display: flex; justify-content: space-between; padding: 3px 0; }
.sum .tot { font-size: 16px; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 8px; }
.sum .dep { color: var(--pri); font-weight: 600; }
.err { color: var(--bad); font-size: 13px; min-height: 18px; margin-top: 6px; }
.alert { background: #fef3c7; color: #78350f; border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 10px 0; }

/* ===== Lịch ===== */
.cal { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-size: 14px; }
.cal-head span { width: 30px; }
.cal-nav { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 18px; line-height: 1; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-grid i { font-style: normal; text-align: center; font-size: 11px; color: var(--mut); padding: 2px 0; }
.day { aspect-ratio: 1; border: 0; border-radius: 8px; font: inherit; font-size: 13px; cursor: pointer; background: #f0fdf4; color: #14532d; padding: 0; }
.day.free:hover { outline: 2px solid var(--pri-2); }
.day.past { background: transparent; color: #cbd5e1; cursor: default; }
.day.booked { background: #fee2e2; color: #991b1b; text-decoration: line-through; cursor: default; }
.day.blocked { background: repeating-linear-gradient(45deg, #e2e8f0, #e2e8f0 4px, #f1f5f9 4px, #f1f5f9 8px); color: #64748b; cursor: default; }
.day.sel { background: var(--pri); color: #fff; font-weight: 700; }
.day.inrange { background: var(--pri-soft); color: var(--pri); }
.day.canend { box-shadow: inset 0 0 0 1px #99f6e4; }
.owner-cal .day.blocked, .owner-cal .day.free { cursor: pointer; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; font-size: 12px; color: var(--mut); margin-top: 10px; }
.lg { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: middle; margin-right: 4px; }
.lg.free { background: #f0fdf4; border: 1px solid #bbf7d0; } .lg.booked { background: #fee2e2; } .lg.sel { background: var(--pri); }
.lg.blocked { background: repeating-linear-gradient(45deg, #e2e8f0, #e2e8f0 3px, #f8fafc 3px, #f8fafc 6px); border: 1px solid #e2e8f0; }

/* ===== Thanh toán QR ===== */
.pay { display: grid; grid-template-columns: 210px 1fr; gap: 18px; align-items: center; margin: 14px 0; }
.qr { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 8px; }
.qr svg { display: block; width: 100%; height: auto; }
.pay-info { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 14px; }
.pay-info dt { color: var(--mut); } .pay-info dd { margin: 0; }
.pay-info .big { font-size: 20px; font-weight: 700; color: var(--pri); }
.done { text-align: center; padding: 20px 0 6px; }
.done-ico { width: 64px; height: 64px; border-radius: 50%; background: #dcfce7; color: var(--ok); display: grid; place-items: center; font-size: 34px; margin: 0 auto 12px; }

/* ===== Trang quản lý (chủ nhà / quản trị) ===== */
.wrap { max-width: 1240px; margin: 0 auto; padding: 24px 20px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.box { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin-bottom: 18px; }
.box-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.box-head h2 { font-size: 17px; margin: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.kpi span { color: var(--mut); font-size: 13px; } .kpi b { display: block; font-size: 22px; margin-top: 2px; } .kpi small { color: var(--mut); font-size: 12px; }
.kpi.hl { background: linear-gradient(135deg, var(--pri), var(--pri-2)); color: #fff; border: 0; } .kpi.hl span, .kpi.hl small { color: #ccfbf1; }
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--mut); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr:hover td { background: #fafafa; }
.svc-list { font-size: 12px; color: #334155; } .svc-list div { white-space: nowrap; }
.st { font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.st-wait { background: #fef3c7; color: #92400e; } .st-paid { background: #dbeafe; color: #1e40af; }
.st-ok { background: #dcfce7; color: #166534; } .st-cancel { background: #f1f5f9; color: #64748b; }
.acts { display: flex; gap: 4px; flex-wrap: wrap; }
.avail-grid td, .avail-grid th { padding: 4px; text-align: center; }
.avail-grid td:first-child, .avail-grid th:first-child { text-align: left; padding-left: 8px; white-space: nowrap; }
.cell { display: block; width: 100%; min-width: 22px; height: 22px; border-radius: 5px; }
.cell.free { background: #bbf7d0; } .cell.booked { background: #fca5a5; } .cell.blocked { background: #e2e8f0; }
.avail-grid th.we { color: var(--acc); }
.side-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 18px; align-items: start; }
.side-layout > * { min-width: 0; }
.prop-list { display: grid; gap: 6px; max-height: 70vh; overflow-y: auto; }
.prop-item { text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 10px; cursor: pointer; font: inherit; }
.prop-item.on { border-color: var(--pri); background: var(--pri-soft); }
.prop-item small { display: block; color: var(--mut); }
.svc-edit { display: grid; grid-template-columns: 1fr 140px 110px auto; gap: 8px; align-items: center; margin-bottom: 6px; }
.svc-edit input { margin: 0; }
.mini-map { height: 260px; border-radius: 12px; border: 1px solid var(--line); margin: 4px 0 10px; }
.check-grid { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 4px 0 10px; }
.check-grid label { display: flex; align-items: center; gap: 6px; color: var(--ink); font-weight: 400; margin: 0; }
.check-grid input { width: auto; margin: 0; }
.switch { width: auto; display: inline-block; margin: 0; accent-color: var(--pri); transform: scale(1.2); }

.who { margin-left: auto; display: flex; align-items: center; gap: 4px; font-size: 14px; white-space: nowrap; }
.who b { margin-right: 6px; }
.login-box { max-width: 400px; margin: 40px auto; padding: 28px; }
.hold { background: #ecfeff; color: #155e75; border-radius: 10px; padding: 8px 12px; margin: 8px 0 0; }
.btn:disabled { opacity: .6; cursor: wait; }
#toast { position: fixed; left: 50%; bottom: 30px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; opacity: 0; transition: .25s; z-index: 3000; pointer-events: none; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===== Điện thoại / máy tính bảng ===== */
@media (max-width: 960px) {
  .search-layout { grid-template-columns: 1fr; height: auto; }
  .map-wrap { height: 62vh; order: -1; position: sticky; top: 60px; z-index: 1; }
  .panel { border-right: 0; overflow: visible; }
  .detail-grid { grid-template-columns: 1fr; }
  .side-layout { grid-template-columns: 1fr; }
  .hotline { display: none; }
}
@media (max-width: 600px) {
  .topbar { gap: 10px; padding: 0 12px; }
  .brand span:last-child { display: none; }
  .topbar nav { gap: 0; }
  .topbar nav a { padding: 6px 7px; font-size: 13px; white-space: nowrap; }
  .map-wrap { position: relative; top: 0; }
  .map-tools { bottom: 14px; }
  .tool { padding: 9px 10px; font-size: 14px; }
  .pay { grid-template-columns: 1fr; } .qr { max-width: 240px; margin: 0 auto; }
  .card { grid-template-columns: 84px 1fr; }
  .svc-edit { grid-template-columns: 1fr 1fr; }
  .modal { padding: 0; } .modal-box { border-radius: 0; min-height: 100%; }
}
