:root { --accent: #c0152a; --ink: #1b2233; --muted: #6b7385; --line: #e3e8f1; --bg: #eef2f8; --card: #ffffff; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px; color: var(--ink); background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 640px; margin: 0 auto; padding: 0 14px 96px; min-height: 100vh; }

/* hero (home) */
.hero {
  margin: 0 -14px 14px; padding: 22px 18px 52px; color: #fff;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #111 40%));
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  border-radius: 0 0 24px 24px;
}
.hero img { width: 52px; height: 52px; border-radius: 14px; background: #fff; object-fit: contain; padding: 4px; }
.hero .hi { font-size: 13px; opacity: .9; }
.hero .shop { font-size: 21px; font-weight: 700; margin-top: 2px; }
.hero-plain { margin-top: 0; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 10px; padding: 16px 2px 12px; }
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; }
.logo-sm { width: 30px; height: 30px; border-radius: 9px; }
.icon-btn { border: 0; background: var(--card); border-radius: 12px; width: 38px; height: 38px; font-size: 18px; cursor: pointer; box-shadow: 0 1px 3px rgba(20,30,60,.08); }
.login { padding-top: 54px; text-align: center; }
.logo-lg { width: 84px; height: 84px; border-radius: 22px; box-shadow: 0 8px 24px rgba(20,30,60,.12); }
.shop.big { font-size: 22px; font-weight: 700; margin: 14px 0 4px; }
.login-card { margin-top: 22px; text-align: left; }
.pin { text-align: center; font-size: 28px; letter-spacing: 12px; }

/* cards & sections */
.card { background: var(--card); border-radius: 16px; padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(20,30,60,.06); }
.section { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 8px 0 8px; font-weight: 700; }
.section-row { display: flex; justify-content: space-between; align-items: center; }
.link { border: 0; background: none; color: var(--accent); font-weight: 600; cursor: pointer; font-size: 13px; }
.muted { color: var(--muted); font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 22px 8px; font-size: 14px; line-height: 1.6; }
.notice { background: #eef4ff; color: #1d3f8a; border-radius: 12px; padding: 10px 12px; font-size: 13px; margin: 10px 0; }
.notice.err { background: #fdecec; color: #8a1d1d; }
.trial { font-size: 13px; background: #fff6dd; color: #6b4a00; border-radius: 12px; padding: 9px 12px; margin: -2px 0 12px; }
.trial.expired { background: #fdecec; color: #8a1d1d; }

/* forms */
label { display: block; font-size: 12px; color: var(--muted); margin: 11px 0 5px; font-weight: 600; }
input[type=text], input[type=tel], input[type=email], input[type=password], input[type=number], input[type=search], textarea, select {
  width: 100%; padding: 12px 12px; font-size: 15px; border: 1px solid #d3dae6; border-radius: 12px; background: #fbfcfe; font-family: inherit; color: var(--ink);
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
textarea { resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 9px; color: var(--ink); font-size: 14px; margin: 14px 0 2px; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.btn {
  display: block; width: 100%; padding: 14px; margin-top: 12px; font-size: 15px; font-weight: 700;
  border: 0; border-radius: 14px; background: var(--accent); color: #fff; cursor: pointer;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 35%, transparent);
}
.btn.ghost { background: var(--card); color: var(--ink); border: 1px solid #d3dae6; box-shadow: none; }
.btn.danger { background: #b3261e; box-shadow: none; }
.btn.small { width: auto; display: inline-block; padding: 8px 12px; margin: 0 0 0 6px; font-size: 13px; box-shadow: none; }
.btn:disabled { opacity: .5; }

/* item lines */
.items-head, .item-line { display: grid; grid-template-columns: 2fr 1.2fr .7fr .9fr 30px; gap: 6px; }
.items-head { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.item-line { margin-bottom: 7px; }
.item-line input { padding: 10px 8px; font-size: 14px; }
.item-line .del { border: 0; background: #fdecec; color: #b3261e; border-radius: 10px; font-size: 18px; cursor: pointer; }
.totals { margin-top: 12px; border-top: 1px dashed #d3dae6; padding-top: 10px; }
.totals > div { display: flex; justify-content: space-between; padding: 3px 0; font-size: 14px; }
.totals .grand { font-weight: 800; font-size: 17px; color: var(--accent); margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--line); }

/* live preview */
.preview-head { display: flex; justify-content: space-between; align-items: baseline; margin: 18px 2px 8px; font-size: 13px; font-weight: 700; }
.sheet-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 12px; padding-bottom: 4px; }

/* stats & quick links */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat { background: var(--card); border-radius: 16px; padding: 14px; box-shadow: 0 1px 3px rgba(20,30,60,.06); }
.stat.hot { background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 65%, #111 35%)); color: #fff; }
.stat span { display: block; font-size: 12px; color: var(--muted); }
.stat.hot span, .stat.hot small { color: rgba(255,255,255,.85); }
.stat strong { display: block; font-size: 19px; margin: 4px 0; }
.stat small { color: var(--muted); font-size: 12px; }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.quick-btn { background: var(--card); border: 0; border-radius: 16px; padding: 12px 4px 10px; font-size: 11px; font-weight: 600; color: var(--ink); cursor: pointer; box-shadow: 0 1px 3px rgba(20,30,60,.06); }
.quick-btn .qi { display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; margin: 0 auto 6px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 12%, #fff); color: var(--accent); font-size: 18px; font-weight: 700; }
.quick-btn.primary .qi { background: var(--accent); color: #fff; }
.quick-btn:disabled { opacity: .5; }

/* list rows */
.row-item { display: flex; align-items: center; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--line); cursor: pointer; }
.row-item:last-child { border-bottom: 0; }
.avatar { flex: 0 0 38px; width: 38px; height: 38px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--accent) 14%, #fff); color: var(--accent); font-weight: 800; font-size: 15px; }
.avatar.big { width: 52px; height: 52px; font-size: 20px; border-radius: 16px; }
.row-main { flex: 1; min-width: 0; }
.row-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.row-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.row-amt { font-weight: 700; white-space: nowrap; font-size: 14px; }
.tag { display: inline-block; font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: color-mix(in srgb, var(--accent) 12%, #fff); color: var(--accent); margin-right: 6px; text-transform: uppercase; letter-spacing: .03em; }

/* bills search & chips */
.search-row { margin-bottom: 10px; }
.search-row input { border-radius: 14px; padding: 13px 14px; background: var(--card); border-color: transparent; box-shadow: 0 1px 3px rgba(20,30,60,.06); }
.chips { display: flex; gap: 8px; margin-bottom: 12px; }
.chip { border: 0; background: var(--card); border-radius: 99px; padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; box-shadow: 0 1px 3px rgba(20,30,60,.06); }
.chip.on { background: var(--accent); color: #fff; }
.fab {
  position: fixed; right: 16px; bottom: 84px; border: 0; border-radius: 99px; padding: 14px 22px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 15px;
  box-shadow: 0 10px 24px color-mix(in srgb, var(--accent) 40%, transparent); cursor: pointer;
}

/* bottom tabs */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); width: min(640px, 100%); bottom: 0; display: flex; background: rgba(255,255,255,.96);
  backdrop-filter: blur(8px); border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); z-index: 5;
}
.tabbar button { flex: 1; border: 0; background: none; padding: 6px 2px; font-size: 11px; font-weight: 600; color: var(--muted); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabbar .ti { font-size: 18px; line-height: 1; }
.tabbar button.on { color: var(--accent); }

/* menu */
.profile { display: flex; align-items: center; gap: 14px; }
.menu .menu-item {
  display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: none; padding: 13px 2px;
  font-size: 15px; border-bottom: 1px solid var(--line); cursor: pointer; color: var(--ink); text-align: left; font-weight: 500;
}
.menu .menu-item:last-child { border-bottom: 0; }
.menu .mi { width: 30px; height: 30px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--accent) 12%, #fff); color: var(--accent); font-size: 14px; }
.menu .chev { margin-left: auto; color: var(--muted); font-size: 20px; }
.foot-card { text-align: center; }

/* swatches & logo */
.swatches { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.swatch { width: 38px; height: 38px; border-radius: 99px; border: 3px solid #fff; box-shadow: 0 0 0 1px #d3dae6; cursor: pointer; }
.swatch.on { box-shadow: 0 0 0 2px var(--ink); }
.logo-row { display: flex; align-items: center; gap: 12px; }
.logo-preview { width: 60px; height: 60px; border-radius: 14px; object-fit: contain; background: #fff; border: 1px solid var(--line); }

/* actions on document screen */
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.actions .btn { margin-top: 0; }
.actions .btn:first-child { grid-column: span 2; }

/* floating-label fields (bill form, settings, setup) */
.ff { position: relative; margin-top: 14px; }
.ff input, .ff textarea {
  width: 100%; padding: 17px 12px 7px; font-size: 15px; border: 1.5px solid #b9c3d3; border-radius: 12px; background: #fff; font-family: inherit; color: var(--ink);
}
.ff textarea { padding-top: 14px; }
.ff > label {
  position: absolute; top: -8px; left: 11px; background: #fff; padding: 0 5px; margin: 0; font-size: 12px;
  color: var(--muted); font-weight: 600; line-height: 1.3; pointer-events: none; z-index: 1;
}
.ff.ro input { background: #f5f7fb; color: #39404f; }
.ff.grow { flex: 1; min-width: 0; }
.ff input:focus, .ff textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); outline: none; }
.meta-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.doc-form .ff { margin-top: 16px; }

/* billed items */
.bill-bar { display: flex; justify-content: space-between; align-items: center; margin: 22px 0 10px; padding: 10px 14px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 14%, #fff); color: var(--accent); font-weight: 700; }
.gst-chip { border: 1px solid #cfd7e4; border-radius: 99px; padding: 5px 11px; font-size: 12px; font-weight: 700; background: #fff; color: var(--muted); cursor: pointer; }
.gst-chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.item-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(20,30,60,.05); }
.item-top { display: flex; align-items: flex-start; gap: 8px; }
.item-top .ff { margin-top: 0; }
.idx { font-size: 12px; font-weight: 700; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, #fff); padding: 8px 9px; border-radius: 9px; margin-top: 2px; }
.item-top .del { flex: 0 0 34px; height: 34px; margin-top: 2px; border: 0; background: #fdecec; color: #b3261e; border-radius: 10px; font-size: 18px; cursor: pointer; }
.item-mid { display: grid; grid-template-columns: 1.2fr .7fr .9fr .75fr; gap: 8px; margin-top: 12px; }
.item-mid .ff { margin-top: 0; }
.item-mid .ff input { padding: 15px 8px 6px; font-size: 14px; }
.item-calc { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; padding: 8px 12px; border-radius: 10px; background: #f3f5f9; font-size: 13px; color: var(--muted); }
.item-calc strong { color: var(--ink); font-size: 15px; }

/* sticky totals + action bar */
.pay-bar {
  position: sticky; bottom: 0; z-index: 4; margin: 18px -14px 0; padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -8px 20px rgba(20,30,60,.08);
  display: flex; align-items: center; gap: 12px;
}
.pay-info { flex: 1; min-width: 0; }
.pay-line { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.pay-line b { color: var(--ink); font-weight: 600; }
.pay-total { display: flex; justify-content: space-between; align-items: baseline; margin-top: 2px; }
.pay-total span { font-weight: 600; color: var(--muted); font-size: 13px; }
.pay-total strong { font-size: 20px; color: var(--accent); }
.pay-btn { width: auto; margin-top: 0; padding: 13px 18px; flex: 0 0 auto; }
.doc-bar { gap: 10px; }
.doc-bar .btn { flex: 1; margin-top: 0; }
.doc-bar .btn.ghost.danger-txt { color: #b3261e; }
.topbar .right { margin-left: auto; display: flex; gap: 8px; }
.topbar .right .icon-btn { font-size: 16px; }

/* quotation / invoice template (screen + print) */
.sheet {
  --accent: #c0152a;
  background: #fff; color: #111; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.4;
  padding: 22px 24px 16px; border-radius: 6px; box-shadow: 0 2px 16px rgba(20,30,60,.12);
  min-width: 600px;
}
.sh-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.sh-brand { display: flex; align-items: center; gap: 10px; }
.sh-brand img { width: 64px; height: 64px; object-fit: contain; }
.sh-name { font-size: 20px; font-weight: 700; color: var(--accent); }
.sh-title { font-size: 32px; font-weight: 300; letter-spacing: .3px; color: #222; }
.sh-band { margin: 6px 0 14px; background: var(--accent); color: #fff; padding: 9px 16px; font-size: 15px; text-align: right; }
.sh-meta { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 10px; }
.sh-from { font-size: 12px; line-height: 1.6; padding-top: 4px; }
.sh-nums, .sh-cust, .sh-tot { border-collapse: collapse; }
.sh-nums { width: 250px; }
.sh-nums th, .sh-nums td, .sh-cust th, .sh-cust td, .sh-tot th, .sh-tot td { border: 1px solid #9aa3b5; padding: 5px 8px; }
.sh-nums th { text-align: left; font-weight: 400; color: #333; width: 52%; }
.sh-nums td { text-align: center; font-weight: 600; }
.sh-cust { width: 56%; margin-bottom: 12px; }
.sh-cust th { text-align: left; width: 38%; font-weight: 400; background: #f4f6fa; }
.sh-items { width: 100%; border-collapse: collapse; }
.sh-items th { background: var(--accent); color: #fff; padding: 7px 6px; font-size: 12px; text-align: left; font-weight: 600; }
.sh-items td { border: 1px solid #b9c1d0; padding: 6px; vertical-align: top; }
.sh-items tr.blank td { height: 24px; }
.sh-items .c { text-align: center; width: 48px; }
.sh-items .r { text-align: right; }
.sh-items th.r { text-align: right; }
.sh-items th.c { text-align: center; }
.sh-foot { display: flex; gap: 12px; margin-top: 10px; align-items: stretch; }
.sh-left { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.sh-right { width: 260px; flex: 0 0 260px; }
.sh-note, .sh-terms, .sh-sign { border: 1px solid #b9c1d0; padding: 8px 10px; }
.sh-h { font-weight: 700; font-size: 11px; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.sh-note { font-weight: 600; font-size: 12px; }
.sh-terms ol { margin: 0; padding-left: 18px; line-height: 1.7; }
.sh-tot { width: 100%; }
.sh-tot th { text-align: right; font-weight: 400; color: #333; background: #f7f8fb; }
.sh-tot td { text-align: right; width: 42%; font-weight: 600; }
.sh-grand { background: var(--accent); color: #fff; display: flex; justify-content: space-between; align-items: center; padding: 11px 14px; font-size: 16px; font-weight: 700; margin-top: 0; }
.sh-sign { margin-top: 10px; min-height: 96px; text-align: left; }
.sh-sign .sig-space { height: 46px; }
.sh-powered { text-align: right; font-size: 10px; color: #8a90a0; margin-top: 10px; }

@media print {
  body { background: #fff; }
  #app { padding: 0; max-width: none; }
  .no-print, .tabbar, .fab { display: none !important; }
  .sheet-scroll { overflow: visible; }
  .sheet { border-radius: 0; box-shadow: none; padding: 0; min-width: 0; width: 100%; }
  .sheet .sh-items, .sheet .sh-grand, .sheet .sh-band, .sheet .sh-items th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  @page { size: A4; margin: 12mm; }
}
