:root {
    --color-bg: #f6f7f9;
    --color-surface: #ffffff;
    --color-border: #e2e5ea;
    --color-text: #1a1d23;
    --color-text-muted: #6b7280;
    --color-primary: #16a34a;
    --color-primary-dark: #15803d;
    --color-danger: #dc2626;
    --color-danger-bg: #fef2f2;
    --radius: 8px;
    --sidebar-width: 220px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 14px;
}

a { color: var(--color-primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Standalone (login) pages --- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #0f2417 0%, var(--color-bg) 340px);
}
.auth-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    padding: 40px;
    width: 100%;
    max-width: 380px;
}
.auth-card h1 {
    font-size: 20px;
    margin: 0 0 4px;
}
.auth-card .subtitle {
    color: var(--color-text-muted);
    margin: 0 0 24px;
    font-size: 13px;
}

/* --- App shell --- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-width);
    background: #0f2417;
    color: #d7ecdf;
    padding: 20px 0;
    flex-shrink: 0;
}
.sidebar .brand {
    font-weight: 700;
    font-size: 18px;
    color: #ffffff;
    padding: 0 20px 20px;
}
.sidebar nav a {
    display: block;
    padding: 10px 20px;
    color: #b9d6c2;
}
.sidebar nav a:hover, .sidebar nav a.active {
    background: rgba(255,255,255,0.06);
    color: #ffffff;
    text-decoration: none;
}
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.topbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.content { padding: 24px; }

/* --- Components --- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 20px;
}
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card .stat-label {
    color: var(--color-text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}
.stat-card .stat-value {
    font-size: 26px;
    font-weight: 700;
}

.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
}
.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 14px;
}
.form-group input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(22,163,74,0.15);
}
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
}
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.btn {
    display: inline-block;
    background: var(--color-primary);
    color: #ffffff;
    border: none;
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    text-align: center;
}
.btn:hover { background: var(--color-primary-dark); }

.alert {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
}
.alert-error {
    background: var(--color-danger-bg);
    color: var(--color-danger);
    border: 1px solid #fecaca;
}
.alert-success {
    background: #f0fdf4;
    color: var(--color-primary-dark);
    border: 1px solid #bbf7d0;
}

/* --- Tabs --- */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--color-border);
}
.tab {
    padding: 8px 14px;
    color: var(--color-text-muted);
    border-bottom: 2px solid transparent;
    font-weight: 600;
    font-size: 13px;
}
.tab:hover { text-decoration: none; color: var(--color-text); }
.tab.active {
    color: var(--color-primary-dark);
    border-bottom-color: var(--color-primary);
}

/* --- Tables --- */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    table-layout: auto;
}
.table th {
    text-align: left;
    padding: 10px 14px;
    color: var(--color-text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: #f9fafb;
    border-bottom: 2px solid var(--color-border);
    border-right: 1px solid var(--color-border);
    white-space: nowrap;
}
.table th:last-child { border-right: none; }
.table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--color-border);
    border-right: 1px solid var(--color-border);
    vertical-align: top;
}
.table td:last-child { border-right: none; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:nth-child(even) { background: #fafbfc; }
.table tbody tr:hover { background: #f3f7f4; }
.empty-cell {
    text-align: center;
    color: var(--color-text-muted);
    padding: 24px !important;
}
.muted { color: var(--color-text-muted); font-size: 12px; }
.actions { white-space: nowrap; }

/* --- Badges --- */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: capitalize;
}
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-approved { background: #dcfce7; color: #166534; }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-suspended { background: #e5e7eb; color: #374151; }
.badge-placed { background: #dbeafe; color: #1e40af; }
.badge-vendor_accepted { background: #e0e7ff; color: #3730a3; }
.badge-accepted { background: #e0e7ff; color: #3730a3; }
.badge-packed { background: #fce7f3; color: #9d174d; }
.badge-rider_assigned { background: #fef3c7; color: #92400e; }
.badge-picked_up { background: #fed7aa; color: #9a3412; }
.badge-out_for_delivery { background: #bfdbfe; color: #1e3a8a; }
.badge-delivered { background: #dcfce7; color: #166534; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }

/* --- Small buttons for inline row actions --- */
.btn-sm {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    margin-right: 4px;
}
.btn-success { background: #dcfce7; color: #166534; }
.btn-success:hover { background: #bbf7d0; }
.btn-danger { background: #fee2e2; color: #991b1b; }
.btn-danger:hover { background: #fecaca; }
.btn-warning { background: #fef3c7; color: #92400e; }
.btn-warning:hover { background: #fde68a; }