:root {
  --bg: #fbf7f3;
  --card: #ffffff;
  --ink: #3a2a1e;
  --muted: #8b7f77;
  --line: #efe4dc;
  --accent: #7b5230;
  --accent-soft: #f7e9e3;
  --gold: #c47c70;
  --gold-soft: #fbefea;
  --pos: #2f7a4f;
  --neg: #b4362f;
  --radius: 14px;
  --serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --tabs-h: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: var(--sans); font-size: 15px; color: var(--ink); background: var(--bg);
  min-height: 100vh; padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 12px);
}
body.no-scroll { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.pad { padding: 12px 14px; margin: 0; }
em { font-style: normal; color: var(--muted); font-weight: 400; }

/* boot */
.boot { display: grid; place-items: center; height: 100vh; }
.boot img { width: 200px; height: auto; }
.wordmark { height: 34px; width: auto; display: block; }
.brand-logo { width: 240px; max-width: 70%; height: auto; margin: 0 auto; }

/* header */
.demo-bar { background: var(--gold-soft); color: #7d5d24; font-size: 12px; text-align: center; padding: 6px; }
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 6px;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px; background: rgba(251, 247, 243, .92);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.top h1 { flex: 1; margin: 0; font-family: var(--serif); font-size: 26px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#actions { display: flex; gap: 4px; }
.icon-btn {
  display: inline-grid; place-items: center; min-width: 38px; height: 38px; border-radius: 50%;
  border: 0; background: transparent; font-size: 20px; padding: 0 6px;
}
.icon-btn:active { background: var(--line); }
.icon-btn.small { min-width: 30px; height: 30px; font-size: 14px; color: var(--muted); }
#back { font-size: 32px; line-height: 1; margin-left: -8px; }

main { max-width: 680px; margin: 0 auto; padding: 14px; }

/* tabs */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; justify-content: space-around;
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
}
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: 11px; }
.tabs a i { font-style: normal; font-size: 20px; line-height: 1.1; }
.tabs a.active { color: var(--accent); font-weight: 600; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-weight: 500; font-size: 14px;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--neg); }
.btn.block { display: flex; width: 100%; margin-top: 12px; }
.btn.big { padding: 14px; font-size: 16px; }
.btn.small { padding: 5px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.btn-row .btn { flex: 1; }
.link { border: 0; background: none; color: var(--accent); padding: 2px 0; font-weight: 500; }
.fab-row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* cards & lists */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.stack > * + * { margin-top: 0; }
.sec { font-family: var(--serif); font-size: 21px; font-weight: 700; margin: 22px 2px 8px; }
.sec.split { display: flex; justify-content: space-between; align-items: center; }
.sec.split .muted { font-family: var(--sans); font-size: 14px; font-weight: 500; }
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list.flat { border: 0; border-radius: 0; margin: 0 -4px; }
.item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 14px; text-align: left;
  border: 0; background: none; border-bottom: 1px solid var(--line);
}
.item:last-child { border-bottom: 0; }
a.item:active, button.item:active { background: var(--bg); }
.item .grow, .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.item b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; text-align: right; white-space: nowrap; }
.item > i { font-style: normal; font-size: 22px; width: 28px; text-align: center; }
.plain { border: 0; background: none; text-align: left; padding: 0; }
.amt { font-weight: 600; white-space: nowrap; }
.thumb { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; flex-shrink: 0; background: var(--gold-soft); }
.thumb.ph { display: grid; place-items: center; font-size: 20px; }
.badge { font-size: 12.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--gold-soft); color: #6f5222; }
.badge.low { background: #fbe4e1; color: var(--neg); }
.badge.zero { background: var(--line); color: var(--muted); }
.pill { display: inline-block; align-self: flex-start; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--line); margin-top: 2px; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.s-draft { background: #eee9e3; color: #6c625b; }
.s-given { background: #e7eef8; color: #3b5b8a; }
.s-with_tailor { background: var(--gold-soft); color: #7d5d24; }
.s-completed { background: #e3f1e8; color: var(--pos); }
.s-sold { background: var(--accent-soft); color: var(--accent); }

.empty { text-align: center; padding: 40px 16px; }
.empty .btn { margin-top: 10px; }
.welcome { background: var(--card); border: 1px dashed var(--gold); border-radius: var(--radius); margin-top: 16px; }
.welcome h3 { font-family: var(--serif); font-size: 24px; margin: 0 0 6px; }
.loading { display: grid; place-items: center; padding: 60px; }
.loading span { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* stats */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stats.three { grid-template-columns: repeat(3, 1fr); margin-top: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.stat span { font-size: 12px; color: var(--muted); }
.stat b { font-family: var(--serif); font-size: 24px; font-weight: 700; }
.stat b small { font-family: var(--sans); font-size: 12px; color: var(--muted); font-weight: 500; }
.stats.three .stat b { font-size: 20px; }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.qbtn { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 6px; border-radius: var(--radius); background: var(--accent-soft); border: 0; color: var(--accent); font-weight: 600; font-size: 13px; text-align: center; }
.qbtn i { font-style: normal; font-size: 24px; }

/* toolbar & chips */
.toolbar { margin-bottom: 10px; }
.search { width: 100%; padding: 11px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font: inherit; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 6px; scrollbar-width: none; }
.chips.wrap { flex-wrap: wrap; }
.chip { flex-shrink: 0; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-size: 13px; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.summary { margin: 4px 2px 8px; }
.seg { display: flex; background: var(--line); border-radius: 999px; padding: 3px; margin-bottom: 12px; }
.seg > * { flex: 1; }
.seg button, .seg label span { display: block; width: 100%; text-align: center; padding: 8px; border-radius: 999px; border: 0; background: none; font-size: 13.5px; font-weight: 500; }
.seg button.on, .seg input:checked + span { background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.seg input { display: none; }

/* forms */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field > span { font-size: 12.5px; font-weight: 600; color: #5d524c; }
input, select, textarea {
  font: inherit; font-size: 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink); width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { font-size: 12.5px; color: #7d5d24; background: var(--gold-soft); padding: 8px 10px; border-radius: 10px; margin-bottom: 10px; }
.photo-pick { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px dashed var(--line); border-radius: 10px; }
.photo-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-preview { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }
.photo-btn { color: var(--accent); font-weight: 500; font-size: 14px; }
.pitem { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.pitem-top { display: flex; gap: 6px; align-items: center; margin-bottom: 10px; }
.pitem .field { margin-bottom: 4px; }
.per { min-height: 16px; }
.totalbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 4px; font-size: 16px; }
.totalbar b { font-family: var(--serif); font-size: 26px; }
.bill { margin-top: 10px; border-radius: 10px; }

/* sheet */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(30, 20, 18, 0); display: flex; align-items: flex-end; justify-content: center; transition: background .25s; }
.sheet-wrap.open { background: rgba(30, 20, 18, .45); }
.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; background: var(--bg);
  border-radius: 20px 20px 0 0; transform: translateY(100%); transition: transform .25s ease;
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet-wrap.open .sheet { transform: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 4px; position: sticky; top: 0; background: var(--bg); z-index: 1; }
.sheet-head h2 { margin: 0; font-family: var(--serif); font-size: 24px; }
.sheet-body { padding: 8px 16px 18px; }
.sheet-actions { display: flex; gap: 8px; margin-top: 8px; }
.sheet-actions .btn { flex: 1; padding: 13px; }
@media (min-width: 700px) {
  .sheet-wrap { align-items: center; }
  .sheet { border-radius: 20px; }
}

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 24px); transform: translate(-50%, 20px); opacity: 0; z-index: 100; background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; transition: all .25s; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--neg); border-radius: 14px; }

/* material detail */
.hero { display: flex; gap: 14px; align-items: flex-start; }
.hero-img { width: 110px; height: 110px; object-fit: cover; border-radius: var(--radius); }
.hero-info p { margin: 4px 0 0; }

/* project detail */
.photos2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.photos2 figure { margin: 0; cursor: pointer; }
.photos2 img, .photos2 .ph { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: var(--radius); background: var(--gold-soft); }
.photos2 .ph { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-size: 28px; color: var(--gold); }
.photos2 .ph small { font-size: 12px; color: #7d5d24; }
.photos2 figure.add .ph { border: 1.5px dashed var(--gold); background: #fffaf0; }
.photos2 figcaption { font-size: 12px; color: var(--muted); text-align: center; margin-top: 5px; }
.stepper { display: flex; gap: 6px; overflow-x: auto; margin: 14px 0; scrollbar-width: none; }
.stepper button { flex-shrink: 0; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-size: 12.5px; color: var(--muted); }
.stepper button.past { color: var(--ink); border-color: #d9cdbd; }
.stepper button.on { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.info { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.info > div { display: flex; flex-direction: column; gap: 2px; }
.info a { color: var(--accent); }
.info .notes { grid-column: 1 / -1; margin: 0; white-space: pre-wrap; background: var(--bg); padding: 8px 10px; border-radius: 8px; }
.costcard { background: linear-gradient(160deg, #4f3420, #7b5230); color: #fff; border-radius: var(--radius); padding: 6px 16px; margin: 12px 0; }
.crow { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px solid rgba(0,0,0,.06); width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; font-size: 14.5px; }
.card .crow { border-bottom-color: var(--line); }
.card .crow:last-child { border-bottom: 0; }
.costcard .crow { border-bottom-color: rgba(255,255,255,.12); color: #f3e9e6; }
.costcard .crow:last-child { border-bottom: 0; }
.costcard .crow.total b { font-family: var(--serif); font-size: 26px; color: #fff; }
.costcard .crow.mrp em { color: #f0c987; text-decoration: underline; }
.costcard .crow.pos b { color: #9ee0b5; }
.costcard .crow.neg b { color: #ffb0a8; }

/* collection */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 12px; }
.gcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.gimg { position: relative; aspect-ratio: 3/4; background: var(--gold-soft); }
.gimg img, .gimg .ph { width: 100%; height: 100%; object-fit: cover; }
.gimg .ph { display: grid; place-items: center; font-size: 32px; color: var(--gold); }
.tag { position: absolute; top: 8px; left: 8px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; }
.gbody { padding: 10px; display: flex; flex-direction: column; gap: 4px; }
.gbody b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gprice { display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
.mpill { font-size: 11.5px; padding: 2px 7px; border-radius: 999px; background: #e3f1e8; }
.mpill.neg { background: #fbe4e1; }

/* reports */
.bars .bar { display: grid; grid-template-columns: 36px 1fr 82px; align-items: center; gap: 8px; padding: 5px 0; font-size: 13px; }
.bt { height: 10px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.bf { height: 100%; background: var(--accent); border-radius: 99px; }
.bv { text-align: right; font-weight: 500; }
.otable { font-size: 13px; }
.oh, .orow { display: grid; grid-template-columns: 1.6fr 1fr 1fr .8fr; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.oh { font-weight: 600; color: var(--muted); font-size: 12px; }
.oh.tot { color: var(--ink); border-bottom: 0; }
.orow span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.oh span:not(:first-child), .orow span:not(:first-child) { text-align: right; }

/* more */
.menu .item { padding: 14px; }
.demo-card { margin-top: 16px; background: var(--gold-soft); border-color: #ead9b5; }
.demo-card p { margin: 6px 0 0; }

/* login */
.login { max-width: 380px; margin: 0 auto; padding: 60px 20px; }
.brand { text-align: center; margin-bottom: 24px; }
.brand h1 { font-family: var(--serif); font-size: 40px; margin: 4px 0; }
.error { color: var(--neg); min-height: 18px; }
