/* ══════════════════════════════════════════════
   ANIMATIONS
══════════════════════════════════════════════ */
.page-enter{animation:pageIn .32s var(--ease-spring) both;}
@keyframes pageIn{from{opacity:0;transform:translateY(12px);}to{opacity:1;transform:translateY(0);}}
@keyframes slideUp{from{opacity:0;transform:translateY(24px);}to{opacity:1;transform:translateY(0);}}
@keyframes fadeIn{from{opacity:0;}to{opacity:1;}}
@keyframes scaleIn{from{opacity:0;transform:scale(.94);}to{opacity:1;transform:scale(1);}}
@keyframes spin{to{transform:rotate(360deg);}}
@keyframes dotPulse{0%,100%{opacity:1;transform:scale(1);}50%{opacity:.5;transform:scale(1.5);}}
@keyframes fadeUp{from{opacity:0;transform:translateY(16px);}to{opacity:1;transform:translateY(0);}}

/* ══════════════════════════════════════════════
   RESPONSIVE — Landing
══════════════════════════════════════════════ */
@media(max-width:900px){
  .land-nav{padding:14px 20px;}
  .features,.how-it-works,.testimonials{padding:60px 20px;}
  .hero{padding:60px 20px 48px;}
  .land-footer{padding:24px 20px;flex-direction:column;gap:12px;text-align:center;}
  .land-footer-logo{justify-content:center;}
  .land-footer-links{justify-content:center;}
  .land-cta{padding:60px 20px;}
  .land-nav-links{display:none;}
}

/* Mobile landing nav drawer */
.land-nav-hamburger{display:none;background:none;border:1px solid var(--border2);border-radius:var(--radius-sm);width:34px;height:34px;cursor:pointer;color:var(--text2);align-items:center;justify-content:center;transition:all .2s;margin-left:4px;}
.land-nav-hamburger:hover{color:var(--accent);border-color:var(--accent);}
/* Show hamburger on landing mobile (after the base rule so it wins) */
@media(max-width:900px){ .land-nav-hamburger{display:flex;} }
.land-mobile-drawer{display:none;position:fixed;inset:0;z-index:200;}
.land-mobile-drawer.open{display:block;}
.land-mobile-drawer-bg{position:absolute;inset:0;background:rgba(0,0,0,.5);backdrop-filter:blur(3px);}
.land-mobile-drawer-panel{position:absolute;top:0;right:0;width:260px;height:100%;background:var(--bg2);border-left:1px solid var(--border2);padding:24px 20px;display:flex;flex-direction:column;gap:4px;animation:slideFromRight .28s var(--ease-spring);}
@keyframes slideFromRight{from{transform:translateX(100%);}to{transform:translateX(0);}}
.land-drawer-close{align-self:flex-end;background:none;border:none;cursor:pointer;color:var(--text2);font-size:22px;padding:4px 8px;margin-bottom:12px;}
.land-drawer-link{display:block;padding:12px 10px;font-size:15px;color:var(--text);border-radius:var(--radius-sm);transition:background .15s;}
.land-drawer-link:hover{background:var(--bg3);text-decoration:none;}
.land-drawer-divider{height:1px;background:var(--border);margin:8px 0;}

/* ══════════════════════════════════════════════
   RESPONSIVE — App
══════════════════════════════════════════════ */
@media(max-width:768px){
  .sidebar{display:none;}
  .mobile-topbar{display:flex;}
  .mobile-nav{display:flex;}
  .shell{flex-direction:column;}
  .main{padding-top:52px;padding-bottom:78px;}
  .topbar{padding:14px 14px 0;flex-direction:column;align-items:flex-start;gap:10px;}
  .topbar-actions{width:100%;flex-wrap:wrap;gap:6px;}
  .topbar-actions .input,.topbar-actions select{flex:1;min-width:120px;}
  .content{padding:14px 12px 32px;}
  .page-title{font-size:20px;}
  .page-sub{font-size:12px;}
  /* Stat grid: 2 columns but allow cards enough height for sparklines */
  .stat-grid{grid-template-columns:repeat(2,1fr);gap:7px;align-items:start;}
  .stat-card{padding:10px 11px;height:auto;min-height:unset;}
  .stat-value{font-size:18px;}
  /* Sparkline/chart inside stat cards: constrain so they don't overflow */
  .stat-card svg{max-width:100%;height:28px!important;display:block;}
  /* Sparkline stat cards: reduce font on mobile so values don't collide */
  .stat-card.stat-card-sparkline .stat-value{font-size:16px;}
  .stat-card.stat-card-sparkline{padding:10px 10px!important;}
  .card{padding:14px 12px;}
  .grid-2{grid-template-columns:1fr!important;}
  /* Member meal totals + bazar contributors: stack vertically on mobile */
  .member-dashboard-bottom-grid{grid-template-columns:1fr!important;}
  /* Member meal totals table: make it full width and readable */
  .member-dashboard-bottom-grid .tbl-wrap{margin:0;width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;}
  .member-dashboard-bottom-grid table{font-size:12px;min-width:280px;}
  .member-dashboard-bottom-grid th,.member-dashboard-bottom-grid td{padding:7px 8px;white-space:nowrap;}
  /* Profile detail popup: stack Recent months + What I Owe vertically */
  .profile-detail-bottom-grid{grid-template-columns:1fr!important;}
  /* Recent months table in profile popup: scrollable on mobile */
  .profile-detail-bottom-grid .tbl-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch;}
  .profile-detail-bottom-grid table{font-size:12px;min-width:360px;}
  .profile-detail-bottom-grid th,.profile-detail-bottom-grid td{padding:6px 8px;white-space:nowrap;}
  /* What I Owe card: ensure it's full width and rows don't overlap */
  .profile-detail-bottom-grid .card{width:100%;box-sizing:border-box;}
  .my-stat-row{font-size:12px;gap:8px;}
  .my-stat-val{min-width:60px;}

  /* My Profile — meal/rent/util balance row: avoid orphaned border-left
     when the row wraps onto its own line on narrow screens. Switch to
     three equal full-width columns with no side borders. */
  .profile-balance-row{width:100%;display:grid!important;grid-template-columns:repeat(3,1fr)!important;gap:8px!important;}
  .profile-balance-item{text-align:center!important;}
  .profile-balance-item-bordered{padding-left:0!important;border-left:none!important;}

  /* Toast above mobile nav */
  #toast{bottom:calc(78px + env(safe-area-inset-bottom, 8px));right:12px;left:12px;max-width:none;text-align:center;}

  /* Modals: full-width on phones */
  .modal-bg{padding:8px;}
  .modal{padding:16px;max-height:94vh;border-radius:10px;}
  .modal.modal-wide{max-width:100%;}
  .modal-title{font-size:17px;}
  .confirm-dialog{padding:20px 16px;}

  /* Tables */
  .tbl-wrap{margin:6px -6px 0;width:calc(100% + 12px);padding:0 6px;-webkit-overflow-scrolling:touch;}
  .tbl-wrap table{font-size:12px;min-width:max-content;}
  .tbl-wrap th,.tbl-wrap td{padding:7px 8px;white-space:nowrap;}

  /* Attendance Board calendar — keep 7-column day alignment but let it
     scroll horizontally on phones instead of squashing cells unreadable */
  .att-cal-scroll{overflow-x:auto;-webkit-overflow-scrolling:touch;margin:0 -12px;padding:0 12px;}
  .att-cal-grid{min-width:540px;}
  .att-cal-cell{min-height:64px!important;padding:4px 4px 4px!important;}

  /* Bazar Calendar modal — same horizontal-scroll approach */
  .bz-cal-scroll{overflow-x:auto;-webkit-overflow-scrolling:touch;margin:0 -16px;padding:0 16px;}
  .bz-cal-grid{min-width:420px;}
  .bz-cal-cell{min-height:48px!important;}

  /* Month selectors */
  .month-sel{flex-wrap:wrap;gap:8px;}
  .month-sel label{font-size:12px;}
  .month-sel .input{flex:1;min-width:100px;}
  .date-row{flex-wrap:wrap;}
  .date-row .input{flex:1;min-width:140px;}

  .auth-card{padding:24px 22px;}

  /* Profile cards */
  .profile-card{padding:13px;}

  /* Summary bars */
  #ut-summary-bar > div,[id$="-summary-bar"] > div{flex-direction:column!important;align-items:flex-start!important;gap:6px!important;}

  /* How-it-works arrows — hide on mobile, layout stacks vertically */
  .step-arrow{display:none;}
  .steps{flex-direction:column;gap:20px;}
}

@media(max-width:400px){
  .land-logo span{display:none;}
}

@media(max-width:480px){
  /* Keep Sign in reachable on phones; Create Mess moves to the drawer */
  .land-nav{gap:10px;padding:12px 16px;}
  .land-nav-actions .btn-ghost:not(.land-signin){display:none;}
  .land-nav-actions{gap:6px;}
  .land-nav-actions .btn-sm{padding-left:10px;padding-right:10px;white-space:nowrap;}
  .land-nav-theme{margin-left:0;}
  .hero-stats{flex-direction:column;gap:16px;}
  .hero-stat-sep{display:none;}

  .stat-grid{grid-template-columns:1fr 1fr;gap:6px;}
  .stat-card{padding:9px 10px;}
  .stat-value{font-size:16px;}
  .stat-label{font-size:10px;}
  /* On very small screens, sparkline stat cards stack 1 column */
  .stat-card.stat-card-sparkline .stat-value{font-size:14px;}
  .stat-card.stat-card-sparkline{padding:9px 9px!important;}

  .topbar{padding:12px 12px 0;}
  .content{padding:12px 10px 32px;}
  .page-title{font-size:18px;}

  .card{padding:12px 11px;}
  .modal{padding:14px;}
  .modal-title{font-size:16px;}

  .btn{padding:7px 12px;font-size:12px;}
  .btn-sm{padding:5px 9px;font-size:11px;}

  .tbl-wrap table{font-size:11px;}
  .tbl-wrap th,.tbl-wrap td{padding:6px;}

  /* What I Owe: tighter rows on very small screens */
  .my-stat-row{font-size:12px;padding:7px 0;gap:6px;}
  .my-stat-val{font-size:12px;}

  /* Profile balance row: 2 columns on very small phones so currency values don't crowd */
  .profile-balance-row{grid-template-columns:repeat(2,1fr)!important;}
}

@media(prefers-reduced-motion:reduce){
  *,*::before,*::after{animation-duration:.01ms!important;transition-duration:.01ms!important;}
}

/* Tablet portrait (769–1024px) */
@media(min-width:769px) and (max-width:1024px){
  .sidebar{width:200px;}
  .content{padding:18px 16px 36px;}
  .stat-grid{grid-template-columns:repeat(auto-fill,minmax(150px,1fr));}
  .modal.modal-wide{max-width:96vw;}
  .tbl-wrap table{font-size:13px;min-width:max-content;}
}
