:root {
    --erp-ink: #172033;
    --erp-muted: #64748b;
    --erp-border: #e2e8f0;
    --erp-canvas: #f4f7fb;
    --erp-primary: #2563eb;
    --erp-sidebar: #101827;
    --bs-primary: #2563eb;
    --bs-primary-rgb: 37, 99, 235;
    --bs-body-font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--erp-ink); background: var(--erp-canvas); font-size: .925rem; }
a { text-decoration: none; }
.btn { --bs-btn-border-radius: .65rem; font-weight: 650; }
.form-control, .form-select { min-height: 2.65rem; border-color: #cbd5e1; border-radius: .65rem; }
.form-control:focus, .form-select:focus { border-color: #60a5fa; box-shadow: 0 0 0 .22rem rgba(37,99,235,.12); }
.form-label { color: #344054; font-size: .84rem; font-weight: 650; }

.app-shell { display: grid; grid-template-columns: 272px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; width: 272px; height: 100vh; color: #cbd5e1; background: var(--erp-sidebar); border-right: 1px solid #1e293b; overflow-y: auto; }
.offcanvas-header { padding: 1.25rem 1rem; }
.brand { display: flex; align-items: center; gap: .75rem; color: #fff; }
.brand > span:last-child { display: flex; flex-direction: column; line-height: 1; }
.brand strong { font-size: 1.12rem; letter-spacing: -.02em; }
.brand small { margin-top: .33rem; color: #94a3b8; font-size: .65rem; font-weight: 700; letter-spacing: .17em; text-transform: uppercase; }
.brand-mark { display: grid; width: 2.5rem; height: 2.5rem; place-items: center; color: #fff; font-size: 1.15rem; font-weight: 800; background: linear-gradient(145deg,#60a5fa,#2563eb); border-radius: .78rem; box-shadow: 0 .45rem 1.3rem rgba(37,99,235,.35); }
.sidebar-nav { padding: 0 .7rem 1rem; }
.sidebar-nav a { display: flex; align-items: center; gap: .68rem; margin: .08rem 0; padding: .55rem .7rem; color: #cbd5e1; border-radius: .55rem; }
.sidebar-nav a span { width: 1.1rem; color: #94a3b8; text-align: center; }
.sidebar-nav a:hover, .sidebar-nav a.active { color: #fff; background: #1e293b; }
.sidebar-nav a.active { font-weight: 700; box-shadow: inset 3px 0 #60a5fa; }
.nav-label { margin: 1.15rem .7rem .38rem; color: #64748b; font-size: .64rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.sidebar-user { display: flex; align-items: center; gap: .65rem; padding: .9rem; border-top: 1px solid #293548; }
.sidebar-user strong { color: #f8fafc; font-size: .8rem; }
.sidebar-user a { color: #94a3b8; font-size: .72rem; }
.avatar { display: grid; flex: 0 0 auto; width: 2.2rem; height: 2.2rem; place-items: center; color: #dbeafe; font-weight: 800; background: #1d4ed8; border-radius: 50%; }

.main-content { min-width: 0; }
.topbar { position: sticky; z-index: 100; top: 0; display: flex; align-items: center; gap: 1rem; min-height: 78px; padding: .8rem clamp(1rem,3vw,2.2rem); background: rgba(255,255,255,.94); border-bottom: 1px solid var(--erp-border); backdrop-filter: blur(14px); }
.topbar h1 { margin: .08rem 0 0; font-size: clamp(1.25rem,2.4vw,1.75rem); font-weight: 760; letter-spacing: -.035em; }
.topbar-date { margin-left: auto; color: var(--erp-muted); font-variant-numeric: tabular-nums; }
.eyebrow { color: var(--erp-muted); font-size: .66rem; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.page-content { padding: clamp(1rem,3vw,2.2rem); }

.panel { background: #fff; border: 1px solid var(--erp-border); border-radius: 1rem; box-shadow: 0 1px 2px rgba(15,23,42,.04); overflow: hidden; }
.panel-header { display: flex; align-items: center; justify-content: space-between; padding: 1.15rem 1.25rem; border-bottom: 1px solid var(--erp-border); }
.panel-header h2 { margin: .1rem 0 0; font-size: 1.08rem; font-weight: 750; letter-spacing: -.02em; }
.panel-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--erp-border); }
.form-panel { padding: 1.25rem; }
.form-panel > .panel-header { margin: -1.25rem -1.25rem 1.2rem; }
.form-actions { display: flex; justify-content: flex-end; gap: .65rem; margin-top: 1.5rem; padding-top: 1.15rem; border-top: 1px solid var(--erp-border); }
.sticky-actions { position: sticky; z-index: 20; bottom: 0; margin: 0; padding: .85rem 1rem; background: rgba(255,255,255,.94); border: 1px solid var(--erp-border); border-radius: .9rem; backdrop-filter: blur(12px); }
.field-switch { min-height: 2.65rem; padding: .75rem 1rem .65rem 3rem; background: #f8fafc; border: 1px solid var(--erp-border); border-radius: .65rem; }
.record-id { margin-bottom: 1rem; padding: .7rem .85rem; color: #334155; background: #eff6ff; border-radius: .65rem; }
.record-summary { padding: .75rem 1.25rem; color: var(--erp-muted); font-size: .8rem; border-bottom: 1px solid var(--erp-border); }
.id-badge { color: #475569; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .78rem; }
.empty-row, .empty-state { padding: 3rem !important; color: var(--erp-muted); text-align: center; }
.empty-state { max-width: 650px; margin: 5vh auto; }
.empty-state h2 { color: var(--erp-ink); }
.empty-icon { display: grid; width: 3.2rem; height: 3.2rem; margin: 0 auto 1rem; place-items: center; color: #b42318; font-size: 1.4rem; font-weight: 800; background: #fee4e2; border-radius: 50%; }
.search-form { display: flex; width: min(100%, 430px); gap: .5rem; }
.table { --bs-table-hover-bg: #f8fafc; }
.table > :not(caption) > * > * { padding: .8rem 1rem; border-color: #edf1f5; }
.table thead th { color: #64748b; background: #f8fafc; font-size: .7rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; }

.stat-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 1rem; }
.stat-card { display: flex; align-items: center; gap: .9rem; padding: 1.15rem; color: inherit; background: #fff; border: 1px solid var(--erp-border); border-radius: .95rem; box-shadow: 0 1px 2px rgba(15,23,42,.04); transition: transform .15s ease, box-shadow .15s ease; }
.stat-card:hover { color: inherit; transform: translateY(-2px); box-shadow: 0 .7rem 1.8rem rgba(15,23,42,.08); }
.stat-icon { display: grid; flex: 0 0 auto; width: 2.8rem; height: 2.8rem; place-items: center; color: #1d4ed8; font-weight: 800; background: #dbeafe; border-radius: .8rem; }
.stat-card small { display: block; color: var(--erp-muted); font-size: .75rem; }
.stat-card strong { display: block; margin-top: .1rem; font-size: 1.55rem; letter-spacing: -.04em; }
.stat-arrow { margin-left: auto; color: #94a3b8; }
.content-grid { display: grid; grid-template-columns: minmax(0,2fr) minmax(270px,1fr); gap: 1rem; }
.quick-actions > a { display: flex; align-items: center; gap: .75rem; padding: .9rem 1.1rem; color: inherit; border-bottom: 1px solid #edf1f5; }
.quick-actions > a:hover { background: #f8fafc; }
.quick-actions > a > span { display: grid; width: 2rem; height: 2rem; place-items: center; color: #1d4ed8; font-weight: 800; background: #eff6ff; border-radius: .6rem; }
.quick-actions strong, .quick-actions small { display: block; }
.quick-actions small { margin-top: .1rem; color: var(--erp-muted); }

.document-toolbar { display: flex; justify-content: space-between; margin-bottom: 1rem; }
.invoice-sheet, .receipt-sheet { max-width: 1100px; margin-inline: auto; padding: clamp(1.25rem,4vw,3rem); }
.invoice-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding-bottom: 1.5rem; border-bottom: 2px solid var(--erp-ink); }
.invoice-header h2 { margin: .2rem 0; font-size: 2rem; }
.invoice-header p { margin: 0; color: var(--erp-muted); }
.invoice-status { padding: .48rem .75rem; color: #b54708; font-weight: 750; background: #fffaeb; border-radius: 2rem; }
.invoice-status.paid { color: #027a48; background: #ecfdf3; }
.invoice-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; padding: 1.7rem 0; }
.invoice-parties div { display: flex; flex-direction: column; }
.invoice-parties small { margin-bottom: .5rem; color: var(--erp-muted); font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.invoice-parties strong { margin-bottom: .3rem; font-size: 1.05rem; }
.invoice-parties span { color: var(--erp-muted); }
.invoice-lines { border: 1px solid var(--erp-border); }
.invoice-totals { display: flex; justify-content: flex-end; padding-top: 1.2rem; }
.invoice-totals dl { width: min(100%,340px); margin: 0; }
.invoice-totals dl div { display: flex; justify-content: space-between; padding: .35rem 0; }
.invoice-totals dt { color: var(--erp-muted); font-weight: 550; }
.invoice-totals dd { margin: 0; font-weight: 700; }
.invoice-totals .grand-total { margin-top: .4rem; padding-top: .8rem; font-size: 1.2rem; border-top: 2px solid var(--erp-ink); }
.receipt-sheet { text-align: center; }
.receipt-sheet h2 { margin: .5rem 0 2rem; font-size: 2rem; }
.receipt-value { margin: 1.5rem 0; font-size: clamp(2.5rem,7vw,5rem); font-weight: 800; letter-spacing: -.06em; }
.receipt-value small { font-size: .3em; letter-spacing: 0; }
.receipt-details { display: grid; grid-template-columns: repeat(3,1fr); gap: 1rem; margin-top: 2rem; text-align: left; }
.receipt-details div { padding: 1rem; background: #f8fafc; border-radius: .8rem; }
.receipt-details dt { color: var(--erp-muted); font-size: .72rem; text-transform: uppercase; }
.receipt-details dd { margin: .3rem 0 0; font-weight: 650; }

.login-page { display: grid; min-height: 100vh; padding: 1.25rem; place-items: center; background: radial-gradient(circle at 15% 10%,#dbeafe,transparent 35%),radial-gradient(circle at 90% 90%,#dcfce7,transparent 30%),#f8fafc; }
.login-card { display: grid; grid-template-columns: 1.1fr .9fr; width: min(100%,980px); min-height: 590px; background: #fff; border: 1px solid var(--erp-border); border-radius: 1.4rem; box-shadow: 0 2rem 5rem rgba(15,23,42,.13); overflow: hidden; }
.login-intro { display: flex; flex-direction: column; justify-content: space-between; padding: clamp(2rem,5vw,4rem); color: #fff; background: linear-gradient(145deg,#111827,#172554); }
.login-intro h1 { max-width: 520px; margin: .8rem 0 1rem; font-size: clamp(2rem,4vw,3.3rem); line-height: 1.02; letter-spacing: -.055em; }
.login-intro p { max-width: 520px; color: #cbd5e1; font-size: 1rem; line-height: 1.65; }
.login-kicker { color: #93c5fd; font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.login-form { display: flex; flex-direction: column; justify-content: center; padding: clamp(2rem,5vw,4rem); }
.login-form h2 { margin: .3rem 0; font-size: 2rem; }

@media (max-width: 991.98px) {
    .app-shell { display: block; }
    .sidebar { position: fixed; width: min(88vw,300px); }
    .stat-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .content-grid { grid-template-columns: 1fr; }
    .login-card { grid-template-columns: 1fr; max-width: 560px; }
    .login-intro { min-height: 280px; }
    .login-intro small { display: none; }
}

@media (max-width: 575.98px) {
    .page-content { padding: .8rem; }
    .topbar { min-height: 66px; padding: .7rem .8rem; }
    .topbar-date { display: none; }
    .stat-grid { grid-template-columns: 1fr 1fr; gap: .7rem; }
    .stat-card { padding: .85rem; }
    .stat-icon { width: 2.25rem; height: 2.25rem; }
    .stat-card strong { font-size: 1.2rem; }
    .stat-arrow { display: none; }
    .panel { border-radius: .8rem; }
    .panel-header { align-items: stretch; }
    .search-form { width: 100%; }
    .invoice-parties, .receipt-details { grid-template-columns: 1fr; gap: 1rem; }
    .invoice-sheet { padding: 1rem; }
    .invoice-header { flex-direction: column; }
    .login-page { padding: .65rem; }
    .login-card { min-height: calc(100vh - 1.3rem); border-radius: 1rem; }
    .login-intro { min-height: 230px; padding: 1.5rem; }
    .login-form { padding: 1.5rem; }
}

@media print {
    .sidebar, .topbar, .document-toolbar, .alert { display: none !important; }
    .app-shell { display: block; }
    .page-content { padding: 0; }
    .panel { border: 0; box-shadow: none; }
    body { background: #fff; }
}
