:root {
  --ink: #172033;
  --muted: #5b6577;
  --line: #dfe3ea;
  --bg: #f5f6f8;
  --card: #ffffff;
  --brand: #1d3f72;
  --brand-ink: #ffffff;
  --accent: #0f766e;
  --danger: #b42318;
  --draft: #64748b;  --draft-bg: #eef1f5;
  --submitted: #1d4ed8; --submitted-bg: #e7efff;
  --returned: #b45309; --returned-bg: #fff3e0;
  --approved: #6d28d9; --approved-bg: #f1ebff;
  --paid: #15803d; --paid-bg: #e6f6ec;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--brand); }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* top bar */
.top { background: var(--brand); color: var(--brand-ink); }
.top-in { max-width: 1180px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 18px; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 700; color: #fff; text-decoration: none; letter-spacing: .01em; }
.brand span { font-weight: 400; opacity: .75; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav a { color: #dbe6f7; text-decoration: none; padding: 6px 10px; border-radius: 6px; font-size: .92rem; }
.nav a:hover, .nav a.on { background: rgba(255,255,255,.14); color: #fff; }
.who { display: flex; align-items: center; gap: 10px; font-size: .88rem; color: #dbe6f7; }
.who form { margin: 0; }
.who button { background: none; border: 1px solid rgba(255,255,255,.35); color: #fff; border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: .85rem; }

main { max-width: 1180px; margin: 0 auto; padding: 22px 16px 60px; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; } }

/* status tiles */
.tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
@media (max-width: 760px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.tile { display: block; text-decoration: none; color: inherit; border-radius: 8px; padding: 12px 14px; border: 1px solid var(--line); background: #fff; border-top: 4px solid var(--c); }
.tile:hover { box-shadow: 0 2px 8px rgba(20,30,50,.08); }
.tile .lbl { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--c); font-weight: 700; }
.tile .n { font-size: 1.7rem; font-weight: 700; line-height: 1.15; }
.tile .amt { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.s-draft { --c: var(--draft); --cb: var(--draft-bg); }
.s-submitted { --c: var(--submitted); --cb: var(--submitted-bg); }
.s-returned { --c: var(--returned); --cb: var(--returned-bg); }
.s-approved { --c: var(--approved); --cb: var(--approved-bg); }
.s-paid { --c: var(--paid); --cb: var(--paid-bg); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; color: var(--c); background: var(--cb); white-space: nowrap; }

/* tables */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: #fafbfc; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f8fafc; }
tfoot td { font-weight: 700; border-bottom: none; }
td.flag { box-shadow: inset 3px 0 0 var(--returned); }
.miss { color: var(--returned); font-size: .82rem; }
.empty { color: var(--muted); padding: 14px 0; }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--brand); background: var(--brand); color: #fff; padding: 9px 16px; border-radius: 8px; font-size: .95rem; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: #fff; color: var(--brand); }
.btn.green { background: var(--accent); border-color: var(--accent); }
.btn.warn { background: #fff; color: var(--returned); border-color: var(--returned); }
.btn.danger { background: #fff; color: var(--danger); border-color: #f0c4bf; }
.btn.sm { padding: 5px 10px; font-size: .85rem; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form p, .field { margin: 0 0 12px; }
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=month], input[type=search], select, textarea {
  width: 100%; padding: 9px 10px; border: 1px solid #c9cfd8; border-radius: 7px; font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #93b4e6; border-color: var(--brand); }
.helptext { display: block; color: var(--muted); font-size: .8rem; margin-top: 3px; }
.errorlist { color: var(--danger); margin: 4px 0; padding-left: 18px; font-size: .85rem; }
.check label { display: flex; gap: 8px; font-weight: 500; align-items: flex-start; }
.check input { margin-top: 4px; }
.fgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 14px; }
.fgrid .wide { grid-column: 1 / -1; }
@media (max-width: 600px) { .fgrid { grid-template-columns: 1fr; } }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.filters > div { min-width: 140px; flex: 1; }
.filters label { font-size: .75rem; color: var(--muted); }

/* messages */
.msgs { list-style: none; padding: 0; margin: 0 0 16px; }
.msgs li { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; background: #e8f3ee; border: 1px solid #b8dcc8; }
.msgs li.error { background: #fdecea; border-color: #f3c0ba; }
.note { padding: 10px 14px; border-radius: 8px; background: var(--returned-bg); border: 1px solid #f2d3a6; margin-bottom: 14px; }
.note.info { background: #eef4ff; border-color: #c9d9f7; }

/* upload */
.drop { border: 2px dashed #b9c3d3; border-radius: 10px; padding: 18px; text-align: center; background: #fbfcfe; }
.drop input[type=file] { margin: 8px auto; max-width: 100%; }

/* receipt preview on line page */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }
.receipt-view { background: #eef0f3; border-radius: 8px; padding: 8px; text-align: center; position: sticky; top: 12px; }
.receipt-view img { max-width: 100%; max-height: 78vh; border-radius: 4px; }
.receipt-view iframe { width: 100%; height: 78vh; border: 0; background: #fff; }

/* history */
.hist { list-style: none; margin: 0; padding: 0; }
.hist li { padding: 7px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.hist li:last-child { border: 0; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.big-total { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.login-wrap { max-width: 400px; margin: 7vh auto; }
.login-wrap .card { padding: 26px; }
.mobile-hide { }
.mobile-only { display: none; }
@media (max-width: 600px) { .mobile-hide { display: none; } .mobile-only { display: block; } }

td a { white-space: nowrap; }
@media (max-width: 700px) {
  .top-in { gap: 6px 12px; padding-top: 8px; }
  .brand { flex: 1; }
  .who span { display: none; }
  .nav { order: 3; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; }
  .nav a { white-space: nowrap; }
  .tiles { grid-template-columns: repeat(5, 1fr); gap: 6px; }
  .tile { padding: 8px 6px; border-top-width: 3px; }
  .tile .lbl { font-size: .62rem; letter-spacing: .02em; }
  .tile .n { font-size: 1.3rem; }
  .tile .amt { font-size: .68rem; }
  th, td { padding: 8px 6px; }
}

th a.sort { color: inherit; text-decoration: none; }
th a.sort:hover, th a.sort.on { color: var(--brand); }
.pager { display: flex; gap: 6px; align-items: center; justify-content: center; flex-wrap: wrap; margin-top: 14px; }

.who-link { color: #fff; font-size: .85rem; text-decoration: none; border: 1px solid rgba(255,255,255,.35); border-radius: 6px; padding: 4px 10px; white-space: nowrap; }
.who-link:hover { background: rgba(255,255,255,.14); }

/* upload buttons: hidden native file inputs inside styled labels */
.hidden-file { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
label.btn { position: relative; margin: 0; color: #fff; }
.touch-only, .touch-only-inline { display: none !important; }
@media (pointer: coarse) {
  .touch-only { display: inline-flex !important; }
  .touch-only-inline { display: inline !important; }
  .touch-hide { display: none !important; }
}

html.touch .touch-only { display: inline-flex !important; }
html.touch .touch-only-inline { display: inline !important; }
html.touch .touch-hide { display: none !important; }
@media (max-width: 700px) { .brand span { display: none; } .who-link { padding: 4px 8px; } }
