:root {
  --green: #0f3d2e; --green2: #1f5c45; --teal: #0e7c7b; --gold: #d4a72c; --gold2: #f3d77a;
  --bg: #f4f6f2; --card: #fff; --line: #e2e7e1; --text: #1c2420; --muted: #6b766f; --red: #c0392b; --ok: #1e8449;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans Tamil", sans-serif; background: var(--bg); color: var(--text); font-size: 15px; }
a { color: var(--teal); }
input, select, textarea, button { font: inherit; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid #cfd8d1; border-radius: 8px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold2); border-color: var(--gold); }
label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }
label input, label select, label textarea { margin-top: 4px; color: var(--text); font-weight: 400; font-size: 15px; }
input.big { font-size: 18px; font-weight: 700; color: var(--green); }

/* top + side */
header.top { position: fixed; inset: 0 0 auto 0; height: 58px; background: var(--green); color: #fff; display: flex; align-items: center; gap: 12px; padding: 0 14px; z-index: 30; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 800; font-size: 19px; flex: 1; }
.brand img { width: 38px; height: 38px; background: #fff; border-radius: 50%; padding: 3px; }
.brand small { display: block; font-size: 11px; font-weight: 400; color: var(--gold2); letter-spacing: .4px; }
.menu-btn { display: none; background: none; border: 0; color: #fff; font-size: 24px; cursor: pointer; }
nav.side { position: fixed; top: 58px; bottom: 0; left: 0; width: 220px; background: #fff; border-right: 1px solid var(--line); padding: 10px 8px; overflow-y: auto; z-index: 25; }
nav.side a { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 500; }
nav.side a span { width: 22px; text-align: center; }
nav.side a:hover { background: #f0f4ef; }
nav.side a.on { background: var(--green); color: #fff; }
.credit { font-size: 11px; color: var(--muted); text-align: center; margin-top: 18px; line-height: 1.5; }
.scrim { display: none; }
main { margin: 58px 0 0 220px; padding: 18px 22px 60px; max-width: 1300px; }
h1 { font-size: 22px; margin: 4px 0 14px; color: var(--green); }
h2 { font-size: 17px; margin: 0 0 10px; color: var(--green); }

/* parts */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 14px; }
.grid2, .grid3, .grid4 { display: grid; gap: 12px; }
.grid2 { grid-template-columns: repeat(2, 1fr); }
.grid3 { grid-template-columns: repeat(3, 1fr); }
.grid4 { grid-template-columns: repeat(4, 1fr); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1; min-width: 140px; }
.row > .btn, .row > button { flex: 0 0 auto; min-width: 0; }
.btn { display: inline-block; border: 1px solid var(--green2); background: #fff; color: var(--green); padding: 9px 16px; border-radius: 8px; cursor: pointer; text-decoration: none; font-weight: 600; white-space: nowrap; }
.btn:hover { background: #f0f4ef; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #1b1b1b; }
.btn.gold:hover { background: #c3981f; }
.btn.green { background: var(--green2); color: #fff; }
.btn.red { border-color: var(--red); color: var(--red); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-weight: 500; }
.flash.ok { background: #e3f4e8; color: var(--ok); border: 1px solid #b9e2c6; }
.flash.err { background: #fdecea; color: var(--red); border: 1px solid #f5c2bd; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.r { text-align: right; } .c { text-align: center; }
.neg, .due { color: var(--red); font-weight: 700; }
.pos { color: var(--ok); font-weight: 700; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 600; background: #eef2ee; }
.badge.red { background: #fdecea; color: var(--red); } .badge.green { background: #e3f4e8; color: var(--ok); }

/* tables */
.table-wrap { overflow-x: auto; }
table.list, table.items { width: 100%; border-collapse: collapse; }
table.list th, table.items th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); background: #f6f8f5; padding: 9px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 9px 8px; border-bottom: 1px solid #eef1ed; vertical-align: middle; }
table.list tr:hover td { background: #fafcf9; }
table.list th.r, table.items th.r { text-align: right; }
table.list tfoot td { font-weight: 700; background: #f6f8f5; }
table.items td { padding: 4px; border-bottom: 1px solid #eef1ed; vertical-align: top; }
table.items td.sn { padding-top: 12px; color: var(--muted); width: 28px; }
table.items td.amt { padding-top: 12px; font-weight: 700; white-space: nowrap; }
table.items input { padding: 7px 8px; }
table.items .code { color: var(--teal); font-size: 11px; }
table.items input.cat { margin-top: 3px; font-size: 12px; padding: 4px 8px; }
.w50 { width: 56px; } .w60 { width: 64px; } .w70 { width: 76px; } .w90 { width: 96px; }
input.r { text-align: right; }
button.x { border: 0; background: #fdecea; color: var(--red); border-radius: 6px; width: 30px; height: 32px; cursor: pointer; margin-top: 2px; }

/* billing */
.scan-row { display: flex; gap: 10px; }
.scan-row input { font-size: 16px; padding: 11px 12px; border: 2px solid var(--gold); }
.suggest { display: none; position: absolute; z-index: 20; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 320px; overflow-y: auto; width: min(620px, 90vw); }
.sg { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid #f1f1f1; }
.sg span { float: right; color: var(--muted); font-size: 13px; }
.sg.on, .sg:hover { background: #fff7dc; }
.cust-info { margin: -6px 0 12px 4px; font-size: 14px; min-height: 18px; }
.bill-bottom { display: grid; grid-template-columns: 1fr 420px; gap: 14px; align-items: start; }
.totals .trow { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px dashed #e7ebe6; gap: 10px; }
.totals .trow > span { color: var(--muted); font-weight: 600; font-size: 14px; }
.totals .trow input { width: 140px; text-align: right; font-weight: 700; }
.totals input.mini { width: 64px; padding: 4px 6px; display: inline-block; }
.totals .grand span, .totals .grand b { font-size: 20px; color: var(--green); }
.totals .bal.neg b, .totals .bal.neg span { color: var(--red); }
.quickpay { display: flex; gap: 8px; justify-content: flex-end; padding: 6px 0; }
.quickpay button { border: 1px solid var(--line); background: #f6f8f5; border-radius: 20px; padding: 4px 12px; font-size: 13px; cursor: pointer; }
.actions { display: flex; gap: 10px; margin-top: 12px; }
.actions .btn { flex: 1; padding: 12px; font-size: 16px; }

/* dashboard */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; border-top: 4px solid var(--teal); }
.stat:nth-child(2) { border-top-color: var(--gold); } .stat:nth-child(3) { border-top-color: var(--green2); } .stat:nth-child(4) { border-top-color: var(--red); }
.stat small { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.stat b { display: block; font-size: 24px; margin-top: 4px; color: var(--green); }
.stat span { font-size: 12px; color: var(--muted); }
.quick { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 14px; }
.quick a { display: block; background: var(--green); color: #fff; text-decoration: none; padding: 16px; border-radius: 12px; font-weight: 700; text-align: center; font-size: 16px; }
.quick a:first-child { background: var(--gold); color: #1b1b1b; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 10px; }
.bars div { flex: 1; background: var(--teal); border-radius: 4px 4px 0 0; position: relative; min-height: 2px; }
.bars div span { position: absolute; bottom: -20px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--muted); }
.bars div em { position: absolute; top: -18px; left: -10px; right: -10px; text-align: center; font-size: 10px; font-style: normal; color: var(--text); }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs a { padding: 7px 14px; border-radius: 20px; background: #fff; border: 1px solid var(--line); text-decoration: none; color: var(--text); font-weight: 600; font-size: 14px; }
.tabs a.on { background: var(--green); color: #fff; border-color: var(--green); }

/* login */
.login-page { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 30% 20%, #1f5c45, #0b2a20); }
.login-card { background: #fff; padding: 28px; border-radius: 16px; width: min(360px, 92vw); text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-card label { text-align: left; margin-bottom: 12px; }
.login-logo { width: 74px; height: 74px; }
.login-card h2 { font-size: 26px; margin: 6px 0 2px; }
.login-card .btn { margin-top: 6px; padding: 12px; }

@media (max-width: 1000px) {
  .bill-bottom { grid-template-columns: 1fr; }
  .stats, .quick { grid-template-columns: repeat(2, 1fr); }
  .grid4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 800px) {
  .menu-btn { display: block; }
  nav.side { transform: translateX(-100%); transition: transform .2s; box-shadow: 4px 0 20px rgba(0,0,0,.15); }
  body.nav-open nav.side { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 58px 0 0 0; background: rgba(0,0,0,.3); z-index: 20; }
  main { margin-left: 0; padding: 14px 10px 60px; }
  .hide-sm { display: none; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .scan-row { flex-direction: column; }
  .totals .trow input { width: 120px; }
  .totals input.mini { width: 50px; }
  .totals .trow > span { font-size: 13px; }
  .brand { font-size: 17px; }
}
