/* ==========================================================================
   SISTEM ARSIP DIGITAL DESA SUNGAI RAYA UTARA
   Layout & Responsive Styles
   Mobile-first & Desktop-refined
   ========================================================================== */

/* Main App Container & Viewport Leak Containment */
html,
body {
  max-width: 100vw;
  overflow-x: clip;
}

.app-container {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  max-width: 100vw;
  position: relative;
  background-color: var(--bg-app);
}

/* ==========================================================================
   SIDEBAR (Admin Dashboard)
   ========================================================================== */
.sidebar {
  width: 230px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  transition: transform var(--transition-smooth);
}

.sidebar-header {
  padding: 16px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  padding: 3px 5px;
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-fast);
}

.brand:hover {
  background-color: rgba(241, 245, 249, 0.7);
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(30, 64, 175, 0.2), 0 1px 2px rgba(15, 23, 42, 0.05);
  flex-shrink: 0;
  cursor: pointer;
  will-change: transform;
}

.brand-icon svg,
.brand-icon img,
.brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 9px;
}

.brand-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.brand-title {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Plus Jakarta Sans", sans-serif;
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.brand-subtitle {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Plus Jakarta Sans", sans-serif;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 1px;
}

/* Sidebar Action Button (+ Tambah Arsip) inspired by reference UI */
.sidebar-action-wrap {
  padding: 8px 12px 12px;
}

.btn-sidebar-add {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8.5px 14px;
  background: linear-gradient(135deg, #1E40AF 0%, #2563EB 100%);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.28);
}

.btn-sidebar-add:hover {
  background: linear-gradient(135deg, #1D4ED8 0%, #3B82F6 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.38);
}

.btn-sidebar-add:active {
  transform: translateY(0);
}

.btn-sidebar-add .add-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}

.add-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.dot-amber { background: #FBBF24; }
.dot-cyan  { background: #38BDF8; }
.dot-rose  { background: #F43F5E; }

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  padding: 4px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 8px 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7.5px 10px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12.5px;
  transition: all var(--transition-fast);
  cursor: pointer;
  border: 1px solid transparent;
}

.nav-link:hover {
  background: #F1F5F9;
  color: var(--text-main);
}

.nav-link.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
  border-color: var(--primary-border);
}

.nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: #E2E8F0;
  color: var(--text-body);
}

.nav-link.active .nav-badge {
  background: var(--primary);
  color: #FFFFFF;
}

/* Sidebar Footer / Motion Ticker Card */
.sidebar-footer {
  padding: 10px 12px 14px;
  border-top: 1px solid var(--border-subtle);
}

.motion-ticker-card {
  background: linear-gradient(135deg, #F8FAFC 0%, #EFF6FF 100%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all var(--transition-base);
  cursor: default;
}

.motion-ticker-card:hover {
  border-color: var(--primary-border);
  box-shadow: 0 4px 12px rgba(30, 64, 175, 0.08);
}

.motion-ticker-header {
  display: flex;
  align-items: center;
  gap: 7px;
}

.motion-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10B981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
  flex-shrink: 0;
}

.motion-ticker-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #1E40AF;
  white-space: nowrap;
}

.btn-sidebar-sync {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  border: 1px solid #BFDBFE;
  background: #EFF6FF;
  color: var(--primary);
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 1px 2px rgba(30, 64, 175, 0.06);
}

.btn-sidebar-sync:hover {
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
  box-shadow: 0 3px 8px rgba(30, 64, 175, 0.25);
  transform: translateY(-1px);
}

.btn-sidebar-sync:active {
  transform: translateY(0);
}

.btn-sidebar-sync.syncing #cloud-sync-icon {
  animation: spin 1s linear infinite;
}

.portal-cloud-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-body);
  box-shadow: var(--shadow-sm);
  margin-top: 10px;
}

.motion-ticker-viewport {
  height: 18px;
  overflow: hidden;
  position: relative;
}

.motion-ticker-text {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  line-height: 18px;
}

/* ==========================================================================
   MAIN CONTENT AREA
   ========================================================================== */
.main-wrapper {
  flex: 1;
  margin-left: 230px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  min-width: 0;
  max-width: 100%;
  transition: margin-left var(--transition-smooth);
}

/* Public Portal Mode: No sidebar margin */
.main-wrapper.full-width {
  margin-left: 0;
}

/* Top Navigation Bar */
.topbar {
  height: 58px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 30;
  -webkit-transform: translate3d(0, 0, 0);
  transform: translate3d(0, 0, 0);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.btn-menu-toggle {
  display: none;
  background: transparent;
  border: none;
  padding: 6px;
  border-radius: var(--radius-md);
  color: var(--text-main);
  cursor: pointer;
}

.topbar-heading {
  display: flex;
  flex-direction: column;
}

.page-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: 11.5px;
  color: var(--text-muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Search Box Pill in Header (Reference UI style) */
.header-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  width: 240px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: all var(--transition-fast);
}

.header-search:hover {
  border-color: var(--border-strong);
}

.header-search:focus-within {
  background: #FFFFFF;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14), 0 2px 6px rgba(0, 0, 0, 0.05);
  width: 280px;
}

.header-search input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 12.5px;
  width: 100%;
  color: var(--text-main);
}

.header-search input::placeholder {
  color: var(--text-light);
}

.kbd-shortcut {
  font-size: 10px;
  font-weight: 600;
  background: #E2E8F0;
  color: var(--text-muted);
  padding: 2px 5px;
  border-radius: 4px;
}

/* Cloud Sync Button & Indicator */
.btn-cloud-sync {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border-subtle);
  background: #FFFFFF;
  color: var(--text-body);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-cloud-sync:hover {
  background: #F1F5F9;
  border-color: var(--border-strong);
}

.btn-cloud-sync.syncing #cloud-sync-icon {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.cloud-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94A3B8;
  display: inline-block;
  transition: all var(--transition-fast);
}

.cloud-status-dot.online {
  background: #10B981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

.cloud-status-dot.syncing {
  background: #3B82F6;
  box-shadow: 0 0 6px rgba(59, 130, 246, 0.6);
}

.cloud-status-dot.offline {
  background: #F59E0B;
}

.cloud-status-dot.error {
  background: #EF4444;
}

/* Portal Mode Toggle & User Profile Pill */
.btn-portal-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid #0284C7;
  background: #0284C7;
  color: #FFFFFF;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.28);
}

.btn-portal-switch .icon {
  color: #FFFFFF;
}

.btn-portal-switch:hover {
  background: #0369A1;
  border-color: #0369A1;
  color: #FFFFFF;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.38);
}

.user-profile-wrap {
  position: relative;
}

.user-profile-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 5px;
  background: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.user-profile-pill:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3B82F6 0%, #1D4ED8 100%);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.user-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.user-role-badge {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: #EFF6FF;
  color: #1E40AF;
}

.user-dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 220px;
  background: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 50;
  display: none;
  flex-direction: column;
  gap: 2px;
}

.user-dropdown-menu.show {
  display: flex;
}

.user-dropdown-header {
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 4px;
}

.user-dropdown-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  display: block;
}

.user-dropdown-role {
  font-size: 11px;
  color: var(--text-muted);
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-body);
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background-color var(--transition-fast);
}

.user-dropdown-item:hover {
  background: #F1F5F9;
  color: var(--text-main);
}

.user-dropdown-item.text-danger {
  color: var(--accent-rose);
}

.user-dropdown-item.text-danger:hover {
  background: #FEF2F2;
}

.user-dropdown-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 3px 0;
}

/* Page Content Viewport */
.content-body {
  flex: 1;
  padding: 16px 20px 32px;
  max-width: 1600px;
  width: 100%;
}

/* View Sections */
.view-section {
  display: none;
}

.view-section.active {
  display: block;
}

/* Section Headers */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
  flex-wrap: wrap;
}

.section-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.section-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.015em;
}

.section-desc {
  font-size: 12px;
  color: var(--text-muted);
}

/* Portal Filter Bar Controls */
.portal-content-header {
  position: relative;
  z-index: 40;
}

.portal-filter-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  min-width: 0;
  position: relative;
  z-index: 50;
  overflow: visible;
}

.portal-filter-scroll {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.portal-filter-scroll::-webkit-scrollbar {
  display: none;
}

.portal-filter-scroll .tab-btn {
  flex-shrink: 0;
  white-space: nowrap;
}

/* Responsive Grid Containers */
.grid-mini-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.grid-folders {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.grid-notes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.grid-albums {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.grid-stats {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

/* Taste Skill & High-End Visual Design: Asymmetrical Executive Bento Stat Layout */
.grid-stats.bento-stats-executive {
  display: grid;
  grid-template-columns: 2.2fr repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 22px;
  align-items: stretch;
}

@media (max-width: 1280px) {
  .grid-stats.bento-stats-executive {
    grid-template-columns: 2.2fr repeat(3, 1fr);
  }
  .grid-stats.bento-stats-executive .stat-card-hero {
    grid-row: span 2;
  }
}

@media (max-width: 1024px) {
  .grid-stats {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }
  .grid-stats.bento-stats-executive {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .grid-stats.bento-stats-executive .stat-card-hero {
    grid-column: span 2;
    grid-row: auto;
  }
}

@media (max-width: 640px) {
  .grid-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .grid-stats.bento-stats-executive {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .grid-stats.bento-stats-executive .stat-card-hero {
    grid-column: span 2;
  }
}

@media (max-width: 440px) {
  .grid-stats,
  .grid-stats.bento-stats-executive {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .grid-stats.bento-stats-executive .stat-card-hero {
    grid-column: span 1;
  }
}

/* ==========================================================================
   DASHBOARD BENTO GRID SYSTEM (UI/UX PRO MAX & TASTE SKILL)
   ========================================================================== */

/* Bento Hero Banner with Double-Bezel Specular Finish */
.dashboard-hero-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: linear-gradient(135deg, #FFFFFF 0%, #F8FAFC 100%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-bezel-outer);
  padding: 16px 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-specular), var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.dashboard-hero-banner::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, #1E40AF 0%, #3B82F6 100%);
  border-radius: 4px 0 0 4px;
}

.hero-greeting-box {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.hero-greeting-time {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
}

.hero-greeting-title {
  margin: 0;
  line-height: 1.15;
}

.hero-greeting-name {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.15;
  background: linear-gradient(135deg, #1E40AF 0%, #2563EB 50%, #0284C7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: inline-block;
  will-change: transform, opacity, filter;
}

.hero-greeting-date {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 1px;
}

.hero-quick-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

/* Taste Skill: Button-in-Button Capsule Architecture */
.btn-quick-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 7px;
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-spring);
  white-space: nowrap;
  border: 1px solid transparent;
  box-shadow: var(--shadow-xs);
}

.btn-quick-action-icon-wrap {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  backdrop-filter: blur(4px);
  transition: transform var(--transition-fast);
}

.btn-quick-action:hover .btn-quick-action-icon-wrap {
  transform: scale(1.12);
}

.btn-quick-action .icon {
  width: 13px;
  height: 13px;
  color: #FFFFFF;
}

.btn-quick-action.action-surat {
  background: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
  color: #FFFFFF;
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.28);
}

.btn-quick-action.action-surat:hover {
  background: linear-gradient(135deg, #1D4ED8 0%, #1E40AF 100%);
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.38);
}

.btn-quick-action.action-doc {
  background: linear-gradient(135deg, #DC2626 0%, #B91C1C 100%);
  color: #FFFFFF;
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 3px 10px rgba(220, 38, 38, 0.28);
}

.btn-quick-action.action-doc:hover {
  background: linear-gradient(135deg, #B91C1C 0%, #991B1B 100%);
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 18px rgba(220, 38, 38, 0.38);
}

.btn-quick-action.action-act {
  background: linear-gradient(135deg, #7C3AED 0%, #6D28D9 100%);
  color: #FFFFFF;
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 3px 10px rgba(124, 58, 237, 0.28);
}

.btn-quick-action.action-act:hover {
  background: linear-gradient(135deg, #6D28D9 0%, #5B21B6 100%);
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.38);
}

.btn-quick-action.action-ai {
  background: linear-gradient(135deg, #6366F1 0%, #4F46E5 100%);
  color: #FFFFFF;
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 3px 10px rgba(99, 102, 241, 0.3);
}

.btn-quick-action.action-ai:hover {
  background: linear-gradient(135deg, #4F46E5 0%, #4338CA 100%);
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.42);
}

/* Bento 2-Kolom Container */
.dashboard-bento-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  align-items: start;
}

.dashboard-bento-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.dashboard-bento-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 76px;
}

@media (max-width: 1024px) {
  .dashboard-bento-layout {
    grid-template-columns: 1fr;
  }
  .dashboard-bento-side {
    position: static;
  }
}

@media (max-width: 768px) {
  .dashboard-hero-banner {
    flex-direction: column;
    align-items: stretch;
    padding: 18px 20px;
  }
  .hero-quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .btn-quick-action {
    justify-content: center;
    padding: 8px 12px;
    font-size: 12px;
  }
}

/* Backdrop for Mobile Drawer */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  z-index: 35;
}

/* ==========================================================================
   PUBLIC PORTAL SPECIFIC LAYOUT
   ========================================================================== */
.portal-navbar {
  height: 58px;
  background: #FFFFFF;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.portal-hero {
  padding: 24px 16px 14px;
  text-align: center;
  max-width: 780px;
  margin: 0 auto;
  position: relative;
}

/* Apple Pure Minimalist Hero Title (Option A) */
.portal-hero h1,
.portal-hero-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
  text-wrap: balance;
}

/* Brand Heading (Besar, Bold, Dominan Ala Apple - Executive Royal Blue) */
.hero-line-brand {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1.1;
  background: linear-gradient(135deg, #1E40AF 0%, #2563EB 45%, #0284C7 80%, #38BDF8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: inline-block;
  padding-bottom: 2px;
  will-change: transform, opacity, filter;
}

/* Subtitle (Medium, Slate-600, Elegan) */
.hero-line-subtitle {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.018em;
  line-height: 1.45;
  color: #475569;
  max-width: 620px;
  will-change: transform, opacity, filter;
}

.portal-search-container {
  max-width: 580px;
  margin: 0 auto;
  position: relative;
  display: flex;
  align-items: center;
}

.portal-search-input {
  width: 100%;
  padding: 11px 126px 11px 44px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #FFFFFF;
  font-size: 13.5px;
  letter-spacing: -0.01em;
  box-shadow: 0 4px 18px -2px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(0, 0, 0, 0.02);
  outline: none;
  transition: all var(--transition-base);
}

.portal-search-input:focus {
  border-color: #6366F1;
  background: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15), 0 8px 26px -4px rgba(99, 102, 241, 0.12);
}

.portal-search-icon {
  position: absolute;
  left: 17px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 16px;
  height: 16px;
  pointer-events: none;
}

/* Hero Tanya AI Button (Google AI Mode Trigger) */
.btn-portal-hero-ai {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6.5px 14px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  border: 1px solid rgba(99, 102, 241, 0.28);
  background: linear-gradient(135deg, #6366F1 0%, #4F46E5 100%);
  color: #FFFFFF;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.32);
}

.btn-portal-hero-ai:hover {
  transform: translateY(-50%) scale(1.02);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.44);
  background: linear-gradient(135deg, #4F46E5 0%, #4338CA 100%);
}

.btn-portal-hero-ai .icon {
  width: 13px;
  height: 13px;
  color: #FDE047;
}

/* AI Assistant Topbar Back Button & Mode Badge */
.btn-ai-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 13px;
  font-size: 12px;
  font-weight: 700;
  border-radius: var(--radius-pill);
  background: #FFFFFF;
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.btn-ai-back:hover {
  background: #F8FAFC;
  border-color: #CBD5E1;
  color: var(--primary);
  transform: translateX(-2px);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.btn-ai-back .icon {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  transition: transform var(--transition-fast), color var(--transition-fast);
}

.btn-ai-back:hover .icon {
  transform: translateX(-2px);
  color: var(--primary);
}

.ai-topbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border-subtle);
  margin: 0 2px;
}

.ai-topbar-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-mode-pill {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: #EEF2FF;
  color: #4338CA;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

@media (max-width: 768px) {
  /* Di smartphone, sembunyikan tombol kembali karena sudah ada tab Portal di bottom nav */
  #btn-back-to-portal,
  .ai-topbar-divider {
    display: none !important;
  }
}

@media (max-width: 640px) {
  .portal-search-input {
    padding-right: 110px;
    font-size: 12.5px;
  }
  .btn-portal-hero-ai span:not(.icon) {
    font-size: 11px;
  }
  .ai-mode-pill {
    display: none;
  }
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS (SMARTPHONE & TABLET UI/UX PRO MAX)
   Inspiration: Modern Health App Architecture (Ergonomic, Touch-first, Ponytail)
   ========================================================================== */

/* ─── Base Mobile & Touch Enhancements ───────────────────────────────────── */
.mobile-location-wrap {
  display: none;
}

.mobile-location-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  touch-action: manipulation;
  transition: all var(--transition-fast);
}

.mobile-location-pill:active {
  transform: scale(0.97);
  background: var(--bg-app);
}

.mobile-location-arrow {
  font-size: 10px;
  color: var(--text-muted);
}

.mobile-carousel-dots {
  display: none;
}

/* ─── Tablet Viewports (769px – 1024px) ─────────────────────────────────── */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop.active {
    display: block;
  }

  .main-wrapper {
    margin-left: 0;
  }

  .btn-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
  }

  .header-search {
    width: 200px;
  }

  .content-body {
    padding: 22px 20px 48px;
  }

  /* Balanced Tablet Grids */
  .grid-stats {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }

  .grid-folders {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }

  .grid-notes {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }

  .grid-albums {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }

  .dashboard-bento-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .dashboard-bento-side {
    position: static;
  }
}

/* ─── Smartphone Viewports (<= 768px) ────────────────────────────────────── */
@media (max-width: 768px) {
  /* Ergonomic Topbar */
  .topbar {
    padding: env(safe-area-inset-top, 0px) 14px 0 14px;
    height: calc(58px + env(safe-area-inset-top, 0px));
  }

  .topbar-heading {
    display: none;
  }

  .mobile-location-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    margin: 0 8px;
  }

  .header-search {
    display: none;
  }

  #label-portal-switch {
    display: none;
  }

  .btn-portal-switch {
    padding: 8px;
    border-radius: 50%;
    min-width: 38px;
    min-height: 38px;
    justify-content: center;
  }

  .user-name,
  .user-role-badge {
    display: none;
  }

  .user-profile-pill {
    padding: 4px;
    border-radius: 50%;
  }

  /* Viewport Padding with iOS Safe-Area clearance */
  .content-body {
    padding: 16px 14px calc(76px + env(safe-area-inset-bottom, 0px));
  }

  /* ── Reference Blue Hero Card: Upcoming Schedule / Desa Summary ── */
  .dashboard-hero-banner {
    flex-direction: column;
    align-items: stretch;
    background: linear-gradient(135deg, #1E40AF 0%, #2563EB 55%, #3B82F6 100%);
    color: #FFFFFF;
    border: none;
    border-radius: 20px;
    padding: 18px 16px 16px;
    box-shadow: 0 10px 24px -4px rgba(30, 64, 175, 0.35);
  }

  .dashboard-hero-banner::before {
    display: none;
  }

  .hero-greeting-time {
    color: rgba(255, 255, 255, 0.82);
    font-size: 10.5px;
    letter-spacing: 0.08em;
  }

  .hero-greeting-title,
  .hero-greeting-name {
    color: #FFFFFF;
    font-size: 20px;
    font-weight: 800;
    line-height: 1.2;
  }

  .hero-greeting-date {
    color: rgba(255, 255, 255, 0.88);
    font-size: 12px;
    margin-top: 2px;
  }

  .hero-quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 14px;
  }

  .btn-quick-action {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.35);
    color: #FFFFFF;
    border-radius: var(--radius-pill);
    font-weight: 600;
    justify-content: center;
    padding: 9px 12px;
    font-size: 12px;
    min-height: 44px;
    touch-action: manipulation;
    transition: background var(--transition-fast), transform var(--transition-fast);
  }

  .btn-quick-action:active {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(0.98);
  }

  .btn-quick-action .icon {
    color: #FFFFFF;
  }

  /* ── Reference Category Carousel: Horizontal Snap Scroll ── */
  .grid-folders {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 12px;
    padding: 4px 2px 8px;
    margin-bottom: 2px;
  }

  .grid-folders::-webkit-scrollbar {
    display: none;
  }

  .grid-folders .folder-card {
    flex: 0 0 115px;
    min-width: 115px;
    max-width: 125px;
    scroll-snap-align: start;
    text-align: center;
    border-radius: 18px;
    padding: 14px 8px 12px;
    background: #FFFFFF;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-xs);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  }

  .grid-folders .folder-card:active {
    transform: scale(0.96);
  }

  .grid-folders .folder-card-top {
    justify-content: center;
    margin-bottom: 8px;
  }

  .grid-folders .folder-btn-more {
    display: none;
  }

  .grid-folders .folder-icon-badge {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
  }

  .grid-folders .folder-card-bottom {
    text-align: center;
  }

  .grid-folders .folder-card-title {
    font-size: 11.5px;
    font-weight: 700;
    line-height: 1.25;
    margin-bottom: 2px;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .grid-folders .folder-card-meta {
    font-size: 10px;
    opacity: 0.8;
  }

  .grid-folders .dashed-action-card {
    flex: 0 0 115px;
    min-width: 115px;
    border-radius: 18px;
    padding: 14px 8px;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-align: center;
  }

  /* Carousel Pagination Dots */
  .mobile-carousel-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin: 6px 0 18px;
  }

  .mobile-carousel-dots .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--border-strong);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .mobile-carousel-dots .dot.active {
    width: 18px;
    border-radius: var(--radius-pill);
    background: var(--primary);
  }

  /* ── Reference Recent Cards: Clean White Stack ── */
  .grid-notes {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .note-card {
    border-radius: 16px;
    padding: 14px 16px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
    touch-action: manipulation;
  }

  .note-card:active {
    transform: scale(0.985);
  }

  .grid-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  /* ── Public Portal Mobile Refinement ── */
  .portal-hero {
    padding: 20px 10px 14px;
  }

  .portal-hero-title {
    gap: 6px;
    margin-bottom: 16px;
  }

  .hero-line-brand {
    font-size: 26px;
    line-height: 1.15;
  }

  .hero-line-subtitle {
    font-size: 13.5px;
    line-height: 1.35;
  }

  .portal-search-input {
    height: 48px;
    font-size: 13.5px;
    border-radius: var(--radius-pill);
    padding-left: 42px;
  }

  .portal-content-header {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .portal-filter-controls {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: visible;
    position: relative;
    z-index: 50;
  }

  #portal-filter-tabs,
  .portal-filter-scroll {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 6px;
    padding: 3px 2px 6px;
  }

  #portal-filter-tabs::-webkit-scrollbar,
  .portal-filter-scroll::-webkit-scrollbar {
    display: none;
  }

  #portal-filter-tabs .tab-btn,
  .portal-filter-scroll .tab-btn {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 6px 14px;
    min-height: 38px;
  }

  #portal-year-select {
    flex-shrink: 0;
    max-width: 125px;
    font-size: 12px !important;
  }

  /* ── Tanya AI Mobile Viewport Fitting (Strictly Fit to Screen) ── */
  .main-wrapper.ai-view-active .content-body {
    padding: 0 !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  #view-ai-assistant {
    height: calc(100dvh - 62px - env(safe-area-inset-bottom, 0px)) !important;
    height: calc(100vh - 62px - env(safe-area-inset-bottom, 0px)) !important;
    max-height: calc(100dvh - 62px - env(safe-area-inset-bottom, 0px)) !important;
    max-height: calc(100vh - 62px - env(safe-area-inset-bottom, 0px)) !important;
    min-height: 0;
    overflow: hidden !important;
  }

  .ai-immersive-view {
    height: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden !important;
  }

  .ai-view-topbar {
    padding: 8px 12px;
    margin-bottom: 8px;
    gap: 8px;
    max-width: 100%;
    min-width: 0;
  }

  .ai-topbar-left {
    gap: 8px;
    flex: 1;
    min-width: 0;
  }

  .ai-topbar-title {
    font-size: 13.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .ai-topbar-subtitle {
    display: none;
  }

  .ai-status-pill {
    padding: 2px 8px;
    font-size: 10px;
  }

  .ai-topbar-actions {
    gap: 6px;
    flex-shrink: 0;
  }

  .ai-topbar-actions button {
    padding: 5px 10px !important;
    font-size: 11px !important;
  }

  .ai-chat-thread {
    padding: 6px 2px 18px;
    gap: 12px;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
  }

  .ai-chat-msg {
    max-width: 100%;
    min-width: 0;
  }

  .ai-msg-bubble-assistant {
    max-width: calc(100% - 42px);
    min-width: 0;
    padding: 12px 14px;
    word-break: break-word;
    overflow-wrap: break-word;
  }

  .ai-msg-bubble-user {
    max-width: 85%;
    min-width: 0;
    padding: 10px 14px;
    word-break: break-word;
    overflow-wrap: break-word;
  }

  .ai-floating-input-container {
    padding: 4px 10px 8px;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .ai-input-bar {
    padding: 6px 8px 6px 14px;
    gap: 8px;
    max-width: 100%;
    min-width: 0;
  }

  .ai-input-field {
    font-size: 13.5px;
    min-width: 0;
  }

  .ai-btn-send {
    padding: 8px 14px;
    font-size: 12px;
    flex-shrink: 0;
  }

  .ai-input-disclaimer {
    font-size: 10px;
    padding: 2px 8px;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* ─── Compact Smartphone Viewports (<= 480px) ────────────────────────────── */
@media (max-width: 480px) {
  .mobile-location-name {
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .grid-stats {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .stat-card {
    padding: 12px 10px;
  }

  .stat-value {
    font-size: 18px;
  }

  .ai-topbar-actions button span:not(.icon) {
    display: none;
  }

  .ai-btn-send span:not(.icon) {
    display: none;
  }

  .ai-btn-send {
    padding: 8px 12px;
    border-radius: 50%;
  }
}
