:root {
  --teal: #0e7c86; --teal-dark: #095860; --teal-light: #e6f4f5;
  --sand: #f7f3ea; --coral: #e0693f; --ink: #1e2a2b; --muted: #6b7c7d;
  --border: #e3e8e8; --danger: #c14545;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
body {
  margin: 0; background: #fff; color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px));
}
.topbar {
  position: sticky; top: 0; z-index: 10; background: linear-gradient(135deg, var(--teal), var(--teal-dark));
  color: #fff; padding: calc(env(safe-area-inset-top, 0px) + 16px) 18px 14px;
}
.topbar .brand { font-weight: 700; font-size: 16px; display: block; }
.topbar .subtitle { font-size: 12.5px; opacity: .85; }
.topbar-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.topbar-row .back-link { color: #fff; opacity: .9; font-size: 12.5px; text-decoration: none; }
.topbar-row .back-link:hover { text-decoration: underline; }
.topbar-row .logout-link {
  background: rgba(255,255,255,.15); border: none; color: #fff; font-size: 12px; font-weight: 600;
  padding: 5px 10px; border-radius: 8px; cursor: pointer;
}
.wrap { max-width: 640px; margin: 0 auto; padding: 16px; }

.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.summary-grid .card { text-align: center; border: 1px solid var(--border); border-radius: 14px; padding: 14px; }
.summary-grid .label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.summary-grid .value { font-size: 20px; font-weight: 700; color: var(--teal-dark); }

.entry-card { border: 1px solid var(--border); border-radius: 14px; padding: 4px 14px; }
.entry {
  display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border);
}
.entry:last-child { border-bottom: none; }
.entry img.thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: var(--sand); border: 1px solid var(--border); }
.entry .thumb-icon { width: 44px; height: 44px; border-radius: 10px; background: var(--teal-light); color: var(--teal); display: flex; align-items: center; justify-content: center; font-size: 19px; }
.entry .info { flex: 1; min-width: 0; }
.entry .info .top-row { display: flex; justify-content: space-between; gap: 8px; }
.entry .info .name { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry .info .amt { font-weight: 700; font-size: 14.5px; color: var(--danger); white-space: nowrap; }
.entry .info .sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.entry button.del { border: none; background: none; color: var(--muted); font-size: 17px; padding: 4px 6px; cursor: pointer; }
.empty { text-align: center; color: var(--muted); font-size: 13.5px; padding: 26px 10px; }

.fab {
  position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  width: 56px; height: 56px; border-radius: 50%; background: var(--coral); color: #fff; border: none;
  font-size: 28px; box-shadow: 0 4px 14px rgba(0,0,0,.25); cursor: pointer; z-index: 20;
}

.sheet-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 30; display: none; align-items: flex-end; justify-content: center; }
.sheet-overlay.open { display: flex; }
.sheet { background: #fff; width: 100%; max-width: 640px; border-radius: 18px 18px 0 0; max-height: 90vh; overflow-y: auto; padding: 16px 16px calc(24px + env(safe-area-inset-bottom, 0px)); }
.sheet h2 { font-size: 16.5px; margin: 2px 0 14px; }
.sheet-close { float: right; border: none; background: var(--sand); border-radius: 50%; width: 30px; height: 30px; font-size: 15px; color: var(--muted); cursor: pointer; }

label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 12px 0 5px; }
label:first-of-type { margin-top: 0; }
input[type=text], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--border); font-size: 15px; font-family: inherit;
}
textarea { resize: vertical; }

.photo-row { display: flex; gap: 10px; align-items: center; }
.photo-preview { width: 68px; height: 68px; border-radius: 10px; object-fit: cover; border: 1px solid var(--border); background: var(--sand); flex-shrink: 0; display: none; }
.photo-btn { flex: 1; border: 1.5px dashed var(--teal); background: var(--teal-light); color: var(--teal-dark); border-radius: 10px; padding: 12px; font-size: 13.5px; font-weight: 600; cursor: pointer; }

.save-btn { width: 100%; margin-top: 16px; border: none; background: var(--coral); color: #fff; border-radius: 12px; padding: 13px; font-size: 15px; font-weight: 700; cursor: pointer; }
.save-btn:disabled { opacity: .6; }
.status { text-align: center; font-size: 13px; min-height: 18px; margin-top: 8px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + env(safe-area-inset-bottom, 0px));
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 20px; font-size: 13.5px; z-index: 50;
  opacity: 0; transition: opacity .25s; pointer-events: none; white-space: nowrap;
}
.toast.show { opacity: 1; }
