.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 16px 24px;
  font-size: 14px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}
.site-footer strong { color: var(--text-link); }
@media (max-width: 640px) {
  .site-footer { flex-direction: column; align-items: flex-start; gap: 4px; }
}
/* ==========================================================================
   App Shell
   ========================================================================== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---------------- Sidebar ---------------- */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 40;
  transition: width var(--transition-base), transform var(--transition-base);
  overflow: hidden;
}
.app-shell:has(> #navCollapse:checked) .sidebar { width: var(--sidebar-width-collapsed); }

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 18px 20px;
  height: var(--header-height);
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar__logo {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-teal));
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.sidebar__brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.sidebar__brand-name { color: var(--text-inverse); font-weight: 700; font-size: var(--fs-md); }
.sidebar__brand-sub { color: var(--sidebar-text); font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; }
.app-shell:has(> #navCollapse:checked) .sidebar__brand-text { display: none; }

.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5) 14px var(--space-8);
}
.sidebar__logout {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 14px 18px;
  padding: 12px 14px;
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--sidebar-text);
  font-size: var(--fs-base);
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}
.sidebar__logout:hover { background: rgba(211, 59, 59, 0.16); border-color: rgba(211, 59, 59, 0.35); color: #fff; }
.sidebar__logout svg { flex-shrink: 0; width: 18px; height: 18px; }
.app-shell:has(> #navCollapse:checked) .sidebar__logout { justify-content: center; padding-left: 0; padding-right: 0; }
.app-shell:has(> #navCollapse:checked) .sidebar__logout .nav-link__label { display: none; }
.sidebar__section { margin-top: var(--space-4); }
.sidebar__section:first-child { margin-top: 0; }
.sidebar__section-label {
  padding: 8px 12px 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-section-label);
  white-space: nowrap;
}
.app-shell:has(> #navCollapse:checked) .sidebar__section-label { text-align: center; padding: 8px 0 6px; }

.nav-item { position: relative; margin-bottom: 4px; }
.nav-item:last-child { margin-bottom: 0; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  font-size: var(--fs-base);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  line-height: 1.2;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.nav-link:hover { background: var(--sidebar-hover-bg); color: #fff; text-decoration: none; }
.nav-link svg { flex-shrink: 0; width: 18px; height: 18px; }
.nav-link.is-active { background: var(--sidebar-active-bg); color: var(--sidebar-text-active); }
.nav-link.is-active::before {
  content: "";
  position: absolute; left: -14px; top: 10px; bottom: 10px; width: 3px;
  background: var(--brand-500); border-radius: var(--radius-full);
}
.nav-link .nav-caret { margin-left: auto; width: 14px; height: 14px; transition: transform var(--transition-fast); opacity: .7; }
.nav-group.is-open > .nav-link .nav-caret { transform: rotate(90deg); }
.nav-children {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-base);
  padding-left: 30px;
}
.nav-group.is-open > .nav-children { max-height: 700px; }
.nav-children .nav-link { padding: 7px 12px; font-size: 13.5px; font-weight: 400; }
.nav-children .nav-link.is-active::before { left: -18px; }
.app-shell:has(> #navCollapse:checked) .nav-link__label,
.app-shell:has(> #navCollapse:checked) .nav-caret { display: none; }
.app-shell:has(> #navCollapse:checked) .nav-children { display: none; }
.app-shell:has(> #navCollapse:checked) .nav-link { justify-content: center; }

/* ---------------- Main column ---------------- */
.main-column {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin-left var(--transition-base);
}
.app-shell:has(> #navCollapse:checked) .main-column { margin-left: var(--sidebar-width-collapsed); }

/* ---------------- Header ---------------- */
.topbar {
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  position: sticky;
  top: 0;
  z-index: 30;
  gap: var(--space-4);
}
.topbar__left { display: flex; align-items: center; gap: var(--space-4); min-width: 0; }
.topbar__toggle {
  width: 36px; height: 36px; border-radius: var(--radius-md); border: 1px solid var(--border-default);
  background: var(--bg-surface); display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: var(--text-secondary);
}
.topbar__toggle:hover { background: var(--bg-sunken); }
.topbar__title-group { min-width: 0; }
.topbar__title { font-size: var(--fs-lg); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb .is-current { color: var(--text-secondary); font-weight: 500; }

.topbar__search {
  display: flex; align-items: center; gap: 8px;
  width: 320px; max-width: 32vw;
  padding: 0 12px; height: 38px;
  border: 1px solid var(--border-default); border-radius: var(--radius-md);
  background: var(--bg-surface-alt);
  color: var(--text-muted);
}
.topbar__search input { border: none; background: transparent; outline: none; width: 100%; font-size: var(--fs-sm); color: var(--text-primary); }
.topbar__search kbd { font-size: 11px; padding: 2px 6px; border-radius: 4px; background: var(--bg-sunken); border: 1px solid var(--border-default); color: var(--text-muted); }

.topbar__right { display: flex; align-items: center; gap: var(--space-3); flex-shrink: 0; }
.icon-btn {
  width: 38px; height: 38px; border-radius: var(--radius-md); border: 1px solid var(--border-default);
  background: var(--bg-surface); display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); position: relative; flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-sunken); }
.icon-btn__dot {
  position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--status-critical); border: 2px solid var(--bg-surface);
}
.profile-trigger { display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 6px; border-radius: var(--radius-full); border: 1px solid var(--border-default); background: var(--bg-surface); }
.profile-trigger:hover { background: var(--bg-sunken); }
.avatar { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; object-fit: cover; background: var(--brand-100); }
.avatar--lg { width: 56px; height: 56px; }
.avatar--sm { width: 24px; height: 24px; }
.profile-trigger__meta { text-align: left; line-height: 1.2; }
.profile-trigger__name { font-size: 13px; font-weight: 600; }
.profile-trigger__role { font-size: 11px; color: var(--text-muted); }

/* ---------------- Page content ---------------- */
.page-content { padding: var(--space-6); max-width: 1600px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-6); flex-wrap: wrap; }
.page-header h1 { font-size: var(--fs-2xl); }
.page-header__desc { color: var(--text-secondary); font-size: var(--fs-sm); margin-top: 4px; }
.page-header__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* Overlay for mobile sidebar */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 39; }
.app-shell:has(> #navMobile:checked) .sidebar-overlay { display: block; }

/* ============ Responsive ============ */
@media (max-width: 1200px) {
  .topbar__search { width: 220px; }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-width); box-shadow: var(--shadow-lg); }
  .app-shell:has(> #navMobile:checked) .sidebar { transform: translateX(0); }
  .main-column { margin-left: 0; }
  .app-shell:has(> #navCollapse:checked) .main-column { margin-left: 0; }
  .topbar__search { display: none; }
  .page-content { padding: var(--space-4); }
  .topbar { padding: 0 var(--space-4); }
}
@media (max-width: 560px) {
  .profile-trigger__meta { display: none; }
  .profile-trigger { padding: 6px; border: none; background: transparent; }
}

/* ---------------- No-JS shell controls ----------------
   #navCollapse (desktop collapse) and #navMobile (mobile drawer) are visually
   hidden checkboxes at the top of .app-shell; the header toggles and the
   overlay are <label>s pointing at them. */
.nav-state { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
label.topbar__toggle, label.sidebar-overlay { cursor: pointer; }
.nav-state:focus-visible ~ .main-column .topbar__toggle { box-shadow: var(--shadow-focus); }
@media (max-width: 900px) {
  .topbar__toggle.u-hide-desktop { display: flex !important; }
  .app-shell:has(> #navCollapse:checked) .sidebar { width: var(--sidebar-width); }
  .app-shell:has(> #navCollapse:checked) .nav-link__label,
  .app-shell:has(> #navCollapse:checked) .sidebar__brand-text { display: initial; }
  .app-shell:has(> #navCollapse:checked) .nav-link { justify-content: flex-start; }
}
