/* ══════════════════════════════════════════════════════════════
   仁和馬里蘭幼兒園 — 完整 RWD CSS
   Mobile-first，支援 320px ~ 1440px
   ══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;700&family=Nunito:wght@400;600;700;800&display=swap');

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --primary:       #E8426A;
  --primary-light: #F2678A;
  --primary-dark:  #C42D54;
  --secondary:     #C8A8E9;
  --lavender:      #EDE4F8;
  --lavender-mid:  #D8C8F0;
  --pink-light:    #FDE8EF;
  --pink-mid:      #F5C8D8;
  --white:         #FFFFFF;
  --gray-50:       #FAFAFA;
  --gray-100:      #F4F4F5;
  --gray-200:      #E4E4E7;
  --gray-400:      #A1A1AA;
  --gray-600:      #52525B;
  --gray-800:      #27272A;
  --text:          #2D2D3A;
  --text-muted:    #7C7C8E;
  --success:       #22C55E;
  --warning:       #F59E0B;
  --info:          #3B82F6;
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:     0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg:     0 8px 32px rgba(0,0,0,0.12);
  --radius:        16px;
  --radius-sm:     10px;
  --radius-xs:     6px;
  --nav-h:         56px;
  --bottom-h:      64px;
  --sidebar-w:     240px;
  /* safe area for notch phones */
  --safe-bottom:   env(safe-area-inset-bottom, 0px);
  --safe-top:      env(safe-area-inset-top, 0px);
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  font-family: 'Nunito', 'Noto Sans TC', sans-serif;
  background: var(--gray-100);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh; /* dynamic viewport for mobile */
  overscroll-behavior: none;
}

img, video { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
button { font-family: inherit; }

/* ── TOP NAV ────────────────────────────────────────────────── */
.top-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
  height: calc(var(--nav-h) + var(--safe-top));
  padding-top: var(--safe-top);
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 16px;
  padding-right: 16px;
  box-shadow: 0 2px 12px rgba(232,66,106,0.3);
}

.top-nav .nav-title {
  font-size: 16px;
  font-weight: 800;
  color: white;
  letter-spacing: 0.3px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-nav .nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* hamburger (mobile only) */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 8px;
  cursor: pointer;
  border: none;
  background: none;
  margin-right: 4px;
}
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: white;
  border-radius: 2px;
  transition: all 0.25s;
}
.hamburger.open span:nth-child(1) { transform: rotate(45deg) translate(5px,5px); }
.hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger.open span:nth-child(3) { transform: rotate(-45deg) translate(5px,-5px); }

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.2);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover, .icon-btn:active { background: rgba(255,255,255,0.35); }

/* notification badge on bell */
.icon-btn-wrap {
  position: relative;
  display: inline-flex;
}
.icon-btn-wrap .notif-dot {
  position: absolute;
  top: 2px; right: 2px;
  width: 10px; height: 10px;
  background: #FFD600;
  border-radius: 50%;
  border: 2px solid var(--primary);
}

/* ── SIDEBAR OVERLAY (mobile) ───────────────────────────────── */
.sidebar-overlay {
  display: none !important;
  pointer-events: none !important;
}

/* ── SIDEBAR ─────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: white;
  border-right: 1px solid var(--gray-200);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 150;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 12px rgba(0,0,0,0.05);
  padding-top: calc(var(--nav-h) + var(--safe-top));
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.sidebar-user {
  padding: 18px 16px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--pink-light);
}
.sidebar-user .avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--secondary), var(--primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
}
.sidebar-user .user-name  { font-size: 14px; font-weight: 700; color: var(--text); }
.sidebar-user .user-class { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.sidebar-nav  { padding: 10px 8px; flex: 1; }
.sidebar-section { margin-bottom: 4px; }
.sidebar-section-title {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 8px 10px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  color: var(--gray-600);
  font-size: 13px;
  font-weight: 500;
  position: relative;
  margin-bottom: 2px;
  -webkit-tap-highlight-color: transparent;
}
.nav-item:hover, .nav-item:active { background: var(--gray-100); color: var(--text); }
.nav-item.active { background: var(--pink-light); color: var(--primary); }
.nav-item .nav-icon { font-size: 17px; width: 22px; text-align: center; flex-shrink: 0; }
.nav-item .badge {
  margin-left: auto;
  background: var(--primary);
  color: white;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

/* ── MAIN CONTENT ───────────────────────────────────────────── */
.main-wrap {
  margin-top: calc(var(--nav-h) + var(--safe-top));
  margin-left: var(--sidebar-w);
  min-height: calc(100vh - var(--nav-h));
  padding: 20px;
}

/* ── BOTTOM NAV ─────────────────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--bottom-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: white;
  border-top: 1px solid var(--gray-200);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.10);
  z-index: 100;
}
.bottom-nav-inner {
  display: flex;
  align-items: stretch;
  height: var(--bottom-h);
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  color: var(--gray-400);
  transition: color 0.15s;
  font-size: 10px;
  font-weight: 700;
  position: relative;
  border: none;
  background: none;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  padding: 0 4px;
}
.bottom-nav-item.active  { color: var(--primary); }
.bottom-nav-item .bnav-icon {
  font-size: 22px;
  transition: transform 0.15s;
}
.bottom-nav-item.active .bnav-icon { transform: scale(1.1); }
.bottom-nav-item .badge {
  position: absolute;
  top: 4px; left: 50%;
  transform: translateX(6px);
  background: var(--primary);
  color: white;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 10px;
  min-width: 16px;
  text-align: center;
}

/* ── SECTION BLOCK ──────────────────────────────────────────── */
.section-block {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  overflow: hidden;
}
.section-block .block-header {
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 700;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-block .block-header .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--primary);
}

/* ── ICON GRID (home menu) ──────────────────────────────────── */
.icon-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
}
.icon-grid-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 8px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
  border-bottom: 1px solid var(--gray-100);
  border-right: 1px solid var(--gray-100);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.icon-grid-item:active { background: var(--gray-50); }
.icon-grid-item:nth-child(4n) { border-right: none; }
.icon-grid-item:last-child,
.icon-grid-item:nth-last-child(-n+4):nth-child(4n+1),
.icon-grid-item:nth-last-child(-n+4):nth-child(4n+2),
.icon-grid-item:nth-last-child(-n+4):nth-child(4n+3),
.icon-grid-item:nth-last-child(-n+4):nth-child(4n+4) { border-bottom: none; }
.icon-grid-item .icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.icon-grid-item .icon-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  line-height: 1.2;
}
.icon-grid-item .badge {
  position: absolute;
  top: 8px; left: 50%;
  transform: translateX(10px);
  background: var(--primary);
  color: white;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(232,66,106,0.35);
}
.icon-wrap.lavender { background: var(--lavender); }
.icon-wrap.pink     { background: var(--pink-light); }
.icon-wrap.blue     { background: #EEF2FF; }
.icon-wrap.green    { background: #ECFDF5; }
.icon-wrap.amber    { background: #FFFBEB; }
.icon-wrap.teal     { background: #E1F5EE; }

/* ── PROFILE HEADER ─────────────────────────────────────────── */
.profile-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: 0 4px 16px rgba(232,66,106,0.25);
}
.profile-avatar {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.4);
}
.profile-info .class-tag {
  font-size: 10px;
  background: rgba(255,255,255,0.25);
  padding: 2px 8px;
  border-radius: 20px;
  display: inline-block;
  margin-bottom: 4px;
}
.profile-info .user-name  { font-size: 18px; font-weight: 800; }
.profile-info .user-role  { font-size: 12px; opacity: 0.85; }
.profile-actions { margin-left: auto; display: flex; gap: 8px; }
.profile-actions .act-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.15);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

/* ── STATS ──────────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-card .stat-icon  { font-size: 20px; }
.stat-card .stat-val   { font-size: 24px; font-weight: 800; color: var(--text); }
.stat-card .stat-label { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.stat-card.primary { background: var(--primary); }
.stat-card.primary .stat-val,
.stat-card.primary .stat-label { color: white; }

/* ── FORMS ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-600);
  margin-bottom: 6px;
  display: block;
  letter-spacing: 0.2px;
}
.form-control {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  transition: border-color 0.15s;
  outline: none;
  color: var(--text);
  background: white;
  -webkit-appearance: none;
  appearance: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(232,66,106,0.10);
}
textarea.form-control {
  resize: vertical;
  min-height: 80px;
}
select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237C7C8E' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* form error */
.form-error {
  font-size: 12px;
  color: var(--primary);
  margin-top: 4px;
}

/* ── BUTTONS ────────────────────────────────────────────────── */
.btn {
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover, .btn-primary:active { background: var(--primary-dark); }
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover, .btn-outline:active { background: var(--pink-light); }
.btn-sm  { padding: 7px 14px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* ── ATTENDANCE TAG ─────────────────────────────────────────── */
.attend-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
}
.attend-tag.present { background: #ECFDF5; color: #16A34A; }
.attend-tag.absent  { background: #FEF2F2; color: #DC2626; }
.attend-tag.late    { background: #FFFBEB; color: #D97706; }

/* ── CARD ───────────────────────────────────────────────────── */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-header h3 { font-size: 14px; font-weight: 700; color: var(--text); }
.card-body { padding: 16px; }

/* ── ANNOUNCE LIST ──────────────────────────────────────────── */
.announce-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.announce-item:active { background: var(--gray-50); }
.announce-item:last-child { border-bottom: none; }
.announce-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
  margin-top: 5px;
}
.announce-dot.read { background: var(--gray-200); }
.announce-content .title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.announce-content .meta  { font-size: 11px; color: var(--text-muted); }
.announce-content .preview {
  font-size: 12px;
  color: var(--gray-600);
  margin-top: 3px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── CALENDAR ───────────────────────────────────────────────── */
.cal-wrap { padding: 14px 16px; }
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.cal-title { font-size: 15px; font-weight: 700; }
.cal-nav-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--gray-200);
  background: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-muted);
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.cal-day-label {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 4px 0;
}
.cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 12px;
  cursor: pointer;
  position: relative;
  font-weight: 500;
  transition: background 0.15s;
}
.cal-day:active { background: var(--gray-100); }
.cal-day.has-event { background: var(--success); color: white; font-weight: 700; }
.cal-day.today    { background: var(--primary); color: white; font-weight: 700; }
.cal-day.selected { outline: 2px solid var(--primary); }
.cal-day.other-month { color: var(--gray-400); }
.cal-day .event-dot {
  position: absolute;
  top: 1px; right: 1px;
  width: 12px; height: 12px;
  background: var(--primary);
  border-radius: 50%;
  font-size: 8px;
  font-weight: 700;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── MODAL ──────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0,0,0,0.5);
  align-items: flex-end; /* mobile: sheet from bottom */
  justify-content: center;
  padding: 0;
}
.modal-overlay.open { display: flex; }

.modal {
  background: white;
  border-radius: var(--radius) var(--radius) 0 0; /* bottom sheet on mobile */
  width: 100%;
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.modal-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}
/* drag handle for modal */
.modal-handle {
  width: 36px; height: 4px;
  background: var(--gray-200);
  border-radius: 2px;
  margin: 10px auto 0;
}
.modal-header h4 { font-size: 16px; font-weight: 700; }
.modal-close {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--gray-100);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--gray-600);
}
.modal-body {
  padding: 16px;
  padding-bottom: calc(16px + var(--safe-bottom));
}
.modal-body .msg-box {
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 14px;
  line-height: 1.8;
  margin-bottom: 14px;
  border-left: 3px solid var(--primary);
}
.modal-body .msg-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }

/* ── ALERTS ─────────────────────────────────────────────────── */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.alert-success { background: #ECFDF5; color: #16A34A; }
.alert-error   { background: #FEF2F2; color: #DC2626; }

/* ── CHIP TABS ──────────────────────────────────────────────── */
.chip-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 14px;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.chip-tabs::-webkit-scrollbar { display: none; }
.chip {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  border: 1.5px solid var(--gray-200);
  background: white;
  color: var(--gray-600);
  white-space: nowrap;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.chip.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ── SCROLLBAR ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 4px; }

/* ── SKELETON / LOADING ─────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-xs);
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── PAGER ──────────────────────────────────────────────────── */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 0;
  flex-wrap: wrap;
}
.pager a, .pager span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  color: var(--gray-600);
  border: 1.5px solid var(--gray-200);
  background: white;
  padding: 0 10px;
}
.pager a:hover { border-color: var(--primary); color: var(--primary); }
.pager .current {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ══ RESPONSIVE BREAKPOINTS ═════════════════════════════════════

   ┌──────────────────────────────────────────────────────────┐
   │  ≤ 768px   Mobile: hamburger + bottom nav + no sidebar   │
   │  769~1024px Tablet: sidebar push (narrow)                │
   │  ≥ 1025px  Desktop: full sidebar + wide main             │
   └──────────────────────────────────────────────────────────┘
══════════════════════════════════════════════════════════════ */

/* ── TABLET (769~1024px) ─────────────────────────────────────── */
@media (max-width: 1024px) and (min-width: 769px) {
  :root { --sidebar-w: 200px; }
  .main-wrap { padding: 16px; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .icon-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ── MOBILE (≤ 768px) ───────────────────────────────────────── */
@media (max-width: 768px) {

  /* show hamburger, hide sidebar by default */
  .hamburger { display: flex; }

  .sidebar {
    transform: translateX(-100%);
    padding-top: 0;
    box-shadow: none;
    pointer-events: none;    /* closed sidebar blocks NOTHING */
    visibility: hidden;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
    pointer-events: auto;    /* open sidebar is interactive */
    visibility: visible;
  }
  .sidebar-overlay { display: none !important; pointer-events: none !important; }
  .sidebar-overlay.open {
    pointer-events: auto;    /* open overlay catches taps to close sidebar */
  }

  /* main content: no sidebar offset, bottom nav padding */
  .main-wrap {
    margin-left: 0;
    padding: 14px 14px;
    padding-bottom: calc(var(--bottom-h) + var(--safe-bottom) + 14px);
  }

  /* bottom nav visible */
  .bottom-nav { display: block; }

  /* 2-col stats on mobile */
  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  /* 4-col icon grid stays 4-col (with smaller icons) */
  .icon-grid { grid-template-columns: repeat(4, 1fr); }
  .icon-grid-item { padding: 14px 6px; }
  .icon-grid-item .icon-wrap { width: 42px; height: 42px; font-size: 19px; border-radius: 12px; }
  .icon-grid-item .icon-label { font-size: 10px; }

  /* profile header compact */
  .profile-header { padding: 14px 16px; }
  .profile-avatar { width: 48px; height: 48px; font-size: 22px; }
  .profile-info .user-name { font-size: 16px; }

  /* modal: full bottom sheet */
  .modal-overlay { align-items: flex-end; }
  .modal { border-radius: var(--radius) var(--radius) 0 0; max-height: 92dvh; }

  /* tables: horizontal scroll */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* forms: stack grid */
  .form-grid-2,
  .form-grid-3 { grid-template-columns: 1fr !important; }

  /* buttons: larger tap targets */
  .btn { padding: 12px 18px; }
  .btn-sm { padding: 9px 14px; font-size: 13px; }

  /* hide non-essential desktop elements */
  .desktop-only { display: none !important; }
}

/* ── SMALL MOBILE (≤ 390px) ────────────────────────────────── */
@media (max-width: 390px) {
  .icon-grid { grid-template-columns: repeat(3, 1fr); }
  .icon-grid-item:nth-child(4n) { border-right: 1px solid var(--gray-100); }
  .icon-grid-item:nth-child(3n) { border-right: none; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .bottom-nav-item { font-size: 9px; }
  .bottom-nav-item .bnav-icon { font-size: 20px; }
}

/* ── DESKTOP ONLY ────────────────────────────────────────────── */
@media (min-width: 769px) {
  .mobile-only { display: none !important; }
  .modal {
    border-radius: var(--radius); /* rounded on desktop */
    max-width: 520px;
    margin: auto;
  }
  .modal-overlay { align-items: center; padding: 20px; }
  @keyframes slideUp {
    from { transform: translateY(16px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
  }
}

/* ── UTILITY ─────────────────────────────────────────────────── */
.text-muted    { color: var(--text-muted); }
.text-primary  { color: var(--primary); }
.text-success  { color: #16A34A; }
.text-danger   { color: #DC2626; }
.font-bold     { font-weight: 700; }
.font-sm       { font-size: 12px; }
.truncate      { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.d-none        { display: none; }
.d-flex        { display: flex; }
.gap-8         { gap: 8px; }
.mt-8          { margin-top: 8px; }
.mb-0          { margin-bottom: 0; }

/* ── PULL TO REFRESH VISUAL ──────────────────────────────────── */
.ptr-spinner {
  display: none;
  text-align: center;
  padding: 12px;
  font-size: 20px;
  color: var(--primary);
}
