* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: #f8fafc;
  color: #1e293b;
}
a { color: inherit; }

.app-layout { display: flex; min-height: 100vh; }

/* Sidebar */
#sidebar {
  width: 240px;
  min-width: 240px;
  background: #0f172a;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
}
.brand { padding: 20px; font-size: 18px; font-weight: 700; border-bottom: 1px solid #1e293b; }
#sidebar nav { flex: 1; padding: 12px 0; }
.nav-link { display: block; padding: 10px 20px; font-size: 14px; color: #cbd5e1; text-decoration: none; }
.nav-link:hover { background: #1e293b; }
.nav-link.active { background: #1e293b; color: #fff; font-weight: 600; }
.user-box { padding: 16px 20px; border-top: 1px solid #1e293b; font-size: 13px; }
.user-name { font-weight: 600; }
.user-role { color: #94a3b8; text-transform: capitalize; margin-bottom: 8px; }
.link-btn { background: none; border: none; color: #f87171; padding: 0; font-size: 12px; cursor: pointer; }

/* Content */
.content { flex: 1; padding: 24px; overflow-y: auto; }
.content-inner { max-width: 1200px; margin: 0 auto; }

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

/* Buttons */
.btn { display: inline-block; padding: 9px 16px; border-radius: 8px; font-size: 14px; font-weight: 500; border: none; cursor: pointer; text-decoration: none; }
.btn-primary { background: #0f172a; color: #fff; }
.btn-primary:hover { background: #1e293b; }
.btn-success { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-secondary { background: #e2e8f0; color: #1e293b; }
.btn-secondary:hover { background: #cbd5e1; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-link { background: none; border: none; color: #2563eb; padding: 0; font-size: 13px; cursor: pointer; text-decoration: underline; }
.btn-danger-link { background: none; border: none; color: #dc2626; padding: 0; font-size: 12px; cursor: pointer; text-decoration: underline; }

/* Cards */
.card { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 20px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 16px; }
.stat-card.tone-green { background: #f0fdf4; border-color: #bbf7d0; }
.stat-card.tone-amber { background: #fffbeb; border-color: #fde68a; }
.stat-card.tone-red { background: #fef2f2; border-color: #fecaca; }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: #64748b; }
.stat-value { font-size: 22px; font-weight: 700; margin-top: 4px; }

/* Forms */
form.panel { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 20px; margin-bottom: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-full { grid-column: 1 / -1; }
label { display: block; font-size: 12px; font-weight: 600; color: #475569; margin-bottom: 4px; }
input, select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px;
  font-family: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #0f172a33; border-color: #0f172a; }
.field { margin-bottom: 0; }

/* Tables */
.table-wrap { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; overflow: hidden; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead { background: #f1f5f9; text-align: left; }
th, td { padding: 10px 12px; white-space: nowrap; }
tbody tr { border-top: 1px solid #e2e8f0; }
tbody tr:hover { background: #f8fafc; }
.empty-row td { color: #94a3b8; padding: 16px; white-space: normal; }

.badge { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: #f1f5f9; color: #475569; }
.badge.status-pending { background: #f1f5f9; color: #475569; }
.badge.status-assigned { background: #dbeafe; color: #1d4ed8; }
.badge.status-in_transit { background: #fef9c3; color: #a16207; }
.badge.status-completed { background: #dcfce7; color: #15803d; }
.badge.status-cancelled { background: #fee2e2; color: #b91c1c; }

.file-link { font-size: 12px; color: #2563eb; text-decoration: underline; }
.muted { color: #94a3b8; }
.error-box { background: #fef2f2; color: #b91c1c; padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.help-text { font-size: 13px; color: #64748b; margin-bottom: 16px; }

/* Login page */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #0f172a; }
.login-card { background: #fff; border-radius: 14px; padding: 32px; width: 100%; max-width: 380px; }
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card p.sub { margin: 0 0 20px; color: #64748b; font-size: 14px; }

/* Two-column detail layout */
.split { display: grid; grid-template-columns: 320px 1fr; gap: 20px; align-items: start; }
.list-panel { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; overflow: hidden; }
.list-item { width: 100%; text-align: left; background: none; border: none; border-bottom: 1px solid #e2e8f0; padding: 14px; cursor: pointer; font: inherit; }
.list-item:hover { background: #f8fafc; }
.list-item.active { background: #f1f5f9; }
.list-item .name { font-weight: 600; }
.list-item .sub { font-size: 12px; color: #64748b; margin-top: 2px; }
.list-item .balance { font-size: 12px; font-weight: 700; color: #dc2626; margin-top: 4px; }

.detail-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.detail-box { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 12px; }
.detail-box .k { font-size: 11px; color: #64748b; }
.detail-box .v { font-weight: 700; margin-top: 2px; }

section.block { margin-bottom: 28px; }
section.block h2 { font-size: 16px; margin: 0 0 12px; }

@media (max-width: 900px) {
  .app-layout { flex-direction: column; }
  #sidebar { width: 100%; min-width: 0; flex-direction: row; overflow-x: auto; }
  #sidebar nav { display: flex; }
  .brand, .user-box { display: none; }
  .split { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid, .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: 1fr; }
}
