/* ================================
   RESET
================================ */

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

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --background: #f5f7fb;
    --surface: #ffffff;
    --border: #e5e7eb;
    --text: #111827;
    --muted: #6b7280;
    --sidebar: #111827;
    --sidebar-hover: #1f2937;
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #dc2626;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    background: var(--background);
    color: var(--text);
}

/* ================================
   APP
================================ */

.app {
    min-height: 100vh;
    display: flex;
}

/* ================================
   SIDEBAR
================================ */

.sidebar {
    width: 250px;
    background: var(--sidebar);
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 1000;
}

.logo {
    height: 90px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.logo-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
}

.logo h2 {
    font-size: 16px;
    margin-bottom: 4px;
}

.logo span {
    font-size: 11px;
    color: #9ca3af;
}

.navigation {
    padding: 25px 14px;
    flex: 1;
}

.nav-title {
    font-size: 10px;
    color: #6b7280;
    font-weight: bold;
    letter-spacing: 1px;
    margin: 18px 10px 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    color: #d1d5db;
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 4px;
    font-size: 14px;
    transition: 0.2s ease;
}

.nav-link:hover {
    background: var(--sidebar-hover);
    color: white;
}

.nav-link.active {
    background: var(--primary);
    color: white;
}

.nav-link span {
    width: 22px;
    text-align: center;
}

.sidebar-footer {
    padding: 20px;
    color: #6b7280;
    font-size: 11px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

/* ================================
   MAIN
================================ */

.main-content {
    margin-left: 250px;
    width: calc(100% - 250px);
    min-height: 100vh;
}

/* ================================
   TOPBAR
================================ */

.topbar {
    height: 70px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 500;
}

.topbar-search {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 14px;
    width: 360px;
}

.topbar-search input {
    border: none;
    outline: none;
    background: transparent;
    width: 100%;
    font-size: 13px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 18px;
}

.icon-button {
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 8px;
    cursor: pointer;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 38px;
    height: 38px;
    background: #dbeafe;
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-info strong {
    font-size: 13px;
}

.user-info span {
    font-size: 11px;
    color: var(--muted);
}

.menu-button {
    display: none;
    border: none;
    background: none;
    font-size: 24px;
    cursor: pointer;
}

/* ================================
   CONTENT
================================ */

.content {
    padding: 30px;
}

.page {
    display: none;
}

.page.active-page {
    display: block;
}

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

.breadcrumb {
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 7px;
}

.page-header h1 {
    font-size: 28px;
    margin-bottom: 6px;
}

.page-description {
    color: var(--muted);
    font-size: 13px;
}

/* ================================
   BUTTONS
================================ */

.primary-button,
.secondary-button {
    border: none;
    border-radius: 8px;
    padding: 11px 17px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s ease;
}

.primary-button {
    background: var(--primary);
    color: white;
}

.primary-button:hover {
    background: var(--primary-dark);
}

.secondary-button {
    background: #f3f4f6;
    color: var(--text);
}

.secondary-button:hover {
    background: #e5e7eb;
}

.text-button {
    border: none;
    background: transparent;
    color: var(--primary);
    font-size: 12px;
    cursor: pointer;
    font-weight: 600;
}

/* ================================
   STATISTICS
================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    margin-bottom: 22px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 21px;
}

.inventory-icon {
    background: #dbeafe;
}

.sales-icon {
    background: #dcfce7;
}

.expense-icon {
    background: #fee2e2;
}

.profit-icon {
    background: #fef3c7;
}

.stat-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-content span {
    font-size: 12px;
    color: var(--muted);
}

.stat-content strong {
    font-size: 21px;
}

.stat-content small {
    color: var(--muted);
    font-size: 10px;
}

/* ================================
   DASHBOARD
================================ */

.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 22px;
}

.dashboard-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
}

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

.card-header h2 {
    font-size: 16px;
    margin-bottom: 4px;
}

.card-header p {
    color: var(--muted);
    font-size: 11px;
}

.card-header select {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 11px;
    background: white;
}

.chart-placeholder {
    height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fafafa;
    border-radius: 10px;
    border: 1px dashed var(--border);
}

.chart-message {
    text-align: center;
    color: var(--muted);
}

.chart-message span {
    font-size: 35px;
}

.chart-message h3 {
    color: var(--text);
    margin: 8px 0 5px;
}

.chart-message p {
    font-size: 12px;
}

.list-container {
    min-height: 220px;
}

.empty-state {
    height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    text-align: center;
}

.empty-state span {
    font-size: 35px;
    margin-bottom: 10px;
}

.empty-state p {
    font-size: 12px;
}

.empty-state.large {
    height: 350px;
}

.empty-state.large h2 {
    color: var(--text);
    margin-bottom: 8px;
}

/* ================================
   TABLE
================================ */

.transactions-card {
    overflow: hidden;
}

.table-wrapper {
    overflow-x: auto;
}

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

th {
    text-align: left;
    background: #f9fafb;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    padding: 13px;
}

td {
    padding: 14px 13px;
    border-top: 1px solid var(--border);
    font-size: 12px;
}

.table-empty {
    text-align: center;
    color: var(--muted);
    padding: 35px;
}

/* ================================
   MODAL
================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 2000;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    width: 100%;
    max-width: 650px;
    background: white;
    border-radius: 14px;
    padding: 25px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 25px;
}

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

.modal-header p {
    color: var(--muted);
    font-size: 12px;
}

.modal-close {
    border: none;
    background: none;
    font-size: 27px;
    color: var(--muted);
    cursor: pointer;
}

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

.form-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
}

.form-group input,
.form-group select {
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    font-size: 13px;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary);
}

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

/* ================================
   RESPONSIVE
================================ */

@media (max-width: 1100px) {

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

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

}

@media (max-width: 800px) {

    .sidebar {
        transform: translateX(-100%);
        transition: 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

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

    .menu-button {
        display: block;
    }

    .topbar {
        padding: 0 15px;
    }

    .topbar-search {
        display: none;
    }

    .content {
        padding: 20px 15px;
    }

    .page-header {
        align-items: flex-start;
        gap: 15px;
    }

    .page-header h1 {
        font-size: 23px;
    }

    .user-info {
        display: none;
    }

}

@media (max-width: 550px) {

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

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

    .page-header {
        flex-direction: column;
    }

    .page-header .primary-button {
        width: 100%;
    }

}
/* ================================
   INVENTORY
================================ */

.inventory-toolbar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.inventory-search {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 9px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 12px;
}

.inventory-search input {
    border: none;
    outline: none;
    width: 100%;
    font-size: 13px;
}

.filter-select {
    border: 1px solid var(--border);
    background: white;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 12px;
    outline: none;
}

.summary-container {
    display: flex;
    flex-direction: column;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid var(--border);
}

.summary-row:last-child {
    border-bottom: none;
}

.summary-row span {
    color: var(--muted);
    font-size: 12px;
}

.summary-row strong {
    font-size: 14px;
}

.product-name-cell {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.product-name-cell strong {
    font-size: 12px;
}

.product-name-cell small {
    color: var(--muted);
    font-size: 10px;
}

.stock-status {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 5px 9px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 600;
}

.stock-normal {
    background: #dcfce7;
    color: #166534;
}

.stock-low {
    background: #fef3c7;
    color: #92400e;
}

.stock-out {
    background: #fee2e2;
    color: #991b1b;
}

.action-buttons {
    display: flex;
    gap: 6px;
}

.action-button {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 7px;
    cursor: pointer;
    font-size: 13px;
}

.action-button:hover {
    background: #f3f4f6;
}

.action-button.delete:hover {
    background: #fee2e2;
}

.low-stock-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

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

.low-stock-product {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.low-stock-product strong {
    font-size: 12px;
}

.low-stock-product span {
    color: var(--muted);
    font-size: 10px;
}

.low-stock-quantity {
    color: var(--danger);
    font-weight: bold;
    font-size: 12px;
}


/* ================================
   RESPONSIVE INVENTORY
================================ */

@media (max-width: 700px) {

    .inventory-toolbar {
        flex-direction: column;
    }

    .filter-select {
        width: 100%;
    }

}
/* ================================
   PURCHASES
================================ */

.purchase-total-box {
    display: flex;
    justify-content: space-between;
    align-items: center;

    margin-top: 20px;
    padding: 15px;

    border-radius: 10px;

    background: #f8fafc;
    border: 1px solid var(--border);
}

.purchase-total-box span {
    font-size: 13px;
    color: var(--muted);
}

.purchase-total-box strong {
    font-size: 18px;
}

.purchase-product {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.purchase-product strong {
    font-size: 12px;
}

.purchase-product small {
    font-size: 10px;
    color: var(--muted);
}
/* ================================
   MODAL DISPLAY
================================ */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    width: 100%;
    max-width: 650px;
    max-height: 90vh;
    overflow-y: auto;
    background: white;
    border-radius: 14px;
    padding: 24px;
}

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

.modal-header h2 {
    margin: 0 0 5px;
}

.modal-header p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
}

.modal-close {
    border: none;
    background: transparent;
    font-size: 28px;
    cursor: pointer;
}

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

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

.form-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
}

.form-group input,
.form-group select {
    padding: 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
}

@media (max-width: 600px) {

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

}


/* =====================================
   REPORTS
===================================== */

.reports-toolbar {
    margin-bottom: 24px;
}

.reports-periods {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
}

.report-filter {
    border: 1px solid var(--border, #e5e7eb);
    background: #fff;
    color: var(--text, #111827);
    border-radius: 8px;
    padding: 9px 14px;
    cursor: pointer;
    font: inherit;
}

.report-filter:hover,
.report-filter.active {
    background: var(--primary, #111827);
    color: #fff;
}

.report-custom-dates {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 12px;
}

.report-custom-dates label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
}

.report-custom-dates input {
    min-height: 40px;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 8px;
    padding: 0 10px;
    font: inherit;
}

.reports-secondary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

.reports-stats-grid {
    margin-bottom: 24px;
}

#reportNetProfit,
#reportGrossProfit {
    font-weight: 700;
}

@media (max-width: 900px) {
    .reports-secondary-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .report-custom-dates {
        align-items: stretch;
        flex-direction: column;
    }

    .report-custom-dates input,
    .report-custom-dates button {
        width: 100%;
    }

    .reports-periods {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ================================
   SETTINGS
================================ */

.settings-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
}

.settings-card-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 24px;
}

.settings-card-header h2 {
    margin: 0 0 5px;
}

.settings-card-header p {
    margin: 0;
    color: var(--muted);
}

.settings-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    font-size: 22px;
    flex-shrink: 0;
}

.settings-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.settings-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 18px 0;
    border-bottom: 1px solid var(--border);
}

.settings-option:last-child {
    border-bottom: none;
}

.settings-option strong {
    display: block;
    margin-bottom: 5px;
}

.settings-option p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.switch {
    position: relative;
    width: 50px;
    height: 28px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    inset: 0;
    cursor: pointer;
    background: #d1d5db;
    border-radius: 30px;
    transition: 0.25s;
}

.slider::before {
    content: "";
    position: absolute;
    width: 22px;
    height: 22px;
    left: 3px;
    top: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.25s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.switch input:checked + .slider {
    background: var(--primary);
}

.switch input:checked + .slider::before {
    transform: translateX(22px);
}

.account-preview {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: #f9fafb;
    border-radius: 12px;
}

.user-avatar.large {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 700;
}

.account-preview p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.settings-note {
    display: block;
    margin-top: 15px;
    color: var(--muted);
}

.danger-button {
    color: var(--danger);
    border-color: #fecaca;
}

.danger-button:hover {
    background: #fef2f2;
}

@media (max-width: 700px) {
    .settings-card {
        padding: 18px;
    }

    .settings-option {
        align-items: flex-start;
    }

    .settings-actions {
        flex-direction: column;
    }

    .settings-actions button {
        width: 100%;
    }
}


/* ================================
   AUTHENTICATION
================================= */

.auth-screen {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, #111827, #1e3a8a);
}

.auth-card {
    width: 100%;
    max-width: 470px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    background: #ffffff;
    border-radius: 20px;
    padding: 32px;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.25);
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 30px;
}

.auth-logo {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 13px;
    background: var(--primary);
    color: #fff;
    font-size: 24px;
    font-weight: 800;
}

.auth-brand h1 {
    font-size: 22px;
    margin: 0;
}

.auth-brand p,
.auth-heading p {
    color: var(--muted);
    margin: 4px 0 0;
}

.auth-heading {
    margin-bottom: 22px;
}

.auth-heading h2 {
    margin: 0;
    font-size: 25px;
}

.auth-form {
    display: grid;
    gap: 16px;
}

.password-field {
    position: relative;
}

.password-field input {
    width: 100%;
    padding-right: 68px;
}

.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: var(--primary);
    font-weight: 700;
    cursor: pointer;
}

.remember-row {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 14px;
    color: var(--muted);
    cursor: pointer;
}

.remember-row input {
    width: auto;
}

.auth-submit {
    width: 100%;
    min-height: 46px;
}

.auth-secondary {
    width: 100%;
}

.auth-message {
    min-height: 20px;
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.auth-message.error {
    color: var(--danger);
}

.auth-message.success {
    color: var(--success);
}

.auth-footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 28px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 12px;
}

body.auth-locked {
    overflow: hidden;
}

@media (max-width: 600px) {
    .auth-screen {
        padding: 12px;
    }

    .auth-card {
        padding: 24px 20px;
        border-radius: 16px;
        max-height: calc(100vh - 24px);
    }

    .auth-footer {
        flex-direction: column;
    }
}


/* =====================================
   PROFESSIONAL FEATURES — STAGE 4
===================================== */

.page-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.table-action-button {
    border: 1px solid var(--border, #e5e7eb);
    background: #fff;
    border-radius: 8px;
    width: 36px;
    height: 34px;
    cursor: pointer;
    transition: 0.2s ease;
}

.table-action-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
}

@media (max-width: 700px) {
    .page-header-actions {
        width: 100%;
    }

    .page-header-actions button {
        flex: 1;
    }
}
