:root {
  --brand: #16a34a;
  --brand-600: #15803d;
  --brand-50: #ecfdf3;
  --ink: #14211a;
  --muted: #5f6f66;
  --line: #e3e9e5;
  --bg: #f3f6f4;
  --side: #0f2a1d;
  --side-ink: #b9cdbf;
  --radius: 14px;
  --bs-primary: var(--brand);
  --bs-primary-rgb: 22, 163, 74;
  --bs-link-color: var(--brand-600);
  --bs-link-color-rgb: 21, 128, 61;
  --bs-body-font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-body-color: var(--ink);
  --bs-border-color: var(--line);
}
html, body { background: var(--bg); }
body { font-size: .925rem; -webkit-font-smoothing: antialiased; }
.tiny { font-size: .72rem; }
.min-w-0 { min-width: 0; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
a { text-decoration: none; }

/* ---------- Buttons & form ---------- */
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand-600); --bs-btn-hover-border-color: var(--brand-600);
  --bs-btn-active-bg: var(--brand-600); --bs-btn-active-border-color: var(--brand-600); --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand); }
.btn-outline-primary { --bs-btn-color: var(--brand-600); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); --bs-btn-active-bg: var(--brand-600); }
.btn { border-radius: 10px; font-weight: 500; }
.btn-icon { border: 0; background: transparent; padding: .35rem .5rem; color: var(--ink); }
.btn-icon:hover { background: rgba(0,0,0,.05); }
.form-control, .form-select { border-radius: 10px; border-color: #d6ded9; }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(22,163,74,.15); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-label { font-weight: 600; font-size: .8rem; color: #33443a; margin-bottom: .3rem; }
.page-link { color: var(--brand-600); } .active > .page-link { background: var(--brand); border-color: var(--brand); }
@media (max-width: 991.98px) { .form-control, .form-select, .btn { min-height: 44px; } .btn-sm { min-height: 36px; } .form-control, .form-select { font-size: 16px; } }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 252px; background: var(--side); color: var(--side-ink); flex-shrink: 0; }
@media (min-width: 992px) { .sidebar.offcanvas-lg { background-color: var(--side) !important; } .sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; } }
@media (max-width: 991.98px) { .sidebar.offcanvas-lg { --bs-offcanvas-width: 280px; background: var(--side); } }
.sidebar-brand { display: flex; align-items: center; gap: .7rem; padding: 1.1rem 1rem; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, #34d36b, #0e8a3b); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 1.15rem; flex-shrink: 0; }
.brand-logo { width: 38px; height: 38px; object-fit: contain; border-radius: 8px; background: #fff; flex-shrink: 0; }
.brand-name { color: #fff; font-weight: 700; }
.brand-sub { font-size: .72rem; color: #8fb19c; }
.sidebar-nav { padding: .6rem .6rem 2rem; }
.sidebar-nav .nav-group { text-transform: uppercase; letter-spacing: .08em; font-size: .66rem; color: #6f927c; padding: 1rem .75rem .35rem; font-weight: 600; }
.sidebar-nav .nav-link { display: flex; align-items: center; gap: .7rem; color: var(--side-ink); padding: .5rem .75rem; border-radius: 9px; font-size: .875rem; }
.sidebar-nav .nav-link i { font-size: 1rem; opacity: .85; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav .nav-link.active { background: rgba(52,211,107,.16); color: #fff; box-shadow: inset 3px 0 0 #34d36b; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .5rem; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); padding: .55rem 1.25rem; min-height: 60px; }
.page-title { font-size: 1.1rem; font-weight: 700; margin: 0; }
.content { padding: 1.25rem; flex: 1; }
@media (max-width: 575.98px) { .content { padding: .9rem .75rem 5.5rem; } .topbar { padding: .5rem .6rem; } }
.app-footer { font-size: .75rem; color: var(--muted); padding: 1rem 1.25rem; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-50); color: var(--brand-600); display: grid; place-items: center; font-weight: 700; }
.notif-dot { position: absolute; top: 2px; right: 0; background: #ef4444; color: #fff; font-size: .62rem; border-radius: 10px; padding: 1px 5px; font-weight: 700; }
.notif-menu { width: 330px; max-width: 92vw; }
.notif-item { white-space: normal; border-bottom: 1px solid var(--line); padding: .6rem 1rem; }
.fab { position: fixed; right: 18px; bottom: 18px; width: 56px; height: 56px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 1.5rem; box-shadow: 0 8px 24px rgba(22,163,74,.4); z-index: 1030; }
.fab:hover { color: #fff; background: var(--brand-600); }
body.has-sticky-bar .fab { display: none !important; }

/* ---------- Cards / KPI ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(16,40,26,.04); }
.card-header { background: #fff; border-bottom: 1px solid var(--line); font-weight: 700; padding: .85rem 1rem; border-radius: var(--radius) var(--radius) 0 0 !important; }
.kpi { padding: 1rem; height: 100%; }
.kpi .label { font-size: .76rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 1.45rem; font-weight: 700; margin-top: .2rem; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: .76rem; color: var(--muted); }
.kpi .ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 1.1rem; }
.ico-green { background: #dcfce7; color: #15803d; } .ico-amber { background: #fef3c7; color: #b45309; } .ico-red { background: #fee2e2; color: #b91c1c; }
.ico-blue { background: #dbeafe; color: #1d4ed8; } .ico-slate { background: #e2e8f0; color: #334155; } .ico-teal { background: #ccfbf1; color: #0f766e; }
.chart-box { position: relative; height: 260px; }

/* ---------- Badges ---------- */
.badge { font-weight: 600; border-radius: 6px; padding: .35em .6em; }
.badge-soft-success { background: #dcfce7; color: #166534; } .badge-soft-warning { background: #fef3c7; color: #92400e; }
.badge-soft-danger { background: #fee2e2; color: #991b1b; } .badge-soft-info { background: #e0f2fe; color: #075985; }
.badge-soft-primary { background: #e0e7ff; color: #3730a3; } .badge-soft-secondary { background: #eef1f0; color: #475569; }
.badge-soft-dark { background: #1f2937; color: #f9fafb; }

/* ---------- Tables (transform into cards on mobile) ---------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; background: #f8faf9; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table > tbody td { vertical-align: middle; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #f6faf7; }
@media (max-width: 767.98px) {
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr { background: #fff; border: 1px solid var(--line); border-radius: 12px; margin: 0 0 .7rem; padding: .55rem .8rem; }
  .table-cards td { border: 0; padding: .28rem 0; display: flex; justify-content: space-between; gap: 1rem; text-align: right !important; }
  .table-cards td::before { content: attr(data-label); font-weight: 600; color: var(--muted); font-size: .75rem; text-align: left; flex-shrink: 0; }
  .table-cards td[data-label=""]::before { display: none; }
  .table-cards td.td-actions { justify-content: flex-end; border-top: 1px dashed var(--line); margin-top: .3rem; padding-top: .5rem; }
  .table-cards tfoot { display: block; } .table-cards tfoot tr { display: flex; justify-content: space-between; }
  .card .table-responsive:has(.table-cards) { padding: .7rem; }
}

/* ---------- Filters ---------- */
.filter-card .form-label { font-size: .72rem; }

/* ---------- Invoice form ---------- */
.step-num { width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: #fff; display: inline-grid; place-items: center; font-size: .8rem; font-weight: 700; margin-right: .5rem; }
.ac-wrap { position: relative; }
.ac-list { position: absolute; z-index: 1060; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 28px rgba(0,0,0,.12); max-height: 280px; overflow-y: auto; margin-top: 4px; display: none; }
.ac-list.show { display: block; }
.ac-item { padding: .55rem .8rem; cursor: pointer; border-bottom: 1px solid #f1f4f2; }
.ac-item:last-child { border-bottom: 0; }
.ac-item:hover, .ac-item.active { background: var(--brand-50); }
.ac-item .ac-sub { font-size: .75rem; color: var(--muted); }
.ac-new { color: var(--brand-600); font-weight: 600; }
.customer-chip { background: var(--brand-50); border: 1px solid #bbf7d0; border-radius: 12px; padding: .75rem 1rem; }
.line-row { border: 1px solid var(--line); border-radius: 12px; padding: .7rem; margin-bottom: .6rem; background: #fff; }
.line-row .line-total { font-weight: 700; }
.line-head { font-size: .72rem; text-transform: uppercase; color: var(--muted); font-weight: 700; letter-spacing: .05em; }
@media (min-width: 768px) {
  .line-row { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: .45rem 0; margin: 0; }
}
.summary-table td { padding: .35rem 0; }
.summary-table .grand td { font-size: 1.35rem; font-weight: 800; border-top: 2px solid var(--ink); padding-top: .6rem; }
.words { font-style: italic; color: var(--muted); font-size: .85rem; }
.pay-quick .btn-check:checked + .btn { background: var(--brand); color: #fff; border-color: var(--brand); }
.sticky-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1035; background: #fff; border-top: 1px solid var(--line); padding: .6rem .8rem calc(.6rem + env(safe-area-inset-bottom)); box-shadow: 0 -6px 20px rgba(0,0,0,.06); }
@media (min-width: 992px) { .sticky-bar { display: none; } }

/* ---------- Detail ---------- */
.dl-grid { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; }
.dl-grid dt { color: var(--muted); font-weight: 600; font-size: .8rem; }
.dl-grid dd { margin: 0; }
.money-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.money-strip > div { background: #f8faf9; border: 1px solid var(--line); border-radius: 12px; padding: .7rem .8rem; }
.money-strip .l { font-size: .72rem; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.money-strip .v { font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.void-row { opacity: .55; text-decoration: line-through; }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.25rem; background: radial-gradient(1200px 600px at 10% -10%, #d6f5e1 0, transparent 60%), radial-gradient(900px 500px at 110% 110%, #cdeedd 0, transparent 55%), var(--bg); }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .card-body { padding: 2rem; }

@media (max-width: 575.98px) { .kpi { padding: .75rem; } .kpi .label { font-size: .64rem; letter-spacing: 0; } .kpi .value { font-size: 1.15rem; } }
