@font-face { font-family: "Plex"; src: url("fonts/plex-Regular.woff") format("woff"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex"; src: url("fonts/plex-Medium.woff") format("woff"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex"; src: url("fonts/plex-SemiBold.woff") format("woff"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Plex"; src: url("fonts/plex-Bold.woff") format("woff"); font-weight: 700; font-display: swap; }
:root {
  --ground: #FBF3E6; --card: #FFFFFF; --ink: #2B1D22; --muted: #6E5A61; --line: #EADBC8; --line2: #D9C4AC;
  --soft: #F6EBDD; --brand: #CB5479; --btn: #A93A60; --btn-dark: #7E2A47;
  --warn-bg: #FDEBD3; --warn-line: #F3C99A; --warn: #8A3F00; --ok-bg: #E3F1E6; --ok-line: #A9D3B4; --ok: #1F5130;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ground); color: var(--ink); }
body { font-family: "Plex", system-ui, sans-serif; font-size: 16px; -webkit-text-size-adjust: 100%; }
button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
.app { max-width: 1100px; margin: 0 auto; min-height: 100vh; padding-bottom: 40px; }
.loading { text-align: center; padding: 80px 0; color: var(--muted); }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 16px 10px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 32px; height: 38px; object-fit: contain; }
.brand b { font-size: 20px; }
.brand small { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.top-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-btn { min-height: 40px; padding: 6px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-size: 14px; }
.chip-btn.on { background: var(--btn); border-color: var(--btn); color: #fff; font-weight: 600; }

/* bars */
.bar { margin: 0 16px 10px; border-radius: 14px; padding: 10px 14px; font-size: 14px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.bar.warn { background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn); }
.bar.ok { background: var(--ok-bg); border: 1px solid var(--ok-line); color: var(--ok); }
.bar.err { background: #FDE2E2; border: 1px solid #F0A9A9; color: #8B1E1E; }
.bar button { flex: none; min-height: 36px; padding: 4px 12px; border-radius: 10px; border: 1px solid currentColor; background: transparent; color: inherit; font-weight: 600; font-size: 14px; }

/* sections */
.section { padding: 0 16px; margin-bottom: 14px; }
.section h2 { font-size: 15px; margin: 6px 0 8px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.section h2 span { font-weight: 400; color: var(--muted); font-size: 13px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px; }
.card.low { background: #FFF7EE; border-color: var(--warn-line); }

/* boxes */
.boxc { display: flex; align-items: center; gap: 10px; background: #FBE6EE; border: 1px solid #EDBACB; border-radius: 16px; padding: 10px 12px; }
.boxc .main { flex: 1 1 auto; min-width: 0; }
.boxc .t { font-weight: 700; font-size: 15px; }
.boxc .s { font-size: 12px; color: var(--muted); }
.boxc .kg { text-align: center; min-width: 64px; }
.boxc .kg b { display: block; font-size: 20px; line-height: 1.1; }
.boxc .kg small { font-size: 11px; color: var(--muted); }
.boxc select { min-height: 40px; border-radius: 10px; border: 1px solid var(--line2); background: #fff; padding: 0 8px; margin-top: 4px; max-width: 100%; }
.small-btn { min-height: 40px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line2); background: #fff; font-size: 13px; }

/* product rows */
.row { display: flex; align-items: center; gap: 8px; }
.row .name { flex: 1 1 auto; min-width: 0; background: none; border: none; padding: 0; text-align: right; }
.row .name b { display: block; font-size: 16px; font-weight: 600; }
.row .name small { font-size: 13px; color: var(--muted); }
.row .name em { display: block; font-style: normal; font-size: 12px; font-weight: 600; color: var(--warn); }
.count { min-width: 44px; text-align: center; font-size: 22px; font-weight: 700; }
.card.low .count { color: var(--warn); }
.add { min-width: 70px; min-height: 44px; border-radius: 12px; border: none; background: var(--btn); color: #fff; font-size: 14px; font-weight: 600; }
.add:disabled { background: #D9C4AC; color: #fff; cursor: not-allowed; }
.outb { min-width: 60px; min-height: 44px; border-radius: 12px; border: 1px solid var(--line2); background: #fff; font-size: 14px; }
.outb:disabled { color: #B9A9A0; cursor: not-allowed; }
.tabs { display: flex; gap: 6px; padding: 0 16px 10px; flex-wrap: wrap; }
.wide { display: block; width: calc(100% - 32px); margin: 4px 16px 12px; min-height: 48px; border-radius: 14px; border: 1px dashed var(--line2); background: transparent; font-size: 15px; }
.more { display: block; margin: 0 auto 12px; min-height: 40px; border: none; background: none; color: var(--btn); font-weight: 600; font-size: 14px; }

/* sheet */
.veil { position: fixed; inset: 0; background: rgba(43, 29, 34, .45); display: flex; flex-direction: column; justify-content: flex-end; align-items: center; z-index: 10; }
.sheet { background: #fff; width: 100%; max-width: 560px; border-radius: 24px 24px 0 0; padding: 18px 18px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; max-height: 92vh; overflow-y: auto; }
@media (min-width: 700px) { .veil { justify-content: center; } .sheet { border-radius: 24px; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.sheet-head b { font-size: 18px; }
.x { width: 44px; height: 44px; border-radius: 22px; border: none; background: var(--soft); font-size: 22px; flex: none; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 16px; }
.stepper button { width: 60px; height: 60px; border-radius: 16px; border: 1px solid var(--line); background: var(--soft); font-size: 28px; }
.stepper input { width: 110px; text-align: center; font-size: 36px; font-weight: 700; border: none; border-bottom: 2px solid var(--line); background: transparent; padding: 4px 0; }
.stepper .unit { display: block; text-align: center; font-size: 13px; color: var(--muted); }
.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; background: #F1E3D1; border-radius: 14px; padding: 4px; }
.seg button { min-height: 44px; border-radius: 11px; border: none; background: transparent; color: var(--muted); font-size: 15px; }
.seg button.on { background: #fff; color: var(--btn); font-weight: 700; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; font-weight: 600; }
.field input, .field select, .field textarea { min-height: 48px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line2); background: #fff; font-size: 16px; }
.hint { font-size: 13px; color: var(--muted); margin: 0; }
.primary { min-height: 54px; border-radius: 14px; border: none; background: var(--btn); color: #fff; font-size: 18px; font-weight: 700; }
.primary:disabled { opacity: .5; }
.danger { min-height: 48px; border-radius: 14px; border: 1px solid #D8A0A0; background: #fff; color: #8B1E1E; font-size: 15px; }

/* login */
.login { max-width: 380px; margin: 0 auto; padding: 60px 20px; display: flex; flex-direction: column; gap: 16px; }
.login img { width: 110px; align-self: center; }
.login h1 { text-align: center; font-size: 22px; margin: 0; }

/* tables (count, moves, settings) */
.list { display: flex; flex-direction: column; gap: 6px; }
.line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.line .grow { flex: 1 1 180px; min-width: 0; }
.line input[type=number] { width: 84px; min-height: 44px; text-align: center; border-radius: 12px; border: 1px solid var(--line2); font-size: 18px; }
.line select, .line input[type=text], .line input[type=email] { min-height: 40px; border-radius: 10px; border: 1px solid var(--line2); background: #fff; padding: 0 8px; font-size: 14px; }
.diff { font-size: 13px; font-weight: 700; color: var(--warn); }
.mv { font-size: 14px; }
.mv small { color: var(--muted); }
.mv.undone { opacity: .45; text-decoration: line-through; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 13px; word-break: break-all; direction: ltr; text-align: left; background: var(--soft); padding: 8px; border-radius: 10px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* balances */
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 16px 18px; }
.hero small { display: block; font-size: 13px; color: var(--muted); }
.hero b { display: block; font-size: 30px; line-height: 1.25; }
.hero.due { background: #FBE6EE; border-color: #EDBACB; }
.hero.due b { color: var(--btn-dark); }
.hero.credit, .hero.zero { background: var(--ok-bg); border-color: var(--ok-line); }
.hero.credit b, .hero.zero b { color: var(--ok); }
.hero-side { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--muted); text-align: left; }
.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-top: 10px; }
.actions button, .actions a { min-height: 48px; border-radius: 14px; font-size: 15px; font-weight: 600; display: flex; align-items: center; justify-content: center; text-decoration: none; }
.act-take { border: none; background: var(--btn); color: #fff; }
.act-pay { border: none; background: #2F6B3F; color: #fff; }
.act-pdf { border: 1px solid var(--line2); background: #fff; color: var(--ink); }
.act-more { border: 1px dashed var(--line2); background: transparent; color: var(--muted); }
.person { display: flex; align-items: center; gap: 12px; width: 100%; text-align: right; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; min-height: 64px; }
.person.off { opacity: .55; }
.avatar { flex: none; width: 42px; height: 42px; border-radius: 21px; background: var(--soft); color: var(--btn-dark); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; }
.person.due .avatar { background: #FBE6EE; }
.pmain { flex: 1 1 auto; min-width: 0; }
.pmain b { display: block; font-size: 16px; }
.pmain small { font-size: 12px; color: var(--muted); }
.pbal { flex: none; font-weight: 700; font-size: 16px; }
.person.due .pbal { color: var(--btn-dark); }
.person.zero .pbal, .person.credit .pbal { color: var(--ok); font-weight: 600; font-size: 14px; }
.back { display: block; margin: 0 16px 8px; min-height: 40px; border: none; background: none; color: var(--btn); font-weight: 600; font-size: 14px; padding: 0; }
.entry { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.entry .dot { flex: none; width: 34px; height: 34px; border-radius: 17px; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.entry.take .dot { background: #FBE6EE; color: var(--btn-dark); }
.entry.pay .dot { background: var(--ok-bg); color: var(--ok); }
.emain { flex: 1 1 auto; min-width: 0; }
.emain b { display: block; font-size: 15px; font-weight: 600; }
.emain small { font-size: 12px; color: var(--muted); }
.emain em { display: block; font-style: normal; font-size: 12px; color: #8B1E1E; }
.eamt { flex: none; text-align: left; }
.eamt b { display: block; font-size: 16px; }
.entry.take .eamt b { color: var(--btn-dark); }
.entry.pay .eamt b { color: var(--ok); }
.eamt small { font-size: 11px; color: var(--muted); }
.entry.void .emain b, .entry.void .eamt b { text-decoration: line-through; color: var(--muted); }
.entry.void { opacity: .7; }
.seg.seg3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field input.big { font-size: 28px; font-weight: 700; text-align: center; min-height: 60px; }
