:root {
  --bg: #f6f5f2; --card: #fff; --ink: #1c1c1c; --muted: #6b6b6b; --line: #e4e2dd;
  --accent: #0f766e; --accent-soft: #e0f2ef; --warn: #b45309; --warn-soft: #fef3c7;
  --bad: #b91c1c; --bad-soft: #fee2e2; --good: #15803d;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121212; --card: #1e1e1e; --ink: #ececec; --muted: #9a9a9a; --line: #2e2e2e;
    --accent: #2dd4bf; --accent-soft: #123b37; --warn: #fbbf24; --warn-soft: #3a2e0c;
    --bad: #f87171; --bad-soft: #3b1515; --good: #4ade80; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
header { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: var(--bg); border-bottom: 1px solid var(--line); }
header h1 { font-size: 20px; margin: 0; }
main { padding: 12px 12px calc(90px + env(safe-area-inset-bottom)); max-width: 760px; margin: 0 auto; }
nav#tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
nav#tabs a { flex: 1; text-align: center; padding: 8px 0 6px; font-size: 11px; color: var(--muted); text-decoration: none; }
nav#tabs a span { display: block; font-size: 20px; line-height: 1.2; }
nav#tabs a.on { color: var(--accent); font-weight: 600; }
nav#tabs a.add span { color: #fff; background: var(--accent); border-radius: 50%; width: 30px; height: 30px; line-height: 30px; margin: 0 auto 1px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card h2 { font-size: 16px; margin: 0 0 10px; display: flex; justify-content: space-between; align-items: center; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
@media (min-width: 560px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.tile .v { font-size: 22px; font-weight: 700; }
.tile .l { font-size: 12px; color: var(--muted); }
.row { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); color: inherit; text-decoration: none; }
.row:first-of-type { border-top: 0; }
.row img, .thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; background: var(--line); flex: none; }
.thumb { display: flex; align-items: center; justify-content: center; font-size: 22px; }
.row .main { flex: 1; min-width: 0; }
.row .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s { font-size: 13px; color: var(--muted); }
.row .right { text-align: right; flex: none; }
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.grey { background: var(--line); color: var(--muted); }
button, .btn { font: inherit; border: 0; border-radius: 11px; padding: 11px 16px; background: var(--accent); color: #fff;
  font-weight: 600; cursor: pointer; text-decoration: none; display: inline-block; text-align: center; }
button.sec, .btn.sec { background: var(--accent-soft); color: var(--accent); }
button.ghost { background: transparent; color: var(--accent); padding: 6px 8px; }
button.danger { background: var(--bad-soft); color: var(--bad); }
button.small, .btn.small { padding: 6px 12px; font-size: 14px; }
button:disabled { opacity: .5; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
.btns.full > * { flex: 1; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea { font: inherit; font-size: 16px; width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--bg); color: var(--ink); }
textarea { min-height: 120px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 10px; }
.photos { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.photo { position: relative; flex: none; }
.photo img { width: 96px; height: 120px; object-fit: cover; border-radius: 10px; display: block; }
.photo .x { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.6); color: #fff; border-radius: 50%;
  width: 24px; height: 24px; padding: 0; font-size: 14px; line-height: 24px; }
.photo .l { position: absolute; bottom: 4px; left: 4px; background: rgba(0,0,0,.6); color: #fff; border-radius: 8px;
  padding: 2px 6px; font-size: 12px; }
.addphoto { width: 96px; height: 120px; flex: none; border: 2px dashed var(--line); border-radius: 10px; display: flex;
  flex-direction: column; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; cursor: pointer; }
.addphoto b { font-size: 28px; }
.chips { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 10px; }
.chip { flex: none; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); font-size: 14px; color: var(--ink); }
.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.copybox { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; white-space: pre-wrap; margin: 4px 0 8px; font-size: 15px; }
.ai { background: var(--accent-soft); border-color: transparent; }
.ai ul { margin: 6px 0; padding-left: 20px; }
.steps { counter-reset: s; padding: 0; margin: 0; list-style: none; }
.steps li { counter-increment: s; display: flex; gap: 10px; align-items: center; padding: 6px 0; }
.steps li::before { content: counter(s); flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff;
  font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.steps li > :first-child { flex: 1; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: right; padding: 6px 4px; border-top: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 500; border-top: 0; }
#toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: #222; color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; transition: .2s; pointer-events: none;
  max-width: 90vw; z-index: 20; font-size: 15px; }
#toast.show { opacity: 1; transform: translateX(-50%); }
.selbar { position: fixed; left: 0; right: 0; bottom: calc(58px + env(safe-area-inset-bottom)); background: var(--card);
  border-top: 1px solid var(--line); padding: 10px 14px; z-index: 6; box-shadow: 0 -4px 16px rgba(0,0,0,.08); }
.check { width: 24px; height: 24px; flex: none; accent-color: var(--accent); }
.login { max-width: 360px; margin: 40px auto; }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: r .8s linear infinite; vertical-align: -3px; margin-right: 6px; }
@keyframes r { to { transform: rotate(360deg); } }
.profit { color: var(--good); font-weight: 700; }
.loss { color: var(--bad); font-weight: 700; }
.empty { text-align: center; color: var(--muted); padding: 20px 0; }
dialog { border: 0; border-radius: var(--radius); padding: 18px; width: min(92vw, 440px); background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(0,0,0,.4); }
a { color: var(--accent); }
.usd { font-size: 12px; color: var(--muted); font-weight: 400; }
.tile .usd { font-size: 13px; }
