:root {
    --brand: #667eea;
    --brand-dark: #5568d3;
    --bg: #f4f6fb;
    --ink: #2d3748;
    --muted: #718096;
    --line: #e2e8f0;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #f6ad55;
    --info: #3182ce;
}

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

body {
    font-family: 'Segoe UI', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.5;
}

a { color: var(--brand); text-decoration: none; }

/* Layout */
.navbar {
    background: #fff;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 60px;
    position: sticky;
    top: 0;
    z-index: 50;
}
.navbar-brand { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 10px; min-width: 0; }
.navbar-brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.navbar-brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.navbar-brand small { font-size: 11px; color: var(--muted); font-weight: 400; }
.navbar-logo { height: 36px; width: 36px; object-fit: contain; border-radius: 6px; background: #fff; padding: 2px; border: 1px solid var(--line); flex-shrink: 0; }
.navbar-logo-emoji { font-size: 22px; flex-shrink: 0; }
.navbar-toggle { display: none; background: none; border: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--ink); padding: 4px 8px; }
.navbar-menu { list-style: none; display: flex; gap: 4px; align-items: center; }
.navbar-menu a {
    padding: 8px 14px; border-radius: 6px; color: var(--ink); font-size: 14px;
}
.navbar-menu a:hover { background: var(--bg); }
.navbar-menu a.active { background: var(--brand); color: #fff; }
.navbar-user { font-size: 13px; color: var(--muted); display: flex; gap: 10px; align-items: center; }

.container { max-width: 1200px; margin: 0 auto; padding: 24px; }

.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-size: 24px; }

/* Cards / stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 18px;
    display: flex; gap: 14px; align-items: center;
}
.stat-card .icon { font-size: 28px; }
.stat-card h3 { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat-card .value { font-size: 22px; font-weight: 700; }
.stat-card.success { border-left: 4px solid var(--success); }
.stat-card.warning { border-left: 4px solid var(--warning); }

.card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 20px; }
.card h2 { font-size: 16px; margin-bottom: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.table tbody tr:hover { background: #fafbff; }
.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Badges */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-success { background: #e6f6ec; color: #1c7c3e; }
.badge-danger  { background: #fdeaea; color: #b42318; }
.badge-warning { background: #fef3e2; color: #b25e09; }
.badge-muted   { background: #edf2f7; color: #4a5568; }

/* Buttons */
.btn { display: inline-block; padding: 9px 16px; border: none; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 500; color: #fff; background: var(--brand); }
.btn:hover { background: var(--brand-dark); }
.btn-success { background: var(--success); }
.btn-danger  { background: var(--danger); }
.btn-info    { background: var(--info); }
.btn-warning { background: var(--warning); color: #1a202c; }
.btn-secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 5px; font-size: 13px; font-weight: 500; }
.form-group input, .form-group select {
    width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; border-left: 4px solid; }
.alert-success { background: #e6f6ec; border-color: var(--success); color: #1c7c3e; }
.alert-danger  { background: #fdeaea; border-color: var(--danger); color: #b42318; }

/* Modal */
.modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 100; }
.modal.show { display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal-content { background: #fff; border-radius: 10px; padding: 24px; width: 100%; max-width: 520px; position: relative; }
.modal-content h2 { margin-bottom: 16px; }
.modal .close { position: absolute; top: 14px; right: 18px; font-size: 24px; cursor: pointer; color: var(--muted); }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #667eea, #764ba2); padding: 20px; }
.login-box { background: #fff; border-radius: 12px; padding: 36px; width: 100%; max-width: 380px; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.login-box h2 { text-align: center; margin-bottom: 4px; }
.login-box h3 { text-align: center; color: var(--muted); font-weight: 400; font-size: 15px; margin-bottom: 20px; }
.login-box .btn { width: 100%; }
.login-hint { margin-top: 16px; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.7; }

/* POS */
.pos-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; }
@media (max-width: 900px) { .pos-grid { grid-template-columns: 1fr; } }
.product-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 10px; max-height: 520px; overflow-y: auto; }
.product-item { border: 1px solid var(--line); border-radius: 8px; padding: 12px; cursor: pointer; transition: .15s; }
.product-item:hover { border-color: var(--brand); box-shadow: 0 2px 8px rgba(102,126,234,.2); }
.product-item .name { font-weight: 600; font-size: 14px; }
.product-item .price { color: var(--brand); font-weight: 600; margin-top: 4px; }
.product-item .stock { font-size: 12px; color: var(--muted); }
.summary-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; }
.summary-row.total { font-size: 18px; font-weight: 700; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 12px; }
.text-center { text-align: center; }
.text-muted { color: var(--muted); }
.mt { margin-top: 16px; }

/* Product image thumbnails */
.product-thumb { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; border: 1px solid var(--line); display: inline-block; vertical-align: middle; }
.product-thumb-empty { display: inline-flex; align-items: center; justify-content: center; color: var(--muted); background: #f5f5f5; }
.product-thumb-lg { width: 90px; height: 90px; }

/* Low / out-of-stock rows highlighted red in the inventory listing */
.table tbody tr.low-stock-row { background: #fdeaea; }
.table tbody tr.low-stock-row:hover { background: #fbdcdc; }
.qty-low { color: var(--danger); font-weight: 700; }

/* ============================================================
   Responsive / mobile
   ============================================================ */
@media (max-width: 768px) {
    /* Collapsible navbar with a hamburger toggle */
    .navbar { flex-wrap: wrap; height: auto; min-height: 56px; padding: 8px 16px; }
    .navbar-toggle { display: block; }
    .navbar-brand-name { max-width: 60vw; }

    .navbar-menu, .navbar-user { display: none; flex-basis: 100%; width: 100%; }
    .navbar.open .navbar-menu {
        display: flex; flex-direction: column; align-items: stretch;
        gap: 2px; padding: 8px 0 4px; border-top: 1px solid var(--line); margin-top: 6px;
    }
    .navbar.open .navbar-menu a { display: block; padding: 12px 12px; border-radius: 8px; }
    .navbar.open .navbar-user {
        display: flex; justify-content: space-between; align-items: center;
        padding: 10px 0 4px; border-top: 1px solid var(--line);
    }

    /* Tighter page chrome */
    .container { padding: 16px 12px; }
    .page-header h1 { font-size: 20px; }

    /* Forms stack to a single column */
    .form-row { grid-template-columns: 1fr; }

    /* POS becomes one column; cap the product grid height so the cart is reachable */
    .pos-grid { grid-template-columns: 1fr; }
    .product-list { max-height: 320px; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }

    /* Modals use the full width with comfortable padding */
    .modal.show { padding: 16px 10px; }
    .modal-content { padding: 18px; }

    /* Keep wide listing tables usable via horizontal scroll without crushing columns.
       Scoped to .table-wrap so fluid tables (POS cart, modal) still fit the screen. */
    .table-wrap .table { min-width: 560px; }
    .table th, .table td { padding: 9px 10px; }
}

@media (max-width: 420px) {
    .stat-card .value { font-size: 19px; }
    .btn { padding: 9px 13px; }
}
