:root {
  --sidebar-width: 250px;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --sidebar-bg: #111827;
  --sidebar-hover: #1f2937;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { font-size: 15px; } /* base scale — everything below in rem follows this */
body {
  background-color: #f3f4f6;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  color: #1f2937;
}

h1, h2, h3, h4, h5, h6 { font-weight: 600; color: #111827; letter-spacing: -.01em; }
h3 { font-size: 1.4rem; }
h4 { font-size: 1.2rem; }
h5 { font-size: 1.05rem; }
.form-label { font-size: .85rem; font-weight: 500; color: #374151; margin-bottom: .3rem; }
.form-control, .form-select { font-size: .92rem; }
.btn { font-size: .88rem; }
.btn-sm { font-size: .8rem; }
.small, small { font-size: .82rem; }
.badge { font-weight: 500; font-size: .75rem; }

/* Simple flexbox layout: sidebar first in the DOM = left side. Flexbox's
   default align-items:stretch makes both columns match height naturally,
   avoiding the row-sizing edge cases that CSS Grid + position:sticky can
   hit in some browsers. */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  background: var(--sidebar-bg);
  color: #d1d5db;
  display: flex;
  flex-direction: column;
}
.sidebar-brand {
  padding: 1.1rem 1.25rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.sidebar-brand i { color: var(--brand); margin-right: .4rem; }
.sidebar-nav { padding: .75rem 0; }
.sidebar-nav a {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem 1.25rem;
  color: #d1d5db; text-decoration: none;
  font-size: .92rem;
  border-left: 3px solid transparent;
}
.sidebar-nav a i { width: 18px; text-align: center; opacity: .85; }
.sidebar-nav a:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-nav a.active { background: var(--sidebar-hover); color: #fff; border-left-color: var(--brand); font-weight: 600; }
.sidebar-section {
  padding: .9rem 1.25rem .3rem;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #6b7280;
}
.sidebar-user {
  padding: .8rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  color: #d1d5db;
  flex-shrink: 0;
}
.sidebar-user-actions { display: flex; gap: .4rem; margin-top: .55rem; }
.sidebar-user-actions .btn { flex: 1 1 0; padding: .2rem .4rem; font-size: .8rem; white-space: nowrap; }

.main-wrapper {
  flex: 1 1 auto;
  min-width: 0; /* critical: lets this column shrink instead of being
                   forced wide by non-wrapping content inside it */
  display: flex;
  flex-direction: column;
}
.topbar {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: .85rem 1.5rem;
  display: flex; align-items: center; gap: .75rem;
  flex-shrink: 0;
}
.topbar-title { font-weight: 600; font-size: 1.05rem; color: #111827; }
.content { padding: 1.5rem; flex: 1 1 auto; min-width: 0; }

@media (max-width: 991.98px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    transform: translateX(-100%);
    z-index: 1040;
    transition: transform .25s ease;
  }
  .app-shell.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 1035;
  }
  .app-shell.sidebar-open .sidebar-backdrop { display: block; }
}

.card { border: 1px solid #e5e7eb; border-radius: .6rem; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.card-stat { border-left: 4px solid var(--brand); }
.stat-number { font-size: 1.5rem; font-weight: 700; color: #111827; }
.stat-label { font-size: .8rem; color: #6b7280; text-transform: uppercase; letter-spacing: .03em; font-weight: 600; }
.table { margin-bottom: 0; font-size: .88rem; }
.table thead th { white-space: nowrap; background: #f9fafb; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: #6b7280; font-weight: 600; padding: .65rem .75rem; }
.table td { padding: .55rem .75rem; vertical-align: middle; }
.card-header { background: #fff; border-bottom: 1px solid #e5e7eb; font-weight: 600; font-size: .95rem; padding: .75rem 1.1rem; }
.card-body { padding: 1.1rem; }
.btn-primary { background-color: var(--brand); border-color: var(--brand); }
.btn-primary:hover { background-color: var(--brand-dark); border-color: var(--brand-dark); }
.btn-outline-primary { color: var(--brand); border-color: var(--brand); }
.btn-outline-primary:hover { background-color: var(--brand); border-color: var(--brand); }

.table-scroll-x { overflow-x: auto; max-width: 100%; }
.table-scroll-x table { min-width: 1400px; }
.table-responsive { max-width: 100%; }

@media print {
  .sidebar, .topbar, .d-print-none { display: none !important; }
  .app-shell { display: block !important; }
  .content { padding: 0 !important; }
  .card { border: none !important; box-shadow: none !important; }
}
