:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --sidebar-width: 260px;
    --navbar-height: 60px;
    --bg-light: #f8fafc;
    --text-dark: #1e293b;
    --border-color: #e2e8f0;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-light);
    color: var(--text-dark);
    overflow-x: hidden;
}

.wrapper { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #1e1b4b 0%, #312e81 100%);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header .logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.1rem;
    font-weight: 700;
}

.sidebar-header .logo i { font-size: 1.5rem; color: #a5b4fc; }

.sidebar-nav { list-style: none; padding: 0.75rem 0; }

.nav-section {
    padding: 0.75rem 1.25rem 0.25rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255,255,255,0.4);
    font-weight: 600;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.25rem;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

.sidebar-nav .nav-link.active {
    border-right: 3px solid #a5b4fc;
}

.sidebar-nav .nav-link i { font-size: 1.1rem; width: 20px; text-align: center; }

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.top-navbar {
    height: var(--navbar-height);
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 999;
}

.sidebar-toggle { color: var(--text-dark); text-decoration: none; }

.content-area { flex: 1; }

.footer {
    background: #fff;
    border-top: 1px solid var(--border-color);
    color: #94a3b8;
}

/* Cards */
.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-card .stat-value { font-size: 1.5rem; font-weight: 700; }
.stat-card .stat-label { font-size: 0.8rem; color: #64748b; }

.bg-primary-soft { background: rgba(79,70,229,0.1); color: var(--primary); }
.bg-success-soft { background: rgba(34,197,94,0.1); color: #16a34a; }
.bg-warning-soft { background: rgba(234,179,8,0.1); color: #ca8a04; }
.bg-danger-soft { background: rgba(239,68,68,0.1); color: #dc2626; }
.bg-info-soft { background: rgba(14,165,233,0.1); color: #0284c7; }

/* Chart Cards */
.chart-card {
    background: #fff;
    border-radius: 12px;
    padding: 1.25rem;
    border: 1px solid var(--border-color);
}

.chart-card .chart-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* Tables */
.card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: none;
}

.card-header {
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    border-radius: 12px 12px 0 0 !important;
}

.table th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: #64748b; font-weight: 600; }

/* Buttons */
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e1b4b 0%, #4f46e5 50%, #7c3aed 100%);
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-card .login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-card .login-logo i { font-size: 3rem; color: var(--primary); }
.login-card .login-logo h3 { margin-top: 0.5rem; font-weight: 700; }

/* POS */
.pos-container { display: grid; grid-template-columns: 1fr 400px; gap: 1rem; height: calc(100vh - 140px); }
.pos-products { overflow-y: auto; }
.pos-cart { background: #fff; border-radius: 12px; border: 1px solid var(--border-color); display: flex; flex-direction: column; }
.pos-cart-header { padding: 1rem; border-bottom: 1px solid var(--border-color); font-weight: 600; }
.pos-cart-body { flex: 1; overflow-y: auto; padding: 0.5rem; }
.pos-cart-footer { padding: 1rem; border-top: 1px solid var(--border-color); }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.75rem; }
.product-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}
.product-card:hover { border-color: var(--primary); box-shadow: 0 2px 8px rgba(79,70,229,0.15); }
.product-card .product-name { font-size: 0.85rem; font-weight: 600; margin: 0.5rem 0 0.25rem; }
.product-card .product-price { color: var(--primary); font-weight: 700; font-size: 0.9rem; }
.product-card .product-stock { font-size: 0.75rem; color: #94a3b8; }

.cart-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem; border-bottom: 1px solid #f1f5f9; }
.cart-item .item-name { flex: 1; font-size: 0.85rem; }
.cart-item .item-qty input { width: 50px; text-align: center; }

/* Print */
@media print {
    .sidebar, .top-navbar, .no-print { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .content-area { padding: 0 !important; }
}

/* Notification dropdown */
.notification-dropdown { width: 320px; max-height: 400px; overflow-y: auto; }

/* Responsive */
@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .pos-container { grid-template-columns: 1fr; height: auto; }
}

/* Form */
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(79,70,229,0.15);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.badge-status { font-size: 0.75rem; padding: 0.35em 0.65em; }

.product-img-thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
}

.receipt { max-width: 300px; margin: 0 auto; font-family: monospace; font-size: 12px; }
.receipt .receipt-header { text-align: center; margin-bottom: 1rem; }
.receipt .receipt-divider { border-top: 1px dashed #000; margin: 0.5rem 0; }

/* PWA standalone mode */
@media all and (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    .top-navbar {
        padding-top: calc(0.5rem + env(safe-area-inset-top));
    }
}

#pwaInstallBtn {
    white-space: nowrap;
}

#pwaOfflineBar {
    padding-top: calc(0.5rem + env(safe-area-inset-top, 0px)) !important;
}

.report-card { transition: transform 0.15s, box-shadow 0.15s; }
.report-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
