:root {
  --sidebar-width: 240px;
  --sidebar-bg: #f1f5f9;
  --sidebar-text: #475569;
  --sidebar-text-hover: #1e293b;
  --sidebar-active-bg: rgba(99, 102, 241, 0.1);
  --sidebar-active-text: #4f46e5;
  --sidebar-brand-text: #1e293b;
  --sidebar-border: rgba(148, 163, 184, 0.25);
  --topbar-height: 56px;
}

html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ===== Mobile top bar ===== */
.sidebar-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1040;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1rem;
  background: var(--sidebar-bg);
  color: var(--sidebar-brand-text);
}

.sidebar-topbar-brand {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--sidebar-brand-text);
  text-decoration: none;
}

.sidebar-toggle {
  color: var(--sidebar-text);
  font-size: 1.5rem;
  padding: 0.25rem;
  line-height: 1;
}

.sidebar-toggle:hover {
  color: var(--sidebar-text-hover);
}

/* ===== Sidebar ===== */
.sidebar {
  background: var(--sidebar-bg);
  width: var(--sidebar-width);
  border-right: 1px solid var(--sidebar-border);
}

.sidebar .offcanvas-header {
  background: var(--sidebar-bg);
  color: var(--sidebar-brand-text);
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar .offcanvas-header .btn-close {
  filter: none;
}

.sidebar-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
}

/* ===== Sidebar brand ===== */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.25rem 1rem;
  text-decoration: none;
  border-bottom: 1px solid var(--sidebar-border);
  margin-bottom: 0.5rem;
}

.sidebar-brand:hover {
  text-decoration: none;
}

.sidebar-brand-icon {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 8px;
}

.sidebar-brand-text {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--sidebar-brand-text);
  letter-spacing: -0.01em;
}

/* ===== Sidebar nav ===== */
.sidebar-nav {
  list-style: none;
  padding: 0.25rem 0.75rem;
  margin: 0;
  flex: 1;
}

.sidebar-nav-item {
  margin-bottom: 2px;
}

.sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--sidebar-text);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.sidebar-nav-link:hover {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-hover);
  text-decoration: none;
}

.sidebar-nav-link svg {
  width: 1.15em;
  height: 1.15em;
  flex-shrink: 0;
}

/* ===== Sidebar footer ===== */
.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-footer .sidebar-nav-link {
  justify-content: flex-start;
}

/* ===== Main content ===== */
.main-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  padding: 1.5rem;
}

/* ===== Footer ===== */
.site-footer {
  padding: 1rem 0;
  border-top: 1px solid #e5e5e5;
  font-size: 0.875rem;
}

.footer-nav {
  list-style: none;
  display: flex;
  gap: 1.25rem;
  margin: 0;
  padding: 0;
}

.footer-nav a {
  color: inherit;
  text-decoration: none;
}

.footer-nav a:hover {
  text-decoration: underline;
}

/* ===== Sidebar logout button ===== */
.sidebar-logout-btn {
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
}

/* ===== Mobile: sidebar as offcanvas, content full width ===== */
@media (max-width: 767.98px) {
  .sidebar-brand {
    display: none;
  }

  .main-wrapper {
    padding-top: var(--topbar-height);
  }
}

/* ===== Desktop: fixed sidebar, content offset ===== */
@media (min-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1030;
    overflow-y: auto;
    visibility: visible !important;
    transform: none !important;
  }

  .main-wrapper {
    margin-left: var(--sidebar-width);
  }
}