/* Phone-first single column; cards on a cool grey ground, deep teal ink, mustard and coral for status. */
:root {
  --ground: #F2F4F1; --surface: #FFFFFF; --ink: #12343B; --muted: #55615F; --line: #E3E7E2; --edge: #C9D1CB;
  --teal-bg: #D9ECEE; --teal-fg: #0B4A54; --warn-bg: #FBE9B8; --warn-fg: #5A3E00;
  --bad-bg: #F8DAD3; --bad-fg: #7E2415; --ok-bg: #E1E8CF; --ok-fg: #36420F;
  --display: 'Bricolage Grotesque', system-ui, sans-serif; --body: 'Figtree', system-ui, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--ground); color: var(--ink); font: 400 15px/1.4 var(--body); -webkit-text-size-adjust: 100%; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
#app { max-width: 560px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: calc(16px + env(safe-area-inset-top, 0px)) 16px 24px; }
h1 { margin: 0; font: 700 24px/1.15 var(--display); text-wrap: balance; }
h2 { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
h2.bad { color: #9C2F1D; }
h3 { margin: 0 0 12px; font: 700 20px/1.2 var(--display); padding-right: 40px; }
small { display: block; font-size: 12.5px; color: var(--muted); }
.sub { font-size: 13px; color: var(--muted); }
.hdr { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hdr img.logo { display: block; width: 190px; max-width: 100%; height: auto; }
.hdr-actions { display: flex; gap: 8px; align-items: center; flex: none; }
.back { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; color: #0F5F6B; }
.demo { background: var(--warn-bg); color: var(--warn-fg); border-radius: 10px; padding: 8px 12px; font-size: 13px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border: 0; border-radius: 22px; background: var(--ink); color: #fff; font: 600 14px var(--body); cursor: pointer; white-space: nowrap; }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--edge); }
.btn.danger { background: var(--surface); color: #9C2F1D; border: 1px solid #E3B5AB; }
.btn.wide { width: 100%; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--edge); background: var(--surface); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.btn:focus-visible, .icon-btn:focus-visible, .chip:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid #1B7E8C; outline-offset: 2px; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--surface); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.stat b { display: block; font: 700 21px/1.2 var(--display); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat span { font-size: 12px; color: var(--muted); }

.card { background: var(--surface); border-radius: 14px; padding: 12px 14px; }
.card > header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding-bottom: 8px; }
.card > header > span { font-size: 13px; color: var(--muted); white-space: nowrap; }
.card > header > span.strong { color: var(--ink); font-weight: 700; }
.row { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); min-height: 56px; }
.row .grow, .grow { flex: 1; min-width: 0; }
.row b { display: block; font-weight: 600; overflow-wrap: anywhere; }
.row .amt { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { margin: 0; padding: 10px 0; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); }
#app > .empty { border: 0; padding: 40px 16px; text-align: center; }
.thumb { width: 44px; height: 44px; flex: none; object-fit: cover; display: block; background: var(--edge); }
.thumb.rd { border-radius: 50%; } .thumb.sq { border-radius: 8px; }
.thumb.big { width: 100%; height: auto; aspect-ratio: 1 / 1; border-radius: 10px; }
.thumb.mid { width: 52px; height: 52px; }
.tag { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 12px; background: var(--teal-bg); color: var(--teal-fg); white-space: nowrap; }
.tag.warn { background: var(--warn-bg); color: var(--warn-fg); } .tag.bad { background: var(--bad-bg); color: var(--bad-fg); }
.tag.ok { background: var(--ok-bg); color: var(--ok-fg); } .tag.plain { background: var(--ground); color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 40px; padding: 0 14px; border: 1px solid var(--edge); border-radius: 20px; background: var(--surface); color: var(--ink); font: 600 13px var(--body); cursor: pointer; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }

.item { display: flex; flex-direction: column; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.item-top { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.item-top > .grow { flex: 1 1 0; }
.item-top select { flex: 1 1 100%; }
.bar { height: 6px; border-radius: 3px; background: var(--line); }
.bar > i { display: block; height: 6px; border-radius: 3px; background: #1B7E8C; }
.bar > i.done { background: #5C6B2E; }
.three { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding-bottom: 12px; }
.three b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.three .good { color: var(--ok-fg); } .three .owed { color: #9C2F1D; }
.hist { font-size: 12.5px; color: var(--muted); padding-top: 4px; }

form { display: flex; flex-direction: column; gap: 12px; margin: 0; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
label.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; min-height: 36px; }
input, select, textarea { font: 400 16px var(--body); color: var(--ink); background: var(--surface); border: 1px solid var(--edge); border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%; }
input[type=checkbox] { width: 22px; height: 22px; min-height: 0; padding: 0; flex: none; accent-color: var(--ink); }
input[type=file] { padding: 8px; font-size: 14px; }
textarea { min-height: 72px; resize: vertical; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.hint { margin: 0; font-size: 12.5px; color: var(--muted); }
.search { margin-bottom: 0; }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.dcard { background: var(--surface); border-radius: 14px; padding: 8px; display: flex; flex-direction: column; gap: 6px; cursor: pointer; border: 0; text-align: left; font: inherit; color: inherit; min-width: 0; }
.dcard .code { font-size: 12px; font-weight: 700; color: var(--teal-fg); }
.dcard b { font-weight: 600; overflow-wrap: anywhere; }
.dcard .in { color: var(--ok-fg); font-weight: 600; font-size: 12px; } .dcard .out { color: var(--muted); font-size: 12px; }
.tile { display: flex; flex-direction: column; gap: 4px; padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-align: left; font: inherit; color: inherit; cursor: pointer; min-width: 0; }
.tile b { font-size: 12px; color: var(--teal-fg); } .tile small { overflow-wrap: anywhere; }
.codes { background: var(--warn-bg); color: #3D2A00; border-radius: 14px; padding: 12px 14px; font-size: 13px; }
.codes b { display: block; font: 700 20px var(--display); padding: 2px 0; }

.tbl-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 6px; text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; padding-left: 0; white-space: normal; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
tr + tr td { border-top: 1px solid var(--line); }
td.neg { color: #9C2F1D; font-weight: 700; }

.tabbar { position: sticky; bottom: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); background: var(--surface); border-top: 1px solid var(--edge); padding: 6px 4px calc(8px + env(safe-area-inset-bottom, 0px)); }
.tabbar a { min-height: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11px; font-weight: 600; }
.tabbar a.on { color: var(--ink); }

#sheet { position: fixed; inset: 0; z-index: 10; display: flex; align-items: flex-end; justify-content: center; }
.sheet-bg { position: absolute; inset: 0; background: rgba(18, 52, 59, .45); }
.sheet-body { position: relative; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; background: var(--ground); border-radius: 18px 18px 0 0; padding: 20px 16px calc(24px + env(safe-area-inset-bottom, 0px)); }
.sheet-x { position: absolute; top: 10px; right: 10px; width: 44px; height: 44px; border: 0; background: none; font-size: 28px; line-height: 1; color: var(--ink); cursor: pointer; }
#sheet-content { display: flex; flex-direction: column; gap: 12px; }
.pick { display: flex; align-items: center; gap: 12px; }
#toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 20; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: calc(100% - 32px); }
.login { max-width: 380px; width: 100%; margin: 12vh auto 0; }
.login img { width: 220px; display: block; margin: 0 auto 8px; }
@media (min-width: 600px) { main { padding-top: 28px; } }
@media (prefers-reduced-motion: no-preference) { .bar > i { transition: width .25s; } }
.nofile { color: #9C2F1D !important; font-weight: 600; }
.lnk { color: #0F5F6B; font-weight: 600; text-decoration: underline; }
.fileblock { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
#cp-msg { font: 400 14px/1.4 var(--body); min-height: 220px; }
