:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --success-light: #dcfce7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --warning: #ea580c;
    --warning-light: #fff7ed;
    --sidebar-bg: #1e1e2d;
    --sidebar-hover: #2a2a3d;
    --sidebar-sub: #161622;
    --sidebar-text: #a0a0b0;
    --sidebar-active: #fff;
    --bg: #f5f5f5;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
}

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

/* Bootstrap-compatible visibility utility (ERP has no Bootstrap CSS) */
.d-none { display: none !important; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    width: 260px;
    height: 100vh;
    background: var(--sidebar-bg);
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    transition: width 0.2s ease;
}
.sidebar-collapse-btn {
    position: absolute;
    right: -18px;
    top: 22px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid #3a3a4d;
    background: var(--sidebar-hover);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    box-shadow: var(--shadow);
}
.sidebar-collapse-btn:hover { background: var(--primary); border-color: var(--primary); }
body.sidebar-collapsed .sidebar { width: 74px; }
body.sidebar-collapsed .main-content { margin-left: 0; }
body.sidebar-collapsed .sidebar-brand .sidebar-title,
body.sidebar-collapsed .sidebar-section-label,
body.sidebar-collapsed .nav-link span:not(.nav-badge),
body.sidebar-collapsed .sidebar-dropdown-toggle span:not(.nav-badge),
body.sidebar-collapsed .sidebar-footer .user-info,
body.sidebar-collapsed .sidebar-submenu { display: none; }
body.sidebar-collapsed .sidebar-brand { padding: 12px 8px; }
body.sidebar-collapsed .sidebar-logo-img { max-width: 44px; margin: 0 auto; }
body.sidebar-collapsed .nav-link,
body.sidebar-collapsed .sidebar-dropdown-toggle { padding: 10px; justify-content: center; }
body.sidebar-collapsed .sidebar-dropdown-toggle .chevron { display: none; }
body.sidebar-collapsed .sidebar-footer { padding: 12px 10px; justify-content: center; }
body.sidebar-collapsed .sidebar-user { justify-content: center; }
body.sidebar-collapsed .user-avatar { width: 34px; height: 34px; }
body.sidebar-collapsed .logout-btn { margin-left: auto; }
body.sidebar-collapsed .sidebar-submenu.show { max-height: 0; }
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #3a3a4d; border-radius: 3px; }

.sidebar-brand {
    padding: 14px 20px;
    border-bottom: 1px solid #333;
    text-align: center;
    background: var(--sidebar-bg);
    z-index: 5;
}
.sidebar-logo-img {
    max-width: 170px;
    height: auto;
    display: block;
    margin: 0 auto;
    filter: brightness(0) invert(1);
}
.sidebar-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #fff;
    display: block;
    margin-top: 6px;
    letter-spacing: 1px;
}

.sidebar-nav { padding: 8px 0; }

.sidebar-section-label {
    padding: 16px 24px 6px 24px;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #6c6c7f;
    font-weight: 600;
}

.nav-link {
    color: var(--sidebar-text);
    padding: 10px 24px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    border-radius: 0;
    transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: var(--sidebar-hover); color: #fff; }
.nav-link.active { background: var(--sidebar-hover); color: #fff; border-left: 3px solid var(--primary); }
.nav-link i { font-size: 1rem; width: 20px; text-align: center; }

/* Sidebar dropdown */
.sidebar-dropdown-toggle {
    color: var(--sidebar-text);
    padding: 10px 24px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s, color 0.15s;
}
.sidebar-dropdown-toggle:hover, .sidebar-dropdown-toggle.active { background: var(--sidebar-hover); color: #fff; }
.sidebar-dropdown-toggle .chevron { margin-left: auto; font-size: 0.65rem; transition: transform 0.2s; }
.sidebar-dropdown-toggle.open .chevron { transform: rotate(180deg); }

.sidebar-submenu {
    background: var(--sidebar-sub);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.sidebar-submenu.show { max-height: 500px; }
.sidebar-submenu .nav-link { padding: 8px 24px 8px 56px; font-size: 0.8rem; }

.sidebar-group-toggle {
    display: flex;
    align-items: center;
    padding: 12px 24px 6px 56px;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #6c6c7f;
    cursor: pointer;
    user-select: none;
}
.sidebar-group-toggle:hover { color: #a0a0b8; }
.sidebar-group-toggle .chevron { margin-left: auto; font-size: 0.5rem; transition: transform 0.2s; }
.sidebar-group-toggle.open .chevron { transform: rotate(180deg); }

.sidebar-group-body { max-height: 0; overflow: hidden; transition: max-height 0.25s ease; }
.sidebar-group-body.show { max-height: 600px; }

.sidebar-divider {
    border-top: 1px solid #333;
    margin: 6px 24px 6px 40px;
}

/* Sidebar footer */
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid #333;
    margin-top: auto;
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}
.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-info .user-name { color: #fff; font-size: 0.8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info .user-role { color: #6c6c7f; font-size: 0.65rem; }
.logout-btn {
    color: #6c6c7f;
    padding: 6px;
    border-radius: 6px;
    text-decoration: none;
    transition: color 0.15s, background 0.15s;
    font-size: 1rem;
}
.logout-btn:hover { color: var(--danger); background: rgba(220,38,38,0.1); }

/* ── Main Content ── */
.main-content { margin-left: 0; padding: 0; min-height: 100vh; }
.main-content.full-page { margin-left: 0; }

.page-container { padding: 24px; max-width: 1200px; margin: 0 auto; }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}
.header-left { display: flex; flex-direction: column; gap: 4px; }
.header-actions { display: flex; gap: 8px; align-items: center; }
.page-title { font-size: 1.5rem; font-weight: 700; margin: 0; }
.page-subtitle { font-size: 0.85rem; color: var(--text-muted); margin: 0; }

.back-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
}
.back-link:hover { text-decoration: underline; }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: 6px;
    border: none;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-danger { background: var(--danger-light); color: var(--danger); }
.btn-danger:hover { background: #fecaca; }
.btn-success { background: var(--success-light); color: var(--success); }
.btn-success:hover { background: #bbf7d0; }

.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: all 0.15s;
}
.btn-icon:hover { border-color: var(--primary); color: var(--primary); }
.btn-delete:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-light); }

/* ── Flash ── */
.flash-messages { margin-bottom: 20px; }
.flash {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 8px;
    font-size: 0.9rem;
    font-weight: 500;
}
.flash-success { background: var(--success-light); color: #166534; border: 1px solid #bbf7d0; }
.flash-error { background: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }
.flash-warning { background: var(--warning-light); color: #9a3412; border: 1px solid #fed7aa; }

/* ── Stats ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px 16px;
    text-align: center;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
.stat-card.alert { background: var(--warning-light); border-color: #fed7aa; }
.stat-card.alert .stat-value { color: var(--warning); }
.stat-card.success { background: #dcfce7; border-color: #86efac; }
.stat-card.success .stat-value { color: #16a34a; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }

/* ── Search ── */
.search-section { margin-bottom: 24px; }
.search-bar {
    display: flex;
    align-items: center;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0 12px;
    box-shadow: var(--shadow);
}
.search-bar input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 14px 0;
    font-size: 1rem;
    outline: none;
}
.search-icon-inline { color: var(--text-muted); margin-right: 8px; font-size: 1rem; }
.scan-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    margin: 4px 0;
    cursor: pointer;
    font-size: 1.1rem;
}

/* ── Sections ── */
.section-block { margin-bottom: 24px; }
.section-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 12px;
}
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

/* ── Alert items ── */
.alert-list { display: flex; flex-direction: column; gap: 8px; }
.alert-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--warning-light);
    border: 1px solid #fed7aa;
    border-radius: 8px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text);
}
.alert-name { font-weight: 600; }
.alert-qty { font-size: 0.85rem; color: var(--warning); font-weight: 700; }

/* ── Items list ── */
.items-list { display: flex; flex-direction: column; gap: 10px; }
.item-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow);
}
.item-card:hover { border-color: var(--primary); }
.item-name { font-weight: 600; font-size: 1rem; margin-bottom: 4px; }
.item-meta { font-size: 0.8rem; color: var(--text-muted); }
.item-qty { text-align: center; padding: 4px 12px; border-radius: 6px; background: #f1f5f9; min-width: 56px; }
.item-qty.low { background: var(--danger-light); color: var(--danger); }
.qty-number { font-size: 1.3rem; font-weight: 700; }
.qty-unit { font-size: 0.7rem; color: var(--text-muted); }

.stock-check-stats { grid-template-columns: repeat(4, 1fr); }
.stock-check-table { white-space: nowrap; }
.stock-thumb { width: 48px; height: 48px; object-fit: contain; border-radius: 6px; border: 1px solid var(--border); background: #fff; padding: 2px; }
.mb-3 { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.form-control { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.9rem; background: #fff; outline: none; }
.form-control-sm { padding: 6px 8px; font-size: 0.85rem; }
.form-check-input { margin-top: 8px; }
.form-check-label { color: var(--text-muted); font-size: 0.8rem; }
.d-grid { display: grid; }
.w-100 { width: 100%; }
.text-center { text-align: center; }
.text-danger { color: var(--danger); }
.fw-bold { font-weight: 700; }
.table-container { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; margin: 0; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table thead th { background: #f8fafc; font-size: 0.82rem; text-transform: uppercase; color: var(--text-muted); }
.table tbody tr:hover { background: #f8fafc; }
.inline-form { display: inline-flex; margin: 0; }
.badge { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.bg-success { background: var(--success-light); color: var(--success); }
.bg-danger { background: var(--danger-light); color: var(--danger); }
.bg-warning { background: var(--warning-light); color: var(--warning); }
/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}
.empty-state p { margin-bottom: 16px; }

/* ── Forms ── */
.photo-preview-box { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.item-photo-preview { width: 120px; height: 120px; object-fit: contain; border: 1px solid var(--border); border-radius: 8px; background: #fff; padding: 4px; }
.item-photo-card { text-align: center; margin-bottom: 16px; }
.item-photo-main { max-width: 100%; max-height: 420px; object-fit: contain; border: 1px solid var(--border); border-radius: 8px; background: #fff; padding: 8px; }
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
    background: #fff;
    outline: none;
    font-family: inherit;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.btn-group { display: flex; gap: 8px; align-items: flex-end; }
.btn-group .btn { flex: 1; }

/* ── Cards ── */
.data-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 20px;
    overflow: hidden;
}
.card-body { padding: 20px; }
.card-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}
.card-footer .btn { min-width: 100px; }

/* ── Data Table ── */
.data-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.data-search {
    display: flex;
    align-items: center;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0 12px;
    flex: 1;
    max-width: 400px;
}
.data-search input {
    flex: 1;
    border: none;
    padding: 9px 0;
    font-size: 0.9rem;
    outline: none;
    background: transparent;
}
.data-search .search-icon { color: var(--text-muted); font-size: 0.9rem; margin-right: 8px; }
.search-clear { color: var(--text-muted); text-decoration: none; font-size: 0.75rem; padding: 4px; }
.search-clear:hover { color: var(--danger); }

.data-table-wrapper { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.data-table th {
    background: #f8fafc;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 2px solid var(--border);
}
.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.data-table tbody tr:hover { background: #f8fafc; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.fw-600 { font-weight: 600; }

/* ── Modals ── */
.modal-backdrop {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}
.modal-backdrop.active { display: flex; }
.modal-dialog {
    background: var(--card-bg);
    border-radius: 10px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.15s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 1.1rem; }
.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; }
.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* Old modal (scanner) */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: flex-end;
}
.modal.active { display: flex; }
.modal-content {
    background: var(--card-bg);
    width: 100%;
    border-radius: 20px 20px 0 0;
    padding: 16px;
    animation: slideUp 0.2s ease;
    max-height: 90vh;
    overflow-y: auto;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.close-btn {
    background: none;
    border: none;
    font-size: 1.8rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
}
.scanner-video {
    width: 100%;
    height: 220px;
    background: #000;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    position: relative;
    overflow: hidden;
}
.scanner-hint { text-align: center; color: var(--text-muted); margin-bottom: 16px; }
.manual-scan { display: flex; gap: 8px; }
.manual-scan input { flex: 1; }

/* ── Detail Page ── */
.detail-card { padding: 24px; }
.detail-qty {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: #f1f5f9;
    border-radius: 8px;
    width: fit-content;
}
.detail-qty.low { background: var(--danger-light); color: var(--danger); }
.qty-big { font-size: 2.4rem; font-weight: 700; }
.unit-big { font-size: 1rem; color: var(--text-muted); font-weight: 500; }
.detail-grid { display: grid; gap: 12px; }
.detail-row { display: flex; justify-content: space-between; align-items: center; }
.detail-row.full { flex-direction: column; align-items: flex-start; gap: 4px; }
.detail-label { font-size: 0.85rem; color: var(--text-muted); font-weight: 500; }
.detail-value { font-weight: 600; text-align: right; }
.detail-row.full .detail-value { text-align: left; }

.stock-card { padding: 20px; }

/* ── Transaction List ── */
.transaction-list { display: flex; flex-direction: column; gap: 10px; padding: 20px; }
.transaction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #f8fafc;
    border-radius: 6px;
    font-size: 0.9rem;
}
.transaction-info { display: flex; flex-direction: column; gap: 2px; }
.transaction-type { font-weight: 700; font-size: 0.8rem; }
.transaction-type.stock_in { color: var(--success); }
.transaction-type.stock_out { color: var(--danger); }
.transaction-notes { color: var(--text-muted); font-size: 0.8rem; }
.transaction-qty { font-weight: 700; }
.transaction-qty.positive { color: var(--success); }
.transaction-qty.negative { color: var(--danger); }
.transaction-date { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; margin-left: 8px; }

/* ── Login page ── */
.main-content.full-page { margin-left: 0; }

.inline-form { display: inline; margin: 0; }

/* ── Top Menu Bar ── */
.top-menu-bar {
    display: flex;
    align-items: center;
    background: var(--sidebar-bg);
    height: 44px;
    padding: 0 8px;
    margin-left: 0;
    position: sticky;
    top: 0;
    z-index: 999;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}
.top-menu-bar .menu-spacer {
    flex: 1;
}
.top-menu-bar .menu-logo {
    height: 30px;
    width: auto;
    margin: 0 8px 0 12px;
}
.top-menu-bar .back-btn {
    color: var(--sidebar-text);
    padding: 0 10px;
    height: 44px;
    display: flex;
    align-items: center;
    font-size: 1.0rem;
    cursor: pointer;
    text-decoration: none;
    transition: color 0.15s;
    border: none;
    background: transparent;
}
.top-menu-bar .back-btn:hover { color: #fff; }
.top-menu-bar .menu-item {
    position: relative;
    color: var(--sidebar-text);
    padding: 0 16px;
    height: 44px;
    display: flex;
    align-items: center;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    user-select: none;
}
.top-menu-bar .menu-item:hover,
.top-menu-bar .menu-item:focus-within {
    color: #fff;
    background: var(--sidebar-hover);
}
.top-menu-bar .menu-item.active {
    color: #fff;
    border-bottom-color: var(--primary);
}
.top-menu-bar .menu-item i {
    margin-right: 6px;
    font-size: 0.9rem;
}
/* Dropdown */
.top-menu-bar .menu-item .menu-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    background: var(--sidebar-bg);
    border: 1px solid #3a3a4d;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    z-index: 1000;
    padding: 4px 0;
    flex-direction: column;
}
.top-menu-bar .menu-item:hover .menu-dropdown,
.top-menu-bar .menu-item:focus-within .menu-dropdown {
    display: flex;
}
.top-menu-bar .menu-dropdown a {
    color: var(--sidebar-text);
    padding: 8px 20px;
    font-size: 0.8rem;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.1s, color 0.1s;
}
.top-menu-bar .menu-dropdown a:hover {
    background: var(--sidebar-hover);
    color: #fff;
}
.top-menu-bar .menu-dropdown a i {
    font-size: 0.85rem;
    width: 18px;
    text-align: center;
}
.top-menu-bar .menu-dropdown .dropdown-sep {
    border-top: 1px solid #3a3a4d;
    margin: 4px 16px;
}
.top-menu-bar .menu-dropdown .dropdown-label {
    padding: 6px 20px 2px;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #6c6c7f;
    font-weight: 600;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .page-container { padding: 16px; }
    .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .stat-card { padding: 12px 8px; }
    .stat-value { font-size: 1.4rem; }
    .form-row { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; gap: 12px; }
    .header-actions { width: 100%; }
    .data-toolbar { flex-direction: column; align-items: stretch; }
    .data-search { max-width: none; }
}

/* Hide mobile elements on desktop by default */
.mobile-header,
.mobile-nav,
.mobile-menu-overlay,
.mobile-menu-panel {
    display: none;
}

@media (max-width: 576px) {
    .top-menu-bar { display: none; }
    .mobile-header,
    .mobile-nav,
    .mobile-menu-panel {
        display: flex;
    }
    .mobile-menu-overlay { display: none; }
    .mobile-menu-overlay.active { display: block; }
    .sidebar { display: none; }
    .main-content { margin-left: 0; padding-top: 56px; }

    /* Mobile header */
    .mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 56px;
        background: var(--sidebar-bg);
        color: #fff;
        padding: 0 16px;
        z-index: 1001;
        box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    }
    .mobile-header-brand {
        display: flex;
        align-items: center;
        gap: 10px;
        font-weight: 700;
        font-size: 1.1rem;
    }
    .mobile-logo-img { height: 32px; width: auto; }
    .mobile-back-btn {
        background: transparent;
        border: none;
        color: #fff;
        font-size: 1.3rem;
        padding: 8px 4px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-right: 4px;
    }
    .mobile-menu-btn {
        background: transparent;
        border: none;
        color: #fff;
        font-size: 1.6rem;
        padding: 8px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Mobile menu overlay & panel */
    .mobile-menu-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.45);
        z-index: 1002;
    }
    .mobile-menu-overlay.active { display: block; }
    .mobile-menu-panel {
        position: fixed;
        top: 0;
        right: -280px;
        width: 280px;
        height: 100vh;
        background: var(--sidebar-bg);
        color: var(--sidebar-text);
        z-index: 1003;
        transition: right 0.25s ease;
        display: flex;
        flex-direction: column;
    }
    .mobile-menu-panel.open { right: 0; }
    .mobile-menu-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px;
        border-bottom: 1px solid rgba(255,255,255,0.08);
    }
    .mobile-menu-title { color: #fff; font-weight: 700; font-size: 1.1rem; }
    .mobile-menu-close {
        background: transparent;
        border: none;
        color: var(--sidebar-text);
        font-size: 1.4rem;
        cursor: pointer;
    }
    .mobile-menu-body {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 8px 0;
    }
    .mobile-menu-section {
        padding: 12px 16px 6px;
        font-size: 0.65rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: rgba(255,255,255,0.4);
    }
    .mobile-menu-link {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 16px;
        color: var(--sidebar-text);
        text-decoration: none;
        font-size: 0.9rem;
        border-left: 3px solid transparent;
    }
    .mobile-menu-link.active,
    .mobile-menu-link:hover {
        background: var(--sidebar-hover);
        color: #fff;
        border-left-color: var(--primary);
    }
    .mobile-menu-link i { font-size: 1.1rem; width: 22px; text-align: center; }

    /* Mobile bottom nav */
    .mobile-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--card-bg);
        border-top: 1px solid var(--border);
        display: flex;
        justify-content: space-around;
        padding: 6px 0 10px;
        z-index: 1000;
    }
    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        color: var(--text-muted);
        text-decoration: none;
        font-size: 0.65rem;
        padding: 4px 12px;
        background: transparent;
        border: none;
        cursor: pointer;
    }
    .mobile-nav-item.active { color: var(--primary); }
    .mobile-nav-item i { font-size: 1.2rem; }
    .page-container { padding: 16px 16px 80px; }

    /* Mobile tables */
    .data-table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .data-table th,
    .data-table td {
        white-space: nowrap;
    }
}

/* ── Nav Badge ── */
.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ── Button: Warning variant ── */
.btn-warning {
    background: var(--warning-light);
    color: var(--warning);
    border: 1px solid #fed7aa;
}
.btn-warning:hover { background: #fed7aa; }
.btn-reject-active { background: var(--danger) !important; color: #fff !important; }

/* ── Empty state padding ── */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}
.empty-state p { margin-bottom: 16px; }
.empty-state .bi-inbox { font-size: 3rem; color: #cbd5e1; }

/* ── Modal backdrop active class support ── */
.modal-backdrop.active { display: flex; align-items: center; justify-content: center; }
.modal-dialog .modal-body { padding: 20px; }
.modal-dialog .modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ── Form input group ── */
.input-group { display: flex; gap: 0; }
.input-group .form-control { border-radius: 6px 0 0 6px; }
.input-group .btn { border-radius: 0 6px 6px 0; border: 1px solid var(--border); border-left: none; }

/* ── Utility ── */
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 10px; }
.mt-3 { margin-top: 12px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
small { font-size: 0.8rem; }
.badge { background: var(--primary-light); color: var(--primary); padding: 2px 8px; border-radius: 10px; font-size: 0.7rem; font-weight: 600; }

/* ══════════════════════════════════════════
   KANBAN CARD VIEW
   ══════════════════════════════════════════ */
.kanban-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    padding-bottom: 24px;
}

.kanban-card {
    background: var(--card-bg);
    border-radius: 10px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.kanban-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.kanban-card.kanban-ok { border-top: 3px solid var(--success); }
.kanban-card.kanban-low { border-top: 3px solid var(--warning); }
.kanban-card.kanban-out { border-top: 3px solid var(--danger); }

/* Photo area */
.kanban-photo {
    position: relative;
    height: 140px;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border);
    overflow: hidden;
}
.kanban-photo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 8px;
}
.kanban-no-photo {
    font-size: 3rem;
    color: #cbd5e1;
}
.kanban-qty-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--success);
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    min-width: 36px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    padding: 0 10px;
}
.kanban-qty-badge.low {
    background: var(--warning);
    color: #fff;
}
.kanban-qty-badge.out {
    background: var(--danger);
    color: #fff;
}

/* Card body */
.kanban-body {
    padding: 14px 16px 10px;
    flex: 1;
}
.kanban-name {
    font-size: 0.92rem;
    font-weight: 600;
    margin: 0 0 6px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.kanban-meta {
    margin-bottom: 8px;
}
.kanban-brand-model {
    font-size: 0.78rem;
    color: var(--primary);
    font-weight: 500;
}
.kanban-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.kanban-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.78rem;
}
.kanban-label {
    color: var(--text-muted);
    flex-shrink: 0;
    margin-right: 8px;
}
.kanban-value {
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}
.kanban-value.batch {
    font-family: 'SF Mono', 'Cascadia Code', monospace;
    font-size: 0.73rem;
    color: var(--text-muted);
}

/* Actions row */
.kanban-actions {
    display: flex;
    gap: 6px;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    background: #fafbfc;
}
.kanban-actions .btn {
    flex: 1;
    text-align: center;
    font-size: 0.8rem;
    padding: 6px 4px;
}

/* Responsive */
@media (max-width: 640px) {
    .kanban-grid {
        grid-template-columns: 1fr;
    }
}

/* ══════════════════════════════════════════
   STOCK CHECK LIST (replaces table)
   ══════════════════════════════════════════ */
.stock-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 24px;
}

.stock-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    border-left: 4px solid var(--success);
    transition: box-shadow 0.15s ease;
}
.stock-row:hover { box-shadow: var(--shadow); }
.stock-row.row-low { border-left-color: var(--warning); }
.stock-row.row-out { border-left-color: var(--danger); }

.stock-row-main {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}
.stock-photo-cell {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    background: #f8fafc;
    border-radius: 6px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.stock-row-photo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 3px;
}
.stock-no-photo {
    font-size: 1.5rem;
    color: #cbd5e1;
}
.stock-row-info {
    flex: 1;
    min-width: 0;
}
.stock-item-name {
    font-size: 0.9rem;
    font-weight: 600;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.stock-item-sub {
    display: flex;
    gap: 6px;
    margin-top: 2px;
}
.stock-brand {
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 500;
}
.stock-model {
    color: var(--text-muted);
    font-size: 0.78rem;
}
.stock-item-meta {
    display: flex;
    gap: 12px;
    margin-top: 3px;
    font-size: 0.73rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}
.stock-sku, .stock-batch, .stock-loc {
    white-space: nowrap;
}
.stock-batch {
    font-family: 'SF Mono', 'Cascadia Code', monospace;
}
.stock-loc i { font-size: 0.65rem; }

.stock-row-qty {
    text-align: center;
    min-width: 70px;
    flex-shrink: 0;
}
.stock-qty-num {
    display: block;
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.2;
}
.stock-qty-num.low { color: var(--warning); }
.stock-qty-num.out { color: var(--danger); }
.stock-qty-unit {
    font-size: 0.7rem;
    color: var(--text-muted);
}
.stock-status-badge {
    display: block;
    margin-top: 2px;
}

.stock-row-actions {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .stock-row {
        flex-wrap: wrap;
    }
    .stock-row-actions {
        width: 100%;
        justify-content: flex-end;
        border-top: 1px solid var(--border);
        padding-top: 10px;
        margin-top: 2px;
    }
}

/* Hide the ERP chrome (sidebar, mobile nav) when printing */
@media print {
    .sidebar,
    .sidebar-collapse-btn,
    .mobile-header,
    .mobile-menu-overlay,
    .mobile-menu-panel {
        display: none !important;
    }
    .main-content {
        margin-left: 0 !important;
    }
    .no-print {
        display: none !important;
    }
}

/* ── System Notification Modal ── */
.sys-notif-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    z-index: 10001; display: flex; align-items: center; justify-content: center;
}
.sys-notif-modal {
    background: #fff; border-radius: 12px; width: 480px; max-width: 92vw;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25); overflow: hidden;
}
.sys-notif-header {
    background: var(--sidebar-bg); color: #fff; padding: 16px 24px;
    font-size: 1rem; font-weight: 700; display: flex; align-items: center; gap: 10px;
}
.sys-notif-body {
    padding: 20px 24px; font-size: 0.9rem; line-height: 1.6; color: #334155;
    max-height: 50vh; overflow-y: auto; white-space: pre-wrap;
}
.sys-notif-footer {
    padding: 12px 24px 16px; text-align: right;
    border-top: 1px solid #e2e8f0;
}

/* ── User Profile Avatars ── */
.user-avatar,
.mobile-user-avatar,
.nav-welcome-avatar,
.profile-photo-round,
.user-avatar-sm {
    border-radius: 50%;
    object-fit: cover;
    vertical-align: middle;
    flex-shrink: 0;
}
.user-avatar {
    width: 28px;
    height: 28px;
    border: 2px solid rgba(255,255,255,0.25);
}
.mobile-user-avatar {
    width: 32px;
    height: 32px;
    border: 2px solid rgba(255,255,255,0.25);
}
.nav-welcome-avatar {
    width: 40px;
    height: 40px;
    border: 2px solid var(--border);
    margin-right: 10px;
}
.user-avatar-sm {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    margin-right: 10px;
}
.avatar-initials {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
}
.user-menu {
    display: inline-flex !important;
    align-items: center;
    gap: 8px;
}
.user-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-list-cell {
    display: flex;
    align-items: center;
}
.mobile-header-user {
    display: flex;
    align-items: center;
    gap: 10px;
}
.profile-preview {
    margin-bottom: 10px;
}
.profile-preview img,
.profile-photo-round {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}

/* ── Sidebar / nav badges ── */
.menu-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    margin-left: 7px;
    border-radius: 9px;
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
    line-height: 1;
    box-shadow: 0 1px 3px rgba(0,0,0,0.35);
}
.menu-badge[hidden] { display: none; }
.menu-badge-crm        { background: #e53e3e; }
.menu-badge-inventory  { background: #dd6b20; }
.menu-badge-rental     { background: #e53e3e; }
.menu-badge-spareparts { background: #d69e2e; }
.menu-badge-repair     { background: #38a169; }

/* Mobile bottom-nav dot */
.mobile-nav-item { position: relative; }
.mnav-badge {
    position: absolute;
    top: 0;
    right: 8px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    font-size: 0.62rem;
    font-weight: 700;
    color: #fff;
    line-height: 16px;
    text-align: center;
    background: #e53e3e;
    border: 1.5px solid var(--card-bg, #fff);
    z-index: 3;
    pointer-events: none;
}
.mnav-badge[hidden] { display: none; }
.mnav-badge-crm        { background: #e53e3e; }
.mnav-badge-inventory  { background: #dd6b20; }
.mnav-badge-rental     { background: #e53e3e; }
.mnav-badge-spareparts { background: #d69e2e; }
.mnav-badge-repair     { background: #38a169; }
