/*
 * Sidhyati Invoices — a calm, light theme on top of Bootstrap 5.
 *
 * Same restrained shell as Sidhyati Soil Testing (flat surfaces, hairline borders, one accent),
 * coloured from the Sidhyati logo: berry accent, charcoal sidebar, and the logo's
 * purple → magenta → orange gradient kept to the brand mark only.
 */
:root {
    --brand: #9c2a6a;
    --brand-600: #802256;
    --brand-50: #f8ebf2;
    --brand-line: #e6bfd4;
    --brand-gradient: linear-gradient(135deg, #7b2a9a 0%, #c23a6e 50%, #f08a24 100%);
    --ink: #1f2023;
    --muted: #6b6b73;
    --line: #e7e7ea;
    --surface: #f7f7f8;
    --card: #ffffff;
    --sidebar: #29282b;
    --sidebar-ink: #b8b5bb;
    --sidebar-hover: #353438;
    --sidebar-line: #3a393d;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05);
    --bs-primary: #9c2a6a;
    --bs-primary-rgb: 156, 42, 106;
    --bs-link-color: #9c2a6a;
    --bs-link-color-rgb: 156, 42, 106;
    --bs-link-hover-color: #802256;
    --bs-link-hover-color-rgb: 128, 34, 86;
    --bs-body-font-family: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --bs-body-color: #1f2023;
    --bs-border-color: #e7e7ea;
}

body { background: var(--surface); font-size: .9rem; -webkit-font-smoothing: antialiased; }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand-600); --bs-btn-hover-border-color: var(--brand-600); --bs-btn-active-bg: var(--brand-600); --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand); }
.btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); --bs-btn-active-bg: var(--brand); --bs-btn-active-border-color: var(--brand); }
.btn { border-radius: var(--radius-sm); font-weight: 500; }
.nav-pills { --bs-nav-pills-link-active-bg: var(--brand); --bs-nav-pills-border-radius: var(--radius-sm); --bs-nav-link-color: var(--brand); --bs-nav-link-hover-color: var(--brand-600); }
.text-primary { color: var(--brand) !important; }
.bg-primary { background-color: var(--brand) !important; }
.btn:focus-visible { box-shadow: 0 0 0 3px var(--brand-50); }
.form-control, .form-select { border-radius: var(--radius-sm); border-color: #d6d6db; }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-check-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }
.form-label { font-weight: 500; font-size: .85rem; color: #3a3a40; margin-bottom: .3rem; }
.form-text { font-size: .78rem; }

/* ---------------------------------------------------------------- shell */
.app { display: flex; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-ink); display: flex; flex-direction: column; }
/* Bootstrap's .offcanvas-lg forces a transparent background from lg up, so the colour is restated with !important. */
@media (min-width: 992px) { .sidebar { width: 248px; flex-shrink: 0; position: sticky; top: 0; height: 100vh; background-color: var(--sidebar) !important; } }
/* Below lg Bootstrap's offcanvas positions the sidebar off-screen; it must not take part in the flex row. */
@media (max-width: 991.98px) { .sidebar { --bs-offcanvas-width: 260px; --bs-offcanvas-bg: var(--sidebar); } }
.sidebar-brand { display: flex; align-items: center; gap: .7rem; padding: 1rem 1.15rem; border-bottom: 1px solid var(--sidebar-line); }
.brand-mark { width: 32px; height: 32px; border-radius: var(--radius-sm); background: var(--brand-gradient); color: #fff; display: grid; place-items: center; font-weight: 700; }
.brand-name { color: #fff; font-weight: 600; line-height: 1.1; }
.brand-sub { font-size: .72rem; color: var(--sidebar-ink); font-weight: 500; }
.sidebar-nav { padding: .75rem .65rem; overflow-y: auto; flex: 1; }
.sidebar-nav .nav-section { text-transform: uppercase; font-size: .68rem; letter-spacing: .07em; font-weight: 600; color: #7d7a82; padding: 1rem .65rem .35rem; }
.sidebar-nav .nav-link { display: flex; align-items: center; gap: .7rem; color: var(--sidebar-ink); border-radius: var(--radius-sm); padding: .5rem .65rem; margin-bottom: 1px; font-size: .875rem; font-weight: 500; }
.sidebar-nav .nav-link i { font-size: 1.05rem; opacity: .85; }
.sidebar-nav .nav-link:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--brand); color: #fff; }
.sidebar-nav .nav-link.active i { opacity: 1; }
.sidebar-foot { padding: .9rem 1.25rem; font-size: .75rem; color: #7d7a82; border-top: 1px solid var(--sidebar-line); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: .75rem; background: #fff; border-bottom: 1px solid var(--line); padding: .7rem 1.5rem; position: sticky; top: 0; z-index: 1020; }
.page-title { font-size: 1.15rem; font-weight: 600; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-icon { border: 0; background: transparent; padding: .25rem; }
.btn-user { display: flex; align-items: center; gap: .5rem; border: 0; background: transparent; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-50); color: var(--brand); display: grid; place-items: center; font-weight: 600; font-size: .8rem; }
.content { padding: 1.5rem; max-width: 1480px; width: 100%; }
@media (max-width: 575.98px) { .content { padding: 1rem .75rem; } .topbar { padding: .6rem .75rem; } }

/* ---------------------------------------------------------------- cards */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { background: transparent; border-bottom: 1px solid var(--line); font-weight: 600; font-size: .9rem; padding: .8rem 1rem; }
.card-body { padding: 1rem; }
.section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin-bottom: .75rem; }

.kpi { padding: 1rem 1.1rem; height: 100%; }
.kpi .kpi-label { color: var(--muted); font-size: .8rem; display: flex; align-items: center; gap: .4rem; }
.kpi .kpi-value { font-size: 1.45rem; font-weight: 650; margin-top: .25rem; letter-spacing: -.01em; }
.kpi .kpi-sub { font-size: .78rem; color: var(--muted); }
.kpi-icon { width: 30px; height: 30px; border-radius: var(--radius-sm); display: grid; place-items: center; font-size: .95rem; }
.tone-brand { background: var(--brand-50); color: var(--brand); }
.tone-orange { background: #fdf0e4; color: #b8521a; }
.tone-blue { background: #e8f1fb; color: #1f5f99; }
.tone-green { background: #e7f6ee; color: #15803d; }
.tone-amber { background: #fdf3e2; color: #b45309; }
.tone-red { background: #fdecec; color: #b91c1c; }
.tone-slate { background: #eef1f5; color: #475569; }

/* ---------------------------------------------------------------- tables */
.table-card .table { margin: 0; }
.table { --bs-table-hover-bg: #faf7f9; }
.table > thead th { background: #f9f9fa; color: #6b6b73; font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid var(--line); white-space: nowrap; padding: .65rem .75rem; }
.table > tbody td { padding: .6rem .75rem; vertical-align: middle; border-color: #efeff1; }
.table tfoot td { background: #f9f9fa; font-weight: 600; }
.table-responsive { border-radius: 0 0 var(--radius) var(--radius); }
.th-sort { color: inherit; text-decoration: none; display: inline-flex; gap: .25rem; align-items: center; }
.th-sort i { font-size: .7rem; opacity: .45; }
.th-sort.is-sorted i { opacity: 1; color: var(--brand); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-link { cursor: pointer; }
.cell-strong { font-weight: 600; color: var(--ink); text-decoration: none; }
.cell-strong:hover { color: var(--brand); text-decoration: underline; }
.cell-sub { font-size: .78rem; color: var(--muted); }
.pager-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pagination { --bs-pagination-active-bg: var(--brand); --bs-pagination-active-border-color: var(--brand); --bs-pagination-color: var(--brand); }

.filter-bar { display: flex; flex-wrap: wrap; gap: .5rem; padding: .85rem 1rem; border-bottom: 1px solid var(--line); align-items: end; }
.filter-bar .form-control, .filter-bar .form-select { min-width: 140px; }
.filter-bar .search { flex: 1 1 220px; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-state i { font-size: 2.2rem; display: block; margin-bottom: .5rem; opacity: .5; }

/* ---------------------------------------------------------------- badges */
.status-badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .72rem; font-weight: 600; padding: .22rem .6rem; border-radius: 999px; white-space: nowrap; }
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-draft { background: #eef1f5; color: #475569; }
.status-sent { background: #e8f1fb; color: #1f5f99; }
.status-partial { background: #fdf3e2; color: #b45309; }
.status-paid { background: #e7f6ee; color: #15803d; }
.status-overdue { background: #fdecec; color: #b91c1c; }
.status-void { background: #f1f1f1; color: #6b7280; text-decoration: line-through; }
.chip { display: inline-block; font-size: .72rem; padding: .15rem .5rem; border-radius: 6px; background: #eef1f5; color: #475569; font-weight: 600; }

/* ---------------------------------------------------------------- document form */
.doc-lines td { vertical-align: top; }
.doc-lines .form-control, .doc-lines .form-select { font-size: .87rem; padding: .35rem .5rem; }
.doc-lines textarea { resize: vertical; min-height: 38px; }
.doc-lines .col-qty { width: 92px; }
.doc-lines .col-rate { width: 120px; }
.doc-lines .col-disc { width: 76px; }
.doc-lines .col-tax { width: 92px; }
.doc-lines .col-hsn { width: 96px; }
.doc-lines .col-amount { width: 120px; }
.doc-lines .line-amount { padding-top: .5rem; font-weight: 600; }
@media (max-width: 991.98px) {
    .doc-lines thead { display: none; }
    .doc-lines tr { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; padding: .75rem; border-bottom: 1px solid var(--line); }
    .doc-lines td { border: 0 !important; padding: 0 !important; width: auto !important; }
    .doc-lines td.col-item, .doc-lines td.col-desc { grid-column: 1 / -1; }
    .doc-lines td[data-label]::before { content: attr(data-label); display: block; font-size: .7rem; color: var(--muted); }
}
.totals-box { background: #f9f9fa; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.totals-box .t-row { display: flex; justify-content: space-between; align-items: center; padding: .25rem 0; gap: .5rem; }
.totals-box .t-total { border-top: 1px solid var(--line); margin-top: .4rem; padding-top: .6rem; font-size: 1.1rem; font-weight: 700; }
.rate-hint { font-size: .75rem; color: var(--muted); }
.sticky-actions { position: sticky; bottom: 0; background: rgba(247, 247, 248, .92); backdrop-filter: blur(6px); border-top: 1px solid var(--line); padding: .75rem 0; margin-top: 1rem; z-index: 5; }

/* ---------------------------------------------------------------- details */
.doc-summary dt { color: var(--muted); font-weight: 500; font-size: .8rem; }
.doc-summary dd { margin-bottom: .6rem; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 1rem 1.25rem; border-left: 2px solid var(--line); margin-left: .35rem; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2px solid var(--brand); }
.timeline .t-when { font-size: .75rem; color: var(--muted); }
.timeline .t-comment { background: #f9f9fa; border: 1px solid var(--line); border-radius: 8px; padding: .4rem .6rem; margin-top: .3rem; font-size: .85rem; }
.pdf-frame { width: 100%; height: 78vh; border: 1px solid var(--line); border-radius: 10px; background: #fff; }

/* ---------------------------------------------------------------- settings */
.settings-nav .list-group-item { border: 0; border-radius: var(--radius-sm) !important; color: #3a3a40; padding: .55rem .8rem; margin-bottom: 2px; }
.settings-nav .list-group-item.active { background: var(--brand-50); color: var(--brand); font-weight: 600; }
.settings-nav .list-group-item i { width: 1.4rem; display: inline-block; }
.image-slot { border: 1px dashed #cbd5e1; border-radius: 10px; height: 120px; display: grid; place-items: center; background: repeating-conic-gradient(#f8fafc 0 25%, #fff 0 50%) 0 0 / 16px 16px; overflow: hidden; }
.image-slot img { max-height: 104px; max-width: 92%; object-fit: contain; }
.color-dot { width: 14px; height: 14px; border-radius: 4px; display: inline-block; vertical-align: middle; border: 1px solid rgba(0, 0, 0, .1); }

/* ---------------------------------------------------------------- auth */
.auth { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 10% 0%, #f1e2ec 0%, transparent 60%), radial-gradient(900px 500px at 100% 100%, #fbeadb 0%, transparent 55%), var(--surface); padding: 1rem; }
.auth-card { width: 100%; max-width: 410px; }
.auth-card .card-body { padding: 2rem; }

.flash { border-radius: 10px; }
.chart-box { position: relative; height: 280px; }
.report-table { font-size: .84rem; }
.report-table td, .report-table th { white-space: nowrap; }
.gst-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; border-radius: 8px; padding: .5rem .75rem; font-size: .85rem; }
@media print { .sidebar, .topbar, .no-print, .sticky-actions { display: none !important; } .content { padding: 0; } }
