/* LedgerPro - professional, responsive UI on top of Bootstrap 5.3 */
:root {
  --lp-brand: #4f46e5;
  --lp-brand-dark: #4338ca;
  --lp-brand-rgb: 79, 70, 229;
  --lp-sidebar: #0f172a;
  --lp-sidebar-2: #1e293b;
  --lp-bg: #f4f6fb;
  --lp-card: #ffffff;
  --lp-border: #e5e8f0;
  --lp-muted: #64748b;
  --lp-pos: #059669;
  --lp-neg: #dc2626;
  --lp-radius: 14px;
  --lp-shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 16px rgba(15, 23, 42, .05);
  --sidebar-w: 264px;
  --bs-primary: var(--lp-brand);
  --bs-primary-rgb: var(--lp-brand-rgb);
  --bs-link-color: var(--lp-brand);
  --bs-link-hover-color: var(--lp-brand-dark);
  --bs-font-sans-serif: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bs-body-font-size: .925rem;
}
[data-bs-theme="dark"] {
  --lp-bg: #0b1120;
  --lp-card: #131c31;
  --lp-border: #243049;
  --lp-muted: #94a3b8;
  --lp-sidebar: #070d1a;
  --lp-sidebar-2: #131c31;
  --lp-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  --bs-body-bg: var(--lp-bg);
  --bs-body-color: #e2e8f0;
  --bs-border-color: var(--lp-border);
  --bs-tertiary-bg: #18233b;
}

body { background: var(--lp-bg); font-feature-settings: "tnum"; -webkit-font-smoothing: antialiased; }
.btn-primary { --bs-btn-bg: var(--lp-brand); --bs-btn-border-color: var(--lp-brand); --bs-btn-hover-bg: var(--lp-brand-dark); --bs-btn-hover-border-color: var(--lp-brand-dark);
  --bs-btn-active-bg: var(--lp-brand-dark); --bs-btn-active-border-color: var(--lp-brand-dark); --bs-btn-disabled-bg: var(--lp-brand); --bs-btn-disabled-border-color: var(--lp-brand); }
.btn-outline-primary { --bs-btn-color: var(--lp-brand); --bs-btn-border-color: var(--lp-brand); --bs-btn-hover-bg: var(--lp-brand); --bs-btn-hover-border-color: var(--lp-brand); --bs-btn-active-bg: var(--lp-brand-dark); }
.form-control:focus, .form-select:focus { border-color: var(--lp-brand); box-shadow: 0 0 0 .22rem rgba(var(--lp-brand-rgb), .15); }
.form-label { font-weight: 500; font-size: .82rem; color: var(--lp-muted); margin-bottom: .3rem; }
.form-control, .form-select { border-radius: 10px; }
.btn { border-radius: 10px; font-weight: 500; }
.text-pos { color: var(--lp-pos) !important; } .text-neg { color: var(--lp-neg) !important; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* ---------- shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--lp-sidebar); color: #cbd5e1; display: flex; flex-direction: column; flex-shrink: 0; }
@media (min-width: 992px) { .sidebar { position: sticky; top: 0; height: 100vh !important; width: var(--sidebar-w) !important; flex: 0 0 var(--sidebar-w) !important; background-color: var(--lp-sidebar) !important; color: #cbd5e1; } }
@media (max-width: 991.98px) { .sidebar { --bs-offcanvas-width: 280px; background: var(--lp-sidebar) !important; color: #cbd5e1; } }
.sidebar-brand { display: flex; align-items: center; gap: .75rem; padding: 1.1rem 1.1rem .9rem; color: #fff; }
.brand-mark { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-size: 1.6rem; color: #fff;
  background: linear-gradient(135deg, #6366f1, #8b5cf6); box-shadow: 0 8px 24px rgba(99, 102, 241, .45); }
.brand-mark.sm { width: 38px; height: 38px; border-radius: 11px; font-size: 1.15rem; flex-shrink: 0; box-shadow: none; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .4rem .7rem 1rem; scrollbar-width: thin; scrollbar-color: #334155 transparent; }
.nav-link-item, .nav-group-toggle { display: flex; align-items: center; gap: .7rem; width: 100%; padding: .55rem .75rem; border-radius: 10px; color: #cbd5e1;
  text-decoration: none; font-size: .9rem; background: none; border: 0; text-align: left; transition: background .15s, color .15s; }
.nav-link-item:hover, .nav-group-toggle:hover { background: var(--lp-sidebar-2); color: #fff; }
.nav-link-item i, .nav-group-toggle > i:first-child { font-size: 1.05rem; width: 1.3rem; text-align: center; opacity: .85; }
.nav-link-item.active { background: rgba(var(--lp-brand-rgb), .95); color: #fff; box-shadow: 0 4px 14px rgba(var(--lp-brand-rgb), .35); }
.nav-group { margin-top: .15rem; }
.nav-group-toggle { font-weight: 500; }
.nav-group-toggle .chev { margin-left: auto; font-size: .7rem; transition: transform .2s; }
.nav-group.open > .nav-group-toggle .chev { transform: rotate(180deg); }
.nav-group-items { display: none; margin: .1rem 0 .3rem 1.05rem; padding-left: .6rem; border-left: 1px solid #263349; }
.nav-group.open > .nav-group-items { display: block; }
.nav-group-items .nav-link-item { font-size: .86rem; padding: .45rem .65rem; }
.sidebar-foot { padding: .8rem 1.2rem; border-top: 1px solid #1e293b; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 100; display: flex; align-items: center; gap: .5rem; height: 62px; padding: 0 1rem;
  background: color-mix(in srgb, var(--lp-card) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--lp-border); }
@media (min-width: 992px) { .topbar { padding: 0 1.75rem; } }
.topbar-title { font-weight: 600; font-size: 1.05rem; }
.btn-icon { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 10px; color: inherit; background: transparent; border: 0; }
.btn-icon:hover { background: rgba(127, 127, 127, .12); }
.btn-user { display: flex; align-items: center; gap: .5rem; border: 0; background: transparent; color: inherit; border-radius: 12px; padding: .25rem .5rem; }
.btn-user:hover { background: rgba(127, 127, 127, .12); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--lp-brand); color: #fff; font-weight: 600; font-size: .85rem; }
.content { padding: 1rem; flex: 1; }
@media (min-width: 992px) { .content { padding: 1.5rem 1.75rem 2.5rem; } }

/* ---------- cards ---------- */
.card { background: var(--lp-card); border: 1px solid var(--lp-border); border-radius: var(--lp-radius); box-shadow: var(--lp-shadow); }
.card-header { background: transparent; border-bottom: 1px solid var(--lp-border); font-weight: 600; padding: .9rem 1.1rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-bottom: 1.1rem; }
.page-head h1 { font-size: 1.35rem; margin: 0; font-weight: 700; }
.page-head .sub { color: var(--lp-muted); font-size: .85rem; }
.page-head .actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }
.kpi { padding: 1.05rem 1.15rem; display: flex; gap: .9rem; align-items: center; height: 100%; }
.kpi .ico { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; font-size: 1.3rem; flex-shrink: 0; }
.kpi .lbl { font-size: .78rem; color: var(--lp-muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.kpi .val { font-size: 1.4rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: .78rem; color: var(--lp-muted); }
.ico-indigo { background: rgba(99, 102, 241, .14); color: #6366f1; } .ico-green { background: rgba(16, 185, 129, .14); color: #10b981; }
.ico-amber { background: rgba(245, 158, 11, .16); color: #d97706; } .ico-red { background: rgba(239, 68, 68, .14); color: #ef4444; }
.ico-sky { background: rgba(14, 165, 233, .14); color: #0ea5e9; } .ico-violet { background: rgba(139, 92, 246, .15); color: #8b5cf6; }

/* ---------- tables ---------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--lp-muted); font-weight: 600; border-bottom: 1px solid var(--lp-border); background: rgba(127, 127, 127, .05); white-space: nowrap; }
.table > tbody td { vertical-align: middle; border-color: var(--lp-border); }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: rgba(var(--lp-brand-rgb), .05); }
.dt-toolbar { display: flex; flex-wrap: wrap; gap: .6rem; padding: .85rem 1rem; border-bottom: 1px solid var(--lp-border); align-items: center; }
.dt-toolbar .search { position: relative; flex: 1 1 220px; max-width: 340px; }
.dt-toolbar .search i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--lp-muted); }
.dt-toolbar .search input { padding-left: 2.2rem; }
.dt-foot { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: space-between; align-items: center; padding: .7rem 1rem; border-top: 1px solid var(--lp-border); color: var(--lp-muted); font-size: .83rem; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .btn { padding: .2rem .5rem; }
.empty-state { text-align: center; color: var(--lp-muted); padding: 2.5rem 1rem; }
.empty-state i { font-size: 2.2rem; opacity: .5; display: block; margin-bottom: .4rem; }
.badge-soft { font-weight: 600; padding: .35em .65em; border-radius: 8px; font-size: .74rem; }
.b-green { background: rgba(16, 185, 129, .15); color: #059669; } .b-red { background: rgba(239, 68, 68, .14); color: #dc2626; }
.b-amber { background: rgba(245, 158, 11, .17); color: #b45309; } .b-gray { background: rgba(100, 116, 139, .16); color: #64748b; }
.b-blue { background: rgba(59, 130, 246, .15); color: #2563eb; } .b-violet { background: rgba(139, 92, 246, .15); color: #7c3aed; }
[data-bs-theme="dark"] .b-green { color: #34d399; } [data-bs-theme="dark"] .b-red { color: #f87171; } [data-bs-theme="dark"] .b-amber { color: #fbbf24; }
[data-bs-theme="dark"] .b-blue { color: #60a5fa; } [data-bs-theme="dark"] .b-violet { color: #a78bfa; }

/* stacked "card" rows on phones */
@media (max-width: 767.98px) {
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tbody tr { padding: .65rem 1rem; border-bottom: 1px solid var(--lp-border); }
  .table-stack tbody td { display: flex; justify-content: space-between; gap: 1rem; padding: .22rem 0; border: 0; text-align: right; }
  .table-stack tbody td::before { content: attr(data-label); font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--lp-muted); text-align: left; flex-shrink: 0; padding-top: .15rem; }
  .table-stack tbody td.row-actions { justify-content: flex-end; padding-top: .45rem; }
  .table-stack tbody td.row-actions::before, .table-stack tbody td[data-label=""]::before { display: none; }
  .table-stack .num { text-align: right; }
}

/* ---------- forms / modals ---------- */
.modal-content { border: 0; border-radius: 16px; background: var(--lp-card); }
.modal-header { border-bottom: 1px solid var(--lp-border); padding: .9rem 1.2rem; }
.modal-header .modal-title { font-weight: 600; font-size: 1.05rem; }
.modal-footer { border-top: 1px solid var(--lp-border); }
.confirm-icon { font-size: 2.4rem; color: var(--lp-brand); }
.confirm-icon.danger { color: var(--lp-neg); }
.section-title { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--lp-muted); font-weight: 700; margin: 1.1rem 0 .6rem; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .9rem 1.2rem; }
.detail-grid .k { font-size: .73rem; text-transform: uppercase; letter-spacing: .04em; color: var(--lp-muted); font-weight: 600; }
.detail-grid .v { font-weight: 500; word-break: break-word; }

/* ---------- document line editor ---------- */
.doc-lines { width: 100%; }
.doc-lines th { font-size: .72rem; text-transform: uppercase; color: var(--lp-muted); font-weight: 600; padding: .4rem .3rem; }
.doc-lines td { padding: .25rem .3rem; vertical-align: top; }
.doc-lines .form-control, .doc-lines .form-select { font-size: .86rem; padding: .35rem .5rem; }
.doc-totals { max-width: 340px; margin-left: auto; }
.doc-totals .tr { display: flex; justify-content: space-between; padding: .3rem 0; }
.doc-totals .tr.grand { border-top: 2px solid var(--lp-border); font-weight: 700; font-size: 1.15rem; margin-top: .3rem; padding-top: .6rem; }
@media (max-width: 767.98px) {
  .doc-lines thead { display: none; }
  .doc-lines, .doc-lines tbody, .doc-lines tr, .doc-lines td { display: block; width: 100%; }
  .doc-lines tr { border: 1px solid var(--lp-border); border-radius: 12px; padding: .6rem; margin-bottom: .6rem; position: relative; }
  .doc-lines td::before { content: attr(data-label); display: block; font-size: .68rem; color: var(--lp-muted); text-transform: uppercase; font-weight: 600; }
  .doc-lines td.rm { position: absolute; top: .3rem; right: .4rem; width: auto; }
  .doc-lines td.rm::before { display: none; }
}

/* ---------- reports ---------- */
.report-wrap { overflow-x: auto; }
.report-table { width: 100%; min-width: 520px; }
.report-table td, .report-table th { padding: .45rem .75rem; }
.report-table tr.r-header td { font-weight: 700; background: rgba(var(--lp-brand-rgb), .07); text-transform: uppercase; font-size: .78rem; letter-spacing: .04em; }
.report-table tr.r-subtotal td { font-weight: 600; border-top: 1px solid var(--lp-border); }
.report-table tr.r-total td { font-weight: 700; border-top: 2px solid var(--lp-border); border-bottom: 3px double var(--lp-border); background: rgba(127, 127, 127, .06); }
.report-table .indent-1 { padding-left: 1.6rem !important; } .report-table .indent-2 { padding-left: 2.6rem !important; }
.report-card { cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s; height: 100%; }
.report-card:hover { transform: translateY(-2px); border-color: var(--lp-brand); box-shadow: 0 8px 24px rgba(var(--lp-brand-rgb), .15); }
.report-card .ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 1.25rem; }
.chart-box { position: relative; height: 290px; }

/* ---------- auth / install ---------- */
.auth-body { min-height: 100vh; background: radial-gradient(1200px 600px at 10% -10%, #4338ca 0%, transparent 60%), radial-gradient(900px 500px at 110% 110%, #7c3aed 0%, transparent 55%), #0f172a; }
.tpl-card { cursor: pointer; display: block; }
.tpl-body { display: block; border: 1.5px solid var(--lp-border); border-radius: 12px; padding: .7rem .9rem; height: 100%; transition: .15s; }
.tpl-card:hover .tpl-body { border-color: var(--lp-brand); }
.btn-check:checked + .tpl-body { border-color: var(--lp-brand); background: rgba(var(--lp-brand-rgb), .08); box-shadow: 0 0 0 3px rgba(var(--lp-brand-rgb), .15); }

/* ---------- printable documents ---------- */
.print-doc { background: #fff; color: #111827; max-width: 860px; margin: 1.5rem auto; padding: 2.5rem; border-radius: 12px; box-shadow: var(--lp-shadow); font-size: .92rem; }
.print-doc h1 { font-size: 1.7rem; letter-spacing: .04em; margin: 0; }
.print-doc table { width: 100%; border-collapse: collapse; }
.print-doc th { background: #f3f4f6; text-align: left; padding: .5rem .6rem; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
.print-doc td { padding: .5rem .6rem; border-bottom: 1px solid #e5e7eb; }
.print-doc .r { text-align: right; }
.print-bar { max-width: 860px; margin: 1rem auto 0; display: flex; gap: .5rem; justify-content: flex-end; padding: 0 .5rem; }
@media (max-width: 767.98px) { .print-doc { padding: 1.1rem; margin: .5rem; } }
@media print {
  body { background: #fff !important; }
  .sidebar, .topbar, .no-print, .print-bar, .dt-toolbar, .dt-foot, .page-head .actions, #toasts { display: none !important; }
  .content { padding: 0 !important; }
  .card { box-shadow: none !important; border: 0 !important; }
  .print-doc { box-shadow: none; margin: 0; max-width: none; padding: 0; }
  .report-wrap { overflow: visible; }
}

@media (max-width: 767.98px) { .doc-lines td { width: 100% !important; min-width: 0 !important; } }
