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

/* Modern Color System - CSS Custom Properties */
:root {
    /* Primary Brand Colors */
    --primary-50: #eff6ff;
    --primary-100: #dbeafe;
    --primary-200: #bfdbfe;
    --primary-300: #93c5fd;
    --primary-400: #60a5fa;
    --primary-500: #3b82f6;
    --primary-600: #2563eb;
    --primary-700: #1d4ed8;
    --primary-800: #1e40af;
    --primary-900: #1e3a8a;

    /* Neutral Colors */
    --neutral-50: #f8fafc;
    --neutral-100: #f1f5f9;
    --neutral-200: #e2e8f0;
    --neutral-300: #cbd5e1;
    --neutral-400: #94a3b8;
    --neutral-500: #64748b;
    --neutral-600: #475569;
    --neutral-700: #334155;
    --neutral-800: #1e293b;
    --neutral-900: #0f172a;

    /* Success Colors */
    --success-50: #f0fdf4;
    --success-100: #dcfce7;
    --success-500: #22c55e;
    --success-600: #16a34a;
    --success-700: #15803d;

    /* Warning Colors */
    --warning-50: #fffbeb;
    --warning-100: #fef3c7;
    --warning-500: #f59e0b;
    --warning-600: #d97706;
    --warning-700: #b45309;

    /* Error/Danger Colors */
    --error-50: #fef2f2;
    --error-100: #fee2e2;
    --error-500: #ef4444;
    --error-600: #dc2626;
    --error-700: #b91c1c;

    /* Semantic Colors */
    --background: var(--neutral-50);
    --surface: #ffffff;
    --text-primary: var(--neutral-900);
    --text-secondary: var(--neutral-600);
    --text-tertiary: var(--neutral-500);
    --border: var(--neutral-200);
    --border-light: var(--neutral-100);

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Screen Management */
.screen {
    display: none;
}

.screen.active {
    display: flex;
}

/* Login Screen - 50/50 Split */
#loginScreen.active {
    min-height: 100vh;
    display: flex;
    overflow: hidden;
}

.login-split-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* Left Side - Full Blue Branding */
.login-branding {
    flex: 1;
    background: linear-gradient(135deg, var(--primary-700) 0%, var(--primary-900) 100%);
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
}

.branding-content {
    width: 100%;
    max-width: 500px;
    text-align: center;
}

.branding-content h1 {
    font-size: 38px;
    font-weight: 700;
    margin-bottom: 12px;
    letter-spacing: -1px;
    line-height: 1.2;
    color: white;
}

.branding-subtitle {
    font-size: 16px;
    font-weight: 400;
    opacity: 0.9;
    line-height: 1.6;
    margin-bottom: 32px;
    color: white;
}

.branding-features {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
}

.feature-item {
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    text-align: left;
}

.feature-item:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateX(8px);
}

.feature-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.feature-text strong {
    font-size: 15px;
    font-weight: 600;
    color: white;
}

.feature-text span {
    font-size: 13px;
    opacity: 0.85;
    color: white;
}

/* Right Side - White Login Form */
.login-form-section {
    flex: 1;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px 60px;
    position: relative;
    overflow-y: auto;
}

/* Logo in top right corner */
.login-logo-top {
    position: absolute;
    top: 30px;
    right: 30px;
}

.login-logo-top img {
    max-width: 150px;
    height: auto;
}

.login-form-wrapper {
    width: 100%;
    max-width: 420px;
}

.login-form-wrapper h2 {
    font-size: 24px;
    font-weight: 700;
    color: #1e40af;
    margin-bottom: 15px;
    letter-spacing: -0.5px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.login-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
    text-align: left;
}

.login-form .form-group label {
    font-size: 12px;
    font-weight: 500;
    color: #334155;
    margin-bottom: 1px;
}

.login-form .form-group small {
    font-size: 10px;
    margin-top: 1px;
}

.login-form input {
    width: 100%;
    padding: 8px 10px;
    border: 2px solid #1e40af;
    border-radius: 5px;
    font-size: 13px;
    transition: all 0.2s ease;
    background: #ffffff;
    color: #1e293b;
}

.login-form input:focus {
    outline: none;
    border-color: #1e40af;
    background: #f8fafc;
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

.login-form input::placeholder {
    color: #94a3b8;
}

.btn-login {
    width: 100%;
    padding: 9px;
    background: #dc2626;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 6px;
}

.btn-login:hover {
    background: #b91c1c;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.btn-login:active {
    transform: translateY(0);
}

/* Mobile Responsive Login */
@media (max-width: 768px) {
    .login-split-container {
        flex-direction: column;
    }

    .login-branding {
        padding: 30px 20px;
        min-height: 40vh;
    }

    .branding-content h1 {
        font-size: 28px;
    }

    .branding-subtitle {
        font-size: 14px;
        margin-bottom: 24px;
    }

    .branding-features {
        gap: 10px;
    }

    .feature-item {
        padding: 12px 16px;
    }

    .feature-text strong {
        font-size: 14px;
    }

    .feature-text span {
        font-size: 12px;
    }

    .login-form-section {
        padding: 30px 20px;
    }

    .login-logo-top {
        top: 20px;
        right: 20px;
    }

    .login-logo-top img {
        max-width: 120px;
    }

    .login-form-wrapper h2 {
        font-size: 28px;
        margin-bottom: 24px;
    }
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.login-form button:active {
    transform: translateY(0);
}

.demo-credentials {
    margin-top: 24px;
    padding: 16px;
    background: #f1f5f9;
    border-radius: 8px;
    font-size: 13px;
    border-left: 3px solid #1e40af;
}

.demo-credentials p {
    margin: 6px 0;
    color: #475569;
}

.demo-credentials strong {
    color: #1e293b;
}

.error-message {
    color: #e74c3c;
    margin-top: 10px;
    font-size: 14px;
}

/* Main App Layout */
#mainApp {
    display: none;
    height: 100vh;
}

#mainApp.active {
    display: flex;
}

/* Sidebar Navigation */
.sidebar {
    width: 280px;
    background: white;
    box-shadow: 2px 0 8px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    border-right: 1px solid #e2e8f0;
}

.nav-brand {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.sidebar-title {
    font-size: 20px;
    background: linear-gradient(135deg, var(--primary-700) 0%, var(--primary-900) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
    letter-spacing: -0.5px;
    text-align: center;
    margin: 0;
}

.sidebar-subtitle {
    color: var(--text-tertiary);
    margin: 0;
    padding: 0;
    font-size: 11px;
    font-weight: 500;
    text-align: center;
}

.nav-brand h1 {
    font-size: 18px;
    background: linear-gradient(135deg, var(--primary-700) 0%, var(--primary-900) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
    letter-spacing: -0.5px;
    text-align: center;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

.nav-btn {
    width: 100%;
    padding: 14px 18px;
    background: transparent;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: left;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    overflow: hidden;
}

.nav-btn::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--primary-500);
    transform: scaleY(0);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 0 4px 4px 0;
}

.nav-btn:hover {
    background: linear-gradient(135deg, var(--primary-50) 0%, var(--neutral-50) 100%);
    color: var(--primary-700);
    transform: translateX(4px);
}

.nav-btn:hover::before {
    transform: scaleY(1);
}

.nav-btn.active {
    background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-800) 100%);
    color: white;
    box-shadow: var(--shadow-lg);
    transform: translateX(4px);
}

.nav-btn.active::before {
    transform: scaleY(1);
    background: white;
}

.nav-user {
    padding: 20px;
    border-top: 1px solid var(--border-light);
    background: linear-gradient(180deg, transparent 0%, var(--primary-50) 100%);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Main Content Area */
.main-content {
    margin-left: 280px;
    width: calc(100% - 280px);
    height: 100vh;
    overflow-y: auto;
    background: #f8fafc;
}

.nav-user span {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    padding: 8px 12px;
    background: white;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    text-align: center;
}

.nav-user button {
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--error-500) 0%, var(--error-600) 100%);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    font-size: 14px;
    box-shadow: var(--shadow-sm);
}

.nav-user button:hover {
    background: linear-gradient(135deg, var(--error-600) 0%, var(--error-700) 100%);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Tab Content */
.tab-content {
    display: none;
    padding: 30px;
    max-width: 1400px;
    margin: 0 auto;
}

.tab-content.active {
    display: block;
}

.tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.tab-header h2 {
    color: #333;
}

/* Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

/* Custom Dashboard Layout: 2 large items top, 3 smaller items bottom */
.dashboard-grid-custom {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 25px;
    margin-bottom: 30px;
}

/* Profit Metrics Layout: 2 cards on top, 3 below */
.profit-metrics-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.profit-metrics-top {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.profit-metrics-bottom {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

/* Large cards span 3 columns each (2 cards = 6 columns) */
.metric-card-large {
    grid-column: span 3;
    padding: 50px 40px;
    min-height: 180px;
}

/* Large card values - bigger font size */
.metric-card-large .metric-value {
    font-size: 56px;
}

.metric-card-large h3 {
    font-size: 15px;
}

/* Small cards span 2 columns each (3 cards = 6 columns) */
.metric-card-small {
    grid-column: span 2;
    padding: 35px 30px;
    min-height: 140px;
}

/* Small card values - standard size */
.metric-card-small .metric-value {
    font-size: 44px;
}

.metric-card {
    background: white;
    padding: 40px 35px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
    border: 1px solid #e2e8f0;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.metric-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.12);
    border-color: #cbd5e1;
}

.metric-card h3 {
    font-size: 14px;
    color: #64748b;
    margin-bottom: 16px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 48px;
    font-weight: 700;
    background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
    word-break: break-word;
}

.metric-card.alert .metric-value {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.dashboard-section {
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.dashboard-section h3 {
    margin-bottom: 15px;
    color: #333;
}

.alert-list, .recent-list {
    max-height: 300px;
    overflow-y: auto;
}

.alert-item, .recent-item {
    padding: 12px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.alert-item:last-child, .recent-item:last-child {
    border-bottom: none;
}

.alert-item.critical {
    background: #ffe6e6;
    border-left: 4px solid #e74c3c;
}

/* Buttons */
.btn-primary {
    padding: 11px 22px;
    background: linear-gradient(135deg, var(--primary-700) 0%, var(--primary-900) 100%);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-md);
}

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

.btn-secondary {
    padding: 11px 22px;
    background: var(--neutral-200);
    color: var(--text-secondary);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: var(--neutral-300);
    color: var(--text-primary);
}

.btn-success {
    padding: 8px 16px;
    background: var(--success-600);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-success:hover {
    background: var(--success-700);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(34, 197, 94, 0.3);
}

.btn-danger {
    padding: 8px 16px;
    background: var(--error-500);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-danger:hover {
    background: var(--error-600);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.3);
}

.btn-info {
    padding: 8px 16px;
    background: var(--primary-500);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-info:hover {
    background: var(--primary-600);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

.btn-warning {
    padding: 8px 16px;
    background: var(--warning-500);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-warning:hover {
    background: var(--warning-600);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(245, 158, 11, 0.3);
}

.btn-remove {
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

/* Sub-tab Buttons */
.sub-tab-btn {
    padding: 12px 24px;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.sub-tab-btn:hover {
    color: var(--text-primary);
    background: var(--neutral-50);
}

.sub-tab-btn.active {
    color: var(--primary-600);
    border-bottom-color: var(--primary-600);
}

/* Profit Section Visibility */
.profit-section {
    display: none !important;
}

.profit-section.active {
    display: block !important;
}

/* Search Bar */
.search-bar {
    margin-bottom: 20px;
}

.search-bar input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

/* Tables */
.table-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow-x: auto;
    border: 1px solid #e2e8f0;
}

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

thead {
    background: #f8fafc;
}

th {
    padding: 16px 18px;
    text-align: left;
    font-weight: 600;
    color: #475569;
    border-bottom: 2px solid #e2e8f0;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

th.sortable {
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

th.sortable:hover {
    background: #e2e8f0;
    color: #1e40af;
}

td {
    padding: 16px 18px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    font-size: 14px;
}

tbody tr:hover {
    background: #f8fafc;
}

.status-badge {
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
    letter-spacing: 0.3px;
}

.status-badge.low-stock {
    background: #fee2e2;
    color: #dc2626;
}

.status-badge.in-stock {
    background: #d1fae5;
    color: #059669;
}

.status-badge.pending {
    background: #fef3c7;
    color: #d97706;
}

.status-badge.approved {
    background: #d1fae5;
    color: #059669;
}

.status-badge.rejected {
    background: #fee2e2;
    color: #dc2626;
}

.status-badge.completed {
    background: #d1fae5;
    color: #059669;
}

/* Modals */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
}

.modal-overlay.active {
    display: block;
}

.modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    z-index: 1001;
    max-height: 90vh;
    overflow-y: auto;
}

.modal.active {
    display: block;
}

.modal-content {
    padding: 32px;
    min-width: 500px;
}

.modal-content.large {
    min-width: 700px;
}

.modal-content h2 {
    margin-bottom: 24px;
    color: #1e293b;
    font-size: 24px;
    font-weight: 700;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

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

.modal-actions {
    margin-top: 25px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Sale Items */
#saleItems {
    margin-bottom: 15px;
}

.sale-item {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 5px;
}

.sale-item select,
.sale-item input {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
}

.item-subtotal {
    font-weight: 600;
    color: #1e40af;
}

.sale-total {
    text-align: right;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid #ddd;
}

.sale-total h3 {
    color: #1e40af;
    font-size: 24px;
}

.info-box {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 15px;
}

.info-box p {
    margin: 5px 0;
}

/* Autocomplete Suggestions */
.autocomplete-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 5px 5px;
    max-height: 350px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.autocomplete-suggestions.show {
    display: block;
}

.suggestion-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f1f1f1;
    transition: background 0.2s;
}

.suggestion-item:hover {
    background: #f8f9fa;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-name {
    font-weight: 600;
    color: #333;
}

.suggestion-details {
    font-size: 12px;
    color: #666;
    margin-top: 2px;
}

/* Action buttons in tables */
.action-buttons {
    display: flex;
    gap: 5px;
}

/* Responsive */
@media (max-width: 768px) {
    .nav-menu {
        flex-wrap: wrap;
    }

    .nav-btn {
        font-size: 12px;
        padding: 8px 12px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .modal-content {
        min-width: 90vw;
    }

    .table-container {
        overflow-x: scroll;
    }

    .sale-item {
        grid-template-columns: 1fr;
    }
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px;
    color: #999;
}

.empty-state h3 {
    margin-bottom: 10px;
}

/* ========================================
   ENHANCED MOBILE RESPONSIVENESS
   ======================================== */

/* Viewport meta tag reminder - add to index.html if not present:
   <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0">
*/

/* Tablets and Small Laptops */
@media (max-width: 1024px) {
    .main-container {
        padding: 15px;
    }

    .sidebar {
        width: 220px;
    }

    .content {
        margin-left: 220px;
    }
}

/* Tablets Portrait */
@media (max-width: 768px) {
    /* Login Screen - Stack vertically on mobile */
    .login-split-container {
        flex-direction: column;
    }

    .login-branding {
        min-height: 40vh;
        padding: 40px 24px;
    }

    .branding-content h1 {
        font-size: 32px;
    }

    .branding-subtitle {
        font-size: 16px;
        margin-bottom: 32px;
    }

    .branding-features {
        gap: 16px;
    }

    .feature-item {
        padding: 16px 20px;
    }

    .feature-icon {
        font-size: 28px;
    }

    .feature-item span:last-child {
        font-size: 14px;
    }

    .login-logo img {
        max-width: 200px;
    }

    .login-form-section {
        padding: 40px 24px;
        min-height: 60vh;
    }

    .login-form-container h2 {
        font-size: 28px;
    }

    .login-subtitle {
        font-size: 14px;
        margin-bottom: 32px;
    }

    /* Sidebar becomes overlay/drawer */
    .sidebar {
        position: fixed;
        left: -250px;
        width: 250px;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }

    .sidebar.mobile-open {
        left: 0;
    }

    .content,
    .main-content {
        margin-left: 0;
        width: 100%;
    }

    /* Header adjustments */
    .header {
        padding: 12px 15px;
        flex-wrap: wrap;
    }

    .header h2 {
        font-size: 20px;
        margin-bottom: 8px;
    }

    /* User info responsive */
    .nav-user {
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
        justify-content: space-between;
    }

    /* Dashboard cards */
    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    /* Tab content on tablets */
    .tab-content {
        padding: 20px 16px;
    }

    .dashboard-grid-custom {
        grid-template-columns: 1fr 1fr;
        gap: 18px;
    }

    /* Profit Metrics - Keep 2 on top, stack 3 below on tablet */
    .profit-metrics-top {
        grid-template-columns: 1fr 1fr;
        gap: 15px;
    }

    .profit-metrics-bottom {
        grid-template-columns: 1fr 1fr;
        gap: 15px;
    }

    .profit-metrics-bottom .metric-card:nth-child(3) {
        grid-column: 1 / -1; /* Make 3rd card full width */
    }

    .metric-card-large {
        grid-column: span 1;
        padding: 35px 28px;
        min-height: 150px;
    }

    .metric-card-large .metric-value {
        font-size: 46px;
    }

    .metric-card-small {
        grid-column: span 1;
        padding: 28px 22px;
        min-height: 120px;
    }

    .metric-card-small .metric-value {
        font-size: 38px;
    }

    .metric-card {
        padding: 30px 25px;
        min-height: 130px;
    }

    .metric-value {
        font-size: 42px;
    }

    .stat-card h3 {
        font-size: 14px;
    }

    .stat-card .value {
        font-size: 24px;
    }

    /* Tables */
    table {
        font-size: 13px;
    }

    th, td {
        padding: 10px 8px;
    }

    /* Action buttons in tables */
    .action-buttons {
        display: flex;
        flex-direction: column;
        gap: 5px;
    }

    .action-buttons button {
        width: 100%;
        font-size: 12px;
        padding: 6px 10px;
    }

    /* Modals */
    .modal-content {
        width: 95%;
        max-width: 500px;
        padding: 24px 16px;
        max-height: 90vh;
        overflow-y: auto;
    }

    /* Forms */
    .form-row {
        grid-template-columns: 1fr;
    }

    /* Search and filter bars */
    .search-bar {
        flex-direction: column;
        gap: 10px;
    }

    .search-bar input {
        width: 100%;
    }

    .search-bar button {
        width: 100%;
    }
}

/* Mobile Phones */
@media (max-width: 480px) {
    /* Login Screen */
    .login-branding {
        min-height: 35vh;
        padding: 32px 20px;
    }

    .branding-content h1 {
        font-size: 28px;
    }

    .branding-subtitle {
        font-size: 15px;
        margin-bottom: 24px;
    }

    .login-logo img {
        max-width: 160px;
    }

    .login-form-section {
        padding: 32px 20px;
    }

    .login-form-container h2 {
        font-size: 24px;
    }

    .login-form input {
        padding: 14px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .btn-login {
        padding: 16px;
        font-size: 16px;
    }

    .btn-primary {
        padding: 14px;
        font-size: 16px;
    }

    /* Header */
    .header {
        padding: 10px 12px;
    }

    .header h2 {
        font-size: 18px;
    }

    .user-info {
        font-size: 12px;
    }

    /* Dashboard - Single column on mobile */
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-grid-custom {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    /* Profit Metrics - Stack all vertically on mobile */
    .profit-metrics-top {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .profit-metrics-bottom {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .metric-card-large,
    .metric-card-small {
        grid-column: 1 / -1;
        padding: 25px 20px;
        min-height: 120px;
    }

    .metric-card-large .metric-value,
    .metric-card-small .metric-value {
        font-size: 36px;
    }

    .metric-card {
        padding: 25px 20px;
        min-height: 120px;
    }

    .metric-value {
        font-size: 36px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-card h3 {
        font-size: 13px;
    }

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

    /* Tables - Horizontal scroll with better touch support */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -16px; /* Extend to screen edges */
        padding: 0 16px;
    }

    table {
        min-width: 100%; /* Responsive width */
        font-size: 12px;
    }

    th, td {
        padding: 10px 8px;
        font-size: 12px;
        min-width: 80px; /* Minimum column width */
    }

    /* Make action buttons stack on mobile */
    td .action-buttons {
        display: flex;
        flex-direction: column;
        gap: 4px;
        min-width: 100px;
    }

    td .action-buttons button {
        width: 100%;
        padding: 6px 10px;
        font-size: 11px;
    }

    /* Alternative: Card view for tables on mobile */
    .table-card-view {
        display: none;
    }

    /* Buttons */
    .btn-primary, .btn-success, .btn-info, .btn-danger {
        padding: 10px 16px;
        font-size: 14px;
    }

    /* Modals - Full screen on mobile for better UX */
    .modal {
        padding: 0;
    }

    .modal-content {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        padding: 20px 16px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-header {
        position: sticky;
        top: 0;
        background: white;
        z-index: 10;
        padding-bottom: 12px;
        margin-bottom: 16px;
        border-bottom: 1px solid #e2e8f0;
    }

    .modal-header h3 {
        font-size: 18px;
        padding-right: 40px; /* Space for close button */
    }

    .modal-body {
        padding-bottom: 80px; /* Space for fixed footer if any */
    }

    /* Forms */
    .form-group label {
        font-size: 13px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 10px 12px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Tab content padding adjustment */
    .tab-content {
        padding: 16px;
    }

    /* Sale items in forms */
    .sale-item {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 12px;
    }

    .sale-item select,
    .sale-item input {
        width: 100%;
    }

    /* Search bars and filters */
    .search-bar,
    .filters {
        flex-direction: column;
        gap: 10px;
    }

    .search-bar input,
    .search-bar select,
    .search-bar button {
        width: 100%;
    }

    /* Cards and sections */
    .card,
    .section {
        margin: 0 0 16px 0;
        border-radius: 8px;
    }

    /* Better touch targets for all interactive elements */
    button,
    .btn,
    a.btn {
        min-height: 44px; /* iOS recommended touch target */
        display: inline-flex;
        align-items: center;
        justify-content: center;
        -webkit-tap-highlight-color: rgba(16, 185, 129, 0.3); /* Visual feedback on tap */
        touch-action: manipulation; /* Disable double-tap zoom on buttons */
    }

    /* Ensure clickable elements are accessible */
    button,
    .btn,
    input[type="button"],
    input[type="submit"],
    select,
    .nav-btn {
        cursor: pointer;
        pointer-events: auto;
    }

    /* Responsive images */
    img {
        max-width: 100%;
        height: auto;
    }

    /* Status badges */
    .status-badge {
        font-size: 11px;
        padding: 4px 8px;
    }

    /* Navigation */
    .nav-btn {
        padding: 10px;
        font-size: 13px;
    }

    .nav-btn i {
        font-size: 16px;
    }

    /* Pagination on mobile */
    .pagination-controls {
        flex-direction: column;
        gap: 12px;
        padding: 16px;
    }

    .pagination-info {
        width: 100%;
        text-align: center;
        font-size: 13px;
    }

    .pagination-buttons {
        width: 100%;
        justify-content: center;
    }

    .btn-pagination {
        padding: 10px 14px;
        font-size: 13px;
        min-width: 44px; /* Better touch target */
    }

    /* Receipt and print styles on mobile */
    .receipt-container {
        width: 100%;
        padding: 16px;
        font-size: 12px;
    }

    /* Better spacing for form groups */
    .form-group {
        margin-bottom: 16px;
    }

    /* Improve modal close button visibility */
    .close-btn {
        position: absolute;
        top: 16px;
        right: 16px;
        width: 32px;
        height: 32px;
        font-size: 24px;
        z-index: 10;
    }
}

/* Very Small Phones */
@media (max-width: 360px) {
    .login-branding {
        padding: 24px 16px;
    }

    .login-form-section {
        padding: 24px 16px;
    }

    .branding-content h1 {
        font-size: 24px;
    }

    .login-form-container h2 {
        font-size: 22px;
    }

    .header h2 {
        font-size: 16px;
    }

    .stat-card .value {
        font-size: 20px;
    }

    table {
        font-size: 11px;
    }

    .btn-primary, .btn-success {
        font-size: 13px;
        padding: 8px 12px;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Larger tap targets for touch devices */
    button, .btn-primary, .btn-success, .btn-info, .btn-danger {
        min-height: 44px; /* Apple's recommended minimum */
        min-width: 44px;
    }

    .nav-btn {
        min-height: 48px;
    }

    /* Remove hover effects on touch devices */
    button:hover,
    .nav-btn:hover {
        transform: none;
    }

    /* Better focus states for accessibility */
    button:active,
    .nav-btn:active {
        transform: scale(0.97);
        opacity: 0.9;
    }
}

/* Landscape mode for phones */
@media (max-width: 768px) and (orientation: landscape) {
    .login-split-container {
        flex-direction: row;
    }

    .login-branding {
        min-height: 100vh;
        flex: 0.4;
    }

    .login-form-section {
        flex: 0.6;
        overflow-y: auto;
    }

    .branding-features {
        display: none; /* Hide features in landscape to save space */
    }

    .modal-content {
        max-height: 85vh;
    }
}

/* Print styles */
@media print {
    .sidebar,
    .header,
    .action-buttons,
    .search-bar,
    .btn-primary,
    .btn-success {
        display: none !important;
    }

    .content {
        margin-left: 0;
        width: 100%;
    }

    table {
        page-break-inside: avoid;
    }

    .pagination-controls {
        display: none !important;
    }
}

/* Pagination Controls */
.pagination-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    margin-top: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    flex-wrap: wrap;
    gap: 15px;
}

.pagination-info {
    font-size: 14px;
    color: #64748b;
    font-weight: 500;
}

.pagination-buttons {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.btn-pagination {
    padding: 8px 12px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    color: #475569;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    min-width: 40px;
}

.btn-pagination:hover:not(:disabled) {
    background: #f8fafc;
    border-color: #1e40af;
    color: #1e40af;
    transform: translateY(-1px);
}

.btn-pagination:active:not(:disabled) {
    transform: translateY(0);
}

.btn-pagination.active {
    background: #1e40af;
    border-color: #1e40af;
    color: white;
    font-weight: 600;
}

.btn-pagination:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f8fafc;
}

/* Responsive pagination */
@media (max-width: 768px) {
    .pagination-controls {
        flex-direction: column;
        align-items: stretch;
        padding: 15px;
    }

    .pagination-info {
        text-align: center;
        order: 1;
    }

    .pagination-buttons {
        justify-content: center;
        order: 2;
    }

    .btn-pagination {
        padding: 10px 12px;
        min-width: 35px;
        font-size: 13px;
    }
}

/* Loading spinner animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========================================
   MOBILE MENU BUTTON & OVERLAY
   ======================================== */

/* Mobile Menu Button (Hamburger) */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1001;
    background: #1e40af;
    border: none;
    border-radius: 8px;
    width: 45px;
    height: 45px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: all 0.3s ease;
}

.mobile-menu-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.mobile-menu-btn:hover {
    background: #1e3a8a;
    transform: scale(1.05);
}

.mobile-menu-btn:active {
    transform: scale(0.95);
}

/* Hamburger animation when menu is open */
.mobile-menu-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.mobile-menu-btn.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* Mobile Overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
}

.mobile-overlay.active {
    opacity: 1;
}

/* Show mobile menu button and overlay on mobile devices */
@media (max-width: 768px) {
    .mobile-menu-btn {
        display: flex;
    }

    .mobile-overlay {
        display: block;
    }

    /* Ensure sidebar is above overlay */
    .sidebar {
        z-index: 1000;
    }
}

/* Tablet size - keep menu button but adjust size */
@media (max-width: 1024px) and (min-width: 769px) {
    .mobile-menu-btn {
        display: flex;
        width: 40px;
        height: 40px;
    }

    .mobile-menu-btn span {
        width: 20px;
    }
}

/* ============================
   PROFIT ANALYSIS SECTION
   ============================ */

.profit-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.profit-card {
    background: white;
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    border-left: 3px solid;
    display: flex;
    gap: 12px;
    align-items: center;
    transition: all 0.2s ease;
}

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

.profit-card.primary {
    border-color: var(--primary-500);
    background: white;
}

.profit-card.success {
    border-color: var(--success-500);
    background: white;
}

.profit-card.info {
    border-color: var(--info-500);
    background: white;
}

.profit-card.warning {
    border-color: var(--warning-500);
    background: white;
}

.profit-content {
    flex: 1;
}

.profit-content h3 {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profit-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.profit-subtitle {
    font-size: 10px;
    color: var(--text-tertiary);
}

/* Analysis Grid */
.analysis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.analysis-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.analysis-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-light);
}

.analysis-header h3 {
    font-size: 18px;
    color: var(--text-primary);
    font-weight: 700;
}

.analysis-badge {
    padding: 4px 12px;
    background: var(--primary-100);
    color: var(--primary-700);
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.items-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--surface);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--primary-500);
    transition: all 0.2s ease;
}

.item-row:hover {
    background: var(--primary-50);
    transform: translateX(4px);
}

.item-row.top {
    border-left-color: var(--success-500);
}

.item-row.low {
    border-left-color: var(--error-500);
}

.item-info {
    flex: 1;
}

.item-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    margin-bottom: 4px;
}

.item-sku {
    font-size: 12px;
    color: var(--text-tertiary);
}

.item-stats {
    text-align: right;
}

.item-value {
    font-weight: 700;
    font-size: 16px;
    color: var(--primary-600);
}

.item-label {
    font-size: 11px;
    color: var(--text-tertiary);
    text-transform: uppercase;
}

/* Analysis Table Section */
.analysis-table-section {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.analysis-table-section h3 {
    font-size: 20px;
    color: var(--text-primary);
    margin-bottom: 20px;
    font-weight: 700;
}

.profit-positive {
    color: var(--success-600);
    font-weight: 600;
}

.profit-negative {
    color: var(--error-600);
    font-weight: 600;
}

.margin-high {
    background: var(--success-50);
    color: var(--success-700);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.margin-medium {
    background: var(--warning-50);
    color: var(--warning-700);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.margin-low {
    background: var(--error-50);
    color: var(--error-700);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.period-select {
    padding: 8px 16px;
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    background: white;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.period-select:hover {
    border-color: var(--primary-500);
}

.period-select:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-100);
}

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}
