:root {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --border: #e2e8f0;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --brand: #2563eb;
    --brand-hover: #1d4ed8;
    --brand-soft: #dbeafe;
    --success: #059669;
    --success-soft: #d1fae5;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --shadow-soft: 0 8px 24px rgba(15, 23, 42, 0.06);
    --radius-main: 14px;
    --radius-btn: 10px;
}

* {
    box-sizing: border-box;
}

body {
    background: #f6f8fb;
    color: var(--text-main);
    font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
}

.container.py-4 {
    max-width: 1400px;
    padding-top: 1.5rem !important;
    padding-bottom: 1.5rem !important;
}

h1 {
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-main);
    font-size: clamp(1.35rem, 2vw, 1.75rem);
}

.text-muted {
    color: var(--text-muted) !important;
}

.card {
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
    border-radius: var(--radius-main);
    background: var(--surface);
}

.app-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--border);
}

.app-nav__brand {
    color: var(--text-main);
    font-weight: 750;
    letter-spacing: -0.02em;
    text-decoration: none;
}

.app-nav__links {
    display: flex;
    gap: 0.35rem;
}

.app-nav__link {
    color: var(--text-muted);
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 650;
    padding: 0.42rem 0.65rem;
    text-decoration: none;
}

.app-nav__link:hover,
.app-nav__link.is-active {
    background: #eaf0f8;
    color: var(--text-main);
}

.filters-card {
    background: var(--surface);
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
    gap: 12px;
    align-items: end;
}

.filters-grid .filter-span-2 {
    grid-column: span 2;
}

.filters-actions {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
}

.quick-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.quick-filter {
    appearance: none;
    border: 1px solid #d5dce5;
    border-radius: 999px;
    background: #fff;
    color: #475569;
    font-size: 0.76rem;
    font-weight: 650;
    line-height: 1;
    padding: 0.48rem 0.65rem;
}

.quick-filter:hover,
.quick-filter.is-active {
    background: #eaf0f8;
    border-color: #94a3b8;
    color: #0f172a;
}

.filters-visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.advanced-filters {
    display: none;
    grid-column: 1 / -1;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem 1rem;
    padding-top: 0.35rem;
    border-top: 1px dashed var(--border);
    margin-top: 0.15rem;
}

.advanced-filters.show {
    display: grid;
}

#advanced-filters-toggle.is-active {
    border-color: #94a3b8;
    background: #f8fafc;
}

.sort-mobile {
    display: none;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.65rem;
}

.sort-mobile__btn {
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    background: #fff;
    color: #334155;
    font-size: 0.74rem;
    font-weight: 650;
    padding: 0.3rem 0.55rem;
}

.sort-mobile__btn.is-active {
    border-color: var(--brand);
    color: var(--brand);
    background: #eff6ff;
}

.sort-mobile__prio {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    margin-right: 0.2rem;
    border-radius: 999px;
    background: #e2e8f0;
    font-size: 0.62rem;
    font-weight: 800;
}

.audit-diff {
    margin-top: 0.35rem;
    font-size: 0.78rem;
    color: #475569;
}

.audit-diff__row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.5rem;
    margin-top: 0.15rem;
}

.audit-diff__key {
    font-weight: 650;
    color: #334155;
}

.audit-diff__old {
    color: #b91c1c;
    text-decoration: line-through;
}

.audit-diff__new {
    color: #047857;
}

.table-tools {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.sort-status {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-soft);
    font-size: 0.78rem;
}

.sort-status--empty .sort-status__hint {
    color: var(--text-muted);
}

.sort-status__label {
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.68rem;
}

.sort-status__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.sort-chip {
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    background: #fff;
    color: #0f172a;
    font-size: 0.76rem;
    font-weight: 650;
    padding: 0.28rem 0.55rem 0.28rem 0.35rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.sort-chip:hover {
    border-color: #94a3b8;
    background: #f8fafc;
}

.sort-chip__index {
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 999px;
    background: #e2e8f0;
    color: #334155;
    font-size: 0.65rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sort-status__clear {
    margin-left: auto;
    padding: 0;
    font-size: 0.76rem;
    text-decoration: none;
}

#rooms-table thead .sort-btn-active {
    color: var(--brand);
}

#rooms-table thead button[data-sort-priority]::after {
    content: attr(data-sort-priority);
    margin-left: 2px;
    font-size: 0.62rem;
    font-weight: 800;
    vertical-align: super;
    color: var(--brand);
}


.table-shell {
    overflow: auto;
    max-height: calc(100vh - 250px);
}

.table {
    --bs-table-bg: transparent;
    margin-bottom: 0;
    font-size: 0.84rem;
}

.table thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 0.72rem;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    background: var(--surface-soft);
    padding: 0.62rem 0.55rem;
}

.table td {
    padding: 0.55rem;
    vertical-align: middle;
}

.table-empty {
    color: var(--text-muted);
    padding: 2.5rem !important;
}

#rooms-table.hide-rate .col-rate,
#rooms-table.hide-note .col-note,
#rooms-table.hide-features .col-features {
    display: none;
}

#rooms-table thead .col-rate,
#rooms-table thead .col-note,
#rooms-table thead .col-features {
    /* class markers for column toggles */
}

.table tbody tr {
    border-bottom: 1px solid #f1f5f9;
}

.table-hover > tbody > tr:hover > * {
    --bs-table-accent-bg: #f8fbff;
}

#rooms-table .col-building {
    max-width: 52px;
    min-width: 52px;
    white-space: nowrap;
    text-align: center;
}

#rooms-table .building-short {
    display: inline-block;
    font-weight: 700;
    letter-spacing: 0.01em;
}

#rooms-table .col-note {
    max-width: 130px;
}

#rooms-table .note-cell-btn {
    border: none;
    background: none;
    padding: 0;
    margin: 0;
    font: inherit;
    color: inherit;
    text-align: left;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
    cursor: pointer;
}

#rooms-table .note-cell-btn:hover,
#rooms-table .note-cell-btn:focus {
    color: var(--brand);
    text-decoration: underline;
    outline: none;
}

#rooms-table .col-note--empty {
    color: var(--text-muted);
}

.note-modal-text {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.55;
}

#rooms-table .col-price {
    white-space: nowrap;
    font-weight: 700;
}

#rooms-table th.actions-col,
#rooms-table td.actions-col {
    position: sticky;
    right: 0;
    z-index: 4;
    min-width: 160px;
    width: 160px;
    background: var(--surface);
    box-shadow: -8px 0 14px rgba(15, 23, 42, 0.05);
}

#rooms-table thead th.actions-col {
    z-index: 6;
    background: var(--surface-soft);
}

#rooms-table tbody tr:hover td.actions-col {
    background: #f8fbff;
}

.money-cell {
    font-size: 0.84rem;
    white-space: nowrap;
}

.form-label {
    font-weight: 600;
    margin-bottom: 0.3rem;
    color: #475569;
    font-size: 0.78rem;
}

.form-control,
.form-select {
    border-radius: var(--radius-btn);
    border-color: #dbe1ea;
    background-color: #fff;
    font-size: 0.84rem;
}

.form-control:focus,
.form-select:focus,
.btn:focus {
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.12);
    border-color: #93c5fd;
}

.btn {
    border-radius: var(--radius-btn);
    font-weight: 600;
    font-size: 0.82rem;
    transition: all 0.15s ease;
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.btn-sm {
    padding: 0.38rem 0.7rem;
}

.btn-primary,
.btn-success#add-room-btn {
    background: var(--brand);
    border-color: var(--brand);
}

.btn-primary:hover,
.btn-success#add-room-btn:hover {
    background: var(--brand-hover);
    border-color: var(--brand-hover);
}

.btn-outline-primary {
    border-color: #bfdbfe;
    color: #1d4ed8;
}

.btn-outline-primary:hover {
    background: var(--brand-soft);
    border-color: #93c5fd;
    color: #1e40af;
}

.btn-outline-secondary {
    border-color: #cbd5e1;
    color: #475569;
}

.btn-ghost {
    background: #fff;
    border: 1px solid var(--border);
    color: #334155;
}

.action-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
}

.btn-action {
    width: 32px;
    height: 32px;
    min-width: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    color: #475569;
}

.btn-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.btn-action-photo.has-photo {
    background: var(--success-soft);
    border-color: #6ee7b7;
    color: var(--success);
}

.btn-action-edit {
    color: #1d4ed8;
    border-color: #bfdbfe;
    background: #eff6ff;
}

.btn-action-delete {
    color: var(--danger);
    border-color: #fecaca;
    background: var(--danger-soft);
}

.badge {
    font-size: 0.72rem;
    padding: 0.38em 0.62em;
    border-radius: 999px;
}

.dropdown-menu {
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}

.table-scroll-hint {
    display: none;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    padding: 0.35rem 0.5rem 0.65rem;
}

.page-header {
    gap: 1rem;
}

.page-header-side {
    min-width: 220px;
    max-width: 280px;
}

.room-price-preview {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 38px;
    padding: 0.5rem 0.7rem;
    border: 1px solid #dbe1ea;
    border-radius: var(--radius-btn);
    background: var(--surface-soft);
    color: var(--text-main);
    font-weight: 700;
}

.room-price-preview small {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
}

.building-card--no-image {
    min-height: 84px;
    display: grid;
    place-items: center;
    background: var(--surface-soft);
    box-shadow: none !important;
}

#building-info .btn {
    white-space: nowrap;
}

.photo-viewer {
    position: relative;
    height: 70vh;
    max-height: 70vh;
    background: rgba(0, 0, 0, 0.03);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#photoModalContent {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.photo-slide {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateX(0);
    opacity: 1;
    transition: all 400ms cubic-bezier(0.4, 0, 0.2, 1);
    background: #fff;
    width: 100%;
    height: 100%;
}

.photo-slide img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 0.25rem;
    background: transparent;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.photo-slide.slide-left {
    transform: translateX(-100%);
    opacity: 0;
}

.photo-slide.slide-right {
    transform: translateX(100%);
    opacity: 0;
}

.photo-slide.slide-center {
    transform: translateX(0);
    opacity: 1;
}

.photo-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 72px;
    border: none;
    border-radius: 0.5rem;
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
    transition: all 0.2s ease;
    font-size: 1.5rem;
    font-weight: bold;
}

.photo-nav:hover {
    background: rgba(0, 0, 0, 0.6);
    transform: translateY(-50%) scale(1.1);
}

.photo-nav.left {
    left: 8px;
}

.photo-nav.right {
    right: 8px;
}

.photo-nav:disabled {
    opacity: 0.3;
    cursor: default;
    transform: translateY(-50%) scale(1);
}

.thumbs-container {
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: #dee2e6 #f8f9fa;
}

#photoThumbs {
    min-width: max-content;
    padding: 0 4px;
}

#photoThumbs img {
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
}

@media (max-width: 992px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start !important;
    }

    .page-header-side {
        align-items: flex-start !important;
        max-width: 100% !important;
        min-width: 100% !important;
    }

    .filters-grid .filter-span-2 {
        grid-column: span 1;
    }

    .table-scroll-hint {
        display: block;
    }
}

@media (max-width: 768px) {
    .container.py-4 {
        padding-top: 1rem !important;
        padding-bottom: 1.25rem !important;
    }

    .table-shell {
        max-height: none;
    }

    .photo-viewer {
        height: 52vh;
        max-height: 52vh;
    }

    .app-nav {
        align-items: flex-start;
        flex-direction: column;
    }

    .filters-grid {
        grid-template-columns: 1fr;
    }

    .filters-grid .filter-span-2 {
        grid-column: span 1;
    }

    .advanced-filters.show {
        grid-template-columns: 1fr;
    }

    .sort-mobile {
        display: flex;
    }

    .sort-status--empty {
        display: none;
    }

    .table-card {
        background: transparent;
        border: 0;
        box-shadow: none;
        overflow: visible;
        padding: 0 !important;
    }

    .table-shell {
        overflow: visible;
    }

    #rooms-table,
    #rooms-table tbody,
    #rooms-table tr,
    #rooms-table td {
        display: block;
        width: 100%;
    }

    #rooms-table thead {
        display: none;
    }

    #rooms-table tbody {
        display: grid;
        gap: 0.75rem;
    }

    #rooms-table tbody tr {
        border: 1px solid var(--border);
        border-radius: var(--radius-main);
        background: var(--surface);
        box-shadow: var(--shadow-soft);
        overflow: hidden;
        padding: 0.6rem 0.8rem;
    }

    #rooms-table tbody td {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 1rem;
        border: 0;
        padding: 0.38rem 0;
        text-align: right !important;
        max-width: none;
        min-width: 0;
        background: transparent !important;
        box-shadow: none;
    }

    #rooms-table tbody td::before {
        content: attr(data-label);
        color: var(--text-muted);
        flex: 0 0 auto;
        font-size: 0.72rem;
        font-weight: 700;
        letter-spacing: 0.03em;
        text-align: left;
        text-transform: uppercase;
    }

    #rooms-table tbody td.col-building,
    #rooms-table tbody td.col-room {
        justify-content: flex-start;
        text-align: left !important;
    }

    #rooms-table tbody td.col-building::before,
    #rooms-table tbody td.col-room::before {
        display: none;
    }

    #rooms-table tbody td.col-building {
        font-size: 0.78rem;
        color: var(--text-muted);
    }

    #rooms-table tbody td.col-room {
        font-size: 1.05rem;
        font-weight: 750;
        padding-top: 0;
    }

    #rooms-table tbody td.col-price {
        border-top: 1px solid #eef2f7;
        margin-top: 0.2rem;
        padding-top: 0.6rem;
    }

    #rooms-table tbody td.actions-col {
        justify-content: space-between;
        position: static;
        width: auto;
        margin-top: 0.25rem;
        padding-top: 0.6rem;
        border-top: 1px solid #eef2f7;
    }

    #rooms-table .col-note {
        align-items: flex-start;
        text-align: left !important;
    }

    #rooms-table .note-cell-btn {
        text-align: right;
    }

    .table-scroll-hint {
        display: none;
    }
}
