:root {
  --app-bg: #f5f7fb;
  --panel: #ffffff;
  --panel-muted: #f8fafc;
  --border: #e6ebf2;
  --text: #122033;
  --text-soft: #66758a;
  --accent: #111827;
  --accent-soft: #eef2ff;
  --success-soft: #ecfdf3;
  --warning-soft: #fff7ed;
  --danger-soft: #fef2f2;
  --info-soft: #eff6ff;
  --shadow-sm: 0 10px 30px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 16px 44px rgba(15, 23, 42, 0.08);
  --radius-sm: 14px;
  --radius-md: 18px;
  --radius-lg: 24px;
}

html,
body {
  min-height: 100%;
}

body {
  background: var(--app-bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
}

body.app-auth {
  background:
    radial-gradient(circle at top left, rgba(17, 24, 39, 0.06), transparent 32%),
    radial-gradient(circle at bottom right, rgba(59, 130, 246, 0.08), transparent 28%),
    var(--app-bg);
}

.app-shell {
  min-height: calc(100vh - 76px);
}

.app-topbar {
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
}

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.app-brand-mark {
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.85rem;
  background: linear-gradient(135deg, #111827, #334155);
  color: #fff;
  font-size: 0.95rem;
  box-shadow: var(--shadow-sm);
}

.app-brand small {
  display: block;
  font-weight: 500;
  color: var(--text-soft);
  letter-spacing: 0;
}

.app-user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.8rem;
  border-radius: 999px;
  background: var(--panel-muted);
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-size: 0.92rem;
}

.app-user-chip strong {
  color: var(--text);
}

.app-sidebar {
  background: transparent;
}

.app-sidebar-panel {
  background: rgba(255, 255, 255, 0.92);
  border-right: 1px solid var(--border);
  min-height: 100%;
  padding: 1.25rem 1rem;
  position: sticky;
  top: 76px;
}

.app-nav-section {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin: 1rem 0 0.55rem;
  padding: 0 0.75rem;
}

.app-nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.78rem 0.9rem;
  border-radius: 0.95rem;
  color: var(--text-soft);
  text-decoration: none;
  margin-bottom: 0.2rem;
  transition: all 0.18s ease;
  border: 1px solid transparent;
}

.app-nav-link:hover {
  color: var(--text);
  background: rgba(255,255,255,0.85);
  border-color: var(--border);
}

.app-nav-link.active {
  color: var(--text);
  background: var(--panel);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
  font-weight: 700;
}

.app-nav-meta {
  color: inherit;
  opacity: 0.65;
  font-size: 0.85rem;
}

.app-content {
  padding: 1.5rem 1.25rem 2rem;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.35rem;
}

.page-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #4338ca;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 0.65rem;
}

.page-title {
  margin: 0;
  font-size: clamp(1.45rem, 1.8vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.page-subtitle {
  margin: 0.35rem 0 0;
  color: var(--text-soft);
  max-width: 70ch;
}

.stat-card,
.card,
.app-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  background: var(--panel);
}

.card-title,
.card h5,
.card h6 {
  letter-spacing: -0.01em;
}

.stat-card {
  padding: 1rem 1.1rem;
  height: 100%;
}

.stat-label {
  color: var(--text-soft);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-value {
  margin-top: 0.35rem;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.stat-sub {
  margin-top: 0.3rem;
  color: var(--text-soft);
  font-size: 0.92rem;
}

.metric-inline {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 0;
  border-bottom: 1px dashed var(--border);
}

.metric-inline:last-child {
  border-bottom: 0;
}

.metric-inline strong {
  color: var(--text);
}

.soft-panel {
  background: var(--panel-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
}

.form-label {
  font-weight: 700;
  color: var(--text);
  font-size: 0.92rem;
}

.form-control,
.form-select,
textarea.form-control {
  min-height: 46px;
  border-radius: 0.95rem;
  border-color: #d7dfeb;
  box-shadow: none;
  padding: 0.7rem 0.85rem;
}

textarea.form-control {
  min-height: 96px;
}

.form-control:focus,
.form-select:focus,
textarea.form-control:focus {
  border-color: #94a3b8;
  box-shadow: 0 0 0 0.2rem rgba(15, 23, 42, 0.07);
}

.form-text,
.small.text-muted,
.text-muted {
  color: var(--text-soft) !important;
}

.btn {
  border-radius: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  padding: 0.68rem 1rem;
}

.btn-sm {
  border-radius: 0.8rem;
  padding: 0.45rem 0.78rem;
}

.btn-primary,
.btn-dark {
  background: #111827;
  border-color: #111827;
}

.btn-primary:hover,
.btn-primary:focus,
.btn-dark:hover,
.btn-dark:focus {
  background: #0f172a;
  border-color: #0f172a;
}

.btn-outline-primary,
.btn-outline-dark,
.btn-outline-secondary,
.btn-outline-success,
.btn-outline-warning,
.btn-outline-danger {
  border-width: 1px;
}

.alert {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.alert-success {
  background: var(--success-soft);
  border-color: #bbf7d0;
  color: #166534;
}

.alert-danger {
  background: var(--danger-soft);
  border-color: #fecaca;
  color: #991b1b;
}

.alert-info {
  background: var(--info-soft);
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.alert-warning {
  background: var(--warning-soft);
  border-color: #fed7aa;
  color: #9a3412;
}

.table {
  --bs-table-bg: transparent;
  --bs-table-border-color: var(--border);
}

.table thead th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  font-weight: 700;
  border-bottom-width: 1px;
}

.table tbody td {
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
}

.table tbody tr:hover {
  background: rgba(15, 23, 42, 0.03);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.38rem 0.72rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.status-PENDING { background: #eef2ff; color: #4338ca; }
.status-ASSIGNED { background: #eff6ff; color: #1d4ed8; }
.status-PICKED_UP { background: #ecfeff; color: #0f766e; }
.status-IN_TRANSIT { background: #fff7ed; color: #c2410c; }
.status-DELIVERED { background: #ecfdf3; color: #15803d; }
.status-CANCELLED { background: #fef2f2; color: #b91c1c; }
.status-low { background: #fff7ed; color: #c2410c; }
.status-ok { background: #ecfdf3; color: #15803d; }
.status-neutral { background: #f1f5f9; color: #475569; }

.code-chip,
code {
  display: inline-block;
  padding: 0.24rem 0.55rem;
  border-radius: 0.65rem;
  background: #f8fafc;
  color: #334155;
  border: 1px solid var(--border);
  font-size: 0.86rem;
}

.map-panel,
.scanner-panel {
  overflow: hidden;
}

.map-canvas {
  min-height: 300px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.scanner-status {
  font-weight: 700;
  color: var(--text-soft);
}

.list-clean {
  list-style: none;
  padding: 0;
  margin: 0;
}

.list-clean li + li {
  margin-top: 0.5rem;
}

.timeline {
  position: relative;
  padding-left: 1.2rem;
}

.timeline::before {
  content: "";
  position: absolute;
  top: 0.3rem;
  bottom: 0.3rem;
  left: 0.38rem;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: 0.95rem;
}

.timeline-item::before {
  content: "";
  position: absolute;
  top: 0.18rem;
  left: -0.04rem;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 999px;
  background: #cbd5e1;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px var(--border);
}

.timeline-item.is-done::before {
  background: #16a34a;
}

.timeline-time {
  color: var(--text-soft);
  font-size: 0.85rem;
}

.login-card {
  border: 1px solid var(--border);
  border-radius: 1.4rem;
  box-shadow: var(--shadow-md);
  background: rgba(255,255,255,0.96);
}

.login-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
}

.login-brand-mark {
  width: 3rem;
  height: 3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 1rem;
  background: linear-gradient(135deg, #111827, #475569);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.auth-note {
  color: var(--text-soft);
  font-size: 0.94rem;
}

.table-warning {
  --bs-table-accent-bg: rgba(251, 191, 36, 0.12);
}

@media (max-width: 991.98px) {
  .app-sidebar-panel {
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    min-height: auto;
    padding-bottom: 0.5rem;
  }

  .app-content {
    padding-top: 1rem;
  }
}
