/* Mark Pulse – application styles (on top of Bootstrap 5.3) */
:root {
  --mp-brand: #4338ca;
  --mp-brand-2: #6366f1;
  --mp-brand-soft: #eef2ff;
  --mp-sidebar: #111433;
  --mp-sidebar-2: #1b1f4b;
  --mp-sidebar-w: 252px;
  --bs-primary: #4338ca;
  --bs-primary-rgb: 67, 56, 202;
  --bs-link-color: #4338ca;
  --bs-link-color-rgb: 67, 56, 202;
  --bs-body-font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --bs-border-radius: .55rem;
}
[data-bs-theme="dark"] {
  --mp-brand-soft: #1e1b4b;
  --mp-sidebar: #0b0d22;
  --mp-sidebar-2: #15183a;
  --bs-body-bg: #0f1226;
  --bs-tertiary-bg: #161a35;
  --bs-secondary-bg: #1b1f40;
  --bs-border-color: #2a2f57;
  --bs-link-color: #a5b4fc;
  --bs-link-color-rgb: 165, 180, 252;
}
.btn-primary { --bs-btn-bg: var(--mp-brand); --bs-btn-border-color: var(--mp-brand); --bs-btn-hover-bg: #3730a3; --bs-btn-hover-border-color: #3730a3; --bs-btn-active-bg: #312e81; --bs-btn-disabled-bg: var(--mp-brand); }
.btn-outline-primary { --bs-btn-color: var(--mp-brand); --bs-btn-border-color: var(--mp-brand); --bs-btn-hover-bg: var(--mp-brand); --bs-btn-hover-border-color: var(--mp-brand); --bs-btn-active-bg: var(--mp-brand); }
[data-bs-theme="dark"] .btn-outline-primary { --bs-btn-color: #a5b4fc; --bs-btn-border-color: #6366f1; }
.text-primary { color: var(--mp-brand) !important; }
[data-bs-theme="dark"] .text-primary { color: #a5b4fc !important; }
.bg-primary-subtle { background: var(--mp-brand-soft) !important; }

body.mp-app { background: var(--bs-tertiary-bg); min-height: 100vh; }

/* ---------- Sidebar ---------- */
.mp-sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--mp-sidebar-w); z-index: 1045;
  background: linear-gradient(180deg, var(--mp-sidebar), var(--mp-sidebar-2));
  color: #c7cbe8; display: flex; flex-direction: column;
}
@media (max-width: 991.98px) { .mp-sidebar.offcanvas-lg { width: var(--mp-sidebar-w); } }
.mp-brand { display: flex; align-items: center; padding: 1.1rem 1.1rem .9rem; border-bottom: 1px solid rgba(255,255,255,.06); }
.mp-brand-name { color: #fff; font-weight: 700; font-size: 1.1rem; letter-spacing: .2px; }
.mp-brand-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; font-weight: 800; color: #fff; font-size: .85rem; background: linear-gradient(135deg, #6366f1, #a855f7); box-shadow: 0 6px 18px rgba(99,102,241,.35); }
.mp-brand-mark.lg { width: 64px; height: 64px; font-size: 1.4rem; border-radius: 18px; }
.mp-brand-logo { max-height: 34px; max-width: 120px; border-radius: 6px; background: #fff; padding: 2px; }
.mp-nav { flex: 1; overflow-y: auto; padding: .5rem .6rem 1rem; }
.mp-nav-group { font-size: .68rem; text-transform: uppercase; letter-spacing: .09em; color: #7d83b5; padding: 1rem .7rem .35rem; }
.mp-nav-link { display: flex; align-items: center; gap: .7rem; color: #c7cbe8; text-decoration: none; padding: .52rem .75rem; border-radius: .55rem; font-size: .92rem; margin-bottom: 2px; transition: background .15s, color .15s; }
.mp-nav-link i { font-size: 1.05rem; opacity: .85; }
.mp-nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.mp-nav-link.active { background: linear-gradient(90deg, rgba(99,102,241,.95), rgba(124,58,237,.85)); color: #fff; box-shadow: 0 6px 16px rgba(79,70,229,.3); }
.mp-sidebar-foot { padding: .7rem 1.1rem; color: #6c72a6; border-top: 1px solid rgba(255,255,255,.06); }
.mp-admin .mp-sidebar { background: linear-gradient(180deg, #1f0f2e, #3b0d3a); }
.mp-admin .mp-nav-link.active { background: linear-gradient(90deg, #be185d, #9333ea); }

/* ---------- Main ---------- */
.mp-main { margin-left: var(--mp-sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
@media (max-width: 991.98px) { .mp-main { margin-left: 0; } }
.mp-topbar { position: sticky; top: 0; z-index: 1030; display: flex; align-items: center; gap: .75rem; padding: .6rem 1.25rem; background: var(--bs-body-bg); border-bottom: 1px solid var(--bs-border-color); }
.mp-search { position: relative; align-items: center; width: min(460px, 45vw); }
.mp-search > i { position: absolute; left: .75rem; color: var(--bs-secondary-color); }
.mp-search input { padding-left: 2.2rem; background: var(--bs-tertiary-bg); border-color: transparent; }
.mp-search input:focus { background: var(--bs-body-bg); }
.mp-search-results { width: 100%; top: 100%; max-height: 420px; overflow-y: auto; }
.mp-avatar { width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--mp-brand); color: #fff; font-size: .75rem; font-weight: 700; }
.mp-content { padding: 1.4rem 1.5rem 3rem; flex: 1; }
@media (max-width: 575.98px) { .mp-content { padding: 1rem .75rem 3rem; } }

.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.2rem; }
.page-head h1 { font-size: 1.45rem; font-weight: 700; margin: 0; }
.page-head .sub { color: var(--bs-secondary-color); font-size: .9rem; }

.card { border: 1px solid var(--bs-border-color); border-radius: .8rem; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: transparent; border-bottom: 1px solid var(--bs-border-color); font-weight: 600; padding: .85rem 1.1rem; }
.card-body { padding: 1.1rem; }

/* KPI tiles */
.kpi { position: relative; overflow: hidden; height: 100%; }
.kpi .kpi-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--bs-secondary-color); }
.kpi .kpi-value { font-size: 1.35rem; font-weight: 700; margin-top: .25rem; white-space: nowrap; }
.kpi .kpi-icon { position: absolute; right: .9rem; top: .9rem; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 1.2rem; }
.kpi-indigo .kpi-icon { background: #eef2ff; color: #4338ca; }
.kpi-green .kpi-icon { background: #ecfdf5; color: #047857; }
.kpi-red .kpi-icon { background: #fef2f2; color: #b91c1c; }
.kpi-amber .kpi-icon { background: #fffbeb; color: #b45309; }
.kpi-sky .kpi-icon { background: #f0f9ff; color: #0369a1; }
.kpi-violet .kpi-icon { background: #f5f3ff; color: #6d28d9; }
[data-bs-theme="dark"] .kpi .kpi-icon { background: rgba(255,255,255,.06) !important; }

/* Tables */
.table-mp { margin: 0; font-size: .9rem; }
.table-mp thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--bs-secondary-color); background: var(--bs-tertiary-bg); border-bottom-width: 1px; white-space: nowrap; font-weight: 600; }
.table-mp td { vertical-align: middle; }
.table-mp tbody tr:hover { background: var(--mp-brand-soft); }
.table-actions { white-space: nowrap; text-align: right; }
.table-actions .btn { padding: .15rem .45rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.filter-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.filter-bar .form-control, .filter-bar .form-select { width: auto; min-width: 140px; }
.range-pills .btn { font-size: .82rem; }

/* Forms */
.form-label { font-size: .84rem; font-weight: 600; margin-bottom: .3rem; }
.req::after { content: " *"; color: #dc2626; }
.form-section-title { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--bs-secondary-color); margin: 1.2rem 0 .6rem; }

/* Autocomplete */
.ac-wrap { position: relative; }
.ac-menu { position: absolute; z-index: 1060; left: 0; right: 0; top: 100%; max-height: 300px; overflow-y: auto; background: var(--bs-body-bg); border: 1px solid var(--bs-border-color); border-radius: .5rem; box-shadow: 0 12px 28px rgba(15,23,42,.18); display: none; margin-top: 2px; min-width: 260px; }
.ac-menu.show { display: block; }
.ac-item { padding: .45rem .7rem; cursor: pointer; font-size: .88rem; border-bottom: 1px solid var(--bs-border-color); }
.ac-item:last-child { border-bottom: 0; }
.ac-item small { color: var(--bs-secondary-color); display: block; font-size: .76rem; }
.ac-item.active, .ac-item:hover { background: var(--mp-brand-soft); }
.ac-empty { padding: .6rem .7rem; color: var(--bs-secondary-color); font-size: .85rem; }

/* Invoice editor */
.inv-editor .table { margin: 0; }
.inv-editor th { font-size: .72rem; text-transform: uppercase; color: var(--bs-secondary-color); white-space: nowrap; background: var(--bs-tertiary-bg); }
.inv-editor td { padding: .3rem; vertical-align: top; }
.inv-editor .form-control, .inv-editor .form-select { font-size: .88rem; padding: .32rem .5rem; }
.inv-editor .col-product { min-width: 260px; }
.inv-editor .col-num { width: 110px; }
.inv-editor .col-qty { width: 80px; }
.inv-editor .col-total { width: 130px; }
.inv-editor .line-total { font-weight: 600; padding-top: .45rem; text-align: right; }
.inv-editor .stock-hint { font-size: .72rem; color: var(--bs-secondary-color); }
.inv-totals .row-t { display: flex; justify-content: space-between; padding: .3rem 0; font-size: .95rem; }
.inv-totals .grand { font-size: 1.25rem; font-weight: 800; color: var(--mp-brand); border-top: 2px dashed var(--bs-border-color); margin-top: .3rem; padding-top: .5rem; }
[data-bs-theme="dark"] .inv-totals .grand { color: #a5b4fc; }
.kbd-help kbd { font-size: .7rem; }
input.enter-focus:focus, select.enter-focus:focus { box-shadow: 0 0 0 .2rem rgba(99,102,241,.35); border-color: #6366f1; }

/* Detail lists */
.dl-grid { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; font-size: .92rem; margin: 0; }
.dl-grid dt { color: var(--bs-secondary-color); font-weight: 500; }
.dl-grid dd { margin: 0; font-weight: 500; }

/* Charts */
.mp-chart { width: 100%; height: 240px; }
.mp-chart text { fill: var(--bs-secondary-color); font-size: 11px; }
.mp-chart .bar { fill: url(#mpGrad); }
.mp-chart .bar.alt { fill: #f59e0b; }
.mp-chart .grid { stroke: var(--bs-border-color); stroke-dasharray: 3 3; }
.mp-chart .bar:hover { opacity: .8; }

/* Timeline */
.timeline { list-style: none; padding-left: 1rem; border-left: 2px solid var(--bs-border-color); margin: 0; }
.timeline li { position: relative; padding: 0 0 1rem .8rem; }
.timeline li::before { content: ""; position: absolute; left: -1.42rem; top: .35rem; width: 12px; height: 12px; border-radius: 50%; background: var(--mp-brand); border: 2px solid var(--bs-body-bg); }

.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--bs-secondary-color); }
.empty-state i { font-size: 2.2rem; display: block; margin-bottom: .5rem; opacity: .5; }

/* Auth pages */
.mp-auth { background: var(--bs-tertiary-bg); }
.mp-auth-wrap { min-height: 100vh; display: flex; }
.mp-auth-side { flex: 1; flex-direction: column; justify-content: space-between; padding: 3.5rem; color: #fff; background: radial-gradient(1200px 600px at -10% -10%, #6366f1 0%, transparent 60%), radial-gradient(900px 500px at 110% 110%, #a855f7 0%, transparent 55%), #111433; }
.mp-auth-admin .mp-auth-side { background: radial-gradient(1200px 600px at -10% -10%, #be185d 0%, transparent 60%), radial-gradient(900px 500px at 110% 110%, #9333ea 0%, transparent 55%), #1f0f2e; }
.mp-auth-main { flex: 1; display: grid; place-items: center; padding: 2rem 1rem; }
.mp-auth-card { width: 100%; max-width: 410px; background: var(--bs-body-bg); border: 1px solid var(--bs-border-color); border-radius: 1rem; padding: 2rem; box-shadow: 0 20px 50px rgba(15,23,42,.08); }

/* Print */
@media print {
  .mp-sidebar, .mp-topbar, .no-print, .btn, .alert { display: none !important; }
  .mp-main { margin: 0 !important; }
  .mp-content { padding: 0 !important; }
  body { background: #fff !important; }
  .card { border: 0 !important; box-shadow: none !important; }
}

/* Small screens */
.kpi .kpi-label { padding-right: 46px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 575.98px) {
  .kpi .kpi-value { font-size: 1.02rem; white-space: normal; word-break: break-word; }
  .kpi .kpi-icon { width: 30px; height: 30px; font-size: .95rem; right: .6rem; top: .6rem; border-radius: 9px; }
  .kpi .kpi-label { padding-right: 34px; font-size: .7rem; }
  .page-head h1 { font-size: 1.2rem; }
  .card-body { padding: .85rem; }
}
