/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-hover: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #38bdf8;
  --accent-hover: #7dd3fc;
  --green: #34d399;
  --yellow: #fbbf24;
  --red: #f87171;
  --orange: #fb923c;
  --purple: #a78bfa;
  --border: #334155;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-height: 64px;
  --card-gradient-shop: linear-gradient(135deg, var(--bg-card) 0%, #1a2a1e 100%);
  --card-gradient-support: linear-gradient(135deg, var(--bg-card) 0%, #1a1a3e 100%);
}
html { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* === Navigation === */
.nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding-bottom: var(--safe-bottom);
}
.nav-brand {
  display: none;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.nav-tabs {
  display: flex;
  justify-content: space-around;
}
.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 11px;
  cursor: pointer;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.nav-tab.active {
  color: var(--accent);
}
.nav-tab svg { display: block; }

/* === Main Content === */
main {
  padding: 16px;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 60px);
  max-width: 600px;
  margin: 0 auto;
}
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.2s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 20px;
}
.view-header h1 {
  font-size: 22px;
  font-weight: 700;
}
.item-count {
  font-size: 14px;
  color: var(--text-muted);
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn-primary {
  background: var(--accent);
  color: #0f172a;
}
.btn-primary:hover, .btn-primary:active { background: var(--accent-hover); }
.btn-lg {
  width: 100%;
  justify-content: center;
  padding: 14px;
  font-size: 16px;
}
.btn-small {
  padding: 6px 10px;
  font-size: 12px;
}
.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(56, 184, 248, 0.08);
}

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}
.empty-icon { font-size: 64px; margin-bottom: 16px; }
.empty-state h2 { margin-bottom: 8px; font-size: 20px; }
.empty-state p { color: var(--text-muted); margin-bottom: 24px; max-width: 320px; margin-left: auto; margin-right: auto; line-height: 1.5; }

/* === Items List === */
.items-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.item-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--bg-card);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}
.item-card:hover, .item-card:active, .item-card:focus-visible { background: var(--bg-hover); }
.item-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Warranty badge on item cards */
.item-name .warranty-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  font-size: 12px;
  margin-left: 4px;
  vertical-align: middle;
  cursor: help;
  border-radius: 50%;
  flex-shrink: 0;
  line-height: 1;
}
.item-card.has-warranty-alert {
  border-left: 3px solid var(--yellow);
}
.item-card.warranty-expired {
  border-left-color: var(--red);
}
.item-card.warranty-soon {
  border-left-color: var(--yellow);
}

/* === Loading Skeleton === */
.loading-skeleton {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.skeleton-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--bg-card);
  border-radius: var(--radius);
}
.skeleton-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--bg-hover);
  flex-shrink: 0;
}
.skeleton-lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.skeleton-line {
  height: 12px;
  border-radius: 6px;
  background: var(--bg-hover);
}
.skeleton-price {
  width: 48px;
  height: 16px;
  border-radius: 8px;
  background: var(--bg-hover);
  flex-shrink: 0;
}
.skeleton-pulse {
  animation: skeletonPulse 1.5s ease-in-out infinite;
}
@keyframes skeletonPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.7; }
}
.item-category {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.item-info { flex: 1; min-width: 0; }
.item-name {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-meta {
  display: flex;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.item-price {
  font-weight: 700;
  font-size: 16px;
  color: var(--green);
  flex-shrink: 0;
}

/* === Add Form === */
.add-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
input, select, textarea {
  width: 100%;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 60px; }
input[type="date"] { min-height: 46px; }

/* Photo Upload */
.photo-upload {
  position: relative;
}
.photo-upload input[type="file"] {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: 2;
}
.photo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 32px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 14px;
  transition: border-color 0.15s;
}
.photo-placeholder:hover { border-color: var(--accent); }
.photo-preview {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
}
.photo-preview img {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  display: block;
}
.btn-photo-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.7);
  color: white;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* === Modal === */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.15s;
}
.modal {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px;
  padding-bottom: calc(24px + var(--safe-bottom));
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.25s;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--bg-hover);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.modal-detail { position: relative; }
.modal-detail h2 { font-size: 22px; margin-bottom: 4px; padding-right: 40px; }
.modal-detail .detail-price {
  font-size: 28px;
  font-weight: 700;
  color: var(--green);
  margin: 12px 0;
}
.modal-detail .detail-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 16px 0;
}
.modal-detail .detail-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.modal-detail .detail-field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
}
.modal-detail .detail-field-value {
  font-size: 15px;
  color: var(--text);
}
.modal-detail .detail-notes {
  margin-top: 16px;
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  line-height: 1.5;
  font-size: 14px;
  color: var(--text-muted);
}
.modal-detail .detail-receipt {
  margin-top: 16px;
}
.modal-detail .detail-receipt img {
  width: 100%;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}
.btn-delete {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
}
.btn-delete:hover { background: rgba(248, 113, 113, 0.1); }
.btn-edit {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}
.btn-edit:hover { background: rgba(56, 189, 248, 0.1); }

/* === Insights === */
.insight-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 24px;
}
.insight-card {
  background: var(--bg-card);
  padding: 16px;
  border-radius: var(--radius);
  text-align: center;
}
.insight-label {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.insight-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
}
.insight-section {
  margin-bottom: 20px;
}
.insight-section h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}
.category-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}
.category-bar .cat-icon { font-size: 18px; width: 28px; }
.category-bar .cat-name { flex: 1; font-size: 14px; }
.category-bar .cat-bar-wrap { flex: 2; height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.category-bar .cat-bar-fill { height: 100%; border-radius: 4px; transition: width 0.3s; }
.category-bar .cat-amount { font-size: 13px; font-weight: 600; color: var(--text-muted); width: 60px; text-align: right; }

.warranty-item, .store-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 14px;
}
.warranty-item .warn-icon { font-size: 16px; }
.warranty-item .warn-name { flex: 1; }
.warranty-item .warn-date { color: var(--text-muted); font-size: 12px; }
.warranty-item .warn-urgent { color: var(--red); }
.warranty-item .warn-soon { color: var(--yellow); }

/* === Search === */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 12px;
}
.search-bar:focus-within { border-color: var(--accent); }
.search-bar input {
  flex: 1;
  background: none;
  border: none;
  padding: 0;
  font-size: 16px;
}
.search-bar input:focus { outline: none; }
.search-bar svg { color: var(--text-dim); flex-shrink: 0; }
.search-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.search-filters select {
  flex: 1;
  padding: 8px 10px;
  font-size: 13px;
}

/* === Barcode Scanner === */
.scanner-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.scanner-btn:hover { border-color: var(--accent); color: var(--accent); }
.scanner-btn:active { background: var(--bg-hover); }
.scanner-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.barcode-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.barcode-row input[type="text"] {
  flex: 1;
}
.barcode-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 12px;
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  animation: fadeIn 0.2s;
}
.barcode-chip .barcode-format {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-dim);
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: 4px;
}
.barcode-chip .barcode-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: var(--bg-hover);
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  line-height: 1;
  transition: all 0.15s;
}
.barcode-chip .barcode-clear:hover { background: var(--red); color: white; }
.barcode-chip .barcode-clear:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Scanner overlay */
.scanner-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 500;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.15s;
}
.scanner-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  color: white;
  font-size: 15px;
  font-weight: 600;
  z-index: 2;
}
.scanner-header button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.15);
  color: white;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.scanner-header button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.scanner-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.scanner-viewport video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.scanner-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(280px, 70vw);
  height: min(280px, 70vw);
  border: 2px solid rgba(56, 189, 248, 0.7);
  border-radius: 16px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.5);
  pointer-events: none;
}
.scanner-frame::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
  animation: scanLine 2s ease-in-out infinite;
}
@keyframes scanLine {
  0%, 100% { top: 0; }
  50% { top: calc(100% - 3px); }
}
.scanner-footer {
  padding: 20px;
  text-align: center;
  color: rgba(255,255,255,0.6);
  font-size: 14px;
  z-index: 2;
}
.scanner-footer span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* === Toast === */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  z-index: 300;
  animation: toastIn 0.3s;
  box-shadow: var(--shadow);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* === Responsive === */
@media (min-width: 768px) {
  .nav {
    position: static;
    border-top: none;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
  }
  .nav-brand { display: flex; align-items: center; gap: 8px; }
  .nav-logo { font-size: 22px; }
  .nav-title { font-size: 18px; font-weight: 700; }
  .nav-tabs {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 16px;
  }
  main {
    padding-top: 24px;
    padding-bottom: 80px;
  }
  .modal {
    border-radius: var(--radius);
    margin: auto;
    max-width: 500px;
    max-height: 80vh;
    animation: fadeIn 0.2s;
  }
  .modal-backdrop { align-items: center; }
  .toast {
    bottom: 24px;
  }
  /* Eco-footer returns to static flow on desktop */
  .eco-footer {
    position: static;
    border-bottom: none;
    padding: 8px 16px;
    font-size: 12px;
  }
  body {
    padding-bottom: 0;
  }
}

/* === Affiliate Section === */
.affiliate-card {
  background: var(--card-gradient-shop);
  border: 1px solid #2d4a32;
  border-radius: var(--radius);
  padding: 16px;
}
.affiliate-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.affiliate-icon { font-size: 28px; }
.affiliate-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.affiliate-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.15s;
}
.affiliate-link:hover {
  border-color: var(--affiliate-accent, var(--accent));
  background: var(--bg-hover);
}
.affiliate-disclosure {
  margin-top: 10px;
  font-size: 10px;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.4;
}

/* Shop on Amazon button */
.btn-shop {
  background: #ff9900;
  color: #0f172a;
  border: none;
}
.btn-shop:hover {
  background: #ffb84d;
}

/* === Export / Import UI === */
.io-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.io-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
}
.io-btn:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}
.io-btn:active { transform: scale(0.97); }
.io-btn .io-icon { font-size: 22px; }
.io-btn .io-label { font-size: 12px; color: var(--text-muted); }
.io-btn-danger:hover { border-color: var(--red); color: var(--red); }
.io-btn-danger:hover .io-label { color: var(--red); }
.io-status {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.5;
  margin-top: 8px;
  animation: fadeIn 0.2s;
}
.io-status.success {
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid var(--green);
  color: var(--green);
}
.io-status.error {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid var(--red);
  color: var(--red);
}
.io-status.info {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid var(--accent);
  color: var(--accent);
}

/* === Support Section === */
.support-section {
  margin-top: 24px;
}
.support-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--card-gradient-support);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.support-icon {
  font-size: 32px;
  flex-shrink: 0;
}
.support-card h3 {
  font-size: 16px;
  margin-bottom: 4px;
  color: var(--text);
}
.support-card p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
  line-height: 1.4;
}
.support-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: #ff5e5b;
  color: white;
  text-decoration: none;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  transition: opacity 0.2s;
}
.support-link:hover {
  opacity: 0.85;
}
.support-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* === Budget Tracking === */
.budget-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.budget-header-row h3 {
  margin-bottom: 0 !important;
}

.budget-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.budget-bar-row {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.budget-bar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 500;
}
.budget-cat-icon {
  margin-right: 6px;
}
.budget-bar-amounts {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.budget-bar-track {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}
.budget-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s;
  min-width: 0;
}
.budget-bar-fill.budget-ok {
  background: var(--green);
}
.budget-bar-fill.budget-warning {
  background: var(--yellow);
}
.budget-bar-fill.budget-critical {
  background: var(--orange);
}
.budget-bar-fill.budget-exceeded {
  background: var(--red);
}
.budget-bar-status {
  font-size: 11px;
  font-weight: 600;
  text-align: right;
  margin-top: 2px;
}
.budget-bar-status.budget-ok { color: var(--green); }
.budget-bar-status.budget-warning { color: var(--yellow); }
.budget-bar-status.budget-critical { color: var(--orange); }
.budget-bar-status.budget-exceeded { color: var(--red); }

/* Budget Modal */
.budget-modal-backdrop {
  z-index: 300;
}
.budget-modal {
  max-width: 480px !important;
  max-height: 80vh;
  overflow-y: auto;
}
.budget-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.budget-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.budget-field label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.budget-cat-name {
  color: var(--text);
}
.budget-input-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}
.budget-dollar {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
}
.budget-input-wrap input {
  flex: 1;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.budget-input-wrap input:focus {
  border-color: var(--accent);
}
.budget-input-wrap input::placeholder {
  color: var(--text-dim);
}

/* Button: small outline */
.btn.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}
.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.modal .form-actions {
  margin-top: 16px;
}
.modal-title {
  margin-bottom: 4px;
}
.modal-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ─── Ecosystem Footer ─── */
/* Positioned above the nav bar on mobile so it doesn't overlap */
.eco-footer {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom));
  left: 0;
  right: 0;
  z-index: 99;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 6px 16px;
  padding-bottom: calc(6px + var(--safe-bottom));
  font-size: 11px;
}
.eco-footer-inner {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}
.eco-footer-brand {
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}
.eco-footer-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
}
.eco-link {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
  white-space: nowrap;
}
.eco-link:hover,
.eco-link:focus-visible {
  color: var(--text);
  text-decoration: underline;
}
.eco-link-sep {
  color: var(--text-dim);
  font-size: 10px;
}

/* === Photo Gallery === */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  padding: 4px 0;
}
.gallery-item {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.12s;
  aspect-ratio: 3 / 4;
}
.gallery-item:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.gallery-item:active {
  transform: translateY(0);
}
.gallery-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.gallery-item-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px 8px 8px;
  background: linear-gradient(transparent, rgba(0,0,0,0.65));
  color: #fff;
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.3;
}
.gallery-item-overlay .gallery-item-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gallery-item-overlay .gallery-item-meta {
  font-size: 0.62rem;
  opacity: 0.8;
  margin-top: 2px;
}
.gallery-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.gallery-empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}
.gallery-empty h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.gallery-empty p {
  font-size: 0.85rem;
  margin-bottom: 16px;
}

/* Lightbox */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: background 0.15s;
}
.lightbox-close:hover,
.lightbox-close:focus-visible {
  background: rgba(255,255,255,0.3);
}
.lightbox-close:focus-visible {
  outline: 2px solid var(--accent);
}
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: background 0.15s;
}
.lightbox-nav:hover,
.lightbox-nav:focus-visible {
  background: rgba(255,255,255,0.3);
}
.lightbox-nav:focus-visible {
  outline: 2px solid var(--accent);
}
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }
.lightbox-content {
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.lightbox-content img {
  max-width: 100%;
  max-height: 70vh;
  border-radius: var(--radius);
  object-fit: contain;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.lightbox-info {
  color: rgba(255,255,255,0.85);
  text-align: center;
  font-size: 0.85rem;
  max-width: 400px;
  line-height: 1.4;
}
.lightbox-info .lb-name {
  font-weight: 600;
  font-size: 1rem;
  color: #fff;
}
.lightbox-info .lb-detail {
  color: rgba(255,255,255,0.6);
  font-size: 0.78rem;
  margin-top: 4px;
}
.lightbox-info .lb-view-item {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 16px;
  background: rgba(255,255,255,0.15);
  color: #fff;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.78rem;
  transition: background 0.15s;
}
.lightbox-info .lb-view-item:hover,
.lightbox-info .lb-view-item:focus-visible {
  background: rgba(255,255,255,0.3);
}
.lightbox-info .lb-view-item:focus-visible {
  outline: 2px solid var(--accent);
}

.text-muted-sm { font-size: 12px; color: var(--text-muted); }
.text-muted-xs { font-size: 0.75rem; color: var(--text-muted); }
.text-muted-md { font-size: 14px; color: var(--text-muted); }

.photo-count {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Body bottom padding so content doesn't hide behind footer */
body {
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 44px);
}

/* === PWA Install Banner === */
.pwa-install-bnr {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg-card);
  color: var(--text);
  padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
  z-index: 9999;
  box-shadow: var(--shadow);
  border-top: 1px solid var(--border);
  transform: translateY(100%);
  transition: transform 0.3s ease;
  padding-bottom: calc(12px + var(--safe-bottom));
}
.pwa-install-bnr.show { transform: translateY(0); }
.pi-text {
  flex: 1; font-size: 14px; color: var(--text-muted);
  line-height: 1.3;
}
.pi-btn {
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.pi-btn:hover, .pi-btn:focus-visible { opacity: 0.9; }
.pi-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pi-dismiss {
  background: none; border: none;
  color: var(--text-dim);
  font-size: 20px; cursor: pointer;
  padding: 4px; line-height: 1;
}
.pi-dismiss:hover, .pi-dismiss:focus-visible { color: var(--text-muted); }
