/* Original Bill Tracker -- ERP-style UI. No external fonts/CDNs: works on an offline LAN. */
:root {
  --bg: #f2f4f7;
  --panel: #ffffff;
  --ink: #1b2430;
  --ink-2: #3b4655;
  --muted: #6b7686;
  --line: #e1e6ed;
  --line-2: #eef1f5;
  --nav: #16283f;
  --nav-2: #1f3553;
  --nav-ink: #c6d2e1;
  --brand: #1f4e8c;
  --brand-2: #173d6f;
  --brand-soft: #e8f0fb;
  --ok: #157347;   --ok-soft: #e6f4ec;
  --warn: #a15c07; --warn-soft: #fdf3e2;
  --bad: #b42318;  --bad-soft: #fdecea;
  --info: #1d5fb8; --info-soft: #e7f0fc;
  --violet: #6a3fb5; --violet-soft: #f1ebfb;
  --teal: #0e7a7a; --teal-soft: #e3f4f3;
  --slate: #4b5565; --slate-soft: #eef0f3;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.45;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.mono { font-family: Consolas, "SFMono-Regular", Menlo, monospace; font-size: 12.5px; }

/* ---------- shell */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--nav); color: var(--nav-ink); position: sticky; top: 0; height: 100vh; overflow-y: auto;
        display: flex; flex-direction: column; }
.brand { padding: 16px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand .logo { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; letter-spacing: .2px; }
.brand .logo i { width: 30px; height: 30px; border-radius: 7px; background: linear-gradient(135deg,#3b82f6,#1f4e8c);
                 display: grid; place-items: center; font-style: normal; font-size: 13px; }
.brand .sub { font-size: 11.5px; color: #8fa3bd; margin-top: 4px; }
.navsec { padding: 14px 10px 4px; }
.navsec h6 { margin: 0 8px 6px; font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: #7f93ad;
             font-weight: 600; }
.navsec a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 10px;
            border-radius: 6px; color: var(--nav-ink); font-size: 13.5px; }
.navsec a:hover { background: var(--nav-2); color: #fff; text-decoration: none; }
.navsec a.on { background: #2a4a74; color: #fff; box-shadow: inset 3px 0 0 #60a5fa; }
.navsec .cnt { font-size: 11px; background: rgba(255,255,255,.1); color: #dbe6f3; padding: 1px 7px; border-radius: 10px;
               min-width: 22px; text-align: center; }
.navsec .cnt.hot { background: #d97706; color: #fff; }
.navsec .cnt.red { background: #dc2626; color: #fff; }
.side .foot { margin-top: auto; padding: 12px 18px; font-size: 11px; color: #6f84a0; border-top: 1px solid rgba(255,255,255,.07); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { background: var(--panel); border-bottom: 1px solid var(--line); height: 56px; display: flex; align-items: center;
          justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 20; }
.topbar .crumb { font-size: 12px; color: var(--muted); }
.topbar h1 { font-size: 17px; margin: 0; font-weight: 650; }
.userchip { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.userchip .av { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-soft); color: var(--brand);
                display: grid; place-items: center; font-weight: 700; font-size: 12.5px; }
.userchip .role { font-size: 11px; color: var(--muted); }
.content { padding: 20px 24px 90px; }

/* ---------- flash */
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; font-size: 13.5px; border: 1px solid; }
.flash.ok { background: var(--ok-soft); color: var(--ok); border-color: #bfe3cd; }
.flash.error { background: var(--bad-soft); color: var(--bad); border-color: #f5c2bd; }
.flash.info { background: var(--info-soft); color: var(--info); border-color: #c4d8f5; }

/* ---------- panels / cards */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel + .panel { margin-top: 16px; }
.panel-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px;
           border-bottom: 1px solid var(--line); }
.panel-h h2, .panel-h h3 { margin: 0; font-size: 14.5px; font-weight: 650; }
.panel-b { padding: 16px; }
.hint { font-size: 12.5px; color: var(--muted); margin: 0 0 14px; max-width: 900px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

/* ---------- KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
       box-shadow: var(--shadow); display: block; color: inherit; border-top: 3px solid var(--line); }
.kpi:hover { text-decoration: none; border-color: #c8d3e1; }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi .v { font-size: 24px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.kpi.t-pending { border-top-color: #d97706; } .kpi.t-transit { border-top-color: #2563eb; }
.kpi.t-ho { border-top-color: #7c3aed; } .kpi.t-verified { border-top-color: #0d9488; }
.kpi.t-filed { border-top-color: #4f46e5; } .kpi.t-closed { border-top-color: #16a34a; }
.kpi.t-rejected { border-top-color: #dc2626; } .kpi.t-erp { border-top-color: #64748b; }

/* ---------- filter bar */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 12px 16px;
           border-bottom: 1px solid var(--line); background: #fafbfc; border-radius: var(--radius) var(--radius) 0 0; }
.filters label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 3px; font-weight: 600; }
.filters .f { min-width: 150px; }
.filters .f.grow { flex: 1; min-width: 220px; }

/* ---------- form controls */
input[type=text], input[type=password], input[type=date], input[type=search], select, textarea {
  width: 100%; height: 34px; padding: 6px 10px; border: 1px solid #cfd6e0; border-radius: 6px; background: #fff;
  font: inherit; font-size: 13.5px; color: var(--ink);
}
textarea { height: auto; min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bcd3f5; border-color: var(--brand); }
.field { margin-bottom: 12px; }
.field > label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.field .help { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.req::after { content: " *"; color: var(--bad); }

.btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 6px;
       border: 1px solid var(--brand); background: var(--brand); color: #fff; font: inherit; font-size: 13.5px;
       font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--brand-2); text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--ink-2); border-color: #cfd6e0; }
.btn.ghost:hover { background: #f5f7fa; }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn.bad { background: #fff; color: var(--bad); border-color: #f0b4ae; }
.btn.bad:hover { background: var(--bad-soft); }
.btn.bad.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }

/* ---------- data grid */
.tablewrap { overflow: auto; max-height: calc(100vh - 290px); }
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.grid th { position: sticky; top: 0; z-index: 2; background: #f6f8fa; text-align: left; font-weight: 600;
                font-size: 11.5px; letter-spacing: .02em; text-transform: uppercase; color: var(--muted);
                padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.grid td { padding: 7px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.grid tbody tr:hover td { background: #f8fafd; }
table.grid tr.sel td { background: #eaf2fe !important; }
table.grid td.cb, table.grid th.cb { width: 34px; text-align: center; padding-left: 12px; padding-right: 4px; }
table.grid tr.selectable { cursor: pointer; }
table.grid .sub { display: block; font-size: 11.5px; color: var(--muted); }
table.grid tfoot td { font-weight: 700; background: #fafbfc; border-top: 1px solid var(--line); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; vertical-align: middle; }
.empty { padding: 44px 16px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink-2); font-size: 14.5px; margin-bottom: 4px; }

/* ---------- pills */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
        white-space: nowrap; border: 1px solid transparent; }
.st-bill-booked { background: var(--slate-soft); color: var(--slate); }
.st-original-bill-pending { background: var(--warn-soft); color: var(--warn); border-color: #f6dcb1; }
.st-dispatched { background: var(--info-soft); color: var(--info); border-color: #c9dbf6; }
.st-in-transit { background: #dbeafe; color: #1e40af; border-color: #bcd4fa; }
.st-received-at-ho { background: var(--violet-soft); color: var(--violet); border-color: #dccdf5; }
.st-verified { background: var(--teal-soft); color: var(--teal); border-color: #bfe5e2; }
.st-filed { background: #e8e9fc; color: #4338ca; border-color: #cfd1f7; }
.st-closed { background: var(--ok-soft); color: var(--ok); border-color: #bfe3cd; }
.st-rejected-by-ho { background: var(--bad-soft); color: var(--bad); border-color: #f5c2bd; }
.st-received, .st-partly-received { background: var(--ok-soft); color: var(--ok); }
.st-not-received { background: var(--bad-soft); color: var(--bad); }
.pay-paid { background: var(--ok-soft); color: var(--ok); }
.pay-part { background: var(--warn-soft); color: var(--warn); }
.pay-unpaid { background: var(--slate-soft); color: var(--slate); }
.age-warn { color: var(--warn); font-weight: 600; }
.age-bad { color: var(--bad); font-weight: 700; }

/* ---------- bulk action bar */
.bulkbar { position: fixed; left: 236px; right: 0; bottom: 0; z-index: 30; background: #102036; color: #fff;
           display: flex; align-items: center; gap: 14px; padding: 10px 24px; transform: translateY(110%);
           transition: transform .15s ease; box-shadow: 0 -4px 14px rgba(0,0,0,.15); }
.bulkbar.show { transform: none; }
.bulkbar .info { font-size: 13.5px; }
.bulkbar .info b { font-size: 15px; }
.bulkbar .sp { flex: 1; }
.bulkbar .btn.ghost { background: transparent; color: #cfe0f5; border-color: #3a5577; }
.bulkbar .btn.ghost:hover { background: #1b3150; }

/* ---------- dialogs */
dialog { border: none; border-radius: 10px; padding: 0; width: min(560px, 94vw); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15,23,42,.45); }
dialog .dh { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between;
             align-items: center; }
dialog .dh h3 { margin: 0; font-size: 15.5px; }
dialog .dh .x { background: none; border: none; font-size: 20px; color: var(--muted); cursor: pointer; }
dialog .db { padding: 16px 18px; max-height: 70vh; overflow: auto; }
dialog .df { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px;
             background: #fafbfc; border-radius: 0 0 10px 10px; }
.selsum { background: var(--brand-soft); color: var(--brand-2); border-radius: 6px; padding: 8px 12px; font-size: 13px;
          margin-bottom: 14px; }
.auto { background: #f6f8fa; border: 1px dashed #cfd6e0; border-radius: 6px; padding: 8px 12px; font-size: 12.5px;
        color: var(--ink-2); margin-bottom: 12px; }
.auto b { color: var(--ink); }
.checklist label { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line);
                   border-radius: 6px; margin-bottom: 6px; cursor: pointer; font-size: 13.5px; }
.checklist label:hover { background: #f8fafd; }
.checklist input:checked + span { color: var(--ok); font-weight: 600; }
.seg { display: flex; border: 1px solid #cfd6e0; border-radius: 6px; overflow: hidden; }
.seg label { flex: 1; text-align: center; padding: 7px 6px; cursor: pointer; font-size: 13px; border-left: 1px solid #cfd6e0; }
.seg label:first-child { border-left: none; }
.seg input { display: none; }
.seg input:checked + span { font-weight: 700; color: var(--brand); }
.seg label:has(input:checked) { background: var(--brand-soft); }

/* ---------- detail page */
.stepper { display: flex; gap: 0; margin: 4px 0 18px; overflow-x: auto; }
.step { flex: 1; min-width: 110px; position: relative; padding: 10px 8px 0; text-align: center; font-size: 12px;
        color: var(--muted); }
.step::before { content: ""; position: absolute; top: 20px; left: -50%; width: 100%; height: 3px; background: var(--line); z-index: 0; }
.step:first-child::before { display: none; }
.step .dot { width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 2px solid #cfd6e0; margin: 0 auto 6px;
             position: relative; z-index: 1; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.step.done { color: var(--ink-2); }
.step.done .dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.step.done::before, .step.cur::before { background: var(--ok); }
.step.cur { color: var(--brand); font-weight: 700; }
.step.cur .dot { border-color: var(--brand); background: var(--brand); color: #fff; box-shadow: 0 0 0 4px #dbe8fb; }
.step.rej .dot { border-color: var(--bad); background: var(--bad); color: #fff; box-shadow: 0 0 0 4px #fbdcd8; }
.step.rej { color: var(--bad); }
.step .when { display: block; font-weight: 400; font-size: 10.5px; color: var(--muted); margin-top: 2px; }

dl.kv { display: grid; grid-template-columns: 170px 1fr; margin: 0; font-size: 13.5px; }
dl.kv dt { color: var(--muted); padding: 6px 0; border-bottom: 1px solid var(--line-2); }
dl.kv dd { margin: 0; padding: 6px 0; border-bottom: 1px solid var(--line-2); font-weight: 500; }
.banner { border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; font-size: 13.5px; }
.banner.bad { background: var(--bad-soft); border: 1px solid #f5c2bd; color: #7a1a12; }
.banner.ok { background: var(--ok-soft); border: 1px solid #bfe3cd; color: #0f5132; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; font-size: 13px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 6px; width: 9px; height: 9px; border-radius: 50%;
                       background: var(--brand); }
.timeline li::after { content: ""; position: absolute; left: 9px; top: 18px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline li.comment::before { background: #f59e0b; }
.timeline li.rej::before { background: var(--bad); }
.timeline .meta { font-size: 11.5px; color: var(--muted); }
.timeline .txt { margin-top: 2px; color: var(--ink-2); }
.timeline .bubble { background: #fffbeb; border: 1px solid #fde68a; border-radius: 6px; padding: 6px 10px; margin-top: 4px; }

/* ---------- misc */
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; }
.bar { height: 8px; border-radius: 4px; background: var(--line-2); overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; }
.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; padding: 10px 16px;
         border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 16px; }
.tabs a { padding: 10px 12px; font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--ink); }

/* ---------- login */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: linear-gradient(150deg, #16283f 0%, #1f4e8c 100%); color: #dbe6f3; padding: 56px;
             display: flex; flex-direction: column; justify-content: center; }
.login-art h1 { color: #fff; font-size: 28px; margin: 0 0 10px; }
.login-art ol { padding-left: 18px; line-height: 2; font-size: 14px; color: #c3d3e8; }
.login-card { display: grid; place-items: center; padding: 32px; }
.login-card form { width: min(360px, 100%); }
.login-card h2 { margin: 0 0 4px; font-size: 20px; }
@media (max-width: 860px) { .login-wrap { grid-template-columns: 1fr; } .login-art { display: none; } }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; } .side { position: static; height: auto; } .bulkbar { left: 0; }
}

/* verify checklist: select-all row and optional tag */
.checklist label.checkall { background: #f6f8fa; font-weight: 600; border-style: dashed; }
.checklist em.opt { font-style: normal; font-weight: 400; color: var(--muted); font-size: 12px; }
.checklist input:checked + span em.opt { color: var(--ok); }

/* notifications */
a.notif { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-bottom: 1px solid var(--line-2);
          color: var(--ink); text-decoration: none; }
a.notif:hover { background: #f8fafd; text-decoration: none; }
a.notif .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; background: transparent; flex: none; }
a.notif.unread { background: #f6f9ff; }
a.notif.unread .dot { background: var(--brand); }
a.notif.unread.rejected .dot { background: var(--bad); }
a.notif .body { display: block; font-size: 13px; color: var(--ink-2); margin-top: 2px; }
a.notif .meta { display: block; font-size: 11.5px; color: var(--muted); margin-top: 3px; }
a.notif:not(.unread) b { font-weight: 500; }
.bell { position: relative; display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
        color: var(--ink-2); margin-right: 4px; }
.bell:hover { background: var(--line-2); text-decoration: none; }
.bell svg { width: 19px; height: 19px; }
.bell .n { position: absolute; top: 1px; right: 0; background: var(--bad); color: #fff; font-size: 10.5px; font-weight: 700;
           min-width: 17px; height: 17px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; }

/* column widths */
table.grid .c-trk { width: 1%; white-space: nowrap; font-size: 12px; }
table.grid .c-sup { min-width: 240px; }
table.grid td.c-sup { font-weight: 500; }
table.grid .c-site { max-width: 130px; min-width: 90px; font-size: 11.5px; line-height: 1.3; overflow-wrap: anywhere; }
table.grid .c-gst { width: 1%; white-space: nowrap; text-align: center; }
.pill.btype { background: #fff4e0; color: #8a5300; border-color: #f3d9a8; font-size: 10.5px; padding: 0 6px; }
