* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: #f3f7f1;
    color: #243323;
    overflow-x: hidden;
}
a { text-decoration: none; }
.layout { display: flex; min-height: 100vh; }
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(12, 29, 18, .45);
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
    z-index: 40;
}
.sidebar {
    width: 260px;
    background: #194d2b;
    color: #fff;
    padding: 18px 14px;
    position: fixed;
    left: 0; top: 0; bottom: 0;
    overflow-y: auto;
    z-index: 50;
}
.sidebar-mobile-head {
    display: none;
    justify-content: flex-end;
    margin-bottom: 8px;
}
.sidebar-close,
.menu-toggle,
.sidebar-link {
    border: none;
    border-radius: 10px;
    cursor: pointer;
}
.sidebar-close {
    width: 38px;
    height: 38px;
    background: rgba(255,255,255,.14);
    color: #fff;
    font-size: 18px;
}
.brand {
    display: flex; gap: 12px; align-items: center;
    padding-bottom: 18px; border-bottom: 1px solid rgba(255,255,255,.18);
    margin-bottom: 16px;
}
.brand-logo {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    object-fit: cover;
    background: #e7f7e1;
    padding: 4px;
}
.brand-icon {
    width: 44px; height: 44px; border-radius: 14px;
    background: #e7f7e1; color: #194d2b;
    display: grid; place-items: center; font-size: 24px;
}
.brand small { display:block; opacity:.8; margin-top:4px; }
.sidebar nav { display:flex; flex-direction:column; gap:7px; }
.sidebar nav a,
.sidebar-link {
    color:#fff; padding:10px 11px; border-radius:10px;
    background:rgba(255,255,255,.06); font-size:14px;
    display:block; width:100%; text-align:left;
}
.sidebar nav a:hover,
.sidebar-link:hover { background:rgba(255,255,255,.15); }
.sidebar nav a.danger,
.sidebar-link.danger { background:rgba(255, 70, 70, .22); }
.sidebar-logout-form { margin: 0; }

.content {
    margin-left:260px;
    padding:22px;
    width:calc(100% - 260px);
    min-width: 0;
}
.topbar {
    background:#fff;
    border-radius:16px;
    padding:18px 20px;
    display:flex; align-items:center; justify-content:space-between; gap:16px;
    box-shadow:0 8px 24px rgba(25,77,43,.08);
    margin-bottom:18px;
}
.topbar h1 { margin:0; font-size:24px; }
.topbar p { margin:6px 0 0; color:#687562; }
.topbar > div:first-child { min-width: 0; }
.menu-toggle {
    display: none;
    margin-bottom: 12px;
    padding: 9px 12px;
    background: #194d2b;
    color: #fff;
    font-size: 14px;
}
.userbox {
    background:#edf8e9;
    padding:10px 14px; border-radius:12px; text-align:right; font-weight:bold;
    flex-shrink: 0;
}
.userbox small { display:block; color:#60705a; font-weight:normal; margin-top:4px; }

.card, .stat {
    background:#fff;
    border-radius:16px;
    padding:18px;
    box-shadow:0 8px 24px rgba(25,77,43,.08);
    margin-bottom:18px;
}
.grid { display:grid; grid-template-columns:repeat(4, 1fr); gap:16px; }
.grid-3 { display:grid; grid-template-columns:repeat(3, 1fr); gap:16px; }
.two-col { display:grid; grid-template-columns:1fr 1fr; gap:18px; }
.stat { border-left:5px solid #348a3d; }
.stat span { color:#667363; font-size:14px; }
.stat h2 { margin:8px 0 0; font-size:25px; }

.table {
    width:100%;
    border-collapse:collapse;
    display:block;
    overflow-x:auto;
    white-space:nowrap;
}
.table th, .table td {
    padding:10px; border-bottom:1px solid #e6eee3; text-align:left; vertical-align:top;
}
.table th { background:#edf8e9; font-size:14px; }
.table small { color:#63705f; }

.form-group { margin-bottom:13px; }
label { display:block; font-weight:bold; margin-bottom:6px; }
input, select, textarea {
    width:100%;
    padding:10px 11px;
    border:1px solid #d0dacb;
    border-radius:10px;
    font-size:14px;
}
textarea { min-height:82px; }

.btn {
    display:inline-block; border:none; padding:9px 13px; border-radius:10px;
    cursor:pointer; background:#2f7d36; color:#fff; font-size:14px;
}
.btn:hover { opacity:.9; }
.btn-secondary { background:#65765e; }
.btn-danger { background:#c0392b; }
.btn-warning { background:#d68910; }
.btn-info { background:#2878a6; }
.actions { display:flex; gap:7px; flex-wrap:wrap; align-items:center; }
.alert { padding:12px 14px; border-radius:12px; margin-bottom:16px; }
.alert-success { background:#e3f6df; color:#1f6428; }
.alert-danger { background:#fde8e5; color:#9e2d22; }
.alert-warning { background:#fff2ce; color:#8b5a00; }
.badge {
    display:inline-block; padding:5px 8px; border-radius:999px;
    background:#edf8e9; color:#2f7d36; font-size:12px; font-weight:bold;
}
.badge-red { background:#fde8e5; color:#c0392b; }
.badge-yellow { background:#fff2ce; color:#8b5a00; }
.low-stock { color:#c0392b; font-weight:bold; }
.text-right { text-align:right; }
.login-page {
    min-height:100vh; display:grid; place-items:center;
    background:linear-gradient(135deg,#194d2b,#77a94a);
}
.login-card {
    width:390px; background:#fff; border-radius:18px; padding:26px;
    box-shadow:0 18px 45px rgba(0,0,0,.18);
}
.login-card h1 { margin-top:0; }
.search-row { display:flex; gap:8px; flex-wrap:wrap; align-items:end; }
.search-row > * { flex:1; min-width:160px; }
.print-only { display:none; }
.preview-box {
    border:1px solid #d8e5d3;
    border-radius:14px;
    padding:16px;
    background:#f8fcf6;
}
.preview-brand {
    display:flex;
    gap:12px;
    align-items:center;
    margin-bottom:12px;
}
.store-logo-preview {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    object-fit: cover;
    background: #e7f7e1;
    padding: 4px;
}
.checkbox-row {
    display:flex;
    align-items:center;
    gap:8px;
    margin-bottom:14px;
    font-weight:bold;
}
.checkbox-row input {
    width:auto;
    margin:0;
}
.preview-box hr {
    border:none;
    border-top:1px dashed #c7d6c2;
    margin:14px 0;
}

@media (max-width: 1200px) {
    .sidebar { width:220px; }
    .content {
        margin-left:220px;
        width:calc(100% - 220px);
    }
    .grid { grid-template-columns:repeat(2, 1fr); }
    .grid-3 { grid-template-columns:repeat(2, 1fr); }
}

@media print {
    .sidebar, .topbar, .no-print { display:none !important; }
    .content { margin:0; width:100%; padding:0; }
    .card, .stat { box-shadow:none; border:1px solid #ddd; }
    .print-only { display:block; }
}
@media (max-width: 980px) {
    .menu-toggle { display: inline-block; }
    .sidebar-mobile-head { display: flex; }
    .sidebar {
        width: 280px;
        max-width: calc(100vw - 32px);
        transform: translateX(-100%);
        transition: transform .22s ease;
    }
    .content { margin-left:0; width:100%; }
    .grid, .grid-3, .two-col { grid-template-columns:1fr; }
    .topbar { flex-direction:column; align-items:flex-start; }
    .userbox { width:100%; text-align:left; }
    body.sidebar-open { overflow: hidden; }
    body.sidebar-open .sidebar {
        transform: translateX(0);
        box-shadow: 0 18px 40px rgba(0,0,0,.2);
    }
    body.sidebar-open .sidebar-overlay {
        opacity: 1;
        visibility: visible;
    }
}

@media (max-width: 640px) {
    .content { padding:16px; }
    .sidebar { padding:14px 12px; }
    .sidebar nav a,
    .sidebar-link {
        font-size:13px;
        padding:9px 10px;
    }
    .topbar {
        padding:16px;
        border-radius:14px;
    }
    .topbar h1 { font-size:20px; }
    .card, .stat { padding:16px; }
    .search-row > * { min-width:100%; }
    .login-card {
        width:calc(100% - 24px);
        padding:22px;
    }
}
