/* WowProfit — a ledger-green desk with a paper receipt on it. One bold thing: the receipt. */
:root {
  --bg: #163a32;
  --bg-2: #1d4a40;
  --bg-3: #285b4f;
  --on-bg: #eef4f0;
  --on-bg-2: #a8c4b9;
  --paper: #fbfbf7;
  --paper-2: #eff0e9;
  --ink: #1c2420;
  --ink-2: #536059;
  --ink-3: #87918c;
  --rule: #d9dcd3;
  --mark: #f4c542;
  --mark-2: #ffd968;
  --mark-ink: #2b2200;
  --bar: #2b7a63;
  --bar-soft: #a9cfc2;
  --danger: #b33a25;
  --up: #1f7a4f;
  --down: #a6402b;
  --font: 'Bricolage Grotesque', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --r-paper: 6px;
  --r-btn: 14px;
  --gutter: 16px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--on-bg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
:focus-visible { outline: 3px solid var(--mark); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#app { max-width: 480px; margin: 0 auto; padding: 0 var(--gutter) calc(var(--nav-h) + 96px + var(--safe-b)); }

.splash { display: grid; place-items: center; gap: 14px; height: 80dvh; font-weight: 700; font-size: 22px; letter-spacing: -.01em; }
.splash-mark { width: 44px; height: 54px; background: var(--paper); border-radius: 4px 4px 0 0;
  -webkit-mask: linear-gradient(#000 0 0) top/100% calc(100% - 6px) no-repeat, conic-gradient(from 135deg at 50% 0, #000 90deg, #0000 0) bottom/11px 6px repeat-x;
  mask: linear-gradient(#000 0 0) top/100% calc(100% - 6px) no-repeat, conic-gradient(from 135deg at 50% 0, #000 90deg, #0000 0) bottom/11px 6px repeat-x; }

/* ------------------------------------------------------------ top bar */
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: calc(14px + env(safe-area-inset-top, 0px)) 0 10px; }
.brand { font-weight: 800; font-size: 19px; letter-spacing: -.02em; display: flex; align-items: center; gap: 8px; }
.brand::before { content: ''; width: 14px; height: 18px; background: var(--mark); border-radius: 2px 2px 0 0;
  -webkit-mask: linear-gradient(#000 0 0) top/100% calc(100% - 3px) no-repeat, conic-gradient(from 135deg at 50% 0, #000 90deg, #0000 0) bottom/5px 3px repeat-x;
  mask: linear-gradient(#000 0 0) top/100% calc(100% - 3px) no-repeat, conic-gradient(from 135deg at 50% 0, #000 90deg, #0000 0) bottom/5px 3px repeat-x; }
.brand .wow { color: var(--mark); margin-right: -8px; }
.sync { font-size: 13px; color: var(--on-bg-2); display: flex; align-items: center; gap: 6px; }
.sync[data-state='pending']::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--mark); }

.daynav { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; margin: 6px 0 14px; }
.daynav h1 { margin: 0; text-align: center; font-size: 21px; font-weight: 700; letter-spacing: -.01em; line-height: 1.2; }
.daynav h1 small { display: block; font-size: 13px; font-weight: 500; color: var(--on-bg-2); letter-spacing: 0; }
.iconbtn { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; color: var(--on-bg); }
.iconbtn:active { background: var(--bg-2); }
.iconbtn:disabled { opacity: .25; cursor: default; }
.iconbtn svg { width: 22px; height: 22px; }
.backtoday { display: block; margin: -6px auto 14px; padding: 6px 14px; border-radius: 99px; background: var(--bg-2); color: var(--mark-2); font-size: 14px; font-weight: 600; }

/* ------------------------------------------------------------ the receipt */
.receipt {
  position: relative;
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--r-paper) var(--r-paper) 0 0;
  padding: 18px 18px 26px;
  font-family: var(--mono);
  font-size: 15px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, .08);
  margin-bottom: 22px;
}
.receipt::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -9px; height: 10px;
  background: conic-gradient(from 135deg at 50% 0, var(--paper) 90deg, transparent 0) 0 0/18px 10px repeat-x;
}
.r-head { display: flex; justify-content: space-between; color: var(--ink-3); font-size: 12px; padding-bottom: 10px; border-bottom: 1.5px dashed var(--rule); margin-bottom: 4px; }
.r-lines { list-style: none; margin: 0; padding: 0; }
.r-line { display: flex; align-items: baseline; gap: 8px; width: 100%; padding: 9px 2px; text-align: left; border-radius: 4px; }
.r-line:active, .r-line:hover { background: var(--paper-2); }
.r-code { font-weight: 600; }
.r-name { color: var(--ink-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40%; }
.r-dots { flex: 1; border-bottom: 1.5px dotted var(--ink-3); opacity: .5; transform: translateY(-4px); min-width: 12px; }
.r-amt { font-variant-numeric: tabular-nums; }
.r-note { display: block; color: var(--ink-2); font-size: 12px; padding: 0 2px 6px; margin-top: -6px; }
.r-pending .r-amt::after { content: ' ⏳'; }
.r-total { display: flex; justify-content: space-between; align-items: baseline; border-top: 1.5px dashed var(--rule); margin-top: 8px; padding-top: 12px; }
.r-total span:first-child { font-size: 13px; color: var(--ink-2); }
.r-total strong { font-size: 30px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.r-plain { font-weight: 500; color: var(--ink-2); }
.r-split { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 14px; margin-top: 8px; font-size: 12.5px; color: var(--ink-2); }
.r-split b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.r-empty { font-family: var(--font); color: var(--ink-2); padding: 18px 2px 8px; margin: 0; }
.r-count { font-size: 12px; color: var(--ink-3); text-align: right; margin-top: 2px; }
@keyframes print { from { clip-path: inset(0 0 100% 0); transform: translateY(-6px); } to { clip-path: inset(0); transform: none; } }
.r-new { animation: print .45s cubic-bezier(.2, .8, .2, 1); background: #fff5cc; transition: background 1.6s; }
.r-new.r-settled { background: transparent; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { position: relative; display: block; background: var(--bg-2); border-radius: 12px; padding: 10px 30px 11px 14px; color: var(--on-bg-2); text-decoration: none; font-size: 13px; font-weight: 600; }
.stat b { display: block; color: var(--on-bg); font-size: 19px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; margin-top: 1px; }
.stat .chev { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); color: var(--on-bg-2); }
.stat:active { background: var(--bg-3); }
.calbtn { display: flex; align-items: center; justify-content: center; gap: 8px; height: 48px; margin-top: 10px; border-radius: 12px; border: 1.5px solid var(--bg-3); color: var(--mark-2); text-decoration: none; font-weight: 700; }
.calbtn svg, .minibtn svg { width: 20px; height: 20px; }
.calbtn:active { background: var(--bg-2); }

/* ------------------------------------------------------------ add button + nav */
.fab {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + 14px + var(--safe-b));
  width: min(448px, calc(100% - 2 * var(--gutter)));
  height: 60px; border-radius: var(--r-btn);
  background: var(--mark); color: var(--mark-ink);
  font-size: 19px; font-weight: 700; letter-spacing: -.01em;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .28);
  z-index: 5;
}
.fab:active { background: var(--mark-2); transform: translateX(-50%) scale(.985); }
.fab svg { width: 22px; height: 22px; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: #10302a; border-top: 1px solid rgba(255, 255, 255, .08);
  display: flex; justify-content: center;
}
.tabs a { flex: 1; max-width: 160px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--on-bg-2); text-decoration: none; font-size: 12px; font-weight: 600; }
.tabs a svg { width: 24px; height: 24px; }
.tabs a[aria-current='page'] { color: var(--mark); }

/* ------------------------------------------------------------ paper cards (reports, settings) */
.sheetcard { background: var(--paper); color: var(--ink); border-radius: var(--r-paper); padding: 16px; margin-bottom: 14px; }
.sheetcard h2 { margin: 0 0 10px; font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.sheetcard p { margin: 0 0 10px; color: var(--ink-2); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--bg-2); border-radius: 12px; padding: 4px; margin-bottom: 8px; }
.seg button { height: 40px; border-radius: 9px; font-weight: 600; color: var(--on-bg-2); }
.seg button[aria-pressed='true'] { background: var(--paper); color: var(--ink); }

.hero { padding: 6px 2px 18px; }
.hero .big { font-size: 44px; font-weight: 800; letter-spacing: -.035em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.hero .big small { font-size: 22px; font-weight: 600; margin-right: 4px; color: var(--on-bg-2); letter-spacing: 0; }
.hero p { margin: 6px 0 0; color: var(--on-bg-2); }
.hero-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.minibtn { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: 99px; background: var(--bg-2); color: var(--mark-2); text-decoration: none; font-weight: 700; font-size: 14px; margin-top: 4px; }
.minibtn:active { background: var(--bg-3); }

/* calendar: one box per day, the day's total under the date, darker = more profit */
.cal { padding: 12px 10px 14px; }
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-head span { text-align: center; font-size: 12px; font-weight: 600; color: var(--ink-3); padding-bottom: 6px; }
.cal-head span:last-child { color: var(--danger); }
.cd { position: relative; min-height: 56px; border-radius: 8px; padding: 5px 2px 6px; display: flex; flex-direction: column; justify-content: space-between; align-items: center; text-decoration: none; color: var(--ink); background: var(--paper-2); overflow: hidden; }
.cd.out { background: transparent; }
.cd-n { font-size: 13px; font-weight: 600; color: var(--ink-2); line-height: 1; }
.cd-a { font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cd.l1 { background: #fff4cf; }
.cd.l2 { background: #ffe89a; }
.cd.l3 { background: #f9d766; }
.cd.l4 { background: var(--mark); }
.cd.l4 .cd-n, .cd.l3 .cd-n { color: var(--mark-ink); }
.cd.now { box-shadow: inset 0 0 0 2px var(--ink); }
.cd.now .cd-n { color: var(--ink); font-weight: 800; }
.cd.future { opacity: .4; }
a.cd:active { filter: brightness(.94); }
.cal .chart-note { margin-top: 10px; }
.trend-up { color: #8fe0b4; font-weight: 600; }
.trend-down { color: #ffb4a3; font-weight: 600; }

/* chart */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--rule); stroke-width: 1; }
.chart .axis { fill: var(--ink-3); font-size: 11px; font-family: var(--font); }
.chart .bar { fill: var(--bar); }
.chart .bar.dim { fill: var(--bar-soft); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:focus-visible { outline: none; }
.chart .sel { fill: var(--ink); opacity: .06; }
.tip { position: absolute; top: -6px; transform: translate(-50%, -100%); background: var(--ink); color: var(--paper); border-radius: 8px; padding: 6px 10px; font-size: 13px; line-height: 1.35; white-space: nowrap; pointer-events: none; z-index: 2; }
.tip b { font-variant-numeric: tabular-nums; }
.chart-note { font-size: 12px; color: var(--ink-3); margin: 6px 0 0; }

/* supplier rows */
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 0; border-top: 1px solid var(--rule); align-items: baseline; }
.row:first-child { border-top: 0; }
.row .who { font-weight: 700; }
.row .who small { font-weight: 500; color: var(--ink-3); margin-left: 6px; }
.row .amt { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.row .meter { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--paper-2); overflow: hidden; }
.row .meter i { display: block; height: 100%; background: var(--bar); border-radius: 3px; }
.row .meta { grid-column: 1 / -1; font-size: 12px; color: var(--ink-3); }
a.row, button.row { width: 100%; text-align: left; color: inherit; text-decoration: none; }
.daylist .row { grid-template-columns: 1fr auto 18px; align-items: center; }
.daylist .row .who { font-weight: 600; }
.daylist .row .who small { display: block; margin: 0; }
.chev { color: var(--ink-3); width: 18px; height: 18px; }

details.more { border-top: 1px solid var(--rule); }
details.more summary { cursor: pointer; padding: 12px 0 4px; font-weight: 600; color: var(--bar); list-style-position: inside; }

/* paper surfaces use light form controls (checkbox, date picker) */
.sheet, .sheetcard { color-scheme: light; accent-color: var(--bar); }

/* settings */
.btn { height: 50px; border-radius: var(--r-btn); padding: 0 18px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-ink { background: var(--ink); color: var(--paper); }
.btn-line { border: 1.5px solid var(--rule); color: var(--ink); background: transparent; }
.btn-danger { color: var(--danger); border: 1.5px solid #e6c2bb; background: transparent; }
.btn-wide { width: 100%; }
.stack { display: grid; gap: 10px; }
.tag { font-size: 12px; color: var(--ink-3); border: 1px solid var(--rule); border-radius: 99px; padding: 1px 8px; margin-left: 6px; font-weight: 500; }
.foot { text-align: center; color: var(--on-bg-2); font-size: 13px; margin: 18px 0; }

/* ------------------------------------------------------------ bottom sheet (add / edit) */
.backdrop { position: fixed; inset: 0; background: rgba(6, 20, 16, .55); z-index: 20; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(100%); } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  max-width: 480px; margin: 0 auto; max-height: 94dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--paper); color: var(--ink);
  border-radius: 20px 20px 0 0;
  padding: 10px var(--gutter) calc(16px + var(--safe-b));
  animation: rise .28s cubic-bezier(.2, .8, .2, 1);
}
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--rule); margin: 0 auto 10px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.sheet-head h2 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.sheet-head .iconbtn { color: var(--ink-2); width: 40px; height: 40px; }
.sheet-head .iconbtn:active { background: var(--paper-2); }
.sheet .when { color: var(--ink-2); font-size: 14px; margin: 0 0 12px; }
.label { font-size: 14px; font-weight: 600; color: var(--ink-2); margin: 14px 0 8px; display: block; }
.label em { font-style: normal; font-weight: 500; color: var(--ink-3); }

.chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.chip { min-height: 50px; border-radius: 12px; border: 1.5px solid var(--rule); background: #fff; font-weight: 700; font-size: 16px; padding: 4px 6px; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; }
.chip small { display: block; font-size: 10.5px; font-weight: 500; color: var(--ink-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip[aria-pressed='true'] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip[aria-pressed='true'] small { color: #c9d1cc; }
.chip-new { border-style: dashed; color: var(--ink-2); font-weight: 600; font-size: 14px; }
.newsup { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 8px; }

.field { width: 100%; height: 50px; border-radius: 12px; border: 1.5px solid var(--rule); background: #fff; padding: 0 14px; font-size: 16px; color: var(--ink); }
.field:focus { border-color: var(--ink); outline: none; }

.amount { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; border-bottom: 2px solid var(--ink); padding: 4px 2px 6px; margin-top: 4px; }
.amount span { font-size: 18px; font-weight: 600; color: var(--ink-2); }
.amount output { font-family: var(--mono); font-size: 38px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.amount output.zero { color: var(--ink-3); }
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 2px; min-height: 40px; align-items: center; }
.quick .hint { font-size: 13px; color: var(--ink-3); }
.qbtn { height: 40px; padding: 0 14px; border-radius: 99px; background: #fff3c4; color: var(--mark-ink); font-weight: 700; font-family: var(--mono); border: 1.5px solid #f0d77a; }
.qbtn:active { background: var(--mark); }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.key { height: 50px; border-radius: 12px; background: var(--paper-2); font-size: 23px; font-weight: 600; font-family: var(--mono); }
.key:active { background: var(--rule); }
.key svg { width: 26px; height: 26px; vertical-align: middle; }
.noteline { margin-top: 12px; }
.sheet-actions { display: grid; grid-template-columns: auto 1fr; gap: 10px; margin-top: 14px; }
.sheet-actions.one { grid-template-columns: 1fr; }
.save { height: 58px; border-radius: var(--r-btn); background: var(--mark); color: var(--mark-ink); font-size: 19px; font-weight: 800; }
.save:disabled { background: var(--paper-2); color: var(--ink-3); cursor: default; }
.err { color: var(--danger); font-size: 14px; margin: 8px 0 0; min-height: 0; }

/* ------------------------------------------------------------ PIN screen */
.pin { min-height: 92dvh; display: flex; flex-direction: column; justify-content: center; max-width: 340px; margin: 0 auto; }
.pin .brand { font-size: 26px; justify-content: center; margin-bottom: 8px; }
.pin p { text-align: center; color: var(--on-bg-2); margin: 0 0 22px; }
.dots { display: flex; justify-content: center; gap: 14px; margin-bottom: 10px; }
.dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--on-bg-2); }
.dots i.on { background: var(--mark); border-color: var(--mark); }
.pin .err { text-align: center; color: #ffb4a3; min-height: 22px; }
.pin .keypad { margin-top: 16px; }
.nokey p b { color: var(--on-bg); }
.nokey .small { font-size: 14px; }
.nk-form { display: grid; gap: 10px; }
.nk-form .field { color-scheme: light; }
.btn-mark { background: var(--mark); color: var(--mark-ink); font-size: 17px; }
.btn-mark:active { background: var(--mark-2); }
.pin .key { background: var(--bg-2); color: var(--on-bg); height: 62px; }
.pin .key:active { background: var(--bg-3); }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.shake { animation: shake .35s; }

/* ------------------------------------------------------------ toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 30;
  bottom: calc(var(--nav-h) + 86px + var(--safe-b));
  width: max-content; max-width: calc(100% - 32px);
  background: var(--paper); color: var(--ink); border-radius: 12px; padding: 10px 10px 10px 16px;
  display: flex; align-items: center; gap: 14px; font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
}
.toast button { color: var(--bar); font-weight: 800; padding: 6px 10px; border-radius: 8px; }
.toast.bad { background: #ffe9e4; color: #6d1f12; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (min-width: 700px) {
  .sheet { bottom: 50%; transform: translateY(50%); border-radius: 20px; animation: fade .2s; }
}
