/* ============================================
   MOBILE SHOP MANAGEMENT SYSTEM
   MODERN ERP THEME v2.0
   ============================================ */

/* ---- CSS Variables ---- */
:root {
    --primary: #4361ee;
    --primary-dark: #3a56d4;
    --primary-light: #eef0ff;
    --secondary: #6c757d;
    --success: #2ecc71;
    --success-dark: #27ae60;
    --success-light: #eafaf1;
    --warning: #f39c12;
    --warning-dark: #d68910;
    --warning-light: #fef9e7;
    --danger: #e74c3c;
    --danger-dark: #c0392b;
    --danger-light: #fdedec;
    --info: #3498db;
    --info-dark: #2980b9;
    --info-light: #eaf2f8;
    --purple: #9b59b6;
    --purple-light: #f5eef8;
    --teal: #1abc9c;
    --teal-light: #e8f8f5;
    --pink: #e91e63;
    --pink-light: #fce4ec;
    --dark: #1e293b;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: #4361ee;
    --body-bg: #f1f5f9;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --transition: all 0.2s ease;
    --sidebar-width: 260px;
    --sidebar-collapsed: 68px;
    --topbar-height: 60px;
}

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

body {
    font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--body-bg);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: var(--primary); }
a:hover { text-decoration: none; color: var(--primary-dark); }

/* ---- Login ---- */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--sidebar-bg) 0%, #1e293b 50%, #334155 100%);
    position: relative;
    overflow: hidden;
}
.login-container::before {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(67,97,238,0.15), transparent 70%);
    top: -100px;
    right: -100px;
    border-radius: 50%;
}
.login-container::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(26,188,156,0.1), transparent 70%);
    bottom: -80px;
    left: -80px;
    border-radius: 50%;
}
.login-box {
    background: white;
    padding: 44px 40px;
    border-radius: 16px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.25);
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
}
.login-box h2 { text-align: center; margin-bottom: 8px; color: var(--dark); font-size: 22px; font-weight: 700; }
.login-box .logo-icon { text-align: center; font-size: 48px; margin-bottom: 12px; }
.login-box .login-subtitle { text-align: center; color: var(--text-secondary); font-size: 13px; margin-bottom: 28px; }
.login-box .form-group { margin-bottom: 18px; }
.login-box .form-control {
    padding: 12px 14px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: var(--transition);
}
.login-box .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67,97,238,0.12);
}
.login-box .btn-primary {
    width: 100%;
    padding: 12px;
    font-size: 15px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    background: var(--primary);
    border: none;
    cursor: pointer;
    transition: var(--transition);
}
.login-box .btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow-md); }

/* ---- Layout ---- */
.wrapper { display: flex; min-height: 100vh; }

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    transition: width 0.3s ease, transform 0.3s ease;
    display: flex;
    flex-direction: column;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.sidebar-header {
    padding: 22px 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
    position: relative;
}
.sidebar-header h3 {
    font-size: 15px;
    margin-top: 8px;
    font-weight: 600;
    letter-spacing: 0.3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-header .shop-icon { font-size: 34px; }
.sidebar-header img {
    max-width: 48px;
    max-height: 48px;
    border-radius: 12px;
    margin-bottom: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.nav-section {
    padding: 12px 20px 8px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.8px;
    color: rgba(255,255,255,0.35);
    font-weight: 600;
    border-top: 1px solid rgba(255,255,255,0.04);
    margin-top: 2px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    transition: color 0.2s ease;
}
.nav-section:hover {
    color: rgba(255,255,255,0.6);
}
.nav-section:first-child { border-top: none; margin-top: 0; }
.nav-section .section-chevron {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}
.nav-section.open .section-chevron {
    transform: rotate(180deg);
}

/* ── Section Items Container (Accordion) ── */
.nav-section-items {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
}
.nav-section-items.open {
    max-height: 600px;
}

.sidebar-nav { flex: 1; padding-bottom: 20px; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 9px 20px;
    color: rgba(255,255,255,0.55);
    text-decoration: none;
    font-size: 13px;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
    gap: 10px;
    position: relative;
}
.sidebar-nav a:hover {
    background: rgba(255,255,255,0.05);
    color: rgba(255,255,255,0.9);
    border-left-color: rgba(67,97,238,0.4);
}
.sidebar-nav a.active {
    background: rgba(67,97,238,0.12);
    color: #fff;
    border-left-color: var(--sidebar-active);
    font-weight: 500;
}
.sidebar-nav a .nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
}
.sidebar-nav a .nav-icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 1.8;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ---- Sidebar Toggle Button ---- */
.sidebar-toggle {
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
}
.sidebar-toggle:hover {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.9);
}
.sidebar-toggle svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.3s ease;
}

/* ---- Sidebar Collapsed State ---- */
.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}
.sidebar.collapsed .sidebar-header {
    padding: 18px 10px;
}
.sidebar.collapsed .sidebar-header h3 {
    display: none;
}
.sidebar.collapsed .sidebar-header .shop-icon {
    font-size: 26px;
}
.sidebar.collapsed .sidebar-header img {
    max-width: 36px;
    max-height: 36px;
}
.sidebar.collapsed .sidebar-toggle {
    right: 50%;
    transform: translate(50%, -50%);
}
.sidebar.collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}
.sidebar.collapsed .nav-section {
    display: none;
}
.sidebar.collapsed .nav-section-items {
    max-height: none;
    overflow: visible;
}
.sidebar.collapsed .sidebar-nav a {
    justify-content: center;
    padding: 12px 0;
    border-left: 3px solid transparent;
}
.sidebar.collapsed .sidebar-nav a span:not(.nav-icon) {
    display: none;
}
.sidebar.collapsed .sidebar-nav a .nav-icon {
    margin-right: 0;
}

/* Collapsed sidebar - tooltip on hover */
.sidebar.collapsed .sidebar-nav a {
    position: relative;
}
.sidebar.collapsed .sidebar-nav a::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--dark);
    color: #fff;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, left 0.2s ease;
    z-index: 2000;
    box-shadow: var(--shadow-md);
}
.sidebar.collapsed .sidebar-nav a:hover::after {
    opacity: 1;
    left: calc(100% + 14px);
}

/* Main content shift when sidebar collapsed */
.main-content.sidebar-collapsed {
    margin-left: var(--sidebar-collapsed);
}

/* ---- Main Content ---- */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

/* ---- Top Navbar with Module Dropdowns ---- */
.top-navbar {
    background: var(--card-bg);
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--topbar-height);
    border-bottom: 1px solid var(--border-color);
    gap: 8px;
}
.topnav-left {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    min-width: 0;
    overflow: visible;
    scrollbar-width: none;
}
.topnav-left::-webkit-scrollbar { display: none; }

.topnav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px 0 4px;
    text-decoration: none;
    color: var(--dark);
    border-right: 1px solid var(--border-color);
    margin-right: 6px;
    white-space: nowrap;
    flex-shrink: 0;
}
.topnav-brand:hover { color: var(--primary); }
.topnav-logo {
    max-width: 32px;
    max-height: 32px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.topnav-logo-icon { font-size: 22px; }
.topnav-brand-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--dark);
    letter-spacing: -0.3px;
}

.topnav-link {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}
.topnav-link:hover {
    background: #f1f5f9;
    color: var(--dark);
}
.topnav-link.active {
    color: var(--primary);
    background: var(--primary-light);
}

.topnav-link-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.topnav-link-icon svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 1.8;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Dropdown container */
.topnav-dropdown {
    position: relative;
    flex-shrink: 0;
}
.topnav-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 10px;
    color: var(--text-secondary);
    background: none;
    border: none;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    white-space: nowrap;
}
.topnav-dropdown-toggle:hover {
    background: #f1f5f9;
    color: var(--dark);
}
.topnav-dropdown.active .topnav-dropdown-toggle {
    color: var(--primary);
    background: var(--primary-light);
}
.topnav-chevron {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.2s ease;
}
.topnav-dropdown.open .topnav-chevron {
    transform: rotate(180deg);
}

/* Dropdown menu */
.topnav-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    padding: 6px 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    z-index: 9999;
}
.topnav-dropdown-menu.topnav-dropdown-wide {
    min-width: 220px;
}
.topnav-dropdown.open .topnav-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.topnav-dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 400;
    transition: background 0.15s ease;
    white-space: nowrap;
}
.topnav-dropdown-menu a:hover {
    background: var(--primary-light);
    color: var(--primary-dark);
}
.topnav-dropdown-menu a.active {
    color: var(--primary);
    background: var(--primary-light);
    font-weight: 600;
}
.topnav-dropdown-menu a .topnav-link-icon {
    opacity: 0.6;
}
.topnav-dropdown-menu a:hover .topnav-link-icon,
.topnav-dropdown-menu a.active .topnav-link-icon {
    opacity: 1;
}

/* Right section */
.topnav-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.topnav-user {
    color: var(--text-secondary);
    font-size: 13px;
    white-space: nowrap;
}
.topnav-user small {
    color: var(--text-muted);
}
.topnav-logout {
    background: var(--danger);
    color: white;
    border: none;
    padding: 7px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition);
    white-space: nowrap;
}
.topnav-logout:hover { background: var(--danger-dark); transform: translateY(-1px); }

/* Mobile menu button in top navbar */
.top-navbar .mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    flex-shrink: 0;
}
.top-navbar .mobile-menu-btn:hover {
    background: #f1f5f9;
    color: var(--dark);
}
.top-navbar .mobile-menu-btn svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.content { padding: 24px 28px; flex: 1; }

/* ---- Stats Grid ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
    border: 1px solid var(--border-color);
}
.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: transparent;
}
.stat-card .stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: white;
    flex-shrink: 0;
}
.stat-card .stat-icon.blue { background: linear-gradient(135deg, #4361ee, #5a7bff); }
.stat-card .stat-icon.green { background: linear-gradient(135deg, #2ecc71, #45d98a); }
.stat-card .stat-icon.orange { background: linear-gradient(135deg, #f39c12, #f5b041); }
.stat-card .stat-icon.red { background: linear-gradient(135deg, #e74c3c, #f1948a); }
.stat-card .stat-icon.purple { background: linear-gradient(135deg, #9b59b6, #af7ac5); }
.stat-card .stat-icon.teal { background: linear-gradient(135deg, #1abc9c, #48c9b0); }
.stat-card .stat-icon.dark { background: linear-gradient(135deg, #1e293b, #334155); }
.stat-card .stat-icon.pink { background: linear-gradient(135deg, #e91e63, #f48fb1); }
.stat-card .stat-info h4 { font-size: 20px; color: var(--dark); font-weight: 700; letter-spacing: -0.3px; }
.stat-card .stat-info p { color: var(--text-muted); font-size: 12px; margin-top: 2px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }

/* ---- Card ---- */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    margin-bottom: 22px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fafbfc;
}
.card-header h3 { font-size: 15px; color: var(--dark); font-weight: 600; }
.card-header h2 { font-size: 16px; color: var(--dark); font-weight: 600; margin: 0; }
.card-header h4 { font-size: 15px; color: var(--dark); font-weight: 600; margin: 0; }
.card-body { padding: 20px; }

/* ---- Tables ---- */
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
table th {
    background: #f8fafc;
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}
table td {
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
    color: var(--text-primary);
    vertical-align: middle;
}
table tr { transition: background 0.15s ease; }
table tr:hover { background: #f8fafc; }

/* Ledger Table (for reports) */
.ledger-table td, .ledger-table th { padding: 8px 12px; font-size: 12px; }
.ledger-table .total-row {
    background: var(--dark) !important;
    color: white;
    font-weight: bold;
}
.ledger-table .total-row td { border-bottom: none; color: white; }
.ledger-table .subtotal-row { background: #f1f5f9; font-weight: 600; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 18px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1.4;
    font-family: inherit;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: var(--success-dark); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: var(--warning-dark); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: var(--danger-dark); color: white; }
.btn-secondary { background: #e2e8f0; color: var(--text-secondary); }
.btn-secondary:hover { background: #cbd5e1; color: var(--text-primary); }
.btn-info { background: var(--info); color: white; }
.btn-info:hover { background: var(--info-dark); }
.btn-outline-secondary { background: white; color: var(--text-secondary); border: 1px solid var(--border-color); }
.btn-outline-secondary:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 4px; }

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 13px;
}
.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 13px;
    transition: all 0.2s ease;
    background: white;
    color: var(--text-primary);
    font-family: inherit;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67,97,238,0.1);
}
.form-control::placeholder { color: var(--text-muted); }
select.form-control { appearance: auto; }
textarea.form-control { resize: vertical; min-height: 70px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.form-text, .text-muted, small.text-muted { color: var(--text-muted) !important; font-size: 11px; margin-top: 4px; }

/* ---- Alerts ---- */
.alert {
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
    font-size: 13px;
    border-left: 4px solid;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.alert-success { background: var(--success-light); color: #155724; border-left-color: var(--success); }
.alert-danger { background: var(--danger-light); color: #721c24; border-left-color: var(--danger); }
.alert-warning { background: var(--warning-light); color: #856404; border-left-color: var(--warning); }
.alert-info { background: var(--info-light); color: #0c5460; border-left-color: var(--info); }
.alert ul { margin: 4px 0 0 18px; padding: 0; }

/* ---- Badges ---- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.2px;
}
.badge-success, .badge-success { background: var(--success-light); color: #155724; }
.badge-danger, .badge-secondary { background: var(--danger-light); color: #721c24; }
.badge-warning { background: var(--warning-light); color: #856404; }
.badge-info { background: var(--info-light); color: #0c5460; }
.badge-primary { background: var(--primary-light); color: #3a56d4; }
.badge-dark { background: #e2e8f0; color: var(--dark); }

/* ---- Action Buttons ---- */
.action-btns { display: flex; gap: 5px; flex-wrap: nowrap; }

/* ---- Filter Bar ---- */
.filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    gap: 12px;
    flex-wrap: wrap;
}
.filter-bar .search-box { display: flex; gap: 8px; flex: 1; max-width: 500px; }
.filter-bar .search-box input { flex: 1; }
.filter-bar h2, .filter-bar h4 { margin: 0; }

/* ---- Balance Highlight ---- */
.balance-positive { color: var(--success-dark); font-weight: 600; }
.balance-negative { color: var(--danger); font-weight: 600; }
.text-warning { color: var(--warning) !important; }
.text-danger { color: var(--danger) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-center { text-align: center; }

/* ---- Report Header ---- */
.report-header {
    text-align: center;
    padding: 20px;
    margin-bottom: 20px;
    border-bottom: 3px double var(--dark);
}
.report-header h2 { color: var(--dark); margin-bottom: 5px; font-size: 20px; }
.report-header p { color: var(--text-secondary); font-size: 13px; }

/* ---- Breadcrumb ---- */
.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    padding: 8px 14px;
    margin: 0 0 16px 0;
    list-style: none;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    font-size: 13px;
}
.breadcrumb-item + .breadcrumb-item::before { content: "/"; padding: 0 8px; color: var(--text-muted); }
.breadcrumb-item a { color: var(--primary); text-decoration: none; font-weight: 500; }
.breadcrumb-item a:hover { text-decoration: underline; }
.breadcrumb-item.active { color: var(--text-secondary); }

/* ---- IMEI ---- */
.imei-code {
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 12px;
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 4px;
    color: var(--dark);
    letter-spacing: 0.3px;
}

/* ---- Account Tree ---- */
.account-inactive { opacity: 0.5; background: #f8fafc; }
.tree-toggle { user-select: none; font-size: 12px; cursor: pointer; }
.tree-children { }

/* ---- Day Book ---- */
.daybook-entry { transition: box-shadow 0.2s; }
.daybook-entry:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.daybook-entry table th { font-size: 11px; padding: 6px 8px; }
.daybook-entry table td { font-size: 12px; padding: 5px 8px; }
@media print {
    .daybook-entry { break-inside: avoid; }
    .daybook-entry:hover { box-shadow: none; }
}

/* ---- Stock Badges (Inventory Report) ---- */
.stock-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 12px;
    border-radius: 50px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.stock-badge.in-stock { background: var(--success-light); color: #155724; }
.stock-badge.out-of-stock { background: var(--danger-light); color: #721c24; }
.stock-badge.low-stock { background: var(--warning-light); color: #856404; }

/* ---- Tab Button Group (Inventory Report) ---- */
.tab-btn-group {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-color);
}
.tab-btn-group .tab-btn {
    padding: 10px 24px;
    border: none;
    background: #f8fafc;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
    transition: all 0.2s;
    flex: 1;
    text-align: center;
    font-family: inherit;
}
.tab-btn-group .tab-btn:hover { background: #e2e8f0; }
.tab-btn-group .tab-btn.active { background: var(--primary); color: #fff; }
.tab-btn-group .tab-btn .count-badge {
    display: inline-block;
    background: rgba(255,255,255,0.2);
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 11px;
    margin-left: 6px;
}
.tab-btn-group .tab-btn.active .count-badge { background: rgba(255,255,255,0.3); }

/* ---- IMEI Toggle / Detail ---- */
.imei-toggle {
    cursor: pointer;
    color: var(--primary);
    text-decoration: underline;
    font-size: 12px;
    font-weight: 500;
}
.imei-toggle:hover { color: var(--primary-dark); }
.imei-detail-row td { padding: 0 !important; background: #f8fafc; }
.imei-detail-box {
    padding: 14px 20px;
    margin: 8px 12px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}
.imei-chip {
    display: inline-block;
    padding: 4px 12px;
    margin: 3px;
    border-radius: 6px;
    font-size: 12px;
    font-family: monospace;
}
.imei-chip.available { background: var(--success-light); color: #155724; border: 1px solid #c3e6cb; }
.imei-chip.sold { background: #e2e3e5; color: #6c757d; border: 1px solid #d6d8db; text-decoration: line-through; }
.imei-chip.defective { background: var(--danger-light); color: #721c24; border: 1px solid #f5c6cb; }
.imei-chip.returned { background: var(--warning-light); color: #856404; border: 1px solid #ffeeba; }
.value-highlight { font-weight: 700; color: var(--primary); }

/* ---- Utility Classes (Bootstrap-like) ---- */
.d-flex { display: flex !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-end { justify-content: flex-end !important; }
.align-items-center { align-items: center !important; }
.align-items-end { align-items: flex-end !important; }
.gap-2 { gap: 8px; }
.mb-0 { margin-bottom: 0 !important; }
.mb-3 { margin-bottom: 12px !important; }
.mb-4 { margin-bottom: 16px !important; }
.mt-3 { margin-top: 12px !important; }
.mt-4 { margin-top: 16px !important; }
.ml-2 { margin-left: 8px; }
.mr-2 { margin-right: 8px; }
.py-4 { padding-top: 24px !important; padding-bottom: 24px !important; }
.col-md-4 { flex: 0 0 33.333%; max-width: 33.333%; }
.col-md-6 { flex: 0 0 50%; max-width: 50%; }
.col-md-8 { flex: 0 0 66.666%; max-width: 66.666%; }
.col-md-12 { flex: 0 0 100%; max-width: 100%; }
.font-weight-bold { font-weight: 700; }
.text-right { text-align: right; }

/* ---- Print ---- */
@media print {
    /* Reset everything to black & white */
    * {
        color: #000 !important;
        background: #fff !important;
        box-shadow: none !important;
        text-shadow: none !important;
        filter: none !important;
    }

    /* Hide everything that is NOT data */
    .sidebar,
    .top-navbar,
    .topnav-dropdown,
    .btn,
    .action-btns,
    .filter-bar,
    .no-print,
    .tab-btn-group,
    .imei-toggle,
    .imei-detail-row,
    .stats-grid,
    .stat-card,
    .alert,
    .breadcrumb,
    .form-group,
    .form-row,
    form,
    .card-header,
    .login-container,
    .login-box,
    .daybook-entry table th { background: #fff !important; }

    /* Hide interactive / nav elements */
    .sidebar,
    .top-navbar,
    .topnav-dropdown,
    .btn,
    .action-btns,
    .filter-bar,
    .no-print,
    .tab-btn-group,
    .imei-toggle,
    .imei-detail-row,
    .stats-grid,
    .stat-card,
    .alert,
    .breadcrumb,
    .form-group,
    .form-row,
    form,
    .card-header {
        display: none !important;
    }

    /* Layout: full width, no margins from sidebar */
    .wrapper { display: block !important; }
    .main-content { margin-left: 0 !important; width: 100% !important; }
    .content { padding: 0 !important; }

    /* Card: remove decoration, keep structure for table wrapper */
    .card {
        box-shadow: none !important;
        border: none !important;
        margin-bottom: 12px !important;
        border-radius: 0 !important;
        animation: none !important;
    }
    .card-body { padding: 0 !important; }

    /* Report header: keep visible but black & white */
    .report-header {
        display: block !important;
        border-bottom: 2px solid #000 !important;
        padding: 10px 0 !important;
        margin-bottom: 10px !important;
    }
    .report-header h2 { font-size: 16px !important; font-weight: 700 !important; }
    .report-header p { font-size: 11px !important; }

    /* ---- TABLES: The star of the print ---- */
    .table-responsive { overflow: visible !important; }

    table {
        width: 100% !important;
        border-collapse: collapse !important;
        font-size: 11px !important;
    }

    table th {
        background: #eee !important;
        color: #000 !important;
        font-weight: 700 !important;
        font-size: 10px !important;
        text-transform: uppercase !important;
        letter-spacing: 0.3px !important;
        padding: 6px 8px !important;
        border: 1px solid #000 !important;
        border-bottom: 2px solid #000 !important;
        white-space: nowrap !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    table td {
        padding: 5px 8px !important;
        border: 1px solid #999 !important;
        font-size: 11px !important;
        color: #000 !important;
        vertical-align: middle !important;
    }

    table tr {
        background: #fff !important;
        page-break-inside: avoid !important;
    }
    table tr:hover { background: #fff !important; }

    /* Ledger table specifics */
    .ledger-table td, .ledger-table th { padding: 4px 6px !important; font-size: 10px !important; }
    .ledger-table .total-row {
        background: #ddd !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    .ledger-table .total-row td { color: #000 !important; font-weight: 700 !important; border-bottom: 2px solid #000 !important; }
    .ledger-table .subtotal-row {
        background: #eee !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Opening balance row */
    .ledger-table tr[style*="background:#f0f2f5"],
    .ledger-table tr[style*="background: #f0f2f5"] {
        background: #eee !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Badges: convert to simple bordered text */
    .badge {
        border: 1px solid #000 !important;
        background: #fff !important;
        color: #000 !important;
        border-radius: 2px !important;
        font-weight: 600 !important;
        font-size: 9px !important;
        padding: 1px 6px !important;
    }

    /* Stock badges in B&W */
    .stock-badge {
        border: 1px solid #000 !important;
        background: #fff !important;
        color: #000 !important;
        border-radius: 2px !important;
    }

    /* IMEI code: simple monospace */
    .imei-code {
        background: #fff !important;
        border: 1px solid #999 !important;
        font-size: 10px !important;
        padding: 1px 4px !important;
    }

    /* Balance text: use bold instead of colors */
    .balance-positive { color: #000 !important; font-weight: 700 !important; }
    .balance-negative { color: #000 !important; font-weight: 700 !important; text-decoration: underline !important; }

    /* Day book entries */
    .daybook-entry {
        break-inside: avoid !important;
        border: 1px solid #999 !important;
        margin-bottom: 8px !important;
    }
    .daybook-entry:hover { box-shadow: none !important; }
    .daybook-entry table th { font-size: 9px !important; padding: 4px 6px !important; }
    .daybook-entry table td { font-size: 10px !important; padding: 3px 6px !important; }

    /* Page settings */
    @page {
        size: A4;
        margin: 10mm;
    }

    /* Avoid orphan rows / widows */
    p, h2, h3, h4 { orphans: 3; widows: 3; }

    /* Links: show URL in print (optional, can remove if not wanted) */
    a[href]:after { content: none !important; }

    /* Hide elements that are only for screen */
    nav, footer, .sidebar-nav, .logout-btn { display: none !important; }
}

/* ---- Invoice POS Print ---- */
@media print {
    .invoice-pos { width: 80mm !important; margin: 0 !important; padding: 2mm !important; }
    .invoice-pos .print-btn { display: none !important; }
}

/* ---- Invoice A5 Print ---- */
@page invoice-a5 { size: A5; margin: 10mm; }
@media print {
    .invoice-a5-page { box-shadow: none !important; margin: 0 !important; }
    .invoice-a5-page .print-btn { display: none !important; }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    /* Mobile: sidebar hidden by default, slides in as overlay */
    .sidebar {
        width: var(--sidebar-width);
        transform: translateX(-100%);
        box-shadow: none;
    }
    .sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0,0,0,0.3);
    }
    .sidebar.collapsed {
        width: var(--sidebar-width);
        transform: translateX(-100%);
    }
    .sidebar.collapsed.mobile-open {
        transform: translateX(0);
    }
    .sidebar.mobile-open .sidebar-header h3,
    .sidebar.mobile-open .sidebar-nav a span:not(.nav-icon),
    .sidebar.mobile-open .nav-section {
        display: flex;
    }
    .sidebar.mobile-open .nav-section-items {
        max-height: 600px;
    }
    .sidebar.mobile-open .sidebar-nav a {
        justify-content: revert;
        padding: 9px 20px;
    }
    .sidebar.mobile-open .sidebar-toggle svg {
        transform: none;
    }
    .sidebar.mobile-open .sidebar-toggle {
        right: 12px;
        transform: translateY(-50%);
    }
    .main-content { margin-left: 0 !important; }
    .main-content.sidebar-collapsed { margin-left: 0 !important; }
    .top-navbar .mobile-menu-btn { display: flex; }
    .topnav-brand-name { display: none; }
    .topnav-link span,
    .topnav-dropdown-toggle span:not(.topnav-link-icon) { display: none; }
    .topnav-link,
    .topnav-dropdown-toggle { padding: 8px; }
    .topnav-chevron { display: none; }
    .topnav-user { display: none; }
    /* Overlay backdrop for mobile */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 999;
        backdrop-filter: blur(2px);
    }
    .sidebar-overlay.active { display: block; }

    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .content { padding: 14px; }
    .top-navbar { padding: 0 10px; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .card-header { flex-direction: column; gap: 10px; align-items: flex-start; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .content { padding: 10px; }
    .login-box { padding: 28px 22px; }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ---- Selection ---- */
::selection { background: rgba(67,97,238,0.15); color: var(--dark); }

/* ---- Searchable Dropdown ---- */
.searchable-dropdown {
    position: relative;
    width: 100%;
}
.searchable-dropdown .sd-input {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 13px;
    transition: all 0.2s ease;
    background: white;
    color: var(--text-primary);
    font-family: inherit;
    cursor: pointer;
}
.searchable-dropdown .sd-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67,97,238,0.1);
}
.searchable-dropdown .sd-input::placeholder { color: var(--text-muted); }
.searchable-dropdown .sd-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1.5px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 220px;
    overflow-y: auto;
    z-index: 9999;
    box-shadow: var(--shadow-md);
    display: none;
}
.searchable-dropdown .sd-list.open { display: block; }
.searchable-dropdown .sd-item {
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.1s ease;
    border-bottom: 1px solid #f1f5f9;
}
.searchable-dropdown .sd-item:hover { background: var(--primary-light); color: var(--primary-dark); }
.searchable-dropdown .sd-item.selected { background: var(--primary); color: white; }
.searchable-dropdown .sd-item .sd-item-code { font-family: monospace; color: var(--text-muted); font-size: 11px; margin-right: 6px; }
.searchable-dropdown .sd-item.selected .sd-item-code { color: rgba(255,255,255,0.7); }
.searchable-dropdown .sd-item .sd-item-type { font-size: 10px; padding: 1px 6px; border-radius: 3px; margin-left: 6px; }
.searchable-dropdown .sd-item .sd-item-type.asset { background: #eef0ff; color: #4361ee; }
.searchable-dropdown .sd-item .sd-item-type.liability { background: #fef9e7; color: #d68910; }
.searchable-dropdown .sd-item .sd-item-type.equity { background: #f5eef8; color: #9b59b6; }
.searchable-dropdown .sd-item .sd-item-type.income { background: #eafaf1; color: #27ae60; }
.searchable-dropdown .sd-item .sd-item-type.expense { background: #fdedec; color: #e74c3c; }
.searchable-dropdown .sd-no-result { padding: 10px 12px; color: var(--text-muted); font-size: 12px; text-align: center; }
.searchable-dropdown .sd-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--text-muted);
    font-size: 16px;
    display: none;
    line-height: 1;
    padding: 2px;
}
.searchable-dropdown .sd-clear:hover { color: var(--danger); }
.searchable-dropdown.has-value .sd-clear { display: block; }
.searchable-dropdown.has-value .sd-input { padding-right: 28px; }

/* ---- Responsive Tables Enhancement ---- */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    margin-bottom: 16px;
}
.table-responsive table {
    min-width: 600px;
}

/* ---- Form Inputs Fit Screen ---- */
.form-control {
    max-width: 100%;
    width: 100%;
}
input[type="number"].form-control {
    min-width: 80px;
}
select.form-control {
    max-width: 100%;
}

/* ---- Item Tables in Purchase/Sale ---- */
#itemsTable {
    min-width: 700px;
}
#itemsTable input[type="text"],
#itemsTable input[type="number"],
#itemsTable select {
    font-size: 12px;
    padding: 6px 8px;
}

/* ---- Screen Size Responsive ---- */
@media (max-width: 1024px) {
    .form-row { grid-template-columns: 1fr 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .content { padding: 14px; }
    .top-navbar { padding: 0 10px; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .card-header { flex-direction: column; gap: 10px; align-items: flex-start; }
    #itemsTable input[type="text"],
    #itemsTable input[type="number"],
    #itemsTable select {
        font-size: 11px;
        padding: 5px 6px;
    }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .content { padding: 10px; }
    .login-box { padding: 28px 22px; }
    table th, table td { padding: 6px 8px; font-size: 11px; }
    .btn { padding: 6px 12px; font-size: 12px; }
    .btn-sm { padding: 4px 8px; font-size: 11px; }
}

/* ---- Animation ---- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.card { animation: fadeIn 0.3s ease; }
.stat-card { animation: fadeIn 0.3s ease; }
