/* ============================================================
   App shell — sidebar + topbar + content, mobile-first
   ============================================================ */
.app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; position: fixed; top: 0; bottom: 0; left: 0; z-index: 200;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: transform .25s var(--ease);
}
.sidebar-brand {
  display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s5);
  height: var(--topbar-h); border-bottom: 1px solid var(--border);
}
.sidebar-brand img { width: 30px; height: 30px; border-radius: 8px; object-fit: contain; }
.sidebar-brand .logo-fallback {
  width: 30px; height: 30px; border-radius: 8px; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .95rem;
}
.sidebar-brand .name { font-weight: var(--fw-bold); font-size: .98rem; letter-spacing: -.01em; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: var(--s4) var(--s3); }
.nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); font-weight: var(--fw-semibold); padding: var(--s4) var(--s3) var(--s2); }
.nav-link {
  display: flex; align-items: center; gap: var(--s3); padding: 9px 12px; margin-bottom: 2px;
  border-radius: var(--radius-sm); color: var(--text-2); font-size: .9rem; font-weight: var(--fw-medium);
  transition: all var(--dur) var(--ease);
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--primary-soft); color: var(--primary); }
.nav-link .icon { width: 20px; text-align: center; font-size: 1.02rem; }
.nav-link .count { margin-left: auto; background: var(--danger); color: #fff; font-size: .68rem; font-weight: 700; border-radius: var(--radius-full); padding: 1px 7px; }

.sidebar-footer { padding: var(--s3); border-top: 1px solid var(--border); }

/* ---------- Topbar ---------- */
.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--topbar-h); position: sticky; top: 0; z-index: 150;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--s4); padding: 0 var(--s6);
}
.hamburger { display: none; background: none; border: none; font-size: 1.3rem; color: var(--text-2); cursor: pointer; }
.topbar-search { flex: 1; max-width: 420px; position: relative; }
.topbar-search input {
  width: 100%; padding: 8px 14px 8px 38px; border-radius: var(--radius-full);
  border: 1px solid var(--border); background: var(--surface-2); font-size: .88rem; color: var(--text);
}
.topbar-search input:focus { outline: none; border-color: var(--primary); background: var(--surface); }
.topbar-search .search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: .9rem; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--s2); }
.topbar-btn { position: relative; background: none; border: none; width: 38px; height: 38px; border-radius: 50%; color: var(--text-2); font-size: 1.1rem; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.topbar-btn:hover { background: var(--surface-2); color: var(--text); }
.topbar-btn .badge-dot { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); border: 2px solid var(--surface); }

/* ---------- Content ---------- */
.content { padding: var(--s6); max-width: 1440px; width: 100%; margin: 0 auto; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s6); flex-wrap: wrap; }
.page-title h1 { font-size: 1.45rem; }
.page-title .breadcrumb { font-size: .8rem; color: var(--text-3); margin-top: 2px; }
.page-actions { display: flex; gap: var(--s3); }

/* Grids */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s4); margin-bottom: var(--s6); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s6); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s4); }
/* !important so pages that set a custom desktop column split inline
   (e.g. my-profile's 300px 1fr, roles' 280px 1fr) still collapse to a
   single column on mobile — inline styles would otherwise win over
   this media query and break the layout on phones. */
@media (max-width: 980px) { .grid-2, .grid-3 { grid-template-columns: 1fr !important; } }

/* FAB (mobile quick action) */
.fab {
  position: fixed; right: var(--s5); bottom: calc(var(--s5) + env(safe-area-inset-bottom)); z-index: 300;
  width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--primary); color: #fff; font-size: 1.5rem; box-shadow: var(--shadow-lg);
  display: none; align-items: center; justify-content: center;
  transition: transform var(--dur) var(--ease);
}
.fab:active { transform: scale(.92); }

/* ---------- Auth pages ---------- */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--s5); background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; }
.auth-logo { text-align: center; margin-bottom: var(--s6); }
.auth-logo .mark { width: 52px; height: 52px; border-radius: 14px; background: var(--primary); color: #fff; font-size: 1.5rem; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; margin-bottom: var(--s3); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(10,15,30,.45); z-index: 190; animation: fadeIn .2s; }
  .main { margin-left: 0; }
  .hamburger { display: block; }
  .content { padding: var(--s4); }
  .fab { display: flex; }
  .topbar-search { display: none; }
}

@media print {
  .sidebar, .topbar, .fab, .page-actions, .no-print { display: none !important; }
  .main { margin: 0; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}
