:root { color-scheme: dark; }
* { box-sizing: border-box; margin: 0; font-family: "Segoe UI", system-ui, sans-serif; }
body { background: #101114; color: #ececec; }
.app { max-width: 560px; margin: 0 auto; background: radial-gradient(120% 45% at 50% -5%, #292219 0%, #17181c 55%); min-height: 100vh; }

/* header */
.hdr { padding: 12px 15px; border-bottom: 1px solid #3a3325; display: flex; justify-content: space-between; align-items: center; }
.hdr .brand { display: flex; align-items: center; gap: 10px; }
.hdr .badge { width: 37px; height: 37px; border-radius: 11px; background: linear-gradient(145deg, #e8c84a, #b8912a); color: #17181c; font-weight: 900; font-size: 15.5px; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 14px rgba(201,162,39,.35); }
.hdr b { font-size: 18px; letter-spacing: .4px; }
.hdr .g { color: #c9a227; }
.hdr span { font-size: 12px; color: #9a9a9a; }
.sessbar { display: flex; gap: 6px; margin-bottom: 12px; }
.sessbar select, .sessbar input[type="date"] { flex: 1; min-width: 0; padding: 8px; border: 1px solid #3a3b41; border-radius: 9px; font-size: 13.5px; background: #232429; color: #ececec; }
.sbtn { background: #c9a227; color: #17181c; border: none; border-radius: 9px; padding: 8px 12px; font-size: 13.5px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.sbtn.gray { background: #232429; color: #ececec; border: 1px solid #3a3b41; }

/* sections */
.sec { display: none; padding: 12px; }
.sec.on { display: block; }
.backrow { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.backrow .back { color: #c9a227; font-size: 21px; font-weight: 700; cursor: pointer; line-height: 1; }
.backrow h2 { font-size: 16px; }

/* home */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.tile { background: linear-gradient(180deg, #2e2b23, #1e1d20); border: 1px solid #49402c; border-top-color: #7d683a; border-radius: 16px; padding: 15px 12px; text-align: center; font-size: 15.5px; font-weight: 600; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; box-shadow: 0 6px 16px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.04); }
.tile svg { width: 25px; height: 25px; stroke: #d9b83c; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tile.gold { background: linear-gradient(150deg, #ecc95a, #c39b27); border-color: #8a6d1d; color: #17181c; box-shadow: 0 8px 20px rgba(201,162,39,.35); }
.tile.gold svg { stroke: #17181c; }
.total { margin-top: 12px; background: linear-gradient(120deg, #2a2517, #1e1e23 60%); border: 1px solid #57492a; border-radius: 16px; padding: 13px 16px; display: flex; flex-direction: column; gap: 3px; box-shadow: 0 6px 16px rgba(0,0,0,.35); }
.total .tlab { font-size: 12.5px; color: #cbb26a; letter-spacing: 1.2px; }
.total .tamt { display: flex; align-items: baseline; gap: 7px; }
.total .tamt span { font-size: 13px; color: #9a9aa2; }
.total b { font-size: 26px; }

/* ledger */
.statrow { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13.5px; color: #9a9a9a; }
.statrow b { color: #ececec; font-size: 14.5px; }
.limitbtn { background: #232429; border: 1px solid #3a3b41; color: #ececec; border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer; }
.digits { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; margin-bottom: 10px; }
.dig { background: #232429; border: 1px solid #3a3b41; border-radius: 7px; text-align: center; font-size: 14px; font-weight: 700; padding: 6px 0; color: #ececec; cursor: pointer; }
.dig.on { background: #c9a227; border-color: #c9a227; color: #17181c; }
.ledger { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.cell { background: #232429; border: 1px solid #3a3b41; border-radius: 9px; padding: 8px 2px 7px; text-align: center; }
.cell .n { font-size: 17px; font-weight: 800; }
.cell .a { font-size: 11px; color: #9a9a9a; margin-top: 2px; }
.cell.hot { border-color: #7a2e2e; background: #2e1d1d; }
.cell.hot .a { color: #e08a8a; }
.cell.win { border-color: #c9a227; background: #33300f; }

/* forms */
select.inp, input.inp { width: 100%; padding: 11px 12px; border: 1px solid #3a3b41; border-radius: 10px; font-size: 14.5px; background: #232429; color: #ececec; margin-bottom: 9px; }
textarea.ta { width: 100%; background: #232429; border: 1px solid #3a3b41; border-radius: 10px; padding: 11px 12px; font-size: 14.5px; line-height: 1.8; min-height: 110px; resize: vertical; color: #ececec; }
.frow { display: flex; gap: 8px; }
.frow > * { flex: 1; min-width: 0; }

/* preview / errors */
.prev { margin-top: 9px; border: 1px solid #3f5a3f; background: #1e2a1e; border-radius: 10px; padding: 10px 12px; font-size: 13.5px; line-height: 1.65; }
.prev .pt { border-top: 1px solid #3f5a3f; margin-top: 6px; padding-top: 6px; font-weight: 700; }
.bad { margin-top: 9px; border: 1px solid #7a3a3a; background: #2e1d1d; border-radius: 10px; padding: 10px 12px; font-size: 13.5px; line-height: 1.65; color: #e08a8a; }
.btn { margin-top: 10px; background: #c9a227; color: #17181c; text-align: center; font-weight: 700; font-size: 15.5px; border-radius: 11px; padding: 12px; border: none; width: 100%; cursor: pointer; }
.btn:disabled { opacity: .45; cursor: default; }
.status { margin-top: 9px; font-size: 13.5px; color: #8fce8f; text-align: center; min-height: 18px; }

/* tables */
table.grid { width: 100%; border-collapse: collapse; background: #232429; font-size: 14px; }
table.grid th, table.grid td { border: 1px solid #3a3b41; padding: 8px 9px; text-align: right; }
table.grid th { background: #2b2c31; font-weight: 700; }
table.grid td:first-child, table.grid th:first-child { text-align: left; }
table.grid tr.tot td { font-weight: 800; background: #2b2c31; }
.neg { color: #e08a8a; }
.pos { color: #7bc47f; font-weight: 700; }
.empty { background: #232429; border: 1px solid #3a3b41; border-radius: 10px; padding: 16px; text-align: center; color: #9a9a9a; font-size: 14px; }

/* vouchers */
.vbatch { background: #232429; border: 1px solid #3a3b41; border-radius: 10px; margin-bottom: 12px; overflow: hidden; }
.vhead { background: #2b2c31; border-bottom: 1px solid #3a3b41; padding: 7px 11px; font-weight: 800; font-size: 13.5px; }
table.vt { width: 100%; border-collapse: collapse; font-size: 14px; }
table.vt td { border: 1px solid #33343a; padding: 7px 9px; text-align: center; width: 33.33%; }
table.vt td.frm { text-align: left; font-weight: 600; }
table.vt tr.vtot td { border-top: 2px dashed #55565e; font-weight: 800; text-align: right; background: #2b2c31; }

/* people */
.prow { display: flex; gap: 6px; align-items: center; background: #232429; border: 1px solid #3a3b41; border-radius: 10px; padding: 9px 11px; margin-bottom: 7px; font-size: 14px; }
.prow .nm { font-weight: 700; flex: 1; }
.prow .del { background: transparent; border: 1px solid #7a3a3a; color: #e08a8a; border-radius: 8px; padding: 5px 10px; cursor: pointer; font-size: 13px; }

/* settings */
.setrow { background: #232429; border: 1px solid #3a3b41; border-radius: 10px; padding: 13px; margin-bottom: 9px; font-size: 14.5px; display: flex; justify-content: space-between; align-items: center; }
.danger { background: #c0392b; color: #fff; border: none; border-radius: 9px; padding: 9px 14px; font-weight: 700; cursor: pointer; font-size: 14px; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: flex; align-items: center; justify-content: center; z-index: 20; }
.modal.hidden { display: none; }
.mbox { background: #232429; border: 1px solid #3a3b41; border-radius: 14px; padding: 16px; width: 84%; max-width: 340px; }
.mbox h3 { font-size: 15.5px; margin-bottom: 11px; }
.mrow { display: flex; gap: 8px; margin-top: 4px; }

/* board-first entry */
textarea.ta.board { min-height: 44vh; font-size: 16.5px; line-height: 1.9; }
.prow2 { display: flex; gap: 8px; align-items: stretch; }
.prow2 select { flex: 1; min-width: 0; }
.kbt { border: 1px solid #57492a; background: #232429; color: #e8c84a; border-radius: 10px; padding: 0 15px; font-size: 17px; font-weight: 700; cursor: pointer; }
.kbt.on { background: linear-gradient(150deg, #ecc95a, #c39b27); color: #17181c; }
textarea.ta.board { caret-color: #ffd94a; }
.kb { position: fixed; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px; background: #101013; border-top: 1px solid #3a3325; padding: 8px 7px 12px; z-index: 15; box-shadow: 0 -8px 24px rgba(0,0,0,.5); }
.krow { display: flex; gap: 6px; margin-bottom: 6px; }
.krow:last-child { margin-bottom: 0; }
.k { flex: 1; background: linear-gradient(180deg, #2b2b32, #222228); border: 1px solid #3d3a30; border-bottom-width: 2px; border-radius: 11px; color: #f2f2f2; font-size: 19px; font-weight: 700; padding: 11px 0; text-align: center; cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.k:active { background: #c9a227; color: #17181c; }
.k.fn { background: linear-gradient(180deg, #3a3220, #2a2517); border-color: #57492a; color: #e8c84a; font-size: 15.5px; }
.k.sym { color: #e8c84a; }
.k.wide { flex: 2.2; }
.boardbar { display: flex; justify-content: space-between; padding: 8px 2px 0; font-size: 13.5px; color: #9a9a9a; }
.boardbar b { color: #ececec; }
.btnrow { display: flex; gap: 8px; margin-top: 10px; }
.btnrow .btn { margin-top: 0; flex: 1 1 0; width: auto; padding: 11px 4px; font-size: 15px; white-space: nowrap; }
.btnrow .btn.gray { flex: 1 1 0; }
.btn.gray { background: #232429; color: #ececec; border: 1px solid #3a3b41; flex: 0 0 110px; }
/* voucher line table */
table.vt td.amt { text-align: right; font-weight: 700; width: 34%; }
table.vt tr.vline { cursor: pointer; }
table.vt td.xpand { text-align: left; background: #1d1e23; padding: 8px 9px; }
.xgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 10px; font-size: 13px; color: #cfcfcf; }

.tag { border: 1px solid #7a3a3a; color: #e08a8a; border-radius: 6px; padding: 1px 7px; font-size: 12px; font-weight: 700; }
table.grid.akan th { background: #3a2323; }
.akanhead { font-size: 14.5px; font-weight: 700; margin: 14px 0 7px; color: #e08a8a; }

.cell.hed { border-color: #3f5a3f; }
.cell.hed .a { color: #8fce8f; }

/* voucher: no text selection / callout on long-press (Pho Oct 22) */
.vt { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.vline:active { background: #2c2c31; }
/* line action sheet */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 60;
  display: flex; align-items: flex-end; justify-content: center; }
.sheetCard { background: #1d1d20; width: 100%; max-width: 520px; padding: 16px;
  border-radius: 16px 16px 0 0; border-top: 1px solid #3a3a40; }
.sheetTitle { font-weight: 700; font-size: 17px; margin-bottom: 12px; word-break: break-all; }
.sheetCard .btn { display: block; width: 100%; margin: 8px 0; padding: 13px; font-size: 16px; }
.sheetInput { width: 100%; box-sizing: border-box; padding: 12px; font-size: 17px;
  border-radius: 10px; border: 1px solid #3a3a40; background: #141416; color: #f2e7c9; margin-bottom: 8px; }

.bchips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.bchip { background: #232429; border: 1px solid #3a3b41; color: #ececec; border-radius: 9px; padding: 8px 12px; font-size: 15px; font-weight: 700; cursor: pointer; }
.bhint { margin-top: 10px; font-size: 12.5px; color: #9a9aa2; }

.prow { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; cursor: pointer; }

/* Entry head: title + person select + keyboard toggle in ONE row (Pho Oct 24) */
.backrow.ehead select { flex: 1; min-width: 0; }
.backrow.ehead h2 { white-space: nowrap; }
.backrow.ehead .kbt { align-self: stretch; }

/* Win/tote ledger highlights (Pho Oct 24): winner RED, tote set YELLOW */
.cell.tote { border-color: #c9a227; background: #33300f; }
.cell.tote .n { color: #ffd94a; }
.cell.win { border-color: #e04848; background: #3a1414; }
.cell.win .n { color: #ff8f8f; }

/* Voucher win/tote marks (Pho Oct 24): spot hits at a glance */
table.vt tr.vwin td { background: #331111; }
table.vt tr.vwin td.frm { color: #ff9a9a; }
table.vt tr.vtote td { background: #2e2a0d; }
table.vt tr.vtote td.frm { color: #ffd94a; }
.xgrid span.w { background: #3a1414; border-color: #e04848; color: #ff8f8f; }
.xgrid span.t { background: #33300f; border-color: #c9a227; color: #ffd94a; }
