:root {
  --bg: #f4f1e8;
  --paper: #fffdf7;
  --ink: #1d2b26;
  --muted: #5f6e67;
  --line: #ddd6c4;
  --green: #1f6b4f;
  --green-dark: #123f2f;
  --green-soft: #e3f0e8;
  --gold: #c99a2e;
  --gold-soft: #f8edd2;
  --red: #b23b32;
  --red-soft: #f8e1de;
  --blue: #2c5d8a;
  --blue-soft: #e1ecf6;
  --shadow: 0 1px 2px rgba(29, 43, 38, .06), 0 4px 14px rgba(29, 43, 38, .06);
  --radius: 14px;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.45; }
a { color: var(--green); }
h1, h2, h3 { font-family: var(--display); font-weight: 600; margin: 0 0 .5rem; letter-spacing: -.01em; }
h1 { font-size: 1.8rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; font-family: var(--sans); font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num, .money { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.hidden { display: none !important; }

/* top bar */
.topbar { background: var(--green-dark); color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar .inner { max-width: 1180px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-size: 1.25rem; font-weight: 600; color: #fff; text-decoration: none; }
.brand .seal { width: 34px; height: 34px; border-radius: 50%; background: var(--gold); color: var(--green-dark); display: grid; place-items: center; font-family: var(--mono); font-weight: 700; font-size: 1rem; border: 2px solid #f3d98f; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: .9rem; opacity: .9; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a, .tabs button { color: #d7e8df; text-decoration: none; padding: 7px 12px; border-radius: 999px; font-size: .92rem; font-weight: 500; background: none; border: 0; cursor: pointer; font-family: inherit; }
.tabs a:hover, .tabs button:hover { background: rgba(255,255,255,.08); color: #fff; }
.tabs a.active, .tabs button.active { background: #fff; color: var(--green-dark); }
.tabs .badge { background: var(--gold); color: var(--green-dark); border-radius: 999px; padding: 0 6px; font-size: .75rem; margin-left: 4px; font-weight: 700; }

main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 60px; }

/* cards & grid */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid > .card + .card, .register > .card + .card, .row > .card + .card { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 26px 0 12px; flex-wrap: wrap; }
.section-title h2 { margin: 0; }

/* stat tiles */
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.stat .value { font-family: var(--mono); font-size: 1.55rem; font-weight: 600; margin-top: 4px; }
.stat .sub { font-size: .82rem; color: var(--muted); }

/* bank card hero */
.bankcard { position: relative; overflow: hidden; border-radius: 18px; padding: 22px 24px; color: #fff; min-height: 190px;
  background: radial-gradient(circle at 85% 15%, rgba(201,154,46,.45), transparent 45%), linear-gradient(135deg, #1f6b4f, #123f2f 70%);
  box-shadow: 0 10px 30px rgba(18, 63, 47, .25); display: flex; flex-direction: column; justify-content: space-between; }
.bankcard::after { content: ""; position: absolute; right: -40px; bottom: -60px; width: 220px; height: 220px; border-radius: 50%; border: 30px solid rgba(255,255,255,.05); }
.bankcard .bk-top { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; letter-spacing: .08em; text-transform: uppercase; opacity: .85; }
.bankcard .chip { width: 42px; height: 30px; border-radius: 6px; background: linear-gradient(135deg, #f3d98f, #c99a2e); }
.bankcard .bk-bal { font-family: var(--mono); font-size: 2.4rem; font-weight: 600; margin: 10px 0 2px; }
.bankcard .bk-name { font-family: var(--mono); letter-spacing: .12em; text-transform: uppercase; font-size: .9rem; opacity: .9; }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; gap: 6px; justify-content: center; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 9px 14px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #b9b19c; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-dark); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--green-dark); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: .85rem; border-radius: 8px; }
.btn.lg { padding: 13px 20px; font-size: 1.05rem; }
.btn.block { width: 100%; }
label { display: block; font-weight: 600; font-size: .88rem; margin: 12px 0 5px; }
label .hint { font-weight: 400; color: var(--muted); }
input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(31,107,79,.35); border-color: var(--green); }
textarea { min-height: 90px; resize: vertical; }
.inline-fields { display: grid; grid-template-columns: 2fr 3fr 1fr auto; gap: 8px; align-items: start; }
@media (max-width: 620px) { .inline-fields { grid-template-columns: 1fr 1fr; } }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 6px 0; }
.check input { width: auto; }

/* pills */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 700; text-transform: capitalize; }
.pill.pending { background: var(--gold-soft); color: #7a5a12; }
.pill.approved, .pill.active, .pill.paid { background: var(--green-soft); color: var(--green-dark); }
.pill.rejected, .pill.denied, .pill.closed, .pill.cancelled { background: var(--red-soft); color: var(--red); }
.pill.info { background: var(--blue-soft); color: var(--blue); }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--line); font-weight: 700; }
td { padding: 9px 8px; border-bottom: 1px solid #ece6d6; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
tr.refunded td { opacity: .5; text-decoration: line-through; }
tr.refunded td:last-child { text-decoration: none; }

/* business tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.tile { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); text-decoration: none; color: inherit; display: flex; gap: 12px; align-items: center; transition: transform .12s, box-shadow .12s; }
a.tile:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(29,43,38,.12); }
.logo { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; background: var(--green-soft); flex: none; display: grid; place-items: center; font-family: var(--display); font-size: 1.5rem; color: var(--green); border: 1px solid var(--line); }
.logo.lg { width: 84px; height: 84px; font-size: 2.2rem; border-radius: 16px; }
.tile .t-name { font-weight: 700; }
.tile .t-sub { font-size: .85rem; color: var(--muted); }
.tile.add { border-style: dashed; justify-content: center; color: var(--green); font-weight: 700; background: transparent; box-shadow: none; cursor: pointer; min-height: 90px; }

/* register */
.register { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) { .register { grid-template-columns: 1fr; } }
.item-buttons { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.item-btn { text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer; font: inherit; min-height: 86px; display: flex; flex-direction: column; justify-content: space-between; }
.item-btn:hover { border-color: var(--green); background: var(--green-soft); }
.item-btn .price { font-family: var(--mono); font-weight: 700; color: var(--green); }
.receipt { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; font-family: var(--mono); font-size: .9rem; }
.receipt .line { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.receipt .total { display: flex; justify-content: space-between; font-size: 1.3rem; font-weight: 700; padding-top: 10px; }
.qty { display: inline-flex; align-items: center; gap: 4px; }
.qty button { width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 700; }
.pin-input { font-family: var(--mono); font-size: 1.4rem; letter-spacing: .5em; text-align: center; }

/* charts */
.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .82rem; margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.bars .bar-row { display: grid; grid-template-columns: minmax(80px, 1fr) 2fr auto; gap: 10px; align-items: center; margin: 7px 0; font-size: .9rem; }
.bars .bar-track { background: #efe9da; border-radius: 6px; height: 12px; overflow: hidden; }
.bars .bar-fill { background: var(--green); height: 100%; border-radius: 6px; }
.empty { text-align: center; color: var(--muted); padding: 22px 10px; font-size: .92rem; }

/* notices */
.notice { border-radius: 12px; padding: 12px 14px; border: 1px solid; }
.notice.warn { background: var(--gold-soft); border-color: #ecd291; }
.notice.ok { background: var(--green-soft); border-color: #b8d8c6; }
.notice.err { background: var(--red-soft); border-color: #eab9b3; }
.notice.info { background: var(--blue-soft); border-color: #bcd3e8; }
.code-box { font-family: var(--mono); font-size: 1.5rem; letter-spacing: .2em; background: #fff; border: 2px dashed var(--gold); border-radius: 10px; padding: 6px 14px; display: inline-block; font-weight: 700; }

/* toast & modal */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 10px; z-index: 100; box-shadow: var(--shadow); max-width: 90vw; opacity: 0; pointer-events: none; transition: opacity .2s; }
#toast.show { opacity: 1; }
#toast.err { background: var(--red); }
.modal-bg { position: fixed; inset: 0; background: rgba(18, 30, 26, .5); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--paper); border-radius: 16px; max-width: 640px; width: 100%; max-height: 90vh; overflow-y: auto; padding: 22px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 20% 10%, rgba(201,154,46,.18), transparent 40%), var(--bg); }
.auth { width: 100%; max-width: 420px; }
.auth .brand { color: var(--green-dark); justify-content: center; font-size: 1.6rem; margin-bottom: 18px; }
.seg { display: flex; background: #ebe5d4; border-radius: 10px; padding: 4px; margin-bottom: 8px; }
.seg button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; color: var(--muted); }
.seg button.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }

.app-card { border-left: 4px solid var(--gold); }
.qa dt { font-weight: 700; font-size: .85rem; color: var(--muted); margin-top: 10px; }
.qa dd { margin: 2px 0 0; white-space: pre-wrap; }
.biz-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.biz-head .grow { flex: 1; min-width: 200px; }
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 18px 0 14px; border-bottom: 1px solid var(--line); }
.subtabs button { border: 0; background: none; padding: 9px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.subtabs button.active { color: var(--green-dark); border-color: var(--green); }
.picker { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: #fff; }
.picker h4 { margin: 8px 0 2px; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
