:root {
    --bg-color: #ffffff;
    --text-color: #000000;
    --code-color: #0056b3;
    --profit-color: #28a745;
    --border-color: #e0e0e0;
    --sidebar-bg: #f8f9fa;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html, body {
    width: 100%;
    min-height: 100vh;
    background-color: var(--bg-color);
    color: var(--text-color);
}

body {
    display: flex;
    flex-direction: column;
}

.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: #ffffff;
    border: 2px solid var(--text-color);
    padding: 35px 25px;
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
}

.login-card h2 {
    margin-bottom: 24px;
    font-size: 26px;
    text-align: center;
    color: var(--text-color);
}

.form-group {
    margin-bottom: 18px;
    width: 100%;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--text-color);
    font-size: 14px;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--text-color);
    border-radius: 6px;
    font-size: 16px;
    outline: none;
    background: #fff;
}

.btn {
    width: 100%;
    padding: 12px;
    background-color: var(--text-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn:hover {
    opacity: 0.85;
}

.error-msg {
    color: #dc3545;
    font-size: 14px;
    text-align: center;
    margin-top: 10px;
    display: none;
}

#app-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100vh;
}

header {
    background-color: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 15px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    width: 100%;
}

header h1 {
    font-size: 20px;
    color: var(--text-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 14px;
}

.logout-btn {
    background: none;
    border: 1px solid var(--text-color);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
}

.logout-btn:hover {
    background-color: var(--text-color);
    color: white;
}

.main-layout {
    display: flex;
    flex: 1;
    width: 100%;
    flex-direction: row;
}

sidebar {
    width: 260px;
    min-width: 260px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    padding: 20px 0;
}

.nav-item {
    padding: 14px 24px;
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-color);
    transition: background 0.2s;
    font-size: 15px;
}

.nav-item:hover, .nav-item.active {
    background-color: #e9ecef;
    border-left: 4px solid var(--text-color);
}

content-area {
    flex: 1;
    padding: 25px;
    overflow-y: auto;
    background-color: var(--bg-color);
    width: 100%;
    min-width: 0;
}

.view-section {
    display: none;
}

.view-section.active {
    display: block;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.card {
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: 8px;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.card h3 {
    font-size: 14px;
    color: #666;
    margin-bottom: 8px;
}

.card .value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-color);
}

.card .value.profit {
    color: var(--profit-color);
}

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

.section-header h2 {
    font-size: 22px;
    color: var(--text-color);
}

.action-btn {
    background-color: var(--text-color);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 20px;
}

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

th, td {
    padding: 14px 18px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    white-space: nowrap;
}

th {
    background-color: var(--sidebar-bg);
    font-weight: 600;
    color: var(--text-color);
}

.product-code {
    color: var(--code-color);
    font-weight: 600;
}

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

.low-stock-row {
    background-color: #fff8f8 !important;
}

.badge-low-stock {
    background-color: #dc3545;
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    margin-left: 6px;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    display: none;
    padding: 20px;
}

.modal-content {
    background: white;
    padding: 25px;
    border-radius: 10px;
    width: 100%;
    max-width: 500px;
    border: 1px solid var(--text-color);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h3 {
    margin-bottom: 18px;
    font-size: 20px;
}

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

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

.btn-secondary {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    width: auto;
}

.modal-buttons .btn {
    width: auto;
    padding: 10px 18px;
    font-size: 14px;
}

.badge-outlet {
    background-color: #ffc107;
    color: #000;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
}

/* --- RESPONSIVE BREAKPOINT FOR TABLETS & PHONES (<= 1024px) --- */
@media screen and (max-width: 1024px) {
    .main-layout {
        flex-direction: column !important;
    }
    sidebar {
        width: 100% !important;
        min-width: 100% !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border-color) !important;
        padding: 8px 0 !important;
        display: flex !important;
        flex-direction: row !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
        background-color: var(--sidebar-bg) !important;
    }
    .nav-item {
        padding: 12px 20px !important;
        border-left: none !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        flex: 1 !important;
        min-width: max-content !important;
    }
    .nav-item:hover, .nav-item.active {
        border-left: none !important;
        border-bottom: 3px solid var(--text-color) !important;
        background-color: #e9ecef !important;
    }
    content-area {
        padding: 20px !important;
        width: 100% !important;
    }
    header {
        padding: 15px 20px !important;
    }
    .form-row {
        grid-template-columns: 1fr !important;
    }
    .card-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)) !important;
    }
}

@media screen and (max-width: 600px) {
    header h1 {
        font-size: 16px !important;
    }
    .user-info span {
        display: none !important;
    }
    .card-grid {
        grid-template-columns: 1fr !important;
    }
}
