/* =====================================================================
   RentDesk — mobile-first styles (Bootstrap 5.3 base)
   ===================================================================== */
:root {
  --brand: #26326c;          /* deep navy (from the design reference) */
  --brand-dark: #1b2453;
  --brand-light: #e9ebf5;    /* navy tint for chips, pills, soft fills */
  --brand-rgb: 38, 50, 108;
  --page-bg: #f2f3f7;
  --card-radius: 16px;
  --appbar-h: 56px;
  --bottom-h: 64px;
  --bs-primary: #26326c;
  --bs-primary-rgb: 38, 50, 108;
  --bs-link-color: #26326c;
  --bs-link-color-rgb: 38, 50, 108;
  --bs-link-hover-color: #1b2453;
  --bs-border-radius: .75rem;
  --bs-border-radius-lg: 1rem;
}
[data-bs-theme="dark"] {
  --brand: #3a4790;
  --brand-dark: #1b2453;
  --brand-light: rgba(142, 155, 224, .16);
  --page-bg: #11141c;
  --bs-primary: #8e9be0;
  --bs-primary-rgb: 142, 155, 224;
  --bs-link-color: #a7b2ec;
  --bs-link-color-rgb: 167, 178, 236;
  --bs-link-hover-color: #c6cdf5;
  --bs-body-bg: #181c27;
  --bs-tertiary-bg: #11141c;
}
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand-dark); --bs-btn-hover-border-color: var(--brand-dark); --bs-btn-active-bg: var(--brand-dark); --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand); }
.btn-outline-primary { --bs-btn-color: var(--bs-primary); --bs-btn-border-color: var(--bs-primary); --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); --bs-btn-active-bg: var(--brand-dark); }
.text-bg-primary { background-color: var(--brand) !important; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }

html, body { -webkit-tap-highlight-color: transparent; }
body { background: var(--page-bg); font-size: 15px; overscroll-behavior-y: none; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { padding: 12px 12px calc(var(--bottom-h) + 24px + env(safe-area-inset-bottom)); max-width: 1200px; }

.appbar {
  position: sticky; top: 0; z-index: 1020; height: var(--appbar-h);
  display: flex; align-items: center; gap: 4px; padding: 0 4px 0 8px;
  background: var(--brand); color: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.appbar-title { font-size: 1.1rem; font-weight: 600; margin: 0 0 0 4px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar-actions { display: flex; align-items: center; }
.appbar-btn { color: #fff; background: none; border: 0; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; font-size: 1.1rem; text-decoration: none; }
.appbar-btn:hover, .appbar-btn:focus { background: rgba(255,255,255,.15); color: #fff; }
.appbar-logo { width: 36px; text-align: center; font-size: 1.2rem; }

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 1030;
  height: calc(var(--bottom-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: var(--bs-body-bg); border-top: 1px solid var(--bs-border-color); box-shadow: 0 -2px 8px rgba(0,0,0,.06);
}
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--bs-secondary-color); text-decoration: none; font-size: .72rem; }
.bottom-nav a i { font-size: 1.25rem; }
.bottom-nav a.active { color: var(--bs-primary); font-weight: 600; }
.bottom-nav a.fab i { background: var(--brand); color: #fff; width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-top: -22px; box-shadow: 0 4px 12px rgba(var(--brand-rgb),.45); font-size: 1.3rem; }

.sidebar { width: 240px; background: var(--brand-dark); color: #fff; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { color: #fff; font-weight: 700; font-size: 1.2rem; padding: 18px 16px 4px; text-decoration: none; }
.sidebar .nav-link { color: rgba(255,255,255,.8); padding: 10px 16px; border-left: 3px solid transparent; }
.sidebar .nav-link:hover { color: #fff; background: rgba(255,255,255,.07); }
.sidebar .nav-link.active { color: #fff; background: rgba(255,255,255,.12); border-left-color: transparent; }

@media (min-width: 992px) {
  .content { padding: 20px 24px 40px; }
  .appbar { background: var(--bs-body-bg); color: var(--bs-body-color); }
  .appbar-btn { color: var(--bs-body-color); }
  .appbar-btn:hover { background: var(--bs-tertiary-bg); color: var(--bs-body-color); }
}

.net-banner { background: #b02a37; color: #fff; text-align: center; font-size: .85rem; padding: 6px; position: sticky; top: var(--appbar-h); z-index: 1019; }

/* ---------- Components ---------- */
.card { border-radius: 14px; }
.card.shadow-sm { box-shadow: 0 1px 3px rgba(0,0,0,.07) !important; }
.card-header { background: transparent; font-weight: 600; }
.section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--bs-secondary-color); font-weight: 600; margin: 18px 4px 8px; }

.stat-card { color: inherit; }
.stat-card .card-body { padding: 14px; }
.stat-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-bottom: 8px; }
.stat-value { font-size: 1.25rem; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: .8rem; color: var(--bs-secondary-color); }
.stat-sub { font-size: .75rem; margin-top: 2px; }

.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.quick-actions a { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px; border-radius: 14px; background: var(--bs-body-bg); text-decoration: none; color: var(--bs-body-color); font-size: .75rem; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,.07); }
.quick-actions a i { font-size: 1.35rem; color: var(--bs-primary); }

.list-card { background: var(--bs-body-bg); border-radius: 14px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.07); }
.list-card .row-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--bs-border-color-translucent); color: inherit; text-decoration: none; min-height: 60px; }
.list-card .row-item:last-child { border-bottom: 0; }
.list-card a.row-item:active { background: var(--bs-tertiary-bg); }
.row-item .grow { flex: 1; min-width: 0; }
.row-item .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-item .sub { font-size: .8rem; color: var(--bs-secondary-color); }
.avatar { width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; background: rgba(var(--bs-primary-rgb), .12); color: var(--bs-primary); font-size: .9rem; }
.unit-chip { min-width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.unit-chip.occupied { background: rgba(25,135,84,.15); color: #198754; }
.unit-chip.vacant { background: rgba(108,117,125,.15); color: var(--bs-secondary-color); }
.unit-chip.maintenance { background: rgba(255,193,7,.2); color: #997404; }
.unit-chip.landlord { background: rgba(13,202,240,.15); color: #087990; }

.unit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.unit-tile { border-radius: 14px; padding: 10px; background: var(--bs-body-bg); box-shadow: 0 1px 3px rgba(0,0,0,.07); text-decoration: none; color: inherit; border-top: 4px solid #adb5bd; display: block; }
.unit-tile.occupied { border-top-color: #198754; }
.unit-tile.maintenance { border-top-color: #ffc107; }
.unit-tile.landlord { border-top-color: #0dcaf0; }
.unit-tile .code { font-weight: 800; font-size: 1.1rem; }
.unit-tile .who { font-size: .75rem; color: var(--bs-secondary-color); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unit-tile .bal { font-size: .78rem; font-weight: 600; }

.alert-list .alert { display: flex; gap: 10px; align-items: center; padding: 10px 12px; margin-bottom: 8px; border-radius: 12px; }
.alert-list .alert a { margin-left: auto; white-space: nowrap; }

.amount-pos { color: #b02a37; }
.amount-neg { color: #198754; }

.form-control, .form-select, .btn { min-height: 44px; }
.btn-sm { min-height: 34px; }
.form-control-lg { font-size: 1.15rem; }
.form-label { font-weight: 500; font-size: .88rem; margin-bottom: 4px; }
.btn-block-mobile { width: 100%; }
@media (min-width: 576px) { .btn-block-mobile { width: auto; } }
.sticky-actions { position: sticky; bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom)); background: var(--bs-tertiary-bg); padding: 10px 0; z-index: 5; }
@media (min-width: 992px) { .sticky-actions { bottom: 0; } }

.nav-pills.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 6px; }
.nav-pills.scroll::-webkit-scrollbar { display: none; }
.nav-pills.scroll .nav-link { white-space: nowrap; border-radius: 20px; background: var(--bs-body-bg); color: var(--bs-body-color); padding: 8px 14px; }
.nav-pills.scroll .nav-link.active { background: var(--brand); color: #fff; }

.empty-state { text-align: center; padding: 36px 16px; color: var(--bs-secondary-color); }
.empty-state > i { font-size: 2.4rem; margin-bottom: 10px; opacity: .5; }

/* Meter entry */
.meter-row { display: grid; grid-template-columns: 52px 1fr; gap: 10px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--bs-border-color-translucent); }
.meter-row:last-child { border-bottom: 0; }
.meter-row .calc { font-size: .8rem; color: var(--bs-secondary-color); }
.meter-row.done { background: rgba(25,135,84,.06); }
.meter-row.flag { background: rgba(255,193,7,.12); }

/* Photos */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.photo-grid .ph { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--bs-secondary-bg); }
.photo-grid img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.photo-grid .del { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; min-height: 0; padding: 0; border-radius: 50%; }
.lowdata .photo-grid img:not(.loaded) { display: none; }
.ph .tap-load { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; font-size: .7rem; text-align: center; color: var(--bs-secondary-color); cursor: pointer; }
.lowdata .ph .tap-load { display: flex; }
.lowdata .ph img.loaded + .tap-load { display: none; }
.upload-progress { height: 6px; }
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.compare-grid .col-head { font-weight: 700; font-size: .85rem; text-align: center; padding: 6px; border-radius: 8px; }

.area-card { border-left: 4px solid var(--bs-border-color); }
.area-card.r-good { border-left-color: #198754; }
.area-card.r-fair { border-left-color: #0dcaf0; }
.area-card.r-poor { border-left-color: #ffc107; }
.area-card.r-damaged { border-left-color: #dc3545; }

/* Statement / receipt (printable) */
.doc-paper { background: var(--bs-body-bg); border-radius: 14px; padding: 18px; box-shadow: 0 1px 3px rgba(0,0,0,.07); }
.doc-paper table { font-size: .9rem; }
.doc-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; border-bottom: 2px solid var(--brand); padding-bottom: 10px; margin-bottom: 12px; }
.doc-head .prop { font-weight: 800; font-size: 1.1rem; color: var(--brand); }
.void-stamp { border: 3px solid #dc3545; color: #dc3545; font-weight: 800; font-size: 1.6rem; padding: 4px 14px; transform: rotate(-8deg); display: inline-block; }

.stmt-items td { border-top: 0; padding: 0 8px 8px 24px !important; font-size: .82rem; color: var(--bs-secondary-color); }
.doc-paper .table td, .doc-paper .table th { padding-left: 4px; padding-right: 4px; }

/* DataTables on phones */
div.dt-container .dt-search input { min-height: 40px; width: 100% !important; margin-left: 0 !important; }
div.dt-container .dt-search label { display: none; }
div.dt-container .dt-layout-row { margin: 6px 0 !important; }
table.dataTable { width: 100% !important; }
.table-card { background: var(--bs-body-bg); border-radius: 14px; padding: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.07); }

.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: radial-gradient(circle at 85% 8%, rgba(255,255,255,.07) 0 60px, transparent 61px 100px, rgba(255,255,255,.05) 101px 102px, transparent 103px 150px, rgba(255,255,255,.04) 151px 152px, transparent 153px), linear-gradient(165deg, #2c3a7c, #26326c 55%, #1b2453); }
.auth-card { width: 100%; max-width: 400px; border-radius: 18px; }

.toast { border-radius: 12px; }
.chart-box { position: relative; height: 220px; }

@media print {
  .appbar, .bottom-nav, .sidebar, .no-print, .offcanvas, .toast-container, .net-banner { display: none !important; }
  body, .content { background: #fff !important; padding: 0 !important; }
  .doc-paper { box-shadow: none; padding: 0; }
  [data-bs-theme="dark"] body { color: #000; }
  a { text-decoration: none; color: #000; }
}

/* Whole date box opens the calendar */
input[type=date]:not([readonly]):not(:disabled), input[type=month]:not([readonly]):not(:disabled), input[type=datetime-local]:not([readonly]):not(:disabled) { cursor: pointer; }

/* Tab rows that must stay fully visible: wrap onto two lines on phones instead of scrolling off-screen */
.nav-pills.wrap-sm { flex-wrap: wrap; gap: 6px; }
.nav-pills.wrap-sm .nav-link { white-space: nowrap; border-radius: 20px; background: var(--bs-body-bg); color: var(--bs-body-color); padding: 7px 13px; }
.nav-pills.wrap-sm .nav-link.active { background: var(--brand); color: #fff; }

/* Rent notice letters */
.doc-paper.letter { line-height: 1.6; margin-bottom: 1.25rem; }
@media print { .letter-break { break-after: page; page-break-after: always; } .doc-paper.letter { margin-bottom: 0; } }

/* Building switcher */
.building-select.on-dark { background-color: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.25); }
.building-select.on-dark option { color: #000; }
.appbar-title .appbar-sub { display: block; font-size: .72rem; font-weight: 400; opacity: .8; line-height: 1.1; }
.building-card { color: inherit; transition: box-shadow .15s, transform .15s; }
.building-card:hover { box-shadow: 0 .4rem 1rem rgba(0,0,0,.12) !important; transform: translateY(-1px); color: inherit; }


/* =====================================================================
   Navy theme — inspired by the flight-booking design reference:
   navy headers with faint rings, white rounded cards on soft grey,
   pill-shaped active states, navy tints for chips.
   ===================================================================== */
/* Rings decoration used on navy surfaces */
.appbar, .sidebar {
  background-color: var(--brand);
  background-image:
    radial-gradient(circle at 92% -30%, transparent 0 46px, rgba(255,255,255,.07) 47px 48px, transparent 49px 78px, rgba(255,255,255,.05) 79px 80px, transparent 81px 112px, rgba(255,255,255,.04) 113px 114px, transparent 115px);
}
.appbar { box-shadow: 0 2px 10px rgba(var(--brand-rgb), .25); }
.sidebar { background-image: radial-gradient(circle at 110% 4%, transparent 0 40px, rgba(255,255,255,.06) 41px 42px, transparent 43px 80px, rgba(255,255,255,.05) 81px 82px, transparent 83px 120px, rgba(255,255,255,.04) 121px 122px, transparent 123px); }
.sidebar .nav-link { margin: 2px 10px; border-left: 0; border-radius: 12px; padding: 9px 12px; }
.sidebar .nav-link.active { background: #fff; color: var(--brand); font-weight: 600; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.sidebar .nav-link.active i { color: var(--brand); }
.building-select.on-dark { border-radius: 12px; }
@media (min-width: 992px) {
  .appbar { background: var(--bs-body-bg); background-image: none; color: var(--bs-body-color); box-shadow: 0 1px 0 rgba(0,0,0,.05); }
}

/* Cards & lists: white, rounded, soft shadow */
.card { border-radius: var(--card-radius); }
.card.shadow-sm, .list-card, .table-card, .stat-card { box-shadow: 0 2px 12px rgba(var(--brand-rgb), .07) !important; }
.list-card, .table-card { border-radius: var(--card-radius); }
.card-header { background: transparent; font-weight: 600; border-bottom-color: rgba(var(--brand-rgb), .08); }
.section-title { color: var(--brand); letter-spacing: .04em; }
[data-bs-theme="dark"] .section-title { color: var(--bs-primary); }

/* Buttons & inputs: rounded like the reference */
.btn { border-radius: 12px; }
.btn-lg { border-radius: 14px; }
.btn-sm { border-radius: 10px; }
.form-control, .form-select { border-radius: 12px; border-color: rgba(var(--brand-rgb), .16); }
.form-control:focus, .form-select:focus { border-color: var(--bs-primary); box-shadow: 0 0 0 .2rem rgba(var(--bs-primary-rgb), .18); }
.input-group > .form-control, .input-group > .btn { border-radius: 12px; }
.input-group > :not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-group > :not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }

/* Tabs / pills: navy pill when active, soft tint otherwise */
.nav-pills .nav-link { border-radius: 999px; }
.nav-pills.scroll .nav-link, .nav-pills.wrap-sm .nav-link { background: var(--bs-body-bg); box-shadow: 0 1px 4px rgba(var(--brand-rgb), .08); }
.nav-pills .nav-link.active, .nav-pills.scroll .nav-link.active, .nav-pills.wrap-sm .nav-link.active { background: var(--brand); color: #fff; box-shadow: 0 3px 10px rgba(var(--brand-rgb), .3); }

/* Bottom navigation: active tab gets a navy pill (like the reference's Home tab) */
.bottom-nav { border-top: 0; box-shadow: 0 -4px 16px rgba(var(--brand-rgb), .08); border-radius: 18px 18px 0 0; }
.bottom-nav a.active:not(.fab) i { background: var(--brand); color: #fff; border-radius: 999px; padding: 4px 16px; font-size: 1.05rem; }
.bottom-nav a.active:not(.fab) { color: var(--brand); }
[data-bs-theme="dark"] .bottom-nav a.active:not(.fab) { color: var(--bs-primary); }

/* Stat icons, quick actions, avatars, chips in navy tints */
.stat-icon.text-bg-primary, .stat-icon.text-bg-success { background: var(--brand) !important; color: #fff !important; }
.quick-actions a { border-radius: var(--card-radius); }
.quick-actions a i { color: var(--brand); }
[data-bs-theme="dark"] .quick-actions a i { color: var(--bs-primary); }
.avatar { background: var(--brand-light); color: var(--brand); }
.unit-chip.occupied { background: var(--brand-light); color: var(--brand); }
.unit-tile { border-radius: 14px; }
.unit-tile.occupied { border-top-color: var(--brand); }
.badge.text-bg-success { background-color: var(--brand) !important; }
.progress-bar.bg-success { background-color: var(--brand) !important; }
.alert { border-radius: 14px; }

/* Documents (receipts, statements, letters) */
.doc-paper { border-radius: var(--card-radius); }
.doc-head { border-bottom-color: var(--brand); }
.doc-head .prop { color: var(--brand); }

/* Info colours in the navy family (instead of bright cyan) */
.alert-info { --bs-alert-bg: var(--brand-light); --bs-alert-color: var(--brand); --bs-alert-border-color: rgba(var(--brand-rgb), .12); }
.btn-info { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-color: #fff; --bs-btn-hover-bg: var(--brand-dark); --bs-btn-hover-border-color: var(--brand-dark); --bs-btn-hover-color: #fff; --bs-btn-active-bg: var(--brand-dark); --bs-btn-active-color: #fff; }
.text-bg-info, .stat-icon.text-bg-info { background-color: #5b6bb5 !important; color: #fff !important; }
.alert-light { --bs-alert-bg: var(--bs-body-bg); }
