:root {
  --primary: #0E4D92; --accent: #F5A623; --primary-ink: #fff;
  --bg: #F3F5F8; --card: #fff; --ink: #1B2430; --muted: #66707D; --line: #E2E6EC; --soft: #EEF2F7;
  --ok: #1E8E4E; --ok-bg: #E6F4EC; --warn: #B26A00; --warn-bg: #FFF4E0; --bad: #C62828; --bad-bg: #FDECEC; --info-bg: #E8F0FB;
  --monthly: #2E6FD8; --seasonal: #C2410C;
  --r: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --side: 232px; --top: 56px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif; color: var(--ink); background: var(--bg); -webkit-tap-highlight-color: transparent; }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 20px; } h2 { font-size: 16px; } h3 { font-size: 14px; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
.num, td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); } .small { font-size: 12px; } .nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

/* layout */
.top { position: sticky; top: 0; z-index: 20; height: var(--top); display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: var(--primary); color: var(--primary-ink); box-shadow: 0 1px 0 rgba(0,0,0,.1); }
.top .logo { height: 36px; width: auto; max-width: 140px; object-fit: contain; background: #fff; border-radius: 6px; padding: 3px 6px; }
.top .brand { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.top .brand b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .brand span { font-size: 11.5px; opacity: .85; white-space: nowrap; }
.top .sp { flex: 1; }
.top .who { font-size: 12.5px; opacity: .9; text-align: right; line-height: 1.2; }
.top .who small { display: block; opacity: .8; text-transform: capitalize; }
.iconbtn { background: transparent; border: 0; color: inherit; padding: 8px; border-radius: 8px; cursor: pointer; display: inline-grid; place-items: center; }
.iconbtn:hover { background: rgba(255,255,255,.12); }
.shell { display: flex; min-height: calc(100vh - var(--top)); }
.side { width: var(--side); flex: none; background: var(--card); border-right: 1px solid var(--line); padding: 12px 10px; position: sticky; top: var(--top); height: calc(100vh - var(--top)); overflow-y: auto; }
.side a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; margin: 2px 0; border-radius: 8px; color: var(--ink); font-weight: 500; }
.side a:hover { background: var(--soft); }
.side a.on { background: color-mix(in srgb, var(--primary) 12%, #fff); color: var(--primary); font-weight: 650; box-shadow: inset 3px 0 0 var(--primary); }
.side .sec { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 12px 4px; }
.side svg, .bnav svg { width: 19px; height: 19px; flex: none; }
.main { flex: 1; min-width: 0; padding: 20px 24px 40px; max-width: 1400px; }
.bnav { display: none; }

@media (max-width: 860px) {
  .side { display: none; }
  .main { padding: 14px 12px calc(84px + env(safe-area-inset-bottom)); }
  .top { padding: 0 12px; } .top .who { display: none; }
  .bnav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--primary); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bnav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; color: rgba(255,255,255,.78); font-size: 11px; font-weight: 500; border-radius: 10px; margin: 0 2px; }
  .bnav a.on { color: var(--primary); background: var(--accent); font-weight: 700; }
}

/* page head */
.ph { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin-bottom: 16px; }
.ph .t { flex: 1; min-width: 200px; }
.ph .t p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.crumb { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.crumb a { color: var(--muted); } .crumb a:hover { color: var(--primary); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #c9d0da; background: #fafbfc; }
.btn.p { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.p:hover { filter: brightness(1.08); }
.btn.a { background: var(--accent); border-color: var(--accent); color: #1b1b1b; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--bad); border-color: #f1c4c4; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn svg { width: 16px; height: 16px; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.card > .hd { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card > .hd h2 { flex: 1; }
.card > .bd { padding: 16px; }
.grid { display: grid; gap: 14px; }
.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: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 860px) { .g2, .g3 { grid-template-columns: 1fr; } }
.mb { margin-bottom: 14px; } .mt { margin-top: 14px; }

/* KPI */
.kpi { padding: 14px 16px; }
.kpi .l { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi .v { font-size: 22px; font-weight: 750; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.hl { background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 70%, #000)); color: #fff; border: 0; }
.kpi.hl .l, .kpi.hl .s { color: rgba(255,255,255,.82); }
.split { display: grid; grid-template-columns: 1fr 1fr; }
.split > div { padding: 14px 16px; }
.split > div + div { border-left: 1px solid var(--line); }
@media (max-width: 520px) { .split { grid-template-columns: 1fr; } .split > div + div { border-left: 0; border-top: 1px solid var(--line); } }
.typehd { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.dot.m { background: var(--monthly); } .dot.s { background: var(--seasonal); }
.rows > div { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; font-size: 13px; }
.rows > div b { font-variant-numeric: tabular-nums; }

/* tabs & chips */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 600; border-bottom: 2.5px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--primary); border-color: var(--primary); }
.seg { display: inline-flex; background: var(--soft); border-radius: 9px; padding: 3px; gap: 2px; }
.seg a, .seg button { padding: 6px 12px; border-radius: 7px; color: var(--muted); font-weight: 600; font-size: 13px; border: 0; background: none; cursor: pointer; }
.seg .on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 650; white-space: nowrap; background: var(--soft); color: var(--muted); }
.tag.Monthly { background: #E6EEFB; color: var(--monthly); } .tag.Seasonal { background: #FDEEE6; color: var(--seasonal); }
.tag.Running, .tag.Settled, .tag.Closed-ok { background: var(--ok-bg); color: var(--ok); }
.tag.Upcoming, .tag.Submitted, .tag.Approved { background: var(--info-bg); color: var(--primary); }
.tag.Ended, .tag.Pending, .tag.Open, .tag.Partly { background: var(--warn-bg); color: var(--warn); }
.tag.Draft { background: var(--soft); color: var(--muted); }
.tag.Raised { background: #FFF1D6; color: #8a5300; }
.tag.Rejected { background: var(--bad-bg); color: var(--bad); }
.tag.Closed { background: #E9ECF1; color: #475467; }

/* tables */
.tw { overflow: auto; -webkit-overflow-scrolling: touch; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
.t th { position: sticky; top: 0; background: #F7F9FB; color: var(--muted); font-weight: 650; text-align: left; font-size: 12px; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.t tbody tr:hover td { background: #FAFBFD; }
.t tr.click { cursor: pointer; }
.t tfoot td { font-weight: 750; background: #F7F9FB; border-top: 2px solid var(--line); }
.t td.name { min-width: 180px; }
.t .sub { display: block; font-size: 11.5px; color: var(--muted); }
.t tr.unmatched td { background: #FFFAF0; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }

/* mobile list cards */
.lc { display: none; }
@media (max-width: 860px) {
  .hide-m { display: none !important; }
  .lc { display: block; }
  .lc .it { display: block; padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--ink); }
  .lc .it:last-child { border-bottom: 0; }
  .lc .r1 { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
  .lc .r1 b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .lc .r2 { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--muted); margin-top: 4px; }
  .lc .r2 b { color: var(--ink); font-variant-numeric: tabular-nums; }
}
@media (min-width: 861px) { .show-m { display: none !important; } }

/* forms */
.form { display: grid; gap: 12px; }
.fr { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: #3B4552; }
label.f small { font-weight: 400; color: var(--muted); }
.in, select.in, textarea.in { height: 38px; padding: 0 11px; border: 1px solid #CDD4DD; border-radius: 8px; background: #fff; width: 100%; min-width: 0; }
textarea.in { height: auto; min-height: 70px; padding: 9px 11px; resize: vertical; }
.in:focus { outline: 2px solid color-mix(in srgb, var(--primary) 35%, transparent); outline-offset: 0; border-color: var(--primary); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 14px; }
.filters label.f { min-width: 140px; flex: 1 1 140px; max-width: 240px; }
.search { position: relative; flex: 1 1 220px; max-width: 360px; }
.search input { padding-left: 34px; }
.search svg { position: absolute; left: 10px; top: 10px; width: 17px; height: 17px; color: var(--muted); }

.drop { border: 2px dashed #C3CCD8; border-radius: 12px; padding: 26px 16px; text-align: center; background: #FAFBFD; cursor: pointer; transition: .15s; }
.drop:hover, .drop.over { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 5%, #fff); }
.drop b { display: block; font-size: 15px; margin: 6px 0 2px; }
.drop svg { width: 34px; height: 34px; color: var(--primary); }
.note { padding: 10px 12px; border-radius: 8px; font-size: 13px; background: var(--info-bg); color: #1e3a5f; }
.note.warn { background: var(--warn-bg); color: #7a4a00; } .note.bad { background: var(--bad-bg); color: #8a1c1c; } .note.ok { background: var(--ok-bg); color: #14532d; }
.steps { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.steps span { padding: 4px 10px; border-radius: 999px; background: var(--soft); color: var(--muted); font-size: 12px; font-weight: 650; }
.steps span.on { background: var(--primary); color: #fff; }

/* settlement cards */
.sc { padding: 14px 16px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; }
.sc:last-child { border-bottom: 0; }
.sc .amt { text-align: right; font-variant-numeric: tabular-nums; }
.sc .amt b { font-size: 16px; display: block; }
.bar { height: 6px; background: var(--soft); border-radius: 99px; overflow: hidden; grid-column: 1 / -1; }
.bar i { display: block; height: 100%; background: var(--ok); border-radius: 99px; }

/* chart */
.chart { display: flex; align-items: flex-end; gap: 8px; height: 170px; padding: 8px 4px 0; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; height: 100%; justify-content: flex-end; }
.chart .stack { width: 100%; max-width: 38px; display: flex; flex-direction: column-reverse; border-radius: 5px 5px 0 0; overflow: hidden; }
.chart .stack i { display: block; }
.chart .lbl { font-size: 11px; color: var(--muted); white-space: nowrap; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* modal */
.modal { position: fixed; inset: 0; z-index: 100; background: rgba(15,23,42,.45); display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.mbox { background: #fff; border-radius: 14px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.mbox.wide { max-width: 860px; }
.mbox .mh { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.mbox .mh h2 { flex: 1; }
.mbox .mb { padding: 16px 18px; overflow: auto; }
.mbox .mf { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
@media (max-width: 860px) { .modal { place-items: end center; padding: 0; } .mbox { border-radius: 16px 16px 0 0; max-height: 92vh; } .mbox .mf { padding-bottom: calc(12px + env(safe-area-inset-bottom)); } }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; z-index: 200; background: #1f2937; color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: calc(100vw - 32px); }
.toast.bad { background: var(--bad); }
@media (max-width: 860px) { .toast { bottom: calc(86px + env(safe-area-inset-bottom)); } }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, var(--primary) 0%, color-mix(in srgb, var(--primary) 65%, #000) 100%); }
.login .card { width: 100%; max-width: 380px; padding: 28px 24px; }
.login .lg { text-align: center; margin-bottom: 18px; }
.login .lg img { max-height: 70px; max-width: 220px; }
.login .lg h1 { margin-top: 10px; font-size: 19px; }
.login .lg p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }

/* print statement */
.stmt { background: #fff; max-width: 820px; margin: 0 auto; padding: 32px; border: 1px solid var(--line); border-radius: 8px; }
.stmt .sh { display: flex; align-items: flex-start; gap: 16px; border-bottom: 3px solid var(--primary); padding-bottom: 14px; margin-bottom: 16px; }
.stmt .sh img { max-height: 60px; max-width: 180px; }
.stmt .sh .c { flex: 1; text-align: right; }
.stmt h1 { font-size: 18px; color: var(--primary); }
.stmt .meta { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 24px; font-size: 13px; margin-bottom: 16px; }
.stmt .meta b { display: inline-block; min-width: 110px; color: var(--muted); font-weight: 600; }
.stmt .sig { display: flex; justify-content: space-between; margin-top: 56px; font-size: 13px; }
.stmt .sig div { border-top: 1px solid #999; padding-top: 6px; min-width: 200px; text-align: center; }
/* debit note */
.dnote { position: relative; background: #fff; max-width: 820px; margin: 0 auto 16px; padding: 28px 32px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; overflow: hidden; }
.dnote .wm { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) rotate(-24deg); font-size: 90px; font-weight: 800; color: rgba(198,40,40,.12); letter-spacing: 6px; pointer-events: none; }
.dnote .dh { display: flex; gap: 16px; align-items: flex-start; }
.dnote .dh img { max-height: 64px; max-width: 190px; }
.dnote .co { flex: 1; text-align: right; display: flex; flex-direction: column; gap: 1px; }
.dnote .co b { font-size: 17px; color: var(--primary); }
.dnote .dt { display: flex; align-items: baseline; gap: 12px; justify-content: center; margin: 14px 0; padding: 7px; background: var(--primary); color: #fff; border-radius: 4px; }
.dnote .dt h1 { font-size: 18px; letter-spacing: 4px; }
.dnote .dt span { font-size: 12px; background: var(--accent); color: #222; padding: 1px 8px; border-radius: 99px; font-weight: 700; }
.dnote .db { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid #cfd6df; border-radius: 4px; }
.dnote .db > div { padding: 10px 12px; line-height: 1.55; }
.dnote .db > div + div { border-left: 1px solid #cfd6df; }
.dnote .lb { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.dnote .big { font-size: 15px; }
.dnote .kv div { display: flex; gap: 8px; } .dnote .kv span { min-width: 110px; color: var(--muted); }
.dnote .subj { margin: 12px 0 8px; }
.dnote .t th { position: static; background: #EEF2F7; color: #333; border: 1px solid #cfd6df; }
.dnote .t td { border: 1px solid #dfe4ea; padding: 6px 8px; }
.dnote .t tfoot td { background: #EEF2F7; }
.dnote .amt { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-top: 10px; padding: 10px 12px; border: 2px solid var(--primary); border-radius: 4px; }
.dnote .amt span { color: var(--muted); margin-right: 10px; } .dnote .amt b { font-size: 17px; } .dnote .amt .w { font-style: italic; text-align: right; }
.dnote .narr { color: #333; margin: 12px 0; }
.dnote .sg { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 24px; margin-top: 48px; text-align: center; }
.dnote .sg div { border-top: 1px solid #888; padding-top: 6px; }
.dnote .ack { margin-top: 26px; padding-top: 10px; border-top: 1px dashed #aaa; font-size: 12px; color: #444; }
.dnote .foot { margin-top: 10px; font-size: 10.5px; color: var(--muted); text-align: center; }
.pb { height: 0; }
@media (max-width: 700px) { .dnote { padding: 16px; } .dnote .db { grid-template-columns: 1fr; } .dnote .db > div + div { border-left: 0; border-top: 1px solid #cfd6df; } .dnote .sg { grid-template-columns: 1fr; gap: 30px; } .dnote .amt { flex-direction: column; align-items: flex-start; } .dnote .amt .w { text-align: left; } }
@media print {
  .dnote { border: 0; padding: 0; margin: 0; max-width: none; }
  .pb { page-break-after: always; break-after: page; }
  .dnote .dt { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  .top, .side, .bnav, .noprint, .toast { display: none !important; }
  .main { padding: 0; max-width: none; }
  .stmt { border: 0; padding: 0; max-width: none; }
  .t th { position: static; }
}
