:root {
  --bg: #f6f7f9; --card: #fff; --ink: #1d2430; --muted: #5d6675; --line: #dfe3ea; --brand: #c2185b; --brand-ink: #fff;
  --ok-bg: #e7f6ec; --ok: #1d6b3a; --bad: #b3261e; --bad-bg: #fdecea; --warn: #8a5a00; --accent: #0b5cad;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 15px; color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--accent); }
h1 { font-size: 1.45rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 1.6rem 0 .6rem; }
.muted { color: var(--muted); } .small, small { font-size: .85em; } .bad { color: var(--bad); } .warnc { color: var(--warn); } .right { text-align: right; }
.mono { font-family: ui-monospace, Consolas, monospace; } .upper { text-transform: uppercase; }
.demo-bar { background: #fff4c2; color: #5b4300; text-align: center; padding: 6px 12px; font-size: .9em; border-bottom: 1px solid #ecd77a; }
header.top { background: #20232b; color: #fff; display: flex; align-items: center; gap: 16px; padding: 8px 16px; flex-wrap: wrap; position: sticky; top: 0; z-index: 5; }
.brand { color: #fff; font-weight: 700; text-decoration: none; white-space: nowrap; }
.nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.nav a { color: #d6d9e0; text-decoration: none; padding: 7px 10px; border-radius: 6px; white-space: nowrap; }
.nav a:hover { background: #333845; } .nav a.on { background: #3a4050; color: #fff; }
.nav a.primary { background: var(--brand); color: #fff; font-weight: 600; }
.me { font-size: .9em; white-space: nowrap; } .me .muted { color: #aab0bd; }
main { max-width: 1180px; margin: 0 auto; padding: 18px 16px 40px; } main.wide { max-width: 1400px; }
.foot { text-align: center; color: var(--muted); font-size: .85em; padding: 20px; }
.pagehead { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.btn { display: inline-block; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 8px; font: inherit; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:hover { border-color: #b9c0cc; } .btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.btn.small { padding: 4px 8px; font-size: .85em; } .btn.big { padding: 11px 22px; font-size: 1.05em; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
button.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font: inherit; text-decoration: underline; }
.me button.link { color: #9ec5ff; }
form.inline { display: inline; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; }
.card.inner { margin: 0; background: #fafbfc; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); border: 1px solid #b7e0c4; }
.flash.err { background: var(--bad-bg); color: var(--bad); border: 1px solid #f3b9b4; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters label { display: flex; gap: 6px; align-items: center; }
input, select, textarea { font: inherit; padding: 7px 9px; border: 1px solid #c8ced8; border-radius: 7px; background: #fff; color: var(--ink); max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #7fb0ea; outline-offset: 0; border-color: #7fb0ea; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field > span { font-weight: 600; font-size: .9em; }
.field small { color: var(--muted); }
.field input, .field select, .field textarea { width: 100%; }
.chk { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 18px; }
.grid2.tight { gap: 0 10px; }
.formbar { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 8px 0 14px; } legend { font-weight: 600; padding: 0 6px; }
.helper { background: #f2f6fb; border-radius: 8px; padding: 10px; } .helper input.small { width: 70px; padding: 4px 6px; }
.tablewrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid #edf0f4; text-align: left; vertical-align: top; }
th { background: #f3f5f8; font-size: .85em; color: #3e4755; font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 700; background: #f8f9fb; }
tr.sub td { background: #f8f9fb; font-weight: 600; } tr.inactive td { color: #8a919c; }
td.empty { text-align: center; color: var(--muted); padding: 22px; }
.tag { font-size: .75em; background: #eef0f4; border-radius: 4px; padding: 1px 6px; } .tag.bad { background: var(--bad-bg); color: var(--bad); }
.tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; }
.tabs a.on { color: var(--ink); border-color: var(--brand); font-weight: 600; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.kpi-l { color: var(--muted); font-size: .85em; } .kpi-v { font-size: 1.6rem; font-weight: 700; margin: 2px 0; font-variant-numeric: tabular-nums; } .kpi-s { font-size: .82em; color: var(--muted); }
.cards3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.big { font-size: 1.6rem; font-weight: 700; }
.link-card { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--ink); } .link-card b { color: var(--accent); } .link-card span { color: var(--muted); }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; margin-top: 10px; }
.bar { flex: 1; height: 100%; display: flex; align-items: flex-end; } .bar i { display: block; width: 100%; background: var(--brand); border-radius: 3px 3px 0 0; opacity: .85; }
.bars-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: .8em; margin-top: 4px; }
.login { max-width: 380px; margin: 60px auto; } .login.wide { max-width: 520px; } .login h1 { margin-bottom: 14px; }
.danger { border-color: #f3b9b4; }
/* bill form */
table.lines td { padding: 5px 6px; } table.lines select { width: 100%; min-width: 240px; }
table.lines input.qty { width: 70px; } table.lines input.rate { width: 95px; } table.lines input.disc { width: 65px; }
table.lines [data-stock] { display: block; margin-top: 2px; } table.lines [data-stock].bad { color: var(--bad); }
.totals > div { display: flex; justify-content: space-between; padding: 4px 0; font-variant-numeric: tabular-nums; }
.totals .grand { border-top: 2px solid var(--ink); margin-top: 6px; padding-top: 8px; font-size: 1.3rem; }
.totals .warn { color: var(--bad); font-size: .9em; display: block; }
/* invoice */
.invoice { background: #fff; border: 1px solid var(--line); padding: 22px; max-width: 900px; margin: 0 auto 16px; font-size: 13.5px; }
.invoice.cancelled { background: repeating-linear-gradient(135deg, #fff, #fff 30px, #fdf0ef 30px, #fdf0ef 60px); }
.inv-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 2px solid var(--ink); padding-bottom: 10px; }
.inv-biz { font-size: 1.35rem; font-weight: 700; } .inv-title { text-align: right; } .inv-t { font-size: 1.15rem; font-weight: 700; letter-spacing: .04em; }
.inv-parties { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.inv-lines th, .inv-lines td { padding: 5px 6px; border-bottom: 1px solid #e6e9ee; }
.inv-foot { display: grid; grid-template-columns: 3fr 2fr; gap: 20px; margin-top: 10px; }
.inv-tax { width: auto; min-width: 60%; } .inv-tax th, .inv-tax td { padding: 3px 8px; }
.inv-totals > div { display: flex; justify-content: space-between; padding: 3px 0; } .inv-totals .grand { border-top: 2px solid var(--ink); font-size: 1.15rem; padding-top: 6px; }
.sign { text-align: right; margin-top: 22px; }
.receipt h2 { margin-top: 18px; }
@media (max-width: 800px) {
  .grid2, .grid3, .cards3, .inv-parties, .inv-foot { grid-template-columns: 1fr; }
  header.top { gap: 6px; position: static; padding: 8px 12px; }
  .brand { width: 100%; }
  .nav { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: 4px; }
  .me { width: 100%; font-size: .85em; }
  table.lines thead { display: none; }
  table.lines tr.line { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 6px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
  table.lines tr.line td { border: 0; padding: 0; }
  table.lines tr.line td:first-child { grid-column: 1 / -1; }
  table.lines input.qty, table.lines input.rate, table.lines input.disc { width: 100%; }
  table.lines [data-gst-pct] { display: none; }
  table.lines [data-line-total] { grid-column: 1 / 4; text-align: left; font-weight: 600; align-self: center; }
  main { padding: 12px 16px 30px; }
  table.lines select { min-width: 170px; }
  .kpi-v { font-size: 1.3rem; }
  .invoice { overflow-x: auto; padding: 12px; font-size: 12.5px; }
  .inv-head { flex-direction: column; } .inv-title { text-align: left; }
}
@media print {
  header.top, .foot, .noprint, .demo-bar, .flash, .filters, .actions, .formbar { display: none !important; }
  body, main { background: #fff; padding: 0; margin: 0; max-width: none; }
  .invoice { border: 0; padding: 0; max-width: none; }
  .tablewrap, .card, .kpi { border-color: #999; break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}
