/* CSS Variables */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #3b82f6;

    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-color: #1e293b;
    --text-muted: #64748b;

    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

/* Dark theme — used on cleaning pages */
body.theme-dark {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --border-color: #334155;
    --text-color: #e2e8f0;
    --text-muted: #94a3b8;
    --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -2px rgba(0,0,0,0.2);
}

body.theme-dark .navbar {
    background: #1e293b;
    border-bottom-color: #334155;
}

body.theme-dark .nav-links a {
    color: #94a3b8;
}

body.theme-dark .nav-links a:hover,
body.theme-dark .nav-links a.active {
    background: #0f172a;
    color: #e2e8f0;
}

body.theme-dark .nav-brand a {
    color: #e2e8f0;
}

body.theme-dark .nav-brand .logo-dark { display: none; }
body.theme-dark .nav-brand .logo-white { display: block; }
.nav-brand .logo-dark { display: block; }
.nav-brand .logo-white { display: none; }

body.theme-dark #lang-btn {
    background: #1e293b !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}

body.theme-dark #lang-dropdown {
    background: #1e293b !important;
    border-color: #334155 !important;
    box-shadow: 0 4px 8px rgba(0,0,0,0.4) !important;
}

body.theme-dark #lang-dropdown a {
    color: #e2e8f0 !important;
}

body.theme-dark #lang-dropdown a:hover {
    background: #0f172a !important;
}

body.theme-dark .footer {
    background: #1e293b;
    border-top-color: #334155;
    color: #94a3b8;
}

body.theme-dark .flash-messages .flash {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

body.theme-dark select,
body.theme-dark input[type="text"],
body.theme-dark input[type="email"],
body.theme-dark input[type="date"],
body.theme-dark textarea {
    background: #0f172a;
    color: #e2e8f0;
    border-color: #334155;
}

body.theme-dark select option {
    background: #1e293b;
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navbar */
.navbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    height: 64px;
    gap: 2rem;
    flex-wrap: nowrap;
    position: relative;
}

/* Hamburger button — hidden on desktop */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    background: none;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    padding: 5px;
    margin-left: auto;
    flex-shrink: 0;
}
.nav-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text-color);
    border-radius: 2px;
    transition: all 0.2s;
}

.nav-brand a {
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 700;
    font-size: 1.45rem;
    color: #333331;
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 0.5rem;
    flex: 1;
}

.nav-links a {
    padding: 0.5rem 0.85rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius);
    transition: all 0.2s;
    font-weight: 600;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--primary-color);
    background: #eff6ff;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-muted);
}


/* Container */
.container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    flex: 1;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

.btn-outline:hover {
    background: var(--bg-color);
}

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-block {
    width: 100%;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--card-bg);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.form-error {
    color: var(--danger-color);
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table tbody tr:hover {
    background: var(--bg-color);
}

/* Hide less important reservation columns on medium screens (not mobile — mobile uses stacked cards) */
@media (max-width: 960px) and (min-width: 641px) {
    .col-hide-md { display: none; }
}

/* Hide View/Edit table actions below hamburger breakpoint */
@media (max-width: 1100px) {
    .table-action-hide { display: none !important; }
    .copy-link-btn { width: 100%; text-align: center; }
}

/* Responsive tables — stack as cards on small screens */
@media (max-width: 640px) {
    .table thead { display: none; }
    .table,
    .table tbody,
    .table tbody tr,
    .table tbody td { display: block; width: 100%; box-sizing: border-box; }
    .table tbody tr {
        border: 1px solid var(--border-color);
        border-radius: var(--radius);
        margin-bottom: 1.5rem;
        padding: 0.25rem 0;
        background: var(--bg-color);
        box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    }
    .table tbody tr:hover { background: var(--bg-color); }
    .table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0.75rem;
        border-bottom: 1px solid var(--border-color);
        text-align: right;
        white-space: normal;
        gap: 0.5rem;
    }
    .table tbody td:last-child { border-bottom: none; }
    .table tbody td[data-label]::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        font-size: 0.72rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        flex-shrink: 0;
        text-align: left;
    }
    .table tbody td[data-label=""] { justify-content: flex-end; }

    /* Prevent container from creating a wide scrollable table on mobile */
    .table-container { overflow-x: visible; }

    /* Hide View/Edit — row tap navigates */
    .table-action-hide { display: none !important; }
    /* Full-width Copy Link */
    .copy-link-btn { width: 100%; text-align: center; }

    /* ── Properties table: clean card layout ── */
    .properties-table tbody tr {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 0.2rem 0.75rem;
        padding: 1rem;
        margin-bottom: 1rem;
        background: var(--card-bg);
        min-height: 7.5rem;
        align-items: center;
    }
    .properties-table tbody td {
        display: block;
        padding: 0;
        border: none;
        font-size: 0.875rem;
        color: var(--text-muted);
        text-align: left;
        min-height: 1.3em;
    }
    .properties-table tbody td::before { display: none !important; }
    .properties-table .prop-td-name {
        grid-column: 1; grid-row: 1;
        font-size: 1.05rem;
        font-weight: 700;
        color: var(--text-color);
        min-height: auto;
    }
    .properties-table .prop-td-name a { color: var(--text-color); text-decoration: none; }
    .properties-table .prop-td-location { grid-column: 1; grid-row: 2; }
    .properties-table .prop-td-times    { grid-column: 1; grid-row: 3; }
    .properties-table .prop-td-res      { grid-column: 1; grid-row: 4; }
    .properties-table .prop-td-actions  { display: none; }
    .properties-table tbody td.drag-handle { display: none; }
    .properties-table .prop-td-star {
        grid-column: 2;
        grid-row: 1 / 5;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        border: none;
        min-height: auto;
    }
}

/* Status badges */
.badge {
    display: inline-flex;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
}

.badge-pending {
    background: #fef3c7;
    color: #92400e;
}

.badge-confirmed {
    background: #dbeafe;
    color: #1e40af;
}

.badge-checked_in {
    background: #dcfce7;
    color: #166534;
}

.badge-completed {
    background: #e0e7ff;
    color: #3730a3;
}

.badge-pending_review {
    background: #ffedd5;
    color: #9a3412;
}

.badge-cancelled {
    background: #fee2e2;
    color: #991b1b;
}

.badge-completed {
    background: #f0fdf4;
    color: #166534;
}

.badge-blocked {
    background: #f3f4f6;
    color: #6b7280;
}

.badge-booking_request {
    background: #ede9fe;
    color: #5b21b6;
}
.badge-overbooking {
    background: #fee2e2;
    color: #991b1b;
}

/* Payment status badges */
.badge-payment-unavailable  { background: #e2e8f0; color: #64748b; }
.badge-payment-lack         { background: rgba(220,67,50,0.15);  color: #dc4332; border: 1px solid rgba(220,67,50,0.35); }
.badge-payment-down_payment { background: rgba(217,154,43,0.18); color: #b45309; border: 1px solid rgba(217,154,43,0.4); }
.badge-payment-fully_paid   { background: rgba(21,160,90,0.15);  color: #15803d; border: 1px solid rgba(21,160,90,0.35); }

/* Payment warning banner */
.payment-warning-banner {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: #fffbeb;
    color: #92400e;
    border-bottom: 1px solid #fcd34d;
    padding: 0.7rem 1.25rem;
    font-size: 0.88rem;
    font-weight: 500;
    position: sticky;
    top: 0;
    /* Below the navbar dropdowns (500–600) but above page content */
    z-index: 400;
}
body.theme-dark .payment-warning-banner {
    background: #451a03;
    color: #fcd34d;
    border-bottom-color: #78350f;
}

/* Flash messages */
.flash-messages {
    margin-bottom: 1.5rem;
}

.flash {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flash-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.flash-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.flash-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.flash-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.flash-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    opacity: 0.7;
}

.flash-close:hover {
    opacity: 1;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}
@media (max-width: 640px) {
    .stats-grid { display: none; }
}

/* Today's Activity rows */
.activity-row  { display: flex; align-items: center; gap: 0.75rem; }
.activity-name { flex: 1; }
.activity-prop { font-size: 0.875rem; color: var(--text-muted); }
@media (max-width: 640px) {
    /* Wrap into two lines: [name][source] / [property][status] */
    .activity-row         { flex-wrap: wrap; overflow: hidden; gap: 0.3rem 0.5rem; }
    .activity-row::after  { content: ''; width: 100%; order: 3; height: 0; } /* line break */
    .activity-name { order: 1; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .activity-src  { order: 2; flex-shrink: 0; }
    .activity-prop { order: 4; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.8rem; }
    .activity-sts  { order: 5; flex-shrink: 0; }
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-color);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}

.empty-state h3 {
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

/* Footer */
.footer {
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    border-top: 1px solid var(--border-color);
}
.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    text-align: center;
}

/* Utilities */
.text-muted {
    color: var(--text-muted);
}

.text-small {
    font-size: 0.875rem;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 3rem; }
.mb-3 { margin-bottom: 1.5rem; }

.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* Detail list */
.detail-list {
    display: grid;
    gap: 1rem;
}

.detail-item {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 1rem;
}

.detail-label {
    font-weight: 500;
    color: var(--text-muted);
}

/* Actions */
.actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ===== Property Calendar ===== */
.cpm-yr-btn {
    width: 32px; height: 32px; border-radius: 50%;
    border: 1px solid #e2e8f0; background: #fff; color: #374151;
    font-size: 1.1rem; font-weight: 700; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.1s, border-color 0.1s;
}
.cpm-yr-btn:hover { background: #eff6ff; border-color: #2563eb; color: #2563eb; }

/* Date range / modal calendar picker */
.dr-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dr-dow { text-align:center; font-size:0.7rem; font-weight:700; color:#94a3b8; padding:0.2rem 0; }
.dr-day {
    height: 34px; border: 2px solid transparent; border-radius: 50%;
    background: transparent; cursor: pointer;
    font-size: 0.82rem; font-weight: 400; color: #374151;
    transition: background 0.1s, color 0.1s;
    width: 100%;
}
.dr-day:hover { background: #eff6ff; color: #2563eb; }
.dr-day.is-start, .dr-day.is-end { background: #2563eb !important; color: #fff !important; font-weight: 700; border-color: #2563eb; border-radius: 50%; }
.dr-day.in-range { background: #dbeafe; color: #1d4ed8; border-radius: 0; border-color: transparent; }
.dr-day.hover-range { background: #eff6ff; color: #2563eb; border-radius: 0; }
.dr-day.hover-end { background: #bfdbfe; color: #1d4ed8; border-radius: 50%; }
.dr-day.is-today:not(.is-start):not(.is-end) { border-color: #2563eb; color: #2563eb; font-weight: 600; }
.dr-day.other-month { color: #cbd5e1; }
.dr-day.other-month:hover { background: #f8fafc; color: #94a3b8; }
.dr-day.is-booked { opacity: 0.3; text-decoration: line-through; }
.dr-day.is-booked:hover { background: transparent; }
.dr-chip {
    font-size: 0.78rem; font-weight: 600; padding: 0.2rem 0.65rem;
    border-radius: 999px; border: 1px solid #e2e8f0;
    background: #f8fafc; color: #374151; cursor: pointer;
    transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.dr-chip:hover { background: #eff6ff; border-color: #2563eb; color: #2563eb; }

.cal-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.cal-legend {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    flex-wrap: wrap;
}

.cal-legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.cal-dow-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px 8px 0 0;
}

#cal-weeks {
    border: 1px solid #e2e8f0;
    border-top: none;
    border-radius: 0 0 8px 8px;
    overflow: hidden;
}

.cal-dow {
    text-align: center;
    font-size: 0.64rem;
    font-weight: 700;
    color: #94a3b8;
    padding: 0.4rem 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-right: 1px solid #e2e8f0;
}
.cal-dow:last-child { border-right: none; }
.cal-dow:nth-child(6),
.cal-dow:nth-child(7) {
    color: #cbd5e1;
}

.cal-week-row {
    position: relative;
    border-bottom: 1px solid #e2e8f0;
    min-width: 0;
    background-image: repeating-linear-gradient(
        90deg,
        transparent 0,
        transparent calc(100% / 7 - 1px),
        #e2e8f0 calc(100% / 7 - 1px),
        #e2e8f0 calc(100% / 7)
    );
}
.cal-week-row:last-child { border-bottom: none; }
.cal-week-row.has-today::before {
    content: '';
    position: absolute;
    top: 0; bottom: 0;
    left: calc(var(--today-col) / 7 * 100%);
    width: calc(100% / 7);
    background: rgba(219, 234, 254, 0.4);
    pointer-events: none;
    z-index: 0;
}

.cal-day-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.cal-day-num {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    position: relative;
}
.cal-day-num:not(.cal-day-outside):hover .wv-add-btn { opacity: 1; }

.cal-day-circle {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.82rem;
    font-weight: 600;
    color: #374151;
}

.cal-today-circle {
    background: var(--primary-color, #2563eb);
    color: #fff;
}

.cal-day-outside {
    opacity: 0.35;
}

.cal-bar-layer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.cal-res-bar {
    position: absolute;
    pointer-events: auto;
    border-radius: 5px;
    padding: 0 4px;
    white-space: nowrap;
    overflow: hidden;
    text-decoration: none;
    transition: filter 0.15s, transform 0.15s;
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    box-sizing: border-box;
    line-height: 1.2;
}
.cal-day-weekend:not(.cal-day-outside) {
    background: rgba(0,0,0,0.018);
}
@media (hover: hover) {
    .cal-res-bar:hover {
        filter: brightness(1.18) drop-shadow(0 2px 6px rgba(0,0,0,0.35));
        transform: translateY(-1px);
        z-index: 2;
    }
}

/* ── Weekly view bar (two-line tinted) ──────────────────────────────── */
/* ── Weekly calendar header (responsive) ── */
.wv-cal-hdr {
    display: grid;
    grid-template-areas: "title actions" "nav nav";
    grid-template-columns: 1fr auto;
    padding: 1rem 1.25rem 0.75rem;
    row-gap: 0.4rem;
    column-gap: 0.5rem;
    align-items: center;
}
.wv-cal-hdr-title  { grid-area: title; margin: 0; }
.wv-cal-hdr-nav    { grid-area: nav; display: flex; flex-direction: column; align-items: center; gap: 0.2rem; }
.wv-cal-hdr-actions{ grid-area: actions; display: flex; align-items: center; gap: 0.75rem; }
.wv-today-desktop  { display: none !important; }
@media (min-width: 641px) {
    .wv-cal-hdr {
        grid-template-areas: "title nav actions";
        grid-template-columns: auto 1fr auto;
        row-gap: 0;
    }
    .wv-today-desktop { display: inline-flex !important; align-items: center; gap: 0.3rem; }
    .wv-today-nav     { display: none !important; }
}

.wv-bar {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    align-self: start;
    width: 100%;
    box-sizing: border-box;
    line-height: 1.2;
    transition: filter 0.15s, transform 0.15s;
}
@media (hover: hover) {
    .wv-bar:hover {
        filter: brightness(1.18) drop-shadow(0 2px 6px rgba(0,0,0,0.35));
        transform: translateY(-2px);
        z-index: 2;
    }
}
.bar-guest  { font-size: 12px; font-weight: 700; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-source { font-size: 10px; font-weight: 500; opacity: 0.7; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 640px) {
    .wv-sync-icon { width: 22px !important; height: 22px !important; }
}

/* ── Weekly view legend ─────────────────────────────────────────────── */
.wv-legend { display: flex; align-items: center; gap: 1rem; padding: 0.6rem 1rem; flex-wrap: wrap; border-top: 1px solid #e2e8f0; }
.wv-legend-group { display: flex; gap: 1.25rem; flex-wrap: wrap; align-items: center; transition: opacity 0.2s; }
/* Default: booking active, payment dimmed */
.wv-legend-group--payment { opacity: 0.3; pointer-events: none; }
/* Payment mode: flip opacities */
.wv-legend--payment .wv-legend-group--booking { opacity: 0.3; pointer-events: none; }
.wv-legend--payment .wv-legend-group--payment { opacity: 1; pointer-events: auto; }
.wv-legend-title { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: #94a3b8; margin-right: 0.15rem; }
.wv-legend-item { display: flex; align-items: center; gap: 0.4rem; font-size: 0.75rem; font-weight: 600; color: #374151; }
.wv-swatch { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; }
/* Toggle switch */
.wv-legend-toggle { display: flex; align-items: center; cursor: pointer; flex-shrink: 0; padding: 0 0.25rem; }
.wv-toggle-track { width: 32px; height: 18px; border-radius: 9px; background: #cbd5e1; position: relative; transition: background 0.2s; flex-shrink: 0; }
.wv-toggle-thumb { position: absolute; width: 14px; height: 14px; border-radius: 50%; background: #fff; top: 2px; left: 2px; transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.25); }
.wv-legend--payment .wv-toggle-track { background: #6366f1; }
.wv-legend--payment .wv-toggle-thumb { transform: translateX(14px); }

/* ── Calendar view toggle (Monthly / Weekly buttons) ─────────────────── */
.cal-view-toggle {
    display: flex;
    gap: 3px;
    background: #f1f5f9;
    border-radius: 9px;
    padding: 3px;
}
.cal-view-btn {
    padding: 0.28rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 500;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    background: transparent;
    color: #64748b;
    transition: background 0.12s, color 0.12s;
}
.cal-view-btn:hover { color: #374151; }
.cal-view-btn.cal-view-active {
    background: #fff;
    color: #2563eb;
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(0,0,0,0.10);
}

/* ── Weekly view ──────────────────────────────────────────────────────── */
.wv-header-row,
.wv-prop-row {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid #e2e8f0;
}
.wv-header-row {
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 8px 8px 0 0;
}
.wv-prop-label {
    width: 180px;
    min-width: 180px;
    max-width: 180px;
    padding: 0.5rem 0.75rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: #374151;
    white-space: normal;
    word-break: break-word;
    display: flex;
    align-items: center;
    border-right: 1px solid #e2e8f0;
    box-sizing: border-box;
    position: sticky;
    left: 0;
    z-index: 3;
}
.wv-header-row .wv-prop-label { background: #f8fafc; }
.wv-prop-row   .wv-prop-label { background: #fff; box-shadow: 2px 0 4px rgba(0,0,0,0.06); }
.wv-days-header {
    display: flex;
    flex-shrink: 0;
}
.wv-day-header-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.4rem 0;
    border-right: 1px solid #e2e8f0;
    gap: 2px;
}
.wv-day-header-cell:last-child { border-right: none; }
.wv-weekend-header { background: rgba(0,0,0,0.02); }
.wv-dow {
    font-size: 0.64rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.wv-date-num {
    font-size: 0.82rem;
    font-weight: 600;
    color: #374151;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}
.wv-today-circle {
    background: #2563eb;
    color: #fff;
}
.wv-prop-row:last-child { border-bottom: none; }
.wv-days-area {
    flex-shrink: 0;
    position: relative;
}
.wv-day-bg {
    position: absolute;
    inset: 0;
    display: flex;
    flex-wrap: nowrap;
    pointer-events: none;
}
.wv-bg-cell {
    border-right: 1px solid #f1f5f9;
    position: relative;
    pointer-events: auto;
}
.wv-bg-cell:last-child { border-right: none; }
.wv-bg-cell.wv-bg-today    { background: rgba(37,99,235,0.06); }
.wv-bg-cell.wv-bg-weekend:not(.wv-bg-today) { background: rgba(0,0,0,0.02); }
.wv-add-btn {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--primary-color, #2563eb);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 17px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 5;
    padding: 0;
}
.wv-bg-cell:hover .wv-add-btn { opacity: 1; }

/* Weekly view horizontal scroll container */
.wv-scroll-outer {
    overflow-x: scroll;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    cursor: grab;
}
.wv-scroll-outer::-webkit-scrollbar { display: none; }
.wv-scroll-outer:active { cursor: grabbing; }
#wv-card:fullscreen,
#wv-card:-webkit-full-screen {
    background: var(--card-bg, #fff);
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    border-radius: 0;
}
#wv-card:fullscreen .wv-scroll-outer,
#wv-card:-webkit-full-screen .wv-scroll-outer {
    flex: 1;
    overflow: auto;
}
/* CSS fake-fullscreen — used on iOS and when requestFullscreen is unavailable */
.wv-fake-fs {
    position: fixed !important;
    inset: 0 !important;
    z-index: 9999 !important;
    margin: 0 !important;
    border-radius: 0 !important;
    background: var(--card-bg, #fff);
    display: flex !important;
    flex-direction: column;
    overflow-y: auto;
}
.wv-fake-fs .wv-scroll-outer { flex: 1; overflow-x: scroll; overflow-y: auto; }
.wv-body-fs { overflow: hidden; }
/* min-width removed — day widths are now set explicitly in JS */

/* Responsive */
/* Mobile menu collapse container — hidden on desktop */
.nav-collapse {
    display: flex;
    align-items: center;
    gap: 2rem;
    flex: 1;
    min-width: 0;
}

/* Medium screens: compact nav items to prevent overflow */
@media (max-width: 1400px) and (min-width: 1101px) {
    .navbar { gap: 0.75rem; padding: 0 1rem; }
    .nav-collapse { gap: 0.75rem; }
    .nav-links a { padding: 0.4rem 0.45rem; font-size: 0.8rem; }
}

@media (max-width: 1100px) {
    /* Navbar: single row with brand + hamburger */
    .navbar {
        height: auto;
        padding: 0.75rem 1rem;
        gap: 0;
        align-items: center;
        flex-wrap: nowrap;
    }

    .nav-brand {
        flex: 1;
    }

    .nav-toggle {
        display: flex;
    }

    /* Collapse container hidden by default, drops below navbar when open */
    .nav-collapse {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        background: var(--card-bg);
        border-bottom: 1px solid var(--border-color);
        box-shadow: 0 4px 12px rgba(0,0,0,0.08);
        padding: 0.5rem 1rem 1rem;
        z-index: 200;
        gap: 0;
    }

    .navbar.open .nav-collapse {
        display: flex;
    }

    .nav-links {
        flex-direction: column;
        gap: 0.1rem;
    }

    .nav-links a {
        padding: 0.65rem 0.75rem;
    }

    .nav-user {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: center;
        padding-top: 0.75rem;
        margin-top: 0.25rem;
        border-top: 1px solid var(--border-color);
        gap: 0.5rem;
    }

    /* General layout */
    .page-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .detail-item {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }

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

}

/* Drag-to-reorder */
.drag-handle { opacity: 0.35; transition: opacity 0.15s; }
.drag-handle:hover { opacity: 0.75; }
tr:hover .drag-handle { opacity: 0.6; }
.sortable-ghost { opacity: 0.4; background: var(--bg-color, #f1f5f9) !important; }
@media (max-width: 1024px) { .drag-handle { display: none; } }

/* Star / prioritize button */
.star-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    color: #cbd5e1;
    display: inline-flex;
    align-items: center;
    transition: color 0.15s;
}
.star-btn svg { fill: none; stroke: currentColor; }
.star-btn:hover { color: #f59e0b; }
.star-btn.starred { color: #f59e0b; }
.star-btn.starred svg { fill: currentColor; }

/* Tab bar */
.tab-bar {
    display: flex;
    gap: 0.25rem;
    background: #f1f3f9;
    border-radius: 12px;
    padding: 5px;
    width: fit-content;
    max-width: 100%;
    flex-wrap: wrap;
    margin-bottom: 1.75rem;
}
.tab-btn {
    padding: 0.55rem 1.4rem;
    border: none;
    border-radius: 9px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #64748b;
    background: none;
    cursor: pointer;
    transition: all 0.18s;
    font-family: inherit;
}
.tab-btn.active {
    background: #fff;
    color: #0f172a;
    box-shadow: 0 1px 6px rgba(0,0,0,0.1);
}
.tab-btn:not(.active):hover { color: #1e293b; }
.tab-panel { display: none; max-width: 100%; }
.tab-panel.active { display: block; }

@media (max-width: 600px) {
    .tab-btn { padding: 0.5rem 0.9rem; font-size: 0.82rem; }

    .cal-dow {
        font-size: 0.6rem;
        letter-spacing: 0;
    }

    .cal-res-bar {
        font-size: 0.6rem;
    }

    .cal-legend {
        font-size: 0.7rem;
    }

    /* Weekly view on mobile: shrink property label, make it sticky */
    .wv-prop-label {
        width: 90px;
        min-width: 90px;
        max-width: 90px;
        font-size: 0.72rem;
        position: sticky;
        left: 0;
        z-index: 3;
    }
    .wv-header-row .wv-prop-label {
        background: #f8fafc;
    }
    .wv-prop-row .wv-prop-label {
        background: #fff;
        box-shadow: 2px 0 4px rgba(0,0,0,0.06);
    }
    #wv-week-label {
        min-width: 0 !important;
        font-size: 0.85rem !important;
    }
    .wv-dow {
        font-size: 0.64rem;
        letter-spacing: 0;
    }
    .wv-date-num {
        font-size: 0.85rem;
        width: 24px;
        height: 24px;
    }
    .wv-day-header-cell {
        border-right: 2px solid #e2e8f0;
    }
    .wv-prop-row {
        border-bottom: 2px solid #e2e8f0;
    }
    .wv-bg-cell {
        border-right: 2px solid #f1f5f9;
    }
}

/* ── Floating Chat Assistant ────────────────────────────────────────────────── */

#chat-bubble {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    height: 36px;
    padding: 0 1.4rem;
    gap: 0.35rem;
    border-radius: 24px;
    background: #fff;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(37,99,235,0.18);
    z-index: 9999;
    transition: background 0.2s, transform 0.15s;
}
#chat-bubble:hover { transform: translateX(-50%) scale(1.08); box-shadow: 0 6px 24px rgba(37,99,235,0.28); }

#chat-panel {
    position: fixed;
    bottom: 5rem;
    right: 1.5rem;
    width: 360px;
    max-width: calc(100vw - 2rem);
    height: 520px;
    max-height: calc(100vh - 7rem);
    background: #fff;
    border: 2px solid var(--primary-color);
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(37,99,235,0.18);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.95) translateY(10px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.18s ease, opacity 0.18s ease;
}
#chat-panel.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

#chat-header {
    padding: 0.875rem 1rem;
    background: #fff;
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
#chat-header span { font-weight: 600; font-size: 0.9rem; }
#chat-close {
    background: none; border: none; color: var(--primary-color);
    cursor: pointer; font-size: 1.3rem; line-height: 1;
    opacity: 0.7; padding: 0 0.2rem;
}
#chat-close:hover { opacity: 1; }

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.875rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    scroll-behavior: smooth;
}

.chat-msg {
    max-width: 84%;
    padding: 0.55rem 0.875rem;
    border-radius: 12px;
    font-size: 0.875rem;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
}
.chat-msg.user {
    align-self: flex-end;
    background: var(--primary-color);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-msg.assistant {
    align-self: flex-start;
    background: #f1f5f9;
    color: var(--text-color);
    border-bottom-left-radius: 4px;
}
.chat-msg.assistant.error { background: #fee2e2; color: #b91c1c; }

.chat-typing {
    align-self: flex-start;
    background: #f1f5f9;
    border-radius: 12px;
    padding: 0.55rem 0.875rem;
    display: flex;
    gap: 4px;
    align-items: center;
}
.chat-typing span {
    width: 6px; height: 6px;
    background: #94a3b8; border-radius: 50%;
    animation: chat-bounce 1.2s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chat-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%           { transform: translateY(-5px); }
}

#chat-confirm-bar {
    padding: 0.5rem 1rem;
    background: #fffbeb;
    border-top: 1px solid #fde68a;
    display: none;
    gap: 0.5rem;
    flex-shrink: 0;
}
#chat-confirm-bar.visible { display: flex; }
#chat-confirm-yes, #chat-confirm-no {
    flex: 1; padding: 0.45rem 0;
    border-radius: 7px; border: none;
    font-size: 0.82rem; font-weight: 600;
    cursor: pointer; font-family: inherit;
}
#chat-confirm-yes { background: #22c55e; color: #fff; }
#chat-confirm-yes:hover { background: #16a34a; }
#chat-confirm-no  { background: #e2e8f0; color: #475569; }
#chat-confirm-no:hover  { background: #cbd5e1; }

#chat-input-row {
    display: flex; gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}
#chat-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    overflow-y: auto;
    line-height: 1.4;
}
#chat-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
#chat-send {
    background: var(--primary-color); color: #fff;
    border: none; border-radius: 8px;
    padding: 0 0.9rem; font-size: 0.875rem;
    font-weight: 600; cursor: pointer;
    font-family: inherit; flex-shrink: 0;
    transition: background 0.15s;
}
#chat-send:hover    { background: var(--primary-hover); }
#chat-send:disabled { opacity: 0.6; cursor: default; }

#chat-unread-badge {
    position: absolute; top: -4px; right: -4px;
    width: 14px; height: 14px;
    background: #ef4444; border-radius: 50%;
    border: 2px solid #fff; display: none;
}

@media (max-width: 480px) {
    #chat-panel {
        right: 0.75rem;
        width: calc(100vw - 1.5rem);
        bottom: 4.5rem;
    }
    #chat-bubble { bottom: 1rem; right: 1rem; }
    /* Prevent iOS auto-zoom on focus (requires font-size >= 16px) */
    #chat-input, #dc-input { font-size: 16px; }
}

/* ── Chat widget — dark theme overrides (cleaning page etc.) ───────────────── */
body.theme-dark #chat-bubble {
    background: #1e293b;
    color: #e2e8f0;
    border-color: #334155;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
body.theme-dark #chat-bubble:hover {
    background: #334155;
    box-shadow: 0 6px 24px rgba(0,0,0,0.5);
}
body.theme-dark #chat-bubble img,
body.theme-dark #chat-header img { filter: brightness(0) invert(1); }
body.theme-dark #chat-panel {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
body.theme-dark #chat-header {
    background: #1e293b;
    color: #e2e8f0;
    border-bottom-color: #334155;
}
body.theme-dark #chat-close { color: #94a3b8; }
body.theme-dark #chat-close:hover { color: #e2e8f0; }
body.theme-dark #chat-messages { background: #1e293b; }
body.theme-dark .chat-msg.assistant {
    background: #0f172a;
    color: #e2e8f0;
}
body.theme-dark .chat-typing { background: #0f172a; }
body.theme-dark .chat-typing span { background: #475569; }
body.theme-dark #chat-input-row { border-top-color: #334155; background: #1e293b; }
body.theme-dark #chat-input {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}
body.theme-dark #chat-input::placeholder { color: #64748b; }
body.theme-dark #chat-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
body.theme-dark #chat-confirm-bar {
    background: #162032;
    border-top-color: #334155;
}
body.theme-dark #chat-unread-badge { border-color: #1e293b; }

/* ── Dashboard embedded chat panel ─────────────────────────────────────────── */
.dc-messages {
    min-height: 220px;
    max-height: 320px;
    overflow-y: auto;
    padding: 0.875rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    scroll-behavior: smooth;
}

.dc-confirm-bar {
    padding: 0.5rem 1rem;
    background: #fffbeb;
    border-top: 1px solid #fde68a;
    display: none;
    gap: 0.5rem;
}
.dc-confirm-bar.visible { display: flex; }
#dc-confirm-yes, #dc-confirm-no {
    flex: 1; padding: 0.45rem 0;
    border-radius: 7px; border: none;
    font-size: 0.82rem; font-weight: 600;
    cursor: pointer; font-family: inherit;
}
#dc-confirm-yes { background: #22c55e; color: #fff; }
#dc-confirm-yes:hover { background: #16a34a; }
#dc-confirm-no  { background: #e2e8f0; color: #475569; }
#dc-confirm-no:hover  { background: #cbd5e1; }

.dc-input-row {
    display: flex; gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    border-top: 1px solid var(--border-color);
}
#dc-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    overflow-y: auto;
    line-height: 1.4;
}
#dc-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
#dc-send {
    background: var(--primary-color); color: #fff;
    border: none; border-radius: 8px;
    padding: 0 0.9rem; font-size: 0.875rem;
    font-weight: 600; cursor: pointer;
    font-family: inherit; flex-shrink: 0;
    transition: background 0.15s;
}
#dc-send:hover    { background: var(--primary-hover); }
#dc-send:disabled { opacity: 0.6; cursor: default; }
