:root {
  --brand: #0b6e4f;
  --brand-dark: #07503a;
  --brand-soft: #e3f1ec;
  --gold: #f2a900;
  --bg: #f3f6f4;
  --card: #ffffff;
  --ink: #17231e;
  --muted: #62736b;
  --line: #dbe4df;
  --danger: #b3261e;
  --warn: #b56a00;
  --radius: 14px;
  --nav-h: 64px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100vh; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
a { color: var(--brand); }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  background: var(--brand); color: #fff; padding: 0 12px; height: 52px;
  padding-top: env(safe-area-inset-top); box-sizing: content-box; }
.top h1 { font-size: 18px; font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .icon { background: transparent; border: 0; color: #fff; font-size: 30px; line-height: 1; width: 40px; height: 40px; cursor: pointer; }
.page { max-width: 720px; margin: 0 auto; padding: 14px 14px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom)); }
.bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: #fff; border-top: 1px solid var(--line);
  display: flex; justify-content: space-around; }
.bottom a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: 12px; font-size: 12px; position: relative; }
.bottom a .ico { font-size: 22px; line-height: 1; }
.bottom a.on { color: var(--brand); font-weight: 600; }
.bottom a.new .ico { background: var(--brand); color: #fff; width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 26px; margin-top: -14px; box-shadow: 0 3px 8px rgba(0,0,0,.25); }
.badge { position: absolute; top: 6px; left: calc(50% + 8px); background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 5px; }

.splash { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 80vh; color: var(--muted); gap: 10px; }
.spinner { width: 34px; height: 34px; border: 4px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- cards & lists ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card h2 { font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 10px; }
.empty { text-align: center; color: var(--muted); padding: 36px 10px; }
.empty b { display: block; font-size: 17px; color: var(--ink); margin-bottom: 4px; }

.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; }
.tabs button { flex: 0 0 auto; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 20px;
  font-size: 14px; cursor: pointer; min-height: 40px; }
.tabs button.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.tabs .n { background: var(--danger); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 6px; margin-left: 4px; }

.filters { display: flex; gap: 8px; margin-bottom: 10px; }
.filters input, .filters select { flex: 1; min-width: 0; }

.v-item { display: block; text-decoration: none; color: inherit; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.v-item:active { background: var(--brand-soft); }
.v-item .row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.v-item .num { font-weight: 700; }
.v-item .amt { font-weight: 700; white-space: nowrap; }
.v-item .payee { margin: 2px 0 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-item .meta { color: var(--muted); font-size: 13px; }

.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 12px; }
.s-wait { background: #fff2d6; color: #7a5200; }
.s-wait2 { background: #e1ecff; color: #1a47a0; }
.s-ok { background: #d9f2e4; color: #0a5a33; }
.s-paid { background: #0b6e4f; color: #fff; }
.s-ret { background: #fde2e0; color: #8c1d18; }
.s-can { background: #e8ecea; color: #51605a; }

/* ---------- forms ---------- */
label { display: block; font-size: 14px; font-weight: 600; margin: 12px 0 4px; }
label small { font-weight: 400; color: var(--muted); }
input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid #c3d0c9;
  border-radius: 10px; padding: 11px 12px; min-height: 46px; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.hint.warn { color: var(--warn); }
.error { color: var(--danger); font-size: 14px; margin-top: 8px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 0 18px;
  border-radius: 12px; border: 1px solid var(--brand); background: var(--brand); color: #fff; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; }
.btn:active { background: var(--brand-dark); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.block { display: flex; width: 100%; margin-top: 14px; }
.btn.ghost { background: #fff; color: var(--brand); }
.btn.warn { background: #fff; color: var(--warn); border-color: var(--warn); }
.btn.danger { background: #fff; color: var(--danger); border-color: var(--danger); }
.btn.small { min-height: 38px; padding: 0 12px; font-size: 14px; }
.actions { display: grid; gap: 10px; margin-top: 12px; }

.item-row { display: grid; grid-template-columns: 1fr 120px 40px; gap: 8px; margin-bottom: 8px; align-items: start; }
.item-row .rm { background: #fff; border: 1px solid var(--line); border-radius: 10px; min-height: 46px; font-size: 18px; color: var(--danger); cursor: pointer; }
.total-line { display: flex; justify-content: space-between; font-size: 18px; font-weight: 700; padding: 10px 2px 0; border-top: 2px solid var(--line); margin-top: 6px; }

.files { list-style: none; padding: 0; margin: 10px 0 0; }
.files li { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-bottom: 6px; background: #fafcfb; }
.files .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files .sz { color: var(--muted); font-size: 12px; }
.files button { border: 0; background: transparent; font-size: 18px; color: var(--danger); cursor: pointer; width: 32px; height: 32px; }
.file-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- voucher detail ---------- */
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 10px; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.big-amt { font-size: 28px; font-weight: 800; margin: 6px 0 2px; }
table.items { width: 100%; border-collapse: collapse; font-size: 15px; }
table.items td { padding: 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
table.items td:last-child { text-align: right; white-space: nowrap; padding-left: 10px; }
table.items tr.tot td { font-weight: 700; border-bottom: 0; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 14px 14px; }
.timeline li::before { content: ""; position: absolute; left: -23px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--brand); border: 2px solid #fff; }
.timeline li.ret::before { background: var(--danger); }
.timeline .who { font-weight: 600; }
.timeline .when { color: var(--muted); font-size: 13px; }
.timeline .cmt { background: #f5f8f6; border-radius: 8px; padding: 6px 10px; margin-top: 4px; font-size: 14px; }
.returned-banner { background: #fde2e0; color: #6d1410; border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }

/* ---------- auth ---------- */
.auth { max-width: 420px; margin: 0 auto; padding: 28px 18px 40px; }
.auth .logo { width: 72px; height: 72px; border-radius: 18px; display: block; margin: 8px auto 12px; }
.auth h1 { text-align: center; font-size: 24px; }
.auth .sub { text-align: center; color: var(--muted); margin: 4px 0 18px; }
.auth .links { display: flex; justify-content: space-between; margin-top: 14px; font-size: 14px; }
.auth .links a { cursor: pointer; }

/* ---------- admin ---------- */
.user-row { border-bottom: 1px solid var(--line); padding: 10px 0; }
.user-row:last-child { border-bottom: 0; }
.user-row .nm { font-weight: 600; }
.user-row .em { color: var(--muted); font-size: 13px; margin-bottom: 6px; word-break: break-all; }
.dept-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.dept-add { display: flex; gap: 8px; margin-top: 10px; }

/* ---------- modal & toast ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 14px; }
.modal .sheet { background: #fff; border-radius: 16px; max-width: 560px; width: 100%; max-height: 90vh; overflow: auto; padding: 14px; }
.modal img { width: 100%; height: auto; border-radius: 8px; display: block; }
.modal .bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 8px; }
.modal .bar b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 60;
  background: #1b2a24; color: #fff; padding: 10px 16px; border-radius: 12px; max-width: 90vw; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s; text-align: center; }
#toast.show { opacity: 1; }
#toast.err { background: var(--danger); }

@media (min-width: 760px) {
  .bottom { max-width: 720px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

.chip.s-high{background:#fde2e0;color:#8c1d18;font-weight:700}

.seg { display: flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 10px; background: #fff; }
.seg button { flex: 1; border: 0; background: #fff; color: var(--ink); padding: 11px 6px; font: inherit; font-size: 14px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--brand); color: #fff; font-weight: 600; }
