html, body {
  overflow-x: hidden;
  width: 100%;
  margin: 0;
  padding: 0;
}

* { box-sizing: border-box; }

:root {
  --navy: #002147;
  --blue: #0067E6;
  --urgent: #e11d48;
  --bg: #f2f4f7;
  --text: #1f2937;
  --subtext: #6b7280;
  --success: #10b981;
  --border: #e5e7eb;
  --gold: #d97706;
  --card-shadow: 0 4px 6px rgba(0,0,0,0.02);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  padding-bottom: 100px;
  display: flex;
  justify-content: center;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; }
button { cursor: pointer; }

.app-content {
  width: 100%;
  max-width: 1200px;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  box-shadow: 0 0 20px rgba(0,0,0,0.05);
  margin: 0 auto;
}

.auth-screen {
  min-height: 100vh;
  width: 100%;
  background: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  background: white;
  width: 100%;
  max-width: 420px;
  border-radius: 24px;
  padding: 36px 22px 28px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
}

.auth-logo {
  width: 84px;
  height: 84px;
  border-radius: 24px;
  background: linear-gradient(135deg, #0067E6, #002147);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 2.5rem;
  margin: 0 auto 20px;
  box-shadow: 0 15px 25px rgba(0, 103, 230, 0.25);
}

.auth-card h1 {
  text-align: center;
  margin: 0;
  color: var(--navy);
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.auth-card p {
  text-align: center;
  color: #64748b;
  font-weight: 700;
  margin: 8px 0 28px;
}

.auth-card label {
  display: block;
  font-size: 0.75rem;
  font-weight: 900;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 7px;
}

.auth-card input {
  width: 100%;
  padding: 16px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 16px;
  outline: none;
}

.auth-card input:focus { border-color: var(--blue); }
.auth-error { background:#fef2f2; color:#dc2626; border:1px solid #fca5a5; padding:12px; border-radius:10px; margin-bottom:15px; font-size:0.9rem; font-weight:bold; text-align:center; }
.auth-note { color: #94a3b8; font-size: 0.72rem; font-weight: 700; line-height: 1.4; text-align: center; margin-top: 18px; }

#fullscreen-loader {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.85);
  z-index: 999999;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
}
.loader-card { text-align: center; color: white; font-weight: 900; text-transform: uppercase; letter-spacing: 1px; }
.loader-logo { font-size: 4rem; animation: fadePulse 1.2s ease-in-out infinite; }
@keyframes fadePulse { 0% { opacity: .45; transform: scale(.98); } 50% { opacity: 1; transform: scale(1.04); } 100% { opacity: .45; transform: scale(.98); } }

.header {
  background: #ffffff;
  padding: 22px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.top-banner { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 15px; }
.brand-mark { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-icon { width: 52px; height: 52px; flex: 0 0 52px; border-radius: 16px; background: linear-gradient(135deg, #0067E6, #002147); display: flex; align-items: center; justify-content: center; color: white; font-size: 1.5rem; box-shadow: 0 6px 16px rgba(0, 103, 230, .2); }
.brand-title { font-size: 1.45rem; font-weight: 900; letter-spacing: -0.03em; color: var(--navy); margin: 0; }
.label { font-size: 0.68rem; font-weight: 900; color: var(--subtext); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; }

.welcome-card { display: flex; justify-content: space-between; align-items: center; background: white; padding: 15px; border-radius: 14px; border: 1px solid #e2e8f0; box-shadow: var(--card-shadow); margin-bottom: 16px; }
.welcome-name { color: var(--navy); font-size: 1.15rem; font-weight: 900; line-height: 1.1; }
.date-chip { background: #f1f5f9; border: 1px solid #cbd5e1; border-radius: 999px; padding: 8px 12px; color: var(--navy); font-weight: 900; font-size: 0.75rem; }

.home-row { display: flex; gap: 10px; margin: 15px 0; }
.stat-box { flex: 1; background: white; padding: 15px 10px; border-radius: 12px; border: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; box-shadow: var(--card-shadow); }
.stat-title { font-size: 0.65rem; font-weight: 900; text-transform: uppercase; color: var(--subtext); margin-bottom: 8px; letter-spacing: 0.5px; }
.stat-val { font-size: 1.35rem; font-weight: 900; color: var(--navy); margin: 0; }

.header-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.header-actions.two { grid-template-columns: 1fr 1fr; }
.btn-header, .pill-btn, .secondary-btn, .primary-btn {
  border-radius: 12px;
  font-weight: 900;
  border: 1px solid #cbd5e1;
  padding: 12px;
  font-size: 0.82rem;
}
.btn-header { background: #f8fafc; color: var(--navy); display: flex; align-items: center; justify-content: center; gap: 6px; text-transform: uppercase; }
.pill-btn { background: rgba(241,245,249,0.8); color: #64748b; border-radius: 999px; padding: 8px 13px; font-size: .68rem; text-transform: uppercase; }
.primary-btn { background: var(--blue); color: white; border-color: var(--blue); box-shadow: 0 4px 12px rgba(0, 103, 230, .25); }
.secondary-btn { background: #f8fafc; color: #334155; width: 100%; margin-top: 10px; }
.primary-btn.full { width: 100%; padding: 16px; font-size: 0.95rem; text-transform: uppercase; }

.card { background: #ffffff; border-radius: 14px; border: 1px solid var(--border); margin: 15px 20px; width: auto; overflow: hidden; box-shadow: var(--card-shadow); }
.list-card { padding: 0; }
.upcoming-label { font-size: 0.8rem; font-weight: 900; color: var(--subtext); text-transform: uppercase; margin: 25px 20px 10px; letter-spacing: 0.5px; }
.row { padding: 16px 18px; border-bottom: 1px solid #f1f5f9; }
.row:last-child { border-bottom: none; }
.row-title { font-weight: 900; color: var(--navy); font-size: 1rem; margin-bottom: 4px; }
.row-sub { color: #64748b; font-size: 0.76rem; font-weight: 700; line-height: 1.4; }
.empty-card { text-align: center; padding: 30px 18px; color: #64748b; font-weight: 800; background: white; border: 2px dashed #cbd5e1; border-radius: 16px; }
.padded-list { padding: 0 20px 100px; }
.item-actions { display: flex; gap: 8px; margin-top: 12px; }
.mini-btn { background: #f8fafc; border: 1px solid #cbd5e1; color: #334155; border-radius: 9px; padding: 8px 10px; font-weight: 900; font-size: .68rem; text-transform: uppercase; }
.mini-btn.danger { background: #fef2f2; color: #dc2626; border-color: #fecaca; }

.floating-actions { position: fixed; right: 18px; bottom: 86px; z-index: 99990; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.floating-btn { width: 60px; height: 60px; border-radius: 50%; border: none; background: #3b82f6; color: white; font-size: 1.6rem; font-weight: 900; box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4); }
.floating-btn.small { width: 48px; height: 48px; background: white; color: #1e293b; border: 1px solid #cbd5e1; font-size: 1.15rem; box-shadow: 0 4px 12px rgba(0,0,0,.15); }

.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; margin: 0 auto; width: 100%; max-width: 1200px; height: 72px; background: rgba(255,255,255,.95); backdrop-filter: blur(10px); border-top: 1px solid var(--border); display: flex; padding: 8px 0 18px; z-index: 99999; }
.nav-btn { flex: 1; background: none; border: none; color: var(--subtext); font-weight: 800; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.nav-btn span { font-size: 1.25rem; line-height: 1; }
.nav-btn small { font-size: .65rem; font-weight: 900; }
.nav-btn.active { color: var(--blue); filter: drop-shadow(0 0 5px rgba(0,103,230,0.35)); }

.tab-content { display: none; animation: fadeIn .25s ease; }
.tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 1000000; justify-content: center; align-items: flex-start; backdrop-filter: blur(2px); padding: 24px 16px 98px; box-sizing: border-box; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-overlay.active { display: flex; }

/* Modal safety: keep popouts above bottom nav/floating buttons and stop background taps. */
body.modal-open .bottom-nav,
body.modal-open .floating-actions {
  pointer-events: none;
}

.modal-box { background: white; padding: 25px 20px; border-radius: 24px; width: 100%; max-width: 620px; max-height: calc(100dvh - 122px); overflow-y: auto; box-shadow: 0 18px 45px rgba(0,0,0,.24); margin: auto 0; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 10px; }
.modal-header h2 { margin: 0; color: var(--navy); font-size: 1.3rem; font-weight: 900; }
.x-btn { width: 36px; height: 36px; border-radius: 50%; background: #f1f5f9; border: 1px solid #cbd5e1; color: #64748b; font-weight: 900; font-size: 1.2rem; }
.modal-label { display: block; font-size: .72rem; font-weight: 900; color: var(--subtext); text-transform: uppercase; margin-top: 15px; margin-bottom: 6px; letter-spacing: 0.5px; }
.modal-input { width: 100%; padding: 13px 14px; border: 1px solid #cbd5e1; border-radius: 10px; font-size: 1rem; background: #f8fafc; color: var(--navy); font-weight: 700; outline: none; }
.modal-input:focus { border-color: var(--blue); background: white; }
textarea.modal-input { resize: vertical; min-height: 84px; }

.modal-help {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  padding: 10px 12px;
  color: #64748b;
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.4;
  margin-top: 8px;
}

.modal-input[hidden] { display: none !important; }
.modal-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.hub-btn { width: 100%; padding: 16px; margin-bottom: 12px; background: white; color: var(--navy); border: 2px solid #e2e8f0; border-radius: 12px; font-weight: 900; font-size: 1rem; cursor: pointer; text-align: left; display: flex; align-items: center; gap: 15px; box-shadow: 0 2px 4px rgba(0,0,0,0.02); }
.hub-btn.danger { color: #dc2626; background: #fef2f2; border-color: #fecaca; }
.action-hub-card { margin: 15px 20px 100px; }
.muted { color: #64748b; font-weight: 700; line-height: 1.5; }

/* Grocery list copied in spirit from Money Matters mobile grocery flow */
.grocery-shell { min-height: calc(100vh - 72px); min-height: calc(100dvh - 72px); display: flex; flex-direction: column; background: #f8fafc; padding-bottom: 58px; }
.grocery-header { background: white; padding: 14px 16px 10px; border-bottom: 1px solid #e2e8f0; }
.grocery-header-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.groc-header-btn { background: #f1f5f9; color: #0f172a; border: 1px solid #cbd5e1; border-radius: 999px; padding: 8px 14px; font-weight: 900; font-size: .75rem; text-transform: uppercase; }
.grocery-title { margin: 2px 0 0; color: var(--navy); font-size: 1.38rem; font-weight: 900; letter-spacing: -0.03em; }
.grocery-subtitle { margin: 7px 0 0; color: #64748b; font-weight: 700; font-size: .78rem; line-height: 1.35; }
.groc-add-card { background: white; border: 1px solid #e2e8f0; border-radius: 14px; margin: 10px 12px; padding: 10px; box-shadow: 0 4px 10px rgba(15, 23, 42, .04); }
.groc-quick-row, .groc-detail-row, .groc-action-row { display: flex; gap: 8px; }
.groc-detail-row, .groc-action-row { margin-top: 8px; }
.groc-quick-row input, .groc-detail-row input, .groc-detail-row select, .groc-bulk-panel textarea { min-width: 0; border: 1px solid #cbd5e1; border-radius: 10px; padding: 10px 11px; font-weight: 800; color: #0f172a; background: #f8fafc; }
.groc-quick-row input { flex: 1; font-size: 1rem; }
.groc-detail-row input, .groc-detail-row select { flex: 1; }
.groc-add-btn { width: 44px; border-radius: 11px; border: none; background: #2563eb; color: white; font-size: 1.45rem; font-weight: 900; line-height: 1; }
.groc-light-btn, .groc-danger-btn, .groc-primary-wide { flex: 1; border-radius: 10px; padding: 8px; font-weight: 900; font-size: .68rem; border: 1px solid #cbd5e1; background: #f8fafc; color: #334155; }
.groc-primary-wide { background: #2563eb; color: white; border-color: #2563eb; }
.groc-danger-btn { background: #fef2f2; color: #dc2626; border-color: #fecaca; }
.groc-clear-list-btn { background: white; color: #64748b; border-color: #e2e8f0; }
.groc-bulk-panel { margin-top: 10px; border-top: 1px dashed #cbd5e1; padding-top: 10px; }
.groc-bulk-panel textarea { width: 100%; min-height: 115px; resize: vertical; line-height: 1.4; }
.groc-bulk-help { color: #64748b; font-size: .72rem; font-weight: 700; margin: 7px 2px 0; }
.grocery-list-container { flex: 1; overflow-y: auto; padding: 0 12px 78px; -webkit-overflow-scrolling: touch; }
.groc-trip-card { background: linear-gradient(135deg, #1e3a8a 0%, #0f172a 100%); color: white; border-radius: 15px; padding: 13px 15px; margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; box-shadow: 0 10px 20px rgba(15,23,42,.18); }
.groc-trip-label { font-size: .68rem; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; color: #bfdbfe; }
.groc-trip-title { font-size: 1.25rem; font-weight: 900; margin-top: 3px; }
.groc-trip-sub { font-size: .8rem; font-weight: 800; color: #cbd5e1; margin-top: 3px; }
.groc-trip-icon { font-size: 1.9rem; }
.groc-section { background: white; border: 1px solid #e2e8f0; border-radius: 14px; overflow: hidden; margin-bottom: 10px; box-shadow: 0 3px 8px rgba(15,23,42,.035); }
.groc-section-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; background: #f1f5f9; border-bottom: 1px solid #e2e8f0; color: #0f172a; font-size: .78rem; font-weight: 900; text-transform: uppercase; letter-spacing: .04em; }
.groc-checked-head { background: #f8fafc; color: #64748b; }
.groc-section-body { padding: 2px 12px; }
.groc-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; border-bottom: 1px solid #f1f5f9; }
.groc-row:last-child { border-bottom: none; }
.groc-row-checked { opacity: .56; }
.groc-row-checked .groc-item-name { text-decoration: line-through; }
.groc-check-label { flex: 1; display: flex; align-items: center; min-width: 0; gap: 12px; cursor: pointer; }
.groc-check-input { position: absolute; opacity: 0; pointer-events: none; }
.groc-check-box { width: 25px; height: 25px; flex: 0 0 25px; border: 2px solid #cbd5e1; border-radius: 8px; background: white; display: inline-flex; align-items: center; justify-content: center; }
.groc-check-input:checked + .groc-check-box { background: #2563eb; border-color: #2563eb; }
.groc-check-input:checked + .groc-check-box::after { content: '✓'; color: white; font-weight: 900; font-size: 1rem; }
.groc-item-text { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.groc-item-name { color: #0f172a; font-size: 1rem; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.groc-item-note { color: #64748b; font-size: .72rem; font-weight: 800; }
.groc-delete-btn { width: 30px; height: 30px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; background: #f8fafc; color: #94a3b8; border: none; }
.groc-empty-card, .groc-hidden-note { text-align: center; background: white; border: 2px dashed #cbd5e1; border-radius: 16px; padding: 28px 18px; color: #64748b; font-weight: 800; margin: 14px 0; }
.groc-footer-actions { position: fixed; left: auto; right: 12px; bottom: 74px; z-index: 99997; width: auto; max-width: calc(100vw - 24px); display: flex; gap: 5px; background: rgba(255,255,255,.94); backdrop-filter: blur(8px); border: 1px solid #e2e8f0; border-radius: 999px; padding: 5px; box-shadow: 0 -4px 20px rgba(15,23,42,.08); }
.groc-footer-actions .groc-primary-wide { flex: 0 0 auto; width: auto; min-height: 30px; padding: 7px 11px; border-radius: 999px; font-size: .64rem; }

.inventory-toolbar { display: grid; grid-template-columns: 1.5fr 1fr; gap: 10px; padding: 15px 20px 0; }
.inventory-grid { padding: 15px 20px 110px; display: grid; grid-template-columns: repeat(auto-fill, minmax(285px, 1fr)); gap: 15px; }
.asset-card { background: white; border: 1px solid #e2e8f0; border-radius: 16px; overflow: hidden; box-shadow: 0 4px 10px rgba(15,23,42,.045); }
.asset-card-head { padding: 15px; background: linear-gradient(135deg, #f8fafc, #ffffff); border-bottom: 1px solid #e2e8f0; display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.asset-name { color: var(--navy); font-size: 1.05rem; font-weight: 900; line-height: 1.2; }
.asset-category { margin-top: 6px; color: #64748b; font-size: .72rem; font-weight: 900; text-transform: uppercase; }
.asset-value { color: #0f766e; font-weight: 900; white-space: nowrap; }
.asset-body { padding: 15px; }
.asset-line { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed #e2e8f0; font-size: .78rem; }
.asset-line:last-child { border-bottom: none; }
.asset-line span:first-child { color: #64748b; font-weight: 900; text-transform: uppercase; font-size: .65rem; }
.asset-line span:last-child { color: #0f172a; font-weight: 800; text-align: right; word-break: break-word; }

#toast { display: none; position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); z-index: 999999; background: var(--navy); color: white; padding: 12px 24px; border-radius: 50px; font-size: .85rem; font-weight: 800; box-shadow: 0 10px 25px rgba(0,33,71,.3); text-align: center; white-space: nowrap; }

@media screen and (max-width: 768px) {
  .card, .home-row { margin-left: 12px !important; margin-right: 12px !important; }
  .header { padding: 16px 14px 16px; }
  .brand-icon { width: 46px; height: 46px; flex-basis: 46px; border-radius: 14px; }
  .brand-title { font-size: 1.25rem; }
  .stat-box { padding: 12px 5px; }
  .stat-val { font-size: 1.08rem; }
  .modal-overlay { padding: 14px 10px 92px; align-items: flex-start; }
  .modal-box { padding: 18px 14px; border-radius: 20px; max-width: none; max-height: calc(100dvh - 106px); margin: 0; }
  .modal-row, .inventory-toolbar { grid-template-columns: 1fr; gap: 0; }
  .inventory-toolbar { gap: 8px; padding: 12px 12px 0; }
  .inventory-grid { grid-template-columns: 1fr; padding: 12px 12px 110px; }
  .floating-actions { right: 13px; }
}

@media print {
  body * { visibility: hidden !important; }
  .tab-content.active, .tab-content.active * { visibility: visible !important; }
  .tab-content.active { position: absolute !important; left: 0 !important; top: 0 !important; width: 100% !important; display: block !important; }
  button, .bottom-nav, .floating-actions, .header-actions, .groc-hide-print { display: none !important; }
  body { background: white !important; }
  .card, .asset-card { box-shadow: none !important; border: 1px solid #ccc !important; page-break-inside: avoid !important; break-inside: avoid !important; }
}

/* --- V6: fixed floating buttons, saved grocery picker, and asset photos --- */
.floating-actions {
  right: max(16px, calc((100vw - 1200px) / 2 + 18px));
  bottom: calc(92px + env(safe-area-inset-bottom));
}

.groc-saved-panel {
  margin-top: 10px;
  border-top: 1px dashed #cbd5e1;
  padding-top: 10px;
}

.groc-saved-search {
  width: 100%;
  min-width: 0;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 10px 11px;
  font-weight: 800;
  color: #0f172a;
  background: #f8fafc;
  margin-bottom: 10px;
}

.groc-saved-list {
  max-height: 340px;
  overflow-y: auto;
  padding-right: 2px;
  -webkit-overflow-scrolling: touch;
}

.groc-saved-head {
  background: #eff6ff !important;
  color: #1e3a8a !important;
}

.groc-saved-row {
  opacity: 0.96;
}

.groc-add-saved-btn {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: none;
  background: #2563eb;
  color: white;
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.asset-photo-count {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  vertical-align: middle;
  margin-left: 6px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  font-size: 0.62rem;
  font-weight: 900;
}

.photo-upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}

.photo-upload-card {
  background: #f8fafc;
  border: 2px dashed #cbd5e1;
  border-radius: 14px;
  padding: 14px 10px;
  text-align: center;
  color: var(--navy);
  font-weight: 900;
  cursor: pointer;
}

.photo-upload-card span {
  display: block;
  font-size: 1.7rem;
  margin-bottom: 5px;
}

.photo-upload-card strong,
.photo-upload-card small {
  display: block;
}

.photo-upload-card small {
  color: #64748b;
  font-size: 0.7rem;
  margin-top: 3px;
}

.photo-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.asset-photo-preview,
.asset-photo-gallery {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.asset-photo-thumb,
.asset-photo-gallery a {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  min-height: 140px;
}

.asset-photo-thumb img,
.asset-photo-gallery img {
  width: 100%;
  height: 100%;
  min-height: 140px;
  object-fit: cover;
  display: block;
}

.asset-photo-thumb button {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.75);
  background: rgba(15,23,42,.75);
  color: white;
  font-weight: 900;
  padding: 0;
}

.photo-empty {
  grid-column: 1 / -1;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  padding: 14px;
  color: #64748b;
  font-weight: 800;
  text-align: center;
}

.asset-detail-box .asset-line {
  font-size: 0.86rem;
}

.detail-label {
  margin-left: 0;
  margin-right: 0;
}

@media screen and (max-width: 768px) {
  .floating-actions {
    right: 13px;
    bottom: calc(94px + env(safe-area-inset-bottom));
    gap: 10px;
  }

  .floating-btn {
    width: 54px;
    height: 54px;
    font-size: 1.35rem;
  }

  .floating-btn.small {
    width: 42px;
    height: 42px;
    font-size: 1rem;
  }

  .photo-upload-grid,
  .asset-photo-preview,
  .asset-photo-gallery {
    grid-template-columns: 1fr 1fr;
  }

  .asset-photo-thumb,
  .asset-photo-gallery a,
  .asset-photo-thumb img,
  .asset-photo-gallery img {
    min-height: 118px;
  }
}


/* --- V7: larger phone-friendly popouts and clearer grocery picker --- */
.asset-detail-box {
  max-width: 760px;
}

.asset-detail-box .modal-header h2 {
  font-size: 1.55rem;
}

.asset-detail-box .asset-photo-gallery {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.asset-detail-box .asset-photo-gallery a,
.asset-detail-box .asset-photo-gallery img {
  min-height: 190px;
}

.groc-saved-panel {
  background: #f8fafc;
  border: 1px solid #dbeafe;
  border-radius: 16px;
  padding: 12px;
}

.groc-saved-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.groc-saved-title {
  color: var(--navy);
  font-weight: 900;
  font-size: 0.9rem;
}

.groc-saved-subtitle {
  color: #64748b;
  font-weight: 800;
  font-size: 0.7rem;
  margin-top: 2px;
}

.groc-saved-close {
  flex: 0 0 auto;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: white;
  color: #64748b;
  font-weight: 900;
  padding: 7px 10px;
  font-size: 0.65rem;
  text-transform: uppercase;
}

.groc-saved-cats {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 2px 0 10px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.groc-saved-cats::-webkit-scrollbar { display: none; }

.groc-saved-cat-btn {
  flex: 0 0 auto;
  border: 1px solid #cbd5e1;
  background: white;
  color: #334155;
  border-radius: 999px;
  padding: 8px 11px;
  font-weight: 900;
  font-size: 0.68rem;
  white-space: nowrap;
}

.groc-saved-cat-btn.active {
  background: #2563eb;
  color: white;
  border-color: #2563eb;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.18);
}

.groc-saved-list {
  max-height: min(52dvh, 500px);
}

.groc-saved-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.groc-saved-tile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 13px;
  padding: 11px 10px;
}

.groc-saved-tile-name {
  min-width: 0;
  color: #0f172a;
  font-weight: 900;
  font-size: 0.86rem;
  line-height: 1.15;
}

.groc-saved-tile-cat {
  margin-top: 3px;
  color: #64748b;
  font-size: 0.65rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media screen and (max-width: 768px) {
  .modal-header h2 { font-size: 1.25rem; }
  .asset-detail-box {
    max-width: none;
    width: 100%;
  }
  .asset-detail-box .asset-photo-gallery {
    grid-template-columns: 1fr;
  }
  .asset-detail-box .asset-photo-gallery a,
  .asset-detail-box .asset-photo-gallery img {
    min-height: 230px;
  }
  .groc-saved-panel {
    margin-top: 8px;
    padding: 10px;
  }
  .groc-saved-list {
    max-height: 50dvh;
  }
  .groc-saved-grid {
    grid-template-columns: 1fr 1fr;
    gap: 7px;
  }
  .groc-saved-tile {
    padding: 10px 8px;
  }
  .groc-saved-tile-name { font-size: 0.8rem; }
  .groc-add-saved-btn {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
  }
}


/* --- V8: saved grocery picker management --- */
.groc-saved-help {
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 800;
  background: white;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 10px;
}

.groc-saved-manage {
  display: grid;
  grid-template-columns: 1.5fr 1fr auto;
  gap: 8px;
  margin-bottom: 10px;
}

.groc-saved-new-name,
.groc-saved-new-cat,
.groc-saved-search {
  width: 100%;
  min-width: 0;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 10px 11px;
  font-weight: 800;
  color: #0f172a;
  background: white;
}

.groc-saved-add-custom {
  border: none;
  border-radius: 10px;
  background: #2563eb;
  color: white;
  font-weight: 900;
  padding: 10px 14px;
  text-transform: uppercase;
  font-size: 0.7rem;
}

.groc-saved-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.groc-delete-saved-btn {
  width: 31px;
  height: 31px;
  border-radius: 999px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #dc2626;
  font-weight: 900;
  line-height: 1;
}

@media screen and (max-width: 768px) {
  .groc-saved-manage {
    grid-template-columns: 1fr;
  }
  .groc-saved-add-custom {
    width: 100%;
    min-height: 38px;
  }
}

/* --- V9: roomier saved grocery picker cards --- */
.groc-saved-panel {
  padding: 14px;
}

.groc-saved-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.groc-saved-tile {
  min-height: 68px;
  padding: 14px 14px;
  border-radius: 16px;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.groc-saved-tile-name {
  font-size: 1rem;
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: anywhere;
}

.groc-saved-tile-cat {
  font-size: 0.72rem;
}

.groc-saved-actions {
  gap: 8px;
}

.groc-add-saved-btn,
.groc-delete-saved-btn {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  font-size: 1.05rem;
}

.groc-saved-search,
.groc-saved-new-name,
.groc-saved-new-cat {
  min-height: 44px;
  font-size: 0.92rem;
}

.groc-saved-cat-btn {
  padding: 10px 14px;
  font-size: 0.75rem;
}

@media screen and (max-width: 768px) {
  .groc-saved-panel {
    padding: 12px;
    border-radius: 18px;
  }

  .groc-saved-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .groc-saved-tile {
    min-height: 74px;
    padding: 15px 14px;
  }

  .groc-saved-tile-name {
    font-size: 1.05rem;
  }

  .groc-saved-tile-cat {
    font-size: 0.76rem;
  }

  .groc-add-saved-btn,
  .groc-delete-saved-btn {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
  }
}

/* --- Styled confirmation popups (replaces browser confirm boxes) --- */
.confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000000;
  background: rgba(15, 23, 42, 0.68);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 24px 16px 96px;
  box-sizing: border-box;
}

.confirm-overlay.active { display: flex; }

.confirm-box {
  position: relative;
  width: min(94vw, 460px);
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 24px;
  padding: 28px 24px 22px;
  box-shadow: 0 28px 70px rgba(0, 33, 71, 0.32);
  text-align: left;
  animation: confirmPop 0.18s ease-out;
}

@keyframes confirmPop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.confirm-x {
  position: absolute;
  top: 16px;
  right: 16px;
}

.confirm-icon {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  background: linear-gradient(135deg, #0067E6, #002147);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 900;
  margin-bottom: 14px;
  box-shadow: 0 12px 22px rgba(0, 103, 230, 0.22);
}

.confirm-box h2 {
  margin: 4px 48px 8px 0;
  color: var(--navy);
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.confirm-box p {
  margin: 0;
  color: #475569;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.5;
  white-space: pre-wrap;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 10px;
  margin-top: 22px;
}

.confirm-primary,
.confirm-secondary {
  border-radius: 14px;
  padding: 14px 12px;
  font-weight: 900;
  font-size: 0.9rem;
  border: 1px solid #cbd5e1;
  text-transform: uppercase;
}

.confirm-primary {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
  box-shadow: 0 8px 18px rgba(0, 103, 230, 0.22);
}

.confirm-primary.danger {
  background: #dc2626;
  border-color: #dc2626;
  box-shadow: 0 8px 18px rgba(220, 38, 38, 0.18);
}

.confirm-secondary {
  background: #f8fafc;
  color: #334155;
}

@media screen and (max-width: 768px) {
  .confirm-overlay {
    align-items: flex-start;
    padding: 18px 14px 96px;
  }

  .confirm-box {
    width: 100%;
    padding: 24px 18px 18px;
    border-radius: 22px;
  }

  .confirm-actions {
    grid-template-columns: 1fr;
  }

  .confirm-secondary { order: 2; }
  .confirm-primary { order: 1; }
}

/* --- PWA / iPhone Home Screen Polish --- */
@supports (padding: max(0px)) {
  body {
    padding-bottom: max(100px, calc(92px + env(safe-area-inset-bottom)));
  }

  .bottom-nav {
    height: calc(72px + env(safe-area-inset-bottom));
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }

  .floating-actions {
    bottom: calc(96px + env(safe-area-inset-bottom));
  }

  .groc-footer-actions {
    bottom: calc(84px + env(safe-area-inset-bottom));
  }
}

@media all and (display-mode: standalone) {
  body {
    background: var(--bg);
  }

  .app-content {
    min-height: 100dvh;
  }
}

@media screen and (max-width: 768px) {
  .auth-screen {
    min-height: 100dvh;
    padding: 18px 14px calc(18px + env(safe-area-inset-bottom));
  }

  .auth-card {
    border-radius: 22px;
    padding: 28px 18px 24px;
  }

  .auth-logo {
    width: 76px;
    height: 76px;
    border-radius: 22px;
  }

  .auth-card h1 {
    font-size: 1.75rem;
  }

  .primary-btn,
  .secondary-btn,
  .btn-header,
  .groc-light-btn,
  .groc-danger-btn,
  .groc-primary-wide,
  .mini-btn {
    min-height: 44px;
  }

  .bottom-nav {
    left: 0;
    right: 0;
    width: 100vw;
  }

  .nav-btn small {
    font-size: 0.62rem;
  }
}
