:root {
  --bg: #f5f5f3; --surface: #ffffff; --surface-2: #fafaf8; --border: #e4e3de; --border-strong: #cfcdc6;
  --text: #0b0b0b; --text-2: #52514e; --muted: #807e78;
  --accent: #2a78d6; --accent-ink: #ffffff; --accent-soft: #e8f1fc;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a;
  --good: #0a7d0a; --good-soft: #e6f4e6; --warn: #8a5a00; --warn-soft: #fdf3dc;
  --bad: #c22f2f; --bad-soft: #fbe9e9; --info-soft: #eef2f7;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121211; --surface: #1a1a19; --surface-2: #20201f; --border: #2e2e2c; --border-strong: #42423f;
    --text: #ffffff; --text-2: #c3c2b7; --muted: #8f8e86;
    --accent: #3987e5; --accent-ink: #ffffff; --accent-soft: #17283d;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
    --good: #5cc65c; --good-soft: #15291a; --warn: #f0b84a; --warn-soft: #2e2510;
    --bad: #f07a7a; --bad-soft: #321718; --info-soft: #1f2530;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 650; }
h3 { font-size: 13px; margin: 0 0 8px; font-weight: 650; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.boot { padding: 60px; text-align: center; color: var(--muted); }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: Consolas, "SF Mono", Menlo, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }

/* layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--border); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; font-size: 15px; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 15px; font-weight: 800; flex: none; }
.brand.has-logo { flex-direction: column; align-items: flex-start; gap: 8px; }
.brand .logo-img { display: block; max-height: 48px; max-width: 180px; width: auto; height: auto; object-fit: contain; }
.side { overflow-x: hidden; }
.logo-row { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
/* Fixed-size box; any logo shape (wide, square, tall, any resolution) is scaled down to fit inside. */
.logo-preview { width: 220px; height: 100px; border: 1px dashed var(--border-strong); border-radius: 10px; display: flex; align-items: center; justify-content: center; background: #fff; padding: 8px; flex: none; overflow: hidden; }
.logo-preview img { display: block; width: 100%; height: 100%; object-fit: contain; }
.logo-row > div:last-child { flex: 1 1 260px; }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; color: var(--text-2); font-weight: 500; margin-bottom: 1px; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.nav .sec { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 10px 6px; }
.nav svg { width: 17px; height: 17px; flex: none; }
.nav .badge { margin-left: auto; }
.side .me { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); }
.shell > div { min-width: 0; }
.main { padding: 26px 32px 60px; min-width: 0; }
.head > div:first-child { flex: 1 1 320px; min-width: 0; }
.t td.mono { white-space: nowrap; }
.t td.issues { min-width: 180px; max-width: 280px; }
.topbar { display: none; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.head .sub { color: var(--muted); margin-top: 2px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.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)); }
.span2 { grid-column: span 2; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card .card-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); gap: 10px; flex-wrap: wrap; }
.card .card-head h2 { margin: 0; }
.stat .lbl { color: var(--text-2); font-size: 12.5px; font-weight: 500; }
.stat .val { font-size: 24px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .hint { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* tables */
.tbl-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-2); padding: 9px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.t td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.t tbody tr:last-child td { border-bottom: 0; }
.t tr.click { cursor: pointer; }
.t tr.click:hover td { background: var(--surface-2); }
.t tfoot td { font-weight: 650; background: var(--surface-2); border-top: 1px solid var(--border-strong); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--info-soft); color: var(--text-2); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.b-good { background: var(--good-soft); color: var(--good); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-bad { background: var(--bad-soft); color: var(--bad); }
.b-info { background: var(--accent-soft); color: var(--accent); }
.count { background: var(--bad); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 7px; }

/* forms */
label.f { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 12px; }
label.f > span { display: block; margin-bottom: 5px; }
label.f .req { color: var(--bad); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 7px; padding: 8px 10px; width: 100%; min-width: 0; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
input[type=checkbox] { width: auto; margin: 0 6px 0 0; vertical-align: -2px; }
.check { display: flex; align-items: center; font-weight: 500; color: var(--text); font-size: 13.5px; margin-bottom: 12px; }
.hint-text { font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 4px; }
.btn { font: inherit; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 7px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.good { background: var(--good); border-color: var(--good); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: default; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters label.f { margin: 0; }
.filters input, .filters select { width: auto; }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 13.5px; }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.good { background: var(--good-soft); color: var(--good); }
.alert.info { background: var(--info-soft); color: var(--text-2); }
.alert ul { margin: 4px 0 0; padding-left: 18px; }

/* line items editor */
.items td { padding: 6px 6px; border-bottom: 1px solid var(--border); }
.items th { padding: 6px; font-size: 12px; color: var(--text-2); text-align: left; }
.items input, .items select { padding: 6px 8px; }
.totals { margin-left: auto; width: 320px; max-width: 100%; }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; font-variant-numeric: tabular-nums; }
.totals .grand { border-top: 1px solid var(--border-strong); margin-top: 6px; padding-top: 8px; font-size: 17px; font-weight: 700; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: 100%; max-width: 440px; padding: 28px; }
.auth.wide .card { max-width: 620px; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: 12px; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* screenshot */
.shot { border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; min-height: 220px; overflow: hidden; }
.shot img { max-width: 100%; max-height: 560px; display: block; cursor: zoom-in; }
.shot.big img { max-height: none; cursor: zoom-out; }

/* chart */
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11.5px; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--text-2); margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.tip { position: fixed; z-index: 60; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; box-shadow: 0 6px 20px rgba(0,0,0,.15); font-variant-numeric: tabular-nums; }
.tip b { display: block; margin-bottom: 3px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--text-2); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
pre.code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow-x: auto; font-size: 12px; margin: 0 0 12px; white-space: pre; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 70; }
#toast div { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; margin-top: 8px; font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
#toast div.err { background: var(--bad); color: #fff; }

@media (max-width: 960px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3, .g2 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 40; left: 0; top: 0; width: 250px; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .side.open { transform: none; }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; font-weight: 700; }
  .main { padding: 18px 16px 50px; }
  .g4 { grid-template-columns: 1fr 1fr; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { margin-top: 6px; }
  .filters input, .filters select { width: 100%; }
  .filters label.f { flex: 1 1 140px; }
}
@media print {
  .side, .topbar, .filters, .btn { display: none !important; }
  .shell { display: block; }
  .card { box-shadow: none; }
}
.t.tight td { white-space: nowrap; }
.items input.desc { min-width: 170px; }
.items input.tx { min-width: 100px; }

/* dashboard analytics */
.delta { display: inline-block; font-size: 11.5px; font-weight: 650; padding: 0 6px; border-radius: 999px; margin-left: 2px; }
.delta.up { background: var(--good-soft); color: var(--good); }
.delta.down { background: var(--bad-soft); color: var(--bad); }
.meter { height: 6px; background: var(--border); border-radius: 999px; margin-top: 10px; overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 999px; }
.legend { flex-wrap: wrap; }
.legend i.dash, .tip i.dash { background: none !important; border-top: 2px dashed; height: 0; width: 14px; border-radius: 0; vertical-align: 3px; }
.legend i.dot { background: none !important; border-top: 2px dotted; height: 0; width: 14px; border-radius: 0; vertical-align: 3px; }
.legend i.line { height: 2px; width: 14px; border-radius: 1px; vertical-align: 3px; }
.legend i.ghost { opacity: .3; }
.legend i.tick { width: 2px; height: 12px; border-radius: 1px; background: var(--text); vertical-align: -2px; }
.chart .gridline.zero { stroke: var(--border-strong); }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .xhair { stroke: var(--border-strong); stroke-width: 1; }
.chart .today { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 2 3; }
.tip .trow { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.tip .trow b { margin-left: auto; padding-left: 14px; display: inline; }
.tip .trow i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; flex: none; }
details.tview { margin-top: 10px; }
details.tview summary { cursor: pointer; font-size: 12.5px; color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 7px; overflow: hidden; }
.seg button { font: inherit; font-size: 12.5px; border: 0; background: var(--surface); color: var(--text-2); padding: 5px 10px; cursor: pointer; }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.hbars { display: grid; gap: 10px; }
.hb { display: grid; grid-template-columns: minmax(80px, 140px) 1fr auto; align-items: center; gap: 10px; font-size: 13px; }
.hb-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.hb-t { position: relative; height: 16px; }
.hb-t span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; }
.hb-f { opacity: .28; }
.hb-k { width: 2px; background: var(--text); top: -3px !important; bottom: -3px !important; border-radius: 1px !important; margin-left: -1px; }
.hb-v { font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 12.5px; }
@media (max-width: 760px) { .hb { grid-template-columns: 90px 1fr auto; } }

/* purchase bill items */
/* Photo beside the form only on very wide screens; otherwise stacked so the item table has room. */
.billgrid { grid-template-columns: 1fr; }
@media (min-width: 1500px) { .billgrid { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); } }
.billgrid #shot img { max-height: 420px; }
.bill-items { width: 100%; border-collapse: collapse; min-width: 560px; }
.bill-items th { white-space: nowrap; }
.bill-items td { padding: 5px 4px; }
.bill-items input, .bill-items select { padding: 6px 7px; }
.bill-items input.desc { min-width: 140px; }
.bill-items input.hsn { width: 78px; }
.bill-items input.qty { width: 58px; }
.bill-items select.unit { width: 74px; }
.bill-items input.rt { width: 92px; }
.bill-items select.gr { width: 70px; }
.bill-items td.amt { min-width: 70px; padding-right: 8px; font-variant-numeric: tabular-nums; }

/* bill capture */
.pickbtn { justify-content: center; padding: 16px 14px; font-size: 15px; cursor: pointer; }
.drop { margin-top: 10px; border: 2px dashed var(--border-strong); border-radius: 10px; padding: 26px 12px; text-align: center; color: var(--muted); font-size: 13px; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; margin-right: 8px; vertical-align: -2px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (hover: none) { .drop { display: none; } }

/* ---------- EnRoll ---------- */
:root { --accent: #0e7a55; --accent-soft: #e3f4ec; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --accent: #1f9a6d; --accent-soft: #10291f; } }
.st-present { color: var(--good); }
.st-absent { color: var(--bad); }
.st-holiday { color: var(--muted); }
.st-paid { color: var(--accent); }
.t tr.flag td { background: var(--warn-soft); }
.t tr.off td { color: var(--muted); }
.punches { font-family: Consolas, "SF Mono", Menlo, monospace; font-size: 12px; color: var(--text-2); }
.slip { max-width: 900px; }
.slip .two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .slip .two { grid-template-columns: 1fr; } }
.slip .net { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-radius: 10px; background: var(--accent-soft); font-size: 18px; font-weight: 700; margin-top: 16px; }
.sync-ok { color: var(--good); }
.sync-err { color: var(--bad); }
.month-nav { display: inline-flex; align-items: center; gap: 6px; }
.month-nav input { width: auto; }
.wt-row, .slab-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 8px; margin-bottom: 8px; align-items: end; }
.slab-row { grid-template-columns: repeat(2, minmax(0, 1fr)) auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; }
