:root {
    --brand: #4338ca;
    --brand-dark: #362f9e;
    --brand-light: #eef1ff;
    --brand-50: #f5f6ff;
    --accent: #0891b2;
    --ink: #14171f;
    --ink-soft: #5b6270;
    --ink-faint: #9096a3;
    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface-alt: #fafbfd;
    --border: #e6e8f0;
    --border-strong: #d6d9e6;
    --success: #15803d;
    --success-bg: #ecfdf3;
    --success-border: #a7e3bd;
    --warning: #b45309;
    --warning-bg: #fffaeb;
    --warning-border: #fadf99;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --danger-border: #f5b9b9;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-xs: 0 1px 2px rgba(20, 23, 31, 0.05);
    --shadow: 0 1px 3px rgba(20, 23, 31, 0.06), 0 4px 10px -4px rgba(20, 23, 31, 0.08);
    --shadow-md: 0 8px 24px -6px rgba(20, 23, 31, 0.16);
    --shadow-focus: 0 0 0 3px rgba(67, 56, 202, 0.18);
    --sidebar-w: 248px;
}

* { box-sizing: border-box; }
::selection { background: var(--brand-light); color: var(--brand-dark); }

body {
    font-family: 'Montserrat', -apple-system, Segoe UI, Roboto, sans-serif;
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }
h1, h2, h3 { font-weight: 700; letter-spacing: -0.015em; color: var(--ink); }
h1 { font-size: 21px; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 30px 0 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-soft); font-weight: 700; }
h3 { font-size: 14px; margin: 0 0 12px; }
small { color: var(--ink-soft); }
code { background: var(--surface-alt); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; font-size: 12px; }

/* ---------- Auth screens ---------- */
.layout-auth {
    display: flex; align-items: center; justify-content: center; min-height: 100vh;
    background:
        radial-gradient(circle at 15% 20%, rgba(255,255,255,0.10) 0, transparent 45%),
        radial-gradient(circle at 85% 80%, rgba(255,255,255,0.08) 0, transparent 45%),
        linear-gradient(135deg, #4338ca 0%, #6d28d9 55%, #0891b2 100%);
    padding: 20px;
}
.auth-shell {
    width: 100%; max-width: 392px; background: var(--surface); border-radius: var(--radius-lg);
    padding: 40px 36px; box-shadow: var(--shadow-md);
}
.auth-brand { font-size: 22px; font-weight: 800; margin-bottom: 6px; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.auth-brand span { color: var(--brand); }
.auth-shell h2 { color: var(--ink-soft); font-weight: 500; font-size: 13.5px; margin: 0 0 24px; text-transform: none; letter-spacing: 0; }
.auth-shell label { display: block; margin-bottom: 15px; font-size: 13px; font-weight: 600; color: var(--ink); }
.auth-shell input {
    width: 100%; padding: 11px 13px; margin-top: 6px; box-sizing: border-box;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-family: inherit; font-size: 14px;
    background: var(--surface-alt); transition: border-color .15s, box-shadow .15s, background .15s;
}
.auth-shell input:focus { outline: none; border-color: var(--brand); box-shadow: var(--shadow-focus); background: var(--surface); }
.auth-shell button {
    width: 100%; padding: 12px; background: var(--brand); color: #fff; border: none; border-radius: var(--radius-sm);
    cursor: pointer; font-family: inherit; font-weight: 700; font-size: 14px; margin-top: 6px;
    transition: background .15s, transform .1s;
}
.auth-shell button:hover { background: var(--brand-dark); }
.auth-shell button:active { transform: scale(0.98); }
.auth-shell p { text-align: center; margin-top: 18px; font-size: 13px; }


/* ---------- Split login (form left, demo tiles right) ---------- */
.auth-split {
    width: 100%; max-width: 1080px; min-height: 620px; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    background: var(--surface); border-radius: 22px; overflow: hidden;
    box-shadow: 0 30px 70px -20px rgba(15, 12, 60, 0.55), 0 0 0 1px rgba(255,255,255,0.12);
    animation: authIn .5s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes authIn { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
.auth-split:not(:has(.auth-right)) { max-width: 480px; grid-template-columns: 1fr; }
.auth-left { padding: 40px 48px 28px; display: flex; flex-direction: column; }
.auth-left .auth-brand { margin-bottom: 0; font-size: 20px; }
.auth-left .auth-brand b { font-weight: 800; }
.auth-left .brand-mark {
    width: 32px; height: 32px; border-radius: 10px; color: #fff; display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--brand), var(--accent)); box-shadow: 0 6px 14px -4px rgba(67,56,202,.55);
}
.auth-form-wrap { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 28px 0; }
.auth-left h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; margin: 0 0 6px; }
.auth-sub { color: var(--ink-soft); margin: 0 0 26px; font-size: 14px; }
.auth-left .error { margin-bottom: 18px; }
.auth-form label { display: block; margin-bottom: 16px; font-size: 12.5px; font-weight: 700; color: var(--ink); }
.auth-form .field { position: relative; display: block; margin-top: 7px; }
.auth-form .field svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-faint); pointer-events: none; transition: color .15s; }
.auth-form .field input { padding-left: 42px; margin-top: 0; }
.auth-form .field:focus-within svg { color: var(--brand); }
.auth-form input {
    width: 100%; padding: 13px 14px; border: 1.5px solid var(--border); border-radius: 10px; font: inherit; font-weight: 500;
    background: var(--surface-alt); transition: border-color .15s, box-shadow .15s, background .15s;
}
.auth-form input[name=code] { margin-top: 7px; text-align: center; letter-spacing: .5em; font-size: 20px; font-weight: 700; }
.auth-form input:focus { outline: none; border-color: var(--brand); box-shadow: var(--shadow-focus); background: var(--surface); }
.auth-form button {
    width: 100%; padding: 13px; margin-top: 4px; border: 0; border-radius: 10px; cursor: pointer; color: #fff; font: inherit; font-weight: 700; font-size: 14.5px;
    background: linear-gradient(135deg, var(--brand), #6d28d9); box-shadow: 0 8px 18px -6px rgba(67,56,202,.6);
    transition: transform .12s, box-shadow .15s, filter .15s;
}
.auth-form button:hover { filter: brightness(1.08); box-shadow: 0 12px 22px -6px rgba(67,56,202,.65); transform: translateY(-1px); }
.auth-form button:active { transform: scale(.985); }
.auth-links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 20px; font-size: 13px; font-weight: 600; }
.auth-foot { font-size: 12px; color: var(--ink-faint); }

.auth-right {
    padding: 36px 34px; display: flex; flex-direction: column; color: #fff; position: relative; overflow: hidden;
    background: radial-gradient(circle at 90% 0%, rgba(8,145,178,.55), transparent 50%), linear-gradient(160deg, #1e1b4b 0%, #312e81 55%, #4c1d95 100%);
}
.auth-right::before { content: ''; position: absolute; width: 340px; height: 340px; border-radius: 50%; left: -120px; bottom: -140px; background: rgba(255,255,255,.05); }
.demo-head { position: relative; margin-bottom: 20px; }
.demo-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 4px 11px; border-radius: 99px; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.22); }
.demo-badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 3px rgba(74,222,128,.25); }
.auth-right h2 { color: #fff; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; text-transform: none; margin: 12px 0 4px; }
.demo-head p { margin: 0; font-size: 13px; color: rgba(255,255,255,.72); }
.demo-grid { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.demo-form { margin: 0; display: contents; }
.auth-right .demo-tile {
    width: 100%; height: 100%; margin: 0; text-align: left; cursor: pointer; font: inherit; color: #fff;
    display: flex; align-items: flex-start; gap: 11px; padding: 13px 13px 13px 12px; position: relative;
    background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14); border-radius: 13px;
    backdrop-filter: blur(6px); transition: transform .15s, background .15s, border-color .15s, box-shadow .15s;
}
.auth-right .demo-tile:hover, .auth-right .demo-tile:focus-visible {
    background: rgba(255,255,255,.16); border-color: var(--tc, #818cf8); transform: translateY(-2px); outline: none;
    box-shadow: 0 10px 22px -10px rgba(0,0,0,.6), 0 0 0 1px var(--tc, #818cf8);
}
.auth-right .demo-tile:active { transform: scale(.98); }
.demo-ico { flex-shrink: 0; width: 38px; height: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center; color: #fff; background: var(--tc, #6366f1); box-shadow: 0 6px 12px -4px rgba(0,0,0,.4); }
.demo-txt { display: flex; flex-direction: column; min-width: 0; }
.demo-txt strong { font-size: 13.5px; font-weight: 700; line-height: 1.25; }
.demo-txt small { color: rgba(255,255,255,.66); font-size: 11.5px; line-height: 1.4; margin-top: 3px; }
.demo-go { position: absolute; top: 11px; right: 11px; opacity: 0; transform: rotate(45deg) translate(-3px, 3px); transition: opacity .15s, transform .15s; color: #fff; }
.demo-tile:hover .demo-go, .demo-tile:focus-visible .demo-go { opacity: .9; transform: rotate(45deg); }
.tone-indigo { --tc: #6366f1; } .tone-violet { --tc: #8b5cf6; } .tone-emerald { --tc: #10b981; } .tone-sky { --tc: #0ea5e9; }
.tone-amber { --tc: #f59e0b; } .tone-teal { --tc: #14b8a6; } .tone-orange { --tc: #f97316; } .tone-rose { --tc: #f43f5e; }
.tone-cyan { --tc: #06b6d4; } .tone-slate { --tc: #64748b; }
@media (max-width: 900px) {
    .layout-auth { align-items: flex-start; }
    .auth-split { grid-template-columns: 1fr; min-height: 0; }
    .auth-left { padding: 32px 26px 22px; }
    .auth-right { padding: 28px 22px; }
}
@media (max-width: 480px) { .demo-grid { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .auth-split { animation: none; } }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w); flex-shrink: 0; background: #14162a; color: #b7bdd6;
    padding: 18px 0 0; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow: hidden;
}
.sidebar-brand {
    font-size: 17px; font-weight: 800; color: #fff; padding: 4px 20px 16px; display: flex; align-items: center; gap: 9px; text-decoration: none; flex-shrink: 0;
}
.sidebar-brand .brand-mark {
    width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--brand), var(--accent));
    display: flex; align-items: center; justify-content: center; flex-shrink: 0; box-shadow: var(--shadow-xs);
}
.sidebar-brand .brand-mark svg { width: 17px; height: 17px; }
.sidebar-brand span { color: #a5b0ff; }
.sidebar-brand .brand-name { color: #fff; }
.nav-link {
    display: flex; align-items: center; gap: 11px; padding: 8px 12px; border-radius: var(--radius-sm);
    color: #b7bdd6; text-decoration: none; font-size: 13.5px; font-weight: 500; margin-bottom: 1px;
    transition: background .12s, color .12s;
}
.nav-link svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.85; }
.nav-link:hover { background: #1f2240; color: #fff; }
.nav-link.active { background: var(--brand); color: #fff; box-shadow: var(--shadow-xs); }
.nav-link.active svg { opacity: 1; }

.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex; justify-content: space-between; align-items: center; gap: 16px;
    padding: 14px 28px; background: var(--surface); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-size: 16.5px; font-weight: 700; }
.topbar-search {
    flex: 1; max-width: 360px; display: flex; align-items: center; gap: 8px;
    background: var(--surface-alt); border: 1px solid var(--border); border-radius: 999px;
    padding: 8px 14px; color: var(--ink-faint); font-size: 13px; cursor: pointer; transition: border-color .15s;
}
.topbar-search:hover { border-color: var(--border-strong); }
.topbar-search kbd {
    margin-left: auto; font-size: 10.5px; background: var(--surface); border: 1px solid var(--border);
    border-radius: 5px; padding: 2px 6px; font-family: inherit; color: var(--ink-faint);
}
.topbar-user { display: flex; align-items: center; gap: 12px; font-size: 13px; flex-shrink: 0; }
.topbar-name { font-weight: 600; }
.avatar {
    width: 30px; height: 30px; border-radius: 50%; background: var(--brand-light); color: var(--brand-dark);
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; flex-shrink: 0;
}
.role-pill {
    font-size: 10.5px; text-transform: uppercase; font-weight: 700; letter-spacing: 0.04em;
    padding: 3px 9px; border-radius: 20px; background: var(--brand-light); color: var(--brand-dark);
}
.logout-link {
    color: var(--ink-soft); border: 1px solid var(--border); padding: 6px 10px; border-radius: var(--radius-sm);
    display: flex; align-items: center; transition: border-color .15s, color .15s;
}
.logout-link:hover { border-color: var(--border-strong); color: var(--ink); }
.logout-link svg { width: 15px; height: 15px; }

.notif-bell { position: relative; display: flex; align-items: center; padding: 6px; border-radius: var(--radius-sm); color: var(--ink-soft); transition: background .15s; }
.notif-bell:hover { background: var(--surface-alt); color: var(--ink); }
.notif-bell svg { width: 18px; height: 18px; }
.notif-count {
    position: absolute; top: 1px; right: 1px; background: var(--danger); color: #fff; font-size: 9.5px;
    font-weight: 700; border-radius: 10px; padding: 1px 5px; line-height: 1.4; box-shadow: 0 0 0 2px var(--surface);
}

.content { max-width: var(--content-max); margin: 0 auto; padding: 22px 28px 40px; width: 100%; flex: 1; }
.content ul { padding-left: 20px; }
.content li { margin-bottom: 8px; }

/* ---------- Alerts ---------- */
.error { background: var(--danger-bg); color: #991b1b; border: 1px solid var(--danger-border); padding: 11px 15px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 16px; }
.success { background: var(--success-bg); color: #166534; border: 1px solid var(--success-border); padding: 11px 15px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 16px; }

/* ---------- Forms ---------- */
.form-box { max-width: 480px; background: var(--surface); padding: 26px; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.form-box label { display: block; margin-bottom: 15px; font-size: 13px; font-weight: 600; }
.form-box input, .form-box select {
    width: 100%; padding: 10px 12px; margin-top: 6px; box-sizing: border-box; border: 1.5px solid var(--border);
    border-radius: var(--radius-sm); font-family: inherit; font-size: 13.5px; background: var(--surface-alt);
    transition: border-color .15s, box-shadow .15s, background .15s;
}
.form-box input:focus, .form-box select:focus { outline: none; border-color: var(--brand); box-shadow: var(--shadow-focus); background: var(--surface); }
.form-box button {
    padding: 10px 22px; background: var(--brand); color: #fff; border: none; border-radius: var(--radius-sm);
    cursor: pointer; font-family: inherit; font-weight: 700; font-size: 13.5px; transition: background .15s, transform .1s;
}
.form-box button:hover { background: var(--brand-dark); }
.form-box button:active { transform: scale(0.98); }
.actions-row { display: flex; gap: 10px; margin-top: 4px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius-sm);
    border: 1.5px solid transparent; cursor: pointer; font-family: inherit; font-weight: 700; font-size: 13px;
    text-decoration: none; transition: background .15s, border-color .15s, transform .1s, box-shadow .15s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--border-strong); background: var(--surface-alt); color: var(--ink); }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn[disabled] { opacity: 0.6; cursor: default; pointer-events: none; }
.btn .btn-spinner {
    width: 13px; height: 13px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff; animation: btn-spin 0.6s linear infinite; display: none;
}
.btn-secondary .btn-spinner { border: 2px solid var(--border); border-top-color: var(--ink-soft); }
.btn.is-loading .btn-spinner { display: inline-block; }
.btn.is-loading .btn-label { opacity: 0.7; }
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* ---------- Cards / grids ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.building-card {
    display: block; background: var(--surface); border-radius: var(--radius); overflow: hidden;
    box-shadow: var(--shadow); border: 1px solid var(--border); text-decoration: none; color: inherit;
    transition: box-shadow .18s, transform .18s, border-color .18s;
}
.building-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--border-strong); }
.building-card img { width: 100%; height: 130px; object-fit: cover; display: block; }
.photo-placeholder { width: 100%; height: 130px; background: var(--brand-50); display: flex; align-items: center; justify-content: center; color: var(--brand); font-size: 13px; font-weight: 700; }
.building-card-body { padding: 15px; }
.building-card-body h3 { margin: 0 0 4px; font-size: 15px; }
.building-card-body p { margin: 2px 0; font-size: 12.5px; color: var(--ink-soft); }
.card-actions { padding: 0 15px 15px; display: flex; gap: 8px; }

.building-header { display: flex; gap: 22px; align-items: center; margin-bottom: 22px; background: var(--surface); padding: 20px; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.building-hero { width: 220px; height: 140px; object-fit: cover; border-radius: 10px; }

.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 8px; margin-bottom: 14px; }
.room-tile { background: var(--surface); border-radius: var(--radius-sm); padding: 9px 10px; font-size: 12px; line-height: 1.35; border: 1px solid var(--border); border-left: 4px solid var(--border-strong); box-shadow: var(--shadow-xs); transition: box-shadow .15s, transform .15s; }
.room-tile:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.room-tile.room-vacant { border-left-color: var(--ink-faint); }
.room-tile.room-occupied { border-left-color: var(--brand); }
.room-tile.room-maintenance { border-left-color: var(--warning); }
.room-tile-actions { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }

.badge { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; padding: 3px 9px; border-radius: 20px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.01em; }
.badge-paid { background: var(--success-bg); color: #166534; border: 1px solid var(--success-border); }
.badge-partial { background: var(--warning-bg); color: #92400e; border: 1px solid var(--warning-border); }
.badge-unpaid { background: var(--danger-bg); color: #991b1b; border: 1px solid var(--danger-border); }
.badge-unknown { background: var(--surface-alt); color: var(--ink-soft); border: 1px solid var(--border); }
.badge-repair { background: #fef3c7; color: #78350f; border: 1px solid var(--warning-border); }

/* ---------- Data tables (auto-enhanced by app.js: search + sort) ---------- */
.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.table-search {
    display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1.5px solid var(--border);
    border-radius: var(--radius-sm); padding: 7px 12px; font-size: 13px; max-width: 260px; flex: 1;
    transition: border-color .15s, box-shadow .15s;
}
.table-search:focus-within { border-color: var(--brand); box-shadow: var(--shadow-focus); }
.table-search svg { width: 15px; height: 15px; color: var(--ink-faint); flex-shrink: 0; }
.table-search input { border: none; outline: none; background: transparent; font-family: inherit; font-size: 13px; width: 100%; }
.table-count { font-size: 12px; color: var(--ink-faint); white-space: nowrap; }

.table-scroll { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.data-table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: 13px; }
.data-table th, .data-table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td:nth-child(1), .data-table th:nth-child(1) { white-space: normal; }
.data-table th {
    background: var(--surface-alt); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em;
    color: var(--ink-soft); position: sticky; top: 0; user-select: none; cursor: pointer;
}
.data-table th:hover { color: var(--ink); }
.data-table th .sort-arrow { display: inline-block; margin-left: 4px; opacity: 0.35; font-size: 10px; }
.data-table th.sorted-asc .sort-arrow, .data-table th.sorted-desc .sort-arrow { opacity: 1; color: var(--brand); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background .1s; }
.data-table tbody tr:hover { background: var(--brand-50); }
.data-table a { text-decoration: none; font-weight: 700; }
.data-table .row-hidden { display: none; }

/* ---------- Complaint threads ---------- */
.complaint-thread { background: var(--surface); border-radius: var(--radius); padding: 18px 22px; margin-bottom: 16px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.complaint-thread h3 { margin: 0 0 4px; font-size: 15px; }
.thread-meta { font-size: 12px; color: var(--ink-soft); margin: 0 0 10px; }
.thread-reply { background: var(--surface-alt); padding: 10px 14px; border-radius: var(--radius-sm); margin-top: 8px; font-size: 13px; }
.thread-reply-form { margin-top: 14px; display: flex; gap: 8px; }
.thread-reply-form input { flex: 1; padding: 9px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-family: inherit; }
.thread-reply-form button { padding: 9px 16px; background: var(--brand); color: #fff; border: none; border-radius: var(--radius-sm); cursor: pointer; font-weight: 700; font-family: inherit; }

/* ---------- Filters ---------- */
.filter-bar { display: flex; gap: 16px; align-items: flex-end; background: var(--surface); padding: 18px; border-radius: var(--radius); margin-bottom: 22px; font-size: 13px; box-shadow: var(--shadow); border: 1px solid var(--border); flex-wrap: wrap; }
.filter-bar label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; }
.filter-bar select, .filter-bar input { padding: 8px 11px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-family: inherit; }
.filter-bar button { padding: 9px 18px; background: var(--brand); color: #fff; border: none; border-radius: var(--radius-sm); cursor: pointer; font-weight: 700; font-family: inherit; }

.report-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 30px; }
@media (max-width: 860px) { .report-columns { grid-template-columns: 1fr; } }

/* ---------- Stat cards ---------- */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 26px; }
.stat-card { background: var(--surface); padding: 18px 20px; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); position: relative; overflow: hidden; }
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; width: 3px; height: 100%; background: var(--brand); opacity: 0.55; }
.stat-label { font-size: 11px; color: var(--ink-soft); margin-bottom: 7px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.stat-value { font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
.stat-sub { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.progress-bar { background: var(--border); border-radius: 6px; height: 7px; margin-top: 10px; overflow: hidden; }
.progress-bar-fill { background: linear-gradient(90deg, var(--brand), var(--accent)); height: 100%; border-radius: 6px; transition: width .4s ease; }
.chart-card { background: var(--surface); padding: 22px; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); margin-bottom: 26px; }

.readonly-note { background: var(--brand-light); color: var(--brand-dark); padding: 11px 15px; border-radius: var(--radius-sm); font-size: 12.5px; margin-bottom: 18px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.readonly-note svg { width: 15px; height: 15px; flex-shrink: 0; }

.toolbar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }

/* ---------- Receipts / statements (print-friendly) ---------- */
.receipt-box { max-width: 560px; background: var(--surface); padding: 32px; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.receipt-header { text-align: center; margin-bottom: 20px; border-bottom: 2px solid var(--border); padding-bottom: 16px; }
.receipt-header h1 { margin: 0; font-size: 20px; }
.receipt-header p { margin: 4px 0 0; color: var(--ink-soft); font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; }
.receipt-meta { width: 100%; border-collapse: collapse; margin-bottom: 20px; font-size: 13.5px; }
.receipt-meta td { padding: 6px 0; border-bottom: 1px dashed var(--border); }
.receipt-meta td:first-child { color: var(--ink-soft); width: 45%; }
.receipt-amount { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
.receipt-amount td { padding: 10px 0; font-size: 14px; }
.receipt-amount .amount { font-size: 22px; font-weight: 800; text-align: right; color: var(--success); }
.receipt-footer { text-align: center; color: var(--ink-soft); font-size: 13px; margin-top: 10px; }

@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .main-area, .content { margin: 0 !important; padding: 0 !important; max-width: 100% !important; }
    body { background: #fff !important; }
    .receipt-box { box-shadow: none; border: none; }
}

/* ---------- Command palette ---------- */
.cmdk-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(20, 23, 31, 0.45); z-index: 100;
    align-items: flex-start; justify-content: center; padding-top: 12vh;
}
.cmdk-backdrop.open { display: flex; }
.cmdk-box { width: 100%; max-width: 520px; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); overflow: hidden; }
.cmdk-input-row { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.cmdk-input-row svg { width: 17px; height: 17px; color: var(--ink-faint); flex-shrink: 0; }
.cmdk-input-row input { flex: 1; border: none; outline: none; font-family: inherit; font-size: 15px; background: transparent; }
.cmdk-input-row kbd { font-size: 11px; background: var(--surface-alt); border: 1px solid var(--border); border-radius: 5px; padding: 2px 7px; color: var(--ink-faint); }
.cmdk-results { max-height: 320px; overflow-y: auto; padding: 8px; }
.cmdk-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13.5px; color: var(--ink); }
.cmdk-item svg { width: 15px; height: 15px; color: var(--ink-soft); flex-shrink: 0; }
.cmdk-item.active { background: var(--brand-light); color: var(--brand-dark); }
.cmdk-item.active svg { color: var(--brand-dark); }
.cmdk-empty { padding: 20px; text-align: center; color: var(--ink-faint); font-size: 13px; }

/* ---------- Misc ---------- */
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }

/* =====================================================================
   v2: shell (grouped sidebar, solid fixed footer), tables, modals,
   wizards, dashboard cards, accounting, exports
   ===================================================================== */
:root { --bar-h: 46px; --bar-bg: #14162a; --content-max: 1320px; }

/* --- Sidebar --- */
.sidebar-nav { overflow-y: auto; padding: 0 12px 12px; flex: 1; scrollbar-width: thin; scrollbar-color: #2b2f52 transparent; }
.sidebar-nav::-webkit-scrollbar { width: 6px; } .sidebar-nav::-webkit-scrollbar-thumb { background: #2b2f52; border-radius: 6px; }
.nav-link.nav-sub { padding: 7px 12px 7px 14px; font-size: 13px; }
.nav-section { margin: 2px 0; }
.nav-section-head {
    width: 100%; display: flex; align-items: center; gap: 11px; padding: 9px 12px; border: 0; background: transparent; cursor: pointer;
    color: #b7bdd6; font: inherit; font-size: 13.5px; font-weight: 600; border-radius: var(--radius-sm); text-align: left; transition: background .12s, color .12s;
}
.nav-section-head:hover { background: #1f2240; color: #fff; }
.nav-section-head svg:first-child { width: 17px; height: 17px; opacity: .85; flex-shrink: 0; }
.nav-section-head span:not(.nav-emoji) { flex: 1; text-align: left; font-size: 13px; letter-spacing: 0; }
.nav-section-head .nav-emoji { flex: none; }
.nav-section-head svg:last-child { width: 14px; height: 14px; transition: transform .2s; opacity: .6; }
.nav-section.open > .nav-section-head { color: #fff; }
.nav-section.open > .nav-section-head svg:last-child { transform: rotate(180deg); }
.nav-section-body { display: none; margin: 1px 0 4px 17px; padding-left: 8px; border-left: 1px solid #2b2f52; }
.nav-section.open > .nav-section-body { display: block; }
.sidebar-logout {
    flex-shrink: 0; height: var(--bar-h); display: flex; align-items: center; gap: 11px; padding: 0 22px;
    background: var(--bar-bg); color: #cfd3ea; font-size: 13.5px; font-weight: 600; text-decoration: none;
    border-top: 1px solid rgba(255,255,255,.09); transition: background .15s, color .15s;
}
.sidebar-logout svg { color: #ff8a8a; }
.sidebar-logout:hover { background: #3b1d2a; color: #fff; }

/* --- Footer: normal flow (no permanently reserved space) --- */
.app-footer { padding: 14px 28px; color: var(--ink-faint); font-size: 12px; border-top: 1px solid var(--border); background: transparent; }
.app-footer strong { color: var(--ink-soft); }
.content > h1 { margin-bottom: 14px; }
.menu-toggle { display: none; border: 0; background: transparent; padding: 6px; color: var(--ink); cursor: pointer; border-radius: 8px; }
.sidebar-scrim { display: none; }
@media (max-width: 900px) {
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 90; width: min(84vw, 300px); height: 100%; transform: translateX(-100%); transition: transform .25s; box-shadow: none; }
    body.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
    body.nav-open { overflow: hidden; }
    body.nav-open .sidebar-scrim { display: block; position: fixed; inset: 0; background: rgba(20,23,31,.5); z-index: 80; }
    .menu-toggle { display: inline-flex; }
    .topbar { padding: 10px 14px; gap: 10px; justify-content: flex-start; }
    .topbar-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
    .topbar-search, .topbar-name { display: none; }
    .topbar-search-btn { display: inline-flex; }
    .topbar-user { gap: 8px; }
    .content { padding: 16px 14px 24px; }
    .app-footer { padding: 12px 14px; }
}
@media (max-width: 640px) { .role-pill { display: none; } }
.topbar-search-btn { display: none; border: 0; background: transparent; padding: 6px; color: var(--ink-soft); cursor: pointer; border-radius: 8px; }
.topbar-search-btn:hover { background: var(--surface-alt); color: var(--ink); }
.nav-section-head:focus-visible, .nav-link:focus-visible, .menu-toggle:focus-visible { outline: 2px solid #a5b0ff; outline-offset: 1px; }

/* --- Page heading --- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head p { margin: 2px 0 0; color: var(--ink-soft); font-size: 13px; }
.crumbs { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 4px; }
.crumbs a { color: var(--ink-soft); } .crumbs a:hover { color: var(--brand); }

/* --- Table card (toolbar with search + top-right Add) --- */
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 22px; overflow: hidden; }
.table-toolbar { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); margin: 0; flex-wrap: wrap; }
.table-search { min-width: 220px; flex: 0 1 300px; }
.table-count { color: var(--ink-faint); font-size: 12px; }
.table-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.table-scroll { box-shadow: none; border: 0; border-radius: 0; }
.table-card .data-table { border: 0; }
.data-table th { background: var(--surface-alt); }
.btn-add { display: inline-flex; align-items: center; gap: 6px; }
.btn-add svg, .btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.table-pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--ink-soft); flex-wrap: wrap; }
.pager-btns { display: flex; gap: 4px; align-items: center; }
.pager-btns button { min-width: 30px; height: 30px; border: 1px solid var(--border); background: var(--surface); border-radius: 7px; cursor: pointer; font: inherit; font-size: 12.5px; color: var(--ink); }
.pager-btns button:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.pager-btns button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager-btns button:disabled { opacity: .4; cursor: default; }
.pager-gap { color: var(--ink-faint); }
.data-table td .btn + .btn, .data-table td form + .btn, .data-table td .btn + form { margin-left: 4px; }
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table tfoot td { font-weight: 700; background: var(--surface-alt); border-top: 2px solid var(--border-strong); }
.data-table tr.row-total td { font-weight: 700; background: var(--surface-alt); }
.data-table tr.row-head td { background: var(--brand-50); color: var(--brand-dark); font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; }

/* --- Modal --- */
.modal-backdrop { position: fixed; inset: 0; z-index: 200; background: rgba(20,23,31,.55); display: none; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; overflow-y: auto; backdrop-filter: blur(2px); }
.modal-backdrop.open { display: flex; animation: mfade .15s; }
@keyframes mfade { from { opacity: 0; } to { opacity: 1; } }
.modal-box { width: 100%; max-width: 560px; background: var(--surface); border-radius: var(--radius-lg); box-shadow: 0 24px 60px -12px rgba(0,0,0,.5); overflow: hidden; animation: mpop .2s cubic-bezier(.2,.8,.2,1); }
@keyframes mpop { from { transform: translateY(14px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid var(--border); background: var(--surface-alt); }
.modal-head h3 { margin: 0; font-size: 15.5px; }
.modal-close { border: 0; background: transparent; font-size: 26px; line-height: 1; cursor: pointer; color: var(--ink-faint); padding: 0 4px; }
.modal-close:hover { color: var(--ink); }
.modal-box form.in-modal { max-width: none; border: 0; box-shadow: none; border-radius: 0; margin: 0; padding: 20px 22px 22px; }
.modal-box form.in-modal .form-actions, .form-actions { display: flex; gap: 10px; margin-top: 8px; }

/* --- Forms (extra controls) --- */
.form-box select, .form-box textarea, .form-box input[type=date], .form-box input[type=number], .form-box input[type=file] {
    width: 100%; padding: 10px 12px; margin-top: 6px; box-sizing: border-box; border: 1.5px solid var(--border);
    border-radius: var(--radius-sm); font-family: inherit; font-size: 13.5px; background: var(--surface-alt);
}
.form-box textarea { min-height: 80px; resize: vertical; }
.form-box input[type=checkbox], .form-box input[type=radio] { width: auto !important; margin: 0 6px 0 0 !important; display: inline-block; }
.form-box textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--shadow-focus); background: var(--surface); }
.form-box.wide { max-width: 760px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.form-hint { font-size: 12px; color: var(--ink-faint); font-weight: 400; margin-top: 4px; display: block; }
.btn-secondary.btn-link { background: transparent; border-color: transparent; }

/* --- Wizard --- */
.wizard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px 26px; max-width: 820px; margin-bottom: 24px; }
.wiz-steps { list-style: none; display: flex; gap: 0; margin: 0 0 24px; padding: 0 !important; counter-reset: s; }
.wiz-steps li { flex: 1; display: flex; align-items: center; gap: 9px; font-size: 12.5px; font-weight: 600; color: var(--ink-faint); position: relative; margin: 0; }
.wiz-steps li:not(:last-child)::after { content: ''; flex: 1; height: 2px; background: var(--border); margin: 0 12px; border-radius: 2px; }
.wiz-dot { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--surface-alt); border: 2px solid var(--border-strong); font-size: 12px; font-weight: 700; flex-shrink: 0; transition: all .2s; }
.wiz-steps li.on { color: var(--brand); } .wiz-steps li.on .wiz-dot { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 0 0 4px var(--brand-light); }
.wiz-steps li.done { color: var(--success); } .wiz-steps li.done .wiz-dot { background: var(--success); border-color: var(--success); color: #fff; }
.wiz-steps li.done:not(:last-child)::after { background: var(--success); }
.wiz-panel { display: none; } .wiz-panel.on { display: block; animation: mfade .2s; }
.wiz-panel h3 { margin: 0 0 4px; font-size: 16px; } .wiz-panel > p { margin: 0 0 16px; color: var(--ink-soft); font-size: 13px; }
.wiz-panel label { display: block; margin-bottom: 14px; font-size: 13px; font-weight: 600; }
.wiz-panel label > input, .wiz-panel label > select, .wiz-panel label > textarea {
    width: 100%; padding: 10px 12px; margin-top: 6px; box-sizing: border-box; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-family: inherit; font-size: 13.5px; background: var(--surface-alt);
}
.wiz-panel input:focus, .wiz-panel select:focus, .wiz-panel textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--shadow-focus); background: var(--surface); }
.wiz-panel input[type=checkbox] { width: auto; margin-right: 8px; }
.wiz-nav { display: flex; align-items: center; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.wiz-spacer { flex: 1; }
.review-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.review-table td { padding: 8px 4px; border-bottom: 1px dashed var(--border); } .review-table td:first-child { color: var(--ink-soft); width: 40%; }
@media (max-width: 640px) { .wiz-label { display: none; } .wizard { padding: 18px; } }

/* --- Dashboard: KPI cards, progress, module cards, compact rooms --- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi {
    position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px;
    box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; overflow: hidden; transition: transform .15s, box-shadow .15s;
}
a.kpi { color: inherit; } a.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kpi-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
.kpi-ico { width: 38px; height: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center; background: var(--tint, var(--brand-light)); color: var(--tone, var(--brand)); flex-shrink: 0; }
.kpi-ico svg { width: 19px; height: 19px; }
.kpi-value { font-size: 24px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; margin-top: 2px; }
.kpi-value small { font-size: 13px; font-weight: 600; color: var(--ink-soft); letter-spacing: 0; }
.kpi-sub { font-size: 12px; color: var(--ink-soft); }
.kpi .meter { height: 8px; background: var(--border); border-radius: 8px; overflow: hidden; margin-top: 8px; }
.kpi .meter > i { display: block; height: 100%; border-radius: 8px; background: var(--tone, var(--brand)); transition: width .6s cubic-bezier(.2,.8,.2,1); }
.kpi-meta { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-soft); margin-top: 5px; font-variant-numeric: tabular-nums; }
.kpi-meta b { color: var(--ink); }
.tone-brand { --tone: #4338ca; --tint: #eef1ff; } .tone-green { --tone: #16a34a; --tint: #ecfdf3; } .tone-amber { --tone: #d97706; --tint: #fffaeb; }
.tone-red { --tone: #dc2626; --tint: #fef2f2; } .tone-cyan { --tone: #0891b2; --tint: #ecfeff; } .tone-violet { --tone: #7c3aed; --tint: #f5f3ff; }
.tone-rose { --tone: #e11d48; --tint: #fff1f2; } .tone-slate { --tone: #475569; --tint: #f1f5f9; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 26px 0 12px; gap: 10px; }
.section-head h2 { margin: 0; } .section-head a { font-size: 12.5px; font-weight: 700; }
.dash-cols { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; margin-bottom: 20px; }
@media (max-width: 1000px) { .dash-cols { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.panel h3 { margin: 0 0 14px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.panel h3 svg { width: 16px; height: 16px; color: var(--brand); }
.mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.mod-card { display: flex; align-items: center; gap: 12px; padding: 13px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--ink); transition: transform .15s, box-shadow .15s, border-color .15s; }
.mod-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--tone, var(--brand)); color: var(--ink); }
.mod-card .kpi-ico { width: 36px; height: 36px; border-radius: 10px; }
.mod-card strong { display: block; font-size: 13.5px; } .mod-card small { color: var(--ink-soft); font-size: 11.5px; }
.room-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.room-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 8px; font-size: 12px; font-weight: 700; border: 1px solid var(--border); background: var(--surface-alt); color: var(--ink); }
.room-chip i { width: 8px; height: 8px; border-radius: 50%; background: #9096a3; display: inline-block; }
.room-chip.occupied i { background: var(--success); } .room-chip.maintenance i { background: var(--warning); } .room-chip.vacant i { background: #9096a3; }
.room-chip.occupied { background: var(--success-bg); border-color: var(--success-border); color: #166534; }
.room-chip.maintenance { background: var(--warning-bg); border-color: var(--warning-border); color: #92400e; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-soft); margin: 0 0 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; } .legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.floor-row { display: flex; align-items: flex-start; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.floor-row:last-child { border-bottom: 0; }
.floor-label { width: 62px; flex-shrink: 0; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); padding-top: 6px; }
.bld-summary { display: flex; flex-direction: column; gap: 14px; }
.bld-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 13px; }
.bld-row .meter { grid-column: 1 / -1; height: 7px; background: var(--border); border-radius: 7px; overflow: hidden; }
.bld-row .meter i { display: block; height: 100%; background: var(--tone, var(--brand)); border-radius: 7px; }
.bld-row a { font-weight: 700; }
.list-clean { list-style: none; padding: 0 !important; margin: 0; }
.list-clean li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--border); margin: 0; font-size: 13px; }
.list-clean li:last-child { border-bottom: 0; }

/* --- Buildings page: rich cards --- */
.bcard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.bcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; transition: transform .15s, box-shadow .15s; }
.bcard:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.bcard-media { position: relative; height: 128px; background: linear-gradient(135deg, #4338ca, #0891b2); display: flex; align-items: center; justify-content: center; color: rgba(255,255,255,.9); overflow: hidden; }
.bcard-media img { width: 100%; height: 100%; object-fit: cover; }
.bcard-media svg { width: 44px; height: 44px; opacity: .85; }
.bcard-badges { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; }
.bcard-badges .badge { margin: 0; box-shadow: var(--shadow-xs); }
.bcard-body { padding: 14px 16px 6px; flex: 1; }
.bcard-body h3 { margin: 0 0 2px; font-size: 15.5px; } .bcard-body h3 a { color: var(--ink); }
.bcard-loc { font-size: 12.5px; color: var(--ink-soft); display: flex; align-items: center; gap: 5px; }
.bcard-loc svg { width: 13px; height: 13px; }
.bcard-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 10px; }
.bcard-stat { background: var(--surface-alt); border-radius: 9px; padding: 8px 10px; }
.bcard-stat b { display: block; font-size: 15px; } .bcard-stat span { font-size: 10.5px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }
.bcard .meter { height: 7px; background: var(--border); border-radius: 7px; overflow: hidden; margin: 4px 0 4px; }
.bcard .meter i { display: block; height: 100%; border-radius: 7px; background: linear-gradient(90deg, var(--brand), var(--accent)); }
.bcard-meta { font-size: 11.5px; color: var(--ink-soft); display: flex; justify-content: space-between; }
.bcard-foot { padding: 12px 16px 14px; display: flex; gap: 8px; flex-wrap: wrap; }

/* --- Room tiles (compact) on building view --- */
.room-tile strong { font-size: 13px; }
.room-tile .badge { margin-top: 2px; }
.room-tile-actions .btn-sm { padding: 3px 8px; font-size: 11px; }
.floor-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); margin: 14px 0 8px; }

/* --- Accounting --- */
.subnav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; padding: 5px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; width: fit-content; max-width: 100%; }
.subnav a { padding: 7px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--ink-soft); display: inline-flex; align-items: center; gap: 6px; }
.subnav a svg { width: 14px; height: 14px; }
.subnav a:hover { background: var(--surface-alt); color: var(--ink); }
.subnav a.on { background: var(--brand); color: #fff; }
.export-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0 0 14px; }
.export-bar .spacer { flex: 1; }
.stmt-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 20px; }
.stmt-box h3 { margin: 0 0 2px; font-size: 16px; } .stmt-box .stmt-sub { color: var(--ink-soft); font-size: 12.5px; margin-bottom: 14px; }
.stmt { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.stmt td { padding: 7px 4px; border-bottom: 1px solid var(--border); } .stmt td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.stmt tr.grp td { font-weight: 700; padding-top: 14px; color: var(--brand-dark); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; border-bottom: 2px solid var(--border-strong); }
.stmt tr.tot td { font-weight: 700; background: var(--surface-alt); } .stmt tr.grand td { font-weight: 800; font-size: 15px; border-top: 2px solid var(--ink); border-bottom: 3px double var(--ink); }
.stmt td.indent { padding-left: 18px; } .neg { color: var(--danger); }
.pos { color: var(--success); }
.je-lines { width: 100%; border-collapse: collapse; margin: 6px 0 12px; font-size: 13px; }
.je-lines th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); padding: 6px 4px; }
.je-lines td { padding: 4px; } .je-lines select, .je-lines input { margin: 0 !important; padding: 8px 10px !important; width: 100%; }
.je-total { display: flex; justify-content: flex-end; gap: 22px; font-weight: 700; font-size: 13.5px; margin-bottom: 8px; }
.je-total .bad { color: var(--danger); } .je-total .good { color: var(--success); }
.table-actions .btn-secondary svg { width: 14px; height: 14px; }
@media print {
    .sidebar, .topbar, .app-footer, .no-print, .table-toolbar, .table-pager, .subnav, .export-bar, .menu-toggle { display: none !important; }
    .main-area { padding: 0 !important; } .content { max-width: 100%; padding: 0 !important; }
    .table-card, .stmt-box { box-shadow: none; border: 0; } .row-hidden { display: table-row !important; }
    .app-shell { display: block; }
}

/* misc defects */
.badge { margin-top: 0; }
.data-table td form { display: inline; margin: 0; }
.content h2 { margin: 26px 0 12px; }
.card-grid { gap: 14px; }
.demo-tile { text-align: left; }

/* --- Building view refinements --- */
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.panel-head .legend { margin: 0; }
.rt-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.rt-top .badge { margin: 0; font-size: 10px; padding: 2px 7px; }
.rt-sub { color: var(--ink-soft); font-size: 11.5px; }
.rt-tenant { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.actions-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.actions-row form { margin: 0; }
.brand-name { font-weight: 800; letter-spacing: -.01em; }
.floors { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 6px 22px; }
.floors .room-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-bottom: 6px; }
.floors .floor-title { margin-top: 12px; }

/* Lone primary action bars sit at the top right */
.page-actions { display: flex; justify-content: flex-end; margin: 0 0 14px; }
.toolbar:has(> a.btn-primary:only-child), .toolbar:has(> form:only-child) { justify-content: flex-end; }

.stmt tr.grp td:last-child { text-align: left; }
.stmt td.code { color: var(--ink-soft); width: 70px; }
@media (max-width: 640px) {
    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .kpi { padding: 12px; } .kpi-value { font-size: 19px; } .kpi-ico { width: 32px; height: 32px; }
}

/* =====================================================================
   v3: multi-column modals, consistent forms, responsive tables, row menus
   ===================================================================== */
.modal-box.cols-1 { max-width: 480px; }
.modal-box.cols-2 { max-width: 680px; }
.modal-box.cols-3 { max-width: 940px; }
.modal-backdrop { padding: 4vh 16px 16px; }
.modal-box { max-height: 92vh; display: flex; flex-direction: column; }
.modal-head { flex-shrink: 0; padding: 13px 20px; }
.modal-box form.in-modal { overflow-y: auto; padding: 16px 20px 18px; display: grid; gap: 0 16px; grid-template-columns: 1fr; align-content: start; }
.modal-box.cols-2 form.in-modal { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.modal-box.cols-3 form.in-modal { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.modal-box form.in-modal > .span-all, .modal-box form.in-modal > .form-actions { grid-column: 1 / -1; }
.modal-box form.in-modal label { margin-bottom: 12px; min-width: 0; }
.modal-box form.in-modal .form-grid { display: contents; }
.modal-box form.in-modal .form-actions { margin-top: 2px; }
@media (max-width: 820px) { .modal-box.cols-3 form.in-modal { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) {
    .modal-box form.in-modal, .modal-box.cols-2 form.in-modal, .modal-box.cols-3 form.in-modal { grid-template-columns: 1fr; }
    .modal-backdrop { padding: 0; align-items: stretch; }
    .modal-box { max-height: 100vh; border-radius: 0; }
}

/* Consistent form building blocks (replace ad-hoc inline styles) */
.form-box label.check, label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.form-box label.check input { width: auto; margin: 0; }
.form-box .full { grid-column: 1 / -1; }
.form-inline { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.form-inline label { margin: 0; flex: 1 1 160px; }
.form-inline .btn, .form-inline button { flex: 0 0 auto; }
.form-row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; margin: 0; }

/* Table actions */
.data-table td.actions { white-space: nowrap; }
.data-table td.actions > form, .data-table td.actions > a { display: inline-block; margin: 0 4px 0 0; }
.data-table td.actions > form > button { margin: 0; }
.data-table td.has-menu { width: 1%; text-align: right; }
details.row-menu { display: inline-block; }
details.row-menu > summary { list-style: none; cursor: pointer; width: 32px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 8px; color: var(--ink-soft); background: var(--surface); }
details.row-menu > summary::-webkit-details-marker { display: none; }
details.row-menu > summary:hover, details.row-menu[open] > summary { border-color: var(--brand); color: var(--brand); }
details.row-menu .row-menu-body { position: fixed; z-index: 120; min-width: 160px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-md); padding: 6px; display: flex; flex-direction: column; gap: 4px; text-align: left; }
details.row-menu .row-menu-body > * { margin: 0 !important; display: block; }
details.row-menu .row-menu-body .btn, details.row-menu .row-menu-body button { width: 100%; justify-content: flex-start; }
details.row-menu .row-menu-body form { width: 100%; }

/* Tables on phones: stacked cards with the column name beside each value */
@media (max-width: 640px) {
    .table-card .data-table, .table-card .data-table tbody, .table-card .data-table tr, .table-card .data-table td { display: block; width: 100%; }
    .table-card .data-table thead { display: none; }
    .table-card .data-table tr { border-bottom: 8px solid var(--bg); padding: 6px 0; }
    .table-card .data-table td { border: 0; padding: 6px 14px; display: flex; gap: 12px; justify-content: space-between; align-items: center; text-align: right; }
    .table-card .data-table td::before { content: attr(data-label); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-faint); text-align: left; flex: 0 0 38%; }
    .table-card .data-table td:not([data-label])::before, .table-card .data-table td[data-label=""]::before { content: none; }
    .table-card .data-table td.has-menu, .table-card .data-table td.actions { justify-content: flex-end; white-space: normal; flex-wrap: wrap; }
    .table-card .data-table td.has-menu::before, .table-card .data-table td.actions::before { flex: 1; }
    .table-card .data-table tfoot td { display: flex; }
    .table-toolbar { padding: 10px; } .table-search { flex: 1 1 100%; } .table-actions { margin-left: 0; width: 100%; }
    .table-actions .btn { flex: 1; justify-content: center; }
}
.input-sm { width: 130px; padding: 4px 8px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.panel h3 { margin-bottom: 10px; }
dl.kv { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 8px 14px; margin: 0; font-size: 13px; }
dl.kv dt { color: var(--ink-soft); font-weight: 600; } dl.kv dd { margin: 0; word-break: break-word; }
.modal-box form.in-modal > button[type=submit] { justify-self: start; }

/* v3 utilities replacing repeated inline styles */
.m-0{margin:0}.mt-10{margin-top:10px}.mt-16{margin-top:16px}.mb-20{margin-bottom:20px}
.inline-form{display:inline}.input-auto{width:auto;display:inline-block;margin-right:6px}
.w-110{width:110px}.nowrap{white-space:nowrap}.muted-60{opacity:.6}
.flex-between{display:flex;justify-content:space-between;gap:12px;align-items:center}
.flex-wrap-row{display:flex;gap:8px;flex-wrap:wrap;margin:10px 0 0}
.inline-flex-gap{display:inline-flex;gap:6px;align-items:center}
.mw-none{max-width:none}.w-auto{width:auto}.w-170{width:170px}.w-280{width:280px}.mt-6{margin-top:6px}.mt-8{margin-top:8px}.mt-14{margin-top:14px}.mt-24{margin-top:24px}.mt-36{margin-top:36px}
.mb-12{margin-bottom:12px}.mb-14{margin-bottom:14px}.mb-18{margin-bottom:18px}.mb-22{margin-bottom:22px}.mb-24{margin-bottom:24px}.pre-wrap{white-space:pre-wrap}.text-right{text-align:right}.text-danger{color:#dc2626}
.card-accent-success{border-left:4px solid var(--success,#16a34a)}.card-accent-warning{border-left:4px solid var(--warning,#d97706)}
.tok-break{word-break:break-all;user-select:all}.mw-640{max-width:640px}.mw-900{max-width:900px}.w-40{width:40px}
.nav-emoji{display:inline-flex;width:20px;justify-content:center;font-size:15px;line-height:1;flex:none}
.nav-link.nav-sub{position:relative;padding-left:40px}
.nav-branch{position:absolute;left:22px;top:0;bottom:0;width:10px;border-left:1px solid var(--border,#d9dce6)}
.nav-branch::after{content:"";position:absolute;left:0;top:50%;width:9px;border-top:1px solid var(--border,#d9dce6)}
.nav-sub:last-child .nav-branch{bottom:50%}
