:root {
  --bg: #F4F6F1;
  --card: #FFFFFF;
  --ink: #15231B;
  --muted: #5B6B61;
  --line: #E2E8E3;
  --line-strong: #D5DDD7;
  --green: #1E7A4C;
  --green-dark: #15603B;
  --green-soft: #E3F1E8;
  --orange: #B4590F;
  --orange-soft: #FCEEDD;
  --radius: 14px;
  --tabbar: 68px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body { margin: 0; background: var(--bg); color: var(--ink); }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  font-size: 16px;
  line-height: 1.35;
  min-height: 100vh;
}

button, input { font: inherit; color: inherit; }

main {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(16px + var(--safe-top)) 16px calc(var(--tabbar) + var(--safe-bottom) + 96px);
}

h1 { margin: 2px 0 0; font-size: 26px; font-weight: 750; letter-spacing: -0.01em; }
h2 { margin: 0; font-size: 18px; }

.brand { font-weight: 800; font-size: 19px; color: var(--green); }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 13px; }
.label { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; color: var(--muted); text-transform: uppercase; margin: 18px 2px 8px; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.header-block { margin: 12px 0 14px; }
.header-block button.linklike { background: none; border: none; padding: 0; text-align: left; cursor: pointer; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}

.total-card { display: flex; flex-direction: column; gap: 8px; }
.total-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.big { font-size: 32px; font-weight: 800; letter-spacing: -0.02em; }
.bar { height: 8px; border-radius: 4px; background: var(--green-soft); overflow: hidden; }
.bar > div { height: 100%; background: var(--green); border-radius: 4px; transition: width .25s; }
.bar.over > div { background: var(--orange); }
.ok-text { color: var(--green); font-weight: 650; font-size: 14px; }
.warn-text { color: var(--orange); font-weight: 650; font-size: 14px; }

.add-row { display: flex; gap: 8px; margin: 14px 0 6px; }
.add-row input[type=text] { flex: 1; min-width: 0; }

.input {
  height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 0 14px;
  background: var(--card);
  outline: none;
}
.input:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }

.btn {
  height: 48px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--card);
  padding: 0 16px;
  font-weight: 650;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:active { background: var(--green-dark); }
.btn.danger { color: var(--orange); }
.btn.block { width: 100%; }
.btn.tall { height: 56px; border-radius: 16px; font-size: 16px; }
.btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 22px;
  border: 1px solid var(--line-strong); background: var(--card);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none;
}
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.suggestions { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 4px; }
.chip {
  border: 1px solid var(--line-strong); background: var(--card); border-radius: 999px;
  padding: 6px 12px; font-size: 14px; cursor: pointer; min-height: 36px;
}

.counts { display: flex; justify-content: space-between; margin: 14px 2px 8px; }

.items { display: flex; flex-direction: column; gap: 8px; }
.item {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  display: flex; align-items: center; gap: 4px; padding: 4px 10px 4px 4px; min-height: 60px;
}
.item.done .item-name { color: var(--muted); }
.check {
  width: 48px; height: 48px; border: none; background: none; cursor: pointer; flex: none;
  display: flex; align-items: center; justify-content: center;
}
.check .ring { width: 26px; height: 26px; border-radius: 13px; border: 2px solid #B8C4BC; display: flex; align-items: center; justify-content: center; }
.item.done .check .ring { background: var(--green); border-color: var(--green); }
.check svg { width: 14px; height: 14px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.item-body { flex: 1; min-width: 0; background: none; border: none; text-align: left; padding: 8px 4px; cursor: pointer; display: flex; align-items: center; gap: 10px; }
.item-text { flex: 1; min-width: 0; }
.item-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; }
.item-detail { font-size: 12px; color: var(--muted); }
.item-price { font-weight: 700; white-space: nowrap; }
.thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; flex: none; background: var(--bg); }
.tag-promo { display: inline-block; font-size: 11px; font-weight: 700; color: var(--orange); background: var(--orange-soft); border-radius: 6px; padding: 1px 6px; margin-left: 6px; vertical-align: 1px; }

.empty { text-align: center; padding: 28px 16px; color: var(--muted); }
.empty b { color: var(--ink); display: block; font-size: 17px; margin-bottom: 4px; }

.finish { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  height: calc(var(--tabbar) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--card); border-top: 1px solid var(--line);
  display: flex; justify-content: space-around; align-items: stretch;
}
.tab {
  flex: 1; max-width: 140px; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 12px; color: var(--muted);
}
.tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tab.active { color: var(--green); font-weight: 700; }

.backdrop { position: fixed; inset: 0; background: rgba(16, 24, 20, 0.45); z-index: 20; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  max-width: 560px; margin: 0 auto;
  max-height: 92vh; overflow-y: auto;
  background: var(--card); border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(20px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 14px;
}
.sheet .grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 0 auto 2px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 600; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper .input { text-align: center; width: 72px; flex: none; padding: 0 6px; }
.stepper .icon-btn { width: 48px; height: 48px; border-radius: 12px; font-size: 22px; font-weight: 700; }
.photo-big { width: 100%; max-height: 260px; object-fit: contain; border-radius: 12px; background: var(--bg); }
.switch-row { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.switch-row input { width: 22px; height: 22px; accent-color: var(--green); }
.sub-total { font-size: 14px; color: var(--muted); }

.hist-month { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.hist-month .card { padding: 14px; }
.hist-item { display: flex; flex-direction: column; gap: 6px; }
.hist-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: none; border: none; padding: 0; width: 100%; text-align: left; cursor: pointer; }
.hist-lines { display: flex; flex-direction: column; gap: 4px; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; font-size: 14px; }
.hist-line { display: flex; justify-content: space-between; gap: 8px; }
.hist-actions { display: flex; gap: 8px; margin-top: 6px; }
.hist-actions .btn { flex: 1; height: 42px; font-size: 14px; }

.soon { text-align: center; padding: 32px 20px; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.soon .badge { width: 72px; height: 72px; border-radius: 36px; background: var(--green-soft); display: flex; align-items: center; justify-content: center; }
.soon .badge svg { width: 34px; height: 34px; fill: none; stroke: var(--green); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar) + var(--safe-bottom) + 86px); z-index: 30;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px;
  max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.18);
}

.snap-bar {
  position: fixed; left: 0; right: 0; z-index: 9;
  bottom: calc(var(--tabbar) + var(--safe-bottom));
  max-width: 560px; margin: 0 auto;
  padding: 10px 16px 12px;
  background: linear-gradient(rgba(244,246,241,0), var(--bg) 30%);
}
.ac-list {
  background: var(--card); border: 1px solid var(--line-strong); border-radius: 12px;
  margin: -2px 0 8px; overflow: hidden; box-shadow: 0 8px 24px rgba(21,35,27,.08);
}
.ac-item {
  width: 100%; min-height: 48px; padding: 10px 14px; border: none; background: none;
  border-bottom: 1px solid var(--line); text-align: left; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 16px;
}
.ac-item:last-child { border-bottom: none; }
.ac-item:active { background: var(--green-soft); }
.ac-tag { font-size: 11px; font-weight: 700; color: var(--green); background: var(--green-soft); border-radius: 6px; padding: 2px 6px; white-space: nowrap; }
.chip-on { background: var(--green); border-color: var(--green); color: #fff; }

.install-tip { margin-top: 18px; font-size: 13px; color: var(--muted); text-align: center; }
