:root {
    --bg: #F6F8FB;
    --surface: #FFFFFF;
    --text: #0F172A;
    --muted: #64748B;
    --border: #E2E8F0;
    --primary: #1E4ED8;
    --teal: #0F9D8A;
    --warning: #F59E0B;
    --danger: #DC2626;
    --success: #16A34A;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: Inter, Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
code { background: #EFF6FF; padding: 0.1rem 0.35rem; border-radius: 0.35rem; }

.app-shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
    background: #0F172A;
    color: #E5E7EB;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.brand { display: flex; align-items: center; gap: 0.8rem; }
.brand-logo {
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 0.85rem;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #1E4ED8, #0F9D8A);
    color: #fff;
    font-weight: 700;
}
.brand-logo.large { width: 4rem; height: 4rem; font-size: 1.25rem; margin: 0 auto 0.5rem; }
.brand-title { font-weight: 700; }
.brand-subtitle { font-size: 0.8rem; color: #94A3B8; }
.nav { display: flex; flex-direction: column; gap: 0.35rem; }
.nav-link {
    padding: 0.8rem 0.95rem;
    border-radius: 0.8rem;
    color: #CBD5E1;
}
.nav-link:hover, .nav-link.active { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-footer { margin-top: auto; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(246,248,251,0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 0.75rem; }
.page { padding: 1.25rem; display: grid; gap: 1rem; }

.hotel-switcher select, .global-search input, .filter-row input, .filter-row select,
.form-grid input, .form-grid select, .form-grid textarea, .form-stack input {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 0.75rem;
    padding: 0.72rem 0.9rem;
    min-height: 2.8rem;
    width: 100%;
}
.global-search { position: relative; min-width: 280px; }
.search-results {
    position: absolute;
    top: calc(100% + 0.35rem);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 0.85rem;
    box-shadow: var(--shadow);
    overflow: hidden;
}
.search-results a {
    display: block;
    padding: 0.75rem 0.95rem;
    border-bottom: 1px solid var(--border);
}
.search-results a:hover { background: #F8FAFC; }
.search-results .tiny { color: var(--muted); }

.button {
    appearance: none;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    border-radius: 0.8rem;
    padding: 0.72rem 0.95rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 2.8rem;
}
.button:hover { filter: brightness(0.98); }
.button-small { min-height: 2.2rem; padding: 0.5rem 0.75rem; border-radius: 0.7rem; }
.button-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.button-ghost { background: transparent; }
.button-block { width: 100%; }

.sync-chip {
    border-radius: 999px;
    padding: 0.45rem 0.8rem;
    background: #E2E8F0;
    color: var(--text);
    font-size: 0.85rem;
}
.user-menu { display: flex; flex-direction: column; align-items: flex-end; }
.user-name { font-weight: 600; }
.page-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.page-header h1 { margin: 0; font-size: 1.65rem; }
.page-header p { margin: 0.35rem 0 0; }

.kpi-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(6, minmax(0, 1fr));
}
.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1rem;
    box-shadow: var(--shadow);
    padding: 1rem;
}
.kpi-label { color: var(--muted); font-size: 0.92rem; }
.kpi-value { font-size: 1.75rem; font-weight: 700; margin-top: 0.35rem; }

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1rem;
    box-shadow: var(--shadow);
    padding: 1rem;
}
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.9rem;
}
.panel-header h2 { margin: 0; font-size: 1.1rem; }

.two-col {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(340px, 0.9fr);
    gap: 1rem;
}
.stack { display: grid; gap: 1rem; }
.table-wrap { overflow: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}
.data-table th, .data-table td {
    padding: 0.8rem 0.75rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}
.data-table th { color: var(--muted); font-weight: 600; }

.badge, .status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border-radius: 999px;
    padding: 0.35rem 0.65rem;
    font-size: 0.8rem;
    white-space: nowrap;
}
.badge-direct { background: #DBEAFE; color: #1D4ED8; }
.badge-booking { background: #DBEAFE; color: #1E3A8A; }
.badge-airbnb { background: #FEE2E2; color: #B91C1C; }
.badge-phone { background: #DCFCE7; color: #166534; }
.badge-walkin { background: #E2E8F0; color: #334155; }
.badge-other { background: #F1F5F9; color: #475569; }

.status-confirmed { background: #DBEAFE; color: #1D4ED8; }
.status-checked_in { background: #DCFCE7; color: #166534; }
.status-pending, .status-hold { background: #FEF3C7; color: #92400E; }
.status-cancelled { background: #E2E8F0; color: #475569; text-decoration: line-through; }
.status-no_show { background: #FEE2E2; color: #991B1B; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
}
.form-grid label, .form-stack label { display: grid; gap: 0.35rem; }
.form-grid .full { grid-column: 1 / -1; }
.form-stack { display: grid; gap: 0.85rem; }
.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
    align-items: end;
}
.filter-row label { display: grid; gap: 0.35rem; min-width: 180px; }
.button-row { display: flex; flex-wrap: wrap; gap: 0.75rem; }

.result-card, .flash, .alert-item {
    border-radius: 0.9rem;
    padding: 0.9rem 1rem;
    border: 1px solid var(--border);
    background: #F8FAFC;
}
.flash-success { background: #ECFDF5; color: #065F46; border-color: #A7F3D0; }
.flash-error { background: #FEF2F2; color: #991B1B; border-color: #FECACA; }
.alert-list { display: grid; gap: 0.75rem; }
.alert-warning { background: #FEF3C7; border-color: #FDE68A; }
.alert-danger { background: #FEE2E2; border-color: #FECACA; }
.alert-message { font-weight: 600; }

.legend { display: flex; flex-wrap: wrap; gap: 1rem; color: var(--muted); font-size: 0.88rem; }
.legend-item { display: inline-flex; align-items: center; gap: 0.35rem; }
.legend-swatch {
    width: 1rem; height: 0.7rem; border-radius: 0.25rem; display: inline-block;
}
.legend-dot {
    width: 0.65rem; height: 0.65rem; border-radius: 999px; background: var(--teal); display: inline-block;
}
.swatch-confirmed { background: #1E4ED8; }
.swatch-inhouse { background: #16A34A; }
.swatch-hold { background: #F59E0B; }
.swatch-blocked { background: #DC2626; }

.calendar-panel { overflow: auto; }
.calendar-shell { min-width: 1100px; }
.calendar-header-row, .calendar-row {
    display: grid;
    grid-template-columns: 220px minmax(900px, 1fr);
    align-items: stretch;
}
.calendar-room-header, .room-label {
    position: sticky;
    left: 0;
    z-index: 8;
    background: var(--surface);
    border-right: 1px solid var(--border);
}
.calendar-room-header {
    padding: 0.85rem;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
}
.room-label {
    padding: 0.8rem;
    border-bottom: 1px solid var(--border);
    display: grid;
    gap: 0.15rem;
}
.room-label .room-number { font-weight: 700; }
.room-label .room-meta { color: var(--muted); font-size: 0.82rem; }

.calendar-days, .calendar-track {
    display: grid;
    position: relative;
}
.calendar-days {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.day-head, .calendar-cell {
    min-width: 84px;
    border-right: 1px solid var(--border);
}
.day-head {
    padding: 0.7rem 0.35rem;
    text-align: center;
    font-size: 0.82rem;
    color: var(--muted);
    background: #F8FAFC;
}
.calendar-track { min-height: 76px; background: linear-gradient(180deg, rgba(255,255,255,1), rgba(248,250,252,1)); }
.calendar-cell {
    min-height: 76px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.calendar-cell:hover { background: rgba(30, 78, 216, 0.03); }

.booking-block, .mark-pill {
    border: none;
    border-radius: 0.75rem;
    padding: 0.4rem 0.55rem;
    margin: 0.32rem 0.18rem;
    cursor: pointer;
    text-align: left;
    overflow: hidden;
    z-index: 4;
}
.booking-block {
    color: #fff;
    align-self: start;
    min-height: 2.4rem;
    box-shadow: 0 8px 20px rgba(30, 78, 216, 0.18);
}
.booking-block .booking-main {
    display: flex;
    justify-content: space-between;
    gap: 0.6rem;
    font-size: 0.82rem;
    font-weight: 600;
}
.booking-block .booking-sub {
    display: flex;
    gap: 0.5rem;
    opacity: 0.92;
    font-size: 0.74rem;
    margin-top: 0.12rem;
}
.booking-confirmed { background: #1E4ED8; }
.booking-checked_in { background: #16A34A; }
.booking-pending, .booking-hold { background: #F59E0B; }
.booking-cancelled { background: #94A3B8; text-decoration: line-through; }
.booking-other { background: #475569; }

.mark-pill {
    align-self: end;
    background: rgba(15, 157, 138, 0.12);
    color: #0F766E;
    border: 1px solid rgba(15, 157, 138, 0.2);
    font-size: 0.72rem;
    min-height: 1.6rem;
}
.calendar-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--muted);
}

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: min(520px, 95vw);
    height: 100vh;
    background: #fff;
    border-left: 1px solid var(--border);
    box-shadow: -10px 0 30px rgba(15, 23, 42, 0.12);
    z-index: 60;
    display: flex;
    flex-direction: column;
}
.drawer.hidden { display: none; }
.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.1rem;
    border-bottom: 1px solid var(--border);
}
.drawer-body {
    padding: 1rem 1.1rem 1.25rem;
    overflow: auto;
    display: grid;
    gap: 1rem;
}
.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}
.detail-card {
    background: #F8FAFC;
    border: 1px solid var(--border);
    border-radius: 0.9rem;
    padding: 0.9rem;
}
.detail-card .label {
    color: var(--muted);
    font-size: 0.78rem;
    margin-bottom: 0.2rem;
}
.detail-card .value {
    font-weight: 600;
}
.drawer section {
    display: grid;
    gap: 0.75rem;
}

.login-card {
    width: min(420px, calc(100vw - 2rem));
    margin: 8vh auto;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 1.2rem;
    box-shadow: var(--shadow);
    padding: 1.5rem;
}
.login-header { text-align: center; margin-bottom: 1rem; }
.login-header h1 { margin: 0.3rem 0 0.2rem; }
.login-footer {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.92rem;
}
.blank-layout { background: radial-gradient(circle at top, #E0ECFF, #F6F8FB 45%); }

.toast {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    background: #0F172A;
    color: #fff;
    padding: 0.9rem 1rem;
    border-radius: 0.85rem;
    box-shadow: var(--shadow);
    z-index: 70;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.tiny { font-size: 0.78rem; }

@media (max-width: 1200px) {
    .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 980px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .topbar { flex-direction: column; align-items: stretch; }
    .topbar-left, .topbar-right { width: 100%; justify-content: space-between; }
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .calendar-header-row, .calendar-row {
        grid-template-columns: 180px minmax(720px, 1fr);
    }
    .day-head, .calendar-cell { min-width: 76px; }
}

@media (max-width: 640px) {
    .page { padding: 0.75rem; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .global-search { min-width: 0; flex: 1; }
}
