/* ── Sidebar shell ────────────────────────────────────────────────────────── */
#sidebar {
  width: 260px;
  min-height: 100vh;
  background: #fff;
  border-right: 1px solid #e9ecef;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease;
  overflow: hidden;
}


/* Brand row */
.sidebar-brand {
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  min-height: 56px;
  flex-shrink: 0;
}

.sidebar-brand-text {
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
}

/* Scroll area */
.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 0.6rem 1rem;
}
.sidebar-scroll::-webkit-scrollbar { width: 4px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 2px; }

/* Section labels */
.sidebar-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #adb5bd;
  padding: 0.75rem 0.75rem 0.25rem 4.4rem;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.15s;
}

/* Nav links */
#sidebar a,
#sidebar a:hover,
#sidebar a:focus,
#sidebar a:active,
#sidebar a:visited {
  text-decoration: none !important;
}

.sidebar-link {
  color: #5a6270;
  border-radius: 7px;
  padding: 0.42rem 0.7rem 0.42rem 2.2rem;
  font-size: 0.855rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
  text-decoration: none !important;
  font-weight: 400;
}
.sidebar-link:hover  { background: #f1f3f5; color: #1a1d21; text-decoration: none !important; }
.sidebar-link.active { background: #e8f0fe; color: #1a56db; font-weight: 500; }
.sidebar-link i { font-size: 0.95rem; width: 1.1rem; text-align: center; flex-shrink: 0; opacity: 0.75; }
.sidebar-link.active i { opacity: 1; }
.sidebar-link-text { overflow: hidden; }

/* ── Avatar / footer ──────────────────────────────────────────────────────── */
.sidebar-footer {
  padding: 0.75rem 0 0.25rem;
  border-top: 1px solid #e9ecef;
  margin-top: 0.5rem;
}
.sidebar-footer-inner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  overflow: hidden;
  padding-left: 1rem;
}
.sidebar-footer-text { overflow: hidden; }

.avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Dashboard stat icons ─────────────────────────────────────────────────── */
.stat-icon {
  width: 52px; height: 52px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* ── Main content ─────────────────────────────────────────────────────────── */
main { background: #f8f9fa; min-height: 100vh; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card { border-radius: 12px; }

/* Clip tables inside cards to the card's rounded corners.
   clip-path works where overflow:hidden fails on scrollable children. */
.card > .table-responsive { clip-path: inset(0 round 11px); }
.card > .table-responsive:first-child:not(:last-child) { clip-path: inset(0 round 11px 11px 0 0); }
.card > .table-responsive:last-child:not(:first-child)  { clip-path: inset(0 round 0  0  11px 11px); }
.card .table { margin-bottom: 0; }
.table th {
  font-size: 0.78rem; text-transform: uppercase;
  letter-spacing: 0.04em; font-weight: 600;
}
.list-group-item:hover { background: #f8f9fa; }
.font-monospace {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.82rem;
}

/* ── Dark mode ────────────────────────────────────────────────────────────── */
[data-bs-theme="dark"] body { background: #0d1117!important; }
[data-bs-theme="dark"] .bg-white,
[data-bs-theme="dark"] .bg-light { background-color: #161b22!important; }
[data-bs-theme="dark"] .table-light,
[data-bs-theme="dark"] .table-light th,
[data-bs-theme="dark"] .table-light td {
  background-color: #21262d!important; color: #e6edf3!important; border-color: #30363d!important;
}
[data-bs-theme="dark"] .border,
[data-bs-theme="dark"] .border-bottom,
[data-bs-theme="dark"] .border-top { border-color: #30363d!important; }
[data-bs-theme="dark"] .text-muted { color: #8b949e!important; }
[data-bs-theme="dark"] code { color: #79c0ff; background: transparent; }

[data-bs-theme="dark"] #sidebar { background: #161b22; border-right-color: #30363d; }
[data-bs-theme="dark"] .sidebar-link { color: #8b949e; }
[data-bs-theme="dark"] .sidebar-link:hover { background: #21262d; color: #e6edf3; }
[data-bs-theme="dark"] .sidebar-link.active { background: #1f3a5f; color: #79c0ff; }
[data-bs-theme="dark"] .sidebar-section-label { color: #484f58; }
[data-bs-theme="dark"] .sidebar-footer { border-top-color: #30363d !important; }
[data-bs-theme="dark"] .sidebar-brand-text { color: #e6edf3; }


[data-bs-theme="dark"] main { background: #0d1117; }
[data-bs-theme="dark"] .card { background: #161b22; border-color: #30363d!important; }
[data-bs-theme="dark"] .card-header { background: #161b22!important; border-bottom-color: #30363d!important; }
[data-bs-theme="dark"] .table-light { --bs-table-bg:#21262d; --bs-table-color:#e6edf3; }
[data-bs-theme="dark"] .list-group-item:hover { background: #21262d; }

#theme-toggle {
  background: none; border: 1px solid transparent; border-radius: 8px;
  color: inherit; padding: 0.3rem 0.45rem; cursor: pointer;
  transition: background 0.15s, border-color 0.15s; font-size: 1rem; line-height: 1;
}
#theme-toggle:hover { background: rgba(0,0,0,.06); border-color: #dee2e6; }
[data-bs-theme="dark"] #theme-toggle:hover { background: #21262d; border-color: #30363d; }

/* ── Impersonation banner ─────────────────────────────────────────────────── */
.impersonation-banner {
  background: #fde8e8;
  border: 1px solid #f5a0a0;
  border-left: 4px solid #dc3545;
  color: #6b1a1a;
}
.impersonation-email { color: #a03030; }
.impersonation-btn {
  background: #dc3545;
  border: 1px solid #b02a37;
  color: #fff;
}
.impersonation-btn:hover { background: #b02a37; color: #fff; }

[data-bs-theme="dark"] .impersonation-banner {
  background: #2c0f0f;
  border-color: #8b2020;
  border-left-color: #dc3545;
  color: #f5a0a0;
}
[data-bs-theme="dark"] .impersonation-email { color: #c97070; }
[data-bs-theme="dark"] .impersonation-btn {
  background: #8b2020;
  border-color: #6b1515;
  color: #ffe8e8;
}
[data-bs-theme="dark"] .impersonation-btn:hover { background: #6b1515; color: #ffe8e8; }

/* ── Tools collapsible toggle ─────────────────────────────────────────────── */
.sidebar-tools-toggle {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #adb5bd;
  padding: 0.75rem 0.75rem 0.25rem 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: color 0.12s;
}
.sidebar-tools-toggle:hover { color: #6c757d; }
.sidebar-tools-toggle .tools-chevron {
  font-size: 0.62rem;
  margin-right: 0.4rem;
  transition: transform 0.2s ease;
  opacity: 0.7;
}
.sidebar-tools-toggle[aria-expanded="true"] .tools-chevron { transform: rotate(180deg); }
[data-bs-theme="dark"] .sidebar-tools-toggle { color: #484f58; }
[data-bs-theme="dark"] .sidebar-tools-toggle:hover { color: #8b949e; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar { width: 200px; }
}
