/* ===== Sidebar base styles (must come before media queries for cascade) ===== */
.sidebar-nav {
  display: none;
  position: sticky;
  top: 0;
  height: 100vh;
  width: var(--sidebar-width);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border-light);
  flex-direction: column;
  z-index: var(--z-nav);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--color-border-light);
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--color-primary), #764ba2);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-menu {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-muted);
  transition: background var(--transition-fast), color var(--transition-fast);
  text-align: left;
  width: 100%;
}

.sidebar-item:hover {
  background: var(--color-primary-bg);
  color: var(--color-primary);
}

.sidebar-item.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
}

.sidebar-item-icon {
  font-size: 18px;
  line-height: 1;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-item-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--color-border-light);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.sidebar-user:hover {
  background: var(--color-bg);
}

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

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.sidebar-user-role {
  font-size: 11px;
  color: var(--color-text-faint);
  line-height: 1.3;
}

/* ===== Desktop (>= 768px) ===== */
@media (min-width: 768px) {
  body { background: var(--color-bg-desktop); }
  .bottom-nav { display: none; }
  .fab, body.fab-visible .fab { display: none; }
  .view-back-btn { display: none; }
  .sidebar-nav { display: flex; }
  #page-app,
  #page-app.active {
    height: auto;
    overflow: visible;
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    max-width: none;
    min-height: 100vh;
  }
  .content-wrapper {
    height: auto;
    padding: 32px 40px 40px;
    max-width: none;
    width: 100%;
    flex: initial;
    min-height: 0;
    overflow: visible;
    overscroll-behavior: auto;
  }
  .task-grid { padding: 16px 0 40px; grid-template-columns: repeat(2, 1fr); }
  .reward-grid { grid-template-columns: repeat(4, 1fr); }
  .card-pack-grid { grid-template-columns: repeat(3, 1fr); }
  #view-wallet { padding-bottom: 0; }
  #view-mine { display: none; }
  .task-header { padding: 0 0 16px; }
  .import-box { padding: 0 0 40px; }
}

@media (min-width: 1100px) {
  .task-grid { grid-template-columns: repeat(3, 1fr); }
  .reward-grid { grid-template-columns: repeat(5, 1fr); }
  .card-pack-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 1500px) {
  .task-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 768px) and (max-width: 900px) {
  #page-app { grid-template-columns: 64px 1fr; }
  .sidebar-nav { width: 64px; }
  .sidebar-title, .sidebar-item-label, .sidebar-user-info { display: none; }
  .sidebar-header { justify-content: center; padding: 20px 10px 16px; }
  .sidebar-item { justify-content: center; padding: 10px; }
  .sidebar-user { justify-content: center; padding: 8px; }
  .content-wrapper { padding: 32px 24px 40px; }
}

@media (min-width: 768px) {
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-panel { padding: 24px; }
  #view-settings { padding: 0; }
  .view { padding: 0; }
}

@media (min-width: 1200px) {
  .dashboard-stats { grid-template-columns: repeat(6, 1fr); }
  .stat-value { font-size: 32px; }
}
