/* =====================================================
   LCD Pro - MOBILE-FIRST CSS
   ===================================================== */

:root {
    --primary: #2563EB;
    --primary-dark: #1D4ED8;
    --primary-light: #DBEAFE;
    --primary-rgb: 37, 99, 235;      /* dùng trong rgba(var(--primary-rgb), .x) */
    --primary-soft: #93C5FD;
    --primary-2: #60A5FA;
    --success: #16A34A;
    --success-light: #DCFCE7;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --danger: #DC2626;
    --danger-light: #FEE2E2;
    --info: #0891B2;
    --info-light: #CFFAFE;
    --secondary: #6B7280;
    --purple: #7C3AED;

    --bg: #F0F2F5;
    --bg-card: #FFFFFF;
    --text: #1F2937;
    --text-muted: #9CA3AF;
    --border: #E5E7EB;

    --sidebar-bg: #FFFFFF;
    --sidebar-text: #4B5563;
    --sidebar-active: #EFF6FF;
    --sidebar-width: 280px;

    --bottom-nav-height: 68px;
    --top-bar-height: 56px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.1);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    padding-top: var(--top-bar-height);
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: var(--primary); }
a:hover { opacity: 0.8; }
img { max-width: 100%; height: auto; }

/* ===== TOP BAR ===== */
.top-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--top-bar-height);
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    z-index: 200;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.hamburger {
    width: 40px; height: 40px;
    border: none; background: none;
    font-size: 22px; color: var(--text);
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}
.hamburger:active { background: var(--bg); }

.page-title {
    font-size: 17px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 2px;
}

.btn-quick-add {
    width: 40px; height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--primary);
    font-size: 26px;
}
.btn-quick-add:active { background: var(--primary-light); }

.btn-icon {
    width: 40px; height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--secondary);
    font-size: 18px;
}
.btn-icon:active { background: var(--bg); }

/* ===== OVERLAY ===== */
.overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 110;
    display: none;
}
.overlay.show { display: block; }

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    padding-bottom: constant(safe-area-inset-bottom, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--sidebar-bg);
    z-index: 300;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 12px rgba(0,0,0,0.1);
}
.sidebar.open { transform: translateX(0); }

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

.sidebar-brand { display: flex; align-items: center; gap: 12px; }
.sidebar-brand:hover { text-decoration: none; }

.brand-icon {
    width: 40px; height: 40px;
    background: var(--primary);
    color: white;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}
.brand-name { font-size: 18px; font-weight: 700; color: var(--text); display: block; }
.brand-sub { font-size: 11px; color: var(--text-muted); display: block; }

.sidebar-close {
    width: 36px; height: 36px;
    border: none; background: var(--bg);
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--secondary);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: #F9FAFB;
}

.user-avatar {
    width: 40px; height: 40px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}

.user-info-text { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-size: 14px; font-weight: 600; color: var(--text); }
.user-role { font-size: 12px; color: var(--text-muted); }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 20px;
    color: var(--sidebar-text);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}
.nav-item i { width: 22px; text-align: center; font-size: 16px; color: var(--secondary); }
.nav-item:active { background: var(--bg); }
.nav-item.active {
    background: var(--sidebar-active);
    color: var(--primary);
    border-left-color: var(--primary);
}
.nav-item.active i { color: var(--primary); }
.nav-item:hover { text-decoration: none; }

.nav-divider {
    margin: 8px 16px;
    border: none;
    border-top: 1px solid var(--border);
}

.nav-logout { margin-top: auto; color: var(--danger) !important; }
.nav-logout i { color: var(--danger) !important; }

/* ===== BOTTOM NAV ===== */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: calc(var(--bottom-nav-height) + constant(safe-area-inset-bottom, 0px));
    height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
    background: white;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: stretch;
    z-index: 100;
    padding-bottom: constant(safe-area-inset-bottom, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 500;
    padding: 4px 0;
    position: relative;
}
.bottom-nav-item i { font-size: 20px; }
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item:active { background: var(--bg); }
.bottom-nav-item:hover { text-decoration: none; }

.bottom-nav-center {
    position: relative;
}

.fab-btn {
    width: 52px; height: 52px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(var(--primary-rgb),0.4);
    margin-top: -14px;
}
.fab-btn:active { transform: scale(0.95); }

/* ===== MAIN CONTENT ===== */
.main-content {
    padding-bottom: calc(var(--bottom-nav-height) + constant(safe-area-inset-bottom, 0px));
    padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
    min-height: calc(100vh - var(--top-bar-height));
    min-height: calc(100dvh - var(--top-bar-height));
}

.content-body {
    padding: 12px;
}

/* ===== ALERTS ===== */
.alert {
    padding: 12px 16px;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border-bottom: 1px solid transparent;
    animation: slideDown 0.3s ease;
}
@keyframes slideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.alert-success { background: var(--success-light); color: #166534; border-color: #BBF7D0; }
.alert-danger { background: var(--danger-light); color: #991B1B; border-color: #FECACA; }
.alert-warning { background: var(--warning-light); color: #92400E; border-color: #FDE68A; }
.alert-info { background: var(--info-light); color: #155E75; border-color: #A5F3FC; }
.alert-close { background: none; border: none; font-size: 20px; cursor: pointer; opacity: 0.6; padding: 4px; }

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 12px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}
.card-header h3 { margin-right: auto; }
.card-header h3 {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
.card-body { padding: 16px; }
.card-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg);
    border-radius: 0 0 var(--radius) var(--radius);
}

.p-0 { padding: 0 !important; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 10px; }
.mt-3 { margin-top: 16px; }
.mb-2 { margin-bottom: 10px; }
.mb-3 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.hidden { display: none !important; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }

/* ===== STAT CARDS (Dashboard) ===== */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
    position: relative;
    border: 1px solid var(--border);
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.stat-card .stat-value {
    font-size: 22px;
    font-weight: 700;
}

.stat-card .stat-icon {
    position: absolute;
    top: 12px; right: 12px;
    width: 36px; height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    opacity: 0.8;
}

.stat-color-primary .stat-icon { background: var(--primary-light); color: var(--primary); }
.stat-color-primary { border-left: 3px solid var(--primary); }
.stat-color-success .stat-icon { background: var(--success-light); color: var(--success); }
.stat-color-success { border-left: 3px solid var(--success); }
.stat-color-warning .stat-icon { background: var(--warning-light); color: var(--warning); }
.stat-color-warning { border-left: 3px solid var(--warning); }
.stat-color-info .stat-icon { background: var(--info-light); color: var(--info); }
.stat-color-info { border-left: 3px solid var(--info); }
.stat-color-purple .stat-icon { background: #EDE9FE; color: var(--purple); }
.stat-color-purple { border-left: 3px solid var(--purple); }
.stat-color-danger .stat-icon { background: var(--danger-light); color: var(--danger); }
.stat-color-danger { border-left: 3px solid var(--danger); }

/* Full-width stat row */
.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 8px;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn:hover { text-decoration: none; }

.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:active { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger-outline { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger-outline:hover { background: var(--danger); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-info { background: var(--info); color: white; }
.btn-outline { background: white; color: var(--text); border-color: var(--border); }
.btn-outline:active { background: var(--bg); }
.btn-ghost { background: none; color: var(--text); border: none; }
.btn-secondary { background: var(--secondary); color: white; }
.btn-dark { background: #1F2937; color: white; }

.btn-sm { padding: 6px 12px; font-size: 12px; min-height: 32px; }
.btn-lg { padding: 14px 24px; font-size: 16px; min-height: 48px; }
.btn-block { width: 100%; display: flex; justify-content: center; }
.btn-icon-only { width: 44px; height: 44px; padding: 0; border-radius: 50%; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 14px; }
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}
.required { color: var(--danger); }

.form-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    color: var(--text);
    background: white;
    transition: border-color 0.2s;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
}
.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb),0.1);
}
.form-input::placeholder { color: var(--text-muted); }

select.form-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%236B7280'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 20px;
    padding-right: 36px;
}

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

.form-row {
    display: flex;
    gap: 10px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-direction: column;
}
.form-actions .btn { flex: 1; }

/* Search + toolbar */
.toolbar {
    margin-bottom: 12px;
}

/* Thanh thống kê gọn (trang Công việc được giao) */
.stat-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 18px;
    padding: 7px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .85rem;
    color: var(--text-muted);
}
.stat-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.stat-item strong {
    font-size: .95rem;
    color: var(--text);
}

/* Bộ lọc thu gọn (trang Công việc được giao) */
.filter-card .card-header.filter-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}
.filter-chevron {
    color: var(--text-muted);
    font-size: .85rem;
    transition: transform .2s ease;
}
.filter-card.collapsed .filter-chevron {
    transform: rotate(-90deg);
}
/* Mobile: ẩn thân bộ lọc khi thu gọn */
.filter-card.collapsed .card-body {
    display: none;
}
/* Desktop: luôn hiển thị đầy đủ, ẩn mũi tên */
@media (min-width: 768px) {
    .filter-card .card-body { display: block; }
    .filter-chevron { display: none; }
    .filter-card .card-header.filter-toggle { cursor: default; }
}

.search-box {
    position: relative;
}
.search-box .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 16px;
}
.search-box .form-input { padding-left: 42px; }

/* Suggestions dropdown */
.suggestions-box {
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    max-height: 240px;
    overflow-y: auto;
    z-index: 50;
    display: none;
    box-shadow: var(--shadow-lg);
}
.suggestions-box.show { display: block; }

.suggestion-item {
    padding: 12px 14px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
    -webkit-tap-highlight-color: transparent;
}
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:active { background: var(--primary-light); }

/* ===== TABLES ===== */
.table-container {
    overflow-x: auto;
    margin: 0;
    max-width: 100%;
}

.table {
    width: 100%;
    border-collapse: collapse;
    min-width: 100%;
}

.table th, .table td {
    padding: 10px 12px;
    text-align: left;
    font-size: 13px;
    white-space: nowrap;
}

.table th {
    font-weight: 600;
    color: var(--secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: #F9FAFB;
    position: sticky;
    top: 0;
}

.table tbody tr {
    border-bottom: 1px solid var(--border);
    background-color: #ffffff;   /* nền trắng cho từng dòng */
}
.table tbody tr:active { background: #F3F4F6; }

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

.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: #92400E; }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-secondary { background: #F3F4F6; color: var(--secondary); }

/* ===== MODAL ===== */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 500;
    animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
    background: white;
    border-radius: 16px 16px 0 0;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.modal-full .modal-content {
    border-radius: 0;
    max-height: 100vh;
    height: 100vh;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }

.modal-close {
    width: 36px; height: 36px;
    background: none; border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}
.modal-close:active { background: var(--bg); }

.modal-body { padding: 16px 20px; }
.modal-footer {
    display: flex;
    gap: 10px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: #F9FAFB;
}

/* ===== TRẢ HÀNG (trang chi tiết đơn): trên trang chỉ có một nút, bảng trả hàng nằm trong popup #deliverModal ===== */
.dlv-open { gap: 8px; flex-wrap: wrap; white-space: normal; }
.dlv-count {
    font-size: 12px; font-weight: 600; line-height: 1;
    padding: 4px 9px; border-radius: 999px;
    background: rgba(255,255,255,0.24); white-space: nowrap;
}
.btn-outline .dlv-count { background: var(--bg); color: var(--text-muted); }
/* (2.7.0) dòng hàng còn công đoạn chưa xong thì chưa trả được: nút khoá + hộp cảnh báo nêu công đoạn / nhân viên */
.dlv-open.is-locked, .dlv-open.is-locked:disabled { opacity: 1; cursor: not-allowed; color: var(--text-muted); background: var(--bg); border-style: dashed; box-shadow: none; }
.dlv-warn { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: #FFFBEB; border: 1px solid #FCD34D; color: #92400E; font-size: 13px; }
.dlv-warn-title { font-weight: 700; }
.dlv-warn ul { margin: 6px 0 0; padding-left: 20px; }
.dlv-warn li { margin: 2px 0; }
.dlv-warn-line { color: #B45309; }
.dlv-lock { margin-top: 3px; font-size: 12px; font-weight: 400; color: #B45309; white-space: normal; }
.dlv-lock-ico { color: #B45309; }
.dlv-row-locked td { background: #FFFBEB; }
.dlv-warn-n { font-size: 12px; white-space: nowrap; }
/* (2.8.0) chốt công đoạn theo từng quả: số quả đã xong trên nút + các dòng trong hộp thoại hỏi số quả */
.step-qty { font-weight: 700; margin-left: 2px; padding: 0 6px; border-radius: 999px; background: var(--bg); }
.step-ask-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.step-ask-row:first-of-type { border-top: 0; }
.step-ask-name { flex: 1 1 auto; min-width: 0; font-size: 13.5px; }
.step-ask-qty { flex: 0 0 84px; width: 84px; text-align: center; padding: 8px 6px; font-size: 16px; font-weight: 700; }
.modal-content.dlv-modal { max-width: 620px; }
.dlv-modal .modal-header h3 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
/* nút "Trả hàng" luôn nằm dưới đáy popup, đơn nhiều dòng không phải cuộn mới thấy */
.dlv-modal .modal-footer { position: sticky; bottom: 0; z-index: 1; }
.dlv-modal .modal-footer .btn-outline { flex: 0 0 auto; }
.dlv-modal .modal-footer .btn-success { flex: 1 1 auto; }
/* trong popup bảng không có lề hẹp sẵn như bảng nằm trong thẻ: thu ô lại để cột "Trả lần này" không bị đẩy ra ngoài màn hình điện thoại */
.dlv-modal .modal-body { padding: 14px 16px; }
.modal .dlv-modal table.table th, .modal .dlv-modal table.table td { padding-left: 6px; padding-right: 6px; }
.modal .dlv-modal table.table th { letter-spacing: 0; }
.modal .dlv-modal table.table td:first-child { white-space: normal; }
/* trên điện thoại mọi bảng trong trang bị đổi thành khối cuộn ngang (display:block) - trong popup thì để bảng dàn đủ bề ngang */
.modal .dlv-modal table.table { display: table; }

/* ===== KANBAN ===== */
.kanban-board-mobile {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.kanban-group {
    background: white;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

.kanban-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    font-weight: 600;
    font-size: 14px;
}
.kanban-group-header .count {
    background: var(--bg);
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.kanban-group-body { padding: 0 12px 12px; }
.kanban-group-body:empty { padding: 0; }

/* Kanban card */
.kanban-card {
    background: #F9FAFB;
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
}
.kanban-card:last-child { margin-bottom: 0; }
.kanban-card:active { background: #F3F4F6; }

.kanban-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
}
.kanban-card-code {
    font-weight: 600;
    font-size: 14px;
}
.kanban-card-body { font-size: 13px; color: var(--secondary); }
.kanban-card-body p { margin: 2px 0; }
.kanban-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

/* Quick action buttons */
.quick-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

/* Kanban nhóm theo StepGroup */
.kanban-section {
    background: #fff;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}
.kanban-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    font-weight: 700;
    font-size: 15px;
    border-bottom: 1px solid var(--border);
    background: #FAFAFB;
}
.kanban-section-header .count {
    background: var(--primary, #2563EB);
    color: #fff;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.kanban-section-body {
    padding: 10px 12px 12px;
}
.kanban-section-body .kanban-group {
    background: #FCFCFD;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    overflow: hidden;
}
.kanban-section-body .kanban-group:last-child {
    margin-bottom: 0;
}
.kanban-section-body .kanban-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    font-weight: 600;
    font-size: 14px;
    background: #fff;
}
.kanban-section-body .kanban-group-body {
    padding: 0 12px 10px;
}
.step-empty {
    display: none;
}
.btn-show-empty {
    width: 100%;
    margin-top: 8px;
}

/* ===== SECTION TITLES ===== */
.section-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== ORDER LIST ITEMS (mobile) ===== */
.order-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.order-item-pay {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    padding: 8px 10px;
    background: var(--bg);
    border-radius: 8px;
    font-size: 13px;
}

/* ===== ORDER TABLE (desktop) ===== */
.order-table { display: none; }
.order-table tbody tr:hover { background: #F3F4F6; }
.order-table .text-muted { color: var(--text-muted); }

.order-item {
    background: white;
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
.order-item:active { background: #F9FAFB; }

.order-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
}
.order-item-code {
    font-weight: 700;
    font-size: 15px;
    color: var(--primary);
}
.order-item-body { font-size: 13px; color: var(--secondary); }
.order-item-body p { margin: 2px 0; display: flex; gap: 6px; align-items: center; }
.order-item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

/* ===== TIMELINE ===== */
.timeline {
    padding: 0;
}
.timeline-item {
    display: flex;
    gap: 12px;
    padding-bottom: 16px;
    position: relative;
}
.timeline-item::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 28px;
    bottom: 0;
    width: 2px;
    background: var(--border);
}
.timeline-item:last-child::before { display: none; }
.timeline-item:last-child { padding-bottom: 0; }

.timeline-marker {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
    z-index: 1;
}

.timeline-item.completed .timeline-marker { background: var(--success); color: white; border-color: var(--success); }
.timeline-item.active .timeline-marker { background: var(--primary); color: white; border-color: var(--primary); }

.timeline-content {
    flex: 1;
    padding-top: 4px;
}
.timeline-step { font-weight: 600; font-size: 14px; }
.timeline-info { font-size: 12px; color: var(--text-muted); }

/* ===== BOTTOM SHEET ===== */
.bottom-sheet {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: white;
    border-radius: 16px 16px 0 0;
    z-index: 500;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
}
.bottom-sheet.open { transform: translateY(0); }

.sheet-handle {
    width: 36px; height: 4px;
    background: #D1D5DB;
    border-radius: 2px;
    margin: 8px auto;
}

/* ===== FILTER TABS ===== */
.filter-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
}
.filter-scroll::-webkit-scrollbar { display: none; }

.filter-tabs {
    display: flex;
    gap: 6px;
    white-space: nowrap;
}

.filter-tab {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--secondary);
    background: white;
    border: 1px solid var(--border);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.filter-tab:active { background: var(--bg); }
.filter-tab.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ===== LINE TYPE TABS (Mẫu pin / Sản phẩm / Cell) ===== */
.line-type-btn {
    padding: 5px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid var(--border);
    background: white;
    color: var(--secondary);
    cursor: pointer;
    transition: all 0.15s;
}
.line-type-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

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

/* ===== IMAGE GALLERY ===== */
.gallery-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
}
.gallery-scroll::-webkit-scrollbar { display: none; }

.gallery-item {
    width: 100px;
    height: 100px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    flex-shrink: 0;
}
.gallery-item img { width: 100%; height: 100%; object-fit: cover; }

/* ===== BUTTON GRID ===== */
.btn-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.btn-grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 16px;
    background: white;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    box-shadow: var(--shadow);
}
.btn-grid-item i { font-size: 24px; color: var(--primary); }
.btn-grid-item:active { background: var(--bg); transform: scale(0.97); }
.btn-grid-item:hover { text-decoration: none; }

/* ===== TABS ===== */
.tabs {
    display: flex;
    gap: 0;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 12px;
}

.tab {
    flex: 1;
    text-align: center;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--secondary);
    background: none;
    border: none;
    cursor: pointer;
}
.tab.active { background: white; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* ===== LOGIN PAGE ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #1E293B 0%, var(--primary) 100%);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: white;
    border-radius: 20px;
    padding: 32px 24px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.login-header { text-align: center; margin-bottom: 32px; }

.login-logo {
    width: 72px; height: 72px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 18px;
    display: flex;
    align-items: center; justify-content: center;
    margin: 0 auto 16px;
    font-size: 32px; color: white;
    box-shadow: 0 4px 12px rgba(var(--primary-rgb),0.3);
}

.login-title { font-size: 24px; font-weight: 700; }
.login-subtitle { font-size: 14px; color: var(--text-muted); margin-top: 4px; }

.login-input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 16px;
    margin-bottom: 14px;
    background: #F9FAFB;
}
.login-input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
}

/* ===== RESPONSIVE - TABLET & UP ===== */
@media (min-width: 768px) {
    body.has-bottom-nav {
        padding-top: 0;
        padding-left: var(--sidebar-width);
    }

    .top-bar {
        position: static;
        border-bottom: 1px solid var(--border);
    }

    .bottom-nav { display: none; }

    .sidebar {
        transform: translateX(0);
        box-shadow: none;
        border-right: 1px solid var(--border);
    }

    .overlay { display: none !important; }

    .main-content {
        padding-bottom: 0;
        min-height: 100vh;
    }

    .hamburger { display: none; }
    .sidebar-close { display: none; }
    .btn-quick-add { display: none; }

    .content-body {
        padding: 20px 24px;
    }

    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }

    .form-actions {
        flex-direction: row;
    }

    .order-list {
        display: block;
    }
    .order-item { display: none; }
    .order-table { display: table; }

    .kanban-board-mobile {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 16px;
    }

    .modal {
        align-items: center;
    }
    .modal-content {
        border-radius: 16px;
        width: 90%;
        max-width: 500px;
        max-height: 80vh;
    }
    .modal-full .modal-content {
        border-radius: 16px;
        height: auto;
        max-height: 90vh;
    }

    .btn-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ===== PRINT ===== */
@media print {
    .bottom-nav, .top-bar, .sidebar, .fab-btn, .btn, .toolbar { display: none !important; }
    body.has-bottom-nav { padding-left: 0; padding-top: 0; }
}

/* ===== Chuong thong bao + ho so ca nhan ===== */
.notif-badge {
    position: absolute;
    top: 2px; right: 2px;
    min-width: 17px; height: 17px;
    padding: 0 4px;
    background: var(--danger);
    color: #fff;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border: 2px solid #fff;
    box-sizing: border-box;
}

.user-avatar-img {
    width: 40px; height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

a.sidebar-user { text-decoration: none; color: inherit; cursor: pointer; }
a.sidebar-user:hover { background: #F3F4F6; }

.profile-avatar-lg {
    width: 84px; height: 84px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.profile-avatar-initial {
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
}

.stat-mini {
    min-width: 130px;
    padding: 10px 14px;
    background: var(--bg);
    border-radius: var(--radius-sm);
}
.stat-mini-num { font-size: 1.15rem; font-weight: 700; color: var(--text); }

.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ===== Anh chan cong ===== */
.att-thumb {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
    margin-right: 4px;
    vertical-align: middle;
}

/* Dashboard stat cards clickable */
a.stat-card { text-decoration:none; color:inherit; }
a.stat-card:hover { opacity:0.8; }


/* ===== Gia cố hiển thị MOBILE (chống che khuất / tràn / vỡ layout) ===== */
@media (max-width: 767px) {
    /* Bảng dài tự cuộn ngang thay vì bị cắt */
    .content-body table.table,
    .card-body table.table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }
    /* Hàng form xuống dòng khi hẹp */
    .form-row { flex-wrap: wrap; }
    .form-row > .form-group,
    .form-row > div { min-width: 46%; flex: 1 1 46%; }
    /* Ảnh không tràn khung */
    .content-body img { max-width: 100%; height: auto; }
    /* Modal không tràn màn hình */
    .modal-content { max-height: 88vh; overflow-y: auto; }
    /* Toolbar & nút không tràn */
    .toolbar { gap: 6px; }
    .toolbar .btn { white-space: nowrap; }
    .btn-block { width: 100%; box-sizing: border-box; }
    /* Thẻ thống kê đều 2 cột */
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    /* Ô nhập & chọn không tràn */
    .form-input, select.form-input { max-width: 100%; }
    /* Kanban & nội dung ngang có cuộn mượt */
    .content-body .overflow-auto,
    .kanban-board { -webkit-overflow-scrolling: touch; }
    /* Menu kéo dài không bị chìm dưới thanh công cụ trình duyệt */
    .sidebar {
        height: 100dvh;
        height: 100vh;
        min-height: -webkit-fill-available;
        overscroll-behavior: contain;
    }
    .sidebar-nav {
        padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px));
        -webkit-overflow-scrolling: touch;
    }
    .sidebar-nav::-webkit-scrollbar { width: 4px; }
    .sidebar-nav::-webkit-scrollbar-thumb { background: rgba(0,0,0,.18); border-radius: 4px; }
}


/* Timeline công đoạn trên mobile: đầy đủ nội dung, không tràn/cắt */
@media (max-width: 767px) {
    .timeline-content { min-width: 0; }
    .timeline-content .flex-between { flex-wrap: wrap; gap: 4px 6px; align-items: flex-start; }
    .timeline-step { min-width: 0; flex: 1 1 auto; overflow-wrap: anywhere; }
    .timeline-content .badge { flex: 0 0 auto; }
    .timeline-info {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 2px 8px;
        overflow-wrap: anywhere;
    }
    .timeline-info .text-sm,
    .timeline-info strong,
    .timeline-info .btn-link { min-width: 0; overflow-wrap: anywhere; }
    .timeline-info .btn-outline { white-space: normal; }
}


/* Timeline công đoạn mobile: KHÔNG xuống dòng — cuộn ngang như bảng lương */
@media (max-width: 767px) {
    .timeline-content { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .timeline-content .flex-between { flex-wrap: nowrap !important; min-width: max-content; gap: 8px 10px; }
    .timeline-content .timeline-info {
        flex-wrap: nowrap !important;
        min-width: max-content;
        display: flex;
        align-items: center;
        gap: 8px;
        white-space: nowrap;
    }
    .timeline-step { white-space: nowrap; }
    .timeline-info .btn-outline,
    .timeline-info .btn-link { white-space: nowrap; }
}


/* Dòng công đoạn + NV phụ trách trong TẠO/SỬA đơn: cuộn ngang như bảng lương */
@media (max-width: 767px) {
    .battery-steps { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 6px; }
    .battery-steps .steps-list { min-width: max-content; }
    .battery-steps .step-row {
        flex-wrap: nowrap !important;
        min-width: max-content;
        width: max-content;
        padding-right: 4px;
    }
    .battery-steps .step-row select,
    .battery-steps .step-row input { flex: 0 0 auto !important; }
    .battery-steps .step-row .step-select { min-width: 170px; }
    .battery-steps .step-row .step-staff { min-width: 130px; }
    .battery-steps .step-row .step-price { min-width: 110px; }
}


/* Bước cuối: ô công đoạn mobile rộng đủ hiển thị TRỌN nội dung từng ô (stack dọc) */
@media (max-width: 767px) {
    .battery-steps { overflow-x: visible; }
    .battery-steps .steps-list,
    .battery-steps .step-row { min-width: 0 !important; width: 100% !important; }
    .battery-steps .step-row {
        flex-wrap: wrap !important;
        align-items: stretch;
        gap: 6px;
    }
    .battery-steps .step-row select,
    .battery-steps .step-row input {
        flex: 1 1 100% !important;
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
        padding: 10px 8px;
        font-size: 14px;
        white-space: normal;
    }
    .battery-steps .step-row .remove-step { flex: 0 0 auto; margin-left: auto; }
}


/* PHẦN CÔNG ĐOẠN TẠO ĐƠN (MOBILE): KÉO NGANG như bảng lương — mỗi hàng giữ 1 dòng đầy đủ */
@media (max-width: 767px) {
    .battery-steps {
        overflow-x: auto;
        overflow-y: visible;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 8px;
    }
    .battery-steps .steps-list,
    .battery-steps .step-row {
        width: max-content !important;
        min-width: 0 !important;
    }
    .battery-steps .step-row {
        flex-wrap: nowrap !important;
        align-items: center;
        gap: 8px;
    }
    .battery-steps .step-row select,
    .battery-steps .step-row input {
        flex: 0 0 auto !important;
        width: auto;
        min-width: 0;
        box-sizing: border-box;
    }
    .battery-steps .step-row .step-select { min-width: 180px; }
    .battery-steps .step-row .step-staff { min-width: 160px; }
    .battery-steps .step-row .step-price { min-width: 130px; }
    .battery-steps .step-row .remove-step { flex: 0 0 auto; }
}


/* Ô tiền công trong Tạo đơn: gọn + dấu phẩy hàng nghìn ngay dưới ô */
.battery-steps .step-price { width: 104px !important; min-width: 104px !important; }
.battery-steps .step-price { padding: 8px 6px; font-size: 13px; }
.battery-steps .price-wrap .money-badge {
    position: absolute;
    top: calc(100% + 1px);
    left: 0;
    font-size: 10px !important;
    line-height: 1.1 !important;
    margin: 0 !important;
    padding: 0 2px;
    background: var(--bg, #f3f4f6);
    border-radius: 4px;
    pointer-events: none;
    white-space: nowrap;
    z-index: 2;
}
.battery-steps .step-row { padding-bottom: 14px; }
@media (max-width: 767px) {
    .battery-steps .step-row .step-price,
    .battery-steps .step-price { width: 96px !important; min-width: 96px !important; }
}


/* ===== BẢNG LƯƠNG CÁ NHÂN (gọn) ===== */
.salary-period { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.salary-period .form-input { height: 34px; padding: 4px 8px; font-size: 13px; width: auto; min-width: 96px; }
.salary-period .btn { height: 34px; padding: 0 12px; }
.salary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.salary-cell {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 8px 10px; background: #ffffff;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.salary-cell .lbl { font-size: 12px; color: var(--text-muted); }
.salary-cell .val { font-size: 14px; font-weight: 700; color: var(--text); white-space: nowrap; }
.salary-cell.hl { background: rgba(22, 163, 74, .10); border-color: rgba(22, 163, 74, .40); }
.salary-cell.hl .val { color: var(--success); }
@media (max-width: 720px) { .salary-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 420px) { .salary-grid { grid-template-columns: 1fr; } }


/* ===== SỬA TRÙNG ĐƠN: chỉ hiện 1 kiểu danh sách = card (mobile) HOẶC bảng (desktop) ===== */
.order-item { display: block; text-decoration: none; color: inherit; }
.order-table-wrap { margin-top: 0; }
@media (min-width: 768px) {
    .order-list { display: none !important; }      /* desktop: ẩn danh sách card */
    .order-table, .order-table-wrap { display: block !important; }
    .order-table { display: table !important; }
}
@media (max-width: 767px) {
    .order-list { display: flex !important; }      /* mobile: hiện danh sách card */
    .order-table-wrap, .order-table { display: none !important; }
}

/* ===== DESKTOP: hiện HẾT tab trạng thái/thanh toán (xuống dòng, không bị cắt) ===== */
@media (min-width: 768px) {
    .filter-scroll {
        overflow-x: visible;
        padding-bottom: 0;
    }
    .filter-tabs {
        flex-wrap: wrap;
        white-space: normal;
        row-gap: 8px;
    }
    .filter-tab {
        flex: 0 0 auto;          /* giữ nguyên kích thước, không co giãn */
    }
}


/* ===== Ngày đơn / Ngày hoàn thành trên đầu đơn hàng ===== */
.order-dates { text-align: right; line-height: 1.5; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 2px 10px; }
.order-dates > div, .od-item { white-space: nowrap; }
/* nút nhỏ "Sửa ngày" cạnh ngày -> mở popup #dateModal (thay hai khung nhập ngày to ở khối công cụ) */
.od-edit {
    display: inline-flex; align-items: center; gap: 5px;
    min-height: 30px; padding: 3px 11px;
    border: 1px solid var(--border); border-radius: 999px;
    background: #fff; color: var(--primary);
    font: inherit; font-size: 12px; font-weight: 600;
    cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.od-edit:active { background: var(--bg); }
.date-modal .date-row + .date-row { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.date-row-line { display: flex; gap: 8px; align-items: center; }
.date-row-line .form-input { flex: 1 1 auto; min-width: 0; }
.date-row-line .btn { flex: 0 0 auto; }
/* khối công cụ giờ bắt đầu ngay bằng hàng nút: bỏ khoảng trống 20px phía trên */
#orderToolsCard .form-actions { margin-top: 0; }

/* MOBILE: xếp dọc, mỗi ngày 1 dòng, thẳng hàng bên trái — giống nhau */
@media (max-width: 767px) {
    .order-head { flex-wrap: wrap; gap: 6px; }
    .order-dates { text-align: left; width: 100%; margin-top: 2px; justify-content: flex-start; }
    .order-dates > div { white-space: normal; }
}


/* ===== Xem trước ảnh đang tự tải lên ===== */
.upload-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.upload-tile { position: relative; width: 84px; height: 84px; border-radius: 8px; overflow: hidden;
    border: 1px solid var(--border); background: var(--bg); display: flex; align-items: center;
    justify-content: center; font-size: 11px; text-align: center; }
.upload-tile img { width: 100%; height: 100%; object-fit: cover; }
.upload-tile .up-status { position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 3px;
    background: rgba(0, 0, 0, .55); color: #fff; line-height: 1.25; }
.upload-tile.is-loading { border-style: dashed; }
.upload-tile.is-loading .up-status { position: static; background: none; color: var(--muted); }
.upload-tile.is-error { border-color: var(--danger); }
.upload-tile.is-error .up-status { position: static; background: none; color: var(--danger); }
.upload-tile .up-retry { margin-top: 4px; font-size: 11px; padding: 2px 6px; border-radius: 6px;
    border: 1px solid var(--border); background: #fff; cursor: pointer; }


/* ===== Danh sách KHÁCH HÀNG (mobile gọn & chuyên nghiệp) ===== */
.list-meta { font-size: 12.5px; color: var(--muted); margin: 10px 2px 8px; }
.quick-actions { display: flex; gap: 8px; margin-top: 8px; }
.quick-actions .btn { flex: 1; justify-content: center; }

.cust-row { display: flex; align-items: center; gap: 10px; padding: 12px 14px;
    border-bottom: 1px solid var(--border); text-decoration: none; color: inherit; }
.cust-row:last-child { border-bottom: none; }
.cust-row:active { background: #F3F4F6; }
.cust-avatar { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 50%; color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px;
    background: linear-gradient(135deg, var(--primary), var(--primary-2)); }
.cust-main { flex: 1; min-width: 0; }
.cust-name { display: block; font-weight: 600; font-size: 14px; line-height: 1.3;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cust-meta { display: block; font-size: 12px; color: var(--muted); margin-top: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cust-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.cust-chev { color: #C7CDD6; font-size: 11px; }

.chip { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.chip-debt { background: #FEF2F2; color: #B91C1C; border: 1px solid #FCA5A5; }
.chip-credit { background: #ECFDF5; color: #047857; border: 1px solid #6EE7B7; }

.list-pager { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 14px 0 4px; }

@media (min-width: 768px) {
    .quick-actions { justify-content: flex-end; }
    .quick-actions .btn { flex: 0 0 auto; }
    .cust-row:hover { background: #F9FAFB; }
}
@media (max-width: 380px) {
    .chip { font-size: 10px; padding: 3px 6px; }
    .quick-actions .btn { font-size: 12px; padding: 8px 6px; }
}


/* ===== ĐƠN HÀNG — giao diện MOBILE gọn ===== */
.quick-strip { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

@media (max-width: 767px) {
    .hide-mobile { display: none !important; }

    /* 3 thẻ tổng hợp: 3 cột nhỏ gọn */
    .stats-grid { grid-template-columns: repeat(3, 1fr) !important; gap: 6px !important; }
    .stats-grid .stat-card { padding: 8px 6px !important; border-radius: 10px; }
    .stats-grid .stat-icon { width: 24px; height: 24px; font-size: 12px; margin-bottom: 4px; }
    .stats-grid .stat-label { font-size: 9.5px; line-height: 1.2; }
    .stats-grid .stat-value { font-size: 12.5px; line-height: 1.15; word-break: break-word; }

    /* Thanh công cụ: ô tìm 1 hàng, chọn loại đơn 1 hàng */
    .toolbar { flex-wrap: wrap; gap: 8px; }
    .toolbar > form { flex: 1 1 100% !important; }
    .toolbar select.form-input { min-width: 0 !important; width: 100%; font-size: 13px; padding: 9px 10px; }

    /* Lọc theo ngày: xếp dọc gọn */
    #dateFilterForm { gap: 7px !important; }
    #dateFilterForm select[name="date_kind"] { flex: 1 1 100%; max-width: none !important; font-size: 13px; }
    #dateFilterForm input[type="date"] { flex: 1 1 44%; max-width: none !important; font-size: 12.5px; padding: 8px 6px; }
    #dateFilterForm button[type="submit"] { flex: 1 1 100%; }
    .quick-strip { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: 2px;
                   -webkit-overflow-scrolling: touch; scrollbar-width: none; }
    .quick-strip::-webkit-scrollbar { display: none; }
    .quick-strip .btn { flex: 0 0 auto; font-size: 12px; padding: 7px 11px; }

    /* Tab trạng thái / thanh toán gọn hơn, dễ vuốt */
    .filter-scroll { padding-bottom: 4px; }
    .filter-tab { font-size: 12px; padding: 6px 10px; }
    .filter-tab .badge { font-size: 10px; padding: 1px 5px; }
}


/* ===== Khối LỌC NGÀY: mobile thu gọn, mở bằng mũi tên tam giác ===== */
.date-filter-head { display: none; }
.date-filter-arrow { transition: transform .18s ease; }

@media (max-width: 767px) {
    .date-filter { padding: 0 !important; overflow: hidden; }
    .date-filter-head { display: flex; align-items: center; justify-content: space-between; gap: 8px;
        width: 100%; padding: 11px 12px; background: none; border: 0; cursor: pointer;
        font-size: 13px; font-weight: 600; color: inherit; text-align: left; }
    .date-filter-head .dft-title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
    .date-filter-arrow { font-size: 15px; color: var(--muted); flex: 0 0 auto; }
    .date-filter.open .date-filter-arrow { transform: rotate(180deg); }
    .date-filter-body { display: none !important; }
    .date-filter.open .date-filter-body { display: flex !important; padding: 0 12px 12px; }
}


/* ===== Nút thao tác trong bảng (không bị dính nhau) ===== */
.row-actions { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; }
.row-actions form { margin: 0; display: inline-flex; }
.row-actions .btn { white-space: nowrap; }
.table td .row-actions .btn { padding: 5px 10px; font-size: 12.5px; line-height: 1.2; }
@media (max-width: 767px) {
    .row-actions { gap: 6px; }
    .table td .row-actions .btn { padding: 6px 9px; font-size: 12px; }
    .table td .row-actions .btn i { margin-right: 0; }
}


/* ===== TRANG CÔNG VIỆC: khoảng cách các nút (không dính nhau) ===== */
.task-toolbar { display: flex; align-items: center; justify-content: space-between;
                gap: 10px; flex-wrap: wrap; }
.task-toolbar-views { display: flex; gap: 8px; flex-wrap: wrap; }
.task-toolbar > .btn, .task-toolbar > button { flex: 0 0 auto; }
.filter-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-bottom: 2px; }

@media (max-width: 767px) {
    .task-toolbar { gap: 8px; }
    .task-toolbar-views { flex: 1 1 100%; }
    .task-toolbar-views .btn { flex: 1; text-align: center; justify-content: center; }
    .task-toolbar > .btn, .task-toolbar > button { flex: 1 1 100%; justify-content: center; }
    .filter-actions { gap: 8px; }
    .filter-actions .btn { flex: 1; justify-content: center; }
    .modal-footer { gap: 8px; }
    .modal-footer .btn { flex: 1; justify-content: center; }
}


/* ===== TRANG CHẤM CÔNG: bộ lọc gọn + mobile thu gọn bằng mũi tên ===== */
.att-filter-head { display: none; }
.att-filter-arrow { transition: transform .18s ease; }
.att-filter-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.att-filter-form .form-group { min-width: 150px; }
.att-filter-form .att-staff { min-width: 160px; }
.att-filter-actions { display: flex; gap: 8px; align-items: flex-end; }
.att-stats { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 12px; }

@media (max-width: 767px) {
    .att-filter { padding: 0 !important; overflow: hidden; }
    .att-filter-head { display: flex; align-items: center; justify-content: space-between; gap: 8px;
        width: 100%; padding: 11px 12px; background: none; border: 0; cursor: pointer;
        font-size: 13px; font-weight: 600; color: inherit; text-align: left; }
    .att-filter-head .aft-title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
    .att-filter-arrow { font-size: 15px; color: var(--muted); flex: 0 0 auto; }
    .att-filter.open .att-filter-arrow { transform: rotate(180deg); }
    .att-filter-body { display: none !important; }
    .att-filter.open .att-filter-body { display: block !important; }

    .att-filter-form { gap: 8px; }
    .att-filter-form .form-group { flex: 1 1 44%; min-width: 0; }
    .att-filter-form .att-staff { flex: 1 1 100%; }
    .att-filter-actions { flex: 1 1 100%; gap: 8px; }
    .att-filter-actions .btn { flex: 1; justify-content: center; }
    .att-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
    .att-stats .stat-mini { text-align: center; }
}


/* ===== TRANG CHẤM CÔNG — DESKTOP gọn & chuyên nghiệp ===== */
.att-filter-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
                   gap: 12px; align-items: end; }
.att-filter-form .form-group { min-width: 0; }
.att-filter-actions { display: flex; gap: 8px; align-items: flex-end; justify-self: end; }

.att-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 14px; }
.att-stats .stat-mini { background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
    padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.att-stats .stat-mini .lbl { font-size: 12.5px; color: var(--muted); display: inline-flex;
    align-items: center; gap: 7px; }
.att-stats .stat-mini .lbl i { color: var(--primary); }
.att-stats .stat-mini-num { font-size: 1.35rem; }

.att-table th { white-space: nowrap; font-size: 11.5px; text-transform: uppercase;
    letter-spacing: .3px; color: var(--muted); }
.att-table td { vertical-align: middle; }
.att-table td:first-child { font-weight: 600; white-space: nowrap; }
.att-table tbody tr:hover { background: #F9FAFB; }
.att-table .att-hours { font-weight: 700; }
.att-table .att-hours.att-ok { color: var(--success); }
.att-table .att-no { color: var(--muted); font-weight: 600; }
.att-table .att-del { text-align: right; }
.att-table .att-del form { margin: 0; display: inline-flex; }
.att-table .att-thumb { margin-right: 4px; }

@media (max-width: 767px) {
    .att-stats .stat-mini { display: block; text-align: center; padding: 10px 6px; }
    .att-stats .stat-mini .lbl { justify-content: center; font-size: 11px; }
    .att-stats .stat-mini-num { font-size: 1.05rem; }
}


/* ===== KANBAN — phần đầu trang (thẻ tổng quan + toolbar) ===== */
.stats-row { margin-bottom: 12px; }
.stats-row-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    font-size: 13.5px; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.stats-row-title i { color: var(--primary); }

.stats-grid-kanban { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.kanban-stat { display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
    min-width: 0; transition: box-shadow .15s ease, border-color .15s ease; }
.kanban-stat:hover { border-color: var(--primary); box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.kanban-stat.is-empty { opacity: .62; }
.kanban-stat .ks-icon { font-size: 18px; flex: 0 0 auto; }
.kanban-stat .ks-body { display: flex; align-items: baseline; justify-content: space-between;
    gap: 8px; flex: 1 1 auto; min-width: 0; }
.kanban-stat .ks-name { font-size: 12.5px; color: var(--muted); font-weight: 600;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kanban-stat .ks-num { font-size: 18px; font-weight: 700; color: var(--text); flex: 0 0 auto; }

.kanban-toolbar { display: flex; align-items: center; justify-content: space-between;
    gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.kanban-toolbar .kt-info { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kanban-toolbar .btn { flex: 0 0 auto; }

@media (max-width: 767px) {
    .stats-row-title { font-size: 12.5px; }
    .stats-grid-kanban { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .kanban-stat { padding: 9px 10px; gap: 8px; }
    .kanban-stat .ks-icon { font-size: 16px; }
    .kanban-stat .ks-name { font-size: 11.5px; }
    .kanban-stat .ks-num { font-size: 16px; }
    .kanban-toolbar { gap: 8px; }
    .kanban-toolbar .kt-info { flex: 1 1 100%; }
    .kanban-toolbar .btn { flex: 1 1 100%; justify-content: center; }
}


/* ===== CHI TIẾT ĐƠN: danh sách CÔNG ĐOẠN rõ ràng ===== */
.step-list { display: flex; flex-direction: column; gap: 8px; }
.step-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px;
    background: var(--bg-card); border: 1px solid var(--border); border-left: 4px solid var(--sc, #94A3B8);
    border-radius: 10px; }
.step-item.is-done { background: #F0FDF4; border-color: #BBF7D0; }
.step-item.is-doing { background: #EFF6FF; border-color: #BFDBFE; }
.step-item.is-wait { opacity: .78; }
.step-num { flex: 0 0 26px; width: 26px; height: 26px; border-radius: 50%;
    background: var(--sc, #94A3B8); color: #fff; font-size: 12.5px; font-weight: 700;
    display: flex; align-items: center; justify-content: center; }
.step-main { flex: 1 1 auto; min-width: 0; }
.step-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.step-name { font-size: 14.5px; font-weight: 700; }
.step-time { font-size: 11.5px; color: var(--muted); margin-left: auto; white-space: nowrap; }
.step-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px;
    font-size: 12.5px; color: var(--muted); }
.step-meta .step-staff { display: inline-flex; align-items: center; gap: 5px; }
.step-meta .step-staff i { color: var(--primary); }
.step-money { display: inline-flex; align-items: center; gap: 5px; font-weight: 700;
    color: var(--primary); background: var(--primary-light, #EAF2FF); padding: 3px 9px; border-radius: 999px; }
.step-btn { margin: 0 0 0 auto; display: inline-flex; }
.step-note { font-size: 12px; color: var(--muted); margin-top: 6px; font-style: italic; }

@media (max-width: 767px) {
    .step-item { padding: 11px 12px; gap: 10px; }
    .step-name { font-size: 13.5px; }
    .step-time { margin-left: 0; width: 100%; }
    .step-meta { gap: 8px; }
    .step-btn { margin-left: 0; }
    .step-btn .btn { width: 100%; justify-content: center; }
}


/* ===== TRANG CÔNG NỢ: gọn, ít chiếm diện tích ===== */
.debt-bar { display: flex; flex-wrap: wrap; gap: 8px; }
.debt-bar .db-item { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px;
    border-radius: 999px; font-size: 12.5px; background: var(--bg-card); border: 1px solid var(--border); }
.debt-bar .db-item strong { font-size: 14px; }
.debt-bar .db-danger { color: var(--danger); border-color: var(--danger-light); background: var(--danger-light); }
.debt-bar .db-warn { color: #B45309; border-color: #FDE68A; background: #FEF3C7; }
.debt-bar .db-ok { color: #047857; border-color: #BBF7D0; background: #ECFDF5; }

.debt-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px;
    border-bottom: 1px solid var(--border); text-decoration: none; color: inherit; }
.debt-row:last-child { border-bottom: 0; }
.debt-row:hover { background: #F9FAFB; }
.debt-row .dr-ava { flex: 0 0 28px; width: 28px; height: 28px; border-radius: 50%; font-size: 12px;
    background: var(--danger-light); color: var(--danger); display: flex; align-items: center;
    justify-content: center; font-weight: 700; }
.debt-row.is-credit .dr-ava { background: #ECFDF5; color: #047857; }
.debt-row .dr-info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.debt-row .dr-name { font-weight: 600; font-size: 13.5px; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap; }
.debt-row .dr-sub { font-size: 11.5px; color: var(--muted); overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap; }
.debt-row .dr-amt { flex: 0 0 auto; font-weight: 700; font-size: 14.5px; color: var(--danger); }
.debt-row.is-credit .dr-amt { color: #047857; }

@media (max-width: 767px) {
    .debt-bar .db-item { flex: 1 1 auto; justify-content: center; padding: 6px 10px; font-size: 12px; }
    .debt-bar .db-item strong { font-size: 13px; }
    .debt-row { padding: 8px 10px; gap: 8px; }
    .debt-row .dr-ava { flex: 0 0 26px; width: 26px; height: 26px; font-size: 11px; }
    .debt-row .dr-amt { font-size: 13.5px; }
}


/* ===== KHỐI .card-body.p-0 (bảng danh sách): gọn hơn, ít chiếm diện tích ===== */
.card-body.p-0 table.table th,
.card-body.p-0 table.table td { padding: 7px 10px; line-height: 1.35; }
.card-body.p-0 table.table td { font-size: 12.5px; }
.card-body.p-0 table.table .badge { padding: 2px 7px; font-size: 10.5px; line-height: 1.5; }
.card-body.p-0 table.table .btn-sm { padding: 4px 9px; font-size: 12px; line-height: 1.2; }
.card-body.p-0 table.table .att-thumb { width: 30px; height: 30px; }
.card-body.p-0 > .table:first-child { margin-top: 0; }

@media (max-width: 767px) {
    .card-body.p-0 table.table th,
    .card-body.p-0 table.table td { padding: 6px 8px; font-size: 12px; }
    .card-body.p-0 table.table .badge { padding: 2px 6px; font-size: 10px; }
    .card-body.p-0 table.table .btn-sm { padding: 4px 7px; font-size: 11.5px; }
    .card-body.p-0 table.table .att-thumb { width: 26px; height: 26px; }
    /* Ô nội dung dài tự xuống dòng thay vì kéo ngang */
    .card-body.p-0 table.table td { white-space: normal; }
    .card-body.p-0 table.table td:first-child { white-space: nowrap; }
}


/* Thẻ gọn cho trạng thái không có nợ (thay empty-state to) */
.debt-none { display: flex; align-items: center; gap: 8px; padding: 10px 14px;
    font-size: 13px; color: #047857; background: #ECFDF5; border: 1px solid #BBF7D0;
    border-radius: 10px; }
/* Empty-state trong trang công nợ gọn hơn */
.card-body.p-0 .empty-state { padding: 18px 12px; }
.card-body.p-0 .empty-state i { font-size: 26px; }
.card-body.p-0 .empty-state p { margin: 6px 0 0; font-size: 13px; }


/* ===== TRANG CHI PHÍ: gọn & đồng nhất với các trang khác ===== */
.flt-head { display: none; }
.flt-arrow { transition: transform .18s ease; }
.flt-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
            gap: 12px; align-items: end; }
.flt-form .form-group { min-width: 0; margin-bottom: 0; }
.flt-actions { display: flex; gap: 8px; align-items: flex-end; justify-self: end; }

.exp-bar { display: flex; flex-wrap: wrap; gap: 8px; }
.exp-bar .mchip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px;
    border-radius: 999px; font-size: 12.5px; background: var(--bg-card); border: 1px solid var(--border); }
.exp-bar .mchip strong { font-size: 14px; }
.exp-bar .mc-danger { color: var(--danger); background: var(--danger-light); border-color: var(--danger-light); }
.exp-bar .mc-warn { color: #B45309; background: #FEF3C7; border-color: #FDE68A; }
.exp-bar .mc-primary { color: var(--primary); background: var(--primary-light, #EAF2FF); border-color: #CFE0FF; }
.exp-bar .mc-success { color: #15803D; background: #DCFCE7; border-color: #BBF7D0; }

/* Danh sách dạng dòng (dùng chung: .exp-row = chi phí, .cell-row = loại cell): 1 dòng gọn / mục */
.exp-row, .cell-row, .bm-row { display: flex; align-items: flex-start; gap: 10px; padding: 8px 12px;
    border-bottom: 1px solid var(--border); }
.exp-row:last-child, .cell-row:last-child, .bm-row:last-child { border-bottom: 0; }
.exp-row:hover, .cell-row:hover, .bm-row:hover { background: #F9FAFB; }
.exp-row .er-badge, .cell-row .er-badge, .bm-row .er-badge { flex: 0 0 auto; padding-top: 2px; }
.exp-row .er-info, .cell-row .er-info, .bm-row .er-info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.exp-row .er-note, .cell-row .er-note, .bm-row .er-note { font-size: 13.5px; font-weight: 600; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap; }
.exp-row .er-sub, .cell-row .er-sub, .bm-row .er-sub { font-size: 11.5px; color: var(--muted); }
.exp-row .er-proofs, .cell-row .er-proofs, .bm-row .er-proofs { flex: 0 0 auto; display: flex; flex-wrap: wrap; gap: 6px;
    max-width: 46%; }
.exp-row .er-proofs a, .cell-row .er-proofs a, .bm-row .er-proofs a { flex: 0 0 auto; width: 84px; height: 118px; padding: 3px;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
    border: 1px solid var(--border); border-radius: 8px; background: #F3F4F6; }
.exp-row .er-proofs img, .cell-row .er-proofs img, .bm-row .er-proofs img { max-width: 100%; max-height: 100%; width: auto; height: auto;
    display: block; object-fit: contain; border-radius: 4px; }
.exp-row .er-noimg, .cell-row .er-noimg, .bm-row .er-noimg { flex: 0 0 auto; width: 84px; height: 118px;
    display: flex; align-items: center; justify-content: center; text-align: center;
    border: 1px dashed var(--border); border-radius: 8px; background: #fff;
    color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: .5px;
    line-height: 1.25; }
.exp-row .er-right, .cell-row .er-right, .bm-row .er-right { flex: 0 0 auto; text-align: right; display: flex; flex-direction: column;
    align-items: flex-end; gap: 4px; }
.exp-row .er-amt, .cell-row .er-amt, .bm-row .er-amt { font-weight: 700; font-size: 14.5px; color: var(--danger); white-space: nowrap; }
.exp-row .er-btns, .cell-row .er-btns, .bm-row .er-btns { display: flex; gap: 6px; }

/* Phân tích: 2 cột trên máy tính */
.exp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.exp-stat { display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
    font-size: 13px; }
.exp-stat .es-amt { color: var(--danger); }
.exp-bar-track { background: var(--bg); height: 6px; border-radius: 3px; overflow: hidden; margin: 3px 0 9px; }
.exp-bar-fill { height: 100%; background: var(--danger); }

@media (max-width: 767px) {
    .flt-head { display: flex; align-items: center; justify-content: space-between; gap: 8px;
        width: 100%; padding: 11px 12px; background: none; border: 0; cursor: pointer;
        font-size: 13px; font-weight: 600; color: inherit; text-align: left; }
    .flt-title { display: inline-flex; align-items: center; gap: 6px; }
    .flt-arrow { font-size: 15px; color: var(--muted); }
    .flt-form { gap: 8px; }
    .flt-form .form-group { flex: 1 1 44%; }
    .flt-actions { flex: 1 1 100%; }
    .flt-actions .btn { flex: 1; justify-content: center; }
    .exp-bar .mchip { flex: 1 1 auto; justify-content: center; padding: 6px 10px; font-size: 12px; }
    .exp-bar .mchip strong { font-size: 13px; }
    .exp-row, .cell-row, .bm-row { padding: 8px 10px; gap: 8px; }
    .exp-row .er-amt, .cell-row .er-amt, .bm-row .er-amt { font-size: 13.5px; }
    .exp-row .er-proofs, .cell-row .er-proofs, .bm-row .er-proofs { gap: 4px; max-width: 42%; }
    .exp-row .er-proofs a, .cell-row .er-proofs a, .bm-row .er-proofs a { width: 62px; height: 88px; }
    .exp-row .er-noimg, .cell-row .er-noimg, .bm-row .er-noimg { width: 62px; height: 88px; font-size: 9px; letter-spacing: .3px; }
    .exp-row .er-btns .btn, .cell-row .er-btns .btn, .bm-row .er-btns .btn { padding: 4px 8px; }
}


/* ===== MẪU PIN LAPTOP: ảnh nhỏ + khối lọc thu gọn dùng chung ===== */
.bm-thumb { width: 34px; height: 34px; object-fit: cover; border-radius: 8px; display: inline-block; }
.bm-thumb.bm-noimg { display: inline-flex; align-items: center; justify-content: center;
    background: var(--bg); border: 1px solid var(--border); font-size: 16px; }
.bm-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bm-bar .mchip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
    border-radius: 999px; font-size: 12.5px; background: var(--bg-card); border: 1px solid var(--border); }
.bm-bar .mc-primary { color: var(--primary); background: var(--primary-light, #EAF2FF); border-color: #CFE0FF; }
.bm-bar .mc-warn { color: #B45309; background: #FEF3C7; border-color: #FDE68A; }
.bm-bar .bm-add { margin-left: auto; }

/* Khối lọc thu gọn dùng chung (mobile) */
@media (max-width: 767px) {
    .flt-collapse { padding: 0 !important; overflow: hidden; }
    .flt-collapse .flt-head { display: flex; }
    .flt-collapse .flt-body { display: none !important; }
    .flt-collapse.open .flt-body { display: block !important; }
    .flt-collapse.open .flt-arrow { transform: rotate(180deg); }
    .flt-wide { grid-column: 1 / -1; }
    .bm-thumb { width: 30px; height: 30px; }
    .bm-bar .bm-add { margin-left: 0; width: 100%; justify-content: center; }
}


/* ===== Trang công khai: ghi chú trong lịch sử thanh toán / trả nợ ===== */
.ppay-note { display: block; width: 100%; margin: 0; padding: 5px 10px;
    font-size: 12px; line-height: 1.4; color: var(--text);
    background: #F8FAFC; border-top: 1px dashed var(--border); text-align: left; }
.ppay-note:last-child { border-bottom: none; }
.pub-pay-table .text-xs { font-size: 11.5px; }

/* ===== TRANG CÔNG KHAI KHÁCH: bộ lọc theo ngày ===== */
.pub-filter { background: #fff; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; overflow: hidden; }
.pf-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 11px 13px; cursor: pointer; font-weight: 600; font-size: 13.5px; color: #111827; }
.pf-arrow { color: var(--muted); transition: transform .18s; }
.pub-filter.open .pf-arrow { transform: rotate(180deg); }
.pf-badge { background: #eef2ff; color: var(--primary); font-size: 11px; padding: 2px 8px; border-radius: 20px; margin-left: auto; }
.pf-body { display: none; padding: 0 12px 12px; gap: 8px; grid-template-columns: 1fr 1fr; }
.pub-filter.is-filtered .pf-body, .pub-filter.open .pf-body { display: grid; }
.pf-input { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 9px; font-size: 13px; background: #fff; }
.pf-actions { grid-column: 1 / -1; display: flex; gap: 8px; }
.pf-actions .btn { flex: 1; }
.pub-filter-note { background: #eef2ff; color: #1e3a8a; font-size: 12px; padding: 8px 12px; border-radius: 10px; margin-bottom: 10px; }
@media (min-width: 768px) {
    .pf-body { display: grid !important; grid-template-columns: 200px 1fr 1fr auto; align-items: center; }
    .pf-actions { grid-column: auto; }
    .pf-actions .btn { flex: 0 0 auto; }
    .pf-head { cursor: default; }
    .pf-arrow { display: none; }
}

/* ===== MOBILE: card rộng hết cỡ (full-bleed) ===== */
@media (max-width: 767px) {
  .main-content, .content-wrapper, .content, .container, .container-fluid, main, .page-wrap {
    padding-left: 0 !important; padding-right: 0 !important; }
  .card, .panel, .box {
    margin-left: 0 !important; margin-right: 0 !important;
    border-left: 0 !important; border-right: 0 !important;
    border-radius: 0 !important; width: 100% !important; max-width: 100% !important; }
  .card-body, .card-header, .card-footer { padding-left: 12px !important; padding-right: 12px !important; }
  .card + .card { margin-top: 8px !important; }
}

/* ===== MOBILE: mở rộng thẻ pin + card ra hết bề ngang ===== */
@media (max-width: 767px) {
  .content-body { padding-left: 0 !important; padding-right: 0 !important; }
  .card { padding-left: 0 !important; padding-right: 0 !important; }
  .card-body { padding-left: 10px !important; padding-right: 10px !important; }
  #batteryList .battery-item { padding-left: 8px !important; padding-right: 8px !important; }
}


/* ===== THÔNG BÁO DẠNG POPUP (nổi, góc phải trên) ===== */
.flash-popup-wrap {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 4000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(380px, calc(100vw - 28px));
    pointer-events: none;
}
.flash-popup {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    border-left: 5px solid var(--primary);
    background: var(--bg-card);
    box-shadow: 0 14px 34px rgba(0, 0, 0, .18);
    font-size: 14px;
    line-height: 1.4;
    color: var(--text);
    animation: flashPopIn .28s cubic-bezier(.2, .8, .3, 1);
    transition: opacity .2s ease, transform .2s ease;
}
.flash-popup.hide { opacity: 0; transform: translateX(18px); }
@keyframes flashPopIn {
    from { opacity: 0; transform: translateX(26px) scale(.97); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}
.flash-popup-icon { font-size: 18px; line-height: 1.35; flex: 0 0 auto; }
.flash-popup-msg { flex: 1 1 auto; white-space: pre-line; word-break: break-word; }
.flash-popup-close {
    flex: 0 0 auto; background: none; border: none; cursor: pointer;
    font-size: 20px; line-height: 1; opacity: .55; padding: 0 2px; color: inherit;
}
.flash-popup-close:hover { opacity: 1; }
.flash-popup-success { border-left-color: #10B981; background: var(--success-light); color: #166534; }
.flash-popup-danger  { border-left-color: #EF4444; background: var(--danger-light);  color: #991B1B; }
.flash-popup-warning { border-left-color: #F59E0B; background: var(--warning-light); color: #92400E; }
.flash-popup-info    { border-left-color: #06B6D4; background: var(--info-light);    color: #155E75; }

/* Mobile: popup nằm trên thanh điều hướng dưới cùng */
@media (max-width: 640px) {
    .flash-popup-wrap { top: auto; bottom: 78px; left: 10px; right: 10px; width: auto; }
}


/* ===== KHU ẢNH GỌN: 2 cột, lưới ảnh nhỏ, ô "＋" thay ô chọn file to ===== */
.img-sec-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
@media (max-width: 360px) { .img-sec-grid { grid-template-columns: 1fr; } }
.img-sec { border: 1px solid var(--border); border-radius: 10px; padding: 10px; background: var(--bg-card); }
.img-sec .section-title { margin: 0 0 4px; font-size: 13px; }
.img-sec .hint { font-size: 11px; color: var(--muted); margin: 0 0 8px; line-height: 1.3; }
/* Khối ảnh BẮT BUỘC (ảnh trước khi sửa) -> viền nổi để dễ thấy */
.img-sec-required { border-color: var(--primary); border-left: 4px solid var(--primary); }
.img-sec-required .section-title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* Ô chọn file gốc được ẩn đi, thay bằng ô "＋ Ảnh" nằm trong lưới */
.upload-input { position: absolute !important; width: 1px; height: 1px; opacity: 0;
    padding: 0; border: 0; overflow: hidden; }

/* Lưới ảnh nhỏ (66px) -> nhiều ảnh vẫn không chiếm chỗ */
.upload-preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; margin-top: 2px; }
.upload-preview-grid .upload-tile { width: 100%; height: auto; aspect-ratio: 1 / 1; }
.upload-preview-grid .upload-tile .up-status { font-size: 10px; padding: 2px 3px; }
.upload-preview-grid .upload-tile.is-loading .up-status,
.upload-preview-grid .upload-tile.is-error .up-status { font-size: 9.5px; line-height: 1.15; word-break: break-word; }

.upload-add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    aspect-ratio: 1 / 1; width: 100%; padding: 0; border: 1.5px dashed var(--border); border-radius: 8px;
    background: var(--bg); color: var(--muted); cursor: pointer; font-size: 10px; line-height: 1.1; }
.upload-add:hover, .upload-add:active { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
/* Khung xem trước KHÔNG dùng lưới (flex) -> ô "＋" chỉ rộng 84px như 1 ảnh */
.upload-preview:not(.upload-preview-grid) .upload-add { width: 84px; flex: 0 0 auto; }
.upload-add i { font-size: 16px; }

/* Nút ✕ trên ảnh đang chờ lưu (lỡ chọn nhầm) */
.upload-tile .up-del { position: absolute; top: 2px; right: 2px; z-index: 3; width: 19px; height: 19px;
    border-radius: 50%; border: none; padding: 0; background: rgba(15, 23, 42, .62); color: #fff;
    font-size: 13px; line-height: 1; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.upload-tile .up-del:hover { background: var(--danger); }
.upload-tile.is-done img { cursor: zoom-in; }
.upload-tile.is-error .up-del, .upload-tile.is-loading .up-del { top: 2px; right: 2px; }

/* Nút ✕ trên ảnh ĐÃ LƯU trong đơn hàng */
.gallery-item.has-del { position: relative; }
/* (2.9.2) Ảnh trước / sau sửa nằm trong khung Khách hàng của trang đơn: hai cột ngang hàng, mỗi cột cuộn ngang khi nhiều ảnh */
.cust-photos { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.cust-photos-col { min-width: 0; }
.cust-photos-label { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; white-space: nowrap; }
.cust-photos-label span { font-weight: 400; }
.cust-photos .gallery-item { width: 72px; height: 72px; flex: 0 0 auto; }
.cust-photos-empty { font-size: 12px; color: var(--text-muted); padding: 6px 0; }
.gallery-del { position: absolute; top: 2px; right: 2px; z-index: 3; width: 20px; height: 20px;
    border-radius: 50%; border: none; padding: 0; background: rgba(15, 23, 42, .62); color: #fff;
    font-size: 13px; line-height: 1; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.gallery-del:hover { background: var(--danger); }


/* ===== POPUP TIẾN TRÌNH TẠO ĐƠN ===== */
.op-overlay { position: fixed; inset: 0; z-index: 5000; background: rgba(15, 23, 42, .58);
    display: flex; align-items: center; justify-content: center; padding: 16px; }
.op-card { width: 100%; max-width: 360px; background: var(--bg-card); border-radius: 14px;
    padding: 18px 16px 16px; box-shadow: 0 24px 60px rgba(0, 0, 0, .35); text-align: center;
    animation: opIn .22s cubic-bezier(.2, .8, .3, 1); }
@keyframes opIn { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
.op-spin { font-size: 30px; color: var(--primary); line-height: 1; margin-bottom: 6px; }
.op-spin i, .op-mini-spin { animation: opSpin .9s linear infinite; display: inline-block; }
.op-spin i { font-size: 30px; }
@keyframes opSpin { to { transform: rotate(360deg); } }
.op-title { margin: 0 0 4px; font-size: 16px; }
.op-status { font-size: 12.5px; color: var(--muted); margin-bottom: 12px; min-height: 30px; line-height: 1.35; }
.op-steps { list-style: none; margin: 0 0 12px; padding: 0; text-align: left; }
.op-step { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; padding: 4px 0;
    color: var(--muted); line-height: 1.3; }
.op-step .op-dot { flex: 0 0 16px; width: 16px; text-align: center; font-size: 11px; line-height: 18px; }
.op-step.is-done { color: var(--text); }
.op-step.is-done .op-dot { color: #10B981; }
.op-step.is-active { color: var(--primary); font-weight: 600; }
.op-bar { height: 8px; border-radius: 99px; background: var(--bg); border: 1px solid var(--border); overflow: hidden; }
.op-bar > span { display: block; height: 100%; width: 12%; border-radius: 99px;
    background: linear-gradient(90deg, var(--primary), var(--primary-2)); transition: width .45s ease; }
.op-note { margin-top: 10px; font-size: 11.5px; font-weight: 600; color: var(--danger); line-height: 1.3; }
@media (max-width: 640px) { .op-card { max-width: 330px; } }

/* ===== XEM ẢNH DẠNG POPUP ===== */
.img-lightbox { position: fixed; inset: 0; z-index: 5000; background: rgba(0,0,0,.88);
    display: none; align-items: center; justify-content: center; padding: 10px; }
.img-lightbox.show { display: flex; }
.img-lightbox .ilb-img { max-width: 96vw; max-height: 82vh; border-radius: 10px; background: #111;
    box-shadow: 0 20px 50px rgba(0,0,0,.5); cursor: zoom-out; }
.img-lightbox .ilb-bar { position: fixed; top: 10px; right: 10px; left: 10px; display: flex;
    gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; z-index: 2; }
.img-lightbox .ilb-count { color: #fff; font-size: 13px; opacity: .9; margin-right: auto; }
.img-lightbox .ilb-close { width: 38px; height: 38px; border: none; border-radius: 10px;
    background: rgba(255,255,255,.18); color: #fff; font-size: 24px; line-height: 1; cursor: pointer; }
.img-lightbox .ilb-close:hover { background: rgba(255,255,255,.3); }
.img-lightbox .ilb-nav { position: fixed; top: 50%; transform: translateY(-50%); width: 44px; height: 44px;
    border: none; border-radius: 50%; background: rgba(255,255,255,.18); color: #fff;
    font-size: 18px; cursor: pointer; z-index: 2; }
.img-lightbox .ilb-nav:hover { background: rgba(255,255,255,.32); }
.img-lightbox .ilb-prev { left: 10px; }
.img-lightbox .ilb-next { right: 10px; }
body.no-scroll { overflow: hidden; }
@media (max-width: 640px) {
    .img-lightbox .ilb-img { max-height: 74vh; }
    .img-lightbox .ilb-bar { justify-content: flex-start; }
}


/* ==================== Ô TÌM NHANH LOẠI CELL ==================== */
.ss-native { display: none !important; }
.ss-wrap { position: relative; }
.ss-wrap::after {
    content: '\f002';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: #98a2b3;
    pointer-events: none;
}
.ss-input { padding-right: 30px; }
.ss-list {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 2px);
    z-index: 9999;
    background: #fff;
    border: 1px solid #dfe3ea;
    border-radius: 8px;
    box-shadow: 0 10px 26px rgba(16,24,40,.14);
    max-height: 240px;
    overflow-y: auto;
    display: none;
}
.ss-list.show { display: block; }
.ss-item {
    padding: 8px 10px;
    font-size: 13px;
    cursor: pointer;
    border-bottom: 1px solid #f2f4f7;
}
.ss-item:last-child { border-bottom: 0; }
.ss-item:hover, .ss-item.active { background: rgba(var(--primary-rgb),.10); }
.ss-empty { padding: 10px; font-size: 12px; color: #98a2b3; text-align: center; }

/* HANG + MA PIN LUON IN HOA */
#mBrand, #mCode, #qmBrand, #qmCode, input.up { text-transform: uppercase; letter-spacing: .3px; }

/* O TIM MAU PIN: hien chu HOA */
.battery-model-search { text-transform: uppercase; }

/* PHAN BIET DONG PIN #1 #2 #3 ... BANG MAU NEN (manh, thang inline style) */
#batteryList > .battery-item { border-left: 6px solid #94a3b8 !important; border-radius: 10px; }
#batteryList > .battery-item:nth-child(4n+1) { background: #e8f1ff !important; border-left-color: #2563eb !important; }
#batteryList > .battery-item:nth-child(4n+2) { background: #e6fbf1 !important; border-left-color: #059669 !important; }
#batteryList > .battery-item:nth-child(4n+3) { background: #fff6e5 !important; border-left-color: #d97706 !important; }
#batteryList > .battery-item:nth-child(4n+4) { background: #f3edff !important; border-left-color: #7c3aed !important; }
#batteryList > .battery-item > .flex-between > span:first-child { font-weight: 800; font-size: 15px; }
#batteryList > .battery-item:nth-child(4n+1) > .flex-between > span:first-child { color: #2563eb; }
#batteryList > .battery-item:nth-child(4n+2) > .flex-between > span:first-child { color: #059669; }
#batteryList > .battery-item:nth-child(4n+3) > .flex-between > span:first-child { color: #d97706; }
#batteryList > .battery-item:nth-child(4n+4) > .flex-between > span:first-child { color: #7c3aed; }
