:root {
  --bg: #FBF8F0;
  --surface: #FFFFFF;
  --surface-2: #FDFBF6;
  --line: #E4DED1;
  --line-2: #EEE9DE;
  --ink: #1B2A21;
  --ink-2: #4E5A52;
  --muted: #7B847D;
  --green: #1E5A35;
  --green-btn: #17663B;
  --green-soft: #EAF3E6;
  --green-badge: #DFF0DC;
  --orange: #E2621B;
  --orange-soft: #FDEADB;
  --yellow-soft: #FDF1C9;
  --red: #D7331F;
  --shadow: 0 1px 2px rgba(40, 35, 20, .05), 0 2px 10px rgba(40, 35, 20, .05);
  --radius: 12px;
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  /* iPhone uses its own San Francisco font; Android and desktop use Inter. */
  --sans: -apple-system, BlinkMacSystemFont, 'Inter', system-ui, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: #EFEBE1;
  color: var(--ink);
  font: 15px/1.35 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--green); }
.ic { flex: none; display: block; }
.art { flex: none; display: block; }
[hidden] { display: none !important; }

#app {
  max-width: 480px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--surface-2);
  position: relative;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}
@media (min-width: 520px) {
  #app { box-shadow: 0 0 0 1px var(--line), 0 10px 40px rgba(40, 35, 20, .08); }
}

.boot { min-height: 80dvh; display: grid; place-items: center; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--green); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.page { padding: 14px 16px 0; padding-top: calc(14px + env(safe-area-inset-top)); }

/* ---------- header ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.logo { display: block; }
.usermenu { position: relative; }
.userbtn { display: flex; align-items: center; gap: 8px; background: none; border: 0; padding: 4px; font-size: 16px; font-weight: 500; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: #E7E5E0; color: #3D4440; display: grid; place-items: center; }
.menu { position: absolute; right: 0; top: 46px; z-index: 30; min-width: 200px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 30px rgba(0,0,0,.12); padding: 6px; }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 12px; border: 0; border-radius: 8px; background: none; text-align: left; }
.menu button:hover { background: var(--bg); }

h1 { font-family: var(--serif); font-weight: 700; font-size: 31px; line-height: 1.12; letter-spacing: -.3px; margin: 10px 0 8px; color: var(--green); }
h2 { font-family: var(--serif); font-weight: 700; font-size: 21px; margin: 22px 0 10px; color: var(--green); }

.stats { display: flex; align-items: center; flex-wrap: nowrap; white-space: nowrap; gap: 8px; font-size: 14.5px; color: var(--ink); background: none; border: 0; padding: 4px 0; text-align: left; }
.stats .s { display: inline-flex; align-items: center; gap: 6px; }
.stats .s .art { width: 22px; height: 22px; }
.stats .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--ink); }
.stats .s .ic { color: var(--green); }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.kpi { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-radius: 6px; min-height: 58px; border: 0; text-align: left; }
.kpi .lbl { font-size: 13px; font-weight: 500; }
.kpi .val { font-size: 21px; font-weight: 700; letter-spacing: -.2px; line-height: 1.1; }
.kpi.received { background: var(--green-soft); color: var(--ink); }
.kpi.received .ic { color: var(--green); width: 28px; height: 28px; }
.kpi.received .lbl { color: var(--green); }
.kpi.pending { background: var(--orange-soft); color: var(--orange); }
.kpi.pending .ic { width: 28px; height: 28px; }

.rates-card { width: 100%; margin-top: 8px; display: flex; align-items: center; gap: 14px; padding: 9px 16px 9px 18px; border-radius: 6px; background: var(--yellow-soft); border: 0; text-align: left; }
.rates-card .t { font-weight: 600; font-size: 15.5px; }
.rates-card .sub { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.rates-card .grow { flex: 1; }

.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 40px; padding: 8px 14px; border-radius: 6px;
  border: 1.5px solid var(--green-btn); background: var(--surface); color: var(--ink);
  font-weight: 500; font-size: 15px; text-decoration: none; white-space: nowrap;
}
.btn.ghost { border: 1px solid #CFCFCB; }
.btn .ic { color: var(--ink); }
.btn.wa .ic { color: #1E9E4A; }
.btn.solid { background: var(--green-btn); color: #fff; border-color: var(--green-btn); }
.btn.solid .ic { color: #fff; }
.btn.big { min-height: 52px; font-size: 19px; font-weight: 600; width: 100%; border-radius: 6px; }
.btn.small { min-height: 30px; font-size: 13.5px; padding: 4px 10px; gap: 7px; }
.btn.small .ic { width: 17px; height: 17px; }
.btn.danger { border-color: #E3B5AD; color: var(--red); }
.btn:disabled { opacity: .55; cursor: default; }

.field { position: relative; margin-top: 10px; }
.search { display: flex; align-items: center; gap: 12px; padding: 0 14px; border: 1px solid #D9D5CC; border-radius: 4px; background: var(--surface); min-height: 40px; }
.search input { border: 0; outline: 0; flex: 1; min-width: 0; background: none; font-size: 14.5px; }
.search .ic { color: #555; }
.select { position: relative; }
.select select { appearance: none; -webkit-appearance: none; width: 100%; min-height: 36px; padding: 6px 40px 6px 16px; border: 1px solid #D9D5CC; border-radius: 4px; background: var(--surface); font-size: 14.5px; }
.select .ic { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); pointer-events: none; color: #333; }

/* ---------- customer cards ---------- */
.list { margin: 10px -6px 0; display: flex; flex-direction: column; gap: 8px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px 10px 19px; box-shadow: var(--shadow); }
.card-head { display: flex; gap: 10px; align-items: flex-start; }
.card-head .who { flex: 1; min-width: 0; }
.card-head .name { font-family: var(--serif); font-weight: 700; font-size: 21px; line-height: 1.1; color: var(--ink); }
.card-head .meta { font-size: 14px; color: var(--ink-2); line-height: 1.2; }
.round { width: 44px; height: 40px; border-radius: 6px; border: 1px solid #DCE7DA; background: var(--green-soft); color: var(--green-btn); display: grid; place-items: center; text-decoration: none; }
.round .ic { width: 22px; height: 22px; }
.round.off { opacity: .45; pointer-events: none; }
.items { border-top: 1px solid var(--line-2); margin-top: 6px; padding-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.item { display: flex; align-items: center; gap: 20px; padding-left: 3px; }
.item .n { font-weight: 600; font-size: 14.5px; }
.item .q { font-size: 14px; color: var(--ink-2); }
.noitems { font-size: 14px; color: var(--muted); padding: 6px 0; }
.money { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line-2); margin-top: 8px; padding-top: 6px; text-align: center; }
.money > div + div { border-left: 1px solid var(--line-2); }
.money .lbl { font-size: 12px; color: var(--ink-2); }
.money .v { font-size: 18px; font-weight: 700; }
.money .v.green { color: var(--green-btn); }
.money .v.red { color: var(--red); }
.badge { display: inline-flex; align-items: center; gap: 6px; margin: 4px auto 0; padding: 2px 10px; border-radius: 4px; font-size: 12.5px; font-weight: 500; }
.badge.ok { background: var(--green-badge); color: var(--green-btn); }
.badge.warn { background: #FFF0CC; color: #8A5A00; }
.badge-row { text-align: center; }
.claim { margin-top: 8px; padding: 10px 12px; border-radius: 8px; background: #FFF6DB; border: 1px solid #F1D88E; font-size: 13.5px; }
.claim .row { display: flex; gap: 8px; margin-top: 8px; }
.card-actions { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.card-actions .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card-actions .btn { min-height: 30px; font-size: 14px; }
.card-actions .btn.solid { min-height: 30px; font-size: 14.5px; }
.card-actions .btn .ic { width: 18px; height: 18px; }

.empty { text-align: center; padding: 36px 20px; color: var(--ink-2); }
.empty .art { margin: 0 auto 10px; }

.fab {
  position: fixed; z-index: 20; bottom: calc(22px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(calc(min(240px, 50vw) - 100% - 14px));
  display: inline-flex; align-items: center; gap: 12px; padding: 0 32px 0 26px; min-height: 38px;
  border-radius: 6px; border: 0; background: var(--green-btn); color: #fff; font-size: 16px; font-weight: 600; white-space: nowrap;
  box-shadow: 0 6px 18px rgba(20, 70, 40, .35);
}
.fab .ic { color: #fff; }

/* ---------- forms ---------- */
.screen-head { display: flex; align-items: center; gap: 22px; margin: 4px 0 6px; }
.screen-head h1 { margin: 0; font-size: 31px; }
.iconbtn { border: 0; background: none; padding: 6px; margin-left: -6px; color: var(--ink); display: grid; place-items: center; }
.iconbtn .ic { width: 28px; height: 28px; }
label.l { display: block; font-size: 14.5px; color: var(--ink); margin: 12px 0 4px; }
.input, .page select.input, textarea.input {
  width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid #D5D2CB; border-radius: 4px;
  background: var(--surface); font-size: 16px; outline: 0;
}
.input:focus { border-color: var(--green-btn); box-shadow: 0 0 0 3px rgba(23, 102, 59, .12); }
.input::placeholder { color: #9A9C97; }
.with-btn { display: flex; gap: 10px; }
.with-btn .input { flex: 1; min-width: 0; }
.with-icon { position: relative; }
.with-icon .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: #2B2B2B; width: 22px; height: 22px; }
.with-icon .input { padding-left: 52px; }
.hint { font-size: 13.5px; color: var(--muted); margin-top: 6px; }
.loc-saved { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--green-btn); margin-top: 6px; }
.err { color: var(--red); font-size: 14px; margin-top: 10px; }

.frow { display: grid; grid-template-columns: 56px minmax(0, 1fr) 62px 70px 28px; gap: 8px; align-items: center; margin-top: 8px; }
.frow .thumb { width: 56px; height: 40px; border: 1px solid #D5D2CB; border-radius: 4px; background: var(--surface); display: grid; place-items: center; overflow: hidden; }
.frow .select select { min-height: 40px; padding: 6px 30px 6px 10px; font-size: 14.5px; border-color: #D5D2CB; text-overflow: ellipsis; }
.frow .select .ic { right: 10px; width: 18px; height: 18px; }
.frow .input { min-height: 40px; padding: 6px 12px; font-size: 15px; }
.frow .del { border: 0; background: none; color: var(--red); padding: 0; display: grid; place-items: center; }
.frow .del .ic { width: 22px; height: 22px; }
.frow-note { grid-column: 2 / -1; font-size: 12px; color: var(--muted); margin-top: -4px; }
.addflower { display: inline-flex; align-items: center; gap: 12px; margin: 12px 0 0; padding: 4px 2px; border: 0; background: none; color: var(--green); font-weight: 600; font-size: 15.5px; }
.addflower .ic { width: 22px; height: 22px; }

.summary { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 12px; padding: 8px 0; background: #FDF0D7; border-radius: 6px; text-align: center; }
.summary > div + div { border-left: 1px solid #EBD9B5; }
.summary .lbl { font-size: 14px; color: var(--ink-2); }
.summary .v { font-size: 21px; font-weight: 700; }
.summary .v.red { color: var(--red); }

.pay-row { display: flex; align-items: flex-end; gap: 22px; }
.pay-row .grow { flex: 1; }
.receipt-link { display: flex; align-items: center; gap: 10px; color: var(--green); font-size: 14.5px; padding-bottom: 4px; }
.receipt-link .box { width: 44px; height: 44px; border: 1px solid #D5D2CB; border-radius: 6px; display: grid; place-items: center; color: var(--ink); background: var(--surface); }
.confirm-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 12px; font-size: 14.5px; cursor: pointer; }
.check input { appearance: none; -webkit-appearance: none; width: 24px; height: 24px; border-radius: 3px; border: 1.5px solid #9AA39C; display: grid; place-items: center; margin: 0; background: #fff; }
.check input:checked { background: var(--green-btn); border-color: var(--green-btn); }
.check input:checked::after { content: ''; width: 11px; height: 6px; border: 2.5px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.note { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.note .ic { width: 18px; height: 18px; }
.save-bar { margin-top: 18px; }
.more { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line); }
.order-tabs { display: flex; gap: 6px; overflow-x: auto; margin: 6px 0 2px; scrollbar-width: none; }
.order-tabs::-webkit-scrollbar { display: none; }
.order-tabs button { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13px; }
.order-tabs button.on { background: var(--green-btn); border-color: var(--green-btn); color: #fff; }

/* ---------- other screens ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-top: 12px; }
.rate-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) 76px 76px; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.rate-row:last-child { border-bottom: 0; }
.rate-row .nm { font-weight: 600; font-size: 14px; line-height: 1.2; }
.rate-row .art { width: 36px; height: 36px; }
.rate-row .kind { font-size: 12px; color: var(--muted); }
.rate-row .input { min-height: 38px; padding: 6px 8px; font-size: 15px; }
.rate-head { display: grid; grid-template-columns: 36px minmax(0, 1fr) 76px 76px; gap: 10px; font-size: 12px; color: var(--muted); }
.money-input { position: relative; }
.money-input span { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; }
.money-input .input { padding-left: 20px; }
.need-group h3 { margin: 18px 0 6px; font-size: 15px; color: var(--ink-2); font-weight: 600; }
.need-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.need-row .grow { flex: 1; }
.need-row .big { font-size: 18px; font-weight: 700; }
.ann-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.ann-row .grow { flex: 1; min-width: 0; }
.ann-row .nm { font-weight: 600; }
.ann-row .ph { font-size: 13px; color: var(--muted); }
.sent { color: var(--green-btn); font-size: 13px; font-weight: 600; display: inline-flex; gap: 4px; align-items: center; }
textarea.input { min-height: 160px; resize: vertical; font-size: 14.5px; line-height: 1.45; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line-2); font-size: 15px; }
.kv:last-child { border-bottom: 0; }
.kv b { font-weight: 700; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* login */
.auth { padding: 40px 24px; text-align: center; }
.auth .logo { margin: 0 auto 6px; }
.auth h1 { font-size: 26px; }
.names { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 14px 0; }
.names button { border: 1.5px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 18px; font-weight: 500; }
.names button.on { border-color: var(--green-btn); background: var(--green-soft); color: var(--green); }
.pin { letter-spacing: 10px; text-align: center; font-size: 24px !important; }
.auth form { max-width: 320px; margin: 0 auto; text-align: left; }

/* public pages */
.pub-head { display: flex; justify-content: center; padding: 6px 0 2px; }
.qr { width: 236px; height: 236px; margin: 8px auto; display: block; border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 6px; }
.big-amount { font-size: 34px; font-weight: 700; color: var(--red); text-align: center; letter-spacing: -.5px; }
.paid-stamp { text-align: center; color: var(--green-btn); font-weight: 700; font-size: 20px; display: flex; gap: 8px; justify-content: center; align-items: center; }
.upi-id { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 14px; color: var(--ink-2); }

#toast {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: #1B2A21; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 430px) {
  .frow { grid-template-columns: 44px minmax(0, 1fr) 50px 60px 22px; gap: 6px; }
  .frow .thumb { width: 44px; }
  .frow .input { padding: 6px 8px; }
  .frow .select select { padding-left: 8px; padding-right: 24px; }
  .frow .select .ic { right: 6px; }
}
@media (max-width: 380px) {
  h1 { font-size: 27px; }
  .kpi { gap: 10px; padding: 10px 12px; }
  .btn { font-size: 14px; gap: 8px; padding: 8px 10px; }
}

/* ---------- share sheet ---------- */
body.noscroll { overflow: hidden; }
.sheet-wrap { position: fixed; inset: 0; z-index: 60; background: rgba(20, 30, 24, .45); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease-out; }
.sheet { width: 100%; max-width: 480px; max-height: 92dvh; overflow-y: auto; background: var(--surface-2); border-radius: 16px 16px 0 0; padding: 8px 16px calc(18px + env(safe-area-inset-bottom)); animation: rise .2s ease-out; }
.sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: #D5D0C4; margin: 2px auto 6px; }
.sheet-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 14px 0 10px; }
.sheet-or::before, .sheet-or::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
@keyframes rise { from { transform: translateY(30px); opacity: .6; } }
@keyframes fade { from { opacity: 0; } }

.linkbtn { border: 0; background: none; padding: 2px 4px; color: var(--green); font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; gap: 4px; text-decoration: underline; text-underline-offset: 2px; }
.linkbtn .ic { width: 15px; height: 15px; }
.hello { margin: 8px 0 4px; padding: 10px 12px; border-radius: 8px; background: var(--green-soft); font-size: 14.5px; }
.hello .linkbtn { display: flex; margin-top: 4px; padding-left: 0; }

/* ---------- agreed price & notes ---------- */
.agreed-tag { display: inline-block; padding: 0 6px; border-radius: 4px; background: #FFF0CC; color: #8A5A00; font-size: 11.5px; font-weight: 600; line-height: 18px; white-space: nowrap; }
.frow-note { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; }
.frow-note .linkbtn { font-size: 12px; padding: 0 2px; }
.money-input.mini { display: inline-block; width: 74px; }
.money-input.mini .input { min-height: 30px; padding: 2px 6px 2px 18px; font-size: 14px; }
.card-note { display: flex; gap: 8px; align-items: flex-start; margin-top: 6px; padding: 6px 10px; border-radius: 6px; background: #FFF8E3; color: #6B4E00; font-size: 13.5px; white-space: pre-line; }
.card-note .ic { width: 15px; height: 15px; margin-top: 2px; }
textarea.input.notes { min-height: 64px; font-size: 15px; }

/* ---------- install banner ---------- */
.install-banner { display: flex; gap: 10px; align-items: flex-start; margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: #EAF3E6; border: 1px solid #CFE3C9; font-size: 13px; color: var(--ink-2); }
.install-banner b { color: var(--green); font-size: 14px; }
.install-banner .grow { flex: 1; }
.app-pay { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 6px; }

/* iPhone Safari zooms into any field under 16px; keep every field at 16px on phones. */
@media (max-width: 480px) {
  .input, select, textarea, .frow .input, .frow .select select, .search input, .money-input.mini .input { font-size: 16px !important; }
}
@supports (-webkit-touch-callout: none) {
  input[type="date"].input { -webkit-appearance: none; appearance: none; display: flex; align-items: center; text-align: left; }
  input[type="date"]::-webkit-date-and-time-value { text-align: left; }
}

/* Phone forced into "desktop site" mode (see index.html): the page is zoomed to the phone's
   width, so use the phone layout even though the browser reports a wide screen. */
html.fit-phone #app { box-shadow: none; max-width: none; }
html.fit-phone body { background: var(--surface-2); }
html.fit-phone .frow { grid-template-columns: 44px minmax(0, 1fr) 50px 60px 22px; gap: 6px; }
html.fit-phone .frow .thumb { width: 44px; }
html.fit-phone .fab { left: auto; right: 14px; transform: none; }
