@font-face { font-family: 'Fraunces'; src: url('/fonts/Fraunces.ttf') format('truetype'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Montserrat'; src: url('/fonts/Montserrat.ttf') format('truetype'); font-weight: 100 900; font-display: swap; }

:root {
  --red: #E10600; --red-soft: #FFECEA; --ink: #0A0A0A; --cream: #F7F4EE; --white: #FFFFFF;
  --muted: #78736C; --line: #E4DED4; --green: #168C46; --green-wa: #25A85A; --green-soft: #E5F4EA;
  --amber: #A15C00; --amber-soft: #FFF3DC;
  --radius: 14px; --nav-h: 64px;
  --serif: 'Fraunces', Georgia, serif; --sans: 'Montserrat', system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--cream); color: var(--ink); font-family: var(--sans); font-weight: 400; font-size: 15px; line-height: 1.4; }
body { min-height: 100vh; min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--red); }
.boot { display: grid; place-items: center; min-height: 100vh; }

/* ---------- shell ---------- */
.shell { max-width: 520px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; background: var(--cream); }
.top { background: var(--white); border-bottom: 1px solid var(--line); padding: calc(14px + env(safe-area-inset-top)) 20px 14px; position: sticky; top: 0; z-index: 5; }
.top .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.top .logo { height: 34px; width: auto; display: block; }
.top .back { border: 0; background: none; padding: 6px 0; color: var(--muted); font-size: 14px; cursor: pointer; }
.top h1 { font-family: var(--serif); font-weight: 800; font-size: 28px; line-height: 1.1; margin: 14px 0 2px; letter-spacing: -0.01em; font-variation-settings: 'opsz' 72; }
.top .sub { color: var(--muted); font-size: 13px; margin: 0; }
main { flex: 1; padding: 16px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); }
nav.tabs { position: fixed; bottom: 0; left: 0; right: 0; background: var(--white); border-top: 1px solid var(--line); display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
nav.tabs .in { display: flex; width: 100%; max-width: 520px; }
nav.tabs a { flex: 1; height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); text-decoration: none; font-size: 12px; }
nav.tabs a svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; }
nav.tabs a.on { color: var(--red); font-weight: 600; }

/* ---------- building blocks ---------- */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card.tap { cursor: pointer; display: block; color: inherit; text-decoration: none; }
.card.tap:active { background: #FBFAF7; }
.label { color: var(--muted); font-size: 12px; margin: 0 0 4px; }
.big { font-family: var(--serif); font-weight: 800; font-size: 32px; line-height: 1.1; margin: 2px 0 4px; font-variation-settings: 'opsz' 72; letter-spacing: -0.01em; }
.red { color: var(--red); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.section-title { font-family: var(--serif); font-weight: 700; font-size: 19px; margin: 22px 4px 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 .card { margin-bottom: 0; }
.grid2 > * { min-width: 0; }
.input { min-width: 0; max-width: 100%; }
input[type=time].input, input[type=date].input { padding-right: 8px; }
.tile .big { font-size: 22px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { display: inline-block; border-radius: 999px; padding: 4px 11px; font-size: 11px; font-weight: 600; white-space: nowrap; letter-spacing: .01em; }
.pill.draft { background: #EFECE6; color: var(--muted); }
.pill.sent, .pill.unbilled { background: var(--red-soft); color: var(--red); }
.pill.partially_paid { background: var(--amber-soft); color: var(--amber); }
.pill.paid, .pill.billed { background: var(--green-soft); color: var(--green); }
.pill.running { background: var(--red); color: var(--white); }
.amount { font-weight: 600; font-size: 16px; white-space: nowrap; }
.list-item .title { font-size: 16px; margin: 0; }
.list-item .meta { color: var(--muted); font-size: 12.5px; margin: 2px 0 0; }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; }

/* ---------- forms ---------- */
.field { margin-bottom: 12px; }
.field label { display: block; color: var(--muted); font-size: 12px; margin: 0 0 6px 4px; }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line); background: var(--white); border-radius: 10px; padding: 12px 14px; font-size: 16px; min-height: 48px; outline: none; appearance: none; -webkit-appearance: none; }
select.input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9'%3E%3Cpath d='M0 0h14L7 9z' fill='%2378736C'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 16px center; padding-right: 40px; }
textarea.input { min-height: 84px; resize: vertical; }
.input:focus { border-color: var(--ink); }
.check { display: flex; align-items: center; gap: 10px; margin: 6px 4px 14px; }
.check input { width: 20px; height: 20px; accent-color: var(--red); }

.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px; border-radius: 999px; border: 1.5px solid transparent; background: var(--red); color: var(--white); font-size: 15.5px; font-weight: 600; cursor: pointer; text-decoration: none; padding: 0 18px; margin: 0 0 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ink { background: var(--ink); }
.btn.wa { background: var(--green-wa); }
.btn.ghost { background: transparent; color: var(--red); border-color: var(--red); }
.btn.ghost-green { background: transparent; color: var(--green); border-color: var(--green); }
.btn.ghost-ink { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.small { min-height: 40px; font-size: 14px; width: auto; display: inline-flex; margin: 0; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-row .btn { margin: 0 0 10px; }
.linkbtn { background: none; border: 0; color: var(--red); font-weight: 600; padding: 10px 4px; cursor: pointer; font-size: 14px; }

/* ---------- timer ---------- */
.timer { border-color: var(--ink); }
.timer .clock { font-family: var(--serif); font-weight: 800; font-size: 46px; letter-spacing: .01em; font-variant-numeric: tabular-nums; margin: 6px 0 2px; font-variation-settings: 'opsz' 40; }
.timer .live { color: var(--red); font-weight: 600; font-size: 18px; }
.warn { background: var(--amber-soft); color: var(--amber); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin: 10px 0; font-weight: 500; }
.err { background: var(--red-soft); color: var(--red); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin: 10px 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); display: inline-block; margin-right: 6px; animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .25; } }

/* ---------- month switcher ---------- */
.monthbar { display: flex; align-items: center; justify-content: space-between; margin: 0 0 12px; }
.monthbar button { border: 1px solid var(--line); background: var(--white); border-radius: 999px; width: 40px; height: 40px; font-size: 18px; cursor: pointer; }
.monthbar strong { font-weight: 600; }

/* ---------- invoice preview ---------- */
.inv { padding: 18px 16px; }
.inv .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.inv .head img { height: 30px; }
.inv .head .t { text-align: right; }
.inv .head .t b { font-family: var(--serif); font-weight: 800; font-size: 20px; display: block; letter-spacing: .02em; }
.inv .head .t span { color: var(--red); font-size: 13px; }
.inv .bill { font-size: 13px; margin: 14px 0 12px; }
.inv table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.inv th { background: var(--red); color: var(--white); font-weight: 500; text-align: left; padding: 7px 8px; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
.inv td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.inv td.nw { white-space: nowrap; }
.inv .desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.inv td.r, .inv th.r { text-align: right; white-space: nowrap; }
.inv .totals { margin-top: 12px; }
.inv .totals .row { padding: 3px 0; font-size: 14px; }
.inv .totals .grand { font-family: var(--serif); font-weight: 800; font-size: 22px; color: var(--red); }
.inv .foot { color: var(--muted); font-size: 12px; margin-top: 14px; }

/* ---------- auth ---------- */
.auth { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 24px; text-align: center; max-width: 440px; margin: 0 auto; }
.auth img.logo { width: 240px; max-width: 80%; margin-bottom: 28px; }
.auth h1 { font-family: var(--serif); font-weight: 800; font-size: 30px; margin: 0 0 8px; }
.auth p { color: var(--muted); margin: 0 0 24px; }
.auth .gbtn:empty { display: none; }
.auth .gbtn { min-height: 44px; margin-bottom: 14px; display: flex; justify-content: center; }
.auth .stop { width: 72px; height: 72px; border-radius: 50%; background: var(--red-soft); color: var(--red); display: grid; place-items: center; font-size: 36px; font-weight: 700; margin-bottom: 18px; }

#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--white); padding: 11px 18px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 50; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.sheet-bg { position: fixed; inset: 0; background: rgba(10,10,10,.4); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--cream); width: 100%; max-width: 520px; border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 90dvh; overflow: auto; }
.sheet h2 { font-family: var(--serif); font-weight: 800; font-size: 22px; margin: 0 0 14px; }
