/* Nanmayil · Paper & Ink. Tokens first; phones by default, laptop sidebar from 960px. */
:root {
  --bg: #F5F3EE; --card: #FFFFFF; --ink: #111318; --muted: #5D6270; --line: #E5E1D8; --hair: #EEEBE4; --line-2: #D9D4C9;
  --brand: #196244; --brand-soft: #E1EFE7; --brand-ink: #145238; --deep: #0E3B29; --gold: #E2BE63; --gold-ink: #8A6A1C;
  --danger: #9A2B0E; --danger-soft: #FDE3D8; --warn-soft: #FFF1D2; --warn-ink: #7A5A12;
  --sans: 'Geist', system-ui, sans-serif; --mono: 'Geist Mono', ui-monospace, monospace;
  --r-lg: 22px; --r-md: 16px;
  --top: calc(env(safe-area-inset-top) + 20px); --bottom: calc(env(safe-area-inset-bottom) + 12px);
  --ease: cubic-bezier(.16, 1, .3, 1);
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body { font-family: var(--sans); color: var(--ink); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
#app { position: relative; max-width: 520px; height: 100dvh; margin: 0 auto; display: flex; flex-direction: column; background: var(--bg); overflow: hidden; }
.pane { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.scroll { flex: 1; min-height: 0; overflow-y: auto; padding: var(--top) 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.grow { flex: 1; min-width: 0; }
.mono { font-family: var(--mono); }
.head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
h1, h2 { margin: 0; }
.title { font-size: 30px; font-weight: 800; letter-spacing: -0.04em; }
.sub { font-size: 20px; font-weight: 800; letter-spacing: -0.03em; }
.no { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--muted); }
.caps { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }
.h2 { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.back { width: 44px; height: 44px; margin-left: -10px; border: 0; background: none; display: flex; align-items: center; justify-content: center; flex: none; border-radius: 50%; }
.back:hover { background: rgba(17, 19, 24, .05); }

.btn { min-height: 52px; border-radius: 999px; font-size: 15px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 20px; transition: transform .12s, background .15s, border-color .15s; }
.btn:active { transform: scale(0.98); }
.btn-primary { border: 0; background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(25, 98, 68, .22); }
.btn-primary:hover { background: #15563B; }
.btn-primary:disabled { opacity: .45; box-shadow: none; }
.btn-ghost { border: 1px solid var(--line-2); background: var(--card); }
.btn-ghost:hover { border-color: #BDB7AA; }
.btn-sm { min-height: 44px; font-size: 14px; padding: 0 16px; }
.btn-danger { border: 0; background: none; color: var(--danger); min-height: 44px; font-weight: 700; }
.link { min-height: 32px; padding: 0; border: 0; background: none; color: var(--brand); font-size: 14px; font-weight: 700; }
.see-all { min-height: 40px; display: flex; align-items: center; font-size: 13px; font-weight: 700; color: var(--brand); }

.search { position: relative; }
.search svg { position: absolute; left: 16px; top: 14px; color: var(--muted); pointer-events: none; }
.search input { width: 100%; min-height: 48px; padding: 0 16px 0 46px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-size: 15px; }
.search input:focus, .input:focus { border-color: var(--brand); outline: 0; box-shadow: 0 0 0 3px rgba(25, 98, 68, .12); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; flex: none; }
.chips button { min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--card); font-size: 13px; font-weight: 700; flex: none; transition: background .15s, color .15s; }
.chips button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

.list { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.list > * + * { border-top: 1px solid var(--hair); }
.row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--card); border: 0; width: 100%; text-align: left; min-height: 60px; transition: background .12s; }
a.row:hover, button.row:hover { background: #FBFAF7; }
.row.selected { background: #F1F7F3; }
.row-add { justify-content: center; color: var(--brand); font-size: 15px; font-weight: 700; gap: 8px; }
.tile { width: 40px; height: 40px; border-radius: 12px; flex: none; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 800; }
.tile-q, .tile-c { background: var(--brand-soft); color: var(--brand-ink); }
.tile-i { background: var(--deep); color: var(--gold); }
.tile-cn { background: var(--danger-soft); color: var(--danger); }
.tile-sez { background: var(--warn-soft); color: var(--warn-ink); }
.stack { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.end { align-items: flex-end; flex: none; }
.name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.amt { font-family: var(--mono); font-size: 14px; font-weight: 600; }
.empty { padding: 28px 20px; text-align: center; color: var(--muted); font-size: 14px; background: var(--card); }

.chip { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; border: 0; }
.s-Draft { background: #ECE8DF; color: #4A4F5C; }
.s-Sent { background: #E6ECF7; color: #29457A; }
.s-Issued { background: var(--brand-soft); color: var(--brand-ink); }
.s-Cancelled { background: #ECE8DF; color: #8A8F9A; text-decoration: line-through; }
.s-Accepted { background: var(--warn-soft); color: var(--warn-ink); }
.s-Paid { background: var(--brand); color: #fff; }
.s-Overdue { background: var(--danger-soft); color: var(--danger); }
.s-Declined { background: #F3E4DE; color: #7A3A2A; }
.tag { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--warn-soft); color: var(--warn-ink); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.field { min-height: 62px; padding: 9px 16px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--card); display: flex; flex-direction: column; justify-content: center; gap: 1px; text-align: left; position: relative; transition: border-color .15s; }
button.field:hover, label.field:hover { border-color: var(--line-2); }
.field[disabled] { cursor: default; color: inherit; }
.field .lbl { font-size: 12px; font-weight: 600; color: var(--muted); }
.field .val { font-size: 15px; font-weight: 600; }
.field input[type=date] { border: 0; padding: 0; background: none; font-size: 15px; font-weight: 600; width: 100%; min-height: 24px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.trow { display: flex; justify-content: space-between; align-items: center; font-size: 14px; color: var(--muted); }
.trow .mono { color: var(--ink); }
.rule { height: 1px; background: var(--hair); }
.bar { flex: none; display: flex; gap: 10px; align-items: center; padding: 12px 20px var(--bottom); background: var(--card); border-top: 1px solid var(--line); }
.bar.col { flex-direction: column; align-items: stretch; gap: 10px; }
.bar > * { flex: 1; }
.stepper { flex: none; display: flex; align-items: center; background: var(--card); border: 1.5px solid var(--brand); border-radius: 999px; overflow: hidden; }
.stepper button { width: 44px; height: 44px; border: 0; background: none; color: var(--brand); display: flex; align-items: center; justify-content: center; }
.on-doc { flex: none; display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; color: var(--brand-ink); background: var(--brand-soft); padding: 6px 12px; border-radius: 999px; }
.icon-btn { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--card); color: var(--brand); display: flex; align-items: center; justify-content: center; }
.logo-tile { width: 46px; height: 46px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 800; overflow: hidden; flex: none; }
.logo-tile img { width: 100%; height: 100%; object-fit: cover; }

/* Forms, notes, sheets */
.input { width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); font-size: 15px; }
textarea.input { min-height: 84px; resize: vertical; }
select.input { appearance: auto; }
select.bare { border: 0; background: none; padding: 0; min-height: 24px; font-size: 15px; font-weight: 600; width: 100%; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.hint { font-size: 13px; color: var(--muted); margin: 0; line-height: 1.45; }
.err { color: var(--danger); }
.note { margin: 0; padding: 11px 14px; border-radius: 14px; background: var(--brand-soft); color: var(--brand-ink); font-size: 13px; line-height: 1.45; }
.note.warn { background: var(--warn-soft); color: var(--warn-ink); }
.check { flex-direction: row !important; align-items: flex-start; gap: 10px; color: var(--ink) !important; font-size: 15px !important; font-weight: 500 !important; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--brand); flex: none; }
.problems { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 15px; line-height: 1.4; }
.form-err { margin: 0; font-size: 14px; font-weight: 600; }
.form-err:empty { display: none; }
dialog.sheet { width: 100%; max-width: 520px; max-height: 88dvh; margin: auto auto 0; padding: 20px 20px var(--bottom); border: 0; border-radius: 26px 26px 0 0; background: var(--bg); color: var(--ink); overflow-y: auto; }
dialog.sheet::backdrop { background: rgba(14, 59, 41, .45); }
dialog.sheet[open] { animation: up .24s var(--ease); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px; font-size: 14px; font-weight: 600; z-index: 10; animation: up .2s; max-width: calc(100% - 32px); text-align: center; }

/* Home */
.hello { font-size: 22px; font-weight: 800; letter-spacing: -0.03em; }
.date { font-size: 12px; font-weight: 500; color: var(--muted); }
.round-btn { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--card); border: 1px solid var(--line); flex: none; }
.collect { position: relative; overflow: hidden; border-radius: 26px; padding: 22px; background: var(--deep); color: #F5F3EE; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 18px 40px -18px rgba(14, 59, 41, .6); transition: transform .2s var(--ease); }
.collect:hover { transform: translateY(-2px); }
.collect .wm { position: absolute; right: -30px; bottom: -36px; width: 180px; height: 180px; object-fit: cover; opacity: .16; mix-blend-mode: screen; pointer-events: none; -webkit-mask-image: radial-gradient(circle, #000 45%, transparent 70%); mask-image: radial-gradient(circle, #000 45%, transparent 70%); }
.collect .k { font-size: 13px; font-weight: 600; color: #C7D6CE; }
.collect .big { font-family: var(--mono); font-size: 44px; font-weight: 600; letter-spacing: -0.04em; color: var(--gold); line-height: 1.05; }
.meter { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: #2E5E49; }
.meter span { background: #FF8A65; }
.legend { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; font-weight: 600; color: #C7D6CE; }
.legend .late { color: #FFB49B; }
.action { min-height: 100px; padding: 16px; border-radius: var(--r-lg); display: flex; flex-direction: column; justify-content: space-between; font-size: 16px; font-weight: 700; letter-spacing: -0.01em; background: var(--card); border: 1px solid var(--line); transition: transform .15s var(--ease), box-shadow .15s; }
.action:hover { transform: translateY(-2px); box-shadow: 0 10px 24px -14px rgba(17, 19, 24, .35); }
.action:active { transform: scale(0.97); }
.action.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--brand); }
.dot.late { background: #E2552E; }
.dot.info { background: var(--gold); }
.say { font-size: 12px; font-weight: 500; color: var(--muted); }
.say.late { color: #A33A1A; }
.pill { flex: none; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.pill.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.biz-card { border-radius: var(--r-lg); padding: 18px; background: var(--deep); color: #F5F3EE; display: flex; align-items: center; gap: 14px; }
.biz-card img { width: 58px; height: 58px; border-radius: 16px; object-fit: cover; }
.biz-card .gst { font-family: var(--mono); font-size: 12px; color: var(--gold); }

.home-grid { display: flex; flex-direction: column; gap: 16px; }

/* Navigation: bottom bar with a centre + on phones, deep-green sidebar on laptops */
.tabs { flex: none; display: flex; align-items: center; padding: 8px 10px var(--bottom); background: var(--card); border-top: 1px solid var(--line); }
.tabs.sub { display: none; }
.tabs a { flex: 1; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11px; font-weight: 600; border-radius: 14px; }
.tabs a[aria-current] { color: var(--brand); font-weight: 700; }
.tabs .brand, .fab .fab-l { display: none; }
.fab { width: 54px; height: 54px; margin: 0 6px; border-radius: 50%; border: 0; display: flex; align-items: center; justify-content: center; gap: 8px; background: var(--brand); color: #fff; box-shadow: 0 8px 20px rgba(25, 98, 68, .35); flex: none; transition: transform .15s var(--ease), background .15s; }
.fab:active { transform: scale(.94); }
@media (min-width: 960px) {
  #app { max-width: none; flex-direction: row; }
  .tabs, .tabs.sub { order: -1; display: flex; width: 252px; flex-direction: column; align-items: stretch; gap: 4px; padding: 24px 16px; background: var(--deep); border: 0; }
  .tabs .brand { display: flex; flex: none; flex-direction: row; justify-content: flex-start; align-items: center; gap: 12px; min-height: 0; padding: 0 8px 22px; color: #F5F3EE; }
  .tabs .brand img { width: 42px; height: 42px; border-radius: 12px; }
  .tabs .brand b { display: block; font-size: 17px; font-weight: 800; letter-spacing: -0.02em; }
  .tabs .brand small { font-size: 12px; font-weight: 500; color: #C7D6CE; }
  .fab { width: auto; height: 48px; margin: 0 0 14px; border-radius: 999px; background: var(--gold); color: var(--deep); font-size: 15px; font-weight: 800; box-shadow: none; }
  .fab:hover { background: #EAC977; }
  .fab .fab-l { display: inline; }
  .tabs a:not(.brand) { order: 1; flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; min-height: 46px; padding: 0 14px; color: #C7D6CE; font-size: 14px; }
  .tabs a:not(.brand):hover { background: rgba(255, 255, 255, .06); color: #fff; }
  .tabs a[aria-current]:not(.brand) { background: rgba(255, 255, 255, .1); color: #fff; }
  .scroll, .bar, .pane > .head { padding-left: max(40px, calc((100% - 860px) / 2)) !important; padding-right: max(40px, calc((100% - 860px) / 2)) !important; }
  .scroll { padding-top: 40px; }
  .bar.col { flex-direction: row; }
  .bar.col > * { flex: 1; }
  .home-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 20px; align-items: start; }
  .home-grid > * { min-width: 0; }
  .title { font-size: 34px; }
  .toast { bottom: 32px; }
  dialog.sheet { margin: auto; border-radius: 24px; }
}
@media (min-width: 960px) { .home-grid > section:last-child { grid-column: 1 / -1; } }

/* Preview: A4 is laid out at 760px, zoomed to fit; the PDF maps it to 186 mm */
#app.paper-bg { background: #E9E6DE; }
.paper-fit { width: 100%; display: flex; flex-direction: column; gap: 16px; align-items: center; }
.copies { display: flex; gap: 6px; flex: none; overflow-x: auto; scrollbar-width: none; }
.copies button { min-height: 36px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--card); font-size: 12px; font-weight: 700; flex: none; }
.copies button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.paper { position: relative; width: 760px; min-height: 1114px; padding: 34px 36px 30px; background: #fff; color: var(--ink); font: 11.5px/1.45 var(--sans); box-shadow: 0 1px 2px rgba(17, 19, 24, .08), 0 12px 32px rgba(17, 19, 24, .12); border-radius: 4px; display: flex; flex-direction: column; gap: 14px; overflow: hidden; }
.pp-top { display: flex; justify-content: space-between; gap: 24px; padding-bottom: 14px; border-bottom: 2px solid var(--brand); box-shadow: 0 3px 0 var(--gold); }
.pp-seller { display: flex; gap: 14px; align-items: flex-start; }
.pp-logo { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; }
.pp-biz { font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.pp-trade { font-size: 12px; font-weight: 600; color: var(--deep); margin: 1px 0 3px; }
.pp-gap { color: var(--danger); border: 1px dashed currentColor; padding: 0 4px; border-radius: 3px; }
.pp-title { text-align: right; flex: none; }
.pp-kind { font-size: 21px; font-weight: 800; letter-spacing: .06em; color: var(--brand); }
.pp-no { font: 600 13px var(--mono); margin-top: 2px; }
.pp-amt { font-size: 15px; font-weight: 800; color: var(--deep); margin-top: 2px; font-variant-numeric: tabular-nums; }
.pp-copy { margin-top: 4px; font-size: 9.5px; font-weight: 700; letter-spacing: .1em; color: var(--gold-ink); text-transform: uppercase; }
.pp-not { margin-top: 4px; font-size: 9.5px; font-weight: 700; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; }
.pp-parties { display: flex; gap: 18px; }
.pp-party { flex: 1; min-width: 0; }
.pp-lab { font-size: 9.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 3px; }
.pp-name { font-size: 14px; font-weight: 700; }
.pp-meta { flex: none; width: 250px; display: flex; flex-direction: column; gap: 3px; }
.pp-meta div { display: flex; justify-content: space-between; gap: 10px; }
.pp-meta span { color: var(--muted); }
.pp-meta b { text-align: right; }
.pp-note { padding: 8px 12px; border-radius: 6px; background: #F5F3EE; font-size: 11px; }
.pp-sez { background: #EEF6F2; border: 1px solid #BFDCCD; }
.pp-bad { background: var(--danger-soft); color: var(--danger); font-weight: 700; }
.pp-lines, .pp-sum { border-collapse: collapse; }
.pp-lines { width: 100%; }
.pp-lines th { background: var(--deep); color: #fff; font-size: 9.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 7px 5px; text-align: right; white-space: nowrap; }
.pp-lines td { padding: 8px 5px; border-bottom: 1px solid var(--hair); text-align: right; font-size: 11px; font-variant-numeric: tabular-nums; vertical-align: top; white-space: nowrap; }
.pp-lines .l { text-align: left; font-size: 12.5px; white-space: normal; width: 34%; }
.pp-lines td:first-child, .pp-lines th:first-child { text-align: center; width: 22px; }
.pp-lines tbody tr:nth-child(even) td { background: #FBFAF7; }
.pp-bottom { display: flex; gap: 20px; align-items: flex-start; justify-content: space-between; }
.pp-sum { font-size: 10.5px; }
.pp-sum th { font-size: 9.5px; color: var(--muted); text-align: right; padding: 4px 8px; border-bottom: 1px solid var(--ink); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.pp-sum td { text-align: right; padding: 4px 8px; font-variant-numeric: tabular-nums; border-bottom: 1px solid var(--hair); }
.pp-totals { width: 300px; font-variant-numeric: tabular-nums; display: flex; flex-direction: column; gap: 4px; }
.pp-totals div { display: flex; justify-content: space-between; }
.pp-grand { margin-top: 6px; padding: 12px 14px; background: var(--deep); color: #fff; border-radius: 6px; font-size: 20px; font-weight: 800; }
.pp-grand span:last-child { color: var(--gold); }
.pp-words { margin-top: auto; padding: 8px 0; border-top: 1px solid var(--hair); border-bottom: 1px solid var(--hair); }
.pp-foot { display: flex; justify-content: space-between; gap: 24px; align-items: flex-end; }
.pp-fine { flex: 1; display: flex; flex-direction: column; gap: 8px; font-size: 10.5px; color: #4A4F5C; }
.pp-sign { width: 220px; text-align: center; font-size: 11px; }
.pp-sign img { display: block; max-width: 180px; max-height: 64px; margin: 6px auto; object-fit: contain; }
.pp-signspace { height: 56px; }
.pp-signlab { border-top: 1px solid var(--ink); padding-top: 4px; font-weight: 600; }
.pp-mark { position: absolute; top: 42%; left: 50%; transform: translate(-50%, -50%) rotate(-24deg); font-size: 120px; font-weight: 800; letter-spacing: .1em; color: rgba(154, 43, 14, .08); pointer-events: none; white-space: nowrap; }
.pp-m { color: var(--muted); }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
