/* Hostel Management ERP — application shell and shared components.
   Colours come from CSS variables so that light and dark themes share every rule. */

:root {
    --app-sidebar-width: 264px;
    --app-topbar-height: 60px;
    --app-primary: #3b5bdb;
    --app-primary-rgb: 59, 91, 219;
    --app-sidebar-bg: #111827;
    --app-sidebar-fg: #cbd5e1;
    --app-sidebar-muted: #7c8aa0;
    --app-sidebar-active-bg: rgba(255, 255, 255, .08);
    --app-surface: #ffffff;
    --app-canvas: #f3f5f9;
    --app-border: #e4e8ef;
    --app-muted: #64748b;
    --app-radius: .75rem;
    --bs-primary: var(--app-primary);
    --bs-primary-rgb: var(--app-primary-rgb);
    --bs-link-color-rgb: var(--app-primary-rgb);
    --bs-font-sans-serif: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

[data-bs-theme="dark"] {
    --app-sidebar-bg: #0b1120;
    --app-surface: #172033;
    --app-canvas: #0f172a;
    --app-border: #263349;
    --app-muted: #94a3b8;
    --bs-body-bg: var(--app-canvas);
}

html, body { height: 100%; }
body { background: var(--app-canvas); font-size: .9rem; }

.btn-primary {
    --bs-btn-bg: var(--app-primary); --bs-btn-border-color: var(--app-primary);
    --bs-btn-hover-bg: #3350c4; --bs-btn-hover-border-color: #3350c4;
    --bs-btn-active-bg: #2c46ad; --bs-btn-active-border-color: #2c46ad;
    --bs-btn-disabled-bg: var(--app-primary); --bs-btn-disabled-border-color: var(--app-primary);
}
.btn-outline-primary {
    --bs-btn-color: var(--app-primary); --bs-btn-border-color: var(--app-primary);
    --bs-btn-hover-bg: var(--app-primary); --bs-btn-hover-border-color: var(--app-primary);
    --bs-btn-active-bg: var(--app-primary); --bs-btn-active-border-color: var(--app-primary);
}
.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: rgba(var(--app-primary-rgb), .6);
    box-shadow: 0 0 0 .2rem rgba(var(--app-primary-rgb), .15);
}
.form-check-input:checked { background-color: var(--app-primary); border-color: var(--app-primary); }
.form-label { font-weight: 600; font-size: .8rem; margin-bottom: .3rem; }
.required::after { content: " *"; color: var(--bs-danger); }

/* ---------- Shell ---------- */
.app-sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--app-sidebar-width); z-index: 1040;
    background: var(--app-sidebar-bg); color: var(--app-sidebar-fg);
    display: flex; flex-direction: column; transition: transform .2s ease;
}
.app-brand {
    height: var(--app-topbar-height); display: flex; align-items: center; gap: .65rem; padding: 0 1.1rem;
    color: #fff; font-weight: 700; letter-spacing: .01em; text-decoration: none; flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.app-brand-mark {
    width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 1.05rem;
    background: linear-gradient(135deg, var(--app-primary), #7c3aed); color: #fff;
}
.app-nav { overflow-y: auto; padding: .75rem .6rem 1.5rem; flex: 1; }
.app-nav ul { list-style: none; margin: 0; padding: 0; }
.app-nav-link {
    display: flex; align-items: center; gap: .7rem; width: 100%; padding: .55rem .75rem; margin-bottom: 2px;
    border: 0; border-radius: .55rem; background: transparent; color: var(--app-sidebar-fg);
    text-decoration: none; text-align: left; font-size: .875rem; transition: background .15s, color .15s;
}
.app-nav-link:hover, .app-nav-link:focus-visible { background: var(--app-sidebar-active-bg); color: #fff; outline: 0; }
.app-nav-link.active { background: var(--app-primary); color: #fff; }
.app-nav-link > .bi:first-child { font-size: 1rem; width: 1.15rem; text-align: center; }
.app-nav-link .chevron { margin-left: auto; font-size: .7rem; transition: transform .2s; }
.app-nav-link[aria-expanded="true"] .chevron { transform: rotate(90deg); }
.app-nav-sub { padding-left: 1.15rem !important; }
.app-nav-sub .app-nav-link { font-size: .84rem; padding: .45rem .75rem; }

.app-main { margin-left: var(--app-sidebar-width); min-height: 100%; display: flex; flex-direction: column; transition: margin .2s ease; }
.app-topbar {
    position: sticky; top: 0; z-index: 1030; height: var(--app-topbar-height);
    display: flex; align-items: center; gap: .75rem; padding: 0 1.25rem;
    background: var(--app-surface); border-bottom: 1px solid var(--app-border);
}
.app-topbar .breadcrumb { margin: 0; font-size: .82rem; }
.app-icon-btn {
    width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 10px; font-size: 1.1rem;
    border: 1px solid var(--app-border); background: transparent; color: var(--bs-body-color);
}
.app-icon-btn:hover { background: var(--app-canvas); }
.app-icon-btn { position: relative; }
.app-bell-count {
    position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; font-size: .68rem; font-weight: 700; line-height: 18px;
    text-align: center; background: var(--bs-danger); color: #fff;
}
.notification-menu { width: 340px; max-width: 92vw; padding: 0; }
.notification-menu .notification-item { display: block; padding: .6rem .9rem; border-bottom: 1px solid var(--app-border); color: inherit; text-decoration: none; white-space: normal; }
.notification-menu .notification-item:hover { background: var(--app-canvas); }
.notification-item.unread .notification-title::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--app-primary); }
.notification-title { font-weight: 600; }
.notification-body { font-size: .84rem; color: var(--app-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notice-body { white-space: pre-wrap; }
.app-avatar {
    width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .8rem;
    background: rgba(var(--app-primary-rgb), .14); color: var(--app-primary); text-transform: uppercase;
}
.app-content { padding: 1.4rem 1.5rem 2rem; flex: 1; }
.app-footer { padding: .9rem 1.5rem; color: var(--app-muted); font-size: .78rem; border-top: 1px solid var(--app-border); }

body.sidebar-collapsed .app-sidebar { transform: translateX(-100%); }
body.sidebar-collapsed .app-main { margin-left: 0; }
.app-backdrop { display: none; }

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-main { margin-left: 0; }
    body.sidebar-open .app-sidebar { transform: none; }
    body.sidebar-open .app-backdrop { display: block; position: fixed; inset: 0; z-index: 1035; background: rgba(15, 23, 42, .5); }
    .app-content { padding: 1rem; }
}

/* ---------- Page pieces ---------- */
.page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.1rem; }
.page-title { font-size: 1.3rem; font-weight: 700; margin: 0; }
.page-subtitle { color: var(--app-muted); margin: .15rem 0 0; font-size: .85rem; }

.card { border: 1px solid var(--app-border); border-radius: var(--app-radius); background: var(--app-surface); box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }
.card-header { background: transparent; border-bottom: 1px solid var(--app-border); font-weight: 600; padding: .85rem 1.1rem; }

.stat-card { padding: 1.05rem 1.15rem; display: flex; flex-direction: row; align-items: center; gap: .95rem; height: 100%; }
.stat-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.3rem; flex-shrink: 0; }
.stat-value { font-size: 1.55rem; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--app-muted); font-size: .8rem; }
.tone-primary { background: rgba(var(--app-primary-rgb), .12); color: var(--app-primary); }
.tone-success { background: rgba(25, 135, 84, .13); color: #198754; }
.tone-warning { background: rgba(245, 158, 11, .16); color: #b45309; }
.tone-danger  { background: rgba(220, 53, 69, .13); color: #dc3545; }
.tone-info    { background: rgba(13, 148, 136, .14); color: #0d9488; }
.tone-muted   { background: rgba(100, 116, 139, .14); color: var(--app-muted); }

.filter-panel { padding: .9rem 1.1rem; border-bottom: 1px solid var(--app-border); }
.filter-panel .form-label { color: var(--app-muted); }
.filter-toggle-row { padding: .75rem 1.1rem 0; }

/* ---------- Phones (below 576 px): lists as cards, filters folded ---------- */
@media (max-width: 575.98px) {
    /* A list's filters stay out of the way until asked for (site.js foldFilters). */
    .filter-panel.filter-folding:not(.filter-open) { display: none !important; }

    /* Each row a card, each cell with its column's heading (site.js labelCells), so no column hides off to the right. */
    table.table-stack, table.table-stack tbody, table.table-stack tr, table.table-stack td { display: block; width: 100% !important; }
    table.table-stack thead { display: none; }
    table.table-stack tr { padding: .55rem 0; border-bottom: 1px solid var(--app-border); }
    table.table-stack tbody tr:last-child { border-bottom: 0; }
    table.table-stack td { position: relative; border: 0 !important; padding: .3rem 1rem .3rem calc(38% + 1.5rem) !important; min-height: 1.9rem; text-align: left !important; white-space: normal !important; }
    table.table-stack td::before {
        content: attr(data-label); position: absolute; left: 1rem; top: .35rem; width: 38%;
        color: var(--app-muted); font-size: .72rem; font-weight: 600; letter-spacing: .02em; text-transform: uppercase;
        overflow-wrap: anywhere;
    }
    /* Cells without a heading (row actions, the empty message) use the full width. */
    table.table-stack td[data-label=""], table.table-stack td[colspan], table.table-stack td:not([data-label]) { padding-left: 1rem !important; }
    table.table-stack td[data-label=""]::before, table.table-stack td[colspan]::before, table.table-stack td:not([data-label])::before { content: none; }
    table.table-stack td.row-actions { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: flex-start; padding-left: 1rem !important; }
    table.table-stack td.row-actions::before { content: none; }
    table.table-stack td.row-actions:empty { display: none; }
    table.table-stack td.dt-empty { text-align: center !important; }
}

.badge-soft { font-weight: 600; padding: .35em .6em; border-radius: .4rem; }

/* ---------- Tables ---------- */
table.dataTable { width: 100% !important; margin: 0 !important; }
.table > :not(caption) > * > * { padding: .65rem .9rem; vertical-align: middle; background: transparent; }
.table thead th {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--app-muted);
    font-weight: 700; border-bottom: 1px solid var(--app-border); white-space: nowrap;
}
/* Identifiers that happen to be numeric (room 101) are not amounts: only cells marked .text-end align right. */
table.dataTable th.dt-type-numeric, table.dataTable td.dt-type-numeric { text-align: left; }
table.dataTable th.dt-type-numeric.text-end, table.dataTable td.dt-type-numeric.text-end { text-align: right; }
table.dataTable thead th.dt-type-numeric div.dt-column-header { flex-direction: row; }
.table tbody tr:hover > * { background: rgba(var(--app-primary-rgb), .035); }
.dt-container > .row { margin: 0; padding: .7rem .6rem; align-items: center; }
.dt-container > .row.dt-layout-table { padding: 0; }
.dt-container > .row.dt-layout-table > div { padding: 0; overflow-x: auto; }
.dt-container .dt-search input, .dt-container .dt-length select { font-size: .85rem; }
.dt-container .dt-info { color: var(--app-muted); font-size: .8rem; }
.dt-container .pagination { margin: 0; --bs-pagination-font-size: .8rem; --bs-pagination-active-bg: var(--app-primary); --bs-pagination-active-border-color: var(--app-primary); --bs-pagination-color: var(--bs-body-color); }
div.dt-processing { background: var(--app-surface); border: 1px solid var(--app-border); border-radius: .6rem; box-shadow: 0 6px 24px rgba(15, 23, 42, .12); }
div.dt-processing > div:last-child > div { background: var(--app-primary) !important; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .btn { --bs-btn-padding-y: .2rem; --bs-btn-padding-x: .45rem; --bs-btn-font-size: .9rem; border-color: transparent; color: var(--app-muted); }
.row-actions .btn:hover { background: var(--app-canvas); color: var(--bs-body-color); }
.row-actions .btn.text-danger:hover { color: var(--bs-danger) !important; }
.cell-main { font-weight: 600; }
.cell-sub { color: var(--app-muted); font-size: .8rem; }

.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--app-muted); }
.empty-state .bi { font-size: 2.2rem; opacity: .55; display: block; margin-bottom: .5rem; }

/* ---------- Feedback ---------- */
.app-progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 2000; background: var(--app-primary); opacity: 0; transition: width .3s ease, opacity .3s ease; }
.app-progress.active { width: 85%; opacity: 1; transition: width 8s cubic-bezier(.1, .7, .1, 1), opacity .1s; }
.app-progress.done { width: 100%; opacity: 0; }
.toast-container { z-index: 2100; }
.field-validation-error, .invalid-feedback { font-size: .78rem; color: var(--bs-danger); display: block; margin-top: .25rem; }
.input-validation-error { border-color: var(--bs-danger) !important; }
.validation-summary-valid { display: none; }
.validation-summary-errors ul { margin: 0; padding-left: 1.1rem; }

/* ---------- Auth pages ---------- */
.auth-page { min-height: 100%; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--app-surface); }
.auth-hero {
    position: relative; overflow: hidden; isolation: isolate; color: #fff;
    background: linear-gradient(155deg, #141c3f 0%, #23338a 45%, var(--app-primary) 78%, #7c3aed 120%);
    padding: 2.75rem 3.25rem; display: flex; flex-direction: column; justify-content: space-between; gap: 2rem;
}
/* A faint grid of "rooms" and two soft lights: decoration only, behind the text. */
.auth-hero::before {
    content: ""; position: absolute; inset: 0; z-index: -1;
    background-image: linear-gradient(rgba(255, 255, 255, .055) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .055) 1px, transparent 1px);
    background-size: 44px 44px;
    -webkit-mask-image: radial-gradient(ellipse at 75% 20%, #000 0%, transparent 70%); mask-image: radial-gradient(ellipse at 75% 20%, #000 0%, transparent 70%);
}
.auth-hero::after {
    content: ""; position: absolute; z-index: -1; width: 520px; height: 520px; right: -180px; bottom: -220px; border-radius: 50%;
    background: radial-gradient(circle, rgba(167, 139, 250, .5) 0%, rgba(167, 139, 250, 0) 68%);
}
.auth-hero-brand { display: flex; align-items: center; gap: .65rem; font-weight: 700; font-size: 1.1rem; letter-spacing: .01em; }
.auth-hero-brand .app-brand-mark, .auth-card-brand .app-brand-mark { box-shadow: 0 6px 16px rgba(15, 23, 42, .25); }
.auth-hero-body { max-width: 30rem; }
.auth-hero-eyebrow {
    display: inline-block; padding: .3rem .75rem; border-radius: 999px; font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
    background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .18);
}
.auth-hero h1 { font-size: clamp(1.9rem, 2.6vw, 2.6rem); font-weight: 700; line-height: 1.15; letter-spacing: -.02em; margin: 1.1rem 0 .8rem; }
.auth-hero-lead { font-size: 1rem; color: rgba(255, 255, 255, .78); margin: 0 0 1.9rem; }
.auth-features { list-style: none; margin: 0; padding: 0; display: grid; gap: .7rem; }
.auth-features li {
    display: flex; align-items: center; gap: .9rem; padding: .8rem .95rem; border-radius: .9rem;
    background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .12);
}
.auth-feature-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; font-size: 1.15rem; flex-shrink: 0; background: rgba(255, 255, 255, .14); }
.auth-features strong { display: block; font-weight: 600; font-size: .95rem; }
.auth-features small { display: block; color: rgba(255, 255, 255, .72); font-size: .82rem; }
.auth-hero-foot { font-size: .8rem; color: rgba(255, 255, 255, .7); }

.auth-form {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4.5rem 1.25rem 3.5rem;
    background: radial-gradient(900px 500px at 100% 0%, rgba(var(--app-primary-rgb), .07), transparent 60%), var(--app-surface);
}
.auth-theme-btn { position: absolute; top: 1.1rem; right: 1.1rem; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card-brand { display: none; align-items: center; gap: .65rem; font-weight: 700; font-size: 1.05rem; margin-bottom: 2rem; }
.auth-title { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; margin: 0 0 .3rem; }
.auth-subtitle { color: var(--app-muted); margin: 0 0 1.75rem; }
.auth-card .form-label { font-size: .82rem; }
.auth-card .form-control { padding: .65rem .85rem; font-size: .95rem; border-radius: .65rem; }
/* The icon, the input and the eye button read as one field with one focus ring. */
.auth-field { border: 1px solid var(--bs-border-color); border-radius: .65rem; background: var(--bs-body-bg); transition: border-color .15s, box-shadow .15s; }
.auth-field:focus-within { border-color: rgba(var(--app-primary-rgb), .6); box-shadow: 0 0 0 .2rem rgba(var(--app-primary-rgb), .15); }
.auth-field:has(.input-validation-error) { border-color: var(--bs-danger); }
.auth-field .input-group-text { border: 0; background: transparent; color: var(--app-muted); padding: 0 0 0 .85rem; font-size: 1.05rem; }
.auth-field .form-control, .auth-field .form-control:focus { border: 0; background: transparent; box-shadow: none; }
.auth-field-btn { border: 0; color: var(--app-muted); padding: 0 .85rem; }
.auth-field-btn:hover, .auth-field-btn:focus-visible { color: var(--bs-body-color); }
.auth-submit { padding: .7rem 1rem; font-weight: 600; font-size: .95rem; border-radius: .65rem; box-shadow: 0 8px 20px rgba(var(--app-primary-rgb), .28); }
.auth-submit .bi { transition: transform .15s; display: inline-block; }
.auth-submit:hover .bi { transform: translateX(3px); }
.auth-help { margin: 1.75rem 0 0; padding-top: 1.25rem; border-top: 1px solid var(--app-border); color: var(--app-muted); font-size: .82rem; }
.auth-form-foot { position: absolute; bottom: 1.1rem; left: 0; right: 0; text-align: center; color: var(--app-muted); font-size: .76rem; }
@media (max-width: 991.98px) {
    .auth-page { grid-template-columns: 1fr; }
    .auth-hero { display: none; }
    .auth-card-brand { display: flex; }
}
@media (prefers-reduced-motion: reduce) { .auth-submit .bi, .stat-tile { transition: none; } }

/* ---------- Permission matrix ---------- */
.perm-module { border: 1px solid var(--app-border); border-radius: .65rem; padding: .85rem 1rem; height: 100%; background: var(--app-surface); }
.perm-module-title { font-weight: 700; display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.perm-module .form-check { margin-bottom: .3rem; }
.perm-module .form-check-label small { color: var(--app-muted); display: block; }

/* ---------- Select2 inside Bootstrap ---------- */
.select2-container { width: 100% !important; }
.select2-container--default .select2-selection--multiple,
.select2-container--default .select2-selection--single {
    min-height: 37px; border: 1px solid var(--bs-border-color); border-radius: var(--bs-border-radius); background: var(--bs-body-bg);
}
/* Single selects are sized like .form-select (and .form-select-sm inside filter panels). */
.select2-container--default .select2-selection--single { height: 37px; }
.select2-container--default .select2-selection--single .select2-selection__rendered { line-height: 35px; padding-left: .75rem; padding-right: 2.2rem; color: var(--bs-body-color); }
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 35px; right: 6px; }
.select2-container--default .select2-selection--single .select2-selection__placeholder { color: var(--app-muted); }
.select2-container--default .select2-selection--single .select2-selection__clear { margin-right: 4px; color: var(--app-muted); }
.filter-panel .select2-container--default .select2-selection--single { height: 31px; min-height: 31px; }
.filter-panel .select2-container--default .select2-selection--single .select2-selection__rendered { line-height: 29px; padding-left: .5rem; font-size: .875rem; }
.filter-panel .select2-container--default .select2-selection--single .select2-selection__arrow { height: 29px; }
.select2-container--default.select2-container--disabled .select2-selection--single { background: var(--bs-secondary-bg); }
.select2-container--default .select2-search--dropdown .select2-search__field { border-color: var(--bs-border-color); border-radius: .375rem; background: var(--bs-body-bg); color: var(--bs-body-color); }
.select2-container--default.select2-container--open .select2-selection--single,
.select2-container--default.select2-container--focus .select2-selection--multiple { border-color: rgba(var(--app-primary-rgb), .6); box-shadow: 0 0 0 .2rem rgba(var(--app-primary-rgb), .15); }
.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background: rgba(var(--app-primary-rgb), .12); border: 0; color: var(--bs-body-color); border-radius: .35rem; padding: 1px 8px; margin-top: 6px;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove { color: var(--app-muted); margin-right: 4px; }
.select2-dropdown { border-color: var(--bs-border-color); background: var(--bs-body-bg); color: var(--bs-body-color); z-index: 2000; }
.select2-container--default .select2-results__option--highlighted[aria-selected] { background: var(--app-primary); }
.select2-container--default .select2-results__option[aria-selected=true] { background: rgba(var(--app-primary-rgb), .12); color: var(--bs-body-color); }
.select2-container--default .select2-search--inline .select2-search__field { color: var(--bs-body-color); margin-top: 7px; }

/* ---------- Room status board ---------- */
.board-floor-title { font-weight: 700; font-size: .9rem; margin: 0 0 .6rem; display: flex; align-items: baseline; gap: .5rem; }
.board-floor-title small { color: var(--app-muted); font-weight: 400; }
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: .65rem; }
.room-tile {
    --tile: #94a3b8;
    text-align: left; border: 1px solid var(--app-border); border-left: 5px solid var(--tile); border-radius: .6rem;
    background: color-mix(in srgb, var(--tile) 9%, var(--app-surface)); color: var(--bs-body-color);
    padding: .55rem .65rem; min-height: 88px; display: flex; flex-direction: column; gap: .2rem; transition: transform .1s, box-shadow .1s;
}
.room-tile:hover, .room-tile:focus-visible { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(15, 23, 42, .12); outline: 0; border-color: var(--tile); }
.room-tile-no { font-weight: 700; font-size: 1rem; line-height: 1.1; display: flex; justify-content: space-between; align-items: center; gap: .25rem; }
.room-tile-no .bi { font-size: .8rem; color: var(--app-muted); }
.room-tile-type { color: var(--app-muted); font-size: .74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-tile-beds { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: auto; }
.room-tile-count { margin-left: auto; font-size: .7rem; color: var(--app-muted); white-space: nowrap; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: .75rem; }
.stat-grid .stat-card { padding: .8rem .85rem; gap: .7rem; }
.stat-grid .stat-icon { width: 38px; height: 38px; font-size: 1.1rem; border-radius: 10px; }
.stat-grid .stat-value { font-size: 1.3rem; }
.bed-dot { width: 13px; height: 13px; border-radius: 4px; background: var(--dot, #94a3b8); display: inline-block; }
.st-available, .bd-available { --tile: #2f9e44; --dot: #2f9e44; }
.st-partially_occupied { --tile: #1c7ed6; }
.st-fully_occupied, .bd-occupied { --tile: #e03131; --dot: #e03131; }
.st-reserved, .bd-reserved { --tile: #f08c00; --dot: #f08c00; }
.st-maintenance, .bd-maintenance { --tile: #868e96; --dot: #868e96; }
.st-blocked { --tile: #343a40; }
.st-no_beds { --tile: #ced4da; }
[data-bs-theme="dark"] .st-blocked { --tile: #adb5bd; }
.legend-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--tile); margin-right: .35rem; vertical-align: -1px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem 1rem; margin: 0; }
.detail-grid dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--app-muted); font-weight: 700; }
.detail-grid dd { margin: 0; font-weight: 600; }
.section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--app-muted); font-weight: 700; margin: 1.25rem 0 .5rem; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: .4rem 0; border-bottom: 1px dashed var(--app-border); font-size: .84rem; }
.timeline li:last-child { border-bottom: 0; }
.swal2-input.form-control { margin: .75rem 1.6rem 0; width: auto; font-size: .95rem; box-shadow: none; }

/* ---------- Resident profile and ID card ---------- */
.profile-photo {
    width: 96px; height: 96px; border-radius: 16px; object-fit: cover; flex-shrink: 0;
    background: var(--app-canvas); border: 1px solid var(--app-border); display: grid; place-items: center; font-size: 2.4rem; color: var(--app-muted);
}
.profile-name { font-size: 1.35rem; font-weight: 700; margin: 0; }
.list-row { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; padding: .6rem 0; border-bottom: 1px dashed var(--app-border); }
.list-row:last-child { border-bottom: 0; padding-bottom: 0; }
.list-row:first-child { padding-top: 0; }
.id-card {
    width: 340px; border: 1px solid var(--app-border); border-radius: 16px; overflow: hidden; background: var(--app-surface); margin: 0 auto;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .1);
}
.id-card-head { background: linear-gradient(135deg, #1e2a5a, var(--app-primary)); color: #fff; padding: .9rem 1.1rem; font-weight: 700; }
.id-card-head small { display: block; font-weight: 400; opacity: .85; }
.id-card-body { padding: 1.1rem; display: grid; grid-template-columns: 96px 1fr; gap: .9rem; }
.id-card-body dl { margin: 0; font-size: .82rem; }
.id-card-body dt { font-size: .66rem; text-transform: uppercase; letter-spacing: .05em; color: var(--app-muted); }
.id-card-body dd { margin: 0 0 .35rem; font-weight: 600; }
.id-card-foot { border-top: 1px solid var(--app-border); padding: .8rem 1.1rem; display: flex; align-items: center; justify-content: space-between; gap: .75rem; font-size: .78rem; }
.id-card-foot img { width: 84px; height: 84px; }
.public-page { max-width: 760px; margin: 0 auto; padding: 2rem 1rem 3rem; }

pre.json-view { background: var(--app-canvas); border: 1px solid var(--app-border); border-radius: .5rem; padding: .75rem; font-size: .78rem; max-height: 260px; overflow: auto; margin: 0; white-space: pre-wrap; word-break: break-word; }

@media print {
    .app-sidebar, .app-topbar, .app-footer, .page-header .btn, .filter-panel, .row-actions, .dt-search, .dt-length, .dt-paging { display: none !important; }
    .app-main { margin: 0; }
    body { background: #fff; }
}

/* Settings: a hostel logo in the list. Portal: the week menu, with today picked out. */
.logo-thumb { height: 44px; max-width: 120px; object-fit: contain; }
.menu-week th, .menu-week td { vertical-align: top; min-width: 6.5rem; }
.menu-week .menu-today { background: var(--bs-primary-bg-subtle); }

/* Reports: numbers line up; on paper the table is all there is. */
.report-table td, .report-table th { white-space: nowrap; }
.report-table td:not(.text-end) { white-space: normal; }
@media print {
    .report-table { font-size: 9pt; }
    #reportsPage .card { border: 0; box-shadow: none; }
}

/* Dashboard charts keep one height whatever the data. */
.chart-box { height: 260px; }

/* ---------- Dashboards ---------- */
/* The welcome band: the same indigo as the sign-in page, in both themes. */
.dash-hero {
    position: relative; overflow: hidden; isolation: isolate; color: #fff; border-radius: 1rem; padding: 1.5rem 1.6rem; margin-bottom: 1.5rem;
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1.1rem;
    background: linear-gradient(120deg, #1a2456 0%, #2a3c9c 48%, var(--app-primary) 80%, #7c3aed 125%);
    box-shadow: 0 10px 28px rgba(var(--app-primary-rgb), .22);
}
.dash-hero::before {
    content: ""; position: absolute; inset: 0; z-index: -1;
    background-image: linear-gradient(rgba(255, 255, 255, .06) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .06) 1px, transparent 1px);
    background-size: 36px 36px;
    -webkit-mask-image: linear-gradient(90deg, transparent 35%, #000 100%); mask-image: linear-gradient(90deg, transparent 35%, #000 100%);
}
.dash-hero-date { font-size: .74rem; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: rgba(255, 255, 255, .72); min-height: 1.1em; }
.dash-hero h1 { font-size: clamp(1.3rem, 2.2vw, 1.7rem); font-weight: 700; letter-spacing: -.015em; margin: .3rem 0 .65rem; }
.dash-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.dash-chip { display: inline-flex; align-items: center; gap: .35rem; padding: .22rem .65rem; border-radius: 999px; font-size: .76rem; font-weight: 600; background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .18); }
.dash-hero-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.dash-hero-actions .btn {
    --bs-btn-color: #fff; --bs-btn-hover-color: #1a2456; --bs-btn-active-color: #1a2456;
    --bs-btn-bg: rgba(255, 255, 255, .12); --bs-btn-hover-bg: #fff; --bs-btn-active-bg: #fff;
    --bs-btn-border-color: rgba(255, 255, 255, .22); --bs-btn-hover-border-color: #fff; --bs-btn-active-border-color: #fff;
    font-weight: 600; font-size: .84rem; border-radius: .6rem; padding: .45rem .85rem;
}

.dash-section-title {
    display: flex; align-items: center; gap: .55rem; margin: 0 0 .75rem;
    font-size: .76rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--app-muted);
}
.dash-section-title .bi { font-size: .95rem; color: var(--app-primary); }
.dash-section-title::after { content: ""; flex: 1; height: 1px; background: var(--app-border); }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .9rem; margin-bottom: 1.6rem; }

/* A figure as a tile: icon above, the number large, what it counts below. */
.stat-tile { flex-direction: column; align-items: flex-start; gap: .8rem; padding: 1.05rem 1.1rem; transition: border-color .15s, box-shadow .15s, transform .15s; }
.stat-tile:hover { border-color: rgba(var(--app-primary-rgb), .35); box-shadow: 0 8px 22px rgba(15, 23, 42, .08); transform: translateY(-1px); }
.stat-tile > div:last-child { width: 100%; min-width: 0; }
.stat-tile .stat-icon { width: 40px; height: 40px; border-radius: 11px; font-size: 1.15rem; }
.stat-tile .stat-value { font-size: 1.5rem; letter-spacing: -.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
/* Lakhs and crores still fit on one line of a narrow tile. */
.stat-tile .stat-value.stat-value-long { font-size: 1.1rem; line-height: 1.5; }
.stat-tile .stat-label { margin-top: .25rem; font-size: .8rem; line-height: 1.3; }
.stat-meter { height: 5px; border-radius: 999px; background: var(--app-border); margin-top: .6rem; overflow: hidden; }
.stat-meter > span { display: block; height: 100%; border-radius: inherit; background: var(--app-primary); }

.dash-card-title { display: flex; align-items: center; gap: .5rem; }
.dash-card-title .bi { color: var(--app-primary); }
.activity-item { display: flex; align-items: flex-start; gap: .75rem; padding: .7rem 1.1rem; border-bottom: 1px solid var(--app-border); }
.activity-item:last-child { border-bottom: 0; }
.activity-icon { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; font-size: .9rem; }
.activity-item .cell-main { overflow-wrap: anywhere; }

/* Placeholders while the figures load. */
.skeleton { border-radius: .5rem; background: linear-gradient(90deg, var(--app-border) 25%, color-mix(in srgb, var(--app-border) 45%, var(--app-surface)) 50%, var(--app-border) 75%); background-size: 200% 100%; animation: skeleton 1.3s ease-in-out infinite; }
.skeleton-tile { height: 132px; border-radius: var(--app-radius); }
.skeleton-title { height: 12px; width: 140px; margin-bottom: .85rem; }
@keyframes skeleton { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* On the dark surface the tone colours need to be lighter to stay readable. */
[data-bs-theme="dark"] .tone-primary { background: rgba(129, 152, 255, .16); color: #9db0ff; }
[data-bs-theme="dark"] .tone-success { background: rgba(52, 211, 153, .14); color: #4ade80; }
[data-bs-theme="dark"] .tone-warning { background: rgba(251, 191, 36, .15); color: #fbbf24; }
[data-bs-theme="dark"] .tone-danger  { background: rgba(248, 113, 113, .15); color: #f87171; }
[data-bs-theme="dark"] .tone-info    { background: rgba(45, 212, 191, .14); color: #2dd4bf; }
[data-bs-theme="dark"] .dash-section-title .bi, [data-bs-theme="dark"] .dash-card-title .bi { color: #9db0ff; }

@media (max-width: 575.98px) {
    .dash-hero { padding: 1.2rem 1.1rem; }
    .tile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
    .stat-tile { padding: .85rem .9rem; gap: .6rem; }
    .stat-tile .stat-value { font-size: 1.25rem; }
}
@media print { .dash-hero { background: none; color: #000; box-shadow: none; padding: 0; } .dash-hero-actions { display: none; } }
