.dashboard-layout {
  display: flex;
  min-height: 100vh;
}

/* ═══════════════════════════════════════
   SIDEBAR v3 — Responsive
   ═══════════════════════════════════════ */

:root {
  --sidebar-w: 260px;
  --sidebar-coll-w: 60px;
}

.sidebar {
  width: var(--sidebar-w);
  color: #fff;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
  background: linear-gradient(180deg, #0C1A2E 0%, #070E1A 100%);
  box-shadow: -4px 0 40px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.06);
  contain: layout paint;
  transition: width .3s ease;
}

/* Decorative overlay */
.sidebar::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 0% 100%, rgba(212,160,23,.08) 0%, transparent 60%),
    radial-gradient(ellipse at 100% 0%, rgba(35,156,196,.05) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}
.sidebar > * { position: relative; z-index: 1; }

/* Gold border accent */
.sidebar::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, var(--primary), var(--accent), var(--primary));
  background-size: 100% 200%;
  animation: sidebarBorderGlow 4s ease-in-out infinite;
  pointer-events: none;
  z-index: 2;
}
@keyframes sidebarBorderGlow {
  0%, 100% { background-position: 0 0%; }
  50% { background-position: 0 100%; }
}

.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 10px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.3); }

/* ── Brand ── */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  overflow: hidden;
  white-space: nowrap;
}
.sidebar-logo {
  width: 38px;
  height: auto;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 8px rgba(212,160,23,.2));
  transition: transform .35s ease;
}
.sidebar-brand-text {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  background: linear-gradient(135deg, #fff 55%, rgba(212,160,23,.75));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
}

/* ── User ── */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  white-space: nowrap;
  min-height: 66px;
}
.sidebar-user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 0 0 2px rgba(255,255,255,.1), 0 4px 12px rgba(35,156,196,.25);
}
.sidebar-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}
.sidebar-user-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.sidebar-user-name {
  font-size: .88rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff;
}
.sidebar-user-role {
  font-size: .7rem;
  color: rgba(255,255,255,.45);
  font-weight: 500;
}

/* ── Navigation ── */
.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  overflow-y: auto;
}
.sidebar-section-title {
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: rgba(255,255,255,.25);
  padding: 16px 12px 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(255,255,255,.06), transparent);
  min-width: 8px;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: rgba(255,255,255,.55);
  text-decoration: none;
  font-size: .85rem;
  font-weight: 500;
  margin-bottom: 2px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: color .3s cubic-bezier(.4,0,.2,1), background .3s cubic-bezier(.4,0,.2,1), transform .3s cubic-bezier(.4,0,.2,1);
  white-space: nowrap;
}
.sidebar-item:focus-visible {
  box-shadow: 0 0 0 2px var(--primary), 0 0 0 4px rgba(35,156,196,.3);
  border-radius: 10px;
}
.sidebar-item::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 10px;
  opacity: 0;
  transition: opacity .3s ease;
  background: linear-gradient(135deg, rgba(35,156,196,.1), rgba(212,160,23,.03));
}
.sidebar-item:hover { color: rgba(255,255,255,.9); transform: translateX(-3px); }
.sidebar-item:hover::before { opacity: 1; }
.sidebar-item:hover svg { transform: scale(1.1); }
.sidebar-item svg {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  transition: transform .35s cubic-bezier(.34,1.56,.64,1);
}

.sidebar-item.active {
  color: #fff;
  font-weight: 600;
  background: linear-gradient(135deg, rgba(35,156,196,.18), rgba(35,156,196,.06));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 4px 16px rgba(35,156,196,.12);
}

.sidebar-item.active .sidebar-indicator {
  position: absolute;
  right: -2px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--accent), #F5C842);
  box-shadow: 0 0 10px rgba(212,160,23,.45), 0 0 20px rgba(212,160,23,.15);
  animation: activeIndicator 2.5s ease-in-out infinite;
}
@keyframes activeIndicator {
  0%, 100% { opacity: .6; transform: scaleY(1); }
  50% { opacity: 1; transform: scaleY(1.3); }
}

.sidebar-item .badge {
  margin-right: auto;
  font-size: .65rem;
  padding: 2px 8px;
  min-width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--error), #DC2626);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(239,68,68,.35);
  flex-shrink: 0;
}

/* ── Footer ── */
.sidebar-footer {
  padding: 10px 8px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.sidebar-footer .sidebar-item { color: rgba(255,255,255,.45); font-size: .82rem; }
.sidebar-footer .sidebar-item:hover { color: var(--error); transform: none; }
.sidebar-footer .sidebar-item:hover::before { background: linear-gradient(135deg, rgba(239,68,68,.1), transparent); }

.sidebar-support {
  padding: 4px 0 8px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  margin-bottom: 6px;
}
.sidebar-support .sidebar-support-item { color: rgba(255,255,255,.5); font-size: .78rem; }
.sidebar-support .sidebar-support-item:hover { color: #25D366; transform: none; }
.sidebar-support .sidebar-support-item:hover::before { background: linear-gradient(135deg, rgba(37,211,102,.08), transparent); }
.sidebar-support .sidebar-support-item svg { width: 14px; height: 14px; }
.sidebar.collapsed .sidebar-support { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 2px 0; }

/* ── Collapse button (inside sidebar, bottom) ── */
.sidebar-collapse-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 10px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,.35);
  cursor: pointer;
  transition: color .3s ease;
  border-top: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.sidebar-collapse-btn:hover { color: rgba(255,255,255,.7); }
.sidebar-collapse-btn svg { transition: transform .3s ease; }
.sidebar.collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }

/* ── Staggered entrance ── */
.sidebar-nav .sidebar-item {
  animation: sidebarItemIn .5s cubic-bezier(.16,1,.3,1) backwards;
}
@keyframes sidebarItemIn {
  from { opacity: 0; transform: translateX(24px) scale(.95); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}


/* ── Collapsed state (desktop/tablet) ── */
.sidebar.collapsed {
  width: var(--sidebar-coll-w);
}
.sidebar.collapsed .sidebar-brand { justify-content: center; padding: 18px 8px 14px; }
.sidebar.collapsed .sidebar-brand-text { display: none; }
.sidebar.collapsed .sidebar-logo { width: 32px; }
.sidebar.collapsed .sidebar-user { justify-content: center; padding: 14px 8px; }
.sidebar.collapsed .sidebar-user-info { display: none; }
.sidebar.collapsed .sidebar-user-avatar { width: 32px; height: 32px; }
.sidebar.collapsed .sidebar-section-title { visibility: hidden; height: 0; padding: 0; margin: 0; }
.sidebar.collapsed .sidebar-section-title::after { display: none; }
.sidebar.collapsed .sidebar-item { justify-content: center; padding: 10px 0; border-radius: 8px; margin: 2px 6px; }
.sidebar.collapsed .sidebar-label { display: none; }
.sidebar.collapsed .badge { display: none !important; }
.sidebar.collapsed .sidebar-footer .sidebar-item { justify-content: center; padding: 10px 0; border-radius: 8px; margin: 2px 6px; }
.sidebar.collapsed .sidebar-footer .sidebar-label { display: none; }
.sidebar.collapsed .sidebar-indicator { display: none; }
.sidebar.collapsed .sidebar-item.active { margin: 2px 6px; }


/* ═══════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════ */

.main-content {
  flex: 1;
  margin-right: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg);
  transition: margin-right .3s ease;
}

.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 30px;
  background: var(--card);
  border-bottom: 1px solid var(--card-border);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(20px);
  will-change: transform;
}
.main-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.main-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Mobile toggle button (in header) - visible on all sizes */
.sidebar-mobile-toggle {
  display: flex;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--bg-alt);
  color: var(--text-secondary);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}
.sidebar-mobile-toggle:hover {
  background: var(--primary-glow);
  color: var(--primary);
}
.sidebar-mobile-toggle svg {
  width: 20px;
  height: 20px;
  transition: transform .3s ease;
}

.header-search { position: relative; }
.header-search input {
  padding: 8px 36px 8px 12px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-full);
  background: var(--bg);
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--text);
  width: 240px;
  transition: var(--transition);
}
.header-search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  width: 300px;
}
.header-search .search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  width: 16px;
  height: 16px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--bg-alt);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  font-size: 1.1rem;
  position: relative;
}
.icon-btn:hover {
  background: var(--primary-glow);
  color: var(--primary);
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn .notif-dot {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 8px;
  height: 8px;
  background: var(--error);
  border-radius: 50%;
  border: 2px solid var(--card);
}

.page-content { padding: 24px 30px; }
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  color: var(--secondary);
}
.page-title small {
  display: block;
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 400;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 30px;
}
.stat-card { padding: 20px; display: flex; align-items: center; gap: 16px; }
.stat-card-icon {
  width: 48px; height: 48px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0;
}
.stat-card-icon.primary { background: var(--primary-glow); }
.stat-card-icon.success { background: var(--success-bg); }
.stat-card-icon.accent { background: rgba(212,160,23,0.15); }
.stat-card-icon.error { background: var(--error-bg); }
.stat-card-info h3 {
  font-size: 1.6rem; font-weight: 800; color: var(--secondary);
  font-family: var(--font-heading); line-height: 1;
}
.stat-card-info p { font-size: 0.82rem; color: var(--text-muted); margin-top: 2px; }

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 20px; margin-bottom: 30px;
}
.chart-card { padding: 20px; }
.chart-card h3 { font-family: var(--font-heading); font-size: 1rem; color: var(--secondary); margin-bottom: 16px; }
.chart-container { position: relative; height: 250px; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: right; padding: 12px 16px; font-size: 0.78rem;
  font-weight: 600; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.5px; border-bottom: 2px solid var(--bg-alt);
}
.data-table td { padding: 12px 16px; font-size: 0.9rem; border-bottom: 1px solid var(--bg-alt); color: var(--text); }
.data-table tr:hover td { background: var(--bg-alt); }
.data-table .user-cell { display: flex; align-items: center; gap: 10px; }
.data-table .user-cell img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.table-actions { display: flex; gap: 6px; }
.table-actions .btn { padding: 4px 12px; font-size: 0.78rem; }

.pagination {
  display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: 20px;
}
.pagination button {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1px solid var(--card-border); background: var(--card);
  color: var(--text-secondary); cursor: pointer; font-family: var(--font-body);
  transition: var(--transition);
}
.pagination button:hover, .pagination button.active {
  background: var(--primary); color: white; border-color: var(--primary);
}

.activity-feed { display: flex; flex-direction: column; gap: 12px; }
.activity-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: var(--radius-sm); transition: var(--transition); }
.activity-item:hover { background: var(--bg-alt); }
.activity-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.activity-dot.success { background: var(--success); }
.activity-dot.primary { background: var(--primary); }
.activity-dot.accent { background: var(--accent); }
.activity-dot.error { background: var(--error); }
.activity-content { flex: 1; min-width: 0; }
.activity-content p { font-size: 0.88rem; color: var(--text); margin-bottom: 2px; }
.activity-content small { font-size: 0.75rem; color: var(--text-muted); }

.tabs {
  display: flex; gap: 4px; background: var(--bg-alt); padding: 4px;
  border-radius: var(--radius-md); margin-bottom: 24px; overflow-x: auto;
}
.tab-btn {
  padding: 8px 20px; border: none; background: transparent; color: var(--text-secondary);
  font-family: var(--font-body); font-size: 0.85rem; font-weight: 500;
  cursor: pointer; border-radius: var(--radius-sm); transition: var(--transition); white-space: nowrap;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { background: var(--card); color: var(--primary); box-shadow: var(--shadow-sm); }

.filter-bar { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.filter-bar .input-field { width: auto; min-width: 200px; }

.notifications-list { display: flex; flex-direction: column; gap: 8px; }
.notification-item { display: flex; gap: 14px; align-items: flex-start; padding: 16px 20px; transition: var(--transition); }
.notification-item:hover { border-color: var(--primary); }
.notif-icon { width: 40px; height: 40px; border-radius: 50%; background: var(--primary-glow); color: var(--primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.notif-icon svg { width: 20px; height: 20px; }
.notif-content { flex: 1; min-width: 0; }
.notif-content h4 { font-family: var(--font-heading); font-size: 0.9rem; color: var(--text); margin-bottom: 2px; }
.notif-content p { font-size: 0.83rem; color: var(--text-secondary); line-height: 1.5; }
.notif-date { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; display: block; }

/* @keyframes spin defined in design-system.css — duplicate removed */


/* ═══════════════════════════════════════
   SIDEBAR OVERLAY
   ═══════════════════════════════════════ */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
  opacity: 0;
  transition: opacity .35s ease;
  pointer-events: none;
}
.sidebar-overlay.show {
  display: block;
  opacity: 1;
  pointer-events: auto;
}


/* ═══════════════════════════════════════
   RESPONSIVE: MOBILE (≤820px)
   ═══════════════════════════════════════ */

@media (max-width: 820px) {
  .sidebar {
    width: 280px;
    transform: translateX(100%);
    transition: transform .35s cubic-bezier(.4,0,.2,1);
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: -8px 0 60px rgba(0,0,0,.5);
  }
  .sidebar.collapsed {
    width: 280px;
    transform: translateX(100%);
  }
  .sidebar.collapsed.open {
    transform: translateX(0);
  }
  .sidebar-collapse-btn { display: none; }

  .sidebar-overlay { display: block; }

  .main-content { margin-right: 0 !important; }
  .main-header { padding: 12px 16px; }
  .page-content { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .charts-grid { grid-template-columns: 1fr; }
  .header-search input { width: 160px; }
  .header-search input:focus { width: 200px; }
  .filter-bar { flex-direction: column; }
  .filter-bar .input-field { width: 100%; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}


/* ═══════════════════════════════════════
   RESPONSIVE: TABLET (821–1024px)
   ═══════════════════════════════════════ */

@media (min-width: 821px) and (max-width: 1024px) {
  .sidebar {
    width: var(--sidebar-coll-w);
  }
  .sidebar:not(.collapsed) {
    width: var(--sidebar-w);
  }

  .sidebar-collapse-btn { display: flex; }

  /* Collapsed by default at this range */
  .sidebar.collapsed .sidebar-brand { justify-content: center; padding: 18px 8px 14px; }
  .sidebar.collapsed .sidebar-brand-text { display: none; }
  .sidebar.collapsed .sidebar-user { justify-content: center; padding: 14px 8px; }
  .sidebar.collapsed .sidebar-user-info { display: none; }
  .sidebar.collapsed .sidebar-item { justify-content: center; padding: 10px 0; margin: 2px 6px; border-radius: 8px; }
  .sidebar.collapsed .sidebar-label { display: none; }
  .sidebar.collapsed .badge { display: none !important; }

  /* Expanded override */
  .sidebar:not(.collapsed) .sidebar-brand { justify-content: flex-start; padding: 18px 20px 14px; }
  .sidebar:not(.collapsed) .sidebar-brand-text { display: revert; }
  .sidebar:not(.collapsed) .sidebar-user { justify-content: flex-start; padding: 14px 20px; }
  .sidebar:not(.collapsed) .sidebar-user-info { display: revert; }
  .sidebar:not(.collapsed) .sidebar-item { justify-content: flex-start; padding: 10px 12px; margin: 2px 0; border-radius: 10px; }
  .sidebar:not(.collapsed) .sidebar-label { display: revert; }
}


/* ═══════════════════════════════════════
   RESPONSIVE: DESKTOP (≥1025px)
   ═══════════════════════════════════════ */

@media (min-width: 1025px) {
  .sidebar-collapse-btn { display: flex; }
}


/* ═══════════════════════════════════════
   iOS SAFARI FIX
   ═══════════════════════════════════════ */

@supports (-webkit-overflow-scrolling: touch) {
  .sidebar {
    position: fixed;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
  }
}

