/* Home Management — mobile-first stylesheet.

   Base rules target phones; @media (min-width: …) layers add room for
   tablets (640px) and the desktop shell (960px: sidebar instead of tab bar).
   No framework, no build step. Tokens first, then shell, then components. */

/* ============================== Tokens ============================== */
:root {
  --bg: #f2f2f7;
  --bg-elev: #e9e9ee;
  --surface: #ffffff;
  --surface-2: #f8f8fb;
  --text: #1c1c1e;
  --muted: #6c6c72;
  --faint: #a1a1a8;
  --primary: #0a6cdf;
  --primary-dark: #0058c0;
  --primary-tint: rgba(10, 108, 223, 0.10);
  --on-primary: #ffffff;
  --border: rgba(60, 60, 67, 0.13);
  --border-strong: rgba(60, 60, 67, 0.28);
  --danger: #d70015;
  --danger-bg: #fdeceb;
  --success: #1a7f37;
  --success-bg: #e6f6eb;
  --warning: #9a5b00;
  --warning-bg: #fff4dc;
  --info: #0b5cad;
  --info-bg: #e8f2fc;
  --accent-warm: #f76b15;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 2px 10px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.16);
  --ring: 0 0 0 4px rgba(10,108,223,0.22);
  --bar-bg: rgba(249,249,251,0.86);
  --sidebar-w: 252px;
  --topbar-h: 56px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-elev: #1c1c1e;
    --surface: #1c1c1e;
    --surface-2: #242427;
    --text: #f2f2f7;
    --muted: #9a9aa1;
    --faint: #6c6c72;
    --primary: #3b94ff;
    --primary-dark: #62a9ff;
    --primary-tint: rgba(59, 148, 255, 0.18);
    --border: rgba(255, 255, 255, 0.11);
    --border-strong: rgba(255, 255, 255, 0.24);
    --danger: #ff5c52;
    --danger-bg: #3a1512;
    --success: #34c759;
    --success-bg: #0f2a17;
    --warning: #ffcc4d;
    --warning-bg: #2d2410;
    --info: #64d2ff;
    --info-bg: #0e2733;
    --shadow: 0 1px 2px rgba(0,0,0,0.6);
    --shadow-lg: 0 12px 48px rgba(0,0,0,0.7);
    --ring: 0 0 0 4px rgba(59,148,255,0.3);
    --bar-bg: rgba(22,22,24,0.86);
  }
}

/* ============================== Base ============================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; overflow-x: clip; font-family: var(--font); color: var(--text); background: var(--bg);
  font-size: 16px; line-height: 1.45; letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--primary); }
h1, h2, h3 { letter-spacing: -0.022em; line-height: 1.2; }
h1 { font-size: 1.6rem; font-weight: 700; margin: 0 0 6px; }
h2 { font-size: 1.15rem; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.mt { margin-top: 18px; }
.ta-right { text-align: right; }
.unit { font-size: 0.7em; color: var(--muted); font-weight: 600; }
.container { width: 100%; max-width: 960px; margin: 0 auto; padding: 0 16px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.icon { width: 1.25em; height: 1.25em; display: inline-block; vertical-align: -0.22em; flex-shrink: 0; }
h1 .icon, h2 .icon { vertical-align: -0.14em; margin-right: 0.3em; color: var(--primary); }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 8px; }

/* ============================== App shell ============================== */
.sidebar { display: none; }

.topbar {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; gap: 10px;
  height: calc(var(--topbar-h) + var(--safe-t)); padding: var(--safe-t) 12px 0 16px;
  background: var(--bar-bg); border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
}
.topbar-brand { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1;
  color: var(--text); text-decoration: none; font-weight: 650; font-size: 1.02rem; }
.topbar-org { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0; display: inline-flex;
  align-items: center; justify-content: center; color: #fff;
  background: linear-gradient(135deg, #0a6cdf, #38b6ff); }
.topbar-search, .topbar-actions .topbar-new { display: none; }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.topbar-avatar { display: inline-flex; padding: 4px; border-radius: 50%; }

.icon-btn { display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%; border: none; background: none;
  color: var(--text); cursor: pointer; text-decoration: none; }
.icon-btn:hover { background: var(--bg-elev); }

.acting-bar { position: sticky; top: calc(var(--topbar-h) + var(--safe-t)); z-index: 55;
  display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 16px;
  background: #fff1e6; color: #7a3300; border-bottom: 1px solid #ffd8bd; font-size: 0.92rem; }
.acting-bar > span:not(.avatar) { flex: 1; min-width: 0; }
.acting-bar form { margin: 0; }
@media (prefers-color-scheme: dark) { .acting-bar { background: #33200f; color: #ffc59a; border-color: #4d2f14; } }

.content { padding: 18px 16px calc(var(--tabbar-h) + var(--safe-b) + 28px); max-width: 1120px; }

/* Phone tab bar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding: 0 6px var(--safe-b);
  background: var(--bar-bg); border-top: 1px solid var(--border);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); }
.tabbar-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: 100%; color: var(--muted); text-decoration: none; font-size: 0.68rem; font-weight: 600;
  min-width: 0; }
.tabbar-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabbar-item.active { color: var(--primary); }
.tabbar-add { justify-self: center; width: 54px; height: 54px; margin-top: -18px; border-radius: 50%;
  border: 4px solid var(--bg); background: var(--primary); color: var(--on-primary); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(10,108,223,0.35); }
.tabbar-add:active { transform: scale(0.94); }

/* Public (signed-out) pages */
.public-header { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(12px + var(--safe-t)) 16px 12px; }
.public-nav { display: flex; align-items: center; gap: 14px; }
.public-nav a:not(.btn) { color: var(--text); text-decoration: none; font-weight: 500; }
.public-main { padding: 8px 16px 48px; }

/* Desktop shell */
@media (min-width: 960px) {
  .sidebar { display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
    background: var(--surface-2); border-right: 1px solid var(--border); padding: 14px 10px; z-index: 50; overflow-y: auto; }
  .topbar { margin-left: var(--sidebar-w); padding: 0 24px 0 28px; height: var(--topbar-h); }
  .topbar-brand { display: none; }
  .topbar-search { display: flex; align-items: center; gap: 8px; flex: 1; max-width: 420px; padding: 0 12px;
    height: 38px; border-radius: 10px; background: var(--bg-elev); color: var(--muted); }
  .topbar-search input { flex: 1; border: none; background: none; font: inherit; font-size: 0.95rem; color: var(--text); outline: none; min-width: 0; }
  .topbar-search:focus-within { box-shadow: var(--ring); background: var(--surface); }
  .topbar-actions { margin-left: auto; gap: 10px; }
  .topbar-search-btn { display: none; }
  .topbar-actions .topbar-new { display: inline-flex; }
  .acting-bar { margin-left: var(--sidebar-w); top: var(--topbar-h); padding-left: 28px; }
  .content { margin-left: var(--sidebar-w); padding: 28px 36px 64px; }
  .tabbar { display: none; }
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; text-decoration: none; color: var(--text); }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 0.75rem; color: var(--muted); }
.sidenav { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.sidenav-link { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 9px;
  color: var(--text); text-decoration: none; font-size: 0.94rem; font-weight: 500; }
.sidenav-link .icon { color: var(--muted); }
.sidenav-link:hover { background: var(--bg-elev); }
.sidenav-link.active { background: var(--primary-tint); color: var(--primary); font-weight: 600; }
.sidenav-link.active .icon { color: var(--primary); }
.sidenav-sep { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--faint); padding: 16px 10px 5px; }
.sidebar-me { display: flex; align-items: center; gap: 10px; padding: 10px 8px; margin-top: 10px;
  border-top: 1px solid var(--border); text-decoration: none; color: var(--text); font-weight: 600; font-size: 0.92rem; }
.sidebar-me-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }

/* ============================== Sheets & dialogs ============================== */
.sheet { position: fixed; inset: 0; z-index: 200; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.35); opacity: 0; transition: opacity .2s ease; }
.sheet-panel { position: absolute; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow-y: auto;
  background: var(--surface); border-radius: 22px 22px 0 0; padding: 8px 16px calc(20px + var(--safe-b));
  transform: translateY(100%); transition: transform .26s cubic-bezier(.2,.8,.2,1); box-shadow: var(--shadow-lg); }
.sheet.open .sheet-backdrop { opacity: 1; }
.sheet.open .sheet-panel { transform: none; }
.sheet-grabber { width: 38px; height: 5px; border-radius: 3px; background: var(--border-strong); margin: 2px auto 8px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sheet-head h2 { margin: 0; font-size: 1.2rem; }
@media (min-width: 640px) {
  .sheet-panel { left: 50%; right: auto; bottom: auto; top: 50%; width: 520px; border-radius: var(--radius-lg);
    transform: translate(-50%, -46%) scale(0.97); opacity: 0; transition: transform .2s ease, opacity .2s ease; padding: 16px 20px 22px; }
  .sheet.open .sheet-panel { transform: translate(-50%, -50%); opacity: 1; }
  .sheet-grabber { display: none; }
}
.quick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.quick-item { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 6px;
  border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); text-decoration: none; font-size: 0.85rem; font-weight: 600; text-align: center; }
.quick-item:active { transform: scale(0.97); }
.quick-icon { width: 44px; height: 44px; border-radius: 13px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary-tint); color: var(--primary); }
.quick-item.is-featured { grid-column: 1 / -1; flex-direction: row; justify-content: center; gap: 12px;
  background: linear-gradient(135deg, #0a6cdf, #38b6ff); color: #fff; border: none; font-size: 0.98rem; }
.quick-item.is-featured .quick-icon { background: rgba(255,255,255,0.2); color: #fff; }

/* Confirm dialog (built by main.js) */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.35); display: flex; align-items: center;
  justify-content: center; z-index: 1000; opacity: 0; transition: opacity .18s ease; padding: 20px; }
.modal-overlay.show { opacity: 1; }
.modal { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%;
  max-width: 320px; text-align: center; overflow: hidden; transform: scale(0.94); transition: transform .18s ease; }
.modal-overlay.show .modal { transform: scale(1); }
.modal-body { padding: 24px 22px 8px; }
.modal-title { font-weight: 650; font-size: 1.05rem; margin: 0 0 6px; }
.modal-text { color: var(--muted); font-size: 0.92rem; margin: 0; }
.modal-actions { display: flex; border-top: 1px solid var(--border); margin-top: 20px; }
.modal-btn { flex: 1; padding: 14px; background: none; border: none; font: inherit; cursor: pointer; color: var(--primary); }
.modal-btn + .modal-btn { border-left: 1px solid var(--border); }
.modal-btn.danger { color: var(--danger); font-weight: 650; }

/* ============================== Flash toasts ============================== */
.flashes { position: fixed; top: calc(var(--topbar-h) + var(--safe-t) + 8px); left: 50%; transform: translateX(-50%);
  z-index: 300; width: min(94vw, 460px); display: grid; gap: 8px; }
.flash { padding: 12px 16px; border-radius: 14px; font-size: 0.93rem; box-shadow: var(--shadow-lg);
  border: 1px solid var(--border); animation: toast-in .25s ease; word-break: break-word; }
.flash-danger { background: var(--danger-bg); color: var(--danger); }
.flash-success { background: var(--success-bg); color: var(--success); }
.flash-warning { background: var(--warning-bg); color: var(--warning); }
.flash-info { background: var(--info-bg); color: var(--info); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.is-public .flashes { top: 12px; }

/* ============================== Buttons & inputs ============================== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px;
  padding: 10px 20px; border-radius: 999px; border: none; background: var(--primary); color: var(--on-primary);
  font: inherit; font-size: 0.97rem; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .15s ease, transform .08s ease; }
.btn:hover { background: var(--primary-dark); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-sm { min-height: 36px; padding: 6px 14px; font-size: 0.88rem; }
.btn-block { width: 100%; }
.btn-ghost { background: var(--surface); color: var(--primary); border: 1px solid var(--border-strong); }
.btn-ghost:hover { background: var(--bg-elev); }
.btn-light { background: rgba(255,255,255,0.7); color: inherit; border: 1px solid rgba(0,0,0,0.1); }
.btn-danger { background: var(--danger); }
.btn-lg { min-height: 52px; font-size: 1.05rem; padding: 12px 24px; }

.input { width: 100%; min-height: 44px; padding: 10px 13px; border-radius: 12px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: 16px; transition: border-color .15s, box-shadow .15s; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
textarea.input { resize: vertical; min-height: 72px; }
select.input { -webkit-appearance: none; appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238a8a90' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; accent-color: var(--primary); flex-shrink: 0; }
.input-sm { min-height: 36px; padding: 5px 10px; font-size: 15px; width: auto; }
.input-qty { flex: 0 0 76px; max-width: 76px; }
.field-error { display: block; color: var(--danger); font-size: 0.83rem; margin-top: 4px; }
.checkbox-inline { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 0.93rem; margin: 12px 0; flex-wrap: wrap; }
.link-input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; }
.copy-field { display: flex; gap: 8px; align-items: center; }
.copy-field .input { flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; }

.link-muted { background: none; border: none; color: var(--muted); text-decoration: none; font: inherit; font-size: 0.88rem;
  cursor: pointer; padding: 8px 6px; min-height: 36px; display: inline-flex; align-items: center; gap: 4px; }
.link-muted:hover { color: var(--text); }
.link-danger:hover { color: var(--danger); }
.inline-form { display: inline; margin: 0; }

/* Switch */
.switch { position: relative; display: inline-block; width: 51px; height: 31px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 999px; transition: .2s; }
.slider::before { content: ""; position: absolute; height: 27px; width: 27px; left: 1px; top: 1px; background: #fff;
  border-radius: 50%; transition: .2s; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.switch input:checked + .slider { background: #34c759; border-color: #34c759; }
.switch input:checked + .slider::before { transform: translateX(20px); }
.switch input:disabled + .slider { cursor: not-allowed; opacity: 0.5; }

/* Segmented control */
.seg { display: inline-flex; background: var(--bg-elev); border-radius: 10px; padding: 2px; gap: 2px; }
.seg-btn { padding: 7px 16px; border-radius: 8px; text-decoration: none; color: var(--text); font-size: 0.9rem; font-weight: 500; text-align: center; }
.seg-btn.active { background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,0.12); font-weight: 650; }
.seg-wide { display: flex; width: 100%; max-width: 360px; }
.seg-wide .seg-btn { flex: 1; }

/* ============================== Page structure ============================== */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.page-head h1 { margin: 0; }
.page-head .section-title { margin: 0; }
.page-sub { color: var(--muted); margin: 2px 0 16px; font-size: 0.95rem; }
.row-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.section-title { font-size: 1.08rem; font-weight: 700; margin: 26px 0 10px; display: flex; align-items: center; gap: 4px; }
.section-title .icon { margin-right: 4px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 26px 0 10px; }
.section-head .section-title { margin: 0; }
.section-link { font-size: 0.9rem; font-weight: 600; text-decoration: none; }
.back-link { display: inline-flex; align-items: center; gap: 2px; color: var(--primary); text-decoration: none; font-weight: 500; margin-bottom: 8px; font-size: 0.95rem; }

.dash-grid { display: grid; grid-template-columns: 1fr; gap: 0 28px; }
.dash-grid > *, .content > * { min-width: 0; }   /* let inner scrollers scroll instead of widening the page */
@media (min-width: 900px) { .dash-grid { grid-template-columns: 1fr 1fr; } }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; box-shadow: var(--shadow); }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0; }
@media (min-width: 640px) { .cards { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; } }
.card-label { color: var(--muted); font-size: 0.82rem; font-weight: 500; display: flex; align-items: center; gap: 5px; }
.card-value { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.03em; margin-top: 2px; }
.card-sub { margin-top: 4px; }
.card-link { display: block; text-decoration: none; color: inherit; transition: transform .15s ease, box-shadow .15s ease; }
.card-link:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.form-card { margin: 12px 0; }
.form-card label { display: block; margin: 12px 0 5px; font-size: 0.9rem; font-weight: 600; }
.form-card label.checkbox-inline { display: flex; }
.form-card .btn { margin-top: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
@media (min-width: 640px) { .form-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); } }

/* Collapsible add forms (opened by buttons, the + sheet, or ?add=1) */
.collapse { display: none; }
.collapse.open { display: block; animation: fade-in .18s ease; }
@keyframes fade-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* Empty states */
.placeholder, .empty { background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
  padding: 26px 20px; color: var(--muted); text-align: center; }
.placeholder p { margin: 0; }
.empty-icon { width: 54px; height: 54px; border-radius: 16px; margin: 0 auto 10px; display: flex; align-items: center; justify-content: center;
  background: var(--primary-tint); color: var(--primary); }
.empty-title { font-weight: 650; color: var(--text); margin: 0 0 4px; }
.empty-text { margin: 0 0 14px; font-size: 0.93rem; }

/* Tabs → horizontal scrolling pills on phones */
.tabs { display: flex; gap: 6px; margin: 14px -16px 14px; padding: 2px 16px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex-shrink: 0; padding: 7px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border);
  color: var(--text); text-decoration: none; font-size: 0.9rem; font-weight: 500; white-space: nowrap; }
.tab.active { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }
.tab-toggle { margin-left: auto; }
.tab-count { background: var(--primary); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 0.72rem; font-weight: 700; margin-left: 2px; }
.tab.active .tab-count { background: var(--bg); color: var(--text); }
@media (min-width: 960px) { .tabs { margin: 14px 0; padding: 2px 0; flex-wrap: wrap; } }

/* Chips & badges */
.filter-row { display: flex; align-items: center; gap: 6px; margin: 10px -16px 14px; padding: 2px 16px; overflow-x: auto; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
@media (min-width: 960px) { .filter-row { flex-wrap: wrap; margin: 10px 0 14px; padding: 0; } }
.chip { display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); text-decoration: none; font-size: 0.85rem; white-space: nowrap; }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }
.chip.static { background: var(--bg-elev); border-color: transparent; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; background: var(--bg-elev);
  color: var(--muted); font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.badge-soon { background: var(--warning-bg); color: var(--warning); }
.badge-low, .badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-ok { background: var(--success-bg); color: var(--success); }
.badge-grab, .badge-info { background: var(--primary-tint); color: var(--primary); }
.badge-income { background: var(--success-bg); color: var(--success); }
.overdue-text { color: var(--danger); font-weight: 600; }
.income-text { color: var(--success); }
.expense-text { color: var(--danger); }
.penalty-tag { color: var(--warning); font-weight: 600; }

/* Avatars */
.avatar { --av: #0a84ff; --av-size: 32px; width: var(--av-size); height: var(--av-size); flex-shrink: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; background: var(--av); color: #fff;
  font-size: calc(var(--av-size) * 0.4); font-weight: 700; letter-spacing: 0; line-height: 1; }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { border: 2px solid var(--surface); margin-left: -8px; }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* ============================== Lists (the workhorse) ============================== */
.task-list, .event-list, .mt-list, .bday-list, .fin-list, .ing-list, .list {
  list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.task-item, .event-item, .mt-item, .bday-item, .fin-row, .ing-item, .list-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-height: 56px; }
.task-item.is-overdue, .mt-item.is-overdue { border-left: 4px solid var(--danger); }
.task-item.is-claimable { border-left: 4px solid var(--primary); }
.task-item.is-done .task-title { text-decoration: line-through; color: var(--muted); }
.task-check { display: flex; margin: 0; }
.task-body, .event-body, .mt-body, .bday-info, .fin-main, .list-main { flex: 1; min-width: 0; }
.task-title, .event-title, .fin-name, .list-title, .bday-name { font-weight: 600; overflow-wrap: anywhere; }
.task-sub { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 3px; align-items: center; }
.task-actions, .event-actions, .bday-actions, .fin-actions, .list-actions { display: flex; align-items: center; gap: 2px 6px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.points-badge { background: var(--success-bg); color: var(--success); font-weight: 700; font-size: 0.8rem; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }

/* Round tap-to-complete checkbox (templates render ☐/☑ glyphs; we draw the circle) */
.checkbox { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--border-strong); background: none; cursor: pointer;
  font-size: 0; color: transparent; padding: 0; position: relative; flex-shrink: 0; transition: background .15s, border-color .15s; }
.checkbox:hover { border-color: var(--primary); }
.is-done .checkbox { background: var(--primary); border-color: var(--primary); }
.is-done .checkbox::after { content: ""; position: absolute; left: 8px; top: 3px; width: 7px; height: 13px;
  border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.checkbox.locked { border: none; font-size: 1rem; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; cursor: default; }

/* Grouped list (iOS settings style) */
.group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); }
.group + .group { margin-top: 14px; }
.group-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 54px; color: var(--text); text-decoration: none;
  border-top: 1px solid var(--border); background: none; width: 100%; font: inherit; text-align: left; }
.group-row:first-child { border-top: none; }
a.group-row:hover, button.group-row:hover { background: var(--surface-2); }
.group-row .chev { color: var(--faint); margin-left: auto; }
.group-icon { width: 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary-tint); color: var(--primary); flex-shrink: 0; }
.group-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.group-title { font-weight: 600; }
.group-sub { color: var(--muted); font-size: 0.85rem; }
.group-label { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 22px 4px 8px; }

/* Tables: horizontal scroll on phones */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { text-align: left; padding: 11px 13px; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
.table th { background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 0.82rem; }
.table tr:last-child td { border-bottom: none; }
.row-inactive { opacity: 0.55; }

/* ============================== Home (Family / Me) ============================== */
.home-head { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.greeting { font-size: 1.7rem; font-weight: 750; margin: 0; letter-spacing: -0.03em; }
.greeting-date { color: var(--muted); font-weight: 500; margin: 2px 0 0; }
@media (min-width: 640px) { .home-head { flex-direction: row; align-items: flex-end; justify-content: space-between; } }

.brief-card { display: flex; gap: 12px; align-items: flex-start; padding: 16px; border-radius: var(--radius-lg); color: #fff; margin: 0 0 16px;
  background: linear-gradient(135deg, #0a6cdf 0%, #38b6ff 100%); box-shadow: 0 6px 20px rgba(10,108,223,0.25); }
.brief-icon { margin-top: 1px; }
.brief-title { font-weight: 700; font-size: 0.78rem; opacity: 0.9; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.05em; }
.brief-lines { margin: 0; padding-left: 18px; font-size: 0.97rem; }
.brief-lines li { margin: 3px 0; }

.attention { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; }
@media (min-width: 640px) { .attention { grid-template-columns: repeat(4, 1fr); } }
.attn { display: flex; flex-direction: column; gap: 2px; padding: 14px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow); text-decoration: none; color: var(--text); }
.attn-icon { width: 32px; height: 32px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; margin-bottom: 6px; }
.attn-num { font-size: 1.5rem; font-weight: 750; letter-spacing: -0.03em; line-height: 1.1; }
.attn-label { font-size: 0.85rem; color: var(--muted); font-weight: 500; }
.attn.red .attn-icon { background: var(--danger-bg); color: var(--danger); }
.attn.orange .attn-icon { background: var(--warning-bg); color: var(--warning); }
.attn.blue .attn-icon { background: var(--primary-tint); color: var(--primary); }
.attn.green .attn-icon { background: var(--success-bg); color: var(--success); }

.agenda { display: grid; gap: 8px; }
.agenda-row { display: flex; gap: 12px; align-items: center; padding: 11px 14px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); text-decoration: none; color: var(--text); }
.agenda-time { flex: 0 0 54px; font-weight: 700; font-size: 0.88rem; color: var(--primary); }
.agenda-main { flex: 1; min-width: 0; }
.agenda-title { font-weight: 600; overflow-wrap: anywhere; }

.people { display: flex; gap: 14px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: none; }
.people::-webkit-scrollbar { display: none; }
.person { display: flex; flex-direction: column; align-items: center; gap: 6px; flex-shrink: 0; width: 70px; text-decoration: none;
  color: var(--text); font-size: 0.8rem; font-weight: 600; background: none; border: none; font-family: inherit; cursor: pointer; padding: 0; }
.person span:last-child { max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-add .avatar { background: var(--bg-elev); color: var(--muted); }

.setup-card { display: flex; gap: 14px; align-items: center; padding: 16px; border-radius: var(--radius-lg); margin-bottom: 16px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.setup-card .grow { flex: 1; min-width: 0; }

/* Modules grid (More page / dashboard) */
.module-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (min-width: 640px) { .module-tiles { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); } }
.module-tile { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 6px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); box-shadow: var(--shadow); text-align: center; }
.module-tile:active { transform: scale(0.97); }
.module-tile-icon { width: 46px; height: 46px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary-tint); color: var(--primary); }
.module-tile-name { font-size: 0.85rem; font-weight: 600; }

/* Activity feed */
.activity-feed { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.activity-feed li { display: flex; align-items: baseline; gap: 10px; padding: 11px 14px; border-top: 1px solid var(--border); font-size: 0.92rem; }
.activity-feed li:first-child { border-top: none; }
.activity-dot { color: var(--primary); }
.activity-msg { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.activity-time { white-space: nowrap; }

/* Settings → module rows */
.module-list { display: grid; gap: 0; margin: 16px 0 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.module-row { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-top: 1px solid var(--border); }
.module-row:first-child { border-top: none; }
.module-row.is-soon { opacity: 0.6; }
.module-icon { width: 36px; height: 36px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary-tint); color: var(--primary); flex-shrink: 0; }
.module-meta { flex: 1; min-width: 0; }
.module-name { font-weight: 600; display: flex; align-items: center; gap: 8px; }

/* ============================== Auth & onboarding ============================== */
.auth-card { max-width: 420px; margin: 4vh auto 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 28px 22px; box-shadow: var(--shadow-lg); }
.auth-card h1 { text-align: center; font-size: 1.45rem; }
.auth-card > .muted { text-align: center; }
.auth-card label { display: block; margin: 14px 0 5px; font-size: 0.9rem; font-weight: 600; }
.auth-card label.checkbox { font-weight: 500; display: flex; align-items: center; gap: 8px; }
.auth-card .btn-block { margin-top: 20px; }
.auth-alt { margin-top: 18px; text-align: center; color: var(--muted); font-size: 0.92rem; }

.hero { text-align: center; padding: 40px 0 20px; max-width: 760px; margin: 0 auto; }
.hero h1 { font-size: 2.2rem; letter-spacing: -0.035em; }
@media (min-width: 640px) { .hero h1 { font-size: 3rem; } }
.lead { max-width: 560px; margin: 12px auto 26px; color: var(--muted); font-size: 1.1rem; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.features { display: grid; grid-template-columns: 1fr; gap: 12px; max-width: 980px; margin: 30px auto 0; }
@media (min-width: 640px) { .features { grid-template-columns: repeat(3, 1fr); } }
.feature { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow); }
.feature h3 { margin: 10px 0 4px; font-size: 1.02rem; }
.feature p { margin: 0; color: var(--muted); font-size: 0.93rem; }

.wizard { max-width: 640px; margin: 0 auto; }
.steps { display: flex; gap: 6px; margin: 4px 0 18px; }
.steps span { flex: 1; height: 4px; border-radius: 2px; background: var(--bg-elev); }
.steps span.on { background: var(--primary); }
.goal-grid { display: grid; gap: 10px; }
.goal { display: flex; gap: 12px; align-items: flex-start; padding: 14px; background: var(--surface); border: 2px solid var(--border);
  border-radius: var(--radius); cursor: pointer; }
.goal:has(input:checked) { border-color: var(--primary); background: var(--primary-tint); }
.goal input { margin-top: 2px; }
.goal-title { font-weight: 650; }
.goal-desc { color: var(--muted); font-size: 0.9rem; }
.wizard-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 22px; }

/* ============================== Module-specific ============================== */
/* Shopping */
.add-item-row { display: flex; gap: 8px; margin: 8px 0 14px; }
.add-item-row .input { flex: 1; min-width: 0; }
.new-list-row { display: flex; gap: 8px; margin-top: 22px; max-width: 520px; }
.new-list-row .input { flex: 1; min-width: 0; }
.shop-list .task-item { padding: 10px 14px; }

/* Rewards */
.leaderboard { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.lb-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--border); }
.lb-row:first-child { border-top: none; }
.lb-row.is-me { background: var(--primary-tint); }
.lb-rank { width: 28px; height: 28px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border-radius: 50%;
  background: var(--bg-elev); font-weight: 700; font-size: 0.85rem; }
.lb-rank.rank-1 { background: #fde68a; color: #92400e; }
.lb-rank.rank-2 { background: #e5e7eb; color: #374151; }
.lb-rank.rank-3 { background: #fed7aa; color: #9a3412; }
.lb-name { flex: 1; font-weight: 600; min-width: 0; }
.lb-month { white-space: nowrap; }
.lb-points { font-weight: 700; white-space: nowrap; }
.reward-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 12px; }
@media (min-width: 640px) { .reward-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); } }
.reward-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; }
.reward-card.is-inactive { opacity: 0.6; }
.reward-cost { font-size: 1.3rem; font-weight: 750; color: var(--success); }
.reward-name { font-weight: 650; }
.reward-actions { margin-top: auto; display: flex; align-items: center; gap: 10px; padding-top: 8px; flex-wrap: wrap; }

/* Birthdays */
.bday-item.highlight { border-left: 4px solid var(--primary); }
.bday-when { flex: 0 0 auto; min-width: 70px; font-weight: 650; font-size: 0.85rem; color: var(--muted); }
.bday-when.is-today { color: var(--primary); }
.bday-week { margin-bottom: 8px; }

/* Closet / notes / contacts cards */
.closet-grid, .note-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .closet-grid, .note-grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); } }
.closet-card, .note-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 8px; min-width: 0; overflow-wrap: anywhere; }
.closet-head, .note-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.closet-name, .note-title { font-weight: 700; }
.closet-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.closet-actions, .note-actions { margin-top: auto; display: flex; gap: 4px 10px; padding-top: 2px; flex-wrap: wrap; }
.note-card.is-pinned { border-color: var(--primary); }
.note-body { font-size: 0.95rem; white-space: pre-wrap; }

/* Calendar list */
.event-date { flex: 0 0 50px; text-align: center; background: var(--primary-tint); border-radius: 10px; padding: 6px 0; }
.event-mon { display: block; font-size: 0.68rem; text-transform: uppercase; color: var(--primary); font-weight: 700; }
.event-day { display: block; font-size: 1.3rem; font-weight: 750; line-height: 1; }
.event-item.is-external .event-date { background: var(--bg-elev); }
.event-item.is-external .event-mon { color: var(--muted); }

/* Calendar month grid: dots on phones, chips on desktop */
.cal-grid { width: 100%; border-collapse: separate; border-spacing: 3px; table-layout: fixed; }
.cal-grid thead th { text-align: center; padding: 4px 0; font-size: 0.7rem; text-transform: uppercase; color: var(--muted); font-weight: 650; }
.cal-grid td { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; vertical-align: top; padding: 4px; height: 56px; overflow: hidden; }
.cal-grid td.other-month { opacity: 0.4; }
.cal-grid td.is-today { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.cal-day { font-size: 0.78rem; font-weight: 700; color: var(--muted); display: block; margin-bottom: 2px; }
.cal-grid td.is-today .cal-day { color: var(--primary); }
.cal-chip { display: block; height: 6px; border-radius: 3px; margin: 2px 0; background: var(--primary); font-size: 0; overflow: hidden; text-decoration: none; color: transparent; }
.cal-chip.cal-bday { background: var(--accent-warm); }
.cal-chip.cal-busy, .cal-chip.cal-ext { background: var(--faint); }
.cal-time { opacity: 0.75; font-weight: 500; }
@media (min-width: 768px) {
  .cal-grid { border-spacing: 5px; }
  .cal-grid td { height: 92px; padding: 6px; }
  .cal-chip { height: auto; font-size: 0.74rem; color: var(--primary); background: var(--primary-tint); padding: 2px 6px; border-radius: 6px;
    font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
  .cal-chip.cal-bday { background: var(--warning-bg); color: var(--warning); }
  .cal-chip.cal-busy, .cal-chip.cal-ext { background: var(--bg-elev); color: var(--muted); }
}
.cal-month-list { margin-top: 16px; }
@media (min-width: 768px) { .cal-month-list { display: none; } }
.cal-export { margin-top: 30px; }

.week-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0 14px; }
.week-range { font-weight: 650; text-align: center; }

/* Week menu → day cards (stack on phones, 7 columns on wide screens) */
.week-days { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 1100px) { .week-days { grid-template-columns: repeat(7, 1fr); gap: 8px; } }
.day-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); min-width: 0; }
.day-card.is-today { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.day-head { display: flex; align-items: baseline; gap: 6px; margin-bottom: 6px; }
.day-head .dow { font-weight: 700; }
.day-head .dom { color: var(--muted); font-size: 0.85rem; }
.day-card.is-today .dow { color: var(--primary); }
.slot { display: flex; gap: 8px; align-items: flex-start; padding: 4px 0; border-top: 1px solid var(--border); }
.slot:first-of-type { border-top: none; }
.slot-label { flex: 0 0 70px; font-size: 0.78rem; color: var(--muted); font-weight: 600; padding-top: 5px; }
@media (min-width: 1100px) { .slot { flex-direction: column; gap: 2px; } .slot-label { flex: none; padding-top: 2px; } }
.slot-meals { flex: 1; min-width: 0; }
.meal-chip { display: flex; align-items: center; justify-content: space-between; gap: 4px; background: var(--primary-tint); border-radius: 8px;
  padding: 4px 4px 4px 8px; margin: 2px 0; font-size: 0.86rem; }
.meal-chip a { color: var(--primary); text-decoration: none; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.chip-x { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 0.8rem; padding: 4px 6px; }
.chip-x:hover { color: var(--danger); }
.slot-empty { color: var(--faint); font-size: 0.85rem; padding-top: 4px; }
.meal-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
@media (min-width: 640px) { .meal-cards { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); } }
.meal-card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
  text-decoration: none; color: var(--text); }
.meal-card-name { font-weight: 650; margin-bottom: 4px; }
.ingredient-check { margin-top: 26px; }
.ing-item { min-height: 0; padding: 9px 12px; box-shadow: none; }
.ing-item.need { border-left: 4px solid var(--danger); }
.ing-item.have { border-left: 4px solid var(--success); }
.ing-flag { font-weight: 700; }
.ing-item.have .ing-flag { color: var(--success); }
.ing-item.need .ing-flag { color: var(--danger); }
.ing-name { flex: 1; font-weight: 600; min-width: 0; }
.ing-status { white-space: nowrap; }
.menu-grid { width: 100%; border-collapse: separate; border-spacing: 6px; }

/* Finance */
.fin-amt { text-align: right; white-space: nowrap; }
.fin-raw { font-weight: 700; }
.breakdown { display: grid; gap: 10px; margin-top: 8px; }
.bd-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; }
.bd-name { font-size: 0.92rem; font-weight: 600; }
.bd-bar { grid-column: 1 / -1; grid-row: 2; height: 10px; background: var(--bg-elev); border-radius: 999px; overflow: hidden; }
.bd-fill { height: 100%; background: var(--primary); border-radius: 999px; }
.bd-amt { font-size: 0.9rem; text-align: right; }
@media (min-width: 640px) { .bd-row { grid-template-columns: 140px 1fr 160px; } .bd-bar { grid-column: auto; grid-row: auto; } }
.actual-form { display: inline-flex; gap: 6px; align-items: center; justify-content: flex-end; }
.actual-input { width: 90px; text-align: right; }
.goal-list { display: grid; gap: 12px; }
.goal-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; box-shadow: var(--shadow); }
.goal-card.is-done { border-color: var(--success); }
.goal-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.goal-name { font-weight: 700; }
.goal-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.goal-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.goal-eta { color: var(--muted); font-size: 0.8rem; }
.contribute-form { display: inline-flex; gap: 6px; align-items: center; }
.contribute-form .input-sm { width: 90px; }
.contrib-tag { font-size: 0.8rem; color: var(--primary); background: var(--primary-tint); border-radius: 999px; padding: 2px 10px; font-weight: 600; white-space: nowrap; }

/* Maintenance */
.mt-due { flex: 0 0 66px; text-align: center; }
.mt-due-date { display: block; font-weight: 700; }
.mt-name { font-weight: 600; text-decoration: none; color: var(--text); }
.mt-complete { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Inventory / pantry */
.qty-control { display: inline-flex; align-items: center; gap: 4px; background: var(--bg-elev); border-radius: 999px; padding: 3px; }
.qty-btn { width: 32px; height: 32px; border: none; background: var(--surface); border-radius: 50%; cursor: pointer; font-size: 1.1rem; line-height: 1;
  color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
.qty-btn:active { transform: scale(0.92); }
.qty-val { min-width: 48px; text-align: center; font-weight: 650; font-size: 0.9rem; }
.row-low td { background: var(--warning-bg); }
.pantry-row .list-main { flex-basis: 140px; }
.pantry-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 2px; font-size: 0.85rem; color: var(--muted); align-items: center; }
.exp-soon { color: var(--warning); font-weight: 600; }
.exp-past { color: var(--danger); font-weight: 600; }

.scan-hero { text-align: center; padding: 26px 18px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.scan-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.scan-mode { display: flex; flex-direction: column; gap: 4px; padding: 12px; border-radius: var(--radius); border: 2px solid var(--border); cursor: pointer; text-align: left; background: var(--surface); }
.scan-mode:has(input:checked) { border-color: var(--primary); background: var(--primary-tint); }
.scan-mode input { position: absolute; opacity: 0; pointer-events: none; }
.scan-mode-title { font-weight: 650; display: flex; align-items: center; gap: 6px; }
.scan-mode-desc { color: var(--muted); font-size: 0.85rem; }
.photo-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 28px 16px; border-radius: var(--radius-lg);
  border: 2px dashed var(--border-strong); background: var(--surface-2); cursor: pointer; text-align: center; color: var(--muted); }
.photo-drop:hover { border-color: var(--primary); color: var(--primary); }
.photo-drop input { display: none; }
.photo-previews { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; justify-content: center; }
.photo-previews img { width: 76px; height: 76px; object-fit: cover; border-radius: 12px; border: 1px solid var(--border); }
.scan-busy { display: none; align-items: center; gap: 10px; justify-content: center; margin-top: 12px; color: var(--muted); }
.is-busy .scan-busy { display: flex; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--primary-tint); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.review-row { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; align-items: start; padding: 12px 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); }
.review-row.is-unsure { border-left: 4px solid var(--warning); }
.review-fields { display: grid; grid-template-columns: 1fr 70px; gap: 8px; }
.review-fields .wide { grid-column: 1 / -1; }
.review-fields .input { min-height: 40px; padding: 8px 10px; }
@media (min-width: 640px) { .review-fields { grid-template-columns: 2fr 70px 1fr 1fr 1.2fr; } .review-fields .wide { grid-column: auto; } }
.review-hint { font-size: 0.8rem; color: var(--muted); grid-column: 2; }
.sticky-actions { position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-b) + 10px); display: flex; gap: 10px; justify-content: flex-end;
  padding: 10px; margin-top: 14px; background: var(--bar-bg); border-radius: var(--radius-lg); border: 1px solid var(--border);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); box-shadow: var(--shadow-lg); }
@media (min-width: 960px) { .sticky-actions { bottom: 16px; } }

/* Weather / info banners */
.weather-alert { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid; }
.weather-alert.cold, .weather-alert.info { background: var(--info-bg); border-color: transparent; color: var(--info); }
.weather-alert.hot, .weather-alert.warn { background: var(--warning-bg); border-color: transparent; color: var(--warning); }
.weather-alert-icon { line-height: 1; }
.weather-alert-title { font-weight: 700; margin-bottom: 2px; }
.weather-alert ul { margin: 6px 0 0; padding-left: 18px; font-size: 0.92rem; }

/* Search */
.search-page-form { display: flex; gap: 8px; max-width: 560px; margin: 10px 0 20px; }
.search-page-form .input { flex: 1; min-width: 0; }
.search-group { margin-bottom: 18px; }
.search-link { text-decoration: none; color: var(--text); }
.search-link:hover { color: var(--primary); }
.topnav-search { position: relative; display: flex; align-items: center; }
.search-icon { position: absolute; left: 11px; color: var(--muted); display: flex; }
.search-input { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 8px 12px 8px 32px;
  font: inherit; font-size: 16px; width: 100%; min-width: 180px; color: var(--text); }

/* Members */
.member-head { display: flex; align-items: center; gap: 14px; margin: 6px 0 16px; }
.member-head h1 { margin: 0; }
.check-grid { display: grid; grid-template-columns: 1fr; gap: 0; }
@media (min-width: 640px) { .check-grid { grid-template-columns: 1fr 1fr; } }
.check-row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-top: 1px solid var(--border); font-weight: 500; cursor: pointer; }
.integration { display: flex; gap: 14px; align-items: flex-start; }
.integration + .integration { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.integration-logo { width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-elev); font-weight: 800; }
.integration-body { flex: 1; min-width: 0; }
.integration-body h3 { margin: 0 0 4px; font-size: 1rem; }
.integration-body p { margin: 0 0 10px; color: var(--muted); font-size: 0.92rem; }

/* Errors / footer */
.error-page { text-align: center; padding: 60px 0; }
.error-page h1 { font-size: 3rem; margin-bottom: 8px; }
.site-footer { display: none; }

/* Google sign-in */
.btn-google { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); font-weight: 600; }
.btn-google:hover { background: var(--bg-elev); }
.or-divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 0.85rem; margin: 16px 0 4px; }
.or-divider::before, .or-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--faint); }
.status-dot.on { background: #34c759; }
.status-dot.warn { background: var(--accent-warm); }

.public-footer { text-align: center; padding: 24px 16px calc(24px + var(--safe-b)); color: var(--muted); font-size: 0.88rem; }
.public-footer a { color: var(--muted); }
.wizard h2 { margin-top: 26px; }
.wizard ul { padding-left: 20px; }
.wizard li { margin: 6px 0; }
