:root {
  --p:    #4f46e5;
  --p-d:  #4338ca;
  --p-l:  #e0e7ff;
  --ok:   #10b981;
  --warn: #f59e0b;
  --err:  #ef4444;
  --bg:   #f1f5f9;
  --surf: #ffffff;
  --sur2: #f8fafc;
  --tx:   #0f172a;
  --tx2:  #64748b;
  --brd:  #e2e8f0;
  --shad: 0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.06);
  --shad2:0 4px 16px rgba(15,23,42,.12);
  --nav:  64px;
  --hdr:  56px;
  --r:    12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg:   #0f172a;
    --surf: #1e293b;
    --sur2: #0f172a;
    --tx:   #f1f5f9;
    --tx2:  #94a3b8;
    --brd:  #334155;
    --shad: 0 1px 3px rgba(0,0,0,.3);
    --shad2:0 4px 16px rgba(0,0,0,.4);
    --p-l:  #1e1b4b;
  }
}


*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Scrollbar */
* { scrollbar-width: thin; scrollbar-color: var(--brd) transparent; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--brd); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--tx2); }

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  overflow-x: clip;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--tx);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  overflow-x: clip;
  touch-action: pan-y;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }

/* Splash */
.splash {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; gap: 16px; background: var(--p);
}
.splash-icon {
  width: 80px; height: 80px;
  background: rgba(255,255,255,.15);
  border-radius: 20px; padding: 16px;
}
.splash p { color: white; font-size: 1.25rem; font-weight: 600; }

/* Layout */
#app { height: var(--app-h, 100dvh); display: flex; flex-direction: column; }

.view {
  flex: 1;
  width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
  animation: fadeIn .18s ease-out;
}
@keyframes fadeIn { from { opacity:.4; transform:translateY(6px); } to { opacity:1; transform:none; } }

/* Header */
.hdr {
  position: sticky; top: 0; z-index: 20;
  height: calc(var(--hdr) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  background: var(--surf);
  border-bottom: 1px solid var(--brd);
  display: flex; align-items: center; padding-left: max(16px, calc(50% - 320px)); padding-right: max(16px, calc(50% - 320px)); gap: 12px;
  backdrop-filter: blur(10px);
}
.hdr-title { font-size: 1.1rem; font-weight: 600; flex: 1; }
.hdr-back {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%; background: var(--sur2);
  border: none; cursor: pointer; color: var(--tx); flex-shrink: 0;
  touch-action: manipulation;
}
.hdr-back:active { background: var(--brd); }

/* Property chip in header */
.prop-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--p-l); color: var(--p);
  border: none; border-radius: 99px;
  padding: 4px 10px; font-size: .75rem; font-weight: 600;
  cursor: pointer; white-space: nowrap; max-width: 140px;
  overflow: hidden; text-overflow: ellipsis;
  touch-action: manipulation;
}
.prop-chip:active { opacity: .75; }

/* Bottom nav — in-flow; #app height is controlled by JS via --app-h */
.nav {
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surf);
  border-top: 1px solid var(--brd);
  display: flex; align-items: flex-start; justify-content: center;
}
.nav-inner {
  display: flex; align-items: flex-start;
  width: 100%; max-width: 640px;
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; padding-top: 8px;
  min-height: var(--nav);
  border: none; background: none; cursor: pointer; color: var(--tx2);
  font-size: .65rem; font-weight: 500; touch-action: manipulation;
  transition: color .15s;
}
.nav-btn svg { width: 24px; height: 24px; }
.nav-btn.active { color: var(--p); }
.nav-btn.active svg { filter: none; }

.nav-fab {
  flex: 1; display: flex; align-items: flex-start; justify-content: center;
  padding-top: 4px; min-height: var(--nav);
}
.nav-fab-btn {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--p); color: white;
  border: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 12px rgba(79,70,229,.4);
  touch-action: manipulation; transition: transform .1s, box-shadow .1s;
}
.nav-fab-btn:active { transform: scale(.94); box-shadow: 0 1px 6px rgba(79,70,229,.3); }
.nav-fab-btn svg { width: 28px; height: 28px; }

/* Cards */
.card {
  background: var(--surf);
  border-radius: var(--r);
  box-shadow: var(--shad);
  overflow: hidden;
}

/* Page padding */
.page { padding: 16px; display: flex; flex-direction: column; gap: 16px; max-width: 720px; margin: 0 auto; width: 100%; }

/* Dashboard stats */
.stats-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.stat-card {
  background: var(--surf); border-radius: var(--r); padding: 16px;
  box-shadow: var(--shad); display: flex; flex-direction: column; gap: 4px;
}
.stat-card.accent { background: var(--p); color: white; }
.stat-card.accent .stat-label { color: rgba(255,255,255,.75); }
.stat-num { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .75rem; color: var(--tx2); font-weight: 500; }

/* Section */
.section-hdr {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 20px; margin-bottom: 8px;
}
.stats-grid + .section-hdr,
#neighbor-requests:first-child .section-hdr,
.page > div:first-child .section-hdr { margin-top: 4px; }
.section-title { font-size: .8rem; font-weight: 600; color: var(--tx2); text-transform: uppercase; letter-spacing: .05em; }
.section-link { font-size: .8rem; color: var(--p); font-weight: 500; }

/* Item list */
.item-list { display: flex; flex-direction: column; gap: 2px; }
.item-row {
  background: var(--surf); display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; cursor: pointer; touch-action: manipulation;
  transition: background .1s;
}
.item-row:first-child { border-radius: var(--r) var(--r) 0 0; }
.item-row:last-child  { border-radius: 0 0 var(--r) var(--r); }
.item-row:only-child  { border-radius: var(--r); }
.item-row:active      { background: var(--sur2); }
.item-row + .item-row { border-top: 1px solid var(--brd); }

/* Swipe-to-delete */
.swipe-wrap { position: relative; overflow: hidden; }
.swipe-wrap:first-child,
.swipe-wrap:first-child .item-row { border-radius: var(--r) var(--r) 0 0; }
.swipe-wrap:last-child,
.swipe-wrap:last-child .item-row  { border-radius: 0 0 var(--r) var(--r); }
.swipe-wrap:only-child,
.swipe-wrap:only-child .item-row  { border-radius: var(--r); }
.swipe-wrap + .swipe-wrap         { border-top: 1px solid var(--brd); }
.swipe-wrap .item-row { border-radius: inherit; will-change: transform; touch-action: pan-y; position: relative; z-index: 1; }
.swipe-del-btn {
  position: absolute; right: 0; top: 0; height: 100%; width: 72px;
  background: var(--err); color: #fff; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.item-thumb {
  width: 48px; height: 48px; border-radius: 10px; flex-shrink: 0;
  object-fit: cover; background: var(--sur2);
  display: flex; align-items: center; justify-content: center; color: var(--tx2);
}
.item-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
.item-thumb-borrowed { opacity: .45; }
.item-info { flex: 1; min-width: 0; }
.borrow-badge { display:inline-block; font-size:.68rem; font-weight:600; line-height:1;
  background:rgba(245,158,11,.15); color:var(--warn); border-radius:99px; padding:2px 7px;
  vertical-align:middle; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:140px; }
.item-name { font-size: .95rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-meta { font-size: .75rem; color: var(--tx2); margin-top: 2px; }
.item-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 100px; font-size: .7rem; font-weight: 600;
}

/* Search bar */
.search-wrap {
  display: flex; align-items: center; gap: 0;
  border: 1.5px solid var(--brd); border-radius: var(--r);
  background: var(--surf); transition: border-color .15s;
  padding: 0 10px 0 12px;
}
.search-wrap:focus-within { border-color: var(--p); }
.search-icon {
  display: flex; align-items: center; flex-shrink: 0;
  color: var(--tx2); pointer-events: none; margin-right: 8px;
}
.search-input {
  flex: 1; padding: 10px 0;
  border: none !important; background: none !important; color: var(--tx); font-size: .95rem;
  outline: none; min-width: 0; box-shadow: none !important;
}
.search-clear {
  background: var(--tx2); color: var(--surf); border: none; border-radius: 50%;
  width: 18px; height: 18px; font-size: .7rem; cursor: pointer; display: none;
  align-items: center; justify-content: center; flex-shrink: 0; margin-left: 6px;
}
.search-input:not(:placeholder-shown) ~ .search-clear { display: flex; }

/* Filter chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; padding: 6px 14px; border-radius: 100px;
  border: 1.5px solid var(--brd); background: var(--surf);
  font-size: .8rem; font-weight: 500; cursor: pointer; color: var(--tx2);
  touch-action: manipulation; white-space: nowrap;
}
.chip.active { background: var(--p); border-color: var(--p); color: white; }

/* Filter sheet */
.filter-options { display: flex; flex-direction: column; gap: 2px; }
.filter-option {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-radius: 10px; cursor: pointer;
  font-size: .9rem; color: var(--tx); transition: background .1s;
}
.filter-option:hover  { background: var(--sur2); }
.filter-option.active { background: var(--p-l); color: var(--p); font-weight: 600; }
.filter-option svg    { flex-shrink: 0; color: var(--p); }

/* Item detail */
.detail-img {
  width: calc(100% - 32px);
  margin: 16px auto 0;
  display: flex; justify-content: center;
  flex-shrink: 0;
}
.detail-img img {
  max-width: 100%; max-height: 360px;
  width: auto; height: auto;
  display: block;
  border-radius: var(--r);
  box-shadow: var(--shad);
}
.qty-stepper {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 18px 20px;
}
.qty-stepper-lbl {
  font-size: .7rem; font-weight: 600; color: var(--tx2);
  text-transform: uppercase; letter-spacing: .07em; align-self: flex-start;
}
.qty-stepper-row {
  display: flex; align-items: center; gap: 24px; justify-content: center; width: 100%;
}
.qty-btn {
  width: 52px; height: 52px; border-radius: 50%; flex-shrink: 0;
  background: var(--sur2); border: 1.5px solid var(--brd); color: var(--tx);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  touch-action: manipulation; transition: background .1s, border-color .1s, color .1s, transform .1s;
}
.qty-btn:not(:disabled):active { background: var(--p-l); border-color: var(--p); color: var(--p); transform: scale(.9); }
.qty-btn:disabled { opacity: .25; cursor: default; }
.qty-display { min-width: 80px; text-align: center; }
.qty-val { font-size: 2.4rem; font-weight: 700; line-height: 1; }
.qty-unit { font-size: .78rem; color: var(--tx2); margin-top: 4px; }

.lend-banner {
  width: 100%; max-width: 720px; margin: 0 auto; box-sizing: border-box;
  background: var(--p); color: white; padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
}
.lend-banner-info { flex: 1; min-width: 0; }
.detail-body { padding: 20px 16px; display: flex; flex-direction: column; gap: 16px; max-width: 720px; margin: 0 auto; width: 100%; box-sizing: border-box; }
.detail-name { font-size: 1.4rem; font-weight: 700; }
.detail-props { display: flex; flex-direction: column; gap: 8px; }
.detail-prop { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--brd); }
.detail-prop:last-child { border-bottom: none; }
.prop-label { font-size: .8rem; color: var(--tx2); font-weight: 500; }
.prop-value { font-size: .9rem; font-weight: 500; text-align: right; }

.btn-row { display: flex; gap: 10px; }
.btn {
  flex: 1; padding: 13px; border-radius: var(--r); border: none;
  font-size: .95rem; font-weight: 600; cursor: pointer;
  touch-action: manipulation; transition: opacity .1s;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:active { opacity: .8; }
.btn-primary { background: var(--p); color: white; }
.btn-secondary { background: var(--sur2); color: var(--tx); border: 1.5px solid var(--brd); }
.btn-danger { background: #fef2f2; color: var(--err); border: 1.5px solid #fecaca; }
.btn-icon-only { flex: 0; padding: 13px; }
.btn-sm { flex: 0; padding: 6px 12px; font-size: .8rem; border-radius: 8px; }
.btn-ok  { background: rgba(16,185,129,.12); color: var(--ok); border: 1px solid rgba(16,185,129,.25); }
.btn-err { background: rgba(239,68,68,.08);  color: var(--err); border: 1px solid rgba(239,68,68,.2); }
.badge-count { background: var(--p); color: white; border-radius: 99px; font-size: .7rem; font-weight: 700; padding: 1px 7px; min-width: 20px; text-align: center; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 16px; padding: 16px; max-width: 720px; margin: 0 auto; width: 100%; box-sizing: border-box; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: .8rem; font-weight: 600; color: var(--tx2); }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=tel], input[type=search], select, textarea {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--brd); border-radius: var(--r);
  background: var(--surf); color: var(--tx); font-size: .95rem;
  outline: none; transition: border-color .15s; -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--p); }
textarea { resize: vertical; min-height: 80px; }
select { cursor: pointer; }

/* Hide number input spinners — users type directly */
input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.img-upload {
  width: 100%; aspect-ratio: 16/9; max-height: 220px; border-radius: var(--r);
  border: 2px dashed var(--brd); background: var(--sur2);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; cursor: pointer; color: var(--tx2); transition: border-color .15s;
  overflow: hidden; position: relative;
}
.img-upload:active, .img-upload.drag { border-color: var(--p); background: var(--p-l); }
.img-upload img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.img-upload-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; gap: 12px; color: white;
}
.img-upload-hint { font-size: .8rem; font-weight: 500; }

.scan-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 14px; border: 1.5px solid var(--p);
  border-radius: var(--r); background: var(--p-l); color: var(--p);
  font-size: .9rem; font-weight: 600; cursor: pointer; touch-action: manipulation;
  width: 100%;
}
.scan-btn:active { background: var(--p); color: white; }

/* Condition selector */
.cond-group { display: flex; gap: 8px; }
.cond-opt {
  flex: 1; padding: 8px 4px; border-radius: var(--r);
  border: 1.5px solid var(--brd); background: var(--surf);
  font-size: .75rem; font-weight: 600; text-align: center; cursor: pointer;
  touch-action: manipulation; color: var(--tx2);
}
.cond-opt.active { border-color: currentColor; }
.cond-opt[data-v=new].active    { color: var(--ok);   background: #d1fae5; border-color: var(--ok); }
.cond-opt[data-v=good].active   { color: #3b82f6;     background: #dbeafe; border-color: #3b82f6; }
.cond-opt[data-v=used].active   { color: var(--warn); background: #fef3c7; border-color: var(--warn); }
.cond-opt[data-v=broken].active { color: var(--err);  background: #fee2e2; border-color: var(--err); }

/* Toggle */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: var(--surf); border-radius: var(--r);
  box-shadow: var(--shad);
}
.toggle-label { font-size: .95rem; font-weight: 500; }
.toggle-sub   { font-size: .75rem; color: var(--tx2); margin-top: 2px; }
.toggle {
  width: 48px; height: 28px; border-radius: 100px;
  background: var(--brd); border: none; cursor: pointer;
  position: relative; transition: background .2s; flex-shrink: 0;
  touch-action: manipulation;
}
.toggle::after {
  content: ''; position: absolute;
  width: 22px; height: 22px; border-radius: 50%; background: white;
  top: 3px; left: 3px; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle.on { background: var(--p); }
.toggle.on::after { transform: translateX(20px); }

/* Auth */
.auth-wrap {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: max(24px, calc(env(safe-area-inset-top) + 16px)) 24px max(24px, calc(env(safe-area-inset-bottom) + 16px));
  background: var(--bg);
}
.auth-logo {
  width: 72px; height: 72px; background: var(--p); border-radius: 18px;
  display: flex; align-items: center; justify-content: center; margin-bottom: 24px;
}
.auth-logo svg { width: 40px; height: 40px; }
.auth-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 4px; }
.auth-sub   { font-size: .9rem; color: var(--tx2); margin-bottom: 28px; }
.auth-card  { width: 100%; max-width: 380px; background: var(--surf); border-radius: 20px; padding: 28px; box-shadow: var(--shad2); }
.auth-tabs  { display: flex; gap: 0; border-bottom: 1px solid var(--brd); margin-bottom: 24px; }
.auth-tab   { flex: 1; padding: 10px; text-align: center; font-weight: 600; font-size: .9rem; color: var(--tx2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; touch-action: manipulation; }
.auth-tab.active { color: var(--p); border-bottom-color: var(--p); }
.auth-err   { background: #fee2e2; color: var(--err); border-radius: var(--r); padding: 10px 14px; font-size: .85rem; font-weight: 500; }
.auth-ok    { background: #d1fae5; color: #065f46;   border-radius: var(--r); padding: 10px 14px; font-size: .85rem; font-weight: 500; }

/* Scanner */
.scanner-wrap {
  position: fixed; inset: 0; z-index: 100;
  background: black; display: flex; flex-direction: column;
}
.scanner-video { flex: 1; object-fit: cover; width: 100%; }
.scanner-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; pointer-events: none;
}
.scanner-frame {
  width: 260px; height: 120px; border-radius: 12px;
  border: 3px solid white; box-shadow: 0 0 0 9999px rgba(0,0,0,.6);
}
.scanner-hint { color: white; margin-top: 20px; font-size: .9rem; opacity: .85; }
.scanner-close {
  position: absolute; top: max(20px, env(safe-area-inset-top)); right: 16px;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,.2); color: white; border: none; cursor: pointer;
  font-size: 1.2rem; display: flex; align-items: center; justify-content: center;
  pointer-events: all; touch-action: manipulation;
}

/* Empty state */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 48px 24px; color: var(--tx2); text-align: center;
}
.empty svg { opacity: .35; }
.empty p { font-size: .9rem; }

/* Toast */
.toast-wrap { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  padding: 10px 18px; border-radius: 100px; font-size: .85rem; font-weight: 600;
  box-shadow: var(--shad2); animation: toastIn .2s ease-out;
  pointer-events: all;
}
.toast.ok   { background: var(--ok);   color: white; }
.toast.err  { background: var(--err);  color: white; }
.toast.info { background: var(--surf); color: var(--tx); border: 1px solid var(--brd); }
@keyframes toastIn { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:none; } }

/* Category badge */
.cat-dot {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 100px; font-size: .75rem; font-weight: 600;
}

/* Settings list */
.settings-list { background: var(--surf); border-radius: var(--r); box-shadow: var(--shad); overflow: hidden; }
.settings-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; cursor: pointer; touch-action: manipulation;
  border-bottom: 1px solid var(--brd); transition: background .1s;
}
.settings-item:last-child { border-bottom: none; }
.settings-item:active { background: var(--sur2); }
.settings-item-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.settings-item-body { flex: 1; }
.settings-item-title { font-size: .95rem; font-weight: 500; }
.settings-item-sub   { font-size: .75rem; color: var(--tx2); margin-top: 2px; }
.settings-item-arrow { color: var(--tx2); }

/* Expiry indicators */
.exp-warn { color: var(--warn); font-weight: 600; }
.exp-danger { color: var(--err); font-weight: 600; }

/* Manage lists (categories/locations) */
.manage-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--surf);
  border-bottom: 1px solid var(--brd);
}
.manage-item:first-child { border-radius: var(--r) var(--r) 0 0; }
.manage-item:last-child  { border-radius: 0 0 var(--r) var(--r); border-bottom: none; }
.manage-item:only-child  { border-radius: var(--r); border-bottom: none; }
.manage-icon {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 1rem;
}
.manage-name { flex: 1; font-weight: 500; font-size: .9rem; }
.manage-count { font-size: .75rem; color: var(--tx2); margin-right: 8px; }
.manage-edit {
  color: var(--p); background: none; border: none; cursor: pointer;
  font-size: .8rem; font-weight: 600; padding: 4px 10px; border-radius: 6px;
  touch-action: manipulation;
}
.manage-edit:active { background: var(--p-l); }

/* Bottom sheet / modal */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.5); backdrop-filter: blur(2px);
  display: flex; align-items: flex-end;
  animation: sheetBdIn .2s;
}
@keyframes sheetBdIn { from { opacity:0; } to { opacity:1; } }
.sheet {
  width: 100%; background: var(--surf); border-radius: 20px 20px 0 0;
  padding-bottom: env(safe-area-inset-bottom);
  max-height: 85vh; overflow-y: auto;
  animation: sheetIn .25s ease-out;
}
@keyframes sheetIn { from { transform: translateY(100%); } to { transform: none; } }
.sheet-handle {
  width: 36px; height: 4px; background: var(--brd);
  border-radius: 2px; margin: 12px auto 16px;
}
.sheet-title { font-size: 1.05rem; font-weight: 700; padding: 0 20px 16px; }

/* Loading spinner */
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--brd);
  border-top-color: var(--p); border-radius: 50%;
  animation: spin .7s linear infinite; margin: 32px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Confirm dialog */
.confirm {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; padding: 24px;
}
.confirm-card {
  background: var(--surf); border-radius: 20px; padding: 28px; width: 100%; max-width: 340px;
  box-shadow: var(--shad2);
}
.confirm-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 8px; }
.confirm-msg   { font-size: .9rem; color: var(--tx2); margin-bottom: 24px; }
.confirm-btns  { display: flex; gap: 10px; }

/* Tag input */
.tag-input-wrap {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 8px 12px; border: 1.5px solid var(--brd); border-radius: var(--r);
  background: var(--surf); min-height: 48px; cursor: text;
  transition: border-color .15s;
}
.tag-input-wrap:focus-within { border-color: var(--p); }
.tag-input-field {
  border: none; background: none; outline: none; color: var(--tx);
  font-size: .95rem; min-width: 100px; flex: 1; padding: 2px 0;
}
.tag-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--p-l); color: var(--p);
  border-radius: 100px; padding: 4px 10px;
  font-size: .75rem; font-weight: 600; white-space: nowrap;
}
.tag-chip-x {
  cursor: pointer; line-height: 1; opacity: .6; font-size: 1rem;
  touch-action: manipulation; margin-left: 1px;
}
.tag-chip-x:active { opacity: 1; }
.tags-wrap { display: flex; flex-wrap: wrap; gap: 5px; }

/* Lieferumfang */
.contents-list { display: flex; flex-direction: column; gap: 6px; }
.content-row { display: flex; align-items: center; gap: 8px; }
.content-row input { flex: 1; }
.content-row-del {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 8px;
  border: 1.5px solid var(--brd); background: var(--sur2);
  color: var(--err); cursor: pointer; display: flex; align-items: center;
  justify-content: center; font-size: 1.1rem; touch-action: manipulation;
}
.content-row-del:active { background: var(--brd); }
.contents-add {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 14px; border: 1.5px dashed var(--brd); border-radius: var(--r);
  background: none; color: var(--p); font-size: .88rem; font-weight: 600;
  cursor: pointer; touch-action: manipulation; width: 100%;
}
.contents-add:active { background: var(--p-l); }

/* Borrow status badges */
.borrow-badge {
  font-size: .68rem; font-weight: 600; border-radius: 99px; padding: 2px 8px; white-space: nowrap;
}
.borrow-badge.avail { background: rgba(16,185,129,.12); color: var(--ok); }
.borrow-badge.warn  { background: rgba(245,158,11,.15);  color: var(--warn); }
.borrow-badge.ok    { background: rgba(16,185,129,.15);  color: var(--ok); }
.borrow-badge.info  { background: rgba(79,70,229,.12);   color: var(--p); }
.borrow-badge.err   { background: rgba(239,68,68,.12);   color: var(--err); }

/* FAB speed-dial menu */
.fab-menu-wrap { position: fixed; inset: 0; z-index: 150; }
.fab-menu-backdrop { position: absolute; inset: 0; }
.fab-menu {
  position: absolute; bottom: calc(var(--nav) + 16px); left: 50%; transform: translateX(-50%);
  background: var(--surf); border-radius: var(--r); box-shadow: var(--shad2);
  min-width: 220px; overflow: hidden;
}
.fab-menu-item {
  display: flex; align-items: center; gap: 12px; padding: 15px 20px;
  border: none; background: none; width: 100%; text-align: left;
  font-size: .95rem; color: var(--tx); cursor: pointer;
  border-bottom: 1px solid var(--brd); transition: background .12s;
}
.fab-menu-item:last-child { border-bottom: none; }
.fab-menu-item:hover { background: var(--sur2); }

/* Einräumen — location picker */
.loc-picker-row {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px; border-bottom: 1px solid var(--brd); cursor: pointer;
  transition: background .12s;
}
.loc-picker-row:hover { background: var(--sur2); }
.loc-picker-row:last-child { border-bottom: none; }
.loc-picker-name { flex: 1; font-size: .95rem; }
.loc-has-children { color: var(--tx2); flex-shrink: 0; display: flex; align-items: center; }
.loc-here-btn {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 14px 16px; border: none; border-bottom: 2px solid var(--brd);
  background: var(--p-l); color: var(--p); font-size: .95rem; font-weight: 600;
  cursor: pointer; text-align: left;
}
.loc-here-btn:active { background: var(--p); color: white; }

/* Location picker sheet (used in item form) */
.sheet-loc-picker { display:flex; flex-direction:column; overflow:hidden; }
.sheet-loc-hdr {
  display:flex; align-items:center; gap:8px;
  padding:0 16px 12px; flex-shrink:0;
}
.sheet-loc-body { overflow-y:auto; flex:1; padding-bottom:24px; }
.loc-picker-here {
  background:var(--p-l); color:var(--p); font-weight:600;
  border-bottom:2px solid var(--brd);
}
.loc-picker-here:hover { filter:brightness(.96); }
.loc-picker-none { color:var(--tx2); border-bottom:1px solid var(--brd); }
.loc-picker-active { background:var(--p-l) !important; color:var(--p); }
.loc-picker-active .loc-picker-name { font-weight:600; }

/* Location select button (replaces <select> in forms) */
.loc-select-btn {
  width:100%; text-align:left; padding:11px 14px;
  background:var(--surf); border:1px solid var(--brd); border-radius:var(--r);
  color:var(--tx); font-size:.95rem; cursor:pointer;
  transition:border-color .15s; min-height:44px; display:block;
}
.loc-select-btn:hover { border-color:var(--p); }
.loc-select-btn-empty { color:var(--tx2); }

/* Einräumen — batch loop */
.batch-input-bar {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px;
  background: var(--surf); border-bottom: 1px solid var(--brd); flex-shrink: 0;
}
.batch-input-bar input[type=text] {
  flex: 1; border: 1.5px solid var(--brd); border-radius: var(--r);
  padding: 10px 14px; font-size: 1rem; background: var(--sur2); color: var(--tx);
}
.batch-input-bar input[type=text]:focus { outline: none; border-color: var(--p); }
.batch-photo-btn {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: var(--r);
  border: 1.5px solid var(--brd); background: var(--sur2); color: var(--tx2);
  cursor: pointer; flex-shrink: 0; transition: color .2s;
}
.batch-add-btn {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: var(--r);
  border: none; background: var(--p); color: white; cursor: pointer; flex-shrink: 0;
  transition: background .12s;
}
.batch-add-btn:active { background: var(--p-d); }
.batch-hint { color: var(--tx2); font-size: .9rem; text-align: center; padding: 32px 0; }
.batch-added-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: var(--surf); border-radius: var(--r); cursor: pointer;
  transition: background .12s;
}
.batch-added-row:hover { background: var(--sur2); }
.batch-added-name { flex: 1; font-size: .9rem; }
.batch-del-btn {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%;
  border: none; background: var(--sur2); color: var(--tx2);
  font-size: 1rem; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s;
}
.batch-del-btn:hover { background: rgba(239,68,68,.12); color: var(--err); }
.batch-thumb { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.batch-thumb-ph {
  display: flex; align-items: center; justify-content: center;
  background: var(--p-l); color: var(--p);
}

/* Item row context menu */
.item-row-right { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.item-menu-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px; border: none;
  background: none; color: var(--tx2); font-size: 1.2rem; cursor: pointer;
  letter-spacing: .05em; line-height: 1; flex-shrink: 0;
  transition: background .12s;
}
.item-menu-btn:hover  { background: var(--sur2); }
.item-menu-btn:active { background: var(--brd); }

.menu-action {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 20px; border: none; background: none; width: 100%;
  text-align: left; font-size: .95rem; color: var(--tx); cursor: pointer;
  border-bottom: 1px solid var(--brd); transition: background .12s;
}
.menu-action:last-child { border-bottom: none; }
.menu-action:hover  { background: var(--sur2); }
.menu-action-danger { color: var(--err); }

/* More fields toggle */
.more-fields-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 10px; border: 1px dashed var(--brd); border-radius: var(--r);
  background: none; color: var(--tx2); font-size: .875rem; cursor: pointer;
  transition: background .15s, color .15s;
}
.more-fields-btn:hover { background: var(--sur2); color: var(--tx); }
.more-fields-btn.open  { color: var(--p); border-color: var(--p-l); }

/* Icon-only action buttons (scan, filter) */
.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: var(--r);
  border: 1px solid var(--brd); background: var(--surf); color: var(--tx2);
  cursor: pointer; flex-shrink: 0; transition: background .12s, color .12s;
}
.icon-btn:hover      { background: var(--sur2); color: var(--tx); }
.icon-btn-active     { border-color: var(--p); color: var(--p); background: var(--p-l); }

/* View tabs (Liste / Nach Ort / Nach Kategorie) */
.view-tabs {
  display: flex; gap: 4px; background: var(--sur2);
  border-radius: var(--r); padding: 4px;
}
.view-tab {
  flex: 1; padding: 7px 4px; border: none; background: none;
  border-radius: calc(var(--r) - 3px); font-size: .8rem; font-weight: 500;
  color: var(--tx2); cursor: pointer; transition: background .15s, color .15s;
}
.view-tab.active {
  background: var(--surf); color: var(--tx);
  box-shadow: var(--shad);
}

/* Group blocks (location / category grouped view) */
.group-block { margin-bottom: 8px; }
.group-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-radius: var(--r);
  background: var(--surf); box-shadow: var(--shad);
  cursor: pointer; user-select: none; transition: background .12s;
}
.group-hdr:hover { background: var(--sur2); }
.group-hdr-left {
  display: flex; align-items: center; gap: 8px;
  min-width: 0; overflow: hidden;
}
.group-label {
  font-size: .9rem; font-weight: 600; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.group-count {
  font-size: .75rem; font-weight: 600; color: var(--surf);
  background: var(--tx2); border-radius: 99px;
  padding: 1px 7px; flex-shrink: 0;
}
.group-chevron {
  flex-shrink: 0; color: var(--tx2);
}
/* Attach group item list visually below header */
.group-block .item-list.card { border-radius: 0 0 var(--r) var(--r); margin: 0; }

/* Nested location sub-body */
.group-sub-body {
  border: 1px solid var(--brd); border-top: none;
  border-radius: 0 0 var(--r) var(--r);
  background: var(--sur2); padding: 6px;
  display: flex; flex-direction: column; gap: 3px;
}
.group-sub-hdr {
  box-shadow: none; border: 1px solid var(--brd); padding: 8px 12px;
}
.group-sub-hdr .group-label { font-weight: 500; font-size: .85rem; }
.group-sub-hdr .group-count { background: var(--brd); color: var(--tx2); }

/* Search highlight */
mark {
  background: rgba(79,70,229,.18); color: inherit;
  border-radius: 3px; padding: 0 2px; font-style: normal;
}
@media (prefers-color-scheme: dark) {
  mark { background: rgba(99,102,241,.3); }
}

/* Responsive tweaks */
@media (min-width: 480px) {
  .auth-wrap { background: var(--p); }
  .auth-logo { display: none; }
}

/* Dark mode overrides — must come AFTER all base rules so cascade wins */
@media (prefers-color-scheme: dark) {
  .btn-danger { background: rgba(239,68,68,.15); border-color: rgba(239,68,68,.35); }
  .auth-err   { background: rgba(239,68,68,.2);  color: #fca5a5; }
  .auth-ok    { background: rgba(16,185,129,.2); color: #6ee7b7; }
  .cond-opt[data-v=new].active    { background: rgba(16,185,129,.15); }
  .cond-opt[data-v=good].active   { background: rgba(59,130,246,.15); }
  .cond-opt[data-v=used].active   { background: rgba(245,158,11,.15); }
  .cond-opt[data-v=broken].active { background: rgba(239,68,68,.15);  }
}


