/* ===== DevHub RBAC - Azure-Style Global Styles ===== */
:root {
    color-scheme: light;
    --primary: #0078d4;
    --primary-hover: #106ebe;
    --primary-active: #005a9e;
    --primary-light: rgba(0,120,212,0.08);
    --primary-lighter: rgba(0,120,212,0.04);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.05);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --sidebar-width: 272px;
    --header-height: 56px;
    --transition-fast: 0.15s cubic-bezier(0.4,0,0.2,1);
    --transition-normal: 0.25s cubic-bezier(0.4,0,0.2,1);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    /* Theme-aware text colors */
    --text-primary: #242424;
    --text-secondary: #6b7280;
    --text-label: #374151;
    --text-table-header: #374151;
    --bg-input: #ffffff;
    --bg-card: #ffffff;
    --bg-page: #f5f5f5;
    --bg-sidebar: #fafafa;
    --bg-sidebar-mobile: #ffffff;
    --bg-header: rgba(255,255,255,0.9);
    --bg-modal: #ffffff;
    --bg-input-modal: #ffffff;
    --border-color: #e5e7eb;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', 'Segoe UI', sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background-color var(--transition-normal), color var(--transition-normal);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== Dark Theme ===== */
[data-bs-theme="dark"] {
    color-scheme: dark;
    --bs-body-bg: #0f0f0f;
    --bs-body-color: #e5e7eb;
    --bs-border-color: #27272a;
    --primary-light: rgba(0,120,212,0.15);
    --primary-lighter: rgba(0,120,212,0.08);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
    --text-primary: #e5e7eb;
    --text-secondary: #9ca3af;
    --text-label: #d1d5db;
    --text-table-header: #d1d5db;
    --bg-input: #1e1e22;
    --bg-card: #18181b;
    --bg-page: #0f0f0f;
    --bg-sidebar: #121214;
    --bg-sidebar-mobile: #121214;
    --bg-header: rgba(24,24,27,0.9);
    --bg-modal: #18181b;
    --bg-input-modal: #1e1e22;
    --border-color: #27272a;
}
[data-bs-theme="dark"] body { background: var(--bg-page); color: var(--text-primary); }
[data-bs-theme="dark"] .bg-white { background-color: var(--bg-card) !important; }
[data-bs-theme="dark"] .bg-light { background-color: #121214 !important; }
[data-bs-theme="dark"] .text-muted { color: var(--text-secondary) !important; }

/* ===== TOP HEADER ===== */
.top-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 1030;
    position: fixed;
    top: 0; left: 0; right: 0;
    box-shadow: var(--shadow-sm);
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-btn {
    width: 38px; height: 38px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 16px;
    text-decoration: none;
}
.header-btn:hover {
    background: var(--primary-light);
    border-color: rgba(0,120,212,0.15);
    color: var(--primary);
    transform: translateY(-1px);
}
.header-btn:active { transform: translateY(0); }

.ms-logo {
    width: 22px; height: 22px;
    border-radius: 4px;
    background: linear-gradient(135deg, #f25022 0%, #7fba00 33%, #00a4ef 66%, #ffb900 100%);
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.brand-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
}
.header-nav a {
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    text-decoration: none;
    opacity: 0.7;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    position: relative;
}
.header-nav a.active { opacity: 1; font-weight: 600; }
.header-nav a:hover { opacity: 1; color: var(--primary); background: var(--primary-lighter); }

.header-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: transparent;
    transition: all var(--transition-fast);
}
.header-search:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.header-search i { font-size: 14px; opacity: 0.6; color: var(--text-secondary); }
.header-search input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 13px;
    width: 160px;
    color: var(--text-primary);
}
.header-search input::placeholder { color: var(--text-secondary); }

.notification-dot {
    position: absolute;
    top: 7px; right: 7px;
    width: 9px; height: 9px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid var(--bg-page);
    animation: pulse 2s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.header-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 12px 4px 4px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    cursor: default;
    transition: background var(--transition-fast);
}
.header-user:hover { background: var(--primary-lighter); }

.user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #005a9e);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
}

.user-info { display: flex; flex-direction: column; }
.user-name { font-size: 13px; font-weight: 600; line-height: 1.2; color: var(--text-primary); }
.user-id { font-size: 11px; color: var(--text-secondary); line-height: 1.2; }

.sidebar-toggle { display: none; }

/* ===== PAGE LAYOUT ===== */
.page-layout {
    display: flex;
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
}

/* ===== SIDEBAR (Azure-style) ===== */
.sidebar {
    width: var(--sidebar-width);
    flex: 0 0 var(--sidebar-width);
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
    overflow-x: hidden;
    border-right: 1px solid var(--border-color);
    transition: transform var(--transition-normal);
    scrollbar-width: thin;
    scrollbar-color: rgba(128,128,128,0.2) transparent;
    padding-top: 8px;
    background: var(--bg-sidebar);
}

.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(128,128,128,0.2); border-radius: 10px; }

.sidebar-inner { padding: 8px 12px 32px; }

/* Sidebar System Header - nhom menu theo he thong */
.sidebar-system-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    margin-top: 8px;
}
.sidebar-system-header:first-child { margin-top: 0; }
.sidebar-system-header .sys-dot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.sidebar-system-header .sys-dot.zz { background: #0078d4; }
.sidebar-system-header .sys-dot.go { background: #10b981; }
.sidebar-system-header .sys-dot.aa { background: #f59e0b; }
.sidebar-system-header .sys-dot.default { background: #8b5cf6; }

/* ===== SIDEBAR NAVIGATION ===== */
.nav-group { margin-bottom: 2px; }
.nav-group-title {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    user-select: none;
    transition: all var(--transition-fast);
}
.nav-group-title:hover { background: var(--primary-lighter); }
.nav-group-title .nav-arrow {
    font-size: 10px;
    transition: transform var(--transition-normal);
    opacity: 0.5;
    flex-shrink: 0;
}
.nav-group.nav-open > .nav-group-title .nav-arrow { transform: rotate(90deg); }
.nav-group-title .nav-icon { font-size: 15px; opacity: 0.7; flex-shrink: 0; }

.nav-group-items {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.nav-group.nav-open > .nav-group-items { max-height: 800px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    border-left: 2px solid transparent;
}
.nav-item:hover { background: var(--primary-lighter); color: var(--primary); }
.nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
    border-left-color: var(--primary);
}
.nav-item .nav-icon { font-size: 14px; opacity: 0.6; flex-shrink: 0; }
/* Indentation per depth is now set inline by menu-build.js (style="padding-left:Npx"),
   scaling correctly for any number of nested levels instead of only the 2 fixed
   levels this stylesheet used to hardcode via descendant selectors. */

/* ===== MAIN CONTENT AREA ===== */
.main-content {
    flex: 1;
    min-width: 0;
    padding: 24px 32px 48px;
}

/* ===== BREADCRUMB ===== */
.breadcrumb-bar {
    font-size: 13px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.breadcrumb-bar a {
    color: var(--primary);
    text-decoration: none;
    transition: opacity var(--transition-fast);
}
.breadcrumb-bar a:hover { opacity: 0.8; }
.breadcrumb-bar .sep { color: var(--text-secondary); }

/* ===== PAGE HEADER ===== */
.page-header {
    margin-bottom: 28px;
}
.page-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin-bottom: 6px;
}
.page-header p {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ===== STATS GRID ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: all var(--transition-normal);
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.stat-icon-blue { background: rgba(0,120,212,0.1); color: #0078d4; }
.stat-icon-green { background: rgba(16,185,129,0.1); color: #10b981; }
.stat-icon-purple { background: rgba(139,92,246,0.1); color: #8b5cf6; }
.stat-icon-orange { background: rgba(245,158,11,0.1); color: #f59e0b; }
.stat-icon-red { background: rgba(239,68,68,0.1); color: #ef4444; }

.stat-info { flex: 1; }
.stat-number {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 4px;
}
.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 12px;
}
.card-header h4 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}
.card-body { padding: 20px 24px; }

/* ===== DATA TABLE ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table th {
    background: var(--primary-lighter);
    padding: 10px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-table-header);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border-color);
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}
.data-table tbody tr { transition: background var(--transition-fast); }
.data-table tbody tr:hover { background: var(--primary-lighter); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    color: #fff;
    line-height: 1.4;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: #10b981; }
.btn-success:hover { background: #059669; }
.btn-info { background: #06b6d4; }
.btn-info:hover { background: #0891b2; }
.btn-warning { background: #f59e0b; color: #1a1a2e; }
.btn-warning:hover { background: #d97706; }
.btn-danger { background: #ef4444; }
.btn-danger:hover { background: #dc2626; }
.btn-secondary { background: #6b7280; }
.btn-secondary:hover { background: #4b5563; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}
.btn-outline:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: #f3f4f6; color: #4b5563; }
.badge-warning { background: #fef3c7; color: #92400e; }

[data-bs-theme="dark"] .badge-success { background: rgba(16,185,129,0.15); color: #6ee7b7; }
[data-bs-theme="dark"] .badge-danger { background: rgba(239,68,68,0.15); color: #fca5a5; }
[data-bs-theme="dark"] .badge-info { background: rgba(0,120,212,0.15); color: #93c5fd; }
[data-bs-theme="dark"] .badge-secondary { background: rgba(107,114,128,0.2); color: #d1d5db; }
[data-bs-theme="dark"] .badge-warning { background: rgba(245,158,11,0.15); color: #fcd34d; }

/* ===== FILTER BAR ===== */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.filter-bar label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}
.filter-bar select, .filter-bar input[type="text"], .filter-bar input[type="date"] {
    padding: 7px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--bg-input);
    outline: none;
    color: var(--text-primary) !important;
    transition: border-color var(--transition-fast);
}
.filter-bar select:focus, .filter-bar input[type="text"]:focus,
.filter-bar input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* ===== INPUT DATE - unified look everywhere (filter bars, form-group, form-row) =====
   Rule: NEVER add inline style="" to an <input type="date">. It always inherits from
   its container (.filter-bar / .form-group / .form-row). The calendar icon color is
   controlled by the color-scheme declarations on :root / [data-bs-theme="dark"] above -
   do not try to recolor it with CSS filters or inline styles. */
input[type="date"] {
    font-family: inherit;
    cursor: pointer;
}
input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.75;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}
.modal {
    background: var(--bg-modal);
    border-radius: var(--radius-lg);
    width: 500px;
    max-width: 95vw;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.2s ease;
    border: 1px solid var(--border-color);
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(-8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    padding: 18px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}
.modal-header h4 { font-size: 16px; font-weight: 600; color: var(--text-primary); }

.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
    padding: 4px;
}
.modal-close:hover { color: #ef4444; }

.modal-body { padding: 24px; color: var(--text-primary); }
.modal-footer {
    padding: 16px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid var(--border-color);
}

.form-row { margin-bottom: 16px; }
.form-row label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-label);
    margin-bottom: 6px;
}
.form-row input, .form-row select, .form-row textarea {
    width: 100%;
    padding: 9px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    outline: none;
    color: var(--text-primary) !important;
    background: var(--bg-input-modal);
    transition: border-color var(--transition-fast), background var(--transition-fast);
    font-family: inherit;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
    background: var(--bg-input-modal);
}
.form-row input::placeholder, .form-row select::placeholder, .form-row textarea::placeholder {
    color: var(--text-secondary);
}

/* ===== GLOBAL INPUT/SELECT/TEXTAREA - Theme-aware ===== */
input, select, textarea {
    color: var(--text-primary);
    background: var(--bg-input);
}
input::placeholder, textarea::placeholder {
    color: var(--text-secondary);
}
select {
    background: var(--bg-input);
    color: var(--text-primary);
}
select option {
    background: var(--bg-card);
    color: var(--text-primary);
}
[data-bs-theme="dark"] select option {
    background: #1e1e22;
    color: #e5e7eb;
}
input[type="checkbox"] {
    accent-color: var(--primary);
}

/* ===== UTILITY ===== */
.text-muted { color: var(--text-secondary) !important; font-size: 13px; }
.text-center { text-align: center; }
.text-sm { font-size: 12px; word-break: break-all; max-width: 300px; }
.text-right { text-align: right; }

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}
.empty-state i { font-size: 40px; opacity: 0.3; display: block; margin-bottom: 12px; }
.empty-state p { font-size: 14px; margin: 0; }

/* ===== RESPONSIVE ===== */
@media (max-width: 992px) {
    .sidebar {
        position: fixed;
        top: var(--header-height);
        left: 0;
        bottom: 0;
        width: min(280px, 85vw);
        flex: none;
        z-index: 1020;
        transform: translateX(-100%);
        overflow-y: auto;
        overflow-x: hidden;
        background: var(--bg-sidebar-mobile);
        box-shadow: var(--shadow-lg);
    }
    .sidebar.sidebar-open { transform: translateX(0); }
    .sidebar-toggle { display: inline-flex; }
    .main-content { padding: 20px 16px 48px; }
    .header-search { display: none; }
    .header-nav { display: none; }
    /* Sidebar overlays content on mobile — page-layout must not reserve space for it */
    .page-layout { margin-left: 0 !important; }
}

@media (max-width: 768px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .page-header h1 { font-size: 22px; }
    .card-header { flex-direction: column; align-items: flex-start; }
    .filter-bar { width: 100%; }
    .user-info { display: none; }
}


/* ============================================================
   ============== SHARED EXTENSIONS (v1.1) ====================
   ============================================================
   Added to fix:
   - ZZ popup modals: class-based hide/show, scrollable body, width variants
   - GO module pages: unified form-group / grid / alert / badge / tab styles
   ============================================================ */

:root {
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
    --success-hover: #059669;
    --warning: #f59e0b;
    --warning-hover: #d97706;
    --info: #06b6d4;
    --info-hover: #0891b2;
}
[data-bs-theme="dark"] {
    --danger: #f87171;
    --danger-hover: #ef4444;
    --success: #34d399;
    --success-hover: #10b981;
    --warning: #fbbf24;
    --warning-hover: #f59e0b;
}

/* ===== MODAL STATE + WIDTH VARIANTS ===== */
.modal-overlay { display: flex; }
.modal-overlay.hidden { display: none; }

.modal-lg { width: 800px; }
.modal-xl { width: 1100px; }
.modal-sm { width: 380px; }

/* Make modal body scrollable for long forms (ZZA0_0400, ZZA0_0600) */
.modal {
    max-height: 92vh;
    display: flex;
    flex-direction: column;
}
.modal-body {
    max-height: calc(92vh - 132px);
    overflow-y: auto;
    overscroll-behavior: contain;
}
.modal-header,
.modal-footer { flex-shrink: 0; }

.modal-close:hover { color: var(--danger); }

/* Lock body scroll when modal is open */
body.modal-open { overflow: hidden; }

/* ===== FORM GROUP (shared by GO/A1, GO/A2, GO/A3, GO/A4, GO/A5, GO/A6) ===== */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-label);
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 13px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--bg-input);
    color: var(--text-primary) !important;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text-secondary); }

.form-group .helper-text {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

.readonly-field {
    background: var(--bg-page) !important;
    opacity: 0.75;
    cursor: not-allowed;
}

/* ===== GRID LAYOUTS (shared) ===== */
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.form-grid .full-width,
.row2 .full-width,
.row3 .full-width,
.form-grid-3 .full-width { grid-column: 1 / -1; }

@media (max-width: 768px) {
    .row2, .row3, .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
}

/* ===== ALERT BOXES ===== */
.alert-success,
.alert-error,
.alert-warning,
.alert-info {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 13px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.alert-success { background: rgba(16,185,129,0.10); border: 1px solid rgba(16,185,129,0.30); color: #059669; }
.alert-error   { background: rgba(239,68,68,0.10);  border: 1px solid rgba(239,68,68,0.30);  color: #c23152; }
.alert-warning { background: rgba(245,158,11,0.10); border: 1px solid rgba(245,158,11,0.30); color: #d97706; }
.alert-info    { background: rgba(0,120,212,0.10);  border: 1px solid rgba(0,120,212,0.30);  color: var(--primary); }
[data-bs-theme="dark"] .alert-success { color: #6ee7b7; }
[data-bs-theme="dark"] .alert-error   { color: #fca5a5; }
[data-bs-theme="dark"] .alert-warning { color: #fcd34d; }
[data-bs-theme="dark"] .alert-info    { color: #93c5fd; }

/* ===== REQUIRED ASTERISK ===== */
.required { color: var(--danger); }

/* ===== ACTION BUTTONS GROUP ===== */
.action-btns {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
}
@media (max-width: 480px) {
    .action-btns { flex-direction: column; align-items: stretch; }
}

/* Small ghost action button used in GO/A1/GOA1_0300, GO/A2/GOA2_0300 */
.btn-action {
    padding: 5px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all var(--transition-fast);
}
.btn-action:hover { background: var(--primary-lighter); color: var(--primary); border-color: var(--primary); }
.btn-action.danger { color: var(--danger); border-color: rgba(239,68,68,0.30); }
.btn-action.danger:hover {
    border-color: var(--danger);
    background: rgba(239,68,68,0.08);
    color: var(--danger);
}

/* ===== TAB NAVIGATION (shared by GOA2_0100, GOA4_0200) ===== */
.nav-tabs-bar,
.tab-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0;
    overflow-x: auto;
    flex-wrap: nowrap;
}
.nav-tab,
.tab-bar .tab {
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-secondary);
    margin-bottom: -2px;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    font-family: inherit;
}
.nav-tab:hover,
.tab-bar .tab:hover { color: var(--text-primary); background: var(--primary-lighter); }
.nav-tab.active,
.tab-bar .tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}
.tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-page);
    color: var(--text-secondary);
}
.nav-tab.active .tab-count { background: var(--primary-light); color: var(--primary); }

/* ===== BADGE STATUS ALIASES (12 variants → 5 chuẩn) ===== */
/*
   Ánh xạ về 5 biến thể chuẩn: success / danger / warning / info / secondary
   Các trang GO dùng .badge-active / .badge-completed / .badge-cancelled ... sẽ nhận
   style thống nhất với nhau, không cần override cục bộ nữa.
*/
.badge-status {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

/* Active / completed → success */
.badge-active,
.badge-completed { background: #d1fae5; color: #065f46; }
[data-bs-theme="dark"] .badge-active,
[data-bs-theme="dark"] .badge-completed { background: rgba(16,185,129,0.15); color: #6ee7b7; }

/* Inactive / retired / removed → secondary */
.badge-inactive,
.badge-retired,
.badge-removed { background: #f3f4f6; color: #4b5563; }
[data-bs-theme="dark"] .badge-inactive,
[data-bs-theme="dark"] .badge-retired,
[data-bs-theme="dark"] .badge-removed { background: rgba(107,114,128,0.2); color: #d1d5db; }

/* Pending / expired / maintenance / delayed → warning */
.badge-pending,
.badge-expired,
.badge-maintenance,
.badge-delayed { background: #fef3c7; color: #92400e; }
[data-bs-theme="dark"] .badge-pending,
[data-bs-theme="dark"] .badge-expired,
[data-bs-theme="dark"] .badge-maintenance,
[data-bs-theme="dark"] .badge-delayed { background: rgba(245,158,11,0.15); color: #fcd34d; }

/* Cancelled → danger */
.badge-cancelled { background: #fee2e2; color: #991b1b; }
[data-bs-theme="dark"] .badge-cancelled { background: rgba(239,68,68,0.15); color: #fca5a5; }

/* Planned / in_transit → info */
.badge-planned,
.badge-in_transit { background: #dbeafe; color: #1e40af; }
[data-bs-theme="dark"] .badge-planned,
[data-bs-theme="dark"] .badge-in_transit { background: rgba(0,120,212,0.15); color: #93c5fd; }

/* Legacy alias for "in" status */
.badge-in { background: #d1fae5; color: #065f46; }

/* ===== ROLE / SEARCH chips (GOA1_0200, GOA1_0201) ===== */
.badge-role {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(16,185,129,0.10);
    color: #059669;
    border: 1px solid rgba(16,185,129,0.25);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.badge-role:hover { background: rgba(16,185,129,0.20); }
.badge-role.active { background: #059669; color: #fff; border-color: #059669; }
.badge-role.inactive {
    background: var(--bg-page);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
[data-bs-theme="dark"] .badge-role { background: rgba(16,185,129,0.15); color: #6ee7b7; }

.role-chip {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid rgba(0,120,212,0.20);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.search-item {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 6px;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.search-item:hover { border-color: var(--primary); background: var(--primary-lighter); }
.search-item.selected { border-color: var(--primary); background: var(--primary-light); }

/* ===== STATUS TEXT (GOA1_0300) ===== */
.status-active { color: #059669; font-weight: 500; }
.status-inactive { color: var(--danger); font-weight: 500; }

/* ===== DETAIL ROW (GOA6_0100) ===== */
.section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 18px 0 10px 0;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
}
.detail-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 1fr 36px;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}
.detail-row input,
.detail-row select {
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--bg-input);
    color: var(--text-primary) !important;
    width: 100%;
    outline: none;
}
.detail-row input:focus,
.detail-row select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.detail-del {
    background: var(--danger);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: background var(--transition-fast);
}
.detail-del:hover { background: var(--danger-hover); }
@media (max-width: 768px) {
    .detail-row { grid-template-columns: 1fr 1fr; }
}

/* ===== TENANT CARDS (GOA1_0003) ===== */
.tenant-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}
.tenant-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    background: var(--bg-card);
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
}
.tenant-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0,120,212,0.10);
    transform: translateY(-2px);
}
.tenant-card.active {
    border-color: var(--primary);
    background: var(--primary-lighter);
    box-shadow: 0 0 0 2px rgba(0,120,212,0.20);
}
.tenant-card .card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 16px;
}
.tenant-card .card-icon.default-icon {
    background: linear-gradient(135deg, var(--primary), #00bcf2);
    color: #fff;
}
.tenant-card .card-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.tenant-card .card-short {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}
.tenant-card .card-id {
    font-size: 12px;
    color: var(--text-secondary);
    font-family: monospace;
}
.tenant-card .active-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
}
.btn-select {
    margin-top: 16px;
    padding: 8px 20px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.btn-select:hover { background: var(--primary-hover); }
.btn-select:disabled { opacity: 0.5; cursor: not-allowed; }
@media (max-width: 768px) { .tenant-grid { grid-template-columns: 1fr; } }

/* ===== SPINNER ===== */
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ===== PAGE HEADER (when used as flex row with action button) ===== */
.page-header.is-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}
@media (max-width: 768px) {
    .page-header.is-flex { flex-direction: column; align-items: flex-start; }
}


/* ===== LONE BUTTON VARIANTS (GO module uses .btn-primary without .btn) =====
   When .btn-* variant classes are used WITHOUT the .btn base class, they still
   receive base button styles. specificity: .btn-primary:not(.btn) = (0,2,0)
   which is higher than .btn-primary = (0,1,0), so this rule wins for lone usage
   but does not affect <button class="btn btn-primary">.
*/
.btn-primary:not(.btn),
.btn-success:not(.btn),
.btn-danger:not(.btn),
.btn-warning:not(.btn),
.btn-info:not(.btn),
.btn-secondary:not(.btn),
.btn-outline:not(.btn) {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    color: #fff;
    line-height: 1.4;
    font-family: inherit;
}
.btn-primary:not(.btn):hover,
.btn-success:not(.btn):hover,
.btn-danger:not(.btn):hover,
.btn-warning:not(.btn):hover,
.btn-info:not(.btn):hover,
.btn-secondary:not(.btn):hover,
.btn-outline:not(.btn):hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.btn-primary:not(.btn):disabled,
.btn-success:not(.btn):disabled,
.btn-danger:not(.btn):disabled,
.btn-warning:not(.btn):disabled,
.btn-info:not(.btn):disabled,
.btn-secondary:not(.btn):disabled,
.btn-outline:not(.btn):disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Override color/background/border cho .btn-outline standalone.
   Khac cac variant khac, .btn-outline can border + background trong suot
   de hien thi nhu nut "phu" (Huy / File mau / Import / Export).
   Specificity: .btn-outline:not(.btn) = (0,2,0) > .btn-outline = (0,1,0),
   nen override thanh cong ma khong anh huong <button class="btn btn-outline">. */
.btn-outline:not(.btn) {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}
.btn-outline:not(.btn):hover {
    background: var(--primary-lighter);
    border-color: var(--primary);
    color: var(--primary);
}

/* In GO module, .btn-sm is used ALONE as a small outline/ghost action button
   (NOT as a modifier of .btn). Provide full standalone styles. */
.btn-sm:not(.btn) {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    line-height: 1.4;
    font-family: inherit;
}
.btn-sm:not(.btn):hover {
    background: var(--primary-lighter);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
}

/* ===== PAGE-HEADER flex (when used with .is-flex class) =====
   Pages that need an action button on the right of the page title should add
   the .is-flex modifier instead of inline style. Includes responsive stacking.
*/
.page-header.is-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}
@media (max-width: 768px) {
    .page-header.is-flex {
        flex-direction: column;
        align-items: flex-start;
    }
}


/* ===== MODAL FLAT (for GO modals that don't use header/body/footer structure) =====
   GO module historically used inline-style modals with free-form content (no
   .modal-header / .modal-body / .modal-footer wrappers). This modifier:
   - Reverts the flex-column behavior of .modal
   - Makes the whole modal scrollable
   - Adds padding matching GO's original 28px (or 24px if overridden inline)
*/
.modal-flat {
    display: block;
    padding: 28px;
    overflow-y: auto;
    max-height: 92vh;
}
.modal-flat > h3:first-child {
    margin-bottom: 20px;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.modal-flat .modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 20px;
}
.modal-flat .modal-alert {
    display: none;
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 13px;
}
.modal-flat .modal-alert.show { display: block; }
.modal-flat .modal-alert.alert-error { background: rgba(239,68,68,0.10); color: var(--danger); border: 1px solid rgba(239,68,68,0.30); }
.modal-flat .modal-alert.alert-success { background: rgba(16,185,129,0.10); color: var(--success); border: 1px solid rgba(16,185,129,0.30); }


/* ===== ALERT TINT VARIABLES (for use in JS-set inline styles) ===== */
:root {
    --danger-light: rgba(239,68,68,0.10);
    --danger-border: rgba(239,68,68,0.30);
    --success-light: rgba(16,185,129,0.10);
    --success-border: rgba(16,185,129,0.30);
    --warning-light: rgba(245,158,11,0.10);
    --warning-border: rgba(245,158,11,0.30);
    --info-light: rgba(0,120,212,0.10);
    --info-border: rgba(0,120,212,0.30);
}
[data-bs-theme="dark"] {
    --danger-light: rgba(239,68,68,0.15);
    --danger-border: rgba(239,68,68,0.30);
    --success-light: rgba(16,185,129,0.15);
    --success-border: rgba(16,185,129,0.30);
    --warning-light: rgba(245,158,11,0.15);
    --warning-border: rgba(245,158,11,0.30);
    --info-light: rgba(0,120,212,0.15);
    --info-border: rgba(0,120,212,0.30);
}

/* ===== Pagination ===== */
.pagination-bar { display:flex; align-items:center; justify-content:space-between; padding:14px 16px; border-top:1px solid var(--border-color); flex-wrap:wrap; gap:8px; }
.pagination-info { color:var(--text-secondary); font-size:13px; }
.pagination-controls { display:flex; gap:4px; align-items:center; }
.page-btn { display:inline-flex; align-items:center; justify-content:center; min-width:34px; height:34px; padding:0 8px; border:1px solid var(--border-color); border-radius:var(--radius-sm); background:var(--bg-card); color:var(--text-primary); font-size:13px; font-weight:500; cursor:pointer; transition:all var(--transition-fast); }
.page-btn:hover:not(:disabled):not(.active) { background:var(--primary-light); border-color:var(--primary); color:var(--primary); }
.page-btn.active { background:var(--primary); color:#fff; border-color:var(--primary); }
.page-btn:disabled { opacity:0.35; cursor:default; pointer-events:none; }

/* ===== Column Filter Row ===== */
.filter-row th { padding:6px 8px; background:var(--bg-body, #f8f9fa); border-bottom:2px solid var(--border-color); }
.col-filter-input { width:100%; padding:5px 8px; border:1px solid var(--border-color); border-radius:var(--radius-sm, 6px); font-size:12px; background:var(--bg-card, #fff); color:var(--text-primary); outline:none; transition:border-color var(--transition-fast, 0.15s); box-sizing:border-box; }
.col-filter-input:focus { border-color:var(--primary, #4f46e5); box-shadow:0 0 0 2px rgba(79,70,229,0.1); }
.col-filter-input::placeholder { color:var(--text-secondary); opacity:0.6; }

/* ===== Skeleton Loading ===== */
.skeleton { background:linear-gradient(90deg, var(--bg-input) 25%, var(--border-color) 50%, var(--bg-input) 75%); background-size:200% 100%; animation:shimmer 1.5s infinite; border-radius:var(--radius-sm); }
@keyframes shimmer { 0% { background-position:200% 0; } 100% { background-position:-200% 0; } }
.skeleton-text { height:14px; margin-bottom:8px; }
.skeleton-text.w-25 { width:25%; }
.skeleton-text.w-50 { width:50%; }
.skeleton-text.w-75 { width:75%; }
.skeleton-text.w-100 { width:100%; }
.page-loading { display:flex; align-items:center; justify-content:center; flex-direction:column; gap:12px; min-height:300px; color:var(--text-secondary); }
.page-loading .spinner { width:32px; height:32px; border:3px solid var(--border-color); border-top-color:var(--primary); border-radius:50%; animation:spin 0.8s linear infinite; }
@keyframes spin { to { transform:rotate(360deg); } }

/* ===== Form Validation ===== */
.form-group.has-error input,
.form-group.has-error select,
.form-group.has-error textarea { border-color:var(--danger, #ef4444); background:var(--danger-light, rgba(239,68,68,0.05)); }
.form-error { color:var(--danger, #ef4444); font-size:12px; margin-top:4px; display:none; }
.form-group.has-error .form-error { display:block; }

/* ===== Animations ===== */
@keyframes fadeIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }
.main-content > * { animation:fadeIn 0.2s ease-out; }
.modal-overlay:not(.hidden) { animation:modalIn 0.2s ease-out; }
@keyframes modalIn { from { opacity:0; } to { opacity:1; } }
.stat-card .stat-number { transition:all 0.3s ease; }

/* ===== Chart Container ===== */
.chart-container { position:relative; width:100%; min-height:280px; }
.chart-container canvas { width:100% !important; }
.chart-grid { display:grid; grid-template-columns:1fr 1fr; gap:20px; margin-bottom:20px; }
.chart-card { background:var(--bg-card); border-radius:var(--radius-md); padding:20px; box-shadow:var(--shadow-sm); border:1px solid var(--border-color); }
.chart-card h3 { font-size:15px; font-weight:600; margin-bottom:16px; color:var(--text-primary); }
@media (max-width:900px) { .chart-grid { grid-template-columns:1fr; } }

/* ===== Data Table Scroll ===== */
.table-wrapper { overflow-x:auto; -webkit-overflow-scrolling:touch; }
.table-wrapper .data-table { min-width:700px; }

/* ===== Date Range Filter ===== */
.date-range-bar { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.date-range-bar input[type="date"] { padding:8px 12px; border:1px solid var(--border-color); border-radius:var(--radius-sm); font-size:13px; background:var(--bg-input); color:var(--text-primary); }

/* ===== Export Buttons ===== */
.export-bar { display:flex; gap:8px; margin-top:16px; justify-content:flex-end; }
.export-bar .btn-primary { font-size:13px; padding:7px 14px; }
.export-bar .btn-outline { font-size:13px; padding:7px 14px; }

/* ===== R15: Responsive Improvements =====
   NOTE: The previous `@media (max-width: 1024px)` block here forced the sidebar
   into a 64px icon-only mode using stale selectors (.menu-text, .menu-item, ...)
   that no longer exist in menu-build.js (which now generates .nav-item, .nav-group-title,
   .nav-arrow, ...). The `width: 64px !important` + `overflow: hidden` + `page-layout
   margin-left: 64px !important` rules were dead code that also broke the mobile slide-in
   sidebar (clipping all menu text). That block has been removed.
   Mobile sidebar behavior is now defined entirely in the `@media (max-width: 992px)`
   block near the top of the RESPONSIVE section, plus the R15_MOBILE block at the end
   of this file (backdrop, touch targets, safe-area, brand-name hide). */
@media (max-width: 768px) {
    .chart-grid { grid-template-columns: 1fr !important; }
    .stats-grid { grid-template-columns: 1fr !important; }
    .form-grid, .row2 { grid-template-columns: 1fr !important; }
    .modal { width: calc(100vw - 32px) !important; max-width: none !important; margin: 16px !important; }
    .filter-bar { flex-direction: column; }
    .filter-bar select, .filter-bar input { width: 100% !important; }
    .pagination-bar { flex-direction: column; align-items: flex-start !important; gap: 8px; }
    .date-range-bar { flex-direction: column; align-items: stretch; }
    .date-range-bar input[type="date"] { width: 100%; }
    .data-table { font-size: 13px; }
    .data-table th, .data-table td { padding: 8px 10px !important; }
    .page-header h1 { font-size: 18px !important; }
    .page-header p { font-size: 13px !important; }
}

/* ===== R16: Animations & Micro-interactions ===== */
.main-content > *:nth-child(1) { animation-delay: 0ms; }
.main-content > *:nth-child(2) { animation-delay: 30ms; }
.main-content > *:nth-child(3) { animation-delay: 60ms; }
.main-content > *:nth-child(4) { animation-delay: 90ms; }
.main-content > *:nth-child(5) { animation-delay: 120ms; }
.main-content > *:nth-child(6) { animation-delay: 150ms; }

/* Table row hover animation */
.data-table tbody tr { transition: background-color var(--transition-fast); }

/* Button press effect */
.btn-primary:active:not(:disabled),
.btn-danger:active:not(:disabled),
.btn-sm:active:not(:disabled) {
    transform: scale(0.97);
}

/* Modal backdrop transition */
.modal-overlay { transition: opacity 0.2s ease; }
.modal-overlay.hidden { opacity: 0; pointer-events: none; }

/* Card hover subtle lift */
.stat-card { transition: transform var(--transition-fast), box-shadow var(--transition-fast); }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

/* Chart card animation */
.chart-card { animation: fadeIn 0.3s ease-out; }

/* Page button hover effect */
.page-btn { transition: all var(--transition-fast); }

/* Form focus ring animation */
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    box-shadow: 0 0 0 3px rgba(0,120,212,0.15);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

/* Filter bar animation */
.filter-bar select,
.filter-bar input {
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

/* Smooth scroll for table wrapper */
.table-wrapper { scroll-behavior: smooth; -webkit-overflow-scrolling: touch; }

/* Badge pulse for warning/danger */
.badge-warning, .badge-danger { animation: badgePulse 2s ease-in-out infinite; }
@keyframes badgePulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.75; } }

/* ===== LG — LEGAL FOOTER & BANNER ===== */
/* Footer pháp lý ở cuối mọi trang (link Điều khoản / Bảo mật / Cookie) */
.legal-footer {
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
    padding: 12px 24px;
    font-size: 12px;
    color: var(--text-secondary);
}
.legal-footer-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    max-width: 1400px;
    margin: 0 auto;
}
.legal-footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition-fast);
}
.legal-footer-links a:hover { color: var(--primary); text-decoration: underline; }
.legal-footer-links .sep { margin: 0 6px; opacity: 0.5; }

/* Banner cập nhật điều khoản (hiện trên cùng khi user có pending consent) */
.legal-update-banner {
    position: sticky;
    top: 0;
    z-index: 1050;
    background: linear-gradient(90deg, #fef3c7 0%, #fde68a 100%);
    border-bottom: 1px solid #f59e0b;
    padding: 10px 24px;
    font-size: 13px;
    color: #92400e;
}
.legal-update-banner.hidden { display: none !important; }
.legal-banner-content {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 1400px;
    margin: 0 auto;
    flex-wrap: wrap;
}
.legal-banner-content > i.bi { font-size: 18px; }
.legal-banner-link {
    color: #92400e;
    font-weight: 600;
    text-decoration: underline;
}
.legal-banner-link:hover { color: #78350f; }
.legal-banner-close {
    margin-left: auto;
    background: transparent;
    border: none;
    color: #92400e;
    cursor: pointer;
    font-size: 18px;
    padding: 2px 8px;
    border-radius: 4px;
    transition: background var(--transition-fast);
}
.legal-banner-close:hover { background: rgba(146, 64, 14, 0.15); }

/* ===== LG — LEGAL PAGES (trang /legal/) ===== */
.legal-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 24px;
}
.legal-toc {
    position: sticky;
    top: 80px;
    align-self: start;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}
.legal-toc h4 {
    margin: 0 0 12px 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.legal-toc-list { list-style: none; padding: 0; margin: 0; }
.legal-toc-list li { margin: 0; }
.legal-toc-list a {
    display: block;
    padding: 6px 10px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 13px;
    border-radius: 4px;
    border-left: 2px solid transparent;
    transition: all var(--transition-fast);
}
.legal-toc-list a:hover { background: var(--primary-lighter); color: var(--primary); }
.legal-toc-list a.active {
    background: var(--primary-lighter);
    border-left-color: var(--primary);
    color: var(--primary);
    font-weight: 500;
}
.legal-toc-list .toc-subsystem {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-top: 12px;
    padding: 4px 10px;
    letter-spacing: 0.5px;
}
.legal-toc-list .toc-subsystem:first-child { margin-top: 0; }

.legal-content-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 32px 40px;
    min-height: 600px;
}
.legal-content-wrap h1 {
    font-size: 28px;
    margin: 0 0 8px 0;
    color: var(--text-primary);
}
.legal-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}
.legal-meta-item { display: inline-flex; align-items: center; gap: 4px; }
.legal-meta-item .badge {
    background: var(--primary-lighter);
    color: var(--primary);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.legal-content {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-primary);
}
.legal-content h1, .legal-content h2, .legal-content h3 {
    color: var(--text-primary);
    margin-top: 28px;
    margin-bottom: 12px;
}
.legal-content h2 { font-size: 20px; border-bottom: 1px solid var(--border-color); padding-bottom: 6px; }
.legal-content h3 { font-size: 16px; }
.legal-content p { margin: 0 0 12px 0; }
.legal-content ul, .legal-content ol { margin: 0 0 12px 0; padding-left: 24px; }
.legal-content li { margin-bottom: 4px; }
.legal-content a { color: var(--primary); text-decoration: underline; }
.legal-content code {
    background: var(--bg-body);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}
.legal-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 13px;
}
.legal-content th, .legal-content td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: left;
}
.legal-content th { background: var(--bg-body); font-weight: 600; }
.legal-content blockquote {
    border-left: 3px solid var(--primary);
    margin: 12px 0;
    padding: 8px 16px;
    background: var(--primary-lighter);
    color: var(--text-primary);
    font-size: 13px;
}
.legal-content hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 24px 0;
}

/* Consent box (ở cuối trang /legal/{slug}) */
.legal-consent-box {
    margin-top: 32px;
    padding: 16px 20px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-body);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.legal-consent-box.mandatory {
    border-color: var(--primary);
    background: var(--primary-lighter);
}
.legal-consent-text { font-size: 14px; }
.legal-consent-text strong { color: var(--primary); }
.legal-consent-actions { display: flex; gap: 8px; }

/* LG index page */
.legal-index-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    margin-top: 24px;
}
.legal-index-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    transition: all var(--transition-fast);
    text-decoration: none;
    color: inherit;
    display: block;
}
.legal-index-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}
.legal-index-card .card-icon {
    font-size: 24px;
    color: var(--primary);
    margin-bottom: 8px;
}
.legal-index-card h3 {
    margin: 0 0 8px 0;
    font-size: 16px;
    color: var(--text-primary);
}
.legal-index-card p {
    margin: 0 0 12px 0;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}
.legal-index-card .card-meta {
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    gap: 8px;
    align-items: center;
}
.legal-index-card .badge-mandatory {
    background: #fef3c7;
    color: #92400e;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 500;
}

/* LG admin page */
.legal-admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.legal-admin-table th, .legal-admin-table td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: left;
}
.legal-admin-table th { background: var(--bg-body); font-weight: 600; }
.legal-admin-table tr:hover { background: var(--bg-body); }

/* Responsive LG */
@media (max-width: 900px) {
    .legal-page { grid-template-columns: 1fr; }
    .legal-toc { position: static; max-height: none; }
    .legal-content-wrap { padding: 20px; }
}

/* ============================================================
   ============== R15_MOBILE: Mobile Sidebar Polish ===========
   ============================================================
   Companion to the `@media (max-width: 992px)` block in the
   RESPONSIVE section. Adds:
   - Backdrop overlay shown when sidebar is open on mobile
     (tap outside to close). Backdrop sits below the sidebar
     (z-index 1019 vs sidebar 1020) but above page content.
   - Touch-friendly tap targets for .nav-item / .nav-group-title
     (≥40px height) — only on mobile, doesn't touch desktop.
   - iOS notch / safe-area-inset support so the hamburger button
     in the header isn't hidden under the notch.
   - Compact header on very small screens (≤480px): hide brand
     name text, keep hamburger + logo + avatar only.
   Desktop (>992px) is completely unaffected. */

/* Backdrop: hidden by default, shown via body.sidebar-open */
.sidebar-backdrop {
    position: fixed;
    inset: 0; /* top/right/bottom/left: 0 */
    top: var(--header-height); /* start below the fixed header */
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(1px);
    -webkit-backdrop-filter: blur(1px);
    z-index: 1019; /* sidebar is 1020, so backdrop sits just below */
    display: none;
    cursor: pointer;
    animation: fadeIn 0.2s ease-out;
}
body.sidebar-open .sidebar-backdrop { display: block; }

/* Desktop: never show backdrop (defensive — display:none wins outside media query) */
@media (min-width: 993px) {
    .sidebar-backdrop { display: none !important; }
}

@media (max-width: 992px) {
    /* iOS notch: keep hamburger button clear of the left notch */
    .top-header {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
    }
    /* Sidebar inner top padding respects notch on landscape iOS */
    .sidebar {
        padding-top: max(8px, env(safe-area-inset-top));
        padding-left: max(0px, env(safe-area-inset-left));
    }

    /* Touch-friendly tap targets (≥40px). Only bump vertical padding here;
       the inline padding-left set by menu-build.js (depth-based indent)
       is preserved because we don't override horizontal padding. */
    .nav-item {
        padding-top: 11px;
        padding-bottom: 11px;
    }
    .nav-group-title {
        padding-top: 11px;
        padding-bottom: 11px;
    }
}

@media (max-width: 480px) {
    /* Hide brand text — hamburger + logo is enough on very small screens */
    .brand-name { display: none; }
    /* .user-info already hidden at 768px; keep it hidden here too */
    .user-info { display: none !important; }
    /* Trim header padding for tiny screens */
    .top-header { padding: 0 12px; }
}
