/* GoLiving — Application CSS (Phase 1) */
:root {
    --gl-primary: #2563eb;
    --gl-primary-dark: #1d4ed8;
    --gl-success: #10b981;
    --gl-warning: #f59e0b;
    --gl-danger:  #ef4444;
    --gl-info:    #8b5cf6;
    --gl-bg:      #f5f7fb;
    --gl-card-bg: #ffffff;
    --gl-border:  #e5e7eb;
    --gl-text:    #1f2937;
    --gl-text-muted: #6b7280;
    --gl-sidebar-bg: #111827;
    --gl-sidebar-text: #cbd5e1;
    --gl-sidebar-text-active: #ffffff;
    --gl-sidebar-active: #1f2937;
    --gl-radius-lg: 14px;
    --gl-radius:    10px;
    --gl-radius-sm: 6px;
    --gl-shadow:    0 4px 14px rgba(15,23,42,.06);
    --gl-shadow-lg: 0 10px 30px rgba(15,23,42,.10);
    --gl-sidebar-w: 252px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    font-family: 'Inter', 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--gl-bg);
    color: var(--gl-text);
    margin: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
 * Auth layout
 * ============================================================ */
.auth-body {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 50%, #1d4ed8 100%);
    min-height: 100vh;
}
.auth-wrap {
    display: flex;
    min-height: 100vh;
}
.auth-side {
    flex: 1 1 50%;
    color: #fff;
    padding: 48px 56px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.auth-brand .auth-logo-img {
    display: block;
    width: min(300px, 82vw);
    height: auto;
    margin-bottom: 14px;
    border-radius: 8px;
    box-shadow: 0 14px 34px rgba(15,23,42,.14);
}
.auth-brand .auth-tagline {
    opacity: .9;
    font-size: 18px;
    margin: 0;
}
.auth-features {
    list-style: none;
    padding: 0;
    margin: 32px 0;
    font-size: 15px;
    opacity: .95;
}
.auth-features li {
    padding: 10px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}
.auth-features i { color: #93c5fd; }
.auth-foot { opacity: .7; font-size: 13px; }
.auth-main {
    flex: 1 1 50%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
}
.auth-card {
    width: 100%;
    max-width: 420px;
}
.auth-head h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 6px;
}
.auth-head p {
    color: var(--gl-text-muted);
    margin-bottom: 24px;
}

@media (max-width: 992px) {
    .auth-side { display: none; }
    .auth-main { background: transparent; }
    .auth-card {
        background: #fff;
        padding: 32px 24px;
        border-radius: var(--gl-radius-lg);
        box-shadow: var(--gl-shadow-lg);
    }
}

/* ============================================================
 * App shell (sidebar + topbar + content)
 * ============================================================ */
.app-shell {
    display: flex;
    min-height: 100vh;
}
.app-sidebar {
    width: var(--gl-sidebar-w);
    background: var(--gl-sidebar-bg);
    color: var(--gl-sidebar-text);
    flex-shrink: 0;
    padding: 16px 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    margin-bottom: 8px;
}
.sidebar-collapse-btn {
    margin-left: auto;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.12);
    color: rgba(255,255,255,.7);
    width: 30px; height: 30px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
}
.sidebar-collapse-btn:hover {
    background: rgba(255,255,255,.12);
    color: #fff;
}
.brand-logo-link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}
.brand-logo-mark {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    display: block;
    filter: drop-shadow(0 8px 16px rgba(15,118,110,.20));
}
.brand-logo-link:hover {
    color: inherit;
    text-decoration: none;
}
.brand-name {
    color: #fff;
    font-weight: 700;
    font-size: 18px;
}
.sidebar-nav { padding: 0 8px; }
.nav-section {
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    color: #6b7280;
    padding: 16px 12px 6px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    color: var(--gl-sidebar-text);
    text-decoration: none;
    border-radius: var(--gl-radius-sm);
    font-size: 14px;
    transition: background .15s, color .15s;
}
.nav-item i { width: 18px; text-align: center; opacity: .8; }
.nav-item:hover { background: var(--gl-sidebar-active); color: var(--gl-sidebar-text-active); }
.nav-item.active {
    background: var(--gl-sidebar-active);
    color: var(--gl-sidebar-text-active);
    box-shadow: inset 3px 0 0 var(--gl-primary);
}
.nav-item.disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
    height: 64px;
    background: #fff;
    border-bottom: 1px solid var(--gl-border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar-burger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--gl-border);
    width: 38px; height: 38px;
    border-radius: var(--gl-radius-sm);
    color: var(--gl-text);
    cursor: pointer;
    transition: background .15s;
}
.topbar-burger:hover { background: var(--gl-bg); }
/* Desktop: khi shell có class .sidebar-collapsed → sidebar thu hẹp về icon-only */
.app-shell.sidebar-collapsed .app-sidebar {
    width: 64px;
    overflow: hidden;
    transition: width .2s;
}
.app-shell.sidebar-collapsed .brand-name,
.app-shell.sidebar-collapsed .nav-section,
.app-shell.sidebar-collapsed .nav-item span {
    display: none;
}
.app-shell.sidebar-collapsed .sidebar-brand {
    padding: 8px 0 16px;
    flex-direction: column;
    gap: 12px;
    justify-content: center;
}
.app-shell.sidebar-collapsed .brand-logo-link {
    justify-content: center;
}
.app-shell.sidebar-collapsed .sidebar-collapse-btn {
    margin-left: 0;
    /* Đổi icon hướng phải bằng cách xoay 180deg */
    transform: rotate(180deg);
}
.app-shell.sidebar-collapsed .sidebar-nav { padding: 0 8px; }
.app-shell.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 10px 0;
}
.app-shell.sidebar-collapsed .nav-item i {
    font-size: 18px;
    opacity: 1;
}
.app-shell.sidebar-collapsed .nav-item.active {
    box-shadow: inset 3px 0 0 var(--gl-primary);
}
.topbar-title { font-weight: 600; font-size: 16px; flex: 1; }
.user-chip {
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px;
    border-radius: 999px;
    color: var(--gl-text);
}
.user-chip:hover { background: var(--gl-bg); }
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg,#2563eb,#1d4ed8);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 700;
}
.user-meta { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.user-name { font-weight: 600; font-size: 14px; }
.user-role { font-size: 12px; color: var(--gl-text-muted); }

.app-content { padding: 24px; flex: 1; }

@media (max-width: 992px) {
    .app-sidebar {
        position: fixed;
        left: -260px;
        transition: left .2s;
        z-index: 1050;
    }
    .app-sidebar.open { left: 0; }
    .app-content { padding: 16px; }
    /* Trên mobile: lớp .sidebar-collapsed không áp dụng (mobile có toggle riêng .open) */
    .app-shell.sidebar-collapsed .app-sidebar { width: var(--gl-sidebar-w); padding: 16px 0; }
}

/* ============================================================
 * Page chrome
 * ============================================================ */
.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}
.page-title { font-size: 24px; font-weight: 700; margin: 0; }
.page-subtitle { color: var(--gl-text-muted); margin: 4px 0 0; font-size: 14px; }

/* ============================================================
 * Stat cards
 * ============================================================ */
.stat-card {
    background: var(--gl-card-bg);
    border-radius: var(--gl-radius);
    padding: 18px;
    box-shadow: var(--gl-shadow);
    display: flex;
    align-items: center;
    gap: 14px;
}
.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 20px;
}
.stat-blue .stat-icon  { background: linear-gradient(135deg, #2563eb, #1d4ed8); }
.stat-green .stat-icon { background: linear-gradient(135deg, #10b981, #059669); }
.stat-amber .stat-icon { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-red .stat-icon    { background: linear-gradient(135deg, #ef4444, #dc2626); }
.stat-purple .stat-icon { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.stat-rose .stat-icon   { background: linear-gradient(135deg, #f43f5e, #e11d48); }
.stat-cyan .stat-icon   { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.stat-label { font-size: 13px; color: var(--gl-text-muted); }
.stat-value { font-size: 24px; font-weight: 700; line-height: 1.1; }

/* Dashboard: 6 thẻ thống kê gọn trên 1 hàng, nhãn không xuống dòng */
.dash-stats .stat-card { padding: 15px; gap: 11px; }
.dash-stats .stat-icon { width: 44px; height: 44px; font-size: 18px; border-radius: 11px; }
.dash-stats .stat-meta { min-width: 0; }
.dash-stats .stat-label { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-stats .stat-value { font-size: 22px; }
/* 7 thẻ trạng thái phòng trên 1 hàng ở màn rộng (Bootstrap chỉ có tới row-cols-6). */
@media (min-width: 1200px) {
    .row-cols-xl-7 > * { flex: 0 0 auto; width: 14.2857142857%; }
}
@media (max-width: 575.98px) {
    .dash-stats .stat-label { white-space: normal; }
}

/* Thẻ thống kê dạng link — bấm để xem danh sách phòng theo trạng thái.
   Bỏ hoàn toàn gạch chân/màu link mặc định ở mọi trạng thái. */
a.stat-link,
a.stat-link:hover,
a.stat-link:focus,
a.stat-link:active {
    text-decoration: none !important;
    color: inherit;
}
a.stat-link .stat-label,
a.stat-link .stat-value { text-decoration: none !important; }
a.stat-link { transition: transform .14s ease, box-shadow .14s ease; cursor: pointer; }
a.stat-link:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 24px rgba(15, 23, 42, .14);
}
a.stat-link:hover .stat-icon { transform: scale(1.06); }
.stat-icon { transition: transform .14s ease; }

/* Phân loại "Dọn dẹp" — màu tím, dùng nhất quán cho button + badge + text */
.text-cleaning  { color: #8b5cf6 !important; }
.btn-outline-cleaning {
    color: #8b5cf6;
    border: 1px solid #8b5cf6;
    background: #fff;
}
.btn-outline-cleaning:hover,
.btn-outline-cleaning:focus {
    color: #fff;
    background: #8b5cf6;
    border-color: #8b5cf6;
}
.badge-cleaning {
    background-color: rgba(139,92,246,.1);
    color: #8b5cf6;
    border: 1px solid rgba(139,92,246,.2);
}

/* ============================================================
 * Cards
 * ============================================================ */
.card {
    background: var(--gl-card-bg);
    border: 1px solid var(--gl-border);
    border-radius: var(--gl-radius);
    box-shadow: var(--gl-shadow);
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--gl-border);
    padding: 14px 16px;
    font-size: 14px;
}
.card-body { padding: 16px; }

.empty-chart, .empty-list {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: var(--gl-text-muted);
    padding: 36px 16px;
    text-align: center;
}
.empty-chart i { font-size: 36px; opacity: .35; margin-bottom: 12px; }

/* ============================================================
 * Forms / buttons (light tweaks over Bootstrap)
 * ============================================================ */
.btn-primary {
    background: var(--gl-primary);
    border-color: var(--gl-primary);
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--gl-primary-dark);
    border-color: var(--gl-primary-dark);
}
.form-control:focus {
    border-color: var(--gl-primary);
    box-shadow: 0 0 0 .2rem rgba(37,99,235,.18);
}

.identity-scan-panel {
    border: 1px solid #dbe4f0;
    border-radius: 8px;
    background: #f8fbff;
    padding: 12px;
}
.identity-scan-result {
    border-top: 1px solid #dbe4f0;
    padding-top: 12px;
}
.identity-scan-result .table {
    table-layout: fixed;
}
.identity-scan-result th,
.identity-scan-result td {
    overflow-wrap: anywhere;
}

/* ============================================================
 * Error pages
 * ============================================================ */
.error-body {
    background: var(--gl-bg);
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
}
.error-card {
    background: #fff;
    padding: 48px 40px;
    border-radius: var(--gl-radius-lg);
    box-shadow: var(--gl-shadow-lg);
    text-align: center;
    max-width: 480px;
    width: 100%;
}
.error-code {
    font-size: 96px;
    font-weight: 800;
    color: var(--gl-primary);
    line-height: 1;
    margin-bottom: 12px;
    letter-spacing: -2px;
}
.error-card h1 { font-size: 22px; margin-bottom: 8px; }
.error-card p { color: var(--gl-text-muted); margin-bottom: 24px; }

/* ============================================================
 * Utility (electricity/water) mode picker
 * ============================================================ */
[x-cloak] { display: none !important; }
.utility-box {
    background: #f9fafb;
    border: 1px solid var(--gl-border);
    border-radius: var(--gl-radius);
    padding: 10px 12px;
}
.utility-radio {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    background: #fff;
    border: 1px solid #ced4da;
    border-radius: 999px;
    font-size: 13px;
    cursor: pointer;
}
.utility-radio input { margin: 0; display: none; }
.utility-radio.active {
    background: var(--gl-primary);
    color: #fff;
    border-color: var(--gl-primary);
    font-weight: 600;
}

/* ============================================================
 * Ctrl+K Command Palette
 * ============================================================ */
.cmdk-trigger {
    background: var(--gl-bg);
    border: 1px solid var(--gl-border);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 13px;
    color: var(--gl-text-muted);
    display: inline-flex;
    align-items: center;
    margin-right: 12px;
    cursor: pointer;
    transition: border-color .15s;
}
.cmdk-trigger:hover { border-color: var(--gl-primary); color: var(--gl-text); }
.cmdk-trigger kbd {
    background: #fff;
    border: 1px solid var(--gl-border);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 11px;
    color: var(--gl-text-muted);
}
#gl-cmdk-overlay {
    position: fixed; inset: 0;
    background: rgba(15,23,42,.5);
    z-index: 1090;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 12vh;
}
#gl-cmdk-overlay.open { display: flex; }
.cmdk-modal {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(15,23,42,.35);
    width: 560px;
    max-width: 92vw;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 70vh;
}
.cmdk-input {
    border: none;
    outline: none;
    padding: 16px 20px;
    font-size: 16px;
    border-bottom: 1px solid var(--gl-border);
}
.cmdk-list {
    list-style: none;
    margin: 0;
    padding: 6px;
    overflow-y: auto;
    flex: 1;
}
.cmdk-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}
.cmdk-item:hover, .cmdk-item.active { background: #eef2f7; }
.cmdk-item i { width: 18px; text-align: center; color: var(--gl-primary); }
.cmdk-item .cmdk-name { flex: 1; }
.cmdk-item .cmdk-url { font-size: 11px; color: var(--gl-text-muted); font-family: monospace; }
.cmdk-foot {
    padding: 8px 16px;
    background: #f9fafb;
    border-top: 1px solid var(--gl-border);
    font-size: 11px;
    color: var(--gl-text-muted);
    display: flex;
    gap: 8px;
}
.cmdk-foot kbd {
    background: #fff;
    border: 1px solid var(--gl-border);
    border-radius: 4px;
    padding: 0 5px;
    font-size: 10px;
}

/* ============================================================
 * Installer
 * ============================================================ */
.install-body {
    background: var(--gl-bg);
    min-height: 100vh;
    padding: 24px;
}
.install-wrap {
    max-width: 760px;
    margin: 0 auto;
    background: #fff;
    border-radius: var(--gl-radius-lg);
    box-shadow: var(--gl-shadow-lg);
    overflow: hidden;
}
.install-head {
    background: linear-gradient(135deg,#1d4ed8,#2563eb);
    color: #fff;
    padding: 24px 28px;
}
.install-head h1 { margin: 0; font-size: 22px; font-weight: 700; }
.install-head p { margin: 6px 0 0; opacity: .9; }
.install-steps {
    display: flex;
    background: #f9fafb;
    border-bottom: 1px solid var(--gl-border);
    padding: 12px 20px;
    gap: 12px;
    font-size: 13px;
    color: var(--gl-text-muted);
    overflow-x: auto;
}
.install-step.active { color: var(--gl-primary); font-weight: 600; }
.install-step.done   { color: var(--gl-success); }
.install-body-wrap { padding: 28px; }
.req-table th { font-weight: 600; }
.req-ok   { color: var(--gl-success); }
.req-fail { color: var(--gl-danger); }

/* Chart.js container — khoá chiều cao cố định để canvas không tự co/giãn (resize loop).
   Dùng kèm options.maintainAspectRatio = false. */
.chart-wrap { position: relative; width: 100%; height: 300px; }
.chart-wrap canvas { display: block; }
.chart-wrap--sm { height: 240px; }
.chart-wrap--lg { height: 340px; }

/* ===== Dropdown "Xem bằng tài khoản" (impersonate) ===== */
.imp-menu { min-width: 290px; max-height: 74vh; overflow: auto; padding: 6px; border: 0; border-radius: 14px; box-shadow: 0 12px 32px rgba(15,23,42,.16); }
.imp-title { font-size: 12px; font-weight: 700; color: #475569; padding: 6px 8px 6px; display: flex; align-items: center; gap: 7px; }
.imp-title i { color: var(--gl-primary); }
.imp-group { display: flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #94a3b8; padding: 9px 8px 4px; }
.imp-dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.imp-item { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; border-radius: 10px; padding: 7px 8px; text-align: left; cursor: pointer; transition: background .12s; }
.imp-item:hover { background: #f1f5f9; }
.imp-item.active { background: #eef2ff; box-shadow: inset 0 0 0 1px #c7d2fe; }
.imp-av { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 14px; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 2px rgba(0,0,0,.18); }
.imp-info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.imp-name { font-size: 13.5px; font-weight: 600; color: #0f172a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.imp-name .fa-circle-check { color: var(--gl-primary); font-size: 11px; margin-left: 3px; }
.imp-mail { font-size: 11.5px; color: #94a3b8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.imp-badge { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; color: #334155; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 999px; padding: 3px 9px; }
.imp-badge i { font-size: 9px; color: #94a3b8; }
.imp-exit .imp-name { color: var(--gl-primary); }
.imp-empty { font-size: 12.5px; color: #94a3b8; padding: 10px 8px; line-height: 1.5; }

/* ============================================================
 * Smart reports — insight bar, KPI cards, date pills, gauge, heatmap
 * ============================================================ */

/* Dải nhận định tự động */
.insight-bar {
    display: flex; flex-wrap: wrap; gap: 10px 18px;
    background: linear-gradient(135deg, #eef2ff, #f0f9ff);
    border: 1px solid #e0e7ff;
    border-radius: var(--gl-radius);
    padding: 14px 16px;
    margin-bottom: 18px;
}
.insight-bar .insight-head {
    display: flex; align-items: center; gap: 8px;
    font-weight: 700; color: var(--gl-primary); white-space: nowrap;
}
.insight-list { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 0; padding: 0; list-style: none; }
.insight-list li { display: flex; align-items: center; gap: 7px; font-size: 13.5px; color: #334155; }
.insight-list li i { font-size: 12px; }
.insight-list li.good i { color: var(--gl-success); }
.insight-list li.bad  i { color: var(--gl-danger); }
.insight-list li.warn i { color: var(--gl-warning); }
.insight-list li.info i { color: var(--gl-primary); }

/* Thẻ KPI thông minh */
.kpi-card {
    position: relative; overflow: hidden;
    background: var(--gl-card-bg);
    border-radius: var(--gl-radius);
    box-shadow: var(--gl-shadow);
    padding: 16px 16px 0;
    height: 100%;
    display: flex; flex-direction: column;
    transition: transform .14s ease, box-shadow .14s ease;
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--gl-shadow-lg); }
.kpi-card::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--kpi-accent, var(--gl-primary)); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.kpi-icon {
    width: 40px; height: 40px; border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 17px;
    background: var(--kpi-accent, var(--gl-primary));
}
.kpi-blue   { --kpi-accent: linear-gradient(135deg, #2563eb, #1d4ed8); }
.kpi-green  { --kpi-accent: linear-gradient(135deg, #10b981, #059669); }
.kpi-red    { --kpi-accent: linear-gradient(135deg, #ef4444, #dc2626); }
.kpi-amber  { --kpi-accent: linear-gradient(135deg, #f59e0b, #d97706); }
.kpi-purple { --kpi-accent: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.kpi-cyan   { --kpi-accent: linear-gradient(135deg, #06b6d4, #0891b2); }
.kpi-slate  { --kpi-accent: linear-gradient(135deg, #64748b, #475569); }
.kpi-badge {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
}
.kpi-badge.up   { color: #047857; background: #d1fae5; }
.kpi-badge.down { color: #b91c1c; background: #fee2e2; }
.kpi-badge.flat { color: #475569; background: #f1f5f9; }
.kpi-label { font-size: 13px; color: var(--gl-text-muted); }
.kpi-value { font-size: 23px; font-weight: 800; line-height: 1.15; color: var(--gl-text); margin-top: 2px; }
.kpi-sub { font-size: 12px; color: var(--gl-text-muted); margin-top: 3px; }
.kpi-spark { margin: 8px -16px 0; height: 42px; }
.kpi-spark canvas { display: block; }

/* Bộ lọc thời gian nhanh — pills */
.date-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.date-presets .preset-pill {
    font-size: 12.5px; font-weight: 600;
    padding: 5px 12px; border-radius: 999px;
    border: 1px solid var(--gl-border); background: #fff; color: var(--gl-text);
    cursor: pointer; transition: all .12s ease;
}
.date-presets .preset-pill:hover { border-color: var(--gl-primary); color: var(--gl-primary); }
.date-presets .preset-pill.active { background: var(--gl-primary); border-color: var(--gl-primary); color: #fff; }

/* Gauge lấp đầy */
.gauge-wrap { position: relative; }
.gauge-center {
    position: absolute; left: 0; right: 0; bottom: 8px; text-align: center;
    pointer-events: none;
}
.gauge-center .gauge-pct { font-size: 30px; font-weight: 800; line-height: 1; }
.gauge-center .gauge-cap { font-size: 12px; color: var(--gl-text-muted); }

/* Heatmap theo tháng */
.heat-strip { display: flex; flex-wrap: wrap; gap: 6px; }
.heat-cell {
    flex: 1 1 64px; min-width: 56px;
    border-radius: 8px; padding: 10px 6px; text-align: center;
    color: #fff; position: relative;
}
.heat-cell .heat-month { font-size: 11px; opacity: .9; }
.heat-cell .heat-val { font-size: 15px; font-weight: 800; }
.heat-legend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--gl-text-muted); }
.heat-legend .heat-swatch { width: 16px; height: 12px; border-radius: 3px; display: inline-block; }

/* Badge mã (mã phiếu/HĐ/hóa đơn…) — gọn, monospace, tái dùng toàn hệ thống */
.code-badge {
    display: inline-block;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12.5px; font-weight: 700; letter-spacing: .3px;
    color: #334155; background: #f1f5f9; border: 1px solid #e2e8f0;
    border-radius: 6px; padding: 1px 8px; text-decoration: none; white-space: nowrap;
}
a.code-badge:hover { background: #e2e8f0; color: var(--gl-primary); }
.code-badge.code-pa { color: #be123c; background: #fff1f2; border-color: #fecdd3; }
.code-badge.code-sc { color: #b45309; background: #fffbeb; border-color: #fde68a; }
.code-badge.code-mt { color: #1d4ed8; background: #eff6ff; border-color: #bfdbfe; }

/* Banner "Việc cần làm" trên dashboard */
.todo-bar { border: 1px solid #fcd34d !important; background: linear-gradient(135deg, #fffbeb, #fff7ed); }
.todo-bar .todo-chip {
    display: inline-flex; align-items: center; gap: 6px;
    background: #fff; border: 1px solid #fde68a; border-radius: 999px;
    padding: 4px 12px; font-size: 13px; color: var(--gl-text); text-decoration: none; transition: all .12s ease;
}
.todo-bar .todo-chip:hover { border-color: #f59e0b; box-shadow: 0 3px 10px rgba(245,158,11,.18); transform: translateY(-1px); }

/* ============================================================
 * Fluxen-inspired refresh
 * ============================================================ */
:root {
    --gl-primary: #0f766e;
    --gl-primary-dark: #115e59;
    --gl-accent: #3b82f6;
    --gl-success: #16a34a;
    --gl-warning: #f59e0b;
    --gl-danger:  #dc2626;
    --gl-info:    #0891b2;
    --gl-bg:      #f6f7fb;
    --gl-soft:    #f8fafc;
    --gl-card-bg: #ffffff;
    --gl-border:  #e6e8ef;
    --gl-text:    #111827;
    --gl-text-muted: #6b7280;
    --gl-sidebar-bg: #ffffff;
    --gl-sidebar-text: #667085;
    --gl-sidebar-text-active: #0f172a;
    --gl-sidebar-active: #eef8f6;
    --gl-radius-lg: 8px;
    --gl-radius:    8px;
    --gl-radius-sm: 6px;
    --gl-shadow:    0 1px 2px rgba(16,24,40,.04), 0 10px 24px rgba(16,24,40,.045);
    --gl-shadow-lg: 0 20px 40px rgba(16,24,40,.10);
}

body {
    background:
        radial-gradient(circle at 18% -10%, rgba(20,184,166,.09), transparent 30%),
        radial-gradient(circle at 92% 6%, rgba(59,130,246,.08), transparent 28%),
        var(--gl-bg);
    color: var(--gl-text);
}

.app-shell { background: transparent; }
.app-sidebar {
    background: var(--gl-sidebar-bg);
    color: var(--gl-sidebar-text);
    border-right: 1px solid var(--gl-border);
    padding: 18px 12px;
}
.sidebar-brand {
    padding: 0 6px 18px;
    border-bottom: 0;
    margin-bottom: 10px;
}
.brand-name {
    color: #0f172a;
    font-size: 18px;
    letter-spacing: 0;
}
.sidebar-collapse-btn {
    background: #f8fafc;
    border-color: #e5e7eb;
    color: #667085;
}
.sidebar-collapse-btn:hover {
    background: #eef8f6;
    color: var(--gl-primary);
}
.sidebar-nav { padding: 0; }
.nav-section {
    color: #98a2b3;
    padding: 16px 10px 7px;
    letter-spacing: .06em;
}
.nav-item {
    color: var(--gl-sidebar-text);
    border-radius: 8px;
    padding: 10px 11px;
    margin: 2px 0;
    font-weight: 600;
}
.nav-item i {
    color: #98a2b3;
    opacity: 1;
}
.nav-item:hover {
    background: #f7fafc;
    color: #0f172a;
}
.nav-item:hover i { color: var(--gl-primary); }
.nav-item.active {
    background: var(--gl-sidebar-active);
    color: var(--gl-sidebar-text-active);
    box-shadow: inset 3px 0 0 var(--gl-primary);
}
.nav-item.active i { color: var(--gl-primary); }

.app-main { background: transparent; }
.app-topbar {
    height: 70px;
    background: rgba(255,255,255,.88);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(230,232,239,.9);
    padding: 0 28px;
}
.topbar-burger {
    border-radius: 8px;
    border-color: var(--gl-border);
    background: #fff;
}
.topbar-title {
    font-size: 15px;
    color: #475467;
}
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}
.cmdk-trigger {
    min-width: 250px;
    justify-content: flex-start;
    background: #f8fafc;
    border-color: #e5e7eb;
    border-radius: 8px;
    padding: 9px 12px;
    margin-right: 0;
    color: #667085;
}
.cmdk-trigger:hover {
    background: #fff;
    border-color: #99d6cf;
    color: var(--gl-primary);
}
.cmdk-trigger kbd {
    margin-left: auto !important;
    border-radius: 6px;
}
.user-chip {
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 5px 7px 5px 5px;
}
.user-chip:hover {
    background: #f8fafc;
    border-color: var(--gl-border);
}
.user-avatar {
    border-radius: 8px;
    background: linear-gradient(135deg, #0f766e, #3b82f6);
}
.user-role { color: #98a2b3; }
.app-content {
    padding: 28px;
    max-width: 1680px;
    width: 100%;
}

.page-head {
    align-items: center;
    margin-bottom: 18px;
}
.page-title {
    font-size: 28px;
    letter-spacing: 0;
}
.page-subtitle { color: #667085; }

.card {
    border-color: var(--gl-border);
    border-radius: 8px;
    box-shadow: var(--gl-shadow);
}
.card-header {
    padding: 15px 18px;
    color: #101828;
    border-bottom-color: var(--gl-border);
}
.card-header strong {
    font-size: 14px;
    font-weight: 700;
}
.card-body { padding: 18px; }
.table {
    --bs-table-bg: transparent;
    --bs-table-border-color: #eef0f5;
    color: #344054;
}
.table > :not(caption) > * > * {
    padding: .78rem .9rem;
}
.table-sm > :not(caption) > * > * {
    padding: .62rem .78rem;
}
.table tbody tr:hover { background: #fafcff; }
.badge {
    border-radius: 999px;
    font-weight: 700;
    padding: .38em .62em;
}
.btn {
    border-radius: 8px;
    font-weight: 650;
}
.btn-primary {
    background: var(--gl-primary);
    border-color: var(--gl-primary);
}
.btn-primary:hover,
.btn-primary:focus {
    background: var(--gl-primary-dark);
    border-color: var(--gl-primary-dark);
}
.btn-outline-secondary {
    border-color: #d0d5dd;
    color: #475467;
}
.form-control,
.form-select {
    border-color: #d0d5dd;
    border-radius: 8px;
}
.form-control:focus,
.form-select:focus {
    border-color: #5cc5ba;
    box-shadow: 0 0 0 .2rem rgba(15,118,110,.13);
}

.stat-card {
    border: 1px solid var(--gl-border);
    border-radius: 8px;
    box-shadow: var(--gl-shadow);
}
.stat-icon {
    border-radius: 8px;
}
.stat-blue .stat-icon  { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.stat-green .stat-icon { background: linear-gradient(135deg, #14b8a6, #0f766e); }
.stat-amber .stat-icon { background: linear-gradient(135deg, #f59e0b, #ea580c); }
.stat-red .stat-icon   { background: linear-gradient(135deg, #f43f5e, #dc2626); }
.stat-purple .stat-icon { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.stat-rose .stat-icon  { background: linear-gradient(135deg, #e11d48, #be123c); }
.stat-cyan .stat-icon  { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.stat-label {
    color: #667085;
    font-weight: 650;
}
.stat-value {
    color: #101828;
    letter-spacing: 0;
}
a.stat-link:hover {
    transform: translateY(-2px);
    box-shadow: var(--gl-shadow-lg);
}

.code-badge {
    border-radius: 6px;
    background: #f8fafc;
    border-color: #e5e7eb;
    color: #344054;
}
.todo-bar {
    border-color: #fedf89 !important;
    background: #fffcf5;
}
.todo-bar .todo-chip {
    border-color: #fedf89;
    border-radius: 8px;
}

.gl-dashboard {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.dashboard-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
    gap: 18px;
    align-items: stretch;
    background: #fff;
    border: 1px solid var(--gl-border);
    border-radius: 8px;
    padding: 18px;
    box-shadow: var(--gl-shadow);
}
.dashboard-hero-main {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}
.dashboard-eyebrow {
    color: var(--gl-primary);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    margin-bottom: 7px;
}
.dashboard-title {
    margin: 0;
    font-size: 26px;
    font-weight: 800;
    color: #101828;
}
.dashboard-subtitle {
    margin: 7px 0 0;
    color: #667085;
}
.dashboard-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}
.dashboard-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}
.occupancy-panel {
    background: linear-gradient(135deg, #0f766e, #2563eb);
    color: #fff;
    border-radius: 8px;
    padding: 18px;
    min-height: 150px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.occupancy-label {
    font-size: 13px;
    opacity: .86;
}
.occupancy-value {
    font-size: 42px;
    line-height: 1;
    font-weight: 850;
    margin-top: 8px;
}
.occupancy-meta {
    font-size: 13px;
    opacity: .88;
    margin-top: 5px;
}
.occupancy-track {
    height: 8px;
    background: rgba(255,255,255,.24);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 18px;
}
.occupancy-fill {
    height: 100%;
    background: #fff;
    border-radius: 999px;
}
.dashboard-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 3px 0 0;
}
.dashboard-section-title h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 800;
    color: #101828;
}
.dashboard-section-title span {
    color: #667085;
    font-size: 13px;
}
.dash-stats { margin-bottom: 2px !important; }
.dash-stats .stat-card {
    min-height: 96px;
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
}
.dash-stats .stat-icon {
    width: 38px;
    height: 38px;
    font-size: 16px;
}
.dash-stats .stat-label {
    margin-top: 4px;
    white-space: normal;
}
.dash-stats .stat-value {
    font-size: 25px;
}
.dash-card-large .chart-wrap--sm { height: 276px; }
.dashboard-table-card .card-body { padding: 0; }
.dashboard-table-card .empty-list,
.dashboard-table-card .empty-chart {
    min-height: 150px;
}
.dashboard-table-card .table { margin-bottom: 0; }
.dashboard-table-card td:first-child { padding-left: 18px; }
.dashboard-table-card td:last-child { padding-right: 18px; }

@media (max-width: 992px) {
    .app-sidebar {
        left: -280px;
        width: var(--gl-sidebar-w);
        box-shadow: var(--gl-shadow-lg);
    }
    .app-sidebar.open { left: 0; }
    .app-topbar { padding: 0 16px; }
    .cmdk-trigger { min-width: 0; }
    .app-content { padding: 18px; }
    .dashboard-hero { grid-template-columns: 1fr; }
}
@media (max-width: 576px) {
    .page-title,
    .dashboard-title { font-size: 23px; }
    .dashboard-hero { padding: 14px; }
    .dashboard-actions .btn { width: 100%; justify-content: center; }
    .occupancy-value { font-size: 36px; }
}

/* ============================================================
   PWA — nút cài đặt + điều hướng khi chạy ở chế độ app
   ============================================================ */

/* Nút "Cài đặt app": pwa.js quyết định hiện/ẩn qua thuộc tính [hidden]. */
.pwa-install-btn[hidden] { display: none !important; }
.pwa-install-btn {
    white-space: nowrap;
    border-color: var(--gl-primary);
    color: var(--gl-primary);
}
.pwa-install-btn:hover {
    background: var(--gl-primary);
    border-color: var(--gl-primary);
    color: #fff;
}

/* Nút Quay lại / Tiến tới — CHỈ hiện khi app chạy trong cửa sổ riêng (đã cài),
   vì lúc đó không có thanh địa chỉ nên người dùng mất nút Back của trình duyệt.
   Mở bằng tab trình duyệt bình thường thì ẩn đi, tránh trùng lặp vô nghĩa. */
.pwa-nav { display: none; }
.pwa-standalone .pwa-nav {
    display: flex;
    gap: 2px;
    margin-right: 10px;
}
.pwa-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 13px;
    color: var(--gl-text-muted);
    background: transparent;
    border: 1px solid var(--gl-border);
    border-radius: var(--gl-radius-sm);
    cursor: pointer;
    transition: background .15s, color .15s;
}
.pwa-nav-btn:hover {
    background: var(--gl-soft);
    color: var(--gl-text);
}
@media (max-width: 640px) {
    .pwa-standalone .pwa-nav { display: none; }
}
