/* assets/css/admin.css */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:    #1D9E75;
  --primary-dk: #157a5c;
  --ink:        #0d2b38;
  --muted:      #526672;
  --line:       #e4eaed;
  --bg:         #f4f7f9;
  --white:      #ffffff;
  --sidebar-w:  240px;
  --topbar-h:   58px;
  --danger:     #dc3545;
  --warning:    #f59e0b;
  --success:    #1D9E75;
  --purple:     #534AB7;
  --radius:     12px;
  --shadow:     0 2px 12px rgba(13,43,56,0.08);
}

body {
  font-family: 'Manrope', sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 0.9rem;
}

/* ════════════════════════════════════════
   DESKTOP LAYOUT (default ≥ 901px)
════════════════════════════════════════ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ─── Desktop Sidebar ─── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--ink);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width 0.25s ease;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.brand-logo-img {
  width: 38px; height: 38px;
  object-fit: contain;
  border-radius: 6px;
  background: white;
  padding: 2px;
  flex-shrink: 0;
}

.brand-text {
  color: white;
  font-weight: 700;
  font-size: 1rem;
}

.sidebar-toggle {
  margin-left: auto;
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
  line-height: 1;
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.12); color: #fff; }

/* Collapsed sidebar */
.sidebar.collapsed { width: 60px; }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .admin-info div,
.sidebar.collapsed .logout-btn span,
.sidebar.collapsed .badge { display: none; }
.sidebar.collapsed .brand-logo-img { margin: 0 auto; }
.sidebar.collapsed .sidebar-brand { justify-content: center; padding: 20px 8px; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }
.sidebar.collapsed .sidebar-footer { padding: 12px 8px; }
.sidebar.collapsed .admin-info { justify-content: center; }
.sidebar.collapsed .logout-btn { padding: 10px; justify-content: center; }

body.sidebar-collapsed .main-content { margin-left: 60px; }

/* ─── Desktop Main Content ─── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 24px;
  max-width: 100%;
  overflow-x: hidden;
  transition: margin-left 0.25s ease;
}

/* ─── Sidebar Nav ─── */
.sidebar-nav {
  flex: 1;
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.18s;
  position: relative;
  white-space: nowrap;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: white; }
.nav-item.active { background: var(--primary); color: white; }
.nav-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }
.nav-label { flex: 1; }
.nav-item .badge {
  background: #ef4444; color: white;
  font-size: 0.65rem; font-weight: 700;
  padding: 2px 6px; border-radius: 999px;
  min-width: 18px; text-align: center;
}

/* ─── Sidebar Footer ─── */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.admin-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.admin-avatar {
  width: 34px; height: 34px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 0.85rem;
  flex-shrink: 0;
}

.admin-name { color: white; font-weight: 600; font-size: 0.82rem; }
.admin-role { color: rgba(255,255,255,0.45); font-size: 0.72rem; }

/* ─── Logout Btn — ALWAYS VISIBLE ─── */
.logout-btn {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(220,53,69,0.3);
  text-decoration: none;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.15s;
  white-space: nowrap;
  background: rgba(220,53,69,0.12);
  color: #ff8a90;
}
.logout-btn svg { flex-shrink: 0; }
.logout-btn:hover {
  background: rgba(220,53,69,0.25);
  color: #ffb3b7;
  border-color: rgba(220,53,69,0.5);
  transform: translateY(-1px);
}

/* ════════════════════════════════════════
   MOBILE TOPBAR — hidden on desktop
════════════════════════════════════════ */
.mobile-topbar {
  display: none; /* shown via media queries below */
}

/* ─── Sidebar Overlay ─── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 299;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ════════════════════════════════════════
   PAGE CONTENT COMPONENTS
════════════════════════════════════════ */

/* ─── Page Header ─── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h2 { font-size: 1.5rem; font-weight: 800; }
.page-subtitle { color: var(--muted); font-size: 0.83rem; margin-top: 3px; }
.header-date { color: var(--muted); font-size: 0.82rem; }

/* ─── Stats ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
  border-left: 4px solid transparent;
}
.stat-blue   { border-color: #3b82f6; }
.stat-yellow { border-color: var(--warning); }
.stat-green  { border-color: var(--primary); }
.stat-purple { border-color: var(--purple); }
.stat-icon {
  font-size: 1.8rem;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  border-radius: 10px;
  flex-shrink: 0;
}
.stat-number { font-size: 1.7rem; font-weight: 800; line-height: 1; }
.stat-label  { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }
.stat-sub    { font-size: 0.72rem; color: var(--warning); font-weight: 600; margin-top: 2px; }

/* ─── Dashboard Grid ─── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.card-full { grid-column: 1 / -1; }

/* ─── Card ─── */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  gap: 8px;
}
.card-header h3 { font-size: 0.92rem; font-weight: 700; }
.card-link { font-size: 0.78rem; color: var(--primary); text-decoration: none; font-weight: 600; }
.card-body { padding: 16px 18px; }
.card-body.p0 { padding: 0; }

/* ─── Course Bars ─── */
.course-bar-item { margin-bottom: 14px; }
.course-bar-label {
  display: flex; justify-content: space-between;
  font-size: 0.8rem; margin-bottom: 5px; color: var(--muted);
}
.course-bar-label strong { color: var(--ink); }
.progress-bar { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; transition: width 0.6s ease; }

/* ─── Table ─── */
.table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-compact th, .table-compact td { white-space: nowrap; }
.table th {
  background: var(--bg); padding: 10px 14px; text-align: left;
  font-weight: 700; color: var(--muted); font-size: 0.75rem;
  text-transform: uppercase; letter-spacing: 0.3px; white-space: nowrap;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table-hover tbody tr:hover { background: #fafcfd; }
.row-unread { background: #fffbf0 !important; }
.cell-name { font-weight: 600; }
.cell-sub  { color: var(--muted); font-size: 0.76rem; }
.id-cell { color: var(--muted); font-size: 0.78rem; }
.address-cell { max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: help; }
.date-cell { white-space: nowrap; color: var(--muted); }
.msg-preview { max-width: 300px; color: var(--muted); }
.empty-state { text-align: center; color: var(--muted); padding: 30px !important; }

/* ─── Status Badges ─── */
.badge-status {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; text-transform: capitalize; white-space: nowrap;
}
.badge-pending  { background: #fef3c7; color: #92400e; }
.badge-reviewed { background: #dbeafe; color: #1e40af; }
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-rejected { background: #fee2e2; color: #991b1b; }

/* ─── Course Tag ─── */
.course-tag {
  background: #e4f2f0; color: var(--primary-dk);
  padding: 2px 8px; border-radius: 6px;
  font-size: 0.75rem; font-weight: 600; white-space: nowrap;
}

/* ─── Actions ─── */
.actions-cell { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; }
.btn-action {
  padding: 4px 10px; border-radius: 6px; font-size: 0.75rem; font-weight: 600;
  text-decoration: none; cursor: pointer; border: none; white-space: nowrap;
}
.btn-view   { background: #dbeafe; color: #1e40af; }
.btn-view:hover { background: #bfdbfe; }
.btn-delete { background: #fee2e2; color: #991b1b; }
.btn-delete:hover { background: #fecaca; }
.inline-select {
  padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px;
  font-size: 0.75rem; font-family: inherit; background: white; cursor: pointer;
}

/* ─── Filters ─── */
.filter-card { margin-bottom: 16px; }
.filter-form { display: flex; gap: 10px; align-items: center; padding: 14px 18px; flex-wrap: wrap; }
.filter-input, .filter-select {
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-family: inherit; font-size: 0.83rem; color: var(--ink); background: white;
  outline: none; transition: border-color 0.15s;
}
.filter-input { flex: 1; min-width: 200px; }
.filter-input:focus, .filter-select:focus { border-color: var(--primary); }

/* ─── Buttons ─── */
.btn {
  padding: 10px 20px; border-radius: 8px; font-family: inherit;
  font-size: 0.88rem; font-weight: 600; cursor: pointer; border: none;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
  white-space: nowrap; box-shadow: 0 2px 8px rgba(13,43,56,0.08); letter-spacing: 0.02em;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: white; box-shadow: 0 4px 12px rgba(29,158,117,0.24); }
.btn-primary:hover { background: var(--primary-dk); box-shadow: 0 6px 16px rgba(29,158,117,0.32); transform: translateY(-2px); }
.btn-outline { background: white; color: var(--ink); border: 1.5px solid var(--line); box-shadow: none; }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: rgba(29,158,117,0.04); }
.btn-block { width: 100%; justify-content: center; padding: 12px; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* ─── Alerts ─── */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 0.85rem; font-weight: 500; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* ─── Messages ─── */
.messages-list { display: flex; flex-direction: column; gap: 12px; }
.message-card { background: white; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; border-left: 4px solid var(--line); }
.message-unread { border-left-color: var(--primary); }
.message-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); gap: 12px; flex-wrap: wrap; }
.message-sender { display: flex; align-items: center; gap: 10px; }
.sender-avatar { width: 36px; height: 36px; background: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-weight: 700; font-size: 0.85rem; flex-shrink: 0; }
.sender-name { font-weight: 700; font-size: 0.88rem; }
.sender-email { color: var(--muted); font-size: 0.76rem; }
.unread-dot { width: 8px; height: 8px; background: var(--primary); border-radius: 50%; flex-shrink: 0; }
.message-meta { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.message-date { color: var(--muted); font-size: 0.76rem; }
.message-actions { display: flex; gap: 6px; }
.message-body { padding: 14px 18px; color: var(--ink); line-height: 1.65; }

/* ─── Export ─── */
.export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; max-width: 700px; }
.export-card { text-align: center; padding: 32px 24px !important; }
.export-card .card-body { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.export-icon { font-size: 2.5rem; }
.export-card h3 { font-size: 1.1rem; }
.export-card p { color: var(--muted); font-size: 0.83rem; }

/* ─── Modal ─── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(13,43,56,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; backdrop-filter: blur(2px); padding: 16px;
}
.modal-box { background: white; border-radius: var(--radius); width: 540px; max-width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(13,43,56,0.2); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--muted); line-height: 1; padding: 0 4px; }
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 20px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.detail-full { grid-column: 1 / -1; }
.detail-item label { display: block; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; color: var(--muted); letter-spacing: 0.3px; margin-bottom: 4px; }
.detail-item span { font-size: 0.88rem; color: var(--ink); }

/* ─── Login Page ─── */
.login-page { background: var(--ink); display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-wrapper { width: 100%; max-width: 400px; }
.login-card { background: white; border-radius: 16px; padding: 36px 32px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.login-logo { text-align: center; margin-bottom: 28px; }
.logo-img { width: 120px; height: 80px; object-fit: contain; border-radius: 12px; margin-bottom: 12px; }
.login-logo h1 { font-size: 1.3rem; font-weight: 800; }
.login-logo p  { color: var(--muted); font-size: 0.8rem; margin-top: 4px; }
.login-hint { text-align: center; margin-top: 14px; color: var(--muted); }

/* ─── Password Layout ─── */
.password-layout { max-width: 780px; }
.password-hero {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  margin-bottom: 18px; padding: 22px 24px; border-radius: 18px; color: #fff;
  background: radial-gradient(circle at top right, rgba(126,228,193,0.24), transparent 34%), linear-gradient(135deg,#163d50 0%,#1d9e75 100%);
  box-shadow: 0 18px 40px rgba(22,61,80,0.18); flex-wrap: wrap;
}
.password-eyebrow { display: inline-block; margin-bottom: 8px; padding: 5px 10px; border-radius: 999px; background: rgba(255,255,255,0.16); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.password-hero h3 { margin: 0 0 8px; font-size: 1.35rem; font-weight: 800; }
.password-hero p { margin: 0; max-width: 480px; color: rgba(255,255,255,0.86); font-size: 0.9rem; line-height: 1.65; }
.password-hero-badge { flex-shrink: 0; padding: 12px 16px; border-radius: 14px; background: rgba(255,255,255,0.14); border: 1px solid rgba(255,255,255,0.2); font-size: 0.82rem; font-weight: 700; color: #e7fff7; }
.password-card { background: #fff; border-radius: 18px; box-shadow: var(--shadow); padding: 28px; border: 1px solid rgba(22,61,80,0.08); }
.password-card h3 { margin: 0 0 8px; font-size: 1.1rem; color: var(--ink); }
.password-note { margin: 0 0 24px; color: var(--muted); font-size: 0.88rem; line-height: 1.6; }
.password-actions { display: flex; justify-content: flex-end; margin-top: 8px; }
.password-actions .btn { min-width: 180px; }

/* ─── Forms ─── */
.form-section { background: white; border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--shadow); }
.form-section h4 { font-size: 0.95rem; font-weight: 700; color: var(--ink); margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; margin-bottom: 16px; }
.form-group label { font-size: 0.78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 6px; display: block; }
.form-group input, .form-group select, .form-group textarea { padding: 10px 14px; border: 1.5px solid var(--line); border-radius: 8px; font-family: inherit; font-size: 0.88rem; color: var(--ink); background: #fbfcfc; outline: none; transition: border-color 0.15s, box-shadow 0.15s; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(29,158,117,0.12); }
.form-group textarea { resize: vertical; min-height: 80px; font-family: inherit; }
.checkbox-group { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.checkbox-group input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }
.checkbox-group label { font-size: 0.85rem; font-weight: 500; color: var(--ink); cursor: pointer; margin: 0; text-transform: none; letter-spacing: normal; }
.doc-row { display: grid; grid-template-columns: 200px 150px 1fr; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.doc-row:last-child { border-bottom: none; }
.doc-label { font-size: 0.85rem; font-weight: 600; color: var(--ink); }
.doc-row select { padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px; font-size: 0.82rem; background: white; cursor: pointer; }
.doc-row input[type="file"] { padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 0.78rem; background: white; cursor: pointer; }

/* ─── Status Badges ─── */
.status-badge { display: inline-block; padding: 4px 12px; border-radius: 6px; font-size: 0.75rem; font-weight: 700; text-transform: capitalize; }
.status-new_joiner { background: #dbeafe; color: #1e40af; }
.status-dropout { background: #fee2e2; color: #991b1b; }
.status-completed { background: #dcfce7; color: #16a34a; }
.status-internship_scheduled { background: #fef3c7; color: #92400e; }

/* ─── Action Menu ─── */
.header-actions { position: relative; }
.action-menu-btn { background: none; border: 1px solid transparent; font-size: 1.3rem; cursor: pointer; padding: 6px 8px; line-height: 1; transition: all 0.2s; color: var(--ink); border-radius: 6px; display: flex; align-items: center; justify-content: center; }
.action-menu-btn:hover { background: var(--line); border-color: var(--line); color: var(--primary); }
.action-menu-dropdown { display: none; position: absolute; top: calc(100% + 8px); right: 0; background: white; border-radius: 12px; box-shadow: 0 12px 40px rgba(13,43,56,0.18); min-width: 220px; z-index: 150; overflow: hidden; }
.action-menu-dropdown.active { display: block; }
.action-menu-item { display: flex; align-items: center; gap: 12px; padding: 11px 16px; text-decoration: none; color: var(--ink); font-size: 0.85rem; font-weight: 500; cursor: pointer; transition: all 0.15s; white-space: nowrap; border-left: 3px solid transparent; }
.action-menu-item:hover { background: #f8fafc; border-left-color: var(--primary); padding-left: 18px; }
.action-menu-item.primary { color: var(--primary); font-weight: 600; }
.action-menu-icon { font-size: 1rem; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.action-menu-item hr, .action-menu-dropdown hr { margin: 6px 0; border: none; border-top: 1px solid var(--line); }

/* ════════════════════════════════════════
   TABLET — 641px to 900px
════════════════════════════════════════ */
@media (max-width: 900px) {

  /* Hide the desktop sidebar off-screen */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
    z-index: 300;
    width: 260px !important;
  }

  /* Slide in when open */
  .sidebar.mobile-open {
    transform: translateX(0);
  }

  /* Main content: no left offset, push down below topbar */
  .main-content {
    margin-left: 0 !important;
    padding: calc(var(--topbar-h) + 20px) 20px 24px;
  }

  /* Show the mobile topbar */
  .mobile-topbar {
    display: flex;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: var(--ink);
    z-index: 301;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    box-shadow: 0 2px 12px rgba(13,43,56,0.2);
  }

  /* Grids */
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .export-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .doc-row { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }

  /* Logout always visible in sidebar on tablet */
  .logout-btn span { display: inline !important; }
}

/* ════════════════════════════════════════
   MOBILE — up to 640px
════════════════════════════════════════ */
@media (max-width: 640px) {

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
    z-index: 300;
    width: 270px !important;
  }

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

  .mobile-topbar {
    display: flex;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: var(--ink);
    z-index: 301;
    align-items: center;
    padding: 0 14px;
    gap: 10px;
    box-shadow: 0 2px 12px rgba(13,43,56,0.2);
  }

  .main-content {
    margin-left: 0 !important;
    padding: calc(var(--topbar-h) + 14px) 14px 24px;
  }

  /* Stats: 2 columns on mobile */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 12px; gap: 10px; }
  .stat-icon { width: 36px; height: 36px; font-size: 1.3rem; border-radius: 8px; }
  .stat-number { font-size: 1.3rem; }
  .stat-label { font-size: 0.72rem; }

  .dashboard-grid { grid-template-columns: 1fr; }
  .export-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .doc-row { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }

  .page-header h2 { font-size: 1.2rem; }
  .page-header { margin-bottom: 14px; }

  .filter-form { flex-direction: column; padding: 12px 14px; }
  .filter-input { min-width: 100%; width: 100%; }
  .filter-select { width: 100%; }

  .card-header { padding: 12px 14px; }
  .card-body { padding: 12px 14px; }

  .message-header { flex-direction: column; align-items: flex-start; }
  .message-meta { width: 100%; justify-content: space-between; }

  .password-hero { flex-direction: column; align-items: flex-start; padding: 18px; gap: 12px; }
  .password-hero h3 { font-size: 1.1rem; }
  .password-hero-badge { width: 100%; text-align: center; }
  .password-card { padding: 18px 14px; }
  .password-actions { flex-direction: column; }
  .password-actions .btn { width: 100%; min-width: unset; }

  .form-section { padding: 14px; }
  .login-card { padding: 28px 20px; }

  .logout-btn span { display: inline !important; }
}

/* ════════════════════════════════════════
   EXTRA SMALL — under 400px
════════════════════════════════════════ */
@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr; }
  .main-content { padding-left: 12px; padding-right: 12px; }
}

/* ════════════════════════════════════════
   MOBILE TOPBAR INTERNALS
════════════════════════════════════════ */

/* Hamburger button */
.hamburger-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 8px 6px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  transition: background 0.2s;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  align-items: center;
}
.hamburger-btn:hover { background: rgba(255,255,255,0.1); }
.hamburger-btn span {
  display: block;
  width: 22px;
  height: 2.5px;
  background: white;
  border-radius: 3px;
  transition: transform 0.3s ease, opacity 0.3s ease;
  transform-origin: center;
}
/* Animated X when open */
.hamburger-btn.open span:nth-child(1) { transform: translateY(7.5px) rotate(45deg); }
.hamburger-btn.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger-btn.open span:nth-child(3) { transform: translateY(-7.5px) rotate(-45deg); }

/* Brand in topbar */
.mobile-topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: white;
  font-weight: 700;
  font-size: 0.95rem;
  flex: 1;
  min-width: 0;
}
.mobile-topbar-brand img {
  width: 28px; height: 28px;
  object-fit: contain;
  border-radius: 5px;
  background: white;
  padding: 2px;
  flex-shrink: 0;
}
.mobile-topbar-brand span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Logout icon button in topbar */
.mobile-topbar-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: rgba(220,53,69,0.18);
  border: 1px solid rgba(220,53,69,0.35);
  color: #ff8a90;
  text-decoration: none;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}
.mobile-topbar-logout:hover {
  background: rgba(220,53,69,0.3);
  transform: scale(1.05);
}
.mobile-topbar-logout svg { display: block; }
