:root {
  --bg: #0f1115; --card: #181b22; --card2: #20242d; --line: #2c313c;
  --text: #eceff4; --muted: #9aa3b2; --accent: #38bd94; --accent-ink: #06231a;
  --ok: #3ecf8e; --near: #f5b942; --over: #ef5b5b; --low: #ff9a3c;
  --tabs-h: 58px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
main { max-width: 640px; margin: 0 auto; padding: 14px 14px calc(var(--tabs-h) + 28px + env(safe-area-inset-bottom)); }
h1 { font-size: 1.25rem; margin: 4px 0 12px; }
h2 { font-size: .85rem; margin: 18px 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.right { text-align: right; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* tabs */
#tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; background: #12151b;
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
#tabs button { flex: 1; height: var(--tabs-h); background: none; border: 0; color: var(--muted);
  font: inherit; font-size: .72rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
#tabs button .ic { font-size: 1.3rem; line-height: 1; }
#tabs button.active { color: var(--accent); }

/* forms */
label.f { display: block; margin: 10px 0 4px; font-size: .82rem; color: var(--muted); }
input, select, textarea { width: 100%; background: var(--card2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 12px; font: inherit; min-height: 44px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input.guess { border-color: var(--near); box-shadow: 0 0 0 1px var(--near); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--card2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--over); border-color: #5b2b2b; }
.btn.block { display: flex; width: 100%; margin-top: 10px; }
.btn:disabled { opacity: .5; }
.icon-btn { background: none; border: 0; color: var(--muted); font-size: 1.2rem; min-width: 44px; min-height: 44px; cursor: pointer; }
.icon-btn.del { color: var(--over); }

/* add */
.camera-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 170px; border: 2px dashed var(--accent); border-radius: 18px; color: var(--accent); font-size: 1.1rem; font-weight: 700;
  background: rgba(56, 189, 148, .06); cursor: pointer; }
.camera-btn .big { font-size: 3rem; line-height: 1; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.thumb { position: relative; width: 84px; height: 112px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button { position: absolute; top: 2px; right: 2px; width: 36px; height: 36px; border-radius: 50%; border: 0;
  background: rgba(0, 0, 0, .65); color: #fff; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.9s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.busy { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 26px; font-weight: 600; }

/* review */
.sumbar { position: sticky; top: 0; z-index: 10; margin: -14px -14px 12px; padding: 12px 14px; font-weight: 700; }
.sumbar.ok { background: #123d2c; color: var(--ok); border-bottom: 1px solid var(--ok); }
.sumbar.bad { background: #43191a; color: #ff9494; border-bottom: 1px solid var(--over); }
.item { display: grid; grid-template-columns: 1fr auto auto; gap: 6px 8px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item input.name { grid-column: 1 / 3; }
.item input.val { width: 96px; text-align: right; }
.item .meta { grid-column: 1 / 3; display: flex; gap: 8px; align-items: center; }
.chip { border: 1px solid var(--line); background: var(--card2); color: var(--text); border-radius: 999px; padding: 5px 12px;
  font: inherit; font-size: .85rem; min-height: 32px; cursor: pointer; }
.chip.low { border-color: var(--low); color: var(--low); border-width: 2px; }
.chip.static { cursor: default; color: var(--muted); }
.carousel img { width: 100%; max-height: 26vh; object-fit: contain; border-radius: 10px; background: #000; }
.carousel .nav { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }

.item.withdisc .net { grid-column: 3; font-weight: 700; text-align: right; }
.item.withdisc .sub { grid-column: 1 / 3; margin-top: -2px; }
.item .fields { grid-column: 1 / 3; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.item .fields input { text-align: right; width: 100%; }
.item .fields label { display: block; }
.linkbtn { background: none; border: 0; color: var(--accent); font: inherit; font-size: .85rem; min-height: 32px; padding: 0 4px; cursor: pointer; }

/* month */
.big-total { font-size: 2.6rem; font-weight: 800; letter-spacing: -.02em; margin: 6px 0; }
.monthnav { display: flex; align-items: center; justify-content: space-between; }
.monthnav .label { font-weight: 700; text-transform: capitalize; }
.bar-row { margin: 10px 0; }
.bar-top { display: flex; justify-content: space-between; font-size: .9rem; margin-bottom: 4px; }
.bar { height: 10px; background: var(--card2); border-radius: 6px; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 6px; background: var(--ok); }
.bar.near > span { background: var(--near); }
.bar.over > span { background: var(--over); }
.bar.nolimit > span { background: #5c6676; }
.st-ok { color: var(--ok); } .st-near { color: var(--near); } .st-over { color: var(--over); }

.bar-btn { display: block; width: 100%; background: none; border: 0; padding: 4px 0; margin: 6px 0; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.bar-btn > .bar, .bar-btn > .bar-top { display: block; }
.bar-btn > .bar-top { display: flex; }
.bar-btn .chev { display: inline-block; color: var(--muted); transition: transform .15s; width: 1em; }
.bar-btn[aria-expanded="true"] .chev { transform: rotate(90deg); }
.cat-items { margin: 2px 0 10px; border-left: 2px solid var(--line); padding-left: 10px; }
.prod-row { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line);
  color: inherit; font: inherit; text-align: left; padding: 9px 0; min-height: 44px; cursor: pointer; }
.prod-row:last-child { border-bottom: 0; }
.prod-row .pname, .prod-row .pmeta { display: block; overflow-wrap: anywhere; }

/* lists */
.list-item { display: flex; align-items: center; gap: 10px; padding: 12px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; margin-bottom: 8px; cursor: pointer; width: 100%; color: inherit; font: inherit; text-align: left; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.filters .wide { grid-column: 1 / 3; }
svg.chart { width: 100%; height: auto; display: block; }
svg.chart text { fill: var(--muted); font-size: 11px; }
svg.chart .val { fill: var(--text); font-size: 10px; }

/* modal + toast */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .65); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); border-radius: 18px 18px 0 0; width: 100%; max-width: 640px; max-height: 80vh; overflow: auto;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); border: 1px solid var(--line); }
.sheet .actions { display: flex; gap: 8px; margin-top: 14px; }
.sheet .actions .btn { flex: 1; }
.sheet .opt { display: block; width: 100%; text-align: left; padding: 13px 8px; background: none; border: 0; border-bottom: 1px solid var(--line);
  color: var(--text); font: inherit; }
.sheet .opt.sel { color: var(--accent); font-weight: 700; }
#toast { position: fixed; left: 14px; right: 14px; bottom: calc(var(--tabs-h) + 14px + env(safe-area-inset-bottom)); z-index: 60;
  background: #2a1d1d; border: 1px solid var(--over); color: #ffc9c9; padding: 12px 14px; border-radius: 12px; text-align: center; }
#toast.good { background: #123d2c; border-color: var(--ok); color: #bff3da; }
.login { max-width: 360px; margin: 18vh auto 0; }
