/* FastPay tokens — Wise design language, Midnight Coral palette.
   Names are historical: --forest is the brand ink, --lime the action colour,
   --linen the soft tint, --fog-2 the card surface, --ground the screen background. */
:root {
  /* Brand */
  --forest: #14213d;        /* Navy ink: primary copy, dark surfaces */
  --lime: #ff8a5c;          /* Coral: primary action fill, one per view */
  --lime-press: #f37446;
  --spruce: #0b1530;        /* Deeper navy: tonal depth */
  --linen: #ffe7dc;         /* Peach: soft highlight surfaces, badges */

  /* Neutrals */
  --obsidian: #0f1629;      /* Display headlines */
  --charcoal: #3f4250;      /* Body copy */
  --slate: #5c5e66;         /* Supporting text (4.5:1+) */
  --pebble: #8a8a90;        /* Placeholders, icons, borders */
  --fog: #e3d9cc;           /* Dividers, pressed states */
  --fog-2: #efe8df;         /* Card surfaces */
  --paper: #ffffff;
  --ground: #f7f3ee;        /* Sand: screen background */
  --on-ink-muted: #b9c3dd;  /* Muted text on navy cards */

  /* Supporting accents */
  --blue: #0b4c72;          /* Signal Blue */
  --blue-soft: #dcebf4;
  --red: #cb272f;           /* Alarm Red */
  --red-soft: #fbe3e4;
  --amber: #7a4a00;
  --amber-soft: #fcefd2;

  /* Type */
  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  --font-display: "Inter Tight", "Inter", -apple-system, sans-serif;

  /* Shape */
  --r-sm: 10px;             /* inputs, cards */
  --r-lg: 28px;             /* sheets, hero cards */
  --r-pill: 9999px;         /* buttons, tags, segments */

  /* Flat elevation: hairlines only */
  --ring: 0 0 0 1px rgba(14, 15, 12, 0.12);
  --ring-inset: inset 0 0 0 1px rgba(14, 15, 12, 0.12);
  --hair: rgba(14, 15, 12, 0.10);

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --safe-top: 54px;
  --safe-bottom: 34px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-ui);
  background: var(--fog);
  color: var(--charcoal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }

/* ---------- Views ---------- */
.views { position: absolute; inset: 0; }
.view {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  background: var(--ground);
  padding-top: var(--safe-top);
  transition: transform .34s var(--ease);
  will-change: transform;
}
.view.at-right { transform: translateX(100%); }
.view.at-left { transform: translateX(-26%); }
.view.hidden { visibility: hidden; }
.view.has-tabbar .scroll { padding-bottom: 120px; }

.nav {
  flex: none;
  height: 52px;
  padding: 0 12px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}
.nav-left, .nav-right { display: flex; align-items: center; gap: 8px; }
.nav-right { justify-content: flex-end; }
.nav-title { font-size: 17px; font-weight: 600; color: var(--obsidian); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; text-align: center; }
.nav-text-btn { border: 0; background: none; font-size: 16px; font-weight: 600; color: var(--forest); padding: 10px 6px; min-height: 44px; }
.nav-text-btn:disabled { color: var(--pebble); }

.icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: var(--fog-2); color: var(--forest);
  display: inline-flex; align-items: center; justify-content: center;
  flex: none; position: relative;
}
.icon-btn:active { background: var(--fog); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn .dot { position: absolute; top: 9px; right: 10px; width: 9px; height: 9px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px var(--fog-2); }

.scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 0 16px 40px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.scroll::-webkit-scrollbar { display: none; }

.large-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 40px;
  line-height: .92;
  letter-spacing: -0.035em;
  color: var(--obsidian);
  margin: 4px 0 20px;
}
.h2 { font-family: var(--font-display); font-weight: 900; font-size: 28px; line-height: 1; letter-spacing: -0.03em; color: var(--obsidian); margin: 0; }
.h3 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; color: var(--obsidian); margin: 0; }
.section-label { font-size: 14px; font-weight: 600; color: var(--obsidian); margin: 24px 4px 10px; display: flex; justify-content: space-between; align-items: center; }
.section-label .link { font-weight: 600; }
.muted { color: var(--slate); }
.small { font-size: 14px; }
.micro { font-size: 12px; }
.link { color: var(--forest); text-decoration: underline; text-underline-offset: 3px; font-weight: 500; background: none; border: 0; padding: 0; cursor: pointer; font-size: inherit; }
.center { text-align: center; }

/* ---------- Footer bar ---------- */
.footer {
  flex: none;
  padding: 12px 16px calc(var(--safe-bottom) + 8px);
  background: var(--ground);
  box-shadow: 0 -1px 0 var(--hair);
  display: flex; gap: 10px;
}
.footer > * { flex: 1; }

/* ---------- Buttons ---------- */
.btn {
  min-height: 48px; padding: 0 24px;
  border-radius: var(--r-pill);
  border: 0;
  font-size: 16px; font-weight: 600; letter-spacing: -0.006em;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; white-space: nowrap;
  transition: background .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn svg { width: 20px; height: 20px; }
.btn-primary { background: var(--lime); color: var(--forest); }
.btn-primary:active { background: var(--lime-press); }
.btn-dark { background: var(--forest); color: var(--paper); }
.btn-secondary { background: var(--paper); color: var(--forest); box-shadow: inset 0 0 0 1px var(--forest); }
.btn-secondary:active { background: var(--linen); }
.btn-soft { background: var(--fog-2); color: var(--forest); }
.btn-soft:active { background: var(--fog); }
.btn-danger { background: var(--paper); color: var(--red); box-shadow: inset 0 0 0 1px var(--red); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 16px; font-size: 14px; }
.btn:disabled { opacity: .45; pointer-events: none; }

.fab {
  position: absolute; right: 16px; bottom: calc(84px + 16px); z-index: 20;
  min-height: 56px; min-width: 56px; padding: 0 22px 0 18px;
  border-radius: var(--r-pill); border: 0;
  background: var(--lime); color: var(--forest);
  font-size: 16px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: padding .25s var(--ease), gap .25s var(--ease), background .15s;
  box-shadow: 0 0 0 1px rgba(14,15,12,.06);
}
.fab svg { width: 22px; height: 22px; }
.fab:active { background: var(--lime-press); }
.fab-label { display: inline-block; max-width: 160px; overflow: hidden; white-space: nowrap; transition: max-width .25s var(--ease), opacity .2s; }
.fab.mini { padding: 0; gap: 0; }
.fab.mini .fab-label { max-width: 0; opacity: 0; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 30;
  height: 84px; padding: 6px 6px 0;
  background: var(--ground);
  box-shadow: 0 -1px 0 var(--hair);
  display: grid; grid-template-columns: repeat(5, 1fr);
  transition: transform .3s var(--ease);
}
.tabbar.gone { transform: translateY(100%); }
.tab {
  border: 0; background: none;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding-top: 2px;
  font-size: 11px; font-weight: 500; color: var(--slate);
}
.tab-ico { width: 56px; height: 32px; border-radius: var(--r-pill); display: flex; align-items: center; justify-content: center; transition: background .2s; }
.tab svg { width: 24px; height: 24px; }
.tab.on { color: var(--forest); font-weight: 600; }
.tab.on .tab-ico { background: var(--linen); }

/* ---------- Segmented / chips ---------- */
.seg { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin-bottom: 16px; }
.seg::-webkit-scrollbar { display: none; }
.seg button {
  flex: none; min-height: 40px; padding: 0 18px;
  border-radius: var(--r-pill); border: 0;
  background: var(--fog-2); color: var(--charcoal);
  font-size: 15px; font-weight: 500;
}
.seg button.on { background: var(--forest); color: var(--paper); }
.seg.outline button { background: var(--paper); box-shadow: inset 0 0 0 1px rgba(14,15,12,.14); }
.seg.outline button.on { background: var(--forest); box-shadow: none; color: var(--paper); }
.seg.full { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--fog-2); padding: 4px; border-radius: var(--r-pill); gap: 4px; }
.seg.full button { background: none; min-height: 36px; }
.seg.full button.on { background: var(--paper); color: var(--forest); box-shadow: var(--ring); font-weight: 600; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 14px;
  border-radius: var(--r-pill); border: 0;
  background: var(--fog-2); color: var(--forest);
  font-size: 14px; font-weight: 500;
}
.chip svg { width: 16px; height: 16px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Search ---------- */
.search {
  display: flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 14px;
  border-radius: var(--r-pill); background: var(--fog-2);
  margin-bottom: 16px; color: var(--slate);
}
.search svg { width: 20px; height: 20px; flex: none; }
.search input { border: 0; background: none; outline: none; flex: 1; font-size: 16px; color: var(--obsidian); min-width: 0; }
.search input::placeholder { color: var(--slate); }

/* ---------- Cards / groups / rows ---------- */
.group { background: var(--fog-2); border-radius: var(--r-sm); overflow: hidden; }
.group + .group { margin-top: 12px; }
.row {
  width: 100%;
  display: flex; align-items: center; gap: 12px;
  min-height: 56px; padding: 12px 16px;
  border: 0; background: none; text-align: left;
  position: relative;
}
button.row:active, a.row:active { background: var(--fog); }
.row + .row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: 1px; background: var(--hair); }
.row-ico {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--paper); color: var(--forest);
  display: flex; align-items: center; justify-content: center; flex: none;
}
.row-ico svg { width: 20px; height: 20px; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title, .row-sub { display: block; }
.row-title { font-size: 16px; font-weight: 500; color: var(--obsidian); line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 14px; color: var(--slate); line-height: 1.45; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub.wrap { white-space: pre-line; }
.row-end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; text-align: right; }
.row-val { font-size: 16px; font-weight: 600; color: var(--obsidian); }
.row-val.muted { font-weight: 500; color: var(--slate); }
.chev { width: 18px; height: 18px; color: var(--pebble); flex: none; }
.row.add { color: var(--forest); font-weight: 600; }
.row.add .row-ico { background: var(--linen); }
.row.danger .row-title { color: var(--red); }

.avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--fog); color: var(--forest);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; flex: none; letter-spacing: -0.01em;
}
.avatar.lg { width: 72px; height: 72px; font-size: 24px; }
.avatar.linen { background: var(--linen); }

.doc-row { border: 0; background: none; width: 100%; text-align: left; display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-radius: var(--r-sm); position: relative; }
.doc-row:active { background: var(--fog-2); }
.doc-row + .doc-row::before { content: ""; position: absolute; top: 0; left: 60px; right: 4px; height: 1px; background: var(--hair); }

.month-head { font-size: 13px; font-weight: 600; color: var(--slate); text-transform: uppercase; letter-spacing: .04em; margin: 20px 4px 4px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: var(--r-pill); font-size: 12px; font-weight: 600; line-height: 1.5; white-space: nowrap; }
.b-draft { background: var(--fog); color: var(--charcoal); }
.b-sent { background: var(--fog-2); color: var(--forest); box-shadow: var(--ring-inset); }
.b-viewed { background: var(--blue-soft); color: var(--blue); }
.b-partial { background: var(--amber-soft); color: var(--amber); }
.b-overdue { background: var(--red-soft); color: #a51d24; }
.b-paid, .b-approved { background: var(--linen); color: var(--forest); }
.b-declined { background: var(--red-soft); color: #a51d24; }
.b-invoiced { background: var(--forest); color: var(--paper); }
.b-plan { background: var(--linen); color: var(--forest); }

/* ---------- Hero summary ---------- */
.hero {
  background: var(--forest); color: var(--paper);
  border-radius: var(--r-lg); padding: 24px;
  margin-bottom: 20px;
}
.hero-label { font-size: 14px; font-weight: 500; color: var(--on-ink-muted); }
.hero-amount { font-family: var(--font-display); font-weight: 900; font-size: 44px; line-height: 1; letter-spacing: -0.035em; margin: 8px 0 16px; color: var(--paper); }
.hero-stats { display: flex; gap: 24px; }
.hero-stat b { display: block; font-size: 17px; font-weight: 600; color: var(--paper); }
.hero-stat span { font-size: 13px; color: var(--on-ink-muted); }
.hero-stat.warn b { color: var(--lime); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label, .field .label { font-size: 14px; font-weight: 500; color: var(--charcoal); }
.input, .select, .textarea {
  width: 100%; min-height: 48px;
  border-radius: var(--r-sm);
  border: 1px solid var(--pebble);
  background: var(--paper);
  padding: 12px 14px;
  font-size: 16px; color: var(--obsidian);
  outline: none;
  transition: box-shadow .15s, border-color .15s;
}
.textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--forest); box-shadow: inset 0 0 0 1px var(--forest); }
.input::placeholder, .textarea::placeholder { color: var(--pebble); }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--forest) 50%), linear-gradient(135deg, var(--forest) 50%, transparent 50%); background-position: right 19px center, right 13px center; background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; padding-right: 40px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row.three { grid-template-columns: 1.3fr .8fr .9fr; }
.input-affix { position: relative; }
.input-affix .affix { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--slate); font-size: 15px; pointer-events: none; }
.input-affix .input { padding-right: 36px; }
.hint { font-size: 13px; color: var(--slate); line-height: 1.45; }

/* Inline form rows inside a group */
.frow { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 6px 16px; position: relative; }
.frow + .frow::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: 1px; background: var(--hair); }
.frow label { font-size: 16px; color: var(--slate); flex: none; min-width: 64px; }
.frow input, .frow select, .frow textarea { flex: 1; border: 0; background: none; outline: none; font-size: 16px; text-align: left; color: var(--obsidian); min-width: 0; padding: 8px 0; }
.frow textarea { text-align: left; min-height: 60px; resize: none; }
.frow select { direction: rtl; appearance: none; color: var(--forest); font-weight: 500; }
.frow input::placeholder { color: var(--pebble); }
.frow.stack { flex-direction: column; align-items: stretch; gap: 2px; padding: 10px 16px; }
.frow.stack label { font-size: 13px; color: var(--slate); min-width: 0; }
.frow.stack input, .frow.stack textarea { text-align: left; padding: 2px 0; }

/* Switch */
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: var(--r-pill); background: var(--fog); transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: var(--paper); box-shadow: 0 0 0 1px rgba(14,15,12,.08); transition: transform .2s var(--ease); }
.switch input:checked + span { background: var(--forest); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--forest); outline-offset: 2px; }

/* Radio list */
.opt { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 10px 16px; border: 0; background: none; text-align: left; font-size: 16px; color: var(--obsidian); position: relative; }
.opt + .opt::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: 1px; background: var(--hair); }
.opt:active { background: var(--fog); }
.opt .check { margin-left: auto; width: 22px; height: 22px; color: var(--forest); }
.opt .opt-sub { display: block; font-size: 14px; color: var(--slate); }

/* ---------- Editor (document) ---------- */
.ed-card { background: var(--fog-2); border-radius: var(--r-sm); margin-bottom: 12px; overflow: hidden; }
.ed-head { display: flex; gap: 12px; padding: 16px; border: 0; background: none; width: 100%; text-align: left; align-items: flex-start; }
.ed-head:active { background: var(--fog); }
.logo-box { width: 56px; height: 56px; border-radius: var(--r-sm); background: var(--paper); box-shadow: var(--ring-inset); display: flex; align-items: center; justify-content: center; color: var(--pebble); overflow: hidden; flex: none; }
.logo-box img { width: 100%; height: 100%; object-fit: contain; }
.logo-box svg { width: 22px; height: 22px; }
.ed-meta { margin-left: auto; text-align: right; }
.ed-num { font-size: 17px; font-weight: 700; color: var(--obsidian); }
.item-row .row-sub { white-space: normal; }
.totals .trow { display: flex; justify-content: space-between; align-items: center; min-height: 48px; padding: 10px 16px; border: 0; background: none; width: 100%; font-size: 16px; color: var(--charcoal); position: relative; text-align: left; }
.totals button.trow:active { background: var(--fog); }
.totals .trow + .trow::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: 1px; background: var(--hair); }
.totals .trow b { color: var(--obsidian); font-weight: 600; }
.totals .trow .tval { display: flex; align-items: center; gap: 6px; color: var(--obsidian); }
.totals .trow.total { font-weight: 700; color: var(--obsidian); font-size: 17px; }
.totals .trow.balance { background: var(--forest); color: var(--paper); font-weight: 600; min-height: 60px; }
.totals .trow.balance .tval { color: var(--paper); font-family: var(--font-display); font-weight: 900; font-size: 26px; letter-spacing: -0.03em; }
.totals .trow.balance::before { display: none; }

.banner { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-radius: var(--r-sm); margin-bottom: 12px; font-size: 14px; line-height: 1.45; }
.banner svg { width: 22px; height: 22px; flex: none; }
.banner b { color: inherit; }
.banner.ok { background: var(--linen); color: var(--forest); }
.banner.info { background: var(--blue-soft); color: var(--blue); }
.banner.warn { background: var(--red-soft); color: #a51d24; }
.banner.amber { background: var(--amber-soft); color: var(--amber); }
.banner .btn { margin-left: auto; }

.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 12px 16px 16px; }
.photo { aspect-ratio: 1; border-radius: var(--r-sm); overflow: hidden; border: 0; padding: 0; background: var(--fog); }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo.add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; background: var(--paper); box-shadow: var(--ring-inset); color: var(--forest); font-size: 13px; font-weight: 600; }
.photo.add svg { width: 22px; height: 22px; }

.sig-img { height: 64px; object-fit: contain; object-position: left; }
.sig-pad-wrap { position: relative; background: var(--paper); border-radius: var(--r-sm); box-shadow: var(--ring-inset); height: 220px; touch-action: none; }
.sig-pad-wrap canvas { width: 100%; height: 100%; display: block; }
.sig-line { position: absolute; left: 24px; right: 24px; bottom: 48px; border-bottom: 1px dashed var(--pebble); pointer-events: none; }
.sig-x { position: absolute; left: 24px; bottom: 54px; color: var(--pebble); font-size: 20px; pointer-events: none; }

/* Timeline */
.timeline { position: relative; padding-left: 8px; }
.tl-item { display: flex; gap: 14px; padding-bottom: 20px; position: relative; }
.tl-item::before { content: ""; position: absolute; left: 19px; top: 40px; bottom: 0; width: 2px; background: var(--fog); }
.tl-item:last-child::before { display: none; }
.tl-ico { width: 40px; height: 40px; border-radius: 50%; background: var(--fog-2); color: var(--forest); display: flex; align-items: center; justify-content: center; flex: none; }
.tl-ico svg { width: 20px; height: 20px; }
.tl-ico.ok { background: var(--linen); }
.tl-ico.blue { background: var(--blue-soft); color: var(--blue); }
.tl-ico.red { background: var(--red-soft); color: var(--red); }
.tl-text { padding-top: 2px; }
.tl-text b { display: block; font-size: 16px; font-weight: 600; color: var(--obsidian); }
.tl-text span { font-size: 14px; color: var(--slate); }

/* ---------- Sheets ---------- */
.layer-root { position: absolute; inset: 0; z-index: 50; pointer-events: none; }
.sheet-wrap { position: absolute; inset: 0; pointer-events: auto; }
.backdrop { position: absolute; inset: 0; background: rgba(14, 15, 12, .42); opacity: 0; transition: opacity .3s; border: 0; padding: 0; width: 100%; cursor: default; }
.sheet-wrap.open .backdrop { opacity: 1; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: calc(100% - var(--safe-top) - 8px);
  background: var(--paper);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  display: flex; flex-direction: column;
  transform: translateY(100%);
  transition: transform .36s var(--ease);
}
.sheet.full { top: calc(var(--safe-top) - 8px); }
.sheet-wrap.open .sheet { transform: translateY(0); }
.sheet-grab { width: 36px; height: 5px; border-radius: 3px; background: var(--fog); margin: 8px auto 0; flex: none; }
.sheet-head { flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 4px 8px 4px; min-height: 52px; }
.sheet-head .nav-right { justify-content: flex-end; }
.sheet-title { font-size: 17px; font-weight: 600; color: var(--obsidian); text-align: center; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 16px calc(var(--safe-bottom) + 20px); scrollbar-width: none; }
.sheet-body::-webkit-scrollbar { display: none; }
.sheet-foot { flex: none; padding: 12px 16px calc(var(--safe-bottom) + 8px); box-shadow: 0 -1px 0 var(--hair); display: flex; gap: 10px; }
.sheet-foot > * { flex: 1; }

.action-title { font-size: 14px; color: var(--slate); text-align: center; padding: 8px 16px 12px; }
.action-list .row-title { font-weight: 500; }

/* Dialog */
.dialog-wrap { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: auto; padding: 24px; }
.dialog-wrap .backdrop { opacity: 0; }
.dialog-wrap.open .backdrop { opacity: 1; }
.dialog { position: relative; width: 100%; max-width: 320px; background: var(--paper); border-radius: var(--r-lg); padding: 24px; transform: scale(.94); opacity: 0; transition: transform .22s var(--ease), opacity .2s; }
.dialog-wrap.open .dialog { transform: scale(1); opacity: 1; }
.dialog h3 { margin: 0 0 8px; font-size: 20px; font-weight: 700; color: var(--obsidian); letter-spacing: -0.01em; }
.dialog p { margin: 0 0 20px; font-size: 15px; line-height: 1.5; color: var(--charcoal); }
.dialog .btns { display: flex; flex-direction: column; gap: 8px; }

/* Toast */
.toasts { position: absolute; top: calc(var(--safe-top) + 4px); left: 16px; right: 16px; z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-radius: var(--r-pill); background: var(--forest); color: var(--paper); font-size: 15px; font-weight: 500; transform: translateY(-16px); opacity: 0; transition: transform .3s var(--ease), opacity .3s; max-width: 100%; pointer-events: auto; }
.toast.in { transform: translateY(0); opacity: 1; }
.toast svg { width: 20px; height: 20px; color: var(--lime); flex: none; }

/* Empty */
.empty { text-align: center; padding: 48px 24px; }
.empty-ico { width: 72px; height: 72px; border-radius: 50%; background: var(--linen); color: var(--forest); display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; }
.empty-ico svg { width: 32px; height: 32px; }
.empty h3 { font-size: 20px; font-weight: 700; color: var(--obsidian); margin: 0 0 6px; }
.empty p { margin: 0 0 20px; color: var(--slate); font-size: 15px; line-height: 1.5; }

/* ---------- Onboarding ---------- */
.ob { position: absolute; inset: 0; z-index: 45; overflow: hidden; background: var(--ground); display: flex; flex-direction: column; padding-top: var(--safe-top); }
.ob-hero { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; padding: 24px 24px 8px; }
.ob-display { font-family: var(--font-display); font-weight: 900; font-size: 60px; line-height: .86; letter-spacing: -0.045em; color: var(--forest); margin: 0 0 20px; }
.ob-lead { font-size: 18px; line-height: 1.5; color: var(--charcoal); margin: 0 0 8px; }
.ob-art { flex: none; margin: 8px 24px 0; }
.ob-foot { padding: 16px 24px calc(var(--safe-bottom) + 12px); display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.ob-steps { display: flex; gap: 6px; padding: 14px 24px 0; }
.ob-steps span { height: 4px; flex: 1; border-radius: 2px; background: var(--fog); }
.ob-steps span.on { background: var(--forest); }

.mini-invoice { background: var(--forest); border-radius: var(--r-lg); padding: 20px; color: var(--paper); }
.mini-invoice .mi-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.mini-invoice .mi-amt { font-family: var(--font-display); font-weight: 900; font-size: 40px; letter-spacing: -0.035em; line-height: 1; }
.mini-invoice .mi-line { display: flex; justify-content: space-between; font-size: 14px; color: var(--on-ink-muted); padding: 8px 0; border-top: 1px solid rgba(255,255,255,.14); }
.mini-invoice .mi-paid { display: inline-flex; align-items: center; gap: 6px; background: var(--lime); color: var(--forest); font-weight: 600; font-size: 13px; padding: 4px 12px; border-radius: var(--r-pill); }
.mini-invoice .mi-paid svg { width: 16px; height: 16px; }

/* ---------- Paywall ---------- */
.pw-head { padding: 8px 0 16px; }
.plans { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.plan { width: 100%; text-align: left; border: 0; background: var(--fog-2); border-radius: var(--r-sm); padding: 16px; display: flex; gap: 12px; align-items: flex-start; box-shadow: var(--ring-inset); }
.plan.on { background: var(--linen); box-shadow: inset 0 0 0 2px var(--forest); }
.plan-radio { width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--pebble); flex: none; margin-top: 2px; display: flex; align-items: center; justify-content: center; }
.plan.on .plan-radio { box-shadow: inset 0 0 0 7px var(--forest); }
.plan-name { font-size: 17px; font-weight: 700; color: var(--obsidian); display: flex; gap: 8px; align-items: center; }
.plan-desc { font-size: 14px; color: var(--charcoal); margin-top: 4px; line-height: 1.45; }
.plan-price { margin-left: auto; text-align: right; flex: none; }
.plan-price b { display: block; font-size: 17px; color: var(--obsidian); }
.plan-price span { font-size: 12px; color: var(--slate); }
.feat { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; color: var(--charcoal); padding: 6px 0; line-height: 1.45; }
.feat svg { width: 20px; height: 20px; color: var(--forest); flex: none; margin-top: 1px; }

/* ---------- Reports ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.stat { background: var(--fog-2); border-radius: var(--r-sm); padding: 16px; }
.stat span { font-size: 13px; color: var(--slate); font-weight: 500; }
.stat b { display: block; font-size: 22px; font-weight: 700; color: var(--obsidian); letter-spacing: -0.02em; margin-top: 4px; }
.stat.dark { background: var(--forest); }
.stat.dark span { color: var(--on-ink-muted); }
.stat.dark b { color: var(--paper); }
.bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; align-items: end; height: 150px; padding: 16px 16px 0; }
.bar-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; border: 0; background: none; padding: 0; }
.bar { width: 100%; border-radius: 6px 6px 2px 2px; background: var(--forest); min-height: 3px; transition: height .4s var(--ease); }
.bar.zero { background: var(--fog); }
.bar-col.on .bar { background: var(--spruce); box-shadow: 0 0 0 2px var(--lime); }
.bar-lbl { font-size: 11px; color: var(--slate); padding-bottom: 12px; }
.chart-card { background: var(--fog-2); border-radius: var(--r-sm); margin-bottom: 12px; }
.chart-cap { display: flex; justify-content: space-between; padding: 16px 16px 0; font-size: 14px; color: var(--slate); }
.chart-cap b { color: var(--obsidian); font-size: 15px; }
.progress { height: 6px; border-radius: 3px; background: var(--fog); overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; background: var(--forest); border-radius: 3px; }

/* ---------- Templates ---------- */
.tpl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tpl { border: 0; padding: 0; background: none; text-align: center; font-size: 13px; font-weight: 500; color: var(--charcoal); }
.tpl-thumb { aspect-ratio: 612/792; border-radius: 8px; overflow: hidden; background: var(--paper); box-shadow: var(--ring); margin-bottom: 6px; position: relative; }
.tpl.on .tpl-thumb { box-shadow: 0 0 0 2px var(--forest), 0 0 0 5px var(--linen); }
.tpl.on { color: var(--forest); font-weight: 700; }
.tpl-thumb .pdf { pointer-events: none; }
.swatches { display: flex; flex-wrap: wrap; gap: 12px; }
.swatch { width: 44px; height: 44px; border-radius: 50%; border: 0; display: flex; align-items: center; justify-content: center; color: #fff; }
.swatch svg { width: 20px; height: 20px; }
.swatch.on { box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--obsidian); }

/* Preview frame */
.preview-wrap { background: var(--fog); margin: 0 -16px; padding: 16px; }
.preview-page { background: var(--paper); box-shadow: var(--ring); border-radius: 4px; overflow: hidden; }
.preview-page .pdf { zoom: .585; }
.tpl-thumb .pdf { zoom: .17; }

/* Client portal */
.portal { background: var(--fog-2); min-height: 100%; }
.portal-bar { display: flex; align-items: center; gap: 8px; margin: 0 16px 12px; padding: 8px 14px; border-radius: var(--r-pill); background: var(--paper); box-shadow: var(--ring); font-size: 13px; color: var(--slate); }
.portal-bar svg { width: 14px; height: 14px; }
.pay-methods { display: flex; flex-direction: column; gap: 10px; }

/* Help */
details.faq { background: var(--fog-2); border-radius: var(--r-sm); margin-bottom: 8px; }
details.faq summary { list-style: none; padding: 16px; font-size: 16px; font-weight: 500; color: var(--obsidian); cursor: pointer; display: flex; justify-content: space-between; gap: 12px; }
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary svg { width: 18px; height: 18px; color: var(--forest); transition: transform .2s; flex: none; margin-top: 2px; }
details.faq[open] summary svg { transform: rotate(180deg); }
details.faq p { margin: 0; padding: 0 16px 16px; font-size: 15px; line-height: 1.55; color: var(--charcoal); }

.suggest { background: var(--paper); border-radius: var(--r-sm); box-shadow: var(--ring); margin-top: -8px; margin-bottom: 14px; overflow: hidden; }
.suggest .row { min-height: 48px; padding: 8px 14px; }

.kv { display: flex; justify-content: space-between; font-size: 15px; padding: 6px 0; }
.kv span { color: var(--slate); }
.kv b { color: var(--obsidian); font-weight: 600; }

.qr-box { width: 120px; height: 120px; background: var(--paper); border-radius: var(--r-sm); padding: 8px; box-shadow: var(--ring); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.hidden-input { display: none; }

:focus-visible { outline: 2px solid var(--forest); outline-offset: 2px; }
.row .check { width: 22px; height: 22px; color: var(--forest); flex: none; }
.row:disabled { opacity: .5; cursor: default; }
.avatar svg { width: 20px; height: 20px; }

/* ---------- v2 additions ---------- */
.wordmark { font-family: var(--font-display); font-weight: 900; letter-spacing: -0.03em; color: var(--forest); line-height: 1; }
.lockup .logo-mark { flex: none; display: block; }
.badge svg { width: 12px; height: 12px; stroke-width: 2.2; }
.avatar.t-linen { background: var(--linen); color: var(--forest); }
.avatar.t-blue { background: var(--blue-soft); color: var(--blue); }
.avatar.t-amber { background: var(--amber-soft); color: var(--amber); }
.avatar.t-red { background: var(--red-soft); color: #a51d24; }
.avatar.t-fog { background: var(--fog); color: var(--forest); }
.hero-top { display: flex; justify-content: space-between; align-items: center; }
.hero-divider { height: 1px; background: rgba(255,255,255,.16); margin: 0 0 14px; }
.hero-stat span.lbl { display: flex; align-items: center; gap: 6px; }
.hero-stat span.lbl svg { width: 14px; height: 14px; }
.month-head.soft { text-transform: none; letter-spacing: -0.005em; font-size: 14px; font-weight: 500; color: var(--slate); }

/* Onboarding v2 */
.ob-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; padding: 8px 24px 0; scrollbar-width: none; }
.ob-body::-webkit-scrollbar { display: none; }
.ob-head { display: flex; align-items: center; gap: 12px; padding: 4px 16px 0; min-height: 52px; }
.ob-head .ob-steps { flex: 1; padding: 0; }
.ob-anim { animation: obIn .38s var(--ease) both; }
@keyframes obIn { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }
.ob-welcome-title { font-family: var(--font-display); font-weight: 900; font-size: 46px; line-height: .9; letter-spacing: -0.045em; color: var(--forest); margin: 26px 0 14px; }


/* ---------- Invoice document (PDF) templates ---------- */
.pdf {
  --accent: #163300;
  width: 612px; min-height: 792px;
  background: #fff; color: #2b2d2b;
  font-family: var(--font-ui);
  font-size: 11px; line-height: 1.5;
  padding: 44px 44px 36px;
  position: relative;
  display: flex; flex-direction: column;
}
.pdf * { box-sizing: border-box; }
.pdf h1 { margin: 0; font-size: 28px; line-height: 1; letter-spacing: -0.02em; font-weight: 800; color: var(--accent); }
.pdf-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; }
.pdf-brand { display: flex; flex-direction: column; gap: 10px; }
.pdf-logo { width: 72px; height: 72px; object-fit: contain; object-position: left top; }
.pdf-biz-name { font-size: 15px; font-weight: 700; color: #0e0f0c; }
.pdf-small { color: #5e605e; white-space: pre-line; }
.pdf-title { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.pdf-meta { display: grid; grid-template-columns: auto auto; gap: 2px 14px; text-align: right; }
.pdf-meta span { color: #6a6c6a; }
.pdf-meta b { color: #0e0f0c; font-weight: 600; }
.pdf-parties { display: flex; justify-content: space-between; gap: 24px; margin: 28px 0 22px; }
.pdf-label { font-size: 9px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 4px; }
.pdf-client-name { font-size: 13px; font-weight: 700; color: #0e0f0c; }
.pdf-balance-box { text-align: right; }
.pdf-balance-box .amt { font-size: 22px; font-weight: 800; color: #0e0f0c; letter-spacing: -0.02em; }
.pdf-items { width: 100%; border-collapse: collapse; }
.pdf-items th { text-align: left; font-size: 9px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 8px 8px; background: var(--accent); color: #fff; }
.pdf-items th.num, .pdf-items td.num { text-align: right; white-space: nowrap; }
.pdf-items td { padding: 10px 8px; border-bottom: 1px solid #e8ebe6; vertical-align: top; }
.pdf-items .desc { font-weight: 600; color: #0e0f0c; }
.pdf-items .det { color: #6a6c6a; white-space: pre-line; margin-top: 2px; }
.pdf-bottom { display: flex; justify-content: space-between; gap: 28px; margin-top: 18px; }
.pdf-left { flex: 1; display: flex; flex-direction: column; gap: 14px; }
.pdf-totals { width: 230px; border-collapse: collapse; flex: none; align-self: flex-start; }
.pdf-totals td { padding: 5px 8px; }
.pdf-totals td:last-child { text-align: right; white-space: nowrap; color: #0e0f0c; }
.pdf-totals tr.tot td { font-weight: 700; border-top: 1px solid #d5d8d3; padding-top: 8px; }
.pdf-totals tr.bal td { background: var(--accent); color: #fff !important; font-weight: 700; font-size: 13px; padding: 9px 8px; }
.pdf-pay { display: flex; gap: 14px; align-items: flex-start; }
.pdf-qr { width: 78px; height: 78px; flex: none; }
.pdf-online { display: inline-flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.pdf-online span { border: 1px solid #d5d8d3; border-radius: 99px; padding: 1px 8px; font-size: 9px; font-weight: 600; color: #454745; }
.pdf-photos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 22px; }
.pdf-photos figure { margin: 0; }
.pdf-photos img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 4px; }
.pdf-photos figcaption { font-size: 9px; color: #6a6c6a; margin-top: 3px; }
.pdf-sigs { display: flex; gap: 40px; margin-top: 26px; }
.pdf-sig { width: 200px; }
.pdf-sig img { height: 48px; object-fit: contain; object-position: left bottom; }
.pdf-sig .sig-rule { border-top: 1px solid #454745; padding-top: 4px; color: #6a6c6a; font-size: 9px; }
.pdf-foot { margin-top: auto; padding-top: 24px; text-align: center; color: #868685; font-size: 9px; }
.pdf-stamp {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%) rotate(-18deg);
  border: 8px solid #1f7a2e; color: #1f7a2e;
  font-size: 96px; font-weight: 800; letter-spacing: .1em; line-height: 1;
  padding: 10px 36px; border-radius: 18px; opacity: .13;
  pointer-events: none;
}
.pdf-stamp.declined { border-color: #cb272f; color: #cb272f; }

/* Template: Modern — full-width colour band */
.tpl-modern { padding-top: 0; }
.tpl-modern .pdf-head { margin: 0 -44px; padding: 36px 44px 28px; background: var(--accent); color: #fff; }
.tpl-modern .pdf-head .pdf-biz-name, .tpl-modern .pdf-head h1, .tpl-modern .pdf-head .pdf-meta b { color: #fff; }
.tpl-modern .pdf-head .pdf-small, .tpl-modern .pdf-head .pdf-meta span { color: rgba(255,255,255,.78); }
.tpl-modern .pdf-logo { background: #fff; border-radius: 8px; padding: 6px; }

/* Template: Classic — ruled, restrained */
.tpl-classic h1 { font-family: Georgia, "Times New Roman", serif; font-weight: 700; letter-spacing: 0; color: #0e0f0c; font-size: 30px; }
.tpl-classic .pdf-head { border-bottom: 3px double var(--accent); padding-bottom: 18px; }
.tpl-classic .pdf-items th { background: none; color: var(--accent); border-bottom: 2px solid var(--accent); padding-left: 0; }
.tpl-classic .pdf-items td { padding-left: 0; }

/* Template: Bold — giant display title */
.tpl-bold h1 { font-family: var(--font-display); font-weight: 900; font-size: 64px; letter-spacing: -0.05em; line-height: .85; text-transform: uppercase; }
.tpl-bold .pdf-items th { background: #0e0f0c; }
.tpl-bold .pdf-totals tr.bal td { background: #0e0f0c; }
.tpl-bold .pdf-parties { border-top: 6px solid var(--accent); padding-top: 18px; }

/* Template: Minimal — monochrome, accent only on balance */
.tpl-minimal h1 { font-weight: 500; color: #0e0f0c; font-size: 22px; letter-spacing: .12em; text-transform: uppercase; }
.tpl-minimal .pdf-label { color: #868685; }
.tpl-minimal .pdf-items th { background: none; color: #868685; border-bottom: 1px solid #0e0f0c; padding-left: 0; }
.tpl-minimal .pdf-items td { padding-left: 0; }
.tpl-minimal .pdf-totals tr.bal td { background: none; color: var(--accent) !important; border-top: 2px solid var(--accent); font-size: 15px; }

/* Template: Corporate — side column */
.tpl-corporate { padding-left: 176px; }
.tpl-corporate::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 148px; background: var(--accent); }
.tpl-corporate .pdf-head { flex-direction: column-reverse; }
.tpl-corporate .pdf-brand { position: absolute; left: 20px; top: 44px; width: 110px; color: #fff; }
.tpl-corporate .pdf-brand .pdf-biz-name { color: #fff; font-size: 13px; }
.tpl-corporate .pdf-brand .pdf-small { color: rgba(255,255,255,.8); font-size: 9.5px; word-break: break-word; }
.tpl-corporate .pdf-logo { background: #fff; border-radius: 6px; padding: 4px; width: 64px; height: 64px; }
.tpl-corporate .pdf-title { text-align: left; align-items: flex-start; }
.tpl-corporate .pdf-meta { text-align: left; }
.tpl-corporate .pdf-totals { width: 200px; }

/* Template: Elegant — centred serif */
.tpl-elegant { font-family: Georgia, "Times New Roman", serif; }
.tpl-elegant .pdf-head { flex-direction: column; align-items: center; text-align: center; }
.tpl-elegant .pdf-brand { align-items: center; }
.tpl-elegant .pdf-logo { object-position: center; }
.tpl-elegant .pdf-title { align-items: center; text-align: center; }
.tpl-elegant h1 { font-family: Georgia, serif; font-weight: 400; font-style: italic; font-size: 34px; letter-spacing: 0; }
.tpl-elegant .pdf-meta { text-align: center; }
.tpl-elegant .pdf-items th { background: none; color: var(--accent); border-top: 1px solid var(--accent); border-bottom: 1px solid var(--accent); }
.tpl-elegant .pdf-totals tr.bal td { background: none; color: var(--accent) !important; border-top: 1px solid var(--accent); border-bottom: 1px solid var(--accent); }

/* ---------- Print: only the document ---------- */
#print-root { display: none; }

/* Artboard frame */
.app { position: relative; width: 390px; height: 844px; overflow: hidden; background: var(--ground); isolation: isolate; --safe-top: 54px; --safe-bottom: 34px; }
.statusbar { position: absolute; left: 0; right: 0; top: 0; height: 54px; z-index: 100; display: flex; align-items: center; justify-content: space-between; padding: 4px 34px 0 42px; pointer-events: none; font-size: 16px; font-weight: 600; color: var(--obsidian); letter-spacing: -0.01em; }
.statusbar .sb-icons { display: flex; gap: 6px; align-items: center; }
.statusbar svg { display: block; }
a.fab, a.btn, a.row, a.doc-row, a.tab, a.icon-btn, a.nav-text-btn, a.plan, a.tpl, a.seg-link { text-decoration: none; }
a.row, a.doc-row { color: inherit; }
a.tab { color: var(--slate); }
a.tab.on { color: var(--forest); }
.seg a { flex: none; min-height: 40px; padding: 0 18px; border-radius: var(--r-pill); background: var(--fog-2); color: var(--charcoal); font-size: 15px; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.seg.full a { background: none; min-height: 36px; }
.seg a.on { background: var(--forest); color: var(--paper); }
.seg.full a.on { background: var(--paper); color: var(--forest); box-shadow: var(--ring); font-weight: 600; }
