/* VCG Receipts: clean, Cloudflare-inspired UI */
:root {
  --bg: #f6f6f7;
  --bg-dot: #e4e4e7;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --hover: #f3f3f5;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #18181b;
  --muted: #71717a;
  --faint: #a1a1aa;
  --accent: #f6821f;
  --accent-hover: #e5730f;
  --accent-soft: #fff3e8;
  --accent-text: #c2570a;
  --link: #0051c3;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --ok: #16a34a;
  --ok-soft: #f0fdf4;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 1px 1px rgba(0,0,0,.02);
  --shadow-lg: 0 12px 40px -8px rgba(0,0,0,.18), 0 2px 6px rgba(0,0,0,.06);
  --radius: 10px;
  --radius-sm: 7px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    --bg: #0e0e10; --bg-dot: #1d1d21; --surface: #161619; --surface-2: #1b1b1f; --hover: #222227;
    --border: #2a2a30; --border-strong: #3a3a42; --text: #ededf0; --muted: #a1a1aa; --faint: #6b6b74;
    --accent-soft: rgba(246,130,31,.13); --accent-text: #fb9a45; --link: #6ba6ff;
    --danger: #f87171; --danger-soft: rgba(248,113,113,.1); --ok: #4ade80; --ok-soft: rgba(74,222,128,.1);
    --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 16px 48px -8px rgba(0,0,0,.7), 0 2px 8px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
[data-theme="dark"] {
  --bg: #0e0e10; --bg-dot: #1d1d21; --surface: #161619; --surface-2: #1b1b1f; --hover: #222227;
  --border: #2a2a30; --border-strong: #3a3a42; --text: #ededf0; --muted: #a1a1aa; --faint: #6b6b74;
  --accent-soft: rgba(246,130,31,.13); --accent-text: #fb9a45; --link: #6ba6ff;
  --danger: #f87171; --danger-soft: rgba(248,113,113,.1); --ok: #4ade80; --ok-soft: rgba(74,222,128,.1);
  --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 16px 48px -8px rgba(0,0,0,.7), 0 2px 8px rgba(0,0,0,.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text);
  background: var(--bg); -webkit-font-smoothing: antialiased; min-height: 100vh;
  transition: background-color .2s ease, color .2s ease;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { display: block; }
.ico { display: inline-flex; width: 16px; height: 16px; flex: none; }
.ico svg { width: 100%; height: 100%; }
.num, .mono { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface);
  font-weight: 500; white-space: nowrap; transition: background .12s, border-color .12s, transform .06s, box-shadow .12s;
  box-shadow: var(--shadow);
}
.btn:hover { background: var(--hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.block { width: 100%; height: 40px; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 36px; padding: 0; }
.btn .spinner { width: 14px; height: 14px; border-color: rgba(255,255,255,.4); border-top-color: #fff; }

.field { display: grid; gap: 6px; }
.field + .field { margin-top: 16px; }
.label { font-weight: 600; font-size: 13px; display: flex; align-items: baseline; gap: 6px; }
.label .opt { font-weight: 400; color: var(--faint); font-size: 12px; }
.hint { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: flex-start; }
.hint .ico { width: 14px; height: 14px; margin-top: 2px; color: var(--accent); }
.input, .textarea {
  width: 100%; height: 40px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); outline: none; transition: border-color .12s, box-shadow .12s; font-size: 15px;
}
.textarea { height: auto; min-height: 72px; padding: 10px 12px; resize: vertical; line-height: 1.45; }
.input:focus, .textarea:focus, .affix:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
input[type="date"].input { appearance: none; -webkit-appearance: none; min-width: 0; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }

.affix {
  display: flex; align-items: stretch; height: 40px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); overflow: hidden; transition: border-color .12s, box-shadow .12s;
}
.affix .pre {
  display: grid; place-items: center; padding: 0 12px; background: var(--surface-2); color: var(--muted);
  font-weight: 700; font-family: var(--mono); font-size: 15px; letter-spacing: .02em; user-select: none;
}
.affix .pre.word { font-family: var(--font); font-weight: 600; font-size: 13px; letter-spacing: 0; }
.affix input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; padding: 0 12px; font-size: 15px; }
.affix input.code { font-family: var(--mono); font-weight: 600; letter-spacing: .04em; }
.affix .post { display: grid; place-items: center; padding: 0 6px; }
.eye { border: 0; background: transparent; color: var(--muted); width: 34px; height: 34px; border-radius: 6px; display: grid; place-items: center; }
.eye:hover { background: var(--hover); color: var(--text); }
.eye .ico { width: 18px; height: 18px; }

.err { color: var(--danger); background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent); padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px; }
.err:empty { display: none; }

/* ---------- auth ---------- */
.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(600px 300px at 50% -60px, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
    radial-gradient(var(--bg-dot) 1px, transparent 1px) 0 0 / 18px 18px,
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 28px; box-shadow: var(--shadow-lg); animation: rise .35s cubic-bezier(.2,.8,.2,1);
}
.auth-card h1 { font-size: 21px; margin: 18px 0 4px; letter-spacing: -.01em; }
.auth-card .sub { color: var(--muted); margin: 0 0 22px; }
.auth-card form { display: grid; gap: 14px; }
.auth-card .field + .field { margin-top: 0; }
.auth-switch { text-align: center; margin-top: 18px; color: var(--muted); font-size: 13px; }
.auth-switch button { background: none; border: 0; color: var(--link); padding: 0; font-weight: 500; }
.auth-foot { display: flex; justify-content: center; margin-top: 18px; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: -.01em; font-size: 15px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand .mark { width: 26px; height: 26px; }
.brand small { font-weight: 500; color: var(--muted); font-size: 13px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; height: 56px; display: flex; align-items: center; gap: 10px;
  padding: 0 max(16px, env(safe-area-inset-left)); background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(12px); -webkit-backdrop-filter: saturate(1.6) blur(12px);
  box-shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px -8px rgba(0,0,0,.08);
}
.topbar .spacer { flex: 1; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 9px; background: var(--hover); border: 1px solid var(--border); }
.seg button { border: 0; background: transparent; width: 30px; height: 26px; border-radius: 6px; display: grid; place-items: center; color: var(--muted); }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow), 0 0 0 1px var(--border); }
.seg .ico { width: 15px; height: 15px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border); background: var(--accent-soft);
  color: var(--accent-text); font-weight: 700; display: grid; place-items: center; text-transform: uppercase; font-size: 13px;
}

/* ---------- layout ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 20px max(16px, env(safe-area-inset-left)) 64px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 16px 18px 0; }
.card-h h2 { font-size: 14px; margin: 0; font-weight: 650; }
.card-b { padding: 18px; }

/* window bar */
.wbar { display: grid; grid-template-columns: auto 1fr auto; gap: 1px; align-items: stretch; overflow: hidden; background: var(--border); }
.wbar > * { background: var(--surface); }
.wpick {
  display: flex; align-items: center; gap: 12px; padding: 16px 18px; border: 0; background: transparent; text-align: left;
  min-width: 170px; transition: background .12s;
}
.wpick:hover { background: var(--hover); }
.wpick .k { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.wpick .v { font-size: 26px; font-weight: 750; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.wpick .chev { margin-left: auto; color: var(--muted); }
.wstats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 14px 18px 12px; gap: 18px; align-content: center; }
.stat .k { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 20px; font-weight: 700; letter-spacing: -.015em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .v.neg { color: var(--danger); }
.stat .v.pos { color: var(--ok); }
.editable { border: 0; background: transparent; padding: 0; text-align: left; border-radius: 6px; display: flex; align-items: center; gap: 6px; max-width: 100%; }
.editable .ico { width: 13px; height: 13px; color: var(--faint); opacity: 0; transition: opacity .12s; }
.editable:hover .ico, .editable:focus-visible .ico { opacity: 1; }
@media (hover: none) { .editable .ico { opacity: 1; } }
.budget-input { height: 32px; font-size: 18px; font-weight: 700; width: 160px; padding: 0 8px; }
.meter { grid-column: 1 / -1; }
.bar { position: relative; height: 8px; border-radius: 99px; background: var(--hover); overflow: hidden; display: flex; gap: 2px; box-shadow: inset 0 0 0 1px var(--border); }
.bar span { height: 100%; transition: width .5s cubic-bezier(.2,.8,.2,1); min-width: 3px; }
.bar span:first-child { border-radius: 99px 0 0 99px; }
.bar span:last-child { border-radius: 0 99px 99px 0; }
.bar span:only-child { border-radius: 99px; }
.bar.over { box-shadow: inset 0 0 0 1px var(--danger); }
.meter-legend { display: flex; justify-content: space-between; margin-top: 6px; font-size: 12px; color: var(--muted); }
.wact { display: flex; flex-direction: column; gap: 8px; padding: 16px 18px; }
.wact-main, .wact-reference { display: flex; align-items: center; justify-content: flex-end; gap: 8px; width: 100%; }
.wact-reference { padding-top: 2px; border-top: 1px solid var(--border); }

/* main grid */
.grid { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 20px; margin-top: 20px; align-items: start; }
.sticky { position: sticky; top: 76px; }

/* dropzone */
.drop {
  position: relative; display: grid; place-items: center; text-align: center; gap: 4px; padding: 22px 16px;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2);
  cursor: pointer; transition: border-color .15s, background .15s, transform .15s;
}
.drop:hover { border-color: var(--accent); }
.drop.over { border-color: var(--accent); background: var(--accent-soft); transform: scale(1.01); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.drop .bubble { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); margin-bottom: 6px; }
.drop .bubble .ico { width: 20px; height: 20px; }
.drop b { font-weight: 600; }
.drop b u { color: var(--accent-text); text-decoration: none; }
.drop small { color: var(--muted); font-size: 12px; }
.drop.compact { padding: 12px; grid-template-columns: auto 1fr; text-align: left; gap: 10px; }
.drop.compact .bubble { margin: 0; width: 34px; height: 34px; }

.pending { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; margin-top: 10px; }
.pending:empty { display: none; }
.pfile { position: relative; aspect-ratio: 3 / 4; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); animation: pop .2s ease; }
.pfile img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.pfile { cursor: zoom-in; }
.pfile .x { cursor: pointer; }
.pfile .ph { width: 100%; height: 100%; display: grid; place-items: center; color: var(--muted); }
.pfile .ph .ico { width: 24px; height: 24px; }
.pfile .x { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; display: grid; place-items: center; }
.pfile .x .ico { width: 12px; height: 12px; }
.pfile .prog { position: absolute; left: 6px; right: 6px; bottom: 6px; height: 4px; border-radius: 9px; background: rgba(0,0,0,.35); overflow: hidden; }
.pfile .prog i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .15s; }
.pfile.done .prog { display: none; }
.pfile.done::after { content: ""; position: absolute; left: 6px; bottom: 6px; width: 18px; height: 18px; border-radius: 50%; background: var(--ok) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5L20 7'/%3E%3C/svg%3E") center / 11px no-repeat; }
.pfile.bad { border-color: var(--danger); }
.pfile.bad .ph { color: var(--danger); }
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }

.steps { counter-reset: s; }
.step { position: relative; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  height: 26px; padding: 0 9px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface-2);
  font-family: var(--mono); font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; color: var(--muted);
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.chip i { width: 7px; height: 7px; border-radius: 50%; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row2 .field + .field { margin-top: 0; }
.form-foot { margin-top: 18px; }

/* line items */
.lines-h { display: flex; align-items: center; gap: 10px; margin: 0 2px 12px; }
.lines-h h2 { margin: 0; font-size: 15px; font-weight: 650; }
.week-title { display: inline-flex; align-items: center; gap: 4px; border: 0; background: transparent; padding: 0; font-size: 15px; font-weight: 650; color: var(--text); }
.week-title:hover { color: var(--accent-text); }
.week-title .ico { width: 14px; height: 14px; color: var(--muted); }
.lines-h .count { font-size: 12px; color: var(--muted); background: var(--hover); border: 1px solid var(--border); padding: 1px 8px; border-radius: 99px; }
.lines-h .spacer { flex: 1; }
.lines { display: grid; gap: 12px; }
.line { overflow: hidden; animation: rise .3s cubic-bezier(.2,.8,.2,1) both; }
.line-h { display: flex; align-items: center; gap: 12px; padding: 14px 16px 10px; }
.tag {
  font-family: var(--mono); font-weight: 750; font-size: 14px; padding: 4px 9px; border-radius: 7px;
  background: color-mix(in srgb, var(--c) 14%, transparent); color: color-mix(in srgb, var(--c) 75%, var(--text));
  border: 1px solid color-mix(in srgb, var(--c) 30%, transparent); letter-spacing: .02em;
}
.line-h .meta { font-size: 12.5px; color: var(--muted); }
.line-h .tot { margin-left: auto; text-align: right; }
.line-h .tot b { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; display: block; letter-spacing: -.01em; }
.line-h .tot small { color: var(--muted); font-size: 12px; }
.minibar { margin: 0 16px; height: 3px; border-radius: 9px; background: var(--hover); overflow: hidden; }
.minibar i { display: block; height: 100%; background: var(--c); border-radius: 9px; transition: width .5s cubic-bezier(.2,.8,.2,1); }
.thumbs { display: flex; gap: 10px; padding: 14px 16px 16px; overflow-x: auto; scrollbar-width: thin; }
.stub {
  flex: none; width: 78px; border: 0; padding: 0; background: transparent; text-align: center; display: grid; gap: 6px;
}
.stub .paper {
  position: relative; width: 78px; height: 96px; border-radius: 7px 7px 0 0; overflow: hidden; background: var(--surface-2);
  border: 1px solid var(--border);
  -webkit-mask: linear-gradient(#000 0 0) top / 100% calc(100% - 6px) no-repeat, conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / 10px 6px repeat-x;
  mask: linear-gradient(#000 0 0) top / 100% calc(100% - 6px) no-repeat, conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / 10px 6px repeat-x;
  transition: transform .15s ease, box-shadow .15s;
}
.stub:hover .paper { transform: translateY(-3px) rotate(-1deg); }
.stub .paper img { width: 100%; height: 100%; object-fit: cover; }
.stub .paper .ph { width: 100%; height: 100%; display: grid; place-items: center; align-content: center; gap: 4px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .06em; }
.stub .paper .ph .ico { width: 24px; height: 24px; }
.stub .paper .multi { position: absolute; top: 5px; right: 5px; background: rgba(0,0,0,.65); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 99px; }
.stub .amt { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stub .dt { font-size: 11px; color: var(--muted); margin-top: -6px; }
.stub.flash .paper { animation: flash 1.4s ease; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 3px transparent; } }

.empty { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty .art { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 16px; background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; }
.empty .art .ico { width: 30px; height: 30px; }
.empty h3 { color: var(--text); margin: 0 0 4px; font-size: 15px; }

/* ---------- popover / modal ---------- */
.pop {
  position: fixed; z-index: 60; min-width: 220px; max-width: calc(100vw - 24px); background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-lg); padding: 5px; animation: popin .14s ease; max-height: 60vh; overflow: auto;
}
@keyframes popin { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
.pop .item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 0; background: transparent; border-radius: 6px; text-align: left; }
.pop .item:hover { background: var(--hover); }
.pop .item.on { background: var(--accent-soft); }
.pop .item .ico { color: var(--muted); }
.pop .item small { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.pop .sep { height: 1px; background: var(--border); margin: 5px 2px; }
.pop .head { padding: 8px 10px 6px; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }

.scrim { position: fixed; inset: 0; z-index: 70; background: rgba(9,9,11,.5); display: grid; place-items: center; padding: 16px; animation: fade .15s ease; backdrop-filter: blur(2px); }
@keyframes fade { from { opacity: 0; } }
.modal { width: 100%; max-width: 720px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); animation: rise .2s cubic-bezier(.2,.8,.2,1); }
.modal.wide { max-width: 760px; }
.modal-h { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; padding: 16px 18px; }
.modal-h h3 { margin: 0; font-size: 16px; flex: 1; }
.modal-b { min-height: 0; overflow-y: auto; padding: 0 18px 18px; }
.modal-f { display: flex; gap: 8px; justify-content: flex-end; flex: 0 0 auto; padding: 14px 18px; background: var(--surface-2); border-radius: 0 0 14px 14px; }

/* receipt viewer */
.viewer { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 0; }
.viewer .media { background: var(--surface-2); min-height: 320px; display: grid; place-items: center; padding: 14px; gap: 10px; }
.viewer .media img { max-width: 100%; max-height: 58vh; border-radius: 8px; box-shadow: var(--shadow-lg); }
.viewer .media .fileph { display: grid; place-items: center; gap: 8px; color: var(--muted); }
.viewer .media .fileph .ico { width: 42px; height: 42px; }
.viewer .media .fileph img { max-height: 48vh; }
.viewer .strip { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.viewer .strip button { width: 40px; height: 50px; border-radius: 6px; overflow: hidden; border: 1px solid var(--border); padding: 0; background: var(--surface); display: grid; place-items: center; color: var(--muted); }
.viewer .strip button.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.viewer .strip img { width: 100%; height: 100%; object-fit: cover; box-shadow: none; border-radius: 0; }
.viewer .info { padding: 18px; display: grid; gap: 14px; align-content: start; }
.kv { display: grid; gap: 2px; }
.kv .k { font-size: 12px; color: var(--muted); }
.kv .v { font-weight: 600; word-break: break-word; }
.kv .v.big { font-size: 24px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kv .v.note { font-weight: 400; white-space: pre-wrap; }
.viewer .acts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

/* onboarding */
.onb { min-height: calc(100vh - 56px); display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(var(--bg-dot) 1px, transparent 1px) 0 0 / 18px 18px; }
.onb .card { width: 100%; max-width: 420px; padding: 28px; box-shadow: var(--shadow-lg); animation: rise .3s ease; }
.onb h1 { font-size: 21px; margin: 0 0 6px; letter-spacing: -.01em; }
.onb p { color: var(--muted); margin: 0 0 22px; }
.dots { display: flex; gap: 6px; margin-bottom: 20px; }
.dots i { height: 4px; flex: 1; border-radius: 9px; background: var(--hover); transition: background .3s; }
.dots i.on { background: var(--accent); }
.bigaffix { height: 52px; }
.bigaffix .pre { font-size: 15px; padding: 0 16px; }
.bigaffix input { font-size: 22px; font-weight: 700; }

/* ---------- report ---------- */
.rep-h { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.rep-h h1 { margin: 6px 0 2px; font-size: 24px; letter-spacing: -.02em; }
.rep-h .spacer { flex: 1; }
.rep-h .acts { display: flex; gap: 8px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; border: 0; background: none; padding: 0; }
.back:hover { color: var(--text); }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { padding: 14px 16px; }
.kpi .k { font-size: 12px; color: var(--muted); }
.kpi .v { font-size: 20px; font-weight: 700; letter-spacing: -.015em; font-variant-numeric: tabular-nums; }
.kpi .v.neg { color: var(--danger); }
.rtable { width: 100%; border-collapse: collapse; }
.rtable th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 16px; background: var(--surface-2); white-space: nowrap; }
.rtable td { padding: 11px 16px; vertical-align: top; }
.rtable tbody tr.alt td { background: color-mix(in srgb, var(--surface-2) 70%, var(--hover)); }
.rtable .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rtable tr.sub td { background: var(--accent-soft); font-weight: 650; }
.rtable tr.grand td { font-weight: 750; font-size: 15px; background: var(--surface-2); }
.rtable .first .tag { font-size: 12.5px; }
.rtable .cont { color: transparent; }
.rtable .note { color: var(--muted); max-width: 420px; white-space: pre-wrap; word-break: break-word; }
.rtable .dt small { color: var(--faint); }
.rtable tbody tr:not(.sub):not(.grand):hover td { background: var(--hover); }

/* ---------- toast ---------- */
#toasts { position: fixed; z-index: 90; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 9px; padding: 10px 14px; border-radius: 10px; background: #18181b; color: #fafafa; box-shadow: var(--shadow-lg); font-size: 13.5px; animation: rise .2s ease; border: 1px solid #2a2a30; }
.toast .ico { width: 16px; height: 16px; color: #4ade80; }
.toast.bad .ico { color: #f87171; }
.toast.out { opacity: 0; transform: translateY(6px); transition: .2s; }
body.dragging::after { content: ""; position: fixed; inset: 8px; border: 2px dashed var(--accent); border-radius: 16px; pointer-events: none; z-index: 80; background: color-mix(in srgb, var(--accent) 6%, transparent); }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .grid { grid-template-columns: 1fr; }
  .sticky { position: static; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .wbar { grid-template-columns: 1fr; }
  .wpick { padding: 12px 16px; }
  .wpick .v { font-size: 22px; }
  .wstats { padding: 14px 16px; gap: 12px; }
  .stat .v { font-size: 17px; }
  .wact { padding: 12px 16px; }
  .wact .btn { flex: 1; }
  .brand small { display: none; }
  .viewer { grid-template-columns: 1fr; }
  .viewer .media { min-height: 220px; }
  .scrim { align-items: end; padding: 0; }
  .modal { max-width: none; border-radius: 16px 16px 0 0; max-height: 92vh; animation: sheet .25s cubic-bezier(.2,.8,.2,1); padding-bottom: env(safe-area-inset-bottom); }
  .modal-f { border-radius: 0; }
  .rep-h .acts { width: 100%; }
  .rep-h .acts .btn { flex: 1; }
  .rtable thead { display: none; }
  .rtable, .rtable tbody, .rtable tr, .rtable td { display: block; width: 100%; }
  .rtable tr { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; padding: 11px 14px; }
  .rtable tbody tr.alt { background: color-mix(in srgb, var(--surface-2) 70%, var(--hover)); }
  .rtable td { padding: 0; box-shadow: none; }
  .rtable td.note { grid-column: 1 / -1; max-width: none; }
  .rtable td.note:empty { display: none; }
  .rtable .cont { display: none; }
  .rtable tr:not(.sub):not(.grand) td.dt { grid-column: 1 / 3; }
  .rtable tr.sub, .rtable tr.grand { grid-template-columns: 1fr auto; }
  .rtable tr.sub td, .rtable tr.grand td { background: transparent; }
  .rtable tr.sub { background: var(--accent-soft); }
  .rtable tr.grand { background: var(--surface-2); }
  .rtable tr.sub td:empty, .rtable tr.grand td:empty { display: none; }
  .rtable tbody tr.first-row { padding-top: 16px; }
}
@media (max-width: 420px) {
  .wstats { grid-template-columns: 1fr 1fr; }
  .wstats .stat:nth-child(3) { grid-column: 1 / -1; }
  .row2 { grid-template-columns: 1fr; }
  .row2 .field + .field { margin-top: 16px; }
}
@keyframes sheet { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

@media print {
  body { background: #fff; color: #000; }
  .topbar, .rep-h .acts, .back, #toasts { display: none !important; }
  .card { box-shadow: none; border-color: #ddd; }
  .wrap { padding: 0; max-width: none; }
  .rtable tr.sub td { background: #f5f5f5 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Window line totals and configuration */
.line.near-cap .tot b { color: var(--ok); }
.line.over-cap .tot b, .line.over-cap .tot small { color: var(--danger); }
.line-progress {
  appearance: none;
  display: block;
  width: calc(100% - 32px);
  height: 4px;
  margin: 0 16px;
  border: 0;
  border-radius: 9px;
  overflow: hidden;
  color: var(--c);
  background-color: var(--hover);
}
.line-progress::-webkit-progress-bar { background-color: var(--hover); }
.line-progress::-webkit-progress-value { background-color: currentColor; }
.line-progress::-moz-progress-bar { background-color: currentColor; }
.line.near-cap .line-progress { color: var(--ok); }
.line.over-cap .line-progress { color: var(--danger); }
.line-no-receipts { padding: 12px 16px; color: var(--muted); font-size: .85rem; }
.config-format { padding: 12px; border: 1px solid var(--border); border-radius: 10px; }
.config-format summary { cursor: pointer; font-weight: 650; }
.config-format pre { margin: 10px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.config-format button { margin-top: 8px; }
/* Keep week selection in a viewport-bounded sheet with one scroll container. */
.week-picker-scrim { display: flex; align-items: center; justify-content: center; }
.week-picker.modal {
  width: min(100%, 520px);
  max-height: min(72vh, 520px);
  max-height: min(72dvh, 520px);
}
.week-picker .modal-b { overscroll-behavior: contain; padding-bottom: 10px; }
.week-picker .modal-f { flex-wrap: wrap; }
.week-picker-list.pop {
  position: static;
  min-width: 0;
  max-width: none;
  max-height: none;
  border: 0;
  padding: 0;
  box-shadow: none;
  overflow: visible;
  animation: none;
}
.week-picker-list .item { min-height: 44px; }
body:has(.week-picker-scrim) { overflow: hidden; }
@media (max-width: 760px) {
  .week-picker-scrim { height: 100dvh; align-items: flex-end; }
  .week-picker.modal { width: 100%; }
}

.pending-pdf { width: 100%; height: 70vh; min-height: 280px; border: 0; }
.pending-image { display: block; max-width: 100%; max-height: 70vh; margin: auto; object-fit: contain; }

.line-id {
  display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto;
  border: 0; background: transparent; padding: 4px 6px; margin: -4px -6px; border-radius: 8px;
  text-align: left; transition: background .12s;
}
.line-id:hover { background: var(--hover); }
.line-label { display: grid; gap: 1px; min-width: 0; }
.line-title { font-weight: 650; font-size: 13.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.line-h .tot { flex: none; }
.line-hint { font-size: 12px; color: var(--muted); min-height: 0; }
.line-hint:empty { display: none; }
.line-modal-ref { margin-bottom: 14px; }
.rep-line-title { font-weight: 600; color: var(--text); margin-left: 4px; }
