/*
 * ThiThi79 - lớp ổn định layout.
 *
 * File này được nạp sau app.css để gom các quy tắc responsive về một nơi,
 * tránh các khối CSS cũ ghi đè lẫn nhau.
 */

:root {
    --page-max: 1680px;
    --page-gutter: clamp(12px, 2vw, 28px);
    --control-height: 42px;
}

html {
    min-width: 0;
    min-height: 100%;
    background: var(--bg);
}

body {
    min-width: 0;
    min-height: 100vh;
}

body.is-authenticated {
    overflow-x: hidden;
}

img,
svg,
video,
canvas {
    max-width: 100%;
}

/* ---------- Khung quản trị ---------- */

.hotel-app {
    width: 100%;
    min-width: 0;
}

.hotel-topbar {
    gap: 14px;
    padding-inline: 16px;
}

.brand {
    flex: 0 0 auto;
}

.top-menu {
    min-width: 0;
    justify-content: flex-start;
}

.top-menu > a,
.menu-link {
    min-height: 44px;
    padding: 12px 13px;
}

.menu-link {
    border: 0;
    background: transparent;
}

.top-actions {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 10px;
}

/* ---------- Popup nhập điện nước ---------- */

body.meter-popup-open {
    overflow: hidden;
}

body:has(.meter-popup-mask:target) {
    overflow: hidden;
}

.meter-popup-mask {
    position: fixed;
    inset: 0;
    z-index: 1600;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(15, 23, 42, .52);
    backdrop-filter: blur(3px);
}

.meter-popup-mask.show,
.meter-popup-mask:target {
    display: flex;
}

.meter-popup-dialog {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    width: min(1040px, calc(100vw - 36px));
    height: min(720px, calc(100dvh - 36px));
    overflow: hidden;
    border: 1px solid #d8e1ec;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 28px 80px rgba(15, 23, 42, .28);
}

.meter-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-height: 68px;
    padding: 12px 18px;
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
}

.meter-popup-header h2 {
    margin: 0;
    color: #0f172a;
    font-size: 21px;
    line-height: 1.25;
}

.meter-popup-header small {
    display: block;
    margin-top: 3px;
    color: #64748b;
    font-size: 14px;
}

.meter-popup-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid #dbe3ee;
    border-radius: 10px;
    background: #fff;
    color: #64748b;
    font-size: 27px;
    line-height: 1;
    text-decoration: none;
}

.meter-popup-close:hover {
    border-color: #b8c7da;
    background: #f8fafc;
    color: #0f172a;
}

.meter-popup-body {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    background: #f8fafc;
}

.meter-popup-loading,
.meter-popup-error {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 12px;
    min-height: 260px;
    padding: 24px;
    color: #64748b;
    font-size: 16px;
    text-align: center;
}

.meter-popup-loading::before {
    content: "";
    width: 34px;
    height: 34px;
    border: 3px solid #dbeafe;
    border-top-color: #0875f5;
    border-radius: 50%;
    animation: meterPopupSpin .7s linear infinite;
}

.meter-popup-error {
    color: #b42318;
}

.meter-popup-error button {
    min-height: 40px;
    padding: 8px 16px;
    border: 0;
    border-radius: 9px;
    background: #0875f5;
    color: #fff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
}

@keyframes meterPopupSpin {
    to {
        transform: rotate(360deg);
    }
}

.user-dropdown {
    position: relative;
    flex: 0 0 auto;
}

.user-dropdown-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    max-width: 220px;
    padding: 6px 12px 6px 8px;
    border: 1px solid #d7e1ef;
    border-radius: 999px;
    background: #fff;
    color: #101828;
    cursor: pointer;
    font-weight: 900;
    line-height: 1;
    box-shadow: 0 6px 18px rgba(15, 23, 42, .06);
    transition:
        border-color .18s ease,
        box-shadow .18s ease,
        background .18s ease;
}

.user-dropdown-toggle:hover,
.user-dropdown-toggle[aria-expanded="true"] {
    border-color: #84adff;
    background: #f8fbff;
    box-shadow: 0 10px 24px rgba(15, 23, 42, .1);
}

.user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background:
        linear-gradient(135deg, rgba(0, 110, 255, .14), rgba(8, 163, 77, .12)),
        #eef6ff;
    color: var(--blue);
    font-size: 15px;
}

.user-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-dropdown-toggle > .arrow {
    color: #667085;
    font-size: 12px;
    transition: transform .18s ease;
}

.user-dropdown-toggle[aria-expanded="true"] > .arrow {
    transform: rotate(180deg);
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 1002;
    display: grid;
    gap: 4px;
    width: min(240px, calc(100vw - 24px));
    padding: 10px;
    border: 1px solid rgba(215, 225, 239, .95);
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .18);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(8px) scale(.98);
    transform-origin: top right;
    transition:
        opacity .18s ease,
        visibility .18s ease,
        transform .18s ease;
}

.user-dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.user-dropdown-menu::before {
    content: "";
    position: absolute;
    top: -7px;
    right: 22px;
    width: 14px;
    height: 14px;
    border-left: 1px solid rgba(215, 225, 239, .95);
    border-top: 1px solid rgba(215, 225, 239, .95);
    background: #fff;
    transform: rotate(45deg);
}

.user-dropdown-info {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 4px;
    min-width: 0;
    padding: 10px 12px 12px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 4px;
}

.user-dropdown-info strong {
    overflow: hidden;
    color: #101828;
    font-size: 14px;
    font-weight: 900;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-dropdown-info small {
    display: inline-flex;
    width: fit-content;
    max-width: 100%;
    padding: 4px 8px;
    border-radius: 999px;
    background: #eef6ff;
    color: var(--blue);
    font-size: 12px;
    font-weight: 900;
    line-height: 1;
}

.user-dropdown-menu a {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 40px;
    padding: 10px 12px;
    border-radius: 12px;
    color: #344054;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
}

.user-dropdown-menu a:hover {
    background: #f8fbff;
    color: var(--blue);
}

.user-dropdown-menu a[href="/profile"]::before {
    content: "👤";
    font-size: 14px;
}

.user-dropdown-menu .logout-link {
    color: #b42318;
}

.user-dropdown-menu .logout-link::before {
    content: "↪";
    font-size: 15px;
}

.user-dropdown-menu .logout-link:hover {
    background: #fef3f2;
    color: #b42318;
}

.hotel-main {
    width: min(100%, var(--page-max));
    min-width: 0;
    margin: 0 auto !important;
    padding:
        calc(var(--topbar) + 36px)
        var(--page-gutter)
        30px !important;
}

/* ---------- Thành phần chung ---------- */

.page-head {
    min-width: 0;
    flex-wrap: wrap;
}

.page-head > div:first-child {
    min-width: 0;
}

.page-head h2,
.page-title {
    margin: 0;
    color: #101828;
    font-size: clamp(22px, 2vw, 28px);
    line-height: 1.25;
}

.page-head p {
    margin: 6px 0 0;
    line-height: 1.45;
}

.page-actions,
.toolbar-actions,
.table-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.content-card,
.form-card,
.profile-card,
.card {
    min-width: 0;
    border: 1px solid rgba(225, 234, 246, .95);
    border-radius: 18px;
    background: #fff;
    box-shadow: var(--shadow);
}

.card-body,
.form-card,
.profile-card {
    padding: 18px;
}

.card-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    font-weight: 900;
}

.section-title {
    margin: 0 0 14px;
    font-size: 17px;
    font-weight: 900;
}

.app-form-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 14px;
    align-items: end;
}

.field {
    min-width: 0;
    grid-column: span 3;
}

.field.span-1 {
    grid-column: span 1;
}

.field.span-2 {
    grid-column: span 2;
}

.field.span-3 {
    grid-column: span 3;
}

.field.span-4 {
    grid-column: span 4;
}

.field.span-5 {
    grid-column: span 5;
}

.field.span-6 {
    grid-column: span 6;
}

.field.span-8 {
    grid-column: span 8;
}

.field.span-9 {
    grid-column: span 9;
}

.field.span-10 {
    grid-column: span 10;
}

.field.span-12 {
    grid-column: 1 / -1;
}

.field label,
.form-label {
    display: block;
    margin: 0 0 7px;
    color: #344054;
    font-size: 13px;
    font-weight: 800;
}

.field-hint {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 12px;
}

input,
select,
textarea,
.form-control,
.form-select {
    min-width: 0;
    max-width: 100%;
}

textarea.form-control {
    min-height: 88px;
    resize: vertical;
}

button,
.btn,
.btn-primary,
.btn-light,
.btn-danger,
.btn-sm {
    max-width: 100%;
}

.btn,
.btn-primary,
.btn-light,
.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: var(--control-height);
    padding: 0 16px;
    border-radius: 12px;
    font-weight: 800;
    line-height: 1;
}

.btn {
    border: 1px solid #d7e1ef;
    background: #fff;
    color: #344054;
}

.btn.btn-primary,
.btn-primary {
    border-color: var(--blue);
    background: var(--blue);
    color: #fff;
}

.btn-success {
    border-color: #079455;
    background: #079455;
    color: #fff;
}

.btn-secondary {
    border-color: #d0d5dd;
    background: #f2f4f7;
    color: #344054;
}

.btn-outline-primary {
    border-color: #84adff;
    background: #fff;
    color: var(--blue);
}

.btn.btn-danger,
.btn-danger {
    border-color: var(--red);
    background: var(--red);
    color: #fff;
}

.btn-sm,
.btn.btn-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    height: auto;
    padding: 7px 11px;
    line-height: 1.1;
}

.w-100 {
    width: 100% !important;
}

.d-flex {
    display: flex !important;
}

.gap-1 {
    gap: 6px !important;
}

.gap-2 {
    gap: 10px !important;
}

.mb-3 {
    margin-bottom: 16px !important;
}

.mt-3 {
    margin-top: 16px !important;
}

.alert,
.app-flash {
    border: 1px solid transparent;
    border-radius: 14px;
}

.alert {
    margin-bottom: 14px;
    padding: 13px 15px;
    font-weight: 700;
}

.alert-danger {
    border-color: #fecdca;
    background: #fef3f2;
    color: #b42318;
}

.alert-success {
    border-color: #abefc6;
    background: #ecfdf3;
    color: #067647;
}

/* ---------- Bắt lỗi nhập form ---------- */

.has-error label {
    color: #b42318;
}

input.is-invalid,
select.is-invalid,
textarea.is-invalid,
.form-control.is-invalid,
.form-select.is-invalid {
    border-color: #f04438 !important;
    background: #fffafa;
    box-shadow: 0 0 0 3px rgba(240, 68, 56, .12) !important;
}

.field-error {
    margin-top: 6px;
    color: #b42318;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.35;
}

.form-error-summary {
    margin-bottom: 12px;
    padding: 12px 14px;
    border: 1px solid #fecdca;
    border-radius: 14px;
    background: #fef3f2;
    color: #b42318;
    font-size: 13px;
    font-weight: 900;
}

.readonly-value {
    min-height: 38px;
    display: flex;
    align-items: center;
    border: 1px solid #d3dce2;
    border-radius: 8px;
    background: #f8fafc;
    color: #334155;
    font-weight: 700;
    padding: 0 10px;
}

.inline-payment .field-error {
    grid-column: 1 / -1;
    margin-top: 0;
}

/* ---------- Bảng dữ liệu ---------- */

.table-wrap,
.kv-table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
}

.table-wrap table,
.data-table {
    width: 100%;
    min-width: 760px;
}

.table-wrap .wide-table {
    min-width: 1420px;
}

.table-wrap .billing-table {
    min-width: 1260px;
}

.table-wrap .contract-table {
    min-width: 980px;
}

.table-wrap th,
.kv-table-wrap th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f8fafc;
    color: #475467;
    font-weight: 900;
}

.table-wrap th,
.table-wrap td,
.kv-table-wrap th,
.kv-table-wrap td {
    vertical-align: middle;
}

.table-wrap tbody tr:hover,
.kv-table-wrap tbody tr:hover {
    background: #f8fbff;
}

.table-wrap td:last-child,
.kv-table-wrap td:last-child {
    white-space: nowrap;
}

.table-empty {
    padding: 34px 16px !important;
    color: var(--muted);
    text-align: center;
}

.inline-payment {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) 145px auto;
    gap: 6px;
    min-width: 360px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 27px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #f2f4f7;
    color: #475467;
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}

.status-pill.is-active,
.status-pill.is-paid {
    background: #dcfae6;
    color: #067647;
}

.status-pill.is-pending,
.status-pill.is-partial {
    background: #fef0c7;
    color: #b54708;
}

.status-pill.is-ended,
.status-pill.is-unpaid {
    background: #fee4e2;
    color: #b42318;
}

/* ---------- Popup dùng chung ---------- */

body.modal-open {
    overflow: hidden;
}

.modal-mask {
    overflow-y: auto;
    overscroll-behavior: contain;
}

.modal-box {
    width: min(100%, 580px);
    max-height: calc(100vh - 36px);
    overflow-y: auto;
}

.modal-box.room-modal {
    width: min(100%, 940px);
}

.modal-head {
    position: sticky;
    top: 0;
    z-index: 3;
    margin: -26px -26px 18px;
    padding: 18px 26px 14px;
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.modal-box.room-modal .modal-head {
    margin: 0;
}

.modal-actions {
    position: sticky;
    bottom: -26px;
    z-index: 2;
    background: #fff;
}

/* ---------- Đăng nhập ---------- */

body.is-guest {
    overflow: hidden;
}

.login-wrap {
    width: 100%;
    padding: 20px;
    background:
        radial-gradient(circle at 12% 18%, rgba(0, 110, 255, .16), transparent 32%),
        radial-gradient(circle at 90% 86%, rgba(8, 163, 77, .14), transparent 30%),
        linear-gradient(135deg, #eef6ff, #fff);
}

.login-card {
    width: min(100%, 430px);
    padding: clamp(24px, 4vw, 38px);
    border: 1px solid rgba(215, 225, 239, .95);
    border-radius: 24px;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 24px 70px rgba(16, 42, 67, .16);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 26px;
}

.login-brand .brand-logo {
    flex: 0 0 42px;
}

.login-brand strong {
    display: block;
    font-size: 24px;
}

.login-brand small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
}

.login-card h1 {
    margin: 0 0 6px;
    font-size: 25px;
}

.login-card > p {
    margin: 0 0 22px;
}

.login-form {
    display: grid;
    gap: 16px;
}

.login-form .btn-primary {
    width: 100%;
    margin-top: 4px;
}

/* ---------- Hồ sơ ---------- */

.profile-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
    gap: 16px;
}

.profile-summary {
    display: grid;
    gap: 13px;
}

.profile-row {
    display: grid;
    grid-template-columns: 130px minmax(0, 1fr);
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.profile-row:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.profile-row span {
    color: var(--muted);
}

/* ---------- Dashboard ---------- */

.dashboard-grid {
    min-width: 0;
}

.dash-card {
    min-width: 0;
}

.card-head {
    gap: 12px;
    flex-wrap: wrap;
}

.card-head > div:last-child {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.activity-item > div:last-child {
    min-width: 0;
    overflow-wrap: anywhere;
}

/* ---------- Hạng phòng / Phòng ---------- */

.kv-page,
.kv-layout,
.kv-content {
    min-width: 0;
}

.kv-title-row {
    flex-wrap: wrap;
}

.kv-tabs {
    max-width: 100%;
    overflow-x: auto;
}

.kv-search {
    min-width: 220px;
}

.kv-filter {
    min-width: 0;
    height: fit-content;
}

.kv-table {
    min-width: 980px;
}

.room-form-grid > *,
.room-form-grid input,
.room-form-grid select,
.room-form-grid textarea {
    min-width: 0;
}

/* ---------- Sơ đồ phòng ---------- */

.reception-page {
    min-width: 0;
    min-height: auto;
    border: 1px solid #e5e9ed;
    border-radius: 18px;
}

.rec-toolbar,
.rec-status-bar,
.rec-fast-toolbar {
    min-width: 0;
}

.rec-search-box {
    min-width: 230px;
    max-width: 100%;
}

.rec-room-grid {
    grid-template-columns:
        repeat(auto-fit, minmax(min(220px, 100%), 1fr));
}

.rec-room-card {
    min-width: 0;
}

.rec-fast-modal,
.rec-detail-modal,
.rec-checkout-modal,
.rec-customer-modal {
    overscroll-behavior: contain;
}

/* ---------- Tương thích các view cũ ---------- */

.container {
    width: min(100%, var(--page-max));
    margin-inline: auto;
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin-inline: -7px;
}

.row > * {
    width: 100%;
    min-width: 0;
    padding-inline: 7px;
}

.g-2 {
    row-gap: 14px;
}

.g-3 {
    row-gap: 18px;
}

.justify-content-center {
    justify-content: center;
}

/* ---------- Responsive ---------- */

@media (max-width: 1450px) and (min-width: 1181px) {
    .user-name {
        display: none;
    }

    .user-dropdown-toggle {
        width: 46px;
        padding-inline: 0;
    }

    .top-menu > a,
    .menu-link {
        padding-inline: 10px;
        font-size: 14px;
    }

    .dashboard-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .kpi-row,
    .bottom-card,
    .side-panel {
        grid-column: 1 / -1;
    }

    .side-panel {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 1180px) {
    body.menu-open {
        overflow: hidden;
    }

    body.menu-open::before {
        content: "";
        position: fixed;
        inset: 0;
        z-index: 48;
        background: rgba(15, 23, 42, .32);
        backdrop-filter: blur(2px);
    }

    .hotel-topbar {
        z-index: 50;
    }

    .top-menu {
        position: absolute;
        top: calc(100% + 8px);
        left: 0;
        right: 0;
        z-index: 51;
        display: none;
        max-height: calc(100vh - 108px);
        padding: 10px;
        overflow-y: auto;
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        border: 1px solid var(--line);
        border-radius: 18px;
        background: #fff;
        box-shadow: 0 22px 60px rgba(15, 23, 42, .22);
    }

    body.menu-open .top-menu {
        display: flex;
    }

    .top-menu > a,
    .menu-link {
        width: 100%;
        justify-content: space-between;
        min-height: 44px;
        padding: 11px 14px;
        font-size: 16px;
        font-weight: 700;
        line-height: 1.35;
    }

    .menu-dropdown {
        width: 100%;
    }

    .submenu {
        width: 100%;
        min-width: 0;
        margin-top: 2px;
        padding: 6px 8px;
        border-radius: 12px;
        background: #f7faff;
    }

    .submenu a {
        min-height: 42px;
        padding: 10px 14px;
        font-size: 16px;
        font-weight: 700;
        line-height: 1.35;
    }

    .menu-dropdown:hover .submenu {
        display: none;
    }

    .menu-dropdown.open .submenu {
        display: block;
    }

    .profile-grid {
        grid-template-columns: 1fr;
    }

    .field,
    .field.span-1,
    .field.span-2,
    .field.span-3,
    .field.span-4,
    .field.span-5,
    .field.span-6 {
        grid-column: span 6;
    }

    .field.span-8,
    .field.span-9,
    .field.span-10,
    .field.span-12 {
        grid-column: 1 / -1;
    }

    .kv-layout {
        grid-template-columns: 1fr;
    }

    .kv-filter {
        min-height: auto;
        padding: 14px;
        border-radius: 16px;
    }

    .kv-filter form {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 12px;
    }

    .filter-group {
        min-width: 0;
        margin-bottom: 0;
    }
}

@media (min-width: 768px) {
    .col-md-1 {
        width: 8.333333%;
    }

    .col-md-2 {
        width: 16.666667%;
    }

    .col-md-3 {
        width: 25%;
    }

    .col-md-4 {
        width: 33.333333%;
    }

    .col-md-5 {
        width: 41.666667%;
    }

    .col-md-6 {
        width: 50%;
    }

    .col-md-8 {
        width: 66.666667%;
    }
}

@media (max-width: 820px) {
    .rec-toolbar {
        align-items: stretch;
    }

    .rec-view-tabs {
        width: 100%;
        overflow-x: auto;
    }

    .rec-search-box {
        order: 2;
        width: 100%;
        flex: 1 0 100%;
    }

    .rec-price-list,
    .rec-primary-button {
        min-width: 0;
        flex: 1 1 180px;
    }

    .rec-status-bar {
        flex-wrap: nowrap;
        padding-bottom: 6px;
        overflow-x: auto;
    }

    .rec-status-filter,
    .rec-text-button {
        flex: 0 0 auto;
    }

    .rec-status-spacer {
        display: none;
    }

    .rec-fast-modal,
    .rec-detail-modal,
    .rec-checkout-modal,
    .rec-customer-modal {
        width: calc(100vw - 16px);
        max-height: calc(100dvh - 16px);
        border-radius: 12px;
    }
}

@media (max-width: 767px) {
    :root {
        --page-gutter: 8px;
    }

    .hotel-main {
        padding: 84px var(--page-gutter) 18px !important;
    }

    .hotel-topbar {
        padding-inline: 12px;
    }

    .meter-popup-mask {
        padding: 6px;
    }

    .meter-popup-dialog {
        width: calc(100vw - 12px);
        height: calc(100dvh - 12px);
        border-radius: 14px;
    }

    .meter-popup-header {
        min-height: 58px;
        padding: 9px 12px;
    }

    .meter-popup-header h2 {
        font-size: 18px;
    }

    .meter-popup-header small {
        font-size: 12px;
    }

    .meter-popup-close {
        flex-basis: 36px;
        width: 36px;
        height: 36px;
        font-size: 24px;
    }

    .top-menu {
        left: 0;
        right: 0;
        gap: 3px;
        padding: 10px;
    }

    .top-menu > a,
    .menu-link,
    .submenu a {
        font-size: 15px;
        line-height: 1.3;
    }

    .top-menu > a,
    .menu-link {
        min-height: 42px;
        padding: 10px 12px;
        border-radius: 12px;
    }

    .submenu {
        padding: 5px 7px;
    }

    .submenu a {
        min-height: 40px;
        padding: 9px 12px;
        border-radius: 10px;
    }

    .brand-logo {
        width: 34px;
        height: 34px;
    }

    .brand {
        gap: 7px;
    }

    .top-actions {
        margin-left: auto;
    }

    .user-name,
    .user-dropdown-toggle > .arrow {
        display: none;
    }

    .user-dropdown-toggle {
        width: 40px;
        min-height: 40px;
        padding: 0;
    }

    .user-dropdown-menu {
        right: -52px;
        width: calc(100vw - 24px);
    }

    .user-dropdown-menu::before {
        right: 66px;
    }

    .mobile-toggle {
        flex: 0 0 40px;
        width: 40px;
        height: 40px;
        margin-left: 0;
    }

    .page-head {
        align-items: stretch;
    }

    .page-actions,
    .toolbar-actions {
        width: 100%;
    }

    .page-actions > *,
    .toolbar-actions > * {
        flex: 1 1 auto;
    }

    .form-card,
    .card-body,
    .profile-card {
        padding: 14px;
    }

    .field,
    .field.span-1,
    .field.span-2,
    .field.span-3,
    .field.span-4,
    .field.span-5,
    .field.span-6,
    .field.span-8,
    .field.span-9,
    .field.span-10,
    .field.span-12 {
        grid-column: 1 / -1;
    }

    .rec-customer-form-grid {
        grid-template-columns: 1fr;
    }

    .table-wrap {
        border-radius: 14px;
    }

    .table-wrap table,
    .data-table {
        min-width: 820px;
    }

    .table-wrap .wide-table {
        min-width: 1420px;
    }

    .modal-mask {
        align-items: flex-end;
        padding: 8px;
    }

    .modal-box,
    .modal-box.room-modal {
        width: 100%;
        max-height: calc(100dvh - 16px);
        padding: 18px;
        border-radius: 18px;
    }

    .modal-head,
    .modal-box.room-modal .modal-head {
        margin: -18px -18px 16px;
        padding: 16px 18px 13px;
    }

    .modal-actions,
    .room-modal .modal-actions {
        bottom: -18px;
        margin: 20px -18px -18px;
        padding: 13px 18px 18px;
    }

    .profile-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .dashboard-grid,
    .kpi-row,
    .side-panel {
        grid-template-columns: 1fr;
    }

    .side-panel {
        display: flex;
    }

    .kv-title-row {
        align-items: stretch;
    }

    .kv-tabs,
    .kv-search,
    .kv-add-btn {
        width: 100%;
    }

    .kv-tabs a {
        flex: 1 0 auto;
        justify-content: center;
    }

    .kv-filter form {
        grid-template-columns: 1fr;
    }

    .reception-page {
        border-radius: 14px;
    }

    .rec-room-grid {
        grid-template-columns:
            repeat(auto-fit, minmax(min(260px, 100%), 1fr));
    }

    .rec-modal-header,
    .rec-modal-body,
    .rec-modal-footer,
    .rec-detail-footer {
        padding-inline: 14px;
    }

    .inline-payment {
        min-width: 330px;
    }
}

.quick-actions-card {
    display: grid;
    gap: 12px;
}

.quick-link-list {
    display: grid;
    gap: 8px;
}

.quick-link-list a {
    align-items: center;
    background: #f8fafc;
    border: 1px solid #e4e7ec;
    border-radius: 8px;
    color: #101828;
    display: flex;
    font-weight: 600;
    justify-content: space-between;
    padding: 10px 12px;
    text-decoration: none;
}

.quick-link-list a::after {
    color: #98a2b3;
    content: ">";
    font-weight: 700;
}

.quick-link-list a:hover {
    background: #eef4ff;
    border-color: #b2ccff;
    color: #006eff;
}

.rec-modal-backdrop.open {
    display: block !important;
}

.rec-fast-modal.open,
.rec-detail-modal.open,
.rec-checkout-modal.open,
.rec-customer-modal.open {
    display: block !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    visibility: visible !important;
}

@media (max-width: 430px) {
    .brand strong {
        font-size: 18px;
    }

    .page-actions > *,
    .toolbar-actions > * {
        width: 100%;
    }

    .rec-icon-button span {
        display: none;
    }
}

/* ---------- Đồng bộ font và làm đẹp popup ---------- */

:root {
    --font-main: "Times New Roman", Times, serif;
    --popup-radius: 10px;
    --popup-line: #d9e2ec;
    --popup-soft: #f8fafc;
    --popup-shadow: 0 24px 64px rgba(15, 23, 42, .22);
}

/* ---------- Đồng bộ font thanh menu trên ---------- */

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

.hotel-topbar,
.hotel-topbar .brand,
.hotel-topbar .top-menu,
.hotel-topbar .top-menu > a,
.hotel-topbar .menu-link,
.hotel-topbar .submenu,
.hotel-topbar .submenu a,
.hotel-topbar .top-actions,
.hotel-topbar .user-dropdown-toggle,
.hotel-topbar .user-dropdown-menu,
.hotel-topbar .user-dropdown-menu a,
.hotel-topbar .mobile-toggle {
    font-family: var(--font-main);
}

.hotel-topbar .top-menu > a,
.hotel-topbar .menu-link,
.hotel-topbar .submenu a {
    font-size: 16px;
    line-height: 1.25;
}

.hotel-topbar .brand strong {
    font-family: var(--font-main);
    font-size: 24px;
    line-height: 1;
}

@media (max-width: 1450px) and (min-width: 1181px) {
    .hotel-topbar .top-menu > a,
    .hotel-topbar .menu-link,
    .hotel-topbar .submenu a {
        font-size: 14px;
    }
}

@media (max-width: 1180px) {
    .hotel-topbar .top-menu > a,
    .hotel-topbar .menu-link,
    .hotel-topbar .submenu a {
        font-size: 16px;
        line-height: 1.25;
    }
}

@media (max-width: 430px) {
    .hotel-topbar .brand strong {
        font-size: 18px;
    }

    .hotel-topbar .top-menu > a,
    .hotel-topbar .menu-link,
    .hotel-topbar .submenu a {
        font-size: 15px;
    }
}

html,
body,
button,
input,
select,
textarea {
    font-family: var(--font-main);
}

body {
    font-size: 16px;
}

.modal-mask,
.rec-modal-backdrop {
    background: rgba(15, 23, 42, .48);
    backdrop-filter: blur(2px);
}

.modal-mask {
    padding: 18px;
}

.modal-box,
.rec-fast-modal,
.rec-detail-modal,
.rec-checkout-modal,
.rec-customer-modal {
    border: 1px solid var(--popup-line);
    border-radius: var(--popup-radius);
    background: #fff;
    box-shadow: var(--popup-shadow);
}

.modal-box {
    width: min(860px, calc(100vw - 28px));
    max-height: calc(100dvh - 28px);
    padding: 0;
}

.modal-box.small {
    width: min(480px, calc(100vw - 28px));
}

.modal-box.room-modal {
    width: min(980px, calc(100vw - 28px));
}

.modal-head,
.modal-box.room-modal .modal-head {
    min-height: 58px;
    margin: 0;
    padding: 14px 18px;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
}

.modal-head h3 {
    margin: 0;
    font-size: 21px;
    font-weight: 700;
    line-height: 1.2;
}

.modal-head button,
.rec-modal-close {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 8px;
    background: #fff;
    color: #64748b;
    line-height: 1;
}

.modal-head button:hover,
.rec-modal-close:hover {
    border-color: #dbe4ee;
    background: #f8fafc;
    color: #0f172a;
}

.modal-box > form,
.modal-box > div:not(.modal-head):not(.modal-actions) {
    padding: 18px;
}

.modal-box > form .modal-actions {
    margin: 18px -18px -18px;
}

.modal-actions,
.room-modal .modal-actions {
    bottom: 0;
    gap: 10px;
    margin: 0;
    padding: 14px 18px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
}

.modal-actions button,
.rec-modal-footer button,
.btn-primary,
.btn-secondary {
    min-height: 40px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 700;
}

.field label,
.modal-box label,
.expense-form label,
.app-form-grid label {
    font-size: 16px;
    font-weight: 700;
    color: #111827;
}

.field input,
.field select,
.field textarea,
.modal-box input,
.modal-box select,
.modal-box textarea,
.readonly-value {
    min-height: 40px;
    border-radius: 7px;
    font-size: 16px;
}

.rec-fast-modal {
    width: min(1040px, calc(100vw - 28px));
}

.rec-detail-modal {
    width: min(860px, calc(100vw - 28px));
}

.rec-checkout-modal {
    width: min(820px, calc(100vw - 28px));
}

.rec-customer-modal {
    width: min(620px, calc(100vw - 28px));
}

.rec-modal-header {
    position: sticky;
    top: 0;
    z-index: 4;
    min-height: 58px;
    padding: 0 18px;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
}

.rec-modal-header h2 {
    font-size: 21px;
    font-weight: 700;
    line-height: 1.2;
}

.rec-modal-body {
    padding: 16px 18px 14px;
}

.rec-modal-footer,
.rec-detail-footer {
    position: sticky;
    bottom: 0;
    z-index: 4;
    min-height: 62px;
    padding: 12px 18px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
}

.rec-fast-toolbar {
    grid-template-columns: minmax(330px, 1fr) 160px;
    gap: 10px;
    margin-bottom: 12px;
}

.rec-customer-search,
.rec-guest-counter {
    min-height: 42px;
    border-radius: 8px;
    background: #fff;
}

.rec-customer-search input,
.rec-guest-counter input {
    font-size: 16px;
}

.rec-guest-counter {
    display: grid;
    grid-template-columns: auto minmax(58px, 1fr);
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    border: 1px solid #d5dde7;
}

.rec-guest-label {
    color: #334155;
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
}

.rec-guest-counter input {
    min-width: 0;
    border: 0;
    background: transparent;
    font-weight: 700;
    text-align: right;
    outline: 0;
}

.rec-fast-table-header {
    min-height: 46px;
    padding: 9px 12px;
    border: 1px solid #d8f0e2;
    border-radius: 8px 8px 0 0;
    background: #eaf7ef;
}

#recFastRoomRows {
    border: 1px solid #e5e7eb;
    border-top: 0;
    border-radius: 0 0 8px 8px;
    overflow: hidden;
}

.rec-fast-room-row {
    padding: 12px;
    background: #fff;
}

.rec-fast-room-row + .rec-fast-room-row {
    border-top: 1px solid #eef2f7;
}

.rec-fast-room-row input,
.rec-fast-room-row select,
.rec-fast-note input,
.rec-extra-options input,
.rec-payment-box input,
.rec-payment-box select {
    min-height: 40px;
    border-radius: 7px;
    font-size: 16px;
}

.rec-fast-room-row input[readonly] {
    background: #f8fafc;
    color: #0f172a;
}

.rec-fast-bottom {
    align-items: start;
    gap: 16px;
    margin-top: 14px;
}

.rec-fast-note {
    min-width: 0;
}

.rec-fast-note > label {
    display: inline-block;
    margin-bottom: 7px;
    color: #111827;
    font-size: 17px;
    font-weight: 700;
}

.rec-fast-note > input {
    width: 100%;
    border: 1px solid #d5dde7;
    background: #fff;
}

.rec-extra-options {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.rec-extra-options label {
    gap: 6px;
    padding: 10px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: var(--popup-soft);
    color: #334155;
    font-size: 15px;
    font-weight: 700;
}

.rec-extra-options input {
    background: #fff;
}

.rec-payment-box {
    min-width: 250px;
    padding: 14px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: var(--popup-soft);
}

.rec-payment-row {
    min-height: 42px;
    font-size: 16px;
}

.rec-payment-row input {
    width: 120px;
    border: 1px solid #d5dde7;
    background: #fff;
    padding: 0 9px;
}

.rec-payment-method select {
    width: 100%;
    border: 1px solid #d5dde7;
    background: #fff;
    padding-inline: 10px;
}

.rec-customer-results,
.rec-selected-customer {
    border-radius: 8px;
}

@media (max-width: 900px) {
    .rec-fast-table-header,
    .rec-fast-room-row {
        grid-template-columns: 1fr 1fr;
    }

    .rec-extra-options {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 767px) {
    .modal-mask {
        align-items: flex-end;
        padding: 8px;
    }

    .modal-box,
    .modal-box.small,
    .modal-box.room-modal,
    .rec-fast-modal,
    .rec-detail-modal,
    .rec-checkout-modal,
    .rec-customer-modal {
        width: calc(100vw - 16px);
        max-height: calc(100dvh - 16px);
        border-radius: 10px;
    }

    .modal-head,
    .modal-box.room-modal .modal-head,
    .rec-modal-header {
        padding-inline: 14px;
    }

    .modal-box > form,
    .modal-box > div:not(.modal-head):not(.modal-actions),
    .rec-modal-body {
        padding: 14px;
    }

    .rec-fast-toolbar,
    .rec-fast-bottom {
        grid-template-columns: 1fr;
    }

    .rec-payment-box {
        width: 100%;
        min-width: 0;
    }

    .rec-modal-footer,
    .rec-detail-footer,
    .modal-actions,
    .room-modal .modal-actions {
        flex-wrap: wrap;
        padding-inline: 14px;
    }

    .rec-modal-footer button,
    .rec-detail-footer button,
    .modal-actions button {
        flex: 1 1 160px;
    }
}

@media (max-width: 520px) {
    .rec-fast-table-header,
    .rec-fast-room-row,
    .rec-extra-options {
        grid-template-columns: 1fr;
    }

    .rec-guest-counter {
        grid-template-columns: 1fr;
        padding-block: 8px;
    }

    .rec-guest-counter input {
        text-align: left;
    }
}

/* ---------- Nút thao tác thống nhất trong toàn bộ popup ---------- */

.modal-actions,
.room-modal .modal-actions,
.rec-modal-footer,
.rec-detail-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: nowrap;
    gap: 10px;
}

.modal-actions button,
.modal-actions .btn,
.rec-modal-footer button,
.rec-modal-footer .btn,
.rec-detail-footer button,
.rec-detail-footer .btn {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    min-width: 104px;
    min-height: 42px;
    padding: 9px 18px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-family: var(--font-main);
    font-size: 16px;
    font-weight: 700;
    line-height: 1.15;
    text-align: center;
    white-space: nowrap;
    cursor: pointer;
}

.modal-actions .btn-light,
.modal-actions .btn-secondary,
.rec-modal-footer .btn-light,
.rec-detail-footer .btn-light {
    border-color: #cbd5e1;
    background: #fff;
    color: #334155;
}

.modal-actions .btn-light:hover,
.modal-actions .btn-secondary:hover,
.rec-modal-footer .btn-light:hover,
.rec-detail-footer .btn-light:hover {
    border-color: #94a3b8;
    background: #f8fafc;
}

.modal-actions .btn-primary,
.rec-modal-footer .btn-primary,
.rec-detail-footer .btn-primary {
    border-color: #16894b;
    background: #16894b;
    color: #fff;
}

.modal-actions .btn-primary:hover,
.rec-modal-footer .btn-primary:hover,
.rec-detail-footer .btn-primary:hover {
    border-color: #11763f;
    background: #11763f;
}

.modal-actions .btn-danger {
    border-color: #dc2626;
    background: #dc2626;
    color: #fff;
}

.modal-actions .btn-danger:hover {
    border-color: #b91c1c;
    background: #b91c1c;
}

.bill-meter-note {
    grid-column: 1 / -1;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: 10px 12px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: #eff6ff;
    color: #1e3a8a;
    font-size: 15px;
    line-height: 1.45;
}

.bill-meter-note strong {
    flex: 0 0 auto;
    color: #1d4ed8;
    font-weight: 700;
}

.bill-create-modal {
    width: min(940px, calc(100vw - 28px));
}

.bill-create-form {
    align-items: end;
    gap: 16px 14px;
}

.bill-create-form > .modal-actions {
    grid-column: 1 / -1;
}

.bill-create-form .field {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 7px;
}

.bill-create-form label {
    white-space: nowrap;
}

.bill-create-form input,
.bill-create-form select,
.bill-create-form .readonly-value {
    width: 100%;
}

.tenant-modal {
    width: min(900px, calc(100vw - 28px));
}

.contract-modal {
    width: min(1040px, calc(100vw - 28px));
}

.tenant-form,
.contract-form {
    align-items: end;
    gap: 16px 14px;
}

.tenant-form > .modal-actions,
.contract-form > .modal-actions {
    grid-column: 1 / -1;
}

.tenant-form .field,
.contract-form .field {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 7px;
}

.tenant-form label,
.contract-form label {
    white-space: nowrap;
}

.tenant-form input,
.tenant-form select,
.tenant-form textarea,
.contract-form input,
.contract-form select,
.contract-form textarea {
    width: 100%;
}

.tenant-form input::placeholder,
.contract-form input::placeholder {
    color: #98a2b3;
}

.contract-new-tenant {
    grid-column: 1 / -1;
    padding: 10px 12px;
    border: 1px solid #dbeafe;
    border-radius: 10px;
    background: #f8fbff;
}

.contract-new-tenant[hidden] {
    display: none;
}

.contract-new-tenant-preview {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 34px;
    color: #334155;
    font-size: 15px;
}

.contract-new-tenant-preview strong {
    color: #1d4ed8;
    font-weight: 700;
}

.contract-new-tenant-preview button {
    margin-left: auto;
    min-height: 34px;
    padding: 6px 12px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: #fff;
    color: #1d4ed8;
    font-family: var(--font-main);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

.nested-modal {
    z-index: 1200;
    background: rgba(15, 23, 42, .58);
}

.quick-tenant-form {
    align-items: end;
    gap: 16px 14px;
}

.quick-tenant-form > .modal-actions {
    grid-column: 1 / -1;
}

.confirm-modal > form {
    padding-top: 0;
}

.confirm-message {
    margin: 0;
    padding: 18px 18px 0;
    color: #334155;
    font-size: 16px;
    line-height: 1.55;
}

.confirm-message strong {
    color: #0f172a;
    font-weight: 700;
}

.check-line {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    color: #334155;
    font-weight: 700;
}

.check-line input {
    width: auto;
    min-height: auto;
}

.rec-block-title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.rec-hide-inline-form {
    display: inline-flex;
    margin: 0;
}

.rec-hide-link {
    min-height: 30px;
    padding: 4px 10px;
    border: 1px solid #fecaca;
    border-radius: 8px;
    background: #fff;
    color: #b42318;
    font-family: var(--font-main);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.rec-hide-link:hover {
    background: #fef3f2;
}

.inline-action-form {
    display: inline-flex;
    margin: 0;
}

.rec-checkout-total-box {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 18px;
    margin: 14px 18px 0;
    padding: 14px;
    border: 1px solid #d8e2ef;
    border-radius: 10px;
    background: #f8fafc;
}

.rec-checkout-total-box div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.rec-checkout-total-box span {
    color: #475569;
}

.rec-checkout-total-box small {
    display: block;
    margin-top: 2px;
    color: #64748b;
    font-size: 13px;
    font-weight: 400;
}

.rec-checkout-total-box strong {
    color: #0f172a;
    font-weight: 700;
}

.rec-checkout-balance-row {
    grid-column: 1 / -1;
    padding-top: 10px;
    border-top: 1px solid #d8e2ef;
    font-size: 18px;
}

.rec-checkout-balance-row strong {
    color: #14864a;
}

.modal-box input[readonly],
.modal-box .readonly-value {
    border-color: #d8dee8;
    background: #f5f7fa;
    color: #475569;
    cursor: not-allowed;
}

@media (max-width: 767px) {
    .modal-actions,
    .room-modal .modal-actions,
    .rec-modal-footer,
    .rec-detail-footer {
        flex-wrap: wrap;
    }

    .modal-actions button,
    .modal-actions .btn,
    .rec-modal-footer button,
    .rec-modal-footer .btn,
    .rec-detail-footer button,
    .rec-detail-footer .btn {
        flex: 1 1 150px;
    }

    .bill-meter-note {
        display: block;
    }

    .bill-meter-note strong {
        display: inline;
    }

    .tenant-form label,
    .contract-form label {
        white-space: normal;
    }
}
.bill-pay-modal {
    width: min(760px, calc(100vw - 28px));
    max-width: 760px;
}

.bill-pay-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
/* Modal đặt trong bảng: giữ DOM hợp lệ và không tạo dòng trống. */
.modal-table-host,
.modal-table-host > td {
    height: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
}
