:root {
    --primary: #6b3f1d;
    --primary-light: #9c6b3e;
    --accent: #ff9f1c;
    --accent-hover: #f08700;
    --bg-cream: #fff8ec;
    --bg-soft-peach: #ffe7c2;
    --card-bg: #ffffff;
    --text-main: #3a2a18;
    --text-muted: #8a7561;
    --border-subtle: #f2e1c4;
    --gold-accent: #ffc93c;
    --leaf-green: #3fa34d;
    --danger: #d64545;
    --radius-lg: 20px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow-soft: 0 10px 30px rgba(107, 63, 29, 0.08);
    --shadow-hover: 0 15px 35px rgba(107, 63, 29, 0.16);
    --sidebar-w: 240px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Nunito', sans-serif;
}

h1, h2, h3, h4, .brand-word, button, .btn, .nav-link, .stat-label, th, .badge, .logo-text {
    font-family: 'Poppins', sans-serif;
}

body {
    background-color: var(--bg-cream);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

button { cursor: pointer; border: none; background: none; font-size: 1rem; }

/* ---------- Login Screen ---------- */
.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: radial-gradient(circle at top left, var(--bg-soft-peach), var(--bg-cream) 55%);
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    padding: 40px 32px;
    border: 1px solid var(--border-subtle);
}

.login-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    margin-bottom: 8px;
}

.login-logo i { color: var(--accent); font-size: 1.6rem; }

.logo-text {
    font-weight: 800;
    font-size: 1.3rem;
    color: var(--primary);
    letter-spacing: 0.3px;
}

.login-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 28px;
}

.field {
    margin-bottom: 18px;
}

.field label {
    display: block;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 6px;
    font-family: 'Poppins', sans-serif;
}

.field input {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-subtle);
    font-size: 0.95rem;
    color: var(--text-main);
    background: var(--bg-cream);
    outline: none;
    transition: border-color 0.15s ease;
}

.field input:focus {
    border-color: var(--accent);
}

.btn-primary {
    width: 100%;
    padding: 13px;
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.95rem;
    transition: background 0.15s ease;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.login-error {
    background: #fdecea;
    color: var(--danger);
    border: 1px solid #f5c6c2;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 16px;
    display: none;
}

.login-error.show { display: block; }

/* ---------- App Shell ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--primary);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    flex-shrink: 0;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transition: transform 0.2s ease;
    z-index: 40;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 8px 24px;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.14);
}

.sidebar-logo i { color: var(--gold-accent); font-size: 1.3rem; }
.sidebar-logo .logo-text { color: #fff; font-size: 1.05rem; }
.sidebar-role-tag {
    font-size: 0.68rem;
    background: rgba(255,255,255,0.15);
    padding: 2px 8px;
    border-radius: 20px;
    margin-left: auto;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.78);
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-link i { width: 18px; text-align: center; }
.nav-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-link.active { background: var(--accent); color: #fff; }

.sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.14);
}

.sidebar-user {
    font-size: 0.82rem;
    color: rgba(255,255,255,0.7);
    padding: 0 12px 10px;
    word-break: break-word;
}

.logout-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: rgba(255,255,255,0.85);
    font-weight: 600;
    font-size: 0.88rem;
    border-radius: var(--radius-sm);
}

.logout-btn:hover { background: rgba(255,255,255,0.08); }

.main-area {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 28px 32px 60px;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
}

.topbar h1 {
    font-size: 1.4rem;
    color: var(--primary);
}

.topbar-sub { color: var(--text-muted); font-size: 0.88rem; margin-top: 2px; }

.hamburger {
    display: none;
    background: var(--primary);
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

/* ---------- Cards / Stats ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 20px;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-soft);
}

.stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--primary);
}

.stat-value.accent { color: var(--accent-hover); }
.stat-value.green { color: var(--leaf-green); }

.panel {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-soft);
    padding: 24px;
    margin-bottom: 24px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    flex-wrap: wrap;
    gap: 10px;
}

.panel-head h2 {
    font-size: 1.05rem;
    color: var(--primary);
}

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

th, td {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

th {
    color: var(--text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-weight: 700;
}

tbody tr:hover { background: var(--bg-cream); }

.badge {
    display: inline-block;
    padding: 4px 11px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
}

.badge-pending { background: #ffe7c2; color: #a86a00; }
.badge-confirmed { background: #ffe3b0; color: var(--accent-hover); }
.badge-dispatched { background: #e5d4c1; color: var(--primary); }
.badge-delivered { background: #dff2e1; color: var(--leaf-green); }
.badge-rejected { background: #fdecea; color: var(--danger); }

.status-select {
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-subtle);
    font-size: 0.82rem;
    font-family: 'Nunito', sans-serif;
    background: var(--bg-cream);
    color: var(--text-main);
}

/* ---------- Forms / Buttons ---------- */
.btn {
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.86rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-hover); }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--bg-soft-peach); }
.btn-danger-outline { background: transparent; color: var(--danger); border: 1.5px solid #f0b8b3; }
.btn-danger-outline:hover { background: #fdecea; }
.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.qty-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.qty-row:last-child { border-bottom: none; }

.qty-name { font-weight: 700; color: var(--text-main); }
.qty-price { font-size: 0.82rem; color: var(--text-muted); }

.qty-stepper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-cream);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    border: 1px solid var(--border-subtle);
}

.qty-stepper button {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
}

.qty-stepper span { min-width: 20px; text-align: center; font-weight: 700; }

.order-summary-bar {
    position: sticky;
    bottom: 0;
    margin-top: 8px;
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius-md);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.order-summary-bar .total { font-size: 1.1rem; font-weight: 800; }
.order-summary-bar .total span { color: var(--gold-accent); }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state i { font-size: 1.8rem; color: var(--border-subtle); margin-bottom: 10px; display: block; }

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--primary);
    color: #fff;
    padding: 13px 20px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-hover);
    font-size: 0.88rem;
    font-weight: 600;
    z-index: 100;
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.25s ease;
    pointer-events: none;
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: var(--danger); }

.loader-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    color: var(--text-muted);
    font-weight: 600;
}

.hidden { display: none !important; }

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(58, 42, 24, 0.45);
    display: grid;
    place-items: center;
    z-index: 80;
    padding: 20px;
}

.modal-box {
    background: #fff;
    border-radius: var(--radius-md);
    padding: 26px;
    max-width: 420px;
    width: 100%;
    box-shadow: var(--shadow-hover);
}

.modal-box h3 { color: var(--primary); margin-bottom: 16px; font-size: 1.05rem; }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }
    .main-area { margin-left: 0; padding: 20px 16px 60px; }
    .hamburger { display: flex; }
}
