:root {
  --primary: #42308A;
  --primary-light: #6859A1;
  --primary-dark: #2d2060;
  --secondary: #DC1D35;
  --accent: #6859A1;
  --success: #37b13f;
  --warning: #f5a623;
  --danger: #DC1D35;
  --info: #3286e5;
  --bg: #F9FAFB;
  --bg2: #F3F4F6;
  --white: #fff;
  --black: #292929;
  --grey: #848484;
  --grey-light: #A9A9A9;
  --grey-border: #ECEAF3;
  --sidebar-w: 260px;
  --shadow: 0 1px 4px rgba(128,116,177,0.12);
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Quicksand', -apple-system, BlinkMacSystemFont, sans-serif; background: var(--bg); color: var(--black); font-size: 14px; }

/* ── LAYOUT ── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); background: var(--primary); position: fixed;
  top: 0; left: 0; height: 100vh; overflow-y: auto; z-index: 100;
  display: flex; flex-direction: column;
  transition: transform .3s;
}
.sidebar-logo {
  padding: 24px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex; align-items: center; gap: 12px;
}
.sidebar-logo img { height: 30px; width: auto; object-fit: contain; background: #fff; border-radius: 6px; padding: 4px 10px; }
.sidebar-logo span { color: #fff; font-size: 18px; font-weight: 700; }

.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-section { padding: 8px 20px 4px; color: rgba(255,255,255,.4); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 20px;
  color: rgba(255,255,255,.75); text-decoration: none; font-weight: 600; font-size: 14px;
  transition: all .2s; cursor: pointer; border: none; background: none; width: 100%;
}
.nav-item:hover, .nav-item.active {
  background: rgba(255,255,255,.12); color: #fff;
  border-right: 3px solid #fff;
}
.nav-item svg, .nav-item i { width: 20px; flex-shrink: 0; }
.nav-badge { margin-left: auto; background: var(--secondary); color: #fff; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 20px; }

.sidebar-bottom { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-user { display: flex; align-items: center; gap: 10px; color: #fff; }
.sidebar-user-name { font-weight: 600; font-size: 13px; }
.sidebar-user-role { font-size: 11px; color: rgba(255,255,255,.6); text-transform: capitalize; }

.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; }

.topbar {
  background: #fff; border-bottom: 1px solid var(--grey-border);
  padding: 0 28px; height: 60px; display: flex; align-items: center;
  justify-content: space-between; position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow);
}
.topbar-title { font-size: 18px; font-weight: 700; color: var(--primary); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }

.content { padding: 28px; flex: 1; }

/* ── CARDS ── */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: #fff; border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 16px;
}
.stat-icon { width: 48px; height: 48px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.stat-info { flex: 1; min-width: 0; }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1; color: var(--black); }
.stat-label { font-size: 12px; color: var(--grey); margin-top: 4px; font-weight: 500; }
.stat-sub { font-size: 11px; color: var(--success); margin-top: 2px; }

/* ── CARD ── */
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--grey-border); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 16px; font-weight: 700; color: var(--black); }
.card-body { padding: 20px; }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { padding: 12px 16px; text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--grey); background: var(--bg2); border-bottom: 1px solid var(--grey-border); }
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--grey-border); font-size: 13px; vertical-align: middle; }
tbody tr:hover { background: var(--bg); }
tbody tr:last-child td { border-bottom: none; }

/* ── BADGES ── */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-pending    { background: #fef3c7; color: #92400e; }
.badge-searching  { background: #dbeafe; color: #1e40af; }
.badge-accepted   { background: #d1fae5; color: #065f46; }
.badge-pickup     { background: #e0e7ff; color: #3730a3; }
.badge-in_transit { background: #cffafe; color: #155e75; }
.badge-delivered  { background: #d1fae5; color: #065f46; }
.badge-cancelled  { background: #fee2e2; color: #991b1b; }
.badge-failed     { background: #fee2e2; color: #991b1b; }
.badge-approved   { background: #d1fae5; color: #065f46; }
.badge-rejected   { background: #fee2e2; color: #991b1b; }
.badge-success    { background: #d1fae5; color: #065f46; }
.badge-danger     { background: #fee2e2; color: #991b1b; }
.badge-info       { background: #dbeafe; color: #1e40af; }
.badge-warning    { background: #fef3c7; color: #92400e; }

/* ── BUTTONS ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 18px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; border: none; text-decoration: none; transition: all .2s; white-space: nowrap; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg2); color: var(--black); border: 1px solid var(--grey-border); }
.btn-secondary:hover { background: var(--grey-border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b71c2e; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-icon { padding: 8px; border-radius: 8px; background: var(--bg2); color: var(--grey); border: 1px solid var(--grey-border); }
.btn-icon:hover { color: var(--primary); border-color: var(--primary); }

/* ── FORMS ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 700; color: var(--grey); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .3px; }
.form-control {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--grey-border);
  border-radius: 8px; font-size: 14px; font-family: inherit;
  background: #fff; color: var(--black); outline: none; transition: border .2s;
}
.form-control:focus { border-color: var(--primary); }
select.form-control { cursor: pointer; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── PAGINATION ── */
.pagination { display: flex; align-items: center; gap: 8px; padding: 16px 20px; border-top: 1px solid var(--grey-border); justify-content: flex-end; }
.page-btn { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 8px; border: 1px solid var(--grey-border); background: #fff; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--black); text-decoration: none; }
.page-btn:hover, .page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-info { font-size: 12px; color: var(--grey); }

/* ── MODAL ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200; display: none; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: #fff; border-radius: var(--radius); width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--grey-border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--grey); font-size: 20px; line-height: 1; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--grey-border); display: flex; justify-content: flex-end; gap: 10px; }

/* ── ALERT ── */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 13px; font-weight: 600; margin-bottom: 16px; }
.alert-success { background: #d1fae5; color: #065f46; }
.alert-error   { background: #fee2e2; color: #991b1b; }
.alert-info    { background: #dbeafe; color: #1e40af; }

/* ── AVATAR ── */
.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--bg2); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; color: var(--primary); flex-shrink: 0; }

/* ── FILTER BAR ── */
.filter-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar .form-control { width: auto; min-width: 140px; }
.filter-bar .search-input { min-width: 240px; }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--grey); }
.empty-state svg { width: 64px; height: 64px; margin-bottom: 16px; opacity: .3; }
.empty-state p { font-size: 15px; font-weight: 600; }

/* ── TOAST ── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--black); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 13px; font-weight: 600; min-width: 220px; box-shadow: 0 4px 20px rgba(0,0,0,.25); animation: slideUp .3s ease; }
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  @media (max-width: 480px) { .stat-grid { grid-template-columns: 1fr; } }
}

/* ── CONFIG PAGE ── */
.config-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.config-item { background: var(--bg); border-radius: var(--radius-sm); padding: 14px 16px; border: 1.5px solid var(--grey-border); }
.config-key { font-size: 11px; font-weight: 700; color: var(--grey); text-transform: uppercase; margin-bottom: 6px; }
.config-desc { font-size: 11px; color: var(--grey-light); margin-bottom: 8px; }

/* ── STATUS DOT ── */
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.dot-online  { background: var(--success); }
.dot-offline { background: var(--grey-light); }

/* ── PAGE HEADER ── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-title    { font-size: 22px; font-weight: 700; color: var(--black); line-height: 1.2; }
.page-subtitle { font-size: 13px; color: var(--grey); margin-top: 3px; font-weight: 500; }
.page-actions  { display: flex; align-items: center; gap: 10px; }

/* ── CARD WITH FORM (no card-body) ── */
.card > form   { padding: 24px; }
.card > form h3 { margin-bottom: 16px; color: var(--primary); }

/* ── MODAL BOX (alias) ── */
.modal-box { background: #fff; border-radius: var(--radius); width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2); }

/* ── COMPAT ALIASES ── */
:root { --border: var(--grey-border); }
.btn-outline { background: var(--bg2); color: var(--black); border: 1.5px solid var(--grey-border); display:inline-flex;align-items:center;gap:6px;padding:8px 18px;border-radius:8px;font-size:13px;font-weight:600;cursor:pointer;text-decoration:none;transition:all .2s;white-space:nowrap; }
.btn-outline:hover { background: var(--grey-border); }
.badge-secondary { background: var(--bg2); color: var(--grey); border: 1px solid var(--grey-border); }

/* login page */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%); }
.login-card { background: #fff; border-radius: 20px; padding: 48px 40px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo img { width: 72px; height: 72px; border-radius: 16px; }
.login-logo h1 { font-size: 24px; font-weight: 700; color: var(--primary); margin-top: 12px; }
.login-logo p { font-size: 13px; color: var(--grey); margin-top: 4px; }
