:root {
  --sa-red: #8b1e2d;
  --sa-red-dark: #6b1521;
  --sa-charcoal: #2b2b2e;
  --sa-charcoal-light: #3a3a3f;
  --sa-bg: #f4f5f7;
}

body {
  background: var(--sa-bg);
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
}

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

#sidebar {
  width: 240px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--sa-charcoal), var(--sa-red-dark));
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-brand i { font-size: 28px; color: #fff; }
.brand-title { font-weight: 700; font-size: 15px; line-height: 1.1; }
.brand-sub { font-size: 11px; opacity: 0.75; }

.sidebar-nav { flex: 1; padding: 10px 0; }
.sidebar-nav .nav-link {
  color: rgba(255,255,255,0.85);
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-left: 3px solid transparent;
}
.sidebar-nav .nav-link i { font-size: 16px; width: 18px; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-nav .nav-link.active {
  background: rgba(255,255,255,0.12);
  border-left-color: #fff;
  font-weight: 600;
  color: #fff;
}
.sidebar-footer { padding: 14px; border-top: 1px solid rgba(255,255,255,0.1); }

.nav-section-label {
  padding: 10px 18px 4px;
  font-size: 10.5px;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.5);
  font-weight: 700;
}

.main-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

#topbar {
  background: #fff;
  border-bottom: 1px solid #e3e3e6;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 90;
}
.topbar-title { font-weight: 600; color: var(--sa-charcoal); }

.demo-badge {
  background: #ffe9a8;
  color: #6b4b00;
  font-weight: 600;
  letter-spacing: .3px;
}

.page-content { padding: 20px; flex: 1; }

/* Cards */
.card { border: none; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.card-header { background: #fff; border-bottom: 1px solid #eee; font-weight: 600; }

.stat-card { border-left: 4px solid var(--sa-red); }
.stat-card .stat-value { font-size: 26px; font-weight: 700; color: var(--sa-charcoal); }
.stat-card .stat-label { font-size: 12.5px; color: #777; }
.stat-card .stat-icon { font-size: 30px; color: var(--sa-red); opacity: 0.8; }

/* Buttons */
.btn-danger, .btn-primary.sa-primary {
  background-color: var(--sa-red);
  border-color: var(--sa-red);
}
.btn-danger:hover { background-color: var(--sa-red-dark); border-color: var(--sa-red-dark); }
.btn-outline-danger { color: var(--sa-red); border-color: var(--sa-red); }
.btn-outline-danger:hover { background-color: var(--sa-red); border-color: var(--sa-red); }

/* Tables */
.table-compact th, .table-compact td { padding: 7px 10px; font-size: 13px; vertical-align: middle; }
.table-compact thead th { background: var(--sa-charcoal); color: #fff; font-weight: 600; white-space: nowrap; }

/* Status badges */
.badge-status-received { background: #6c757d; }
.badge-status-progress { background: #fd7e14; }
.badge-status-ready { background: #0d6efd; }
.badge-status-delivered { background: #198754; }

/* Login page */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--sa-charcoal), var(--sa-red-dark));
}
.login-card { max-width: 400px; width: 100%; border-radius: 14px; }
.login-logo { text-align: center; margin-bottom: 10px; }
.login-logo i { font-size: 42px; color: var(--sa-red); }
.login-logo .brand { font-weight: 700; font-size: 20px; color: var(--sa-charcoal); }
.login-logo .brand-sub { font-size: 12px; color: #888; }

/* Signature pad */
.signature-box {
  border: 1px dashed #aaa;
  border-radius: 6px;
  background: #fff;
  touch-action: none;
}

/* Pre-trial checklist */
.pretrial-item { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid #f0f0f0; }

/* Sidebar mobile */
@media (max-width: 991.98px) {
  #sidebar {
    position: fixed;
    left: -240px;
    transition: left 0.2s ease;
  }
  #sidebar.sidebar-open { left: 0; }
}

/* Print */
@media print {
  #sidebar, #topbar, .no-print, .btn, .app-footer { display: none !important; }
  .page-content { padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc !important; }
  body { background: #fff !important; }
}
