:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --ink: #1c1c1e;
  --muted: #8e8e93;
  --accent: #3d5a40;
  --accent-ink: #ffffff;
  --danger: #ff3b30;
  --hairline: rgba(60, 60, 67, 0.29);
  --field-border: rgba(60, 60, 67, 0.18);
  --field-bg: #ffffff;
  --neutral-act: #5d6e5f;
  --radius: 14px;
}
:root[data-theme="dark"] {
  --bg: #000000;
  --card: #1c1c1e;
  --ink: #f2f2f7;
  --muted: #8e8e93;
  --accent: #8fae91;
  --accent-ink: #102412;
  --danger: #ff453a;
  --hairline: rgba(84, 84, 88, 0.6);
  --field-border: rgba(84, 84, 88, 0.5);
  --field-bg: #2c2c2e;
  --neutral-act: #6d7e6f;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --card: #1c1c1e;
    --ink: #f2f2f7;
    --muted: #8e8e93;
    --accent: #8fae91;
    --accent-ink: #102412;
    --danger: #ff453a;
    --hairline: rgba(84, 84, 88, 0.6);
    --field-border: rgba(84, 84, 88, 0.5);
    --field-bg: #2c2c2e;
    --neutral-act: #6d7e6f;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, system-ui, sans-serif;
  font-size: 17px;
  padding-bottom: env(safe-area-inset-bottom);
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 4px;
}
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; color: var(--muted); margin: 20px 4px 8px; text-transform: uppercase; letter-spacing: .04em; }
main { padding: 8px 16px 40px; max-width: 560px; margin: 0 auto; }
.center { display: grid; place-items: center; min-height: 100dvh; }
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  margin: 8px 0;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  border: none;
  display: block;
  text-decoration: none;
  color: inherit;
}
.login { width: min(92vw, 360px); text-align: center; }
.login h1 { margin-bottom: 12px; }
input, select, textarea {
  color: var(--ink);
  caret-color: var(--accent);
}
input, button {
  font: inherit;
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--field-border);
  margin: 5px 0;
  background: var(--field-bg);
}
input#search {
  font-size: 19px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 2px solid var(--accent);
  margin-top: 10px;
}
button {
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  font-weight: 600;
  cursor: pointer;
}
button.danger { background: var(--danger); }
button.ghost, a.ghost {
  background: transparent;
  color: var(--accent);
  border: none;
  width: auto;
  padding: 8px 10px;
  text-decoration: none;
  font-weight: 600;
}
.small { font-size: 15px; }
.row { display: flex; gap: 8px; }
.box-row { display: flex; align-items: center; gap: 12px; }
.box-badge {
  flex: 0 0 auto;
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  border-radius: 999px;
}
.box-info { flex: 1; min-width: 0; }
.qr-link { color: var(--accent); font-weight: 600; text-align: center; }
.taken summary, .swipe-wrap.taken summary { color: var(--muted); }
.taken-tag { color: #b0813a; font-size: 14px; font-weight: 600; }
.item-actions { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; border-top: 0.5px solid var(--hairline); padding-top: 6px; }
.item-actions form { margin: 0; }
.move-form { display: flex; gap: 6px; align-items: center; max-width: 100%; }
.move-form select { flex: 1 1 0; min-width: 0; padding: 10px; border-radius: 10px; border: 1px solid var(--field-border); font: inherit; background: var(--field-bg); }
.move-form button { width: auto; flex: 0 0 auto; }
button.wide { width: 100%; text-align: left; padding-left: 0; }
.file-btn { display: block; text-align: center; background: var(--accent); color: var(--accent-ink); font-weight: 600; padding: 12px; border-radius: 10px; cursor: pointer; }
.file-btn input { display: none; }
.muted { color: var(--muted); font-size: 15px; }
.err { color: var(--danger); }
.hit { display: block; padding: 10px 4px; color: inherit; text-decoration: none; border-bottom: 1px solid var(--hairline); }
.hit:last-child { border-bottom: none; }
.add-item { display: flex; gap: 8px; align-items: center; }
.add-item input { margin: 0; }
.add-item button { width: auto; margin: 0; padding: 12px 18px; }
details summary { cursor: pointer; font-weight: 600; padding: 2px 0; list-style: none; }
details summary::-webkit-details-marker { display: none; }
.list { padding: 2px 14px; }
.swipe-wrap { position: relative; overflow: hidden; border-bottom: 0.5px solid var(--hairline); }
.swipe-wrap:last-child { border-bottom: none; }
.swipe-wrap .item-row { position: relative; background: var(--card); transition: transform .18s ease; border-bottom: none; }
.swipe-actions { position: absolute; top: 0; right: 0; bottom: 0; display: flex; align-items: stretch; }
.swipe-actions form { margin: 0; display: flex; align-items: stretch; }
.swipe-actions button { width: 78px; height: 100%; border-radius: 0; margin: 0; border-left: 3px solid var(--bg); }
.sw-take { background: var(--accent); }
.sw-del { background: var(--danger); }
.item-row { border-bottom: 0.5px solid var(--hairline); }
.item-row:last-child { border-bottom: none; }
.item-row summary { font-weight: 400; padding: 12px 0; }
.item-row form { padding-bottom: 10px; }
details[open] summary { margin-bottom: 8px; }

.feed-row { margin: 0; padding: 9px 0; border-bottom: 0.5px solid var(--hairline); font-size: 15px; }
.feed-row:last-child { border-bottom: none; }

.photo-strip { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0; }
.photo-thumb summary { padding: 0; }
.photo-thumb summary img { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; display: block; }
.photo-full { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 30; display: grid; place-items: center; padding: 20px; }
.photo-full img { max-width: 100%; max-height: 80vh; border-radius: 8px; }
.photo-full form { position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%); width: 200px; }
input[type=file] { border: none; background: transparent; padding: 8px 0; }

.desc-row { display: flex; align-items: flex-start; gap: 10px; }
.desc-details { flex: 1; min-width: 0; }
.qr-mini { color: var(--accent); flex: 0 0 auto; padding: 0 2px; }

.photo-close { position: absolute; top: 18px; right: 18px; width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.15); color: #fff; font-size: 20px; padding: 0; }

.add-btn { background: var(--card); color: var(--accent); font-weight: 600; text-align: center; border: none; }
dialog { border: none; border-radius: var(--radius); padding: 18px; width: min(92vw, 380px); box-shadow: 0 8px 40px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h3 { margin: 0 0 8px; }

.swipe-left { position: absolute; top: 0; left: 0; bottom: 0; display: flex; align-items: stretch; }
.swipe-left form { margin: 0; display: flex; align-items: stretch; }
.sw-move { width: 96px; height: 100%; border-radius: 0; margin: 0; background: var(--neutral-act); border-right: 3px solid var(--bg); }
.move-choice { background: var(--card); color: var(--ink); border: 1px solid var(--field-border); text-align: left; font-weight: 500; }
.move-choice .muted { font-weight: 400; }

.sw-stack { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: 100%; }
.sw-stack svg { width: 22px; height: 22px; }
.sw-stack span { font-size: 11px; font-weight: 600; line-height: 1; }
header { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.top-tools { display: flex; gap: 4px; align-items: center; }
.tool-btn { background: transparent; color: var(--accent); border: none; width: auto; padding: 8px; font-weight: 700; font-size: 15px; }
dialog { background: var(--card); color: var(--ink); }

button.feed-toggle { display: block; width: 100%; text-align: center; padding: 10px 0 4px; }

.qty-input { flex: 0 0 76px; text-align: center; }
.row input { min-width: 0; }
.list-tools { margin: 14px 0 -6px; }
.list-tools input { flex: 1; min-width: 0; }
#sort-btn { flex: 0 0 auto; }
#sort-btn.on { color: var(--accent); border-color: var(--accent); }
.edit-ic { width: 16px; height: 16px; vertical-align: -3px; color: var(--muted); margin-left: 2px; }
.file-btn.busy { opacity: .7; pointer-events: none; }
.file-btn.busy span::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: -2px;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.tools-row { margin-top: 10px; }
.tool-half {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 8px;
  text-align: center;
}
.tool-half svg { width: 17px; height: 17px; flex: 0 0 auto; }
.box-swipe {
  border-radius: var(--radius);
  margin: 8px 0;
  border-bottom: none;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.box-swipe .box-row {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  background: var(--card);
  padding: 14px;
  transition: transform .18s ease;
  text-decoration: none;
  color: inherit;
}
.box-swipe .sw-edit {
  width: 86px;
  height: 100%;
  border-radius: 0;
  margin: 0;
  background: var(--neutral-act);
  color: #fff;
}

.selecting .item-row summary::before {
  content: "";
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--muted);
  border-radius: 50%;
  margin-right: 10px;
  vertical-align: -5px;
  flex: 0 0 auto;
}
.selecting .swipe-wrap.sel summary::before {
  content: "\2713";
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-size: 13px;
  line-height: 20px;
  text-align: center;
}
#bulk-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: var(--card);
  border-top: 0.5px solid var(--hairline);
  z-index: 20;
}
#bulk-bar form { margin: 0; flex: 1; display: flex; }
#bulk-bar form button, #bulk-bar > button { flex: 1; width: 100%; }
#bulk-count { min-width: 22px; text-align: center; font-weight: 600; }
#bulk-bar button:disabled { opacity: .4; }
.danger-text { color: var(--danger); }
#select-btn.on { color: var(--accent); border-color: var(--accent); }
#bulk-bar[hidden] { display: none; }
.item-row summary { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.swipe-wrap.hl .item-row { animation: hl-pulse 2.4s ease; }
@keyframes hl-pulse {
  0%, 35% { background: color-mix(in srgb, var(--accent) 24%, var(--card)); }
  100% { background: var(--card); }
}
#bulk-bar form[hidden] { display: none; }
.swipe-wrap { scroll-margin-top: 76px; }
.feed-time { float: right; font-size: 13px; }
.item-photos { margin: 4px 0 8px; }
.item-photo-form { margin: 0; padding-bottom: 12px; }
.small-file { font-size: 14px; padding: 8px 12px; }
.cam-ic { width: 15px; height: 15px; vertical-align: -2px; color: var(--muted); }
.box-info { flex: 1; min-width: 0; }
.box-count { flex: 0 0 auto; font-size: 15px; }
.feed-time { margin-left: 10px; }
.clearable { position: relative; flex: 1; min-width: 0; }
.clearable input { width: 100%; padding-right: 38px; }
.clear-btn {
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  padding: 0;
  margin: 0;
  border-radius: 50%;
  background: var(--hairline);
  color: var(--muted);
  font-size: 11px;
  line-height: 22px;
  text-align: center;
}
.clear-btn[hidden] { display: none; }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
.thumb-wrap { position: relative; flex: 0 0 auto; }
.thumb-del { position: absolute; top: 4px; right: 4px; margin: 0; z-index: 2; }
.thumb-del button {
  width: 22px;
  height: 22px;
  padding: 0;
  margin: 0;
  border-radius: 50%;
  background: rgba(20,20,20,.65);
  color: #fff;
  font-size: 11px;
  line-height: 22px;
  text-align: center;
}
.photo-thumb { padding: 0; margin: 0; background: none; border: none; display: block; }
.photo-thumb img { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; display: block; }
#lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.94);
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
}
#lightbox[hidden] { display: none; }
#lb-stage { display: flex; align-items: center; justify-content: center; max-height: 72vh; }
#lb-img { max-width: 100%; max-height: 72vh; border-radius: 8px; }
#lb-meta { color: #fff; display: flex; gap: 12px; align-items: baseline; }
#lb-cap { font-weight: 600; }
#lb-del { margin: 0; width: 200px; }
.trash-list { margin: 4px 0 10px; }
.trash-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 0.5px solid var(--hairline);
}
.trash-row:last-child { border-bottom: none; }
.trash-ic { width: 22px; height: 22px; color: var(--muted); flex: 0 0 auto; }
.trash-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.trash-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-sub { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-row form { margin: 0; flex: 0 0 auto; }
.tag-bar { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 2px; }
.tag-chip {
  flex: 0 0 auto;
  padding: 5px 12px;
  border-radius: 14px;
  background: var(--card);
  color: var(--muted);
  font-size: 14px;
  border: 0.5px solid var(--hairline);
}
.tag-chip.on { color: var(--accent); border-color: var(--accent); }
.tile-wrap { display: flex; align-items: center; gap: 10px; padding: 14px; }
.tile { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; text-decoration: none; color: inherit; }
.tile-merchant { font-weight: 600; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-balance { font-size: 24px; font-weight: 700; color: var(--accent); }
.tile-sub { font-size: 13px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.mini-tag { background: var(--hairline); border-radius: 8px; padding: 1px 7px; font-size: 12px; }
.tile-copy { flex: 0 0 auto; }
.draft-tile { display: flex; flex-direction: column; gap: 3px; text-decoration: none; color: inherit; border: 1px dashed var(--muted); }
.h2-like { font-size: 20px; font-weight: 700; padding: 6px 0; }
.notice { color: var(--accent); font-weight: 600; padding: 4px 2px; }
.balance-card { display: flex; flex-direction: column; gap: 2px; }
.balance-label { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.balance-big { font-size: 40px; font-weight: 800; color: var(--accent); line-height: 1.1; }
.secret-row { display: flex; align-items: center; gap: 10px; }
.secret { flex: 1; min-width: 0; font-family: ui-monospace, monospace; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spend-card .row input[name="amount"] { flex: 1; min-width: 0; }
.spend-card .row button { flex: 0 0 130px; }
.spend-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.spend-line .inline-del { margin-left: auto; }
.file-admin { border-top: 0.5px solid var(--hairline); margin-top: 10px; padding-top: 6px; }
.file-admin-row { align-items: center; justify-content: space-between; padding: 6px 0; }
.file-admin-row form { margin: 0; }
.file-mini img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; display: block; }
.file-mini { color: var(--muted); font-weight: 700; font-size: 12px; text-decoration: none; }
.inline-del { display: inline; margin: 0 0 0 6px; }
.inline-del button { padding: 0 6px; width: auto; }
.pdf-thumb { width: 84px; height: 84px; border-radius: 10px; background: var(--hairline); display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--muted); }
.attach-block { padding: 6px 0; }
.pending-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 0.5px solid var(--hairline); }
.pending-row:last-child { border-bottom: none; }
.pending-txt { flex: 1 1 100%; }
.pending-actions { flex: 1; }
.pending-actions select { flex: 1; min-width: 0; }
.pending-row form { margin: 0; }
.danger-text { color: var(--danger); }
.seg-bar { margin-top: 8px; gap: 6px; }
.seg { flex: 1; padding: 7px 0; border-radius: 10px; background: var(--card); color: var(--muted); font-weight: 600; border: 0.5px solid var(--hairline); }
.seg.on { color: var(--accent); border-color: var(--accent); }
#pay-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.95); z-index: 40; display: flex; align-items: center; justify-content: center; padding: 16px; }
#pay-overlay[hidden] { display: none; }
#pay-img { max-width: 100%; max-height: 86vh; border-radius: 8px; background: #fff; }
.pending-amt { flex: 0 0 76px; min-width: 0; }
#receipt-prompt[hidden] { display: none; }
.pending-head { display: flex; flex-direction: column; gap: 2px; width: 100%; }
.pending-head a { color: var(--accent); }
.pending-actions:empty { display: none; }
.pending-btns { width: 100%; }
.pending-btns button { flex: 1; }
.pending-btns .reject-form { flex: 1; display: flex; margin: 0; }
.spend-line .inline-del { margin-left: auto; flex: 0 0 auto; }
.spend-line { flex-wrap: nowrap; }
.spend-line > .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-chip { width: auto; }
.edit-summary {
  text-align: center;
  font-weight: 600;
  color: var(--accent);
  list-style: none;
}
.edit-summary::-webkit-details-marker { display: none; }
.edit-summary .edit-ic { color: var(--accent); }
.edit-upload { margin: 10px 0 4px; }
.step-btn {
  display: block;
  width: 100%;
  text-align: center;
  padding: 15px 12px;
  border-radius: var(--radius);
  font-size: 17px;
  font-weight: 600;
  margin: 8px 0;
  border: none;
}
.step-primary { background: var(--accent); color: #fff; }
.step-secondary {
  background: color-mix(in srgb, var(--accent) 16%, var(--card));
  color: var(--accent);
}
#receipt-prompt { margin: 0; }
.step-btn.busy { opacity: .7; pointer-events: none; }
.step-tertiary {
  background: var(--card);
  color: var(--accent);
  border: 1px solid var(--accent);
}
.summary-hidden { display: none; }
#edit-block { margin-top: 10px; }
.thumb-tag {
  position: absolute;
  bottom: 4px;
  left: 4px;
  background: rgba(20,20,20,.65);
  color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 7px;
}
#lightbox {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 40;
  display: flex;
  flex-direction: column;
  padding: 0;
}
#lightbox[hidden] { display: none; }
#lb-stage { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; padding: 56px 12px 8px; }
#lb-img { max-width: 100%; max-height: 100%; border-radius: 8px; background: #fff; object-fit: contain; }
#lb-meta {
  flex: 0 0 auto;
  color: #fff;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  padding: 10px 16px calc(14px + env(safe-area-inset-bottom));
  width: 100%;
}
#lb-cap { font-weight: 600; }
#lb-pdf { color: #fff; width: auto; }
header .tool-btn { margin-left: auto; }
#lb-del { margin: 0; } #lb-del[hidden] { display: none; }
.lb-arch {
  width: auto;
  padding: 8px 14px;
  background: color-mix(in srgb, var(--accent) 16%, var(--card));
  color: var(--accent);
  font-weight: 600;
}
.receipt-filter input { margin-bottom: 8px; }
.arch-toggle { display: flex; align-items: center; gap: 8px; padding: 4px 0 10px; color: var(--muted); }
.arch-toggle input { width: auto; margin: 0; }
.receipt-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 0.5px solid var(--hairline); }
.receipt-row:last-child { border-bottom: none; }
.rc-thumb { flex: 0 0 auto; }
.rc-thumb img { width: 56px; height: 56px; }
.receipt-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.receipt-merchant { font-weight: 600; color: inherit; text-decoration: none; }
.field-label { display: block; font-size: 13px; color: var(--muted); margin: 2px 2px 4px; }
.dm-bar { margin: 0 0 8px; }
.dm-bar .seg { cursor: pointer; text-align: center; }
.dm-bar .seg input { display: none; }
.rc-thumb { width: auto; padding: 0; background: none; border: none; }
.receipt-info { flex: 1; }
.arch-toggle input[type="checkbox"] { flex: 0 0 auto; width: 20px; height: 20px; }
