/* ==========================================================================
   DigitVilla Invoice – application styles (on top of Bootstrap 5)
   ========================================================================== */

:root {
    --brand: #1F7AE0;
    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #64748b;
    --line: #e6eaf0;
    --surface: #ffffff;
    --canvas: #f5f7fb;
    --sidebar-w: 256px;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .04);
    --shadow-lg: 0 10px 40px rgba(15, 23, 42, .12);
    --series-1: #2a78d6;
    --series-2: #eb6834;
    --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --bs-body-color: var(--ink);
    --bs-border-color: var(--line);
    --bs-link-color: var(--brand);
    --bs-link-hover-color: color-mix(in srgb, var(--brand) 80%, #000);
    --bs-primary: var(--brand);
}

html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--bs-body-font-family); color: var(--ink); background: var(--canvas); font-size: .925rem; }
a { text-decoration: none; }
.min-w-0 { min-width: 0; }
.maxw-220 { max-width: 220px; }
.maxw-320 { max-width: 320px; }
.text-brand { color: var(--brand) !important; }
.columns-2 { columns: 2; column-gap: 2rem; }
@media (max-width: 767.98px) { .columns-2 { columns: 1; } }

/* ---------- Buttons ---------- */
.btn { border-radius: 10px; font-weight: 500; }
.btn-lg { border-radius: 12px; font-size: 1rem; }
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(15, 23, 42, .08), inset 0 1px 0 rgba(255, 255, 255, .12); }
.btn-brand:hover, .btn-brand:focus { background: color-mix(in srgb, var(--brand) 88%, #000); border-color: color-mix(in srgb, var(--brand) 88%, #000); color: #fff; }
.btn-brand:disabled { background: var(--brand); color: #fff; opacity: .6; }
.btn-light { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-light:hover, .btn-light.active { background: #f1f4f9; border-color: #d6dce6; color: var(--ink); }
.btn-soft { background: color-mix(in srgb, var(--brand) 9%, #fff); color: var(--brand); border: 1px dashed color-mix(in srgb, var(--brand) 40%, #fff); }
.btn-soft:hover { background: color-mix(in srgb, var(--brand) 14%, #fff); color: var(--brand); }
.btn-icon { width: 36px; height: 36px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; color: var(--muted); border: 0; background: transparent; }
.btn-icon:hover { background: #eef2f7; color: var(--ink); }
.btn-icon.btn-sm { width: 30px; height: 30px; }
.btn.is-loading { position: relative; color: transparent !important; }
.btn.is-loading::after { content: ""; position: absolute; inset: 0; margin: auto; width: 1rem; height: 1rem; border: 2px solid rgba(255, 255, 255, .7); border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn-light.is-loading::after, .btn-outline-dark.is-loading::after { border-color: var(--muted); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */
.form-control, .form-select { border-radius: 10px; border-color: #dbe1ea; }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: color-mix(in srgb, var(--brand) 60%, #fff); box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--brand) 18%, transparent); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-label { font-weight: 500; color: var(--ink-2); margin-bottom: .35rem; font-size: .875rem; }
.input-group > .form-control, .input-group > .form-select, .input-group-text { border-radius: 10px; }
.input-group-text { background: #f6f8fb; border-color: #dbe1ea; color: var(--muted); }
.form-narrow { max-width: 960px; }

/* ---------- Layout ---------- */
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: #fff; border-right: 1px solid var(--line);
    display: flex; flex-direction: column; padding: 18px 14px; z-index: 1040; transition: transform .25s ease;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 700; font-size: 1.05rem; color: var(--ink); }
.sidebar-mark { width: 34px; height: 34px; object-fit: contain; }
.sidebar-logo { max-height: 38px; max-width: 190px; object-fit: contain; }
.sidebar-cta { border-radius: 12px; padding: .6rem; }
.sidebar-nav { flex: 1; overflow-y: auto; }
.nav-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #94a3b8; font-weight: 600; padding: 14px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: var(--ink-2); font-weight: 500; margin-bottom: 2px; transition: background .15s, color .15s; }
.nav-item i { font-size: 1.05rem; color: #94a3b8; transition: color .15s; }
.nav-item:hover { background: #f3f6fa; color: var(--ink); }
.nav-item.active { background: color-mix(in srgb, var(--brand) 10%, #fff); color: var(--brand); }
.nav-item.active i { color: var(--brand); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 12px 8px 4px; border-top: 1px solid var(--line); margin-top: 8px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 55%, #0f172a)); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: .85rem; flex-shrink: 0; }
.avatar-sm { width: 32px; height: 32px; font-size: .75rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.1rem; }
.avatar.soft { background: color-mix(in srgb, var(--brand) 12%, #fff); color: var(--brand); }
.avatar-btn { width: auto; height: auto; }

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: 14px; padding: 12px 28px; background: rgba(245, 247, 251, .85); backdrop-filter: saturate(180%) blur(10px); border-bottom: 1px solid transparent; }
.topbar-title { font-size: 1.3rem; font-weight: 700; margin: 0; letter-spacing: -.01em; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-search { position: relative; width: 300px; align-items: center; }
.topbar-search i { position: absolute; left: 12px; color: #94a3b8; }
.topbar-search .form-control { padding-left: 36px; background: #fff; border-color: var(--line); }
.content { padding: 8px 28px 40px; flex: 1; animation: fadeUp .25s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.sidebar-backdrop { display: none; }
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    body.sidebar-open .sidebar { transform: none; }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .4); z-index: 1035; }
    .main { margin-left: 0; }
    .topbar { padding: 10px 16px; }
    .topbar-title { font-size: 1.1rem; }
    .content { padding: 8px 16px 96px; }
}

/* ---------- Cards ---------- */
.app-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.app-card.p-0 { padding: 0; }
.card-title-sm { font-size: 1rem; font-weight: 650; margin: 0 0 .25rem; color: var(--ink); }
.card-header-flex { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.filter-card { padding: 14px 16px; }
.info-card { background: linear-gradient(180deg, #f8fbff, #fff); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.search-inline { position: relative; flex: 1; max-width: 420px; min-width: 220px; }
.search-inline i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #94a3b8; }
.search-inline .form-control { padding-left: 36px; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state > i { font-size: 2.4rem; color: #c3cddb; display: block; margin-bottom: 10px; }

.app-alert { border-radius: 12px; border: 0; box-shadow: var(--shadow); }
.alert-success { background: #ecfdf3; color: #05603a; }
.alert-danger { background: #fef3f2; color: #b42318; }
.alert-warning { background: #fffaeb; color: #93370d; }
.alert-info { background: #eff8ff; color: #175cd3; }

/* ---------- Dashboard ---------- */
.setup-banner { background: linear-gradient(120deg, color-mix(in srgb, var(--brand) 10%, #fff), #fff 70%); border: 1px solid color-mix(in srgb, var(--brand) 22%, #fff); border-radius: var(--radius); padding: 16px 20px; }
.setup-icon { width: 42px; height: 42px; border-radius: 12px; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; }
@media (max-width: 575.98px) { .setup-banner .d-flex { flex-wrap: wrap; } }

.quick-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.quick-action { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-radius: var(--radius); background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--ink); font-weight: 600; transition: transform .15s, box-shadow .15s, border-color .15s; }
.quick-action i { font-size: 1.35rem; width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: #f1f5fb; color: var(--brand); flex-shrink: 0; }
.quick-action:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--brand) 30%, #fff); color: var(--ink); }
.quick-action.qa-primary { background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 70%, #0f172a)); color: #fff; border-color: transparent; }
.quick-action.qa-primary i { background: rgba(255, 255, 255, .18); color: #fff; }
.quick-action.qa-primary:hover { color: #fff; }
@media (max-width: 991.98px) { .quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); } .quick-action { padding: 14px; } }

.stat-card { display: flex; align-items: center; gap: 14px; padding: 16px 18px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--ink); height: 100%; transition: border-color .15s, transform .15s; }
a.stat-card:hover { border-color: color-mix(in srgb, var(--brand) 30%, #fff); transform: translateY(-1px); color: var(--ink); }
.stat-icon { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.15rem; flex-shrink: 0; }
.tone-blue { background: #eaf2fd; color: #1f6fd0; }
.tone-slate { background: #f1f5f9; color: #475569; }
.tone-green { background: #e8f8ef; color: #12805c; }
.tone-amber { background: #fff4e0; color: #b45309; }
.tone-violet { background: #f1ecfe; color: #6d3fd8; }
.tone-red { background: #fdecec; color: #c2312c; }
.stat-label { font-size: .78rem; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 1.3rem; font-weight: 700; letter-spacing: -.01em; line-height: 1.25; }
@media (max-width: 575.98px) { .stat-value { font-size: 1.05rem; } .stat-card { padding: 12px; gap: 10px; } .stat-icon { width: 36px; height: 36px; } }

/* Chart */
.chart-wrap { position: relative; }
.bar-chart { width: 100%; height: auto; display: block; overflow: visible; }
.bar-chart .grid-line { stroke: #eef1f5; stroke-width: 1; }
.bar-chart .axis-line { stroke: #cbd5e1; stroke-width: 1; }
.bar-chart .axis-label { fill: #64748b; font-size: 12px; font-family: var(--bs-body-font-family); }
.bar-chart .bar.s1 { fill: var(--series-1); }
.bar-chart .bar.s2 { fill: var(--series-2); }
.bar-chart .hit { fill: transparent; }
.bar-chart .bar-group { outline: none; cursor: default; }
.bar-chart .bar-group .bar { transition: opacity .15s; }
.bar-chart .bar-group.is-dim .bar { opacity: .35; }
.bar-chart .bar-group:focus-visible .hit { fill: rgba(31, 122, 224, .06); }
.chart-legend { display: flex; gap: 14px; font-size: .8rem; color: var(--ink-2); }
.legend-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend-swatch.s1 { background: var(--series-1); }
.legend-swatch.s2 { background: var(--series-2); }
.chart-tooltip { position: absolute; pointer-events: none; background: #0f172a; color: #fff; border-radius: 10px; padding: 8px 10px; font-size: .78rem; min-width: 170px; box-shadow: var(--shadow-lg); z-index: 5; }
.chart-tooltip .tt-title { font-weight: 600; margin-bottom: 4px; color: #cbd5e1; }
.chart-tooltip .tt-row { display: flex; align-items: center; gap: 4px; }
.chart-tooltip .tt-row strong { margin-left: auto; padding-left: 10px; }
.chart-table summary { cursor: pointer; }

/* ---------- Tables ---------- */
.app-table { --bs-table-bg: transparent; }
.app-table thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; background: #f8fafc; border-bottom: 1px solid var(--line); padding: 10px 14px; white-space: nowrap; }
.app-table tbody td { padding: 12px 14px; border-color: #eef1f5; }
.app-table tbody tr { transition: background .12s; }
.app-table tbody tr:hover { background: #fafbfd; }
.app-card > .table-responsive-cards:first-child .app-table thead th:first-child { border-top-left-radius: var(--radius); }

/* Tables become cards on phones. */
@media (max-width: 767.98px) {
    .table-responsive-cards .app-table thead { display: none; }
    .table-responsive-cards .app-table, .table-responsive-cards .app-table tbody, .table-responsive-cards .app-table tr, .table-responsive-cards .app-table td { display: block; width: 100%; }
    .table-responsive-cards .app-table tr { position: relative; padding: 12px 16px; border-bottom: 1px solid var(--line); }
    .table-responsive-cards .app-table td { padding: 2px 0; border: 0; text-align: left !important; }
    .table-responsive-cards .app-table td.d-none { display: none !important; }
    .table-responsive-cards .app-table td[data-label]::before { content: attr(data-label); display: inline-block; min-width: 92px; font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
    .table-responsive-cards .app-table td:first-child::before { display: none; }
    .table-responsive-cards .app-table td:last-child { position: absolute; top: 10px; right: 10px; width: auto; }
    .table-responsive-cards .app-table td > div.d-flex { display: inline-flex !important; }
    .table-responsive-cards .app-table td[data-label] > div { display: inline-block; vertical-align: top; }
}

/* ---------- Status badges ---------- */
.status-badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; line-height: 1.5; }
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.status-secondary { background: #f1f5f9; color: #475569; }
.status-info { background: #e0f2fe; color: #0369a1; }
.status-warning { background: #fff4e0; color: #b45309; }
.status-primary { background: #eaf2fd; color: #1f6fd0; }
.status-success { background: #e8f8ef; color: #12805c; }
.status-danger { background: #fdecec; color: #c2312c; }
.status-dark { background: #e2e8f0; color: #1e293b; }

/* ---------- Invoice editor ---------- */
.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.section-head h2 { font-size: 1.05rem; font-weight: 650; margin: 0; }
.section-step { width: 26px; height: 26px; border-radius: 8px; background: color-mix(in srgb, var(--brand) 12%, #fff); color: var(--brand); font-weight: 700; font-size: .8rem; display: inline-flex; align-items: center; justify-content: center; }

.customer-search, .product-search { position: relative; }
.customer-search > i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: #94a3b8; z-index: 2; }
.customer-search .form-control { padding-left: 40px; font-size: .95rem; background: #f8fafc; }
.search-results { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 1050; max-height: 300px; overflow-y: auto; padding: 4px; }
.search-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: 0; padding: 9px 12px; border-radius: 8px; color: var(--ink); }
.search-item:hover, .search-item.is-active { background: #f1f6fd; }
.search-empty { padding: 12px; font-size: .85rem; color: var(--muted); }
.selected-customer { display: flex; align-items: center; gap: 6px; background: #ecfdf3; color: #05603a; border-radius: 10px; padding: 8px 12px; font-size: .875rem; margin-bottom: 14px; flex-wrap: wrap; }
.ship-fields { border-top: 1px dashed var(--line); padding-top: 14px; }

/* Desktop: two-line rows – name/qty/rate/amount on top, description/discount/tax below. */
.items-header, .item-row { display: grid; grid-template-columns: 14px 20px minmax(0, 1fr) 92px 118px 118px 30px; column-gap: 8px; align-items: start; }
.item-row { grid-template-areas: "h i main qty rate amount tools" "h i main disc disc tax tools"; row-gap: 6px; }
.invoice-editor[data-tax-mode="none"] .item-row { grid-template-areas: "h i main qty rate amount tools" "h i main disc disc . tools"; }
.item-handle { grid-area: h; } .item-index { grid-area: i; } .item-main { grid-area: main; } .item-qty { grid-area: qty; }
.item-rate { grid-area: rate; } .item-amount { grid-area: amount; } .item-disc { grid-area: disc; } .item-tax { grid-area: tax; } .item-tools { grid-area: tools; }
.items-header { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 0 8px 8px; border-bottom: 1px solid var(--line); }
.item-row { padding: 12px 8px; border-bottom: 1px solid #eef1f5; position: relative; background: #fff; transition: background .15s, box-shadow .15s; }
.item-row:hover { background: #fafcff; }
.item-row.is-dragging { opacity: .6; box-shadow: var(--shadow-lg); }
.item-handle { color: #cbd5e1; cursor: grab; padding-top: 8px; }
.item-index { color: var(--muted); font-size: .85rem; padding-top: 9px; text-align: center; }
.item-field label { display: none; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 2px; }
.item-disc, .item-tax { display: flex; align-items: center; gap: 6px; }
.item-disc label, .item-tax label { display: block; margin: 0; white-space: nowrap; }
.item-desc { resize: vertical; min-height: 32px; overflow: hidden; color: var(--ink-2); }
.disc-type { max-width: 54px; padding-left: 8px; padding-right: 22px; background-position: right 4px center; }
.amount-value { font-weight: 650; text-align: right; padding-top: 8px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.item-tools { display: flex; flex-direction: column; align-items: center; }
.item-tools [data-move] { display: none; }
.item-row:hover .item-tools [data-move] { display: inline-flex; }

/* Tax-dependent visibility */
.invoice-editor[data-tax-mode="none"] .tax-only,
.invoice-editor:not([data-tax-mode="gst"]) .gst-only,
.invoice-editor:not([data-tax-mode="custom"]) .custom-only,
.invoice-editor:not([data-tax-mode="gst"]) .gst-intra-only,
.invoice-editor:not([data-tax-mode="gst"]) .gst-inter-only,
.invoice-editor[data-supply="inter"] .gst-intra-only,
.invoice-editor:not([data-supply="inter"]) .gst-inter-only,
.invoice-editor[data-tax-mode="none"] [data-row="taxable"] { display: none !important; }

@media (max-width: 991.98px) {
    .items-header { display: none; }
    .item-row, .invoice-editor[data-tax-mode="none"] .item-row {
        grid-template-columns: 1fr 1fr; grid-template-areas: "main main" "qty rate" "disc tax" "amount amount"; gap: 10px; padding: 14px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
    }
    .item-handle { display: none; }
    .item-index { position: absolute; top: -9px; left: 12px; background: var(--brand); color: #fff; border-radius: 999px; font-size: .7rem; padding: 1px 8px; font-weight: 600; }
    .invoice-editor[data-tax-mode="none"] .item-row { grid-template-areas: "main main" "qty rate" "disc disc" "amount amount"; }
    .item-disc, .item-tax { display: block; }
    .item-field label { display: block; }
    .item-amount { display: flex; justify-content: space-between; align-items: center; border-top: 1px dashed var(--line); padding-top: 8px; }
    .item-amount label { margin: 0; }
    .amount-value { padding-top: 0; font-size: 1.05rem; }
    .item-tools { position: absolute; top: 6px; right: 6px; flex-direction: row; }
    .item-tools [data-move] { display: inline-flex; }
    .disc-type { max-width: none; flex: 0 0 76px; }
}

.summary-sticky { position: sticky; top: 80px; }
.summary-card { border-top: 3px solid var(--brand); }
.totals-list { margin: 0; }
.totals-list > div { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 7px 0; border-bottom: 1px solid #f1f4f8; }
.totals-list dt { font-weight: 500; color: var(--ink-2); }
.totals-list dd { margin: 0; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 550; }
.totals-list .grand { border-bottom: 0; padding-top: 12px; }
.totals-list .grand dt, .totals-list .grand dd { font-size: 1.25rem; font-weight: 700; color: var(--ink); }
.discount-input { max-width: 150px; }
.discount-input .form-select { max-width: 58px; padding-right: 22px; background-position: right 4px center; }
.editor-actions .btn { font-weight: 600; }

.mobile-actionbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; display: flex; align-items: center; gap: 8px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, .96); backdrop-filter: blur(8px); border-top: 1px solid var(--line); box-shadow: 0 -6px 24px rgba(15, 23, 42, .08); }
.mobile-actionbar > div { flex: 1; min-width: 0; }

.bg-preview { background: #e9edf3; }
.preview-frame { width: 100%; min-height: 70vh; border: 0; display: block; background: #e9edf3; }
.preview-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(233, 237, 243, .7); z-index: 2; }
.preview-loading[hidden] { display: none; }

/* ---------- Invoice detail ---------- */
.action-bar { display: flex; flex-wrap: wrap; gap: 8px; }
.invoice-frame { width: 100%; min-height: 900px; border: 0; display: block; background: #e9edf3; }
.generated-banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: #ecfdf3; border: 1px solid #abefc6; color: #05603a; border-radius: var(--radius); padding: 14px 18px; }
.generated-banner > i { font-size: 1.4rem; }
.payment-list li { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 10px 0; border-top: 1px solid #f1f4f8; }
.timeline li { position: relative; padding: 0 0 14px 20px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: color-mix(in srgb, var(--brand) 60%, #fff); }
.timeline li::after { content: ""; position: absolute; left: 7.5px; top: 18px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.attachment-chip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: #f8fafc; }

/* ---------- Settings ---------- */
.settings-nav { position: sticky; top: 80px; }
.settings-link { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--ink-2); font-weight: 500; }
.settings-link i { color: #94a3b8; }
.settings-link:hover { background: #f3f6fa; color: var(--ink); }
.settings-link.active { background: color-mix(in srgb, var(--brand) 10%, #fff); color: var(--brand); }
.settings-link.active i { color: var(--brand); }
@media (max-width: 991.98px) {
    .settings-nav { position: static; display: flex; overflow-x: auto; gap: 4px; flex-wrap: nowrap; }
    .settings-nav hr { display: none; }
    .settings-link { white-space: nowrap; }
}
.settings-save { position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(180deg, rgba(245, 247, 251, 0), var(--canvas) 40%); display: flex; justify-content: flex-end; z-index: 5; }
.setting-switch { padding-top: 4px; }
.setting-switch .form-check-input { margin-top: .3em; }
.upload-tile { border: 1px dashed #d3dbe6; border-radius: 12px; padding: 14px; height: 100%; background: #fbfcfe; }
.upload-preview { height: 84px; display: flex; align-items: center; justify-content: center; background: repeating-conic-gradient(#f3f5f9 0% 25%, #fff 0% 50%) 50% / 16px 16px; border-radius: 10px; margin-bottom: 10px; overflow: hidden; }
.upload-preview img { max-height: 76px; max-width: 90%; object-fit: contain; }
.currency-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.template-picker { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 767.98px) { .template-picker { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.template-option { cursor: pointer; text-align: center; }
.template-option input { position: absolute; opacity: 0; }
.template-thumb { display: block; aspect-ratio: 210 / 260; border: 2px solid var(--line); border-radius: 10px; background: #fff; padding: 10px; position: relative; transition: border-color .15s, box-shadow .15s; }
.template-option input:checked + .template-thumb { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 15%, transparent); }
.template-option input:focus-visible + .template-thumb { outline: 2px solid var(--brand); outline-offset: 2px; }
.template-thumb i { display: block; border-radius: 3px; margin-bottom: 6px; background: #e8edf4; height: 6px; }
.template-thumb i:nth-child(1) { width: 45%; height: 10px; }
.template-thumb i:nth-child(2) { width: 100%; height: 26px; margin-top: 10px; }
.template-thumb i:nth-child(3) { width: 100%; height: 40px; }
.template-thumb i:nth-child(4) { width: 50%; margin-left: auto; height: 14px; }
.tpl-modern::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--brand); border-radius: 8px 8px 0 0; }
.tpl-modern i:nth-child(2) { background: color-mix(in srgb, var(--brand) 14%, #fff); }
.tpl-corporate i:nth-child(1) { background: #0f172a; width: 55%; margin-left: auto; }
.tpl-corporate i:nth-child(3) { background: linear-gradient(#0f172a 0 8px, #e8edf4 8px); }
.tpl-corporate i:nth-child(4) { background: var(--brand); }
.tpl-clean i { background: #fff; border: 1px solid #cbd5e1; }
.tpl-elegant i:nth-child(1) { margin: 0 auto 6px; }
.tpl-elegant i:nth-child(2) { height: 2px; background: #0f172a; box-shadow: 0 4px 0 #0f172a; margin-bottom: 14px; }
.template-name { display: block; font-size: .82rem; font-weight: 600; margin-top: 6px; color: var(--ink-2); }

.export-list .list-group-item { border-color: #f1f4f8; }

/* ---------- Toasts & modals ---------- */
.app-toast { border-radius: 12px; box-shadow: var(--shadow-lg); color: #fff; }
.toast-success { background: #0f172a; }
.toast-danger { background: #b42318; }
.app-toast .btn-close { filter: invert(1); }
.modal-content { border: 0; border-radius: 16px; box-shadow: var(--shadow-lg); }
.modal-header, .modal-footer { border-color: var(--line); }
.confirm-icon { width: 54px; height: 54px; border-radius: 50%; margin: 0 auto; display: flex; align-items: center; justify-content: center; background: #fef3f2; color: #d92d20; font-size: 1.5rem; }
.dropdown-menu { border-radius: 12px; border-color: var(--line); padding: 6px; }
.dropdown-item { border-radius: 8px; padding: 7px 12px; font-size: .9rem; }
.dropdown-menu form { margin: 0; }
.pagination .page-link { border-radius: 8px !important; margin: 0 2px; border-color: var(--line); color: var(--ink-2); }
.pagination .active .page-link { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- Auth ---------- */
.auth-body { background: #fff; }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
.auth-panel { display: flex; flex-direction: column; justify-content: center; padding: 48px clamp(20px, 7vw, 96px); max-width: 620px; width: 100%; margin: 0 auto; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; margin-bottom: 40px; }
.auth-mark { width: 40px; height: 40px; object-fit: contain; }
.auth-logo { max-height: 46px; max-width: 220px; object-fit: contain; }
.auth-title { font-size: 1.75rem; font-weight: 750; letter-spacing: -.02em; margin-bottom: .35rem; }
.auth-aside {
    align-items: center; padding: 64px; color: #e2e8f0;
    background: radial-gradient(1200px 500px at 110% -10%, color-mix(in srgb, #1F7AE0 55%, transparent), transparent 60%),
                radial-gradient(800px 400px at -10% 110%, rgba(235, 104, 52, .25), transparent 60%), #0b1220;
}
.auth-aside h2 { font-size: 2.3rem; font-weight: 750; letter-spacing: -.02em; color: #fff; margin: 16px 0 12px; max-width: 460px; }
.auth-aside p { color: #94a3b8; font-size: 1.05rem; max-width: 440px; }
.auth-aside-badge { display: inline-block; padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .12); font-size: .82rem; }
.auth-points { list-style: none; padding: 0; margin: 24px 0 0; }
.auth-points li { padding: 6px 0; color: #cbd5e1; }
.auth-points i { color: #4ade80; margin-right: 8px; }
@media (max-width: 991.98px) { .auth-shell { grid-template-columns: 1fr; } }

/* ---------- Print: only the page content, never navigation or controls ---------- */
@media print {
    .sidebar, .topbar, .sidebar-backdrop, .mobile-actionbar, .action-bar, .btn, .dropdown, .modal, .toast-container, .settings-save, .app-alert { display: none !important; }
    .main { margin: 0; }
    .content { padding: 0; }
    body { background: #fff; }
    .app-card { box-shadow: none; border: 0; }
}
