:root {
    --sidebar-bg: #1e293b;
    --sidebar-text: #e2e8f0;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --success: #16a34a;
    --error: #dc2626;
    --warning: #d97706;
    --low-stock: #fef3c7;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar-toggle {
    display: none;
}

.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 1.25rem 1rem;
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-nav {
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.25rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.95rem;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    text-decoration: none;
}

.nav-link.active {
    background: rgba(37, 99, 235, 0.35);
    border-left: 3px solid var(--accent);
    padding-left: calc(1.25rem - 3px);
}

.nav-logout {
    margin-top: auto;
    color: #fca5a5;
}

.main-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.menu-btn {
    display: none;
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0.25rem 0.5rem;
}

.page-heading {
    margin: 0;
    font-size: 1.25rem;
    flex: 1;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--muted);
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.badge-role {
    background: #dbeafe;
    color: #1e40af;
}

.content {
    padding: 1.5rem;
    flex: 1;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--card);
    border-radius: 8px;
    padding: 1.25rem;
    border: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.stat-card .label {
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 0.35rem;
}

.stat-card .value {
    font-size: 1.75rem;
    font-weight: 700;
}

.panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.panel h3 {
    margin: 0 0 1rem;
    font-size: 1.1rem;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1rem;
}

.search-form {
    display: flex;
    gap: 0.5rem;
    flex: 1;
    min-width: 200px;
}

.search-form input[type="search"],
.search-form input[type="text"] {
    flex: 1;
    max-width: 320px;
}

.table-wrap {
    overflow-x: auto;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

table.data-table th,
table.data-table td {
    padding: 0.65rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

table.data-table th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

table.data-table tbody tr:hover {
    background: #f8fafc;
}

tr.row-low-stock {
    background: var(--low-stock) !important;
}

.form {
    max-width: 480px;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
    color: #fff;
}

.btn-secondary {
    background: #e2e8f0;
    color: var(--text);
}

.btn-danger {
    background: var(--error);
    color: #fff;
}

.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.8rem;
}

.btn-block {
    width: 100%;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
}

.text-muted {
    color: var(--muted);
    font-size: 0.9rem;
}

.text-right {
    text-align: right;
}

.actions-cell {
    white-space: nowrap;
}

.actions-cell .btn {
    margin-right: 0.35rem;
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}

.login-card {
    background: var(--card);
    padding: 2rem;
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.login-card h1 {
    margin: 0 0 0.25rem;
    text-align: center;
}

.login-subtitle {
    text-align: center;
    color: var(--muted);
    margin: 0 0 1.5rem;
}

.login-hint {
    margin-top: 1.25rem;
    font-size: 0.8rem;
    color: var(--muted);
    text-align: center;
}

.billing-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 900px) {
    .billing-layout {
        grid-template-columns: 1fr;
    }
}

.cart-totals {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.cart-totals .row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.cart-totals .row.total {
    font-size: 1.25rem;
    font-weight: 700;
    margin-top: 0.5rem;
}

.discount-row input {
    width: 100px;
    text-align: right;
}

.product-pick-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.product-pick-list li {
    border-bottom: 1px solid var(--border);
}

.product-pick-list li:last-child {
    border-bottom: none;
}

.product-pick-list button {
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.75rem;
    background: #fff;
    border: none;
    cursor: pointer;
}

.product-pick-list button:hover {
    background: #f1f5f9;
}

.receipt {
    max-width: 400px;
    margin: 0 auto;
    background: #fff;
    padding: 1.5rem;
    border: 1px dashed var(--border);
}

.receipt h1 {
    text-align: center;
    font-size: 1.25rem;
    margin: 0 0 0.5rem;
}

.receipt-meta {
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 1rem;
}

.no-print {
    margin-bottom: 1rem;
}

@media print {
    body * {
        visibility: hidden;
    }
    .receipt, .receipt * {
        visibility: visible;
    }
    .receipt {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        border: none;
    }
    .no-print {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .menu-btn {
        display: block;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }

    .sidebar-toggle:checked ~ .sidebar {
        transform: translateX(0);
    }

    .main-wrap {
        width: 100%;
    }
}
