@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Color Palette - Navy + Purple accent */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-card-hover: #263347;
    --bg-input: #334155;
    --bg-sidebar: #0c1222;
    --bg-success: rgba(34, 197, 94, 0.15);
    --bg-danger: rgba(239, 68, 68, 0.15);
    --bg-warning: rgba(245, 158, 11, 0.15);
    --bg-info: rgba(99, 102, 241, 0.15);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent-primary: #818cf8;
    --accent-primary-hover: #6366f1;
    --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
    --accent-gradient-hover: linear-gradient(135deg, #4f46e5, #7c3aed);

    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #6366f1;

    --border-color: #334155;
    --border-light: rgba(148, 163, 184, 0.1);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);

    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --navbar-height: 64px;
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============ RESET & BASE ============ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--accent-primary-hover);
}

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-input);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============ LAYOUT ============ */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ============ SIDEBAR ============ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: var(--navbar-height);
}

.sidebar-logo {
    width: 36px;
    height: 36px;
    background: var(--accent-gradient);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: white;
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

.sidebar-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.sidebar-nav {
    flex: 1;
    padding: 12px;
}

.nav-section-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    padding: 16px 12px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 2px;
    text-decoration: none;
}

.nav-item:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary);
}

.nav-item.active {
    background: var(--accent-gradient);
    color: white;
    box-shadow: var(--shadow-glow);
}

.nav-item .nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.nav-item .nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* ============ MAIN CONTENT ============ */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-width: 0; /* bảng rộng chỉ cuộn trong .table-container, không đẩy cả trang tràn ngang (cả máy tính) */
    min-height: 100vh;
    transition: var(--transition);
}

/* ============ TOP NAVBAR ============ */
.top-navbar {
    position: sticky;
    top: 0;
    z-index: 900;
    height: var(--navbar-height);
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-toggle-sidebar {
    display: block;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
}

.page-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    color: white;
}

.user-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.user-role {
    font-size: 11px;
    color: var(--text-muted);
}

/* ============ PAGE CONTENT ============ */
.page-content {
    padding: 24px;
}

/* ============ CARDS ============ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding: 20px;
}

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

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    border-radius: 4px 0 0 4px;
}

.stat-card.primary::before { background: var(--accent-gradient); }
.stat-card.success::before { background: var(--success); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.danger::before { background: var(--danger); }

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

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-card.primary .stat-icon { background: var(--bg-info); color: var(--info); }
.stat-card.success .stat-icon { background: var(--bg-success); color: var(--success); }
.stat-card.warning .stat-icon { background: var(--bg-warning); color: var(--warning); }
.stat-card.danger .stat-icon { background: var(--bg-danger); color: var(--danger); }

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

/* ============ TABLE ============ */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table thead th {
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    position: sticky;
    top: 0;
}

.data-table tbody tr {
    border-bottom: 1px solid var(--border-light);
    transition: var(--transition);
}

.data-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.05);
}

.data-table tbody td {
    padding: 4px 12px;
    color: var(--text-primary);
    vertical-align: middle;
}

.data-table tfoot td {
    padding: 6px 12px;
    vertical-align: middle;
}

.data-table .text-right {
    text-align: right;
}

.data-table .text-center {
    text-align: center;
}

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-gradient-hover);
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #16a34a;
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
    transform: translateY(-1px);
}

.btn-warning {
    background: var(--warning);
    color: #1e293b;
}

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

.btn-outline:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.1);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 15px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

.btn-icon.btn-sm {
    width: 28px;
    height: 28px;
}

/* ============ FORMS ============ */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    transition: var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-control::placeholder {
    color: var(--text-muted);
}

/* Fix MudBlazor text color */
.mud-input > input.mud-input-root,
.mud-input-slot {
    color: var(--text-primary) !important;
}
.mud-select-input {
    color: var(--text-primary) !important;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 36px;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.validation-message {
    font-size: 12px;
    color: var(--danger);
    margin-top: 4px;
}

/* ============ BADGES ============ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-success { background: var(--bg-success); color: var(--success); }
.badge-danger { background: var(--bg-danger); color: var(--danger); }
.badge-warning { background: var(--bg-warning); color: var(--warning); }
.badge-info { background: var(--bg-info); color: var(--info); }
.badge-default { background: rgba(148, 163, 184, 0.15); color: var(--text-secondary); }

/* ============ TOAST / NOTIFICATION ============ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.3s ease-out;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 300px;
    max-width: 450px;
}

.toast-success {
    background: #065f46;
    color: #a7f3d0;
    border-left: 4px solid var(--success);
}

.toast-error {
    background: #7f1d1d;
    color: #fca5a5;
    border-left: 4px solid var(--danger);
}

.toast-warning {
    background: #78350f;
    color: #fde68a;
    border-left: 4px solid var(--warning);
}

.toast-info {
    background: #312e81;
    color: #c7d2fe;
    border-left: 4px solid var(--info);
}

@keyframes slideIn {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}


/* Utility Classes */
.d-flex { display: flex !important; }
.align-center { align-items: center !important; }
.align-items-center { align-items: center !important; }
.justify-content-center { justify-content: center !important; }
.gap-1 { gap: 4px !important; }
.gap-2 { gap: 8px !important; }
.gap-3 { gap: 16px !important; }
.flex-wrap { flex-wrap: wrap !important; }
.flex-nowrap { flex-wrap: nowrap !important; }
.justify-content-between { justify-content: space-between !important; }
.w-100 { width: 100% !important; }


/* ============ MODAL ============ */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1050;
    backdrop-filter: blur(2px);
}
.modal-dialog {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-secondary);
}
.modal-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}
.modal-body {
    padding: 24px;
    overflow-y: auto;
}

/* ===== MudTable Group expand/collapse cột nhỏ lại (chỉ áp dụng cho bảng có nhóm) ===== */
.grouped-table .mud-table-container table {
    table-layout: fixed !important;
}
.grouped-table .mud-table-container table colgroup col:first-child {
    width: 40px !important;
}
.grouped-table .mud-table-container table thead tr th:first-child,
.grouped-table .mud-table-container table tbody tr td:first-child {
    width: 40px !important;
    max-width: 40px !important;
    min-width: 40px !important;
    padding-left: 4px !important;
    padding-right: 0 !important;
    overflow: hidden;
    text-align: center;
}

/* ======================================================== */
/* ===== GIAO DIỆN RESPONSIVE & ENHANCEMENTS (SUPERPOWERS) ===== */
/* ======================================================== */

/* Desktop Enhancements */
@media (min-width: 1025px) {
    /* Sticky action column for data tables */
    .data-table th:last-child, 
    .data-table td:last-child {
        position: sticky;
        right: 0;
        background: var(--bg-card);
        z-index: 1;
        box-shadow: -2px 0 5px rgba(0,0,0,0.1);
    }
    
    .data-table thead th:last-child {
        background: var(--bg-primary);
        z-index: 2;
    }
}

.summary-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-md);
    width: 350px;
    margin-left: auto;
}

/* Mobile Enhancements */
@media (min-width: 1025px) {
    .app-container.sidebar-collapsed .sidebar {
        transform: translateX(-100%);
    }
    .app-container.sidebar-collapsed .main-content {
        margin-left: 0;
    }
}
@media (max-width: 1024px) {
    .app-container.sidebar-open .sidebar-overlay {
        display: block;
    }
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }
    
    .app-container.sidebar-open .sidebar {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }
    
    .main-content {
        margin-left: 0;
        /* Không cho bảng/biểu đồ rộng đẩy cả trang tràn ngang; bảng tự cuộn trong .table-container */
        min-width: 0;
    }

    .btn-toggle-sidebar {
        display: block;
    }
}

/* ============ ĐIỆN THOẠI: thanh tiêu đề + lưới Dashboard ============ */
@media (max-width: 768px) {
    .top-navbar {
        padding: 0 12px;
        gap: 8px;
    }
    .navbar-left {
        min-width: 0;
        flex: 1;
        gap: 8px;
    }
    .page-title-container {
        min-width: 0;
    }
    .page-title {
        display: block;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .navbar-right {
        flex-shrink: 0;
        gap: 8px;
    }
    /* Chỉ giữ hình tròn chữ cái đầu, ẩn tên + chức vụ */
    .user-info {
        padding: 4px;
    }
    .user-info > div:not(.user-avatar) {
        display: none;
    }
    .page-content {
        padding-left: 16px;
        padding-right: 16px;
    }
    .dash-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Lưới Dashboard: con của lưới được co lại, bảng cuộn bên trong thay vì đẩy rộng trang */
.dash-grid > * {
    min-width: 0;
}

@media (max-width: 768px) {
    /* 1. Touch targets optimization */
    .btn-icon, .btn-icon.btn-sm {
        width: 44px !important;
        height: 44px !important;
        font-size: 18px !important;
    }
    
    .form-control, .mud-input-control {
        min-height: 44px;
        font-size: 16px; /* Prevent zoom on iOS */
    }

    /* 2. Table to Card-list converter */
    .mobile-card-list,
    .mobile-card-list table,
    .mobile-card-list .mud-table-root,
    .mobile-card-list tbody,
    .mobile-card-list .mud-table-container {
        display: block !important;
        width: 100% !important;
    }
    .mobile-card-list thead {
        display: none;
    }
    .mobile-card-list tbody tr {
        display: flex;
        flex-direction: column;
        background: var(--bg-card);
        margin-bottom: 12px;
        border: 1px solid var(--border-color);
        border-radius: var(--radius);
        padding: 12px;
        box-shadow: var(--shadow-sm);
    }
    .mobile-card-list tbody td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding: 8px 0;
        border-bottom: 1px dashed var(--border-light);
        text-align: right;
        gap: 12px;
        word-break: break-word;
    }
    .mobile-card-list tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-secondary);
        text-align: left;
        flex: 0 0 35%; /* Fixed width for label so it doesn't get squished */
    }
    .mobile-card-list tbody td > * {
        flex: 1; /* Allow content to take remaining space */
    }
    .mobile-card-list tbody td:last-child {
        border-bottom: none;
        justify-content: center;
        padding-top: 12px;
    }
    .mobile-card-list tbody td:last-child::before {
        display: none;
    }

    /* 2.5 Filter Actions Mobile */
    .filter-actions-mobile {
        justify-content: space-between !important;
        flex-wrap: nowrap !important;
        width: 100%;
    }
    .filter-actions-mobile .mud-button-root {
        flex: 1;
    }

    /* 3. Sticky Bottom Actions */
    .sticky-bottom-actions {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(15, 23, 42, 0.95);
        backdrop-filter: blur(10px);
        padding: 12px 16px;
        border-top: 1px solid var(--border-color);
        display: flex;
        gap: 12px;
        z-index: 1000;
        box-shadow: 0 -4px 10px rgba(0,0,0,0.2);
    }
    .sticky-bottom-actions .btn {
        flex: 1;
        height: 48px;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    .page-content {
        padding-bottom: 80px; /* Space for sticky bar */
    }
}


/* ============ STOCK OUT LIST: cân đối chiều rộng cột ============ */
@media (min-width: 1025px) {
    .data-table.so-list {
        table-layout: fixed;
        min-width: 1500px;
    }
    .data-table.so-list thead th,
    .data-table.so-list tbody td {
        padding-left: 8px;
        padding-right: 8px;
        overflow: hidden;
    }
    .data-table.so-list thead th {
        font-size: 10px;
        letter-spacing: 0.2px;
    }
    .data-table.so-list td.so-customer {
        font-weight: 500;
        white-space: normal;
        word-break: break-word;
    }
    .data-table.so-list td.number {
        font-size: 12px;
        white-space: nowrap;
    }
}
/* Mã phiếu và các nút thao tác luôn nằm trên 1 dòng, nút sát nhau (chỉ máy tính; điện thoại vẫn dạng thẻ) */
@media (min-width: 1025px) {
    .data-table.so-list td.so-ma {
        white-space: nowrap;
    }
    .data-table.so-list .so-actions {
        flex-wrap: nowrap !important;
        gap: 4px !important;
    }
}

/* Nhóm menu có thể thu gọn */
.nav-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}
.nav-group-toggle:hover {
    color: var(--text-primary);
}
.nav-group-toggle i {
    font-size: 10px;
    opacity: 0.7;
    transition: transform 0.15s;
}
/* Nhóm menu dùng <details>/<summary>: bỏ tam giác mặc định, xoay mũi tên khi mở */
.nav-group > summary {
    list-style: none;
}
.nav-group > summary::-webkit-details-marker {
    display: none;
}
.nav-group[open] > summary .nav-group-chevron {
    transform: rotate(180deg);
}
/* Lớp nền mờ khi mở menu trên điện thoại (js/app.js thêm class sidebar-open vào .app-container) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* Trang Vai trò: điện thoại 1 cột */
@media (max-width: 768px) {
    .vt-grid { grid-template-columns: minmax(0, 1fr) !important; }
}

/* ============ THEME SÁNG (html[data-theme="light"], nút ☀️/🌙 trên thanh trên cùng) ============ */
html[data-theme="light"] {
    --bg-primary: #f1f5f9;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --bg-input: #f8fafc;
    --bg-sidebar: #ffffff;
    --bg-success: rgba(22, 163, 74, 0.12);
    --bg-danger: rgba(220, 38, 38, 0.10);
    --bg-warning: rgba(217, 119, 6, 0.12);
    --bg-info: rgba(79, 70, 229, 0.10);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --accent-primary: #4f46e5;
    --accent-primary-hover: #4338ca;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --info: #4f46e5;
    --border-color: #cbd5e1;
    --border-light: rgba(15, 23, 42, 0.08);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 10px 25px -3px rgba(15, 23, 42, 0.12);
    --shadow-glow: 0 0 20px rgba(79, 70, 229, 0.10);
    color-scheme: light;
}
html[data-theme="light"] .top-navbar { background: rgba(255, 255, 255, 0.88); }
html[data-theme="light"] .sidebar { border-right: 1px solid var(--border-color); }
html[data-theme="light"] .auth-layout { background: linear-gradient(135deg, #e0e7ff 0%, #f1f5f9 100%) !important; }
html[data-theme="light"] .auth-card { background: rgba(255, 255, 255, 0.92) !important; border-color: #e2e8f0 !important; }
html[data-theme="light"] .auth-header h2 { color: #0f172a !important; }
html[data-theme="light"] .auth-header p, html[data-theme="light"] .auth-checkbox { color: #475569 !important; }
html[data-theme="light"] .auth-form-group label { color: #1e293b !important; }
html[data-theme="light"] .auth-input { background: #f8fafc !important; color: #0f172a !important; border-color: #cbd5e1 !important; }

.btn-theme {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 34px; height: 34px;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.btn-theme:hover { color: var(--text-primary); background: var(--bg-card-hover); }
.btn-theme .icon-toi { display: none; }
html[data-theme="light"] .btn-theme .icon-sang { display: none; }
html[data-theme="light"] .btn-theme .icon-toi { display: inline; }
html[data-theme="light"] .sticky-bottom-actions { background: rgba(255, 255, 255, 0.95) !important; }

/* ============ ĐIỆN THOẠI: bảng hàng trong phiếu cuộn ngang thay vì bị cắt cột (22/11/2026) ============ */
@media (max-width: 768px) {
    .table-container > table.bang-hang { min-width: 760px; }
    .table-container > table.bang-hang-ct { min-width: 640px; }
    .table-container > table.bang-hang td:nth-child(2),
    .table-container > table.bang-hang th:nth-child(2) { min-width: 220px; }
    .btn-sm { min-height: 38px; }
    .btn-icon.btn-sm { min-width: 38px; }
}
/* Nút trên thanh lọc không co cắt chữ, hết chỗ thì xuống dòng */
.filter-actions-mobile > .mud-button-root { flex-shrink: 0; }

/* ============ TRANG ĐĂNG NHẬP / 2 LỚP / KHÓA (chuyển từ Login.razor 22/11/2026, dùng chung AuthLayout) ============ */
    .auth-card {
        background: rgba(32, 33, 44, 0.7);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 20px;
        padding: 40px;
        width: 100%;
        max-width: 420px;
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    }

    .auth-header {
        text-align: center;
        margin-bottom: 30px;
    }

    .auth-logo {
        width: 64px;
        height: 64px;
        background: linear-gradient(135deg, #7c3aed 0%, #3b82f6 100%);
        border-radius: 16px;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0 auto 16px;
        font-size: 32px;
        color: white;
        box-shadow: 0 10px 20px -10px rgba(124, 58, 237, 0.8);
    }

    .auth-header h2 {
        color: white;
        font-size: 24px;
        font-weight: 700;
        margin: 0 0 8px 0;
        letter-spacing: 1px;
    }

    .auth-header p {
        color: #94a3b8;
        font-size: 14px;
        margin: 0;
    }

    .auth-form-group {
        margin-bottom: 20px;
    }

    .auth-form-group label {
        display: block;
        color: #e2e8f0;
        font-size: 13px;
        font-weight: 500;
        margin-bottom: 8px;
    }

    .input-wrapper {
        position: relative;
    }

    .input-wrapper i {
        position: absolute;
        left: 16px;
        top: 50%;
        transform: translateY(-50%);
        color: #64748b;
        font-size: 16px;
    }

    .auth-input {
        width: 100%;
        background: rgba(15, 23, 42, 0.6);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 12px;
        padding: 12px 16px 12px 48px;
        color: white;
        font-size: 14px;
        transition: all 0.2s ease;
        box-sizing: border-box;
    }

    .auth-input:focus {
        outline: none;
        border-color: #7c3aed;
        background: rgba(15, 23, 42, 0.9);
        box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
    }

    .auth-error-msg {
        color: #ef4444;
        font-size: 12px;
        margin-top: 4px;
        display: block;
    }

    .auth-form-options {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 24px;
    }

    .auth-checkbox {
        display: flex;
        align-items: center;
        gap: 8px;
        color: #94a3b8;
        font-size: 13px;
        cursor: pointer;
    }

    .auth-link {
        color: #7c3aed;
        font-size: 13px;
        text-decoration: none;
        transition: color 0.2s;
    }

    .auth-link:hover {
        color: #9353d3;
        text-decoration: underline;
    }

    .auth-btn {
        width: 100%;
        background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
        color: white;
        border: none;
        border-radius: 12px;
        padding: 14px;
        font-size: 15px;
        font-weight: 600;
        letter-spacing: 0.5px;
        cursor: pointer;
        transition: all 0.2s ease;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }

    .auth-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 10px 20px -10px rgba(124, 58, 237, 0.8);
    }

    .auth-btn:active {
        transform: translateY(0);
    }
/* Thông báo trên các trang đăng nhập / 2 lớp (nền tối) */
.auth-card .alert { padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }
.auth-card .alert-danger { color: #fca5a5; background: rgba(239, 68, 68, 0.12); border: 1px solid rgba(239, 68, 68, 0.3); }
.auth-card .alert-success { color: #86efac; background: rgba(34, 197, 94, 0.12); border: 1px solid rgba(34, 197, 94, 0.3); }
html[data-theme="light"] .auth-card .alert-danger { color: #b91c1c; }
html[data-theme="light"] .auth-card .alert-success { color: #15803d; }
.auth-card .auth-input.khong-icon { padding-left: 16px; }

/* Xuất Excel SPX: trên điện thoại (dạng thẻ) ẩn ô chọn trống của phiếu chưa hoàn tất */
@media (max-width: 768px) {
    .so-list td.spx-o-trong { display: none !important; }
}
