:root {
  --green: #3d583c;
  --green-dark: #2b3f2a;
  --green-soft: #f3f6f2;
  --green-line: #dfe6de;
  --hair: #eef2ed;
  --ink: #1f2a1f;
  --muted: #5c6b5c;
  --amber: #b5701f;
  --amber-soft: #fbf3e8;
  --red: #a33a2c;
  --red-soft: #fbeeec;
  --bg: #ffffff;
  --radius: 14px;
  --pad: 20px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: Raleway, system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.45;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--green); }

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}

/* Header */
.top {
  display: flex; align-items: center; gap: 12px;
  padding: calc(16px + env(safe-area-inset-top)) var(--pad) 8px;
}
.top h1 { font-size: 20px; font-weight: 600; margin: 0; flex: 1; }
.top .sub { font-size: 13px; color: var(--muted); }
.icon-btn {
  width: 44px; height: 44px; border-radius: 22px; border: 0;
  background: var(--green-soft); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.icon-btn svg { width: 20px; height: 20px; }

.body { flex: 1; padding: 8px var(--pad) 24px; display: flex; flex-direction: column; gap: 14px; }
.foot {
  position: sticky; bottom: 0; background: var(--bg);
  border-top: 1px solid var(--hair);
  padding: 12px var(--pad) calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px;
}

.hello { font-size: 26px; font-weight: 500; color: var(--green); margin: 4px 0 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.label {
  font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
  margin: 10px 0 0;
}

/* Buttons */
.btn {
  border: 0; border-radius: 12px; padding: 15px 18px; font-size: 15px; font-weight: 500;
  background: var(--green); color: #fff; width: 100%;
}
.btn:active { background: var(--green-dark); }
.btn[disabled] { opacity: 0.5; cursor: default; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--green-line); font-weight: 400; }
.btn.ghost:active { background: var(--green-soft); }
.btn.small { padding: 10px 12px; font-size: 13px; width: auto; }
.btn.line { background: #fff; color: var(--green); border: 1px solid var(--green); font-weight: 400; }
.link-btn { background: none; border: 0; padding: 0; color: var(--green); text-decoration: underline; font-size: 14px; }

/* Tiles */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile {
  border: 1px solid var(--green-line); border-radius: 16px; padding: 16px; background: #fff;
  text-align: left; display: flex; flex-direction: column; gap: 18px; min-height: 112px;
}
.tile.main { grid-column: 1 / -1; border-color: var(--green); }
.tile .t { font-size: 16px; font-weight: 600; }
.tile .s { font-size: 13px; color: var(--muted); }
.tile[disabled] { opacity: 0.55; cursor: default; }
.tile .ic {
  width: 36px; height: 36px; border-radius: 10px; background: var(--green-soft); color: var(--green);
  display: flex; align-items: center; justify-content: center;
}
.tile .ic svg { width: 20px; height: 20px; }

/* Cards */
.card { border: 1px solid var(--green-line); border-radius: var(--radius); padding: 14px 16px; background: #fff; }
.card.soft { background: var(--green-soft); border-color: transparent; }
.card.warn { background: var(--amber-soft); border-color: transparent; }
.card.bad { background: var(--red-soft); border-color: transparent; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 4px; }

/* Upload */
.drop {
  height: 210px; border: 1.5px dashed #9fb09e; border-radius: 18px; background: #f7f9f6;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  color: var(--green); width: 100%;
}
.drop svg { width: 40px; height: 40px; }
.drop .t { font-size: 16px; font-weight: 600; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumb {
  width: 72px; height: 72px; border-radius: 10px; border: 1px solid var(--green-line); overflow: hidden;
  position: relative; background: var(--green-soft); display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--muted);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb button {
  position: absolute; top: 2px; right: 2px; width: 24px; height: 24px; border-radius: 12px; border: 0;
  background: rgba(255,255,255,0.92); font-size: 14px; line-height: 1;
}
textarea, input[type=text], input[type=password], input[type=number], input[type=search], select {
  border: 1px solid var(--green-line); border-radius: 12px; padding: 12px 14px; font-size: 16px; width: 100%;
  background: #fff;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--green); outline-offset: 0; border-color: var(--green); }

/* Reading */
.spinner {
  width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--green-soft); border-top-color: var(--green);
  animation: spin 0.9s linear infinite; margin: 30px auto 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.center { text-align: center; }
.bar { height: 6px; border-radius: 3px; background: var(--green-soft); overflow: hidden; }
.bar > div { height: 100%; background: var(--green); width: 0; transition: width 0.3s; }

/* Review lines */
.line {
  border: 1px solid var(--green-line); border-radius: var(--radius); padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px; background: #fff;
}
.line.check { border-color: var(--amber); }
.line.none { border-color: var(--red); }
.line.skip { opacity: 0.5; }
.line.done { border-color: var(--green); background: var(--green-soft); }
.line .inv { font-size: 12px; color: var(--muted); }
.line .prod { font-size: 15px; font-weight: 500; }
.line .prod.missing { color: var(--red); font-weight: 400; }
.pill {
  display: inline-block; font-size: 11px; letter-spacing: 0.04em; padding: 3px 8px; border-radius: 999px;
  background: var(--green-soft); color: var(--green); white-space: nowrap;
}
.pill.check { background: var(--amber-soft); color: var(--amber); }
.pill.none { background: var(--red-soft); color: var(--red); }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field label { font-size: 11px; color: var(--muted); }
.field input { padding: 9px 10px; font-size: 16px; }
.costnote { font-size: 12px; color: var(--muted); }
.costnote.up { color: var(--amber); }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); }
.check-row input { width: 20px; height: 20px; accent-color: var(--green); }
.line-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Sheet */
.sheet-back {
  position: fixed; inset: 0; background: rgba(20, 30, 20, 0.35); z-index: 20;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: #fff; width: 100%; max-width: 560px; max-height: 92dvh; border-radius: 20px 20px 0 0;
  display: flex; flex-direction: column; overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet-head { padding: 16px var(--pad) 10px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--hair); }
.sheet-head h2 { margin: 0; font-size: 17px; font-weight: 600; flex: 1; }
.sheet-body { padding: 12px var(--pad) 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.result {
  border: 0; border-bottom: 1px solid var(--hair); background: none; text-align: left; padding: 12px 2px;
  display: flex; justify-content: space-between; gap: 10px; width: 100%;
}
.result .n { font-size: 15px; }
.result .m { font-size: 12px; color: var(--muted); white-space: nowrap; text-align: right; }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 14px; z-index: 40;
  max-width: calc(100% - 32px);
}

.tick {
  width: 72px; height: 72px; border-radius: 36px; background: var(--green-soft); color: var(--green);
  display: flex; align-items: center; justify-content: center; margin: 30px auto 4px;
}
.tick svg { width: 34px; height: 34px; }
.recent { display: flex; flex-direction: column; }
.recent .r { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--hair); font-size: 14px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Home ---------- */
:root { --stock: #3d583c; --stock-soft: #edf2ec; --fulfil: #a85d36; --fulfil-soft: #f8eee8; --tools: #3f6680; --tools-soft: #eaf1f6; }
.hero {
  background: var(--green); color: #fff; border-radius: 0 0 28px 28px;
  padding: calc(14px + env(safe-area-inset-top)) var(--pad) 22px;
  background-image: radial-gradient(120% 90% at 100% 0%, rgba(255,255,255,.10), transparent 60%);
}
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; }
.hero-logo { height: 96px; width: auto; display: block; margin-left: -4px; }
.hero-gear { width: 44px; height: 44px; border-radius: 22px; border: 0; background: rgba(255,255,255,.14); color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.hero-gear svg { width: 20px; height: 20px; }
.hero-hello { font-size: 26px; font-weight: 500; margin: 14px 0 0; }
.hero-date { font-size: 14px; opacity: .8; margin: 2px 0 0; }
.body.home { gap: 8px; padding-top: 18px; }
.sec { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.sec-h { display: flex; align-items: center; gap: 8px; margin: 4px 0 0; font-size: 15px; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; color: var(--c); }
.sec-h .dot { width: 8px; height: 8px; border-radius: 4px; background: var(--c); }
.sec.stock { --c: var(--stock); --soft: var(--stock-soft); }
.sec.fulfil { --c: var(--fulfil); --soft: var(--fulfil-soft); }
.sec.tools { --c: var(--tools); --soft: var(--tools-soft); }
.home .tile { text-decoration: none; color: inherit; border-color: var(--hair); box-shadow: 0 1px 2px rgba(20,40,20,.04), 0 4px 14px rgba(20,40,20,.05); position: relative; transition: transform .12s; }
.home .tile:active { transform: scale(.98); }
.home .tile .ic { background: var(--soft); color: var(--c); width: 40px; height: 40px; border-radius: 12px; }
.home .tile .ic svg { width: 22px; height: 22px; }
.home .tile .go { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: var(--c); opacity: .7; }
.home .tile .go svg { width: 20px; height: 20px; display: block; }
.home .tile.wide { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 14px; min-height: 0; padding-right: 44px; }
.home .tile.main { background: var(--c); border: 0; color: #fff; flex-direction: row; align-items: center; gap: 14px; min-height: 0; padding: 20px 44px 20px 18px; }
.home .tile.main .ic { background: rgba(255,255,255,.16); color: #fff; width: 48px; height: 48px; border-radius: 14px; }
.home .tile.main .t { font-size: 19px; }
.home .tile.main .s { color: rgba(255,255,255,.85); }
.home .tile.main .go { color: #fff; }
.home .tile.locked .ic { background: #f1f2f1; color: var(--muted); }
.home .tile.locked .t { color: var(--muted); }
.slims { display: flex; flex-direction: column; gap: 8px; }
.home .tile.slim { flex-direction: row; align-items: center; gap: 12px; min-height: 0; padding: 12px 44px 12px 12px; }
.home .tile.slim .ic { width: 36px; height: 36px; border-radius: 10px; }
.home .tile.slim .t { font-size: 15px; }
.home .tile .t { font-weight: 500; }
:root { --todo: #8a6420; --todo-soft: #f6efe0; }
.sec.todo { --c: var(--todo); --soft: var(--todo-soft); }
.home .tile.wide .t { font-size: 17px; }
.home .tiles { grid-template-columns: 1fr; gap: 8px; }
.home .tile.wide { padding: 14px 44px 14px 14px; gap: 14px; }
.home .tile.wide .t { font-size: 16px; }
.home .tile .ic, .home .tile.slim .ic { width: 40px; height: 40px; border-radius: 12px; flex: none; }
.hero .hero-date { margin-top: 12px; font-size: 15px; opacity: .85; }
