:root {
    --brand: #7A1F2B;
    --brand-dark: #5c1620;
    --brand-soft: #f6e9eb;
    --ink: #1f2328;
    --muted: #6b7280;
    --bg: #f5f4f1;
    --card: #ffffff;
    --line: #e7e4df;
    --side: #2a1216;
    --side-ink: #e9dcde;
    --side-w: 248px;
    --green: #1f7a4d;
    --red: #b42318;
    --bs-body-font-family: 'Mukta', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --bs-link-color-rgb: 122, 31, 43;
    --bs-link-hover-color-rgb: 92, 22, 32;
}

body { background: var(--bg); color: var(--ink); font-size: 15px; }
a { text-decoration: none; }

/* ---------- sidebar ---------- */
.sidebar {
    background: var(--side) !important; /* Bootstrap's offcanvas-lg forces transparent on desktop */
    color: var(--side-ink);
    width: var(--side-w);
    --bs-offcanvas-width: var(--side-w);
    --bs-offcanvas-bg: var(--side);
}
@media (min-width: 992px) {
    .sidebar { position: fixed; inset: 0 auto 0 0; overflow-y: auto; z-index: 1030; }
    .main { margin-left: var(--side-w); }
}
.sidebar-brand {
    display: flex; align-items: center; gap: .75rem;
    padding: 1.1rem 1.1rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand > .bi { font-size: 1.6rem; color: #fff; background: var(--brand); width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.brand-name { color: #fff; font-weight: 700; line-height: 1.15; }
.brand-sub { font-size: .75rem; opacity: .6; }

.sidebar-nav { padding: .5rem .6rem 2rem; display: flex; flex-direction: column; width: 100%; }
.nav-group {
    font-size: .7rem; text-transform: uppercase; letter-spacing: .08em;
    opacity: .5; padding: 1rem .7rem .35rem;
}
.sidebar .nav-link {
    display: flex; align-items: center; gap: .75rem;
    color: var(--side-ink); border-radius: 8px;
    padding: .55rem .7rem; margin-bottom: 2px;
    transition: background .15s;
}
.sidebar .nav-link .bi { font-size: 1.1rem; width: 1.25rem; text-align: center; opacity: .85; }
.sidebar .nav-link .en { font-size: .95rem; font-weight: 500; line-height: 1.2; }
.sidebar .nav-link small { font-size: .72rem; opacity: .55; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar .nav-link.active { background: var(--brand); color: #fff; }
.sidebar .nav-link.active small { opacity: .8; }

/* ---------- top bar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 1020;
    display: flex; align-items: center; gap: .75rem;
    background: rgba(245,244,241,.92); backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--line);
    padding: .65rem 1.25rem;
}
.page-title { font-size: 1.2rem; font-weight: 700; margin: 0; }
.btn-icon { border: 0; background: transparent; font-size: 1.4rem; padding: .15rem .4rem; line-height: 1; }
.no-caret::after { display: none; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff; font-size: .95rem; font-weight: 600; display: inline-grid; place-items: center; }

.content { padding: 1.25rem; max-width: 1400px; }
@media (max-width: 575px) { .content { padding: .9rem; } .topbar { padding: .55rem .9rem; } }

/* ---------- buttons ---------- */
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover, .btn-brand:focus { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-outline-brand { border-color: var(--brand); color: var(--brand); }
.btn-outline-brand:hover { background: var(--brand); color: #fff; }
.form-control:focus, .form-select:focus { border-color: #b46a74; box-shadow: 0 0 0 .2rem rgba(122,31,43,.15); }
.form-label { font-weight: 500; font-size: .9rem; margin-bottom: .25rem; }

/* ---------- cards & stats ---------- */
.card { border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.card-header { background: transparent; border-bottom: 1px solid var(--line); font-weight: 600; padding: .8rem 1rem; }
.stat {
    background: var(--card); border: 1px solid var(--line); border-radius: 12px;
    padding: 1rem 1.1rem; height: 100%; display: flex; gap: .9rem; align-items: flex-start;
    color: inherit; transition: border-color .15s, transform .15s;
}
a.stat:hover { border-color: #c9a2a8; transform: translateY(-1px); color: inherit; }
.stat .ic { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; font-size: 1.25rem; flex: none; background: var(--brand-soft); color: var(--brand); }
.stat .ic.green { background: #e6f4ec; color: var(--green); }
.stat .ic.red { background: #fdecea; color: var(--red); }
.stat .ic.blue { background: #e8f0fb; color: #2456a6; }
.stat .ic.amber { background: #fdf3dc; color: #a15c00; }
.stat .lbl { font-size: .85rem; color: var(--muted); line-height: 1.2; }
.stat .val { font-size: 1.35rem; font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: .78rem; color: var(--muted); }

/* ---------- tables ---------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; border-bottom-width: 1px; white-space: nowrap; background: #faf9f7; }
.table td, .table th { vertical-align: middle; padding: .55rem .75rem; }
.table tfoot td, .table tfoot th { font-weight: 700; background: #faf9f7; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.cancelled td { text-decoration: line-through; opacity: .5; }
.empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem !important; }
.badge-soft { background: var(--brand-soft); color: var(--brand); font-weight: 500; }

/* ---------- filter bar ---------- */
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; margin-bottom: 1rem; }
.filters .form-control, .filters .form-select { min-width: 140px; }

/* ---------- bill entry ---------- */
.bill-lines td { padding: .35rem .4rem; }
.bill-lines .form-control, .bill-lines .form-select { padding: .3rem .5rem; }
.bill-lines .col-qty { width: 110px; } .bill-lines .col-rate { width: 130px; } .bill-lines .col-amt { width: 140px; }
.bill-lines .stock-hint { font-size: .75rem; color: var(--muted); }
.totals-box { background: #faf9f7; border: 1px solid var(--line); border-radius: 10px; padding: .9rem 1rem; }
.totals-box .row-t { display: flex; justify-content: space-between; align-items: center; padding: .2rem 0; gap: 1rem; }
.totals-box .grand { font-size: 1.25rem; font-weight: 700; border-top: 1px dashed #cfc9c1; margin-top: .3rem; padding-top: .5rem; }
@media (max-width: 767px) {
    .bill-lines thead { display: none; }
    .bill-lines tr { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: .35rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
    .bill-lines td { border: 0; padding: 0; width: auto !important; }
    .bill-lines td.col-item { grid-column: 1 / -1; }
}

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: linear-gradient(160deg, #2a1216 0%, #7A1F2B 100%); }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 16px; padding: 2rem; box-shadow: 0 20px 50px rgba(0,0,0,.25); }

/* ---------- printable bill ---------- */
.invoice { background: #fff; max-width: 800px; margin: 0 auto; padding: 2rem; border: 1px solid var(--line); border-radius: 12px; }
.invoice.thermal { max-width: 80mm; padding: 4mm; font-size: 12px; border-radius: 0; }
.invoice.thermal table td, .invoice.thermal table th { padding: 2px 0; font-size: 12px; }
.invoice h2 { font-weight: 700; margin: 0; }

@media print {
    body { background: #fff; }
    .sidebar, .topbar, .no-print, .alert { display: none !important; }
    .main { margin: 0 !important; }
    .content { padding: 0; max-width: none; }
    .invoice { border: 0; padding: 0; max-width: none; }
    .card { border: 0; box-shadow: none; }
    @page { margin: 10mm; }
}
