
:root {
  color-scheme: light;
  --bg: #eef1f5; --surface: #ffffff; --text: #0f172a; --muted: #334155; --border: #b8c2cf;
  --primary: #1d4ed8; --primary-soft: #dbe6ff; --danger: #b91c1c; --warn-bg: #fef3c7; --warn-text: #78350f;
  --st-vacant: #15803d; --st-occupied: #b91c1c; --st-cleaning: #b45309; --st-maintenance: #475569;
  --radius: 14px; --shadow: 0 1px 3px rgba(15, 23, 42, .12), 0 1px 2px rgba(15, 23, 42, .06);
}
* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 19px; line-height: 1.5; }
[hidden] { display: none !important; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.35rem; margin-bottom: .7rem; }
h3 { font-size: 1.15rem; margin: 1.1rem 0 .5rem; }
small, .muted { color: var(--muted); font-size: .95rem; }
label { display: block; font-size: .95rem; color: var(--muted); font-weight: 600; margin-bottom: .75rem; }
input, select { display: block; width: 100%; min-height: 56px; margin-top: .3rem; padding: .7rem .9rem; font: inherit; font-size: 1.05rem; color: var(--text); background: var(--surface); border: 2px solid var(--border); border-radius: 10px; }
input[type=checkbox], input[type=radio] { display: inline; width: 1.3em; height: 1.3em; min-height: 0; margin: 0 .45rem 0 0; vertical-align: middle; }
input:focus, select:focus { outline: 3px solid var(--primary); outline-offset: 0; }
fieldset { border: 2px solid var(--border); border-radius: 10px; padding: .75rem .9rem .2rem; margin-bottom: .75rem; }
legend { font-size: .95rem; color: var(--muted); font-weight: 600; padding: 0 .35rem; }
fieldset.guest legend { display: flex; align-items: center; gap: .6rem; }
.btn.sm.guest-remove { min-height: 36px; min-width: 0; padding: .1rem .65rem; font-size: .9rem; }
/* Chỉ còn 1 khách thì không xóa được (luôn chừa 1 ô) → ẩn nút Xóa. */
#guest-list > fieldset.guest:only-child .guest-remove { display: none; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 56px; padding: .7rem 1.25rem; font: inherit; font-size: 1.05rem; font-weight: 700; border-radius: 10px; border: 2px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-ghost { background: transparent; color: var(--primary); border-style: dashed; margin-bottom: .75rem; }
.btn.sm { min-height: 48px; min-width: 48px; padding: .3rem .85rem; font-size: 1.15rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: .7rem; justify-content: flex-end; margin-top: 1.2rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .75rem; }
.three-col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 .75rem; }
@media (max-width: 599px) {
  .three-col { grid-template-columns: 1fr 1fr; }
  .three-col > :last-child { grid-column: 1 / -1; }
}
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow); margin-bottom: 1.1rem; }

main { padding: 16px 16px 128px; }
@media (min-width: 1600px) { body { font-size: 21px; } }
.app-nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex; background: var(--surface); border-top: 2px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
.app-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; padding: .55rem 0; font-size: 1.75rem; line-height: 1.2; color: var(--muted); text-decoration: none; }
.app-nav a span { font-size: .95rem; font-weight: 600; }
.app-nav a.active { color: var(--primary); background: var(--primary-soft); border-radius: 12px; }
.app-nav a.active span { font-weight: 800; }
@media (min-width: 900px) {
  .app-nav { top: 0; right: auto; width: 124px; flex-direction: column; border-top: 0; border-right: 2px solid var(--border); padding-top: 1rem; }
  .app-nav a { flex: 0; padding: .9rem 0; }
  main { margin-left: 124px; padding: 24px 32px; }
}
.page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: 1.1rem; }
.page-header .picker-month { width: 190px; margin: 0; }

.st-vacant { --st: var(--st-vacant); }
.st-occupied { --st: var(--st-occupied); }
.st-cleaning { --st: var(--st-cleaning); }
.st-maintenance { --st: var(--st-maintenance); }
.counts { display: flex; flex-wrap: wrap; gap: .5rem; }
.dot { font-size: 1.05rem; font-weight: 700; padding: .35rem .85rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); }
@media (min-width: 900px) { .dot { font-size: 1.15rem; padding: .4rem 1rem; } }
.dot::before { content: ""; display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; margin-right: .35rem; background: var(--st); }
.badge { font-size: .9rem; font-weight: 700; padding: .15rem .6rem; border-radius: 999px; color: #fff; background: var(--st); }

.room-grid { display: grid; grid-template-columns: repeat(2, 1fr); grid-auto-rows: 220px; gap: 1rem; }
@media (min-width: 600px) { .room-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) {
  .room-grid { grid-template-columns: repeat(4, 1fr); grid-auto-rows: minmax(220px, 1fr); min-height: calc(100vh - 140px); gap: 1.25rem; }
}
@media (min-width: 1300px) { .room-grid { grid-template-columns: repeat(6, 1fr); } }
/* Ô phòng là container: chữ bên trong co giãn theo kích thước ô (đơn vị cqmin). */
.room-tile { container-type: size; display: flex; flex-direction: column; align-items: center; justify-content: space-between; gap: .5rem; padding: 1.25rem 1rem; text-align: center; font: inherit; color: var(--text); background: color-mix(in srgb, var(--st) 7%, var(--surface)); border: 2px solid color-mix(in srgb, var(--st) 55%, var(--border)); border-radius: 20px; cursor: pointer; box-shadow: var(--shadow); transition: transform .12s ease, box-shadow .12s ease; }
@media (min-width: 900px) { .room-tile { padding: 1.75rem 1.5rem; } }
.room-tile:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0, 0, 0, .2); }
.room-tile:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
.room-tile.st-occupied { background: color-mix(in srgb, var(--st) 14%, var(--surface)); }
.room-head { display: flex; flex-direction: column; align-items: center; gap: .25rem; }
.room-head b { font-size: clamp(2rem, 24cqmin, 6rem); line-height: 1; letter-spacing: -.02em; }
.room-head small { font-size: clamp(.95rem, 7cqmin, 1.6rem); color: var(--muted); font-weight: 600; }
.room-body { display: flex; flex-direction: column; align-items: center; gap: .15rem; font-size: clamp(1rem, 7.5cqmin, 1.7rem); font-weight: 700; }
.room-money { font-size: 1.15em; }
.room-status { display: block; width: 100%; padding: .45em .6em; border-radius: 999px; background: var(--st); color: #fff; font-weight: 800; letter-spacing: .02em; font-size: clamp(1.05rem, 8cqmin, 1.9rem); }

.dialog-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(10, 14, 20, .55); display: flex; align-items: flex-end; justify-content: center; }
.dialog-panel { width: 100%; max-width: min(960px, 94vw); max-height: 94vh; overflow-y: auto; background: var(--surface); border-radius: 18px 18px 0 0; padding: 1.2rem 16px calc(1.2rem + env(safe-area-inset-bottom)); }
@media (min-width: 600px) {
  .dialog-backdrop { align-items: center; }
  .dialog-panel { border-radius: 18px; padding: 1.6rem; }
}
.chip-group { display: flex; gap: .55rem; margin-bottom: 1rem; flex-wrap: wrap; }
.chip { position: relative; display: inline-flex; align-items: center; min-height: 50px; padding: .6rem 1.1rem; border: 2px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); font: inherit; font-size: 1.05rem; font-weight: 600; cursor: pointer; margin: 0; }
.chip:has(input:checked) { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.service-chips { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: .6rem; }
.custom-service { display: grid; grid-template-columns: 1fr 1fr auto; gap: .5rem; margin-top: .75rem; align-items: center; }
.custom-service input { margin: 0; }
.custom-service input:first-child { grid-column: 1 / -1; }
@media (min-width: 600px) {
  .custom-service { grid-template-columns: 1fr 120px 76px auto; }
  .custom-service input:first-child { grid-column: auto; }
}
.service-line { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .55rem 0; border-bottom: 1px solid var(--border); font-size: 1.05rem; }
.qty { display: inline-flex; align-items: center; gap: .6rem; }
.qty b { min-width: 1.6em; text-align: center; font-size: 1.2rem; }
.warning { background: var(--warn-bg); color: var(--warn-text); padding: .6rem .85rem; border-radius: 10px; margin: .5rem 0; font-size: 1.02rem; font-weight: 600; }
.total { font-size: 1.5rem; margin-top: 1rem; text-align: right; }
.question { font-size: 1.25rem; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin-bottom: 1.1rem; }
@media (min-width: 700px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat-grid div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem; }
.stat-grid b { display: block; font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.chart-box { position: relative; height: 260px; }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 1.02rem; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { padding: .7rem .6rem; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.data-table input, .data-table select { margin: 0; min-width: 110px; }
.data-table .input-sm { min-width: 70px; width: 84px; }
.clickable { cursor: pointer; }
.clickable:hover { background: var(--bg); }
.stay-row { display: flex; flex-direction: column; gap: .2rem; width: 100%; text-align: left; font: inherit; color: var(--text); }
button.stay-row { cursor: pointer; }
.search-row { display: grid; grid-template-columns: 1fr; gap: .6rem; }
@media (min-width: 700px) { .search-row { grid-template-columns: 210px 1fr auto; align-items: end; } }
.search-row input { margin: 0; }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login .card { width: 100%; max-width: 440px; }
.login h1 { margin-bottom: 1.1rem; text-align: center; font-size: 1.9rem; }
.login .btn { width: 100%; }
.error { color: var(--danger); margin-top: .7rem; min-height: 1.3em; font-weight: 600; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(110px + env(safe-area-inset-bottom)); z-index: 30; background: var(--text); color: var(--surface); padding: .9rem 1.3rem; border-radius: 12px; max-width: calc(100% - 32px); font-size: 1.1rem; font-weight: 600; box-shadow: 0 4px 14px rgba(0, 0, 0, .25); }
.toast.toast-error { background: var(--danger); color: #fff; }
.loading { display: flex; align-items: center; justify-content: center; gap: .6rem; color: var(--muted); padding: 1.5rem 0; }
#content > .loading { min-height: 60vh; }
.loading::before, .btn.busy::before { content: ""; flex: none; width: 1.2em; height: 1.2em; border: 3px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.boot-loading { min-height: 100vh; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; }
.load-error p { margin-bottom: .7rem; }
.settings-grid { display: grid; grid-template-columns: 1fr; gap: 0 1.1rem; align-items: start; }
.settings-grid > * { min-width: 0; }
@media (min-width: 1400px) { .settings-grid { grid-template-columns: 1fr 1fr; } }
.input-row { display: flex; gap: .5rem; align-items: center; margin-top: .3rem; }
.input-row input { margin-top: 0; flex: 1; min-width: 0; }
.input-row .btn { flex: none; }
/* flatpickr: phóng to cho dễ bấm */
.flatpickr-calendar { width: 372px; font-size: 18px; border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); }
.flatpickr-calendar.hasTime.noCalendar { width: 240px; }
.flatpickr-days, .dayContainer { width: 364px; min-width: 364px; max-width: 364px; }
.flatpickr-day { max-width: 52px; height: 50px; line-height: 48px; font-size: 1.05rem; }
.flatpickr-day.selected, .flatpickr-day.selected:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.flatpickr-calendar input { min-height: 0; margin: 0; border: 0; border-radius: 0; background: transparent; }
.flatpickr-calendar select { display: inline-block; width: auto; min-height: 0; margin: 0; padding: 0 .25rem; border: 0; font-size: inherit; background: transparent; }
.flatpickr-current-month input.cur-year { display: inline-block; height: auto; padding: 0 0 0 .5ch; }
.flatpickr-months .flatpickr-month { height: 56px; }
.flatpickr-current-month { font-size: 1.2rem; height: 56px; padding-top: 12px; }
.flatpickr-current-month .numInputWrapper { width: 5.5ch; }
span.flatpickr-weekday { font-size: .95rem; font-weight: 700; }
.flatpickr-months .flatpickr-prev-month, .flatpickr-months .flatpickr-next-month { height: 56px; padding: 16px 14px; }
.flatpickr-time { height: 60px; max-height: 60px; line-height: 60px; }
.flatpickr-time input, .flatpickr-time .flatpickr-time-separator { font-size: 1.4rem; }
.flatpickr-monthSelect-month { font-size: 1.05rem; padding: 12px 6px; width: 33%; }
.flatpickr-monthSelect-month.selected { background: var(--primary); border-color: var(--primary); color: #fff; }
@media (max-width: 400px) {
  .flatpickr-calendar { width: 344px; }
  .flatpickr-days, .dayContainer { width: 336px; min-width: 336px; max-width: 336px; }
  .flatpickr-day { max-width: 48px; height: 46px; line-height: 44px; }
}
/* Cột Giờ / Phút kiểu Ant Design */
.flatpickr-calendar.has-time-columns { width: auto; }
.flatpickr-calendar.has-time-columns .flatpickr-time { display: none; }
.flatpickr-calendar.has-time-columns.noCalendar .cal-main { display: none; }
.flatpickr-calendar.has-time-columns.noCalendar [data-fp-now] { display: none; }
.cal-row { display: flex; }
.cal-main { width: 372px; position: relative; }
.cal-main .flatpickr-months { position: relative; }
.time-columns { display: flex; border-left: 1px solid var(--border); }
.time-col { display: flex; flex-direction: column; width: 78px; }
.time-col + .time-col { border-left: 1px solid var(--border); }
.time-col-title { padding: .5rem 0; text-align: center; font-size: .95rem; font-weight: 700; color: var(--muted); border-bottom: 1px solid var(--border); }
.time-col-list { height: 312px; overflow-y: auto; padding: 4px; scrollbar-width: thin; }
.time-cell { display: block; width: 100%; min-height: 44px; margin: 0 0 2px; border: 0; border-radius: 8px; background: transparent; color: var(--text); font: inherit; font-size: 1.1rem; cursor: pointer; }
.time-cell:hover { background: var(--primary-soft); }
.time-cell.selected { background: var(--primary); color: #fff; font-weight: 700; }
.time-footer { display: flex; align-items: center; gap: .5rem; padding: .6rem .8rem; border-top: 1px solid var(--border); }
.time-summary { flex: 1; font-size: 1.05rem; font-weight: 700; }
@media (max-width: 600px) {
  .cal-row { flex-direction: column; }
  .time-columns { border-left: 0; border-top: 1px solid var(--border); }
  .time-col { flex: 1; width: auto; }
  .time-col-list { height: 176px; }
}
@media (max-width: 400px) { .cal-main { width: 344px; } }
.choice-overlay { position: fixed; inset: 0; z-index: 35; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(15, 23, 42, .45); }
.choice-box { width: 100%; max-width: 520px; padding: 1.4rem; border-radius: 16px; background: var(--surface); box-shadow: 0 20px 50px rgba(0, 0, 0, .35); }
.choice-box .question { font-weight: 700; }
.stay-summary { margin: .3rem 0 .9rem; font-size: 1.45rem; font-weight: 700; color: var(--text); }
#dialog-body > h2 { font-size: 1.75rem; }
.stay-summary b { color: var(--primary); }
.badge.badge-lg { display: inline-block; margin: .3rem 0 .4rem; padding: .4rem 1.3rem; font-size: 1.4rem; }
