:root {
    --sidebar-width: 240px;
    --sidebar-collapsed: 60px;
    --topbar-height: 50px;
    --primary: #1a1a2e;
    --primary-light: #16213e;
    --accent: #e94560;
    --bg: #f5f6fa;
    --card-bg: #fff;
    --text: #2d3436;
    --text-muted: #636e72;
    --success: #00b894;
    --warning: #fdcb6e;
    --info: #0984e3;
    --danger: #d63031;
}
* { box-sizing: border-box; }
html { font-size: 14px; position: relative; min-height: 100%; }
@media (min-width: 768px) { html { font-size: 15px; } }
body { margin: 0; padding: 0; font-family: 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); }

.sidebar {
    width: var(--sidebar-width); min-height: 100vh; background: var(--primary);
    color: #fff; display: flex; flex-direction: column; position: fixed;
    left: 0; top: 0; bottom: 0; z-index: 1000; transition: width .3s; overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .sidebar-brand,
.sidebar.collapsed .sidebar-link span,
.sidebar.collapsed .sidebar-heading,
.sidebar.collapsed .sidebar-user div { display: none; }
.sidebar.collapsed .sidebar-header { justify-content: center; }
.sidebar-header {
    display: flex; align-items: center; gap: 10px; padding: 18px 16px;
    font-size: 1.2rem; font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,.1); white-space: nowrap;
}
.sidebar-header i { font-size: 1.5rem; color: var(--accent); }
.sidebar-nav { flex: 1; padding: 10px 0; overflow-y: auto; }
.sidebar-link {
    display: flex; align-items: center; gap: 12px; padding: 11px 18px;
    color: rgba(255,255,255,.7); text-decoration: none; font-size: .92rem;
    transition: all .2s; white-space: nowrap; border-left: 3px solid transparent;
}
.sidebar-link:hover { background: rgba(255,255,255,.08); color: #fff; border-left-color: var(--accent); }
.sidebar-link.active { background: rgba(233,69,96,.15); color: #fff; border-left-color: var(--accent); font-weight: 600; }
.sidebar-link i { font-size: 1.1rem; width: 22px; text-align: center; }
.sidebar-divider { border-color: rgba(255,255,255,.1); margin: 8px 16px; }
.sidebar-heading { padding: 8px 18px; font-size: .72rem; text-transform: uppercase; letter-spacing: 1px; color: rgba(255,255,255,.4); }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.sidebar-user i { font-size: 1.6rem; }
.sidebar-user-name { font-size: .85rem; font-weight: 600; }
.sidebar-user-role { font-size: .72rem; color: var(--accent); }
.logout-link { color: rgba(255,255,255,.5) !important; margin-top: 4px; }
.logout-link:hover { color: var(--accent) !important; }

.page-content { margin-left: var(--sidebar-width); flex: 1; min-height: 100vh; transition: margin-left .3s; }
.page-content.expanded { margin-left: var(--sidebar-collapsed); }
.topbar {
    height: var(--topbar-height); background: #fff; display: flex;
    align-items: center; justify-content: space-between; padding: 0 20px;
    border-bottom: 1px solid #eee; position: sticky; top: 0; z-index: 100;
}
.topbar-date { font-size: .85rem; color: var(--text-muted); }
.main-content { padding: 20px; }

.auth-wrapper {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, #0f3460 50%, var(--primary-light) 100%);
}
.auth-card {
    background: #fff; border-radius: 12px; padding: 40px; width: 100%; max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.auth-card h2 { text-align: center; margin-bottom: 6px; font-weight: 700; color: var(--primary); }
.auth-card .subtitle { text-align: center; color: var(--text-muted); margin-bottom: 28px; font-size: .9rem; }
.auth-card .form-label { font-weight: 600; font-size: .85rem; }
.auth-card .form-control { border-radius: 8px; padding: 10px 14px; border: 1.5px solid #dfe6e9; }
.auth-card .form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(233,69,96,.1); }
.auth-card .btn-primary {
    width: 100%; padding: 11px; border-radius: 8px; font-weight: 600;
    background: var(--accent); border: none; font-size: 1rem;
}
.auth-card .btn-primary:hover { background: #c0392b; }
.auth-logo { text-align: center; margin-bottom: 20px; }
.auth-logo i { font-size: 2.5rem; color: var(--accent); }

.stat-card {
    background: var(--card-bg); border-radius: 12px; padding: 20px;
    box-shadow: 0 2px 12px rgba(0,0,0,.06); display: flex; align-items: center; gap: 16px;
    transition: transform .2s, box-shadow .2s; border-left: 4px solid var(--info);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.1); }
.stat-card.red { border-left-color: var(--accent); }
.stat-card.green { border-left-color: var(--success); }
.stat-card.orange { border-left-color: var(--warning); }
.stat-card.purple { border-left-color: #6c5ce7; }
.stat-icon { font-size: 2rem; width: 50px; height: 50px; display: flex; align-items: center; justify-content: center; border-radius: 10px; }
.stat-icon.blue { background: rgba(9,132,227,.1); color: var(--info); }
.stat-icon.red { background: rgba(233,69,96,.1); color: var(--accent); }
.stat-icon.green { background: rgba(0,184,148,.1); color: var(--success); }
.stat-icon.orange { background: rgba(253,203,110,.2); color: #e17055; }
.stat-icon.purple { background: rgba(108,92,231,.1); color: #6c5ce7; }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }

.app-card {
    background: var(--card-bg); border-radius: 12px; padding: 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,.06); margin-bottom: 20px;
}
.app-card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid #eee;
}
.app-card-header h5 { margin: 0; font-weight: 700; font-size: 1rem; }
.app-table { width: 100%; border-collapse: collapse; }
.app-table th {
    background: var(--primary); color: #fff; padding: 10px 14px;
    font-size: .82rem; font-weight: 600; text-align: left; white-space: nowrap;
}
.app-table th:first-child { border-radius: 8px 0 0 0; }
.app-table th:last-child { border-radius: 0 8px 0 0; }
.app-table td { padding: 10px 14px; font-size: .88rem; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
.app-table tr:hover td { background: #f8f9fa; }

.badge-status { padding: 4px 10px; border-radius: 20px; font-size: .75rem; font-weight: 600; display: inline-block; }
.badge-success { background: rgba(0,184,148,.12); color: #00b894; }
.badge-danger { background: rgba(214,48,49,.12); color: #d63031; }
.badge-warning { background: rgba(253,203,110,.3); color: #e17055; }
.badge-info { background: rgba(9,132,227,.12); color: #0984e3; }

.form-section { margin-bottom: 24px; }
.form-section-title { font-weight: 700; font-size: .95rem; margin-bottom: 12px; padding-bottom: 6px; border-bottom: 2px solid var(--accent); }

.btn-accent { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 8px 18px; font-weight: 600; transition: background .2s; }
.btn-accent:hover { background: #c0392b; color: #fff; }
.btn-dark-custom { background: var(--primary); color: #fff; border: none; border-radius: 8px; padding: 8px 18px; font-weight: 600; }
.btn-dark-custom:hover { background: var(--primary-light); color: #fff; }

.low-stock-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px; border-radius: 8px; background: #fff5f5; border: 1px solid #fed7d7; margin-bottom: 8px;
}
.low-stock-item .name { font-weight: 600; font-size: .88rem; }
.low-stock-item .qty { color: var(--danger); font-weight: 700; }

.receipt-container {
    max-width: 380px; margin: 0 auto; font-family: 'Courier New', monospace;
    background: #fff; padding: 20px; border: 1px dashed #ccc;
}
.receipt-header { text-align: center; margin-bottom: 14px; border-bottom: 1px dashed #999; padding-bottom: 10px; }
.receipt-header h4 { margin: 0; font-size: 1.1rem; }
.receipt-header p { margin: 2px 0; font-size: .78rem; color: #666; }
.receipt-line { display: flex; justify-content: space-between; padding: 3px 0; font-size: .82rem; }
.receipt-total { border-top: 1px dashed #999; margin-top: 8px; padding-top: 8px; font-weight: 700; font-size: .95rem; }
.receipt-footer { text-align: center; margin-top: 12px; font-size: .75rem; color: #888; border-top: 1px dashed #999; padding-top: 10px; }

.sale-layout { display: grid; grid-template-columns: 1fr 380px; gap: 20px; }
@media (max-width: 992px) { .sale-layout { grid-template-columns: 1fr; } }
.cart-summary {
    background: var(--card-bg); border-radius: 12px; padding: 20px;
    box-shadow: 0 2px 12px rgba(0,0,0,.06); position: sticky; top: 70px;
}

.product-search-wrapper { position: relative; }
.product-search-results {
    position: absolute; top: 100%; left: 0; right: 0; background: #fff;
    border: 1px solid #ddd; border-radius: 0 0 8px 8px; max-height: 300px;
    overflow-y: auto; z-index: 50; box-shadow: 0 8px 24px rgba(0,0,0,.12); display: none;
}
.product-search-item {
    padding: 10px 14px; cursor: pointer; border-bottom: 1px solid #f0f0f0;
    display: flex; justify-content: space-between; align-items: center;
}
.product-search-item:hover { background: #f0f7ff; }
.product-search-item .pname { font-weight: 600; font-size: .88rem; }
.product-search-item .pinfo { font-size: .78rem; color: var(--text-muted); }
.product-search-item .pprice { font-weight: 700; color: var(--accent); }

.chart-container { width: 100%; height: 200px; display: flex; align-items: flex-end; gap: 6px; padding: 10px 0; }
.chart-bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; }
.chart-bar {
    width: 100%; background: linear-gradient(180deg, var(--accent), #ff6b6b); border-radius: 4px 4px 0 0;
    min-height: 4px; transition: height .5s;
}
.chart-bar:hover { opacity: .85; }
.chart-label { font-size: .7rem; color: var(--text-muted); margin-top: 4px; }

.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 768px) { .grid-2 { grid-template-columns: 1fr; } }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state i { font-size: 2.5rem; display: block; margin-bottom: 10px; }

.modal-content { border-radius: 12px; border: none; }
.modal-header { background: var(--primary); color: #fff; border-radius: 12px 12px 0 0; }
.modal-header .btn-close { filter: invert(1); }

@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .page-content { margin-left: 0 !important; }
    .main-content { padding: 0 !important; }
    .receipt-container { border: none; max-width: 100%; }
}
