:root {
    --app-sidebar-width: 240px;
    --app-sidebar-bg: #16213a;
    --app-sidebar-fg: #c6cede;
    --app-accent: #2f6fed;
    --bs-primary: #2f6fed;
    --bs-primary-rgb: 47, 111, 237;
    --bs-link-color: #2f6fed;
    --bs-link-color-rgb: 47, 111, 237;
}
.btn-primary { --bs-btn-bg: #2f6fed; --bs-btn-border-color: #2f6fed; --bs-btn-hover-bg: #245bd0; --bs-btn-hover-border-color: #245bd0; --bs-btn-active-bg: #1f4fb6; }
.btn-outline-primary { --bs-btn-color: #2f6fed; --bs-btn-border-color: #2f6fed; --bs-btn-hover-bg: #2f6fed; --bs-btn-hover-border-color: #2f6fed; }

body.app-body { background: #f4f6fa; font-size: .925rem; }
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar { width: var(--app-sidebar-width); background: var(--app-sidebar-bg); color: var(--app-sidebar-fg); flex-shrink: 0; }
@media (min-width: 992px) {
    .app-sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; }
}
.app-sidebar.offcanvas-lg { --bs-offcanvas-bg: var(--app-sidebar-bg); --bs-offcanvas-color: var(--app-sidebar-fg); --bs-offcanvas-width: var(--app-sidebar-width); background-color: var(--app-sidebar-bg) !important; }
.app-brand { align-items: center; gap: .6rem; padding: 1.1rem 1.25rem; font-weight: 600; font-size: 1.05rem; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); }
.app-brand i { color: #7aa5ff; font-size: 1.35rem; }
.app-nav { padding: .75rem .5rem; }
.app-nav .nav-link { color: var(--app-sidebar-fg); border-radius: .4rem; padding: .5rem .75rem; display: flex; align-items: center; gap: .6rem; }
.app-nav .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.app-nav .nav-link.active { background: var(--app-accent); color: #fff; }
.app-nav .nav-heading { text-transform: uppercase; font-size: .7rem; letter-spacing: .06em; opacity: .6; padding: 1rem .75rem .35rem; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .75rem; padding: .6rem 1.5rem; background: #fff; border-bottom: 1px solid #e3e7ef; }
.app-search { position: relative; align-items: center; width: min(460px, 50vw); }
.app-search i { position: absolute; left: .6rem; color: #8a94a6; }
.app-search input { padding-left: 1.9rem; }
.app-content { padding: 1.5rem; flex: 1; }
@media (max-width: 576px) { .app-content { padding: 1rem .75rem; } }

.page-header { margin-bottom: 1.25rem; }
.page-header .breadcrumb { font-size: .8rem; margin-bottom: .35rem; }
.card { border-color: #e3e7ef; }
.card-header { background: #fff; font-weight: 600; }
.table > :not(caption) > * > * { padding: .6rem .75rem; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: #5b6475; background: #f8f9fc; white-space: nowrap; }
.table-card { margin-bottom: 0; }
.sort-link { color: inherit; text-decoration: none; }
.sort-link.active { color: var(--app-accent); }
.money, .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-card .stat-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: #6b7385; }
.stat-card .stat-value { font-size: 1.35rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: #6b7385; }
.empty-state i { font-size: 2rem; display: block; margin-bottom: .5rem; opacity: .6; }
.filter-bar .form-control, .filter-bar .form-select { font-size: .85rem; }
.pagination { margin-bottom: 0; }
.nav-tabs .nav-link { color: #5b6475; }
.form-section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: #6b7385; font-weight: 600; margin: 1.25rem 0 .75rem; border-bottom: 1px solid #e3e7ef; padding-bottom: .35rem; }
.form-section-title:first-child { margin-top: 0; }
dl.detail-list dt { font-weight: 500; color: #6b7385; font-size: .8rem; }
dl.detail-list dd { margin-bottom: .6rem; }

/* Invoice editor */
.items-table td { vertical-align: top; }
.items-table .form-control, .items-table .form-select { font-size: .85rem; }
.items-table > :not(caption) > * > * { padding: .45rem .35rem; }
.items-table .col-desc { min-width: 220px; width: 32%; }
.items-table .col-hsn input { min-width: 78px; }
.items-table .col-qty input { min-width: 68px; }
.items-table .col-unit input { min-width: 62px; }
.items-table .col-price input { min-width: 96px; }
.items-table .col-disc .input-group { min-width: 132px; }
.items-table .col-disc select { min-width: 64px; max-width: 64px; }
.items-table .col-tax select { min-width: 128px; }
.items-table .col-amount { min-width: 105px; text-align: right; white-space: nowrap; }
.items-table .col-actions { width: 90px; white-space: nowrap; }
.items-table tr.dragging { opacity: .5; }
.drag-handle { cursor: grab; color: #9aa3b5; }
.totals-table td { padding: .3rem .5rem; }
.totals-table .grand td { font-weight: 700; font-size: 1.05rem; border-top: 2px solid #dee2e6; }
.calc-status { font-size: .75rem; }
.autocomplete { position: relative; }
.autocomplete-menu { position: absolute; z-index: 1050; left: 0; right: 0; top: 100%; max-height: 280px; overflow-y: auto; background: #fff; border: 1px solid #d7dce5; border-radius: .4rem; box-shadow: 0 6px 16px rgba(20,30,60,.12); }
.autocomplete-menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: .45rem .75rem; font-size: .85rem; }
.autocomplete-menu button:hover, .autocomplete-menu button.active { background: #eef3ff; }
.autocomplete-menu small { color: #6b7385; }

/* Invoice document preview frame */
.doc-frame { background: #e9ecf2; padding: 1.5rem; border-radius: .5rem; overflow-x: auto; }
.doc-frame .invoice-doc { background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.08); margin: 0 auto; max-width: 210mm; min-width: 720px; }
@media (max-width: 576px) { .doc-frame { padding: .5rem; } }
.timeline { list-style: none; padding-left: 0; margin: 0; }
.timeline li { position: relative; padding-left: 1.25rem; padding-bottom: .9rem; border-left: 2px solid #e3e7ef; margin-left: .35rem; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: .3rem; width: 10px; height: 10px; border-radius: 50%; background: var(--app-accent); }
.timeline li:last-child { border-left-color: transparent; }

/* Guest pages */
body.guest-body { background: linear-gradient(135deg, #16213a 0%, #2f4f8f 100%); min-height: 100vh; }
.guest-wrap { max-width: 420px; margin: 0 auto; padding: 8vh 1rem 2rem; }
.guest-wrap h1 { color: #fff; }
.guest-logo { width: 56px; height: 56px; border-radius: 14px; background: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 1.75rem; color: var(--app-accent); }

@media print {
    .app-sidebar, .app-topbar, .page-actions, .no-print, .toast-container, .breadcrumb { display: none !important; }
    .app-content { padding: 0; }
    body.app-body { background: #fff; }
}

/* Column chart (single series). Mark specs: ≤24px bars, 4px rounded data end, hairline baseline. */
.bar-chart-plot { display: flex; align-items: flex-end; gap: 2px; height: 160px; border-bottom: 1px solid #dfe3ea; padding-top: 22px; }
.bar-slot { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; position: relative; outline: none; }
.bar-slot .bar { width: 100%; max-width: 24px; background: #2f6fed; border-radius: 4px 4px 0 0; }
.bar-slot:hover .bar, .bar-slot:focus .bar { background: #245bd0; }
.bar-peak-label { position: absolute; top: -20px; font-size: .7rem; color: #5b6475; white-space: nowrap; }
.bar-tip { display: none; position: absolute; bottom: calc(100% + 4px); z-index: 5; background: #fff; border: 1px solid #dfe3ea; border-radius: 6px; padding: 4px 8px; font-size: .75rem; color: #1f2430; white-space: nowrap; box-shadow: 0 4px 12px rgba(20,30,60,.12); pointer-events: none; }
.bar-slot:hover .bar-tip, .bar-slot:focus .bar-tip { display: block; }
.bar-slot:hover .bar-peak-label, .bar-slot:focus .bar-peak-label { visibility: hidden; }
.bar-chart-axis { display: flex; gap: 2px; margin-top: 4px; }
.bar-chart-axis span { flex: 1; text-align: center; font-size: .68rem; color: #6b7385; white-space: nowrap; overflow: hidden; }

/* Two-factor authentication */
.qr-box img { max-width: 100%; height: auto; background: #fff; padding: .5rem; border-radius: .375rem; }
.totp-secret { font-family: var(--bs-font-monospace); letter-spacing: .05em; word-break: break-all; user-select: all; }
.code-input { font-family: var(--bs-font-monospace); font-size: 1.25rem; letter-spacing: .3em; text-align: center; }
.recovery-codes { columns: 2; list-style: none; padding: 0; font-family: var(--bs-font-monospace); font-size: 1.05rem; }
.recovery-codes li { padding: .15rem 0; }
