/* ============================================================
   FamilyCart — Mobile-First Design System
   Aesthetic: Fresh market · Warm organic · App-native feel
   Target: Pixel 9 (412px) · iPhone 15 (390px) → Desktop
   ============================================================ */

:root {
  --forest:     #1e4620;
  --forest-mid: #2d6a30;
  --forest-lt:  #3d8c40;
  --sage:       #6dab70;
  --mint:       #a8d8aa;
  --mist:       #d4ecd5;
  --foam:       #edf7ee;
  --foam-d:     #e0f0e1;

  --ink:        #14120e;
  --ink-70:     #3d3930;
  --ink-50:     #6b6660;
  --ink-30:     #a8a49c;
  --ink-10:     #e8e5e0;
  --ivory:      #faf8f4;
  --ivory-d:    #f2efe9;
  --white:      #ffffff;

  --rose:       #e05c6e;
  --rose-lt:    #fde8ec;
  --amber:      #d4860a;
  --amber-lt:   #fef3d6;
  --sky:        #2874d4;
  --sky-lt:     #dbeafe;

  --r-xs:  6px;   --r-sm:  10px;  --r-md:  16px;
  --r-lg:  22px;  --r-xl:  32px;  --r-full: 999px;

  --s-xs:  0 1px 3px rgba(0,0,0,0.07);
  --s-sm:  0 2px 8px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.05);
  --s-md:  0 6px 24px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.06);
  --s-lg:  0 16px 48px rgba(0,0,0,0.14), 0 4px 16px rgba(0,0,0,0.08);
  --s-green: 0 4px 20px rgba(30,70,32,0.30);

  --f-display: 'Sora', system-ui, sans-serif;
  --f-body:    'Nunito', system-ui, sans-serif;
  --f-mono:    'JetBrains Mono', monospace;

  --ease:        0.18s cubic-bezier(0.4,0,0.2,1);
  --ease-spring: 0.3s cubic-bezier(0.34,1.56,0.64,1);

  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --bnav-h:      calc(62px + var(--safe-bottom));
}

*,*::before,*::after { box-sizing:border-box; margin:0; padding:0; -webkit-tap-highlight-color:transparent; }
html { font-size:16px; scroll-behavior:smooth; -webkit-text-size-adjust:100%; }
body {
  font-family: var(--f-body);
  background: var(--ivory);
  color: var(--ink);
  min-height: 100vh; min-height: 100dvh;
  line-height: 1.55;
  overscroll-behavior-y: none;
}
img,svg { display:block; max-width:100%; }
button,input,select,textarea { font-family:inherit; }
a { color:inherit; text-decoration:none; }

/* ======================================================
   TOP NAV
   ====================================================== */
.topnav {
  background: var(--forest);
  height: calc(56px + var(--safe-top));
  padding-top: var(--safe-top);
  position: sticky; top:0; z-index:200;
  display: flex; align-items: center;
  box-shadow: 0 2px 16px rgba(0,0,0,0.22);
}
.topnav-inner {
  display: flex; align-items: center;
  justify-content: space-between;
  width: 100%; padding: 0 16px; gap: 12px;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  text-decoration: none; flex-shrink: 0;
}
.brand-icon { font-size: 22px; line-height:1; }
.brand-name {
  font-family: var(--f-display); font-size: 20px;
  font-weight: 700; color: #fff; letter-spacing: -0.3px;
}
.topnav-links {
  display: none; align-items: center; gap: 2px; flex: 1;
  margin-left: 12px;
}
.topnav-link {
  color: rgba(255,255,255,0.76); font-size: 13.5px;
  font-weight: 700; padding: 6px 12px;
  border-radius: var(--r-sm); transition: var(--ease);
}
.topnav-link:hover,.topnav-link.act {
  background: rgba(255,255,255,0.14); color: #fff;
}
.topnav-user { display:flex; align-items:center; gap:8px; flex-shrink:0; }
.user-avatar {
  width: 34px; height: 34px; border-radius: var(--r-full);
  background: var(--forest-lt);
  border: 2px solid rgba(255,255,255,0.22);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: #fff;
  cursor: pointer; transition: var(--ease);
}
.user-avatar:active { transform: scale(0.9); }
.role-chip {
  display: none; font-size: 10px; font-weight: 800;
  letter-spacing: 0.8px; text-transform: uppercase;
  padding: 3px 9px; border-radius: var(--r-full);
}
.role-chip--super_admin { background:#f59e0b; color:#451a03; }
.role-chip--family_admin { background:var(--mint); color:var(--forest); }
.role-chip--family_user  { background:rgba(255,255,255,0.18); color:#fff; }
.hamburger {
  background:none; border:none; cursor:pointer;
  padding:8px; border-radius:var(--r-sm);
  color:rgba(255,255,255,0.8);
  display:flex; flex-direction:column; gap:4px;
}
.hamburger span {
  display:block; width:20px; height:2px;
  background:currentColor; border-radius:2px; transition:var(--ease);
}
.hamburger.open span:nth-child(1){transform:rotate(45deg) translate(4px,4px);}
.hamburger.open span:nth-child(2){opacity:0; transform:scaleX(0);}
.hamburger.open span:nth-child(3){transform:rotate(-45deg) translate(4px,-4px);}

/* Mobile drawer */
.mobile-drawer { position:fixed; inset:0; z-index:400; pointer-events:none; }
.drawer-overlay {
  position:absolute; inset:0;
  background:rgba(0,0,0,0.5); backdrop-filter:blur(2px);
  opacity:0; transition:opacity 0.22s ease;
}
.drawer-panel {
  position:absolute; top:0; right:0;
  width:min(300px,85vw); height:100%;
  background:var(--white); padding-top:var(--safe-top);
  transform:translateX(100%);
  transition:transform 0.26s cubic-bezier(0.4,0,0.2,1);
  box-shadow:-8px 0 32px rgba(0,0,0,0.18);
  display:flex; flex-direction:column; overflow-y:auto;
}
.mobile-drawer.open { pointer-events:all; }
.mobile-drawer.open .drawer-overlay { opacity:1; }
.mobile-drawer.open .drawer-panel { transform:translateX(0); }

.drawer-header {
  display:flex; align-items:center; justify-content:space-between;
  padding:16px 20px; border-bottom:1px solid var(--ink-10);
}
.drawer-user-name { font-weight:800; font-size:16px; }
.drawer-user-email { font-size:12px; color:var(--ink-50); margin-top:2px; }
.drawer-close {
  background:var(--ivory-d); border:none; cursor:pointer;
  width:32px; height:32px; border-radius:var(--r-full);
  display:flex; align-items:center; justify-content:center;
  font-size:16px; color:var(--ink-50); transition:var(--ease);
}
.drawer-close:hover { background:var(--ink-10); color:var(--ink); }
.drawer-nav { flex:1; padding:12px; display:flex; flex-direction:column; gap:2px; }
.drawer-link {
  display:flex; align-items:center; gap:12px;
  padding:13px 16px; border-radius:var(--r-sm);
  color:var(--ink-70); font-weight:700; font-size:15px;
  transition:var(--ease);
}
.drawer-link:hover,.drawer-link.act { background:var(--foam); color:var(--forest); }
.drawer-link .dli { font-size:18px; width:24px; text-align:center; }
.drawer-sep { height:1px; background:var(--ink-10); margin:8px 16px; }
.drawer-footer { padding:16px 20px; border-top:1px solid var(--ink-10); }
.drawer-signout {
  width:100%; background:var(--ivory-d); border:1.5px solid var(--ink-10);
  color:var(--ink-50); font-size:14px; font-weight:700;
  padding:12px; border-radius:var(--r-sm); cursor:pointer; transition:var(--ease);
}
.drawer-signout:hover { background:var(--rose-lt); border-color:var(--rose); color:var(--rose); }

/* ======================================================
   BOTTOM NAV (mobile)
   ====================================================== */
.bottom-nav {
  position:fixed; bottom:0; left:0; right:0;
  height:var(--bnav-h); padding-bottom:var(--safe-bottom);
  background:var(--white);
  border-top:1px solid var(--ink-10);
  box-shadow:0 -4px 20px rgba(0,0,0,0.08);
  z-index:190; display:flex; align-items:stretch;
}
.bnav-item {
  flex:1; display:flex; flex-direction:column;
  align-items:center; justify-content:center;
  gap:3px; color:var(--ink-30);
  font-size:10px; font-weight:800; letter-spacing:0.3px;
  padding-bottom:2px; transition:var(--ease);
  cursor:pointer; background:none; border:none;
  text-decoration:none;
}
.bnav-item.act { color:var(--forest); }
.bnav-item:active { transform:scale(0.88); }
.bnav-icon { font-size:22px; line-height:1; transition:var(--ease); }
.bnav-item.act .bnav-icon { transform:translateY(-2px); }
.bnav-fab { flex:0 0 68px; display:flex; align-items:center; justify-content:center; }
.fab {
  width:54px; height:54px; border-radius:var(--r-full);
  background:var(--forest); border:none; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  box-shadow:var(--s-green); color:#fff; font-size:28px;
  transform:translateY(-12px); transition:var(--ease-spring);
}
.fab:active { transform:translateY(-12px) scale(0.9); }

/* ======================================================
   LAYOUT
   ====================================================== */
.page-wrap {
  max-width:1280px; margin:0 auto;
  padding:20px 16px;
  padding-bottom:calc(var(--bnav-h) + 20px);
}
.page-header {
  display:flex; align-items:flex-start;
  justify-content:space-between; gap:12px;
  margin-bottom:20px; flex-wrap:wrap;
}
.page-title {
  font-family:var(--f-display); font-size:24px;
  font-weight:800; color:var(--forest);
  line-height:1.15; letter-spacing:-0.4px;
}
.page-sub { font-size:13px; color:var(--ink-50); margin-top:3px; }
.page-actions { display:flex; gap:8px; flex-wrap:wrap; align-items:flex-start; }

/* ======================================================
   CARDS
   ====================================================== */
.card {
  background:var(--white); border-radius:var(--r-md);
  box-shadow:var(--s-sm); overflow:hidden;
  border:1px solid var(--ink-10);
}
.card-head {
  display:flex; align-items:center; justify-content:space-between;
  padding:16px 20px; border-bottom:1px solid var(--ink-10); gap:12px;
}
.card-title { font-family:var(--f-display); font-size:16px; font-weight:800; }
.card-body { padding:20px; }
.card-foot {
  padding:12px 20px; border-top:1px solid var(--ink-10);
  background:var(--ivory); display:flex; justify-content:flex-end; gap:8px;
}

/* ======================================================
   BUTTONS
   ====================================================== */
.btn {
  display:inline-flex; align-items:center; justify-content:center;
  gap:6px; font-family:var(--f-body); font-weight:800;
  font-size:14px; line-height:1; cursor:pointer; border:none;
  border-radius:var(--r-sm); padding:12px 22px;
  transition:var(--ease); white-space:nowrap;
  -webkit-tap-highlight-color:transparent;
}
.btn:active { transform:scale(0.95); }
.btn:disabled { opacity:0.45; cursor:not-allowed; transform:none !important; }
.btn-primary { background:var(--forest); color:#fff; box-shadow:var(--s-green); }
.btn-primary:hover { background:var(--forest-mid); }
.btn-secondary { background:var(--ivory-d); color:var(--ink-70); border:1.5px solid var(--ink-10); }
.btn-secondary:hover { background:var(--ink-10); }
.btn-ghost { background:transparent; color:var(--ink-50); border:1.5px solid var(--ink-10); }
.btn-ghost:hover { background:var(--ivory-d); color:var(--ink); }
.btn-danger { background:var(--rose); color:#fff; }
.btn-danger:hover { background:#c24055; }
.btn-sm { font-size:12px; padding:7px 14px; }
.btn-lg { font-size:16px; padding:16px 36px; }
.btn-full { width:100%; }
.btn-icon { padding:10px; }

/* ======================================================
   FORMS
   ====================================================== */
.form-group { margin-bottom:18px; }
.form-label { display:block; font-size:12.5px; font-weight:800; color:var(--ink-70); margin-bottom:6px; }
.form-hint { font-size:11.5px; color:var(--ink-30); margin-top:5px; }
.form-control {
  width:100%; padding:13px 15px;
  border:2px solid var(--ink-10); border-radius:var(--r-sm);
  font-size:16px; font-family:var(--f-body);
  color:var(--ink); background:var(--white);
  transition:var(--ease); outline:none;
  -webkit-appearance:none; appearance:none;
}
.form-control:focus { border-color:var(--forest-lt); box-shadow:0 0 0 3px rgba(61,140,64,0.14); }
.form-control::placeholder { color:var(--ink-30); }
select.form-control {
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b6660' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat:no-repeat; background-position:right 14px center; padding-right:38px; cursor:pointer;
}
.form-row { display:flex; gap:12px; flex-direction:column; }

/* ======================================================
   BADGES
   ====================================================== */
.badge {
  display:inline-flex; align-items:center;
  font-size:10.5px; font-weight:800; letter-spacing:0.5px;
  text-transform:uppercase; padding:3px 9px; border-radius:var(--r-full);
}
.badge-green  { background:var(--foam-d); color:var(--forest); }
.badge-amber  { background:var(--amber-lt); color:var(--amber); }
.badge-red    { background:var(--rose-lt); color:var(--rose); }
.badge-blue   { background:var(--sky-lt); color:var(--sky); }
.badge-gray   { background:var(--ivory-d); color:var(--ink-50); }

/* ======================================================
   ALERTS
   ====================================================== */
.alert {
  padding:12px 16px; border-radius:var(--r-sm); font-size:14px;
  font-weight:700; margin-bottom:16px;
  display:flex; align-items:flex-start; gap:9px;
  border-left:4px solid;
}
.alert-success { background:var(--foam-d); border-color:var(--forest-lt); color:var(--forest); }
.alert-error   { background:var(--rose-lt); border-color:var(--rose); color:var(--rose); }
.alert-info    { background:var(--sky-lt); border-color:var(--sky); color:var(--sky); }
.alert-warning { background:var(--amber-lt); border-color:var(--amber); color:var(--amber); }

/* ======================================================
   STATS
   ====================================================== */
.stats-row {
  display:grid; grid-template-columns:repeat(2,1fr);
  gap:12px; margin-bottom:20px;
}
.stat-tile {
  background:var(--white); border-radius:var(--r-md);
  border:1px solid var(--ink-10); box-shadow:var(--s-xs);
  padding:16px; display:flex; flex-direction:column; gap:8px;
}
.stat-tile-icon { font-size:22px; }
.stat-tile-number { font-family:var(--f-display); font-size:28px; font-weight:800; color:var(--forest); line-height:1; }
.stat-tile-label { font-size:11px; font-weight:800; color:var(--ink-30); text-transform:uppercase; letter-spacing:0.6px; }

/* ======================================================
   MODAL SHEETS
   ====================================================== */
.modal-bg {
  position:fixed; inset:0;
  background:rgba(0,0,0,0.45); backdrop-filter:blur(3px);
  z-index:500; display:flex; align-items:flex-end; justify-content:center;
  opacity:0; pointer-events:none; transition:opacity 0.22s ease;
}
.modal-bg.active { opacity:1; pointer-events:all; }
.modal-sheet {
  background:var(--white); border-radius:var(--r-lg) var(--r-lg) 0 0;
  width:100%; max-height:92dvh; overflow-y:auto;
  transform:translateY(100%);
  transition:transform 0.28s cubic-bezier(0.32,0.72,0,1);
  padding-bottom:var(--safe-bottom);
}
.modal-bg.active .modal-sheet { transform:translateY(0); }
.modal-sheet::before {
  content:''; display:block; width:36px; height:4px;
  background:var(--ink-10); border-radius:2px; margin:10px auto 0;
}
.modal-head {
  display:flex; align-items:center; justify-content:space-between;
  padding:16px 20px 12px;
}
.modal-title { font-family:var(--f-display); font-size:18px; font-weight:800; }
.modal-x {
  width:32px; height:32px; border-radius:var(--r-full);
  background:var(--ivory-d); border:none; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  font-size:16px; color:var(--ink-50); transition:var(--ease);
}
.modal-x:hover { background:var(--rose-lt); color:var(--rose); }
.modal-body { padding:0 20px 20px; }
.modal-foot {
  display:flex; flex-direction:column; gap:8px;
  padding:12px 20px 20px; border-top:1px solid var(--ink-10);
}

/* Full-screen add sheet */
.add-sheet {
  position:fixed; inset:0; background:var(--white); z-index:450;
  transform:translateY(100%);
  transition:transform 0.3s cubic-bezier(0.32,0.72,0,1);
  overflow-y:auto; display:flex; flex-direction:column;
  padding-bottom:var(--safe-bottom);
}
.add-sheet.open { transform:translateY(0); }
.add-sheet-head {
  display:flex; align-items:center; justify-content:space-between;
  padding:calc(16px + var(--safe-top)) 20px 16px;
  background:var(--forest); color:#fff; flex-shrink:0;
}
.add-sheet-title { font-family:var(--f-display); font-size:20px; font-weight:800; }
.add-sheet-x {
  width:36px; height:36px; background:rgba(255,255,255,0.15);
  border:none; border-radius:var(--r-full); cursor:pointer;
  color:#fff; font-size:18px; display:flex; align-items:center; justify-content:center;
  transition:var(--ease);
}
.add-sheet-x:active { background:rgba(255,255,255,0.28); }
.add-sheet-body { padding:20px; flex:1; }

/* ======================================================
   GROCERY LIST
   ====================================================== */
.list-progress-wrap { margin:8px 0 20px; }
.list-progress-track {
  background:var(--ink-10); border-radius:var(--r-full); height:6px; overflow:hidden;
}
.list-progress-fill {
  height:100%; background:linear-gradient(90deg,var(--sage),var(--forest-lt));
  border-radius:var(--r-full); transition:width 0.4s cubic-bezier(0.4,0,0.2,1);
}
.list-meta-row {
  display:flex; align-items:center; justify-content:space-between;
  margin-bottom:12px;
}
.list-meta-text { font-size:13px; font-weight:700; color:var(--ink-50); }

.cat-section { margin-bottom:8px; }
.cat-label {
  font-size:10.5px; font-weight:800; text-transform:uppercase;
  letter-spacing:1.2px; color:var(--ink-30);
  padding:12px 0 8px 2px; display:block;
}

/* Item rows */
.item-row {
  background:var(--white); border:1.5px solid var(--ink-10);
  border-radius:var(--r-sm); padding:13px 14px;
  margin-bottom:8px; display:flex; align-items:center;
  gap:12px; transition:var(--ease); animation:rowIn 0.2s ease;
  touch-action:manipulation;
}
@keyframes rowIn { from{opacity:0;transform:translateY(-6px)} to{opacity:1;transform:none} }
.item-row.is-bought { opacity:0.5; background:var(--ivory); }
.item-row.is-bought .item-name { text-decoration:line-through; color:var(--ink-30); }

.item-cb {
  width:28px; height:28px; border-radius:8px;
  border:2px solid var(--ink-10); background:var(--white);
  flex-shrink:0; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  transition:var(--ease-spring); font-size:14px; color:transparent;
}
.item-cb:active { transform:scale(0.82); }
.item-row.is-bought .item-cb {
  background:var(--forest); border-color:var(--forest); color:#fff;
  box-shadow:0 2px 8px rgba(30,70,32,0.3);
}
.item-body { flex:1; min-width:0; }
.item-name { font-weight:800; font-size:15.5px; color:var(--ink); line-height:1.3; }
.item-qty-tag {
  display:inline-block; font-size:11px; font-weight:800;
  padding:1px 7px; border-radius:var(--r-full);
  background:var(--foam-d); color:var(--forest); margin-left:6px; vertical-align:middle;
}
.item-note { font-size:12px; color:var(--ink-50); margin-top:2px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.item-who { font-size:11px; color:var(--ink-30); margin-top:3px; font-family:var(--f-mono); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.item-btns { display:flex; gap:3px; flex-shrink:0; }
.item-btn {
  background:none; border:none; cursor:pointer;
  width:36px; height:36px; border-radius:var(--r-sm);
  display:flex; align-items:center; justify-content:center;
  font-size:16px; color:var(--ink-30); transition:var(--ease);
}
.item-btn:active { transform:scale(0.85); }
.item-btn.undo:hover,.item-btn.undo:active { color:var(--amber); background:var(--amber-lt); }
.item-btn.del:hover,.item-btn.del:active   { color:var(--rose);  background:var(--rose-lt);  }

.empty-list { text-align:center; padding:60px 24px; }
.empty-list-icon { font-size:56px; margin-bottom:16px; }
.empty-list-title { font-family:var(--f-display); font-size:20px; font-weight:800; color:var(--ink-70); margin-bottom:8px; }
.empty-list-sub { font-size:14px; color:var(--ink-30); }

/* Search + filter */
.search-wrap { position:relative; margin-bottom:12px; }
.search-ico { position:absolute; left:13px; top:50%; transform:translateY(-50%); font-size:15px; color:var(--ink-30); pointer-events:none; }
.search-input {
  width:100%; padding:12px 13px 12px 38px;
  border:2px solid var(--ink-10); border-radius:var(--r-sm);
  font-size:15px; font-family:var(--f-body); background:var(--white);
  color:var(--ink); outline:none; transition:var(--ease); -webkit-appearance:none;
}
.search-input:focus { border-color:var(--forest-lt); }
.search-input::placeholder { color:var(--ink-30); }
.filter-pills {
  display:flex; gap:8px; overflow-x:auto; scrollbar-width:none;
  -webkit-overflow-scrolling:touch; margin-bottom:16px; padding-bottom:2px;
}
.filter-pills::-webkit-scrollbar { display:none; }
.filter-pill {
  flex-shrink:0; font-size:12.5px; font-weight:800;
  padding:7px 16px; border-radius:var(--r-full);
  border:2px solid var(--ink-10); background:var(--white);
  color:var(--ink-50); cursor:pointer; transition:var(--ease); white-space:nowrap;
}
.filter-pill.act { background:var(--forest); border-color:var(--forest); color:#fff; box-shadow:var(--s-green); }

/* ======================================================
   MEMBER CARDS (mobile)
   ====================================================== */
.member-cards { display:flex; flex-direction:column; gap:12px; }
.member-card {
  background:var(--white); border:1.5px solid var(--ink-10);
  border-radius:var(--r-md); padding:16px 18px;
  display:flex; align-items:center; gap:14px;
}
.member-av {
  width:46px; height:46px; border-radius:var(--r-full);
  background:linear-gradient(135deg,var(--forest-mid),var(--sage));
  display:flex; align-items:center; justify-content:center;
  font-size:16px; font-weight:900; color:#fff; flex-shrink:0;
}
.member-info { flex:1; min-width:0; }
.member-name { font-weight:800; font-size:15px; }
.member-email { font-size:11.5px; color:var(--ink-50); margin-top:2px; font-family:var(--f-mono); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.member-actions { display:flex; gap:6px; flex-shrink:0; flex-direction:column; align-items:flex-end; }

/* ======================================================
   AUDIT LOG (timeline)
   ====================================================== */
.audit-list { display:flex; flex-direction:column; }
.audit-item {
  display:flex; gap:12px; padding:12px 0;
  border-bottom:1px solid var(--ink-10);
}
.audit-item:last-child { border-bottom:none; }
.audit-dot {
  width:8px; height:8px; border-radius:var(--r-full);
  background:var(--forest-lt); margin-top:5px; flex-shrink:0;
}
.audit-content { flex:1; min-width:0; }
.audit-action {
  display:inline-block; font-size:11px; font-weight:800;
  font-family:var(--f-mono); padding:2px 8px;
  background:var(--foam-d); color:var(--forest);
  border-radius:var(--r-xs); margin-bottom:3px;
}
.audit-detail { font-size:13px; color:var(--ink-70); }
.audit-meta { font-size:11px; color:var(--ink-30); margin-top:3px; font-family:var(--f-mono); }

/* ======================================================
   TABLE (desktop only)
   ====================================================== */
.table-scroll { overflow-x:auto; -webkit-overflow-scrolling:touch; }
.data-table { width:100%; border-collapse:collapse; font-size:13px; display:none; }
.data-table th {
  background:var(--foam); color:var(--forest); font-weight:800;
  font-size:11px; letter-spacing:0.8px; text-transform:uppercase;
  padding:11px 16px; border-bottom:2px solid var(--mist);
  text-align:left; white-space:nowrap;
}
.data-table td { padding:12px 16px; vertical-align:middle; border-bottom:1px solid var(--ivory-d); }
.data-table tr:last-child td { border-bottom:none; }
.data-table tbody tr:hover { background:var(--ivory); }

/* ======================================================
   LOGIN
   ====================================================== */
.login-page {
  min-height:100dvh; display:flex; flex-direction:column;
  background:var(--forest);
  background-image:
    radial-gradient(ellipse at 0% 0%, rgba(61,140,64,0.5) 0%, transparent 55%),
    radial-gradient(ellipse at 100% 100%, rgba(20,45,20,0.7) 0%, transparent 55%);
}
.login-hero {
  flex:1; display:flex; flex-direction:column;
  align-items:center; justify-content:center;
  padding:60px 24px 24px; text-align:center;
}
.login-logo { font-size:56px; margin-bottom:16px; }
.login-h { font-family:var(--f-display); font-size:34px; font-weight:800; color:#fff; letter-spacing:-0.5px; }
.login-tag { font-size:15px; color:var(--mint); margin-top:8px; }
.login-sheet {
  background:var(--white); border-radius:var(--r-xl) var(--r-xl) 0 0;
  padding:32px 24px calc(32px + var(--safe-bottom));
  box-shadow:0 -8px 40px rgba(0,0,0,0.2);
}
.login-sheet-h { font-family:var(--f-display); font-size:22px; font-weight:800; color:var(--forest); margin-bottom:24px; }

/* ======================================================
   PROFILE
   ====================================================== */
.profile-head {
  background:linear-gradient(135deg,var(--forest),var(--forest-mid));
  padding:24px; display:flex; align-items:center; gap:16px;
  border-radius:var(--r-md) var(--r-md) 0 0;
}
.profile-big-av {
  width:64px; height:64px; border-radius:var(--r-full);
  background:rgba(255,255,255,0.2); border:3px solid rgba(255,255,255,0.35);
  display:flex; align-items:center; justify-content:center;
  font-size:24px; font-weight:900; color:#fff; flex-shrink:0;
}
.profile-nm { font-family:var(--f-display); font-size:20px; font-weight:800; color:#fff; }
.profile-em { font-size:13px; color:var(--mint); margin-top:4px; }

/* ======================================================
   TOASTS
   ====================================================== */
.toast-wrap {
  position:fixed; bottom:calc(var(--bnav-h) + 14px);
  left:16px; right:16px; z-index:9999;
  display:flex; flex-direction:column-reverse; gap:8px;
  pointer-events:none;
}
.toast {
  background:var(--ink); color:#fff;
  padding:13px 16px; border-radius:var(--r-sm);
  font-size:14px; font-weight:700; box-shadow:var(--s-lg);
  display:flex; align-items:center; gap:10px;
  animation:toastUp 0.24s cubic-bezier(0.34,1.56,0.64,1);
  pointer-events:all; border-left:4px solid transparent;
}
@keyframes toastUp { from{opacity:0;transform:translateY(16px) scale(0.93)} to{opacity:1;transform:none} }
.toast.success { background:var(--forest); border-left-color:var(--sage); }
.toast.error   { background:#8b1a26; border-left-color:var(--rose); }
.toast.info    { background:#1a4e8b; border-left-color:var(--sky); }

/* ======================================================
   ADMIN
   ====================================================== */
.admin-grid { display:grid; grid-template-columns:1fr; gap:16px; margin-bottom:16px; }
.smtp-grid  { display:grid; grid-template-columns:1fr; gap:0; }

/* ======================================================
   SPINNER
   ====================================================== */
.spin {
  display:inline-block; width:16px; height:16px;
  border:2px solid rgba(255,255,255,0.3);
  border-top-color:currentColor; border-radius:50%;
  animation:rotating 0.65s linear infinite;
}
@keyframes rotating { to{transform:rotate(360deg)} }

/* ======================================================
   UTILS
   ====================================================== */
.text-muted { color:var(--ink-50); }
.text-sm    { font-size:12.5px; }
.text-xs    { font-size:11px; }
.text-c     { text-align:center; }
.mono       { font-family:var(--f-mono); }
.fw7        { font-weight:700; }
.fw8        { font-weight:800; }
.mt-2{margin-top:8px}  .mt-3{margin-top:12px} .mt-4{margin-top:16px} .mt-5{margin-top:20px}
.mb-2{margin-bottom:8px} .mb-3{margin-bottom:12px} .mb-4{margin-bottom:16px} .mb-5{margin-bottom:20px}
.flex{display:flex} .flex-wrap{flex-wrap:wrap} .items-c{align-items:center} .jc-between{justify-content:space-between}
.gap-2{gap:8px} .gap-3{gap:12px} .w-full{width:100%}
.desktop-only{display:none}
.divider{border:none; border-top:1px solid var(--ink-10); margin:16px 0;}

/* ======================================================
   ██ TABLET 640px+
   ====================================================== */
@media(min-width:640px){
  .page-wrap { padding:24px; padding-bottom:calc(var(--bnav-h) + 24px); }
  .form-row { flex-direction:row; }
  .smtp-grid { grid-template-columns:1fr 1fr; gap:16px; }
  .login-page { flex-direction:row; align-items:stretch; }
  .login-hero { flex:1; padding:40px; justify-content:center; }
  .login-sheet {
    width:440px; flex-shrink:0;
    border-radius:0; padding:48px 40px;
    display:flex; flex-direction:column; justify-content:center;
    box-shadow:-8px 0 40px rgba(0,0,0,0.15);
  }
  .modal-bg { align-items:center; padding:16px; }
  .modal-sheet { border-radius:var(--r-lg); max-width:520px; transform:translateY(24px) scale(0.97); }
  .modal-sheet::before { display:none; }
  .modal-bg.active .modal-sheet { transform:none; }
  .modal-foot { flex-direction:row; justify-content:flex-end; }
  .stats-row { grid-template-columns:repeat(4,1fr); }
}

/* ======================================================
   ██ DESKTOP 1024px+
   ====================================================== */
@media(min-width:1024px){
  .bottom-nav { display:none; }
  .hamburger  { display:none; }
  .topnav-links { display:flex; }
  .role-chip  { display:inline-flex; }
  .desktop-only { display:revert; }

  .page-wrap { padding:32px; padding-bottom:32px; }

  /* Grocery side-by-side layout */
  .grocery-desktop { display:grid; grid-template-columns:320px 1fr; gap:24px; align-items:start; }
  .add-sticky { position:sticky; top:80px; }

  /* Add sheet becomes card */
  .add-sheet {
    position:static; transform:none !important;
    border-radius:var(--r-md); border:1px solid var(--ink-10);
    box-shadow:var(--s-sm); background:var(--white);
  }
  .add-sheet-head { border-radius:var(--r-md) var(--r-md) 0 0; padding:16px 20px; }
  .add-sheet-x { display:none; }

  /* Tables visible */
  .data-table { display:table; }
  .mobile-only { display:none; }

  /* Member table instead of cards */
  .member-cards { display:none; }
  .member-table-wrap { display:block; }

  /* Admin 2-col */
  .admin-grid { grid-template-columns:1fr 1fr; }

  /* Toasts from right */
  .toast-wrap { bottom:24px; left:auto; right:24px; max-width:380px; }
}

/* ======================================================
   ██ WIDE 1280px+
   ====================================================== */
@media(min-width:1280px){
  .page-wrap { padding:40px; }
  .grocery-desktop { grid-template-columns:340px 1fr; gap:32px; }
}

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

/* ======================================================
   GROCERY DESKTOP LAYOUT FIXES
   ====================================================== */

/* Mobile: grocery-desktop is just a single column */
.grocery-desktop {
  display: flex;
  flex-direction: column;
}

/* Desktop slot is hidden on mobile */
.add-sticky {
  display: none;
}

@media (min-width: 1024px) {
  .grocery-desktop {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 24px;
    align-items: start;
  }
  .add-sticky {
    display: block;
    position: sticky;
    top: 76px;
  }

  /* On desktop, the add-sheet is a static card */
  #addSheet {
    position: static !important;
    transform: none !important;
    border-radius: var(--r-md);
    border: 1px solid var(--ink-10);
    box-shadow: var(--s-sm);
    background: var(--white);
    display: flex;
    flex-direction: column;
  }
  #addSheet .add-sheet-head {
    border-radius: var(--r-md) var(--r-md) 0 0;
    padding: 16px 20px;
  }
  #addSheet .add-sheet-x {
    display: none;
  }
  #addSheet .add-sheet-body {
    padding: 20px;
  }
}

@media (min-width: 1280px) {
  .grocery-desktop {
    grid-template-columns: 340px 1fr;
    gap: 32px;
  }
}

/* ======================================================
   MOBILE-ONLY / DESKTOP-ONLY VISIBILITY
   ====================================================== */
@media (min-width: 1024px) {
  .mobile-only  { display: none !important; }
  .desktop-only { display: revert !important; }
  .desktop-only.btn { display: inline-flex !important; }
}

/* ======================================================
   BOTTOM NAV: hide on desktop
   ====================================================== */
@media (min-width: 1024px) {
  .bottom-nav { display: none !important; }
  .page-wrap {
    padding-bottom: 32px !important;
  }
  .toast-wrap {
    bottom: 24px !important;
    left: auto !important;
    right: 24px !important;
    max-width: 380px;
  }
}

/* ======================================================
   ADMIN SMTP: 2-col on tablet+
   ====================================================== */
@media (min-width: 640px) {
  .smtp-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
}

/* ======================================================
   MEMBER TABLE: show on desktop, hide mobile cards
   ====================================================== */
@media (min-width: 1024px) {
  .member-table-wrap { display: block !important; }
  .member-cards.mobile-only { display: none !important; }
  .data-table { display: table !important; }
}

/* ======================================================
   FORM ROW: horizontal on tablet+
   ====================================================== */
@media (min-width: 640px) {
  .form-row { flex-direction: row; }
}

/* ======================================================
   STATS: 4 columns on tablet+
   ====================================================== */
@media (min-width: 640px) {
  .stats-row { grid-template-columns: repeat(4, 1fr); }
}

/* ======================================================
   ADMIN GRID: 2 cols on desktop
   ====================================================== */
@media (min-width: 1024px) {
  .admin-grid { grid-template-columns: 1fr 1fr; }
}

/* ======================================================
   TOPNAV: show links and hide hamburger on desktop
   ====================================================== */
@media (min-width: 1024px) {
  .hamburger    { display: none !important; }
  .topnav-links { display: flex !important; }
  .role-chip    { display: inline-flex !important; }
}

/* ======================================================
   LOGIN: side-by-side on tablet+
   ====================================================== */
@media (min-width: 640px) {
  .login-page {
    flex-direction: row;
    align-items: stretch;
  }
  .login-hero {
    flex: 1;
    padding: 48px;
    justify-content: center;
  }
  .login-sheet {
    width: 420px;
    flex-shrink: 0;
    border-radius: 0;
    padding: 56px 48px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: -8px 0 40px rgba(0,0,0,0.15);
  }
}

/* ======================================================
   MODAL: centered on tablet+
   ====================================================== */
@media (min-width: 640px) {
  .modal-bg {
    align-items: center;
    padding: 16px;
  }
  .modal-sheet {
    border-radius: var(--r-lg);
    max-width: 520px;
    transform: translateY(24px) scale(0.97);
  }
  .modal-sheet::before { display: none; }
  .modal-bg.active .modal-sheet {
    transform: translateY(0) scale(1);
  }
  .modal-foot {
    flex-direction: row;
    justify-content: flex-end;
  }
  .modal-foot .btn-full {
    width: auto;
  }
}

/* main-content: full-width wrapper inside <main> tag */
.main-content {
  width: 100%;
  min-height: calc(100dvh - calc(56px + var(--safe-top)));
}

/* ======================================================
   GROCERY LIST — SPLIT SECTIONS & NEW BUY BUTTON
   ====================================================== */

/* Section headers */
.list-section { margin-bottom: 8px; }
.list-section-header {
  display: flex; align-items: center; gap: 10px;
  padding: 0 2px 10px;
}
.list-section-title {
  font-family: var(--f-display); font-size: 15px; font-weight: 800;
  color: var(--ink-70); text-transform: uppercase; letter-spacing: 0.8px;
}
.bought-title { color: var(--ink-30); }
.list-section-count {
  background: var(--forest); color: #fff;
  font-size: 11px; font-weight: 800;
  padding: 2px 9px; border-radius: var(--r-full);
}
.list-section:has(.bought-title) .list-section-count,
.bought-title ~ .list-section-count {
  background: var(--ink-10); color: var(--ink-50);
}

/* Item name row */
.item-name-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; }

/* ── Buy button — large, unambiguous ── */
.item-buy-btn {
  flex-shrink: 0;
  width: 36px; height: 36px;
  border-radius: var(--r-full);
  border: 2.5px solid var(--ink-10);
  background: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--ease-spring);
  position: relative;
}
.item-buy-btn:active { transform: scale(0.82); }
.item-buy-btn:hover {
  border-color: var(--forest-lt);
  background: var(--foam);
}

/* The inner circle — becomes a checkmark */
.buy-btn-circle {
  width: 20px; height: 20px;
  border-radius: var(--r-full);
  border: 2px solid var(--ink-10);
  background: transparent;
  display: block;
  position: relative;
  transition: var(--ease-spring);
}
.item-buy-btn:hover .buy-btn-circle {
  border-color: var(--forest-lt);
  background: var(--foam-d);
}

/* Checked state — filled green with ✓ */
.item-buy-btn.is-checked {
  border-color: var(--forest);
  background: var(--forest);
  box-shadow: 0 3px 10px rgba(30,70,32,0.35);
}
.item-buy-btn.is-checked .buy-btn-circle {
  border: none;
  background: transparent;
}
.item-buy-btn.is-checked .buy-btn-circle::after {
  content: '';
  position: absolute;
  top: 1px; left: 5px;
  width: 6px; height: 11px;
  border: 2.5px solid #fff;
  border-top: none; border-left: none;
  transform: rotate(45deg);
}
.item-buy-btn.is-checked:hover {
  background: var(--forest-mid);
  border-color: var(--forest-mid);
}

/* Delete button */
.item-del-btn {
  flex-shrink: 0;
  background: none; border: none; cursor: pointer;
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--ink-30);
  transition: var(--ease);
}
.item-del-btn:hover { color: var(--rose); background: var(--rose-lt); }
.item-del-btn:active { transform: scale(0.85); }

/* Bought row styling */
.item-row.is-bought {
  opacity: 0.6;
  background: var(--ivory);
}
.item-row.is-bought .item-name {
  text-decoration: line-through;
  color: var(--ink-30);
}

/* Meta line */
.item-meta {
  font-size: 11.5px; color: var(--ink-30);
  margin-top: 4px; font-family: var(--f-mono);
}
.item-meta strong { font-weight: 700; color: var(--ink-50); font-family: var(--f-body); }
.item-date { opacity: 0.8; }

/* Progress bar — thinner, sits right under header */
.list-progress-wrap { margin: 0 0 20px; }
.list-progress-track { background: var(--ink-10); border-radius: var(--r-full); height: 4px; overflow: hidden; }
.list-progress-fill  { height: 100%; background: linear-gradient(90deg, var(--sage), var(--forest-lt)); border-radius: var(--r-full); transition: width 0.4s ease; }

/* Divider between sections */
#section-bought { border-top: 1.5px dashed var(--ink-10); padding-top: 8px; }

/* ── Remove old .item-cb rule conflicts ── */
.item-cb { display: none; } /* deprecated, hidden */

/* ── App footer ─────────────────────────────────────────────── */
/* Sits just below last content; never scrolls away on short pages */
body {
  display: flex;
  flex-direction: column;
}
.main-content {
  flex: 1;
}
.app-footer {
  text-align: center;
  padding: 24px 16px;
  padding-bottom: calc(var(--bnav-h) + 12px); /* clear mobile bottom nav */
  font-size: 11.5px;
  color: var(--ink-30);
  letter-spacing: 0.3px;
  flex-shrink: 0;
}
@media (min-width: 1024px) {
  .app-footer {
    padding-bottom: 24px;
  }
}
