/* ================================================================
   BillStack — admin shell
   Ported from the INTCIS admin theme so the two products read the same:
   white sidebar with pastel icon chips, blue-gradient active pill,
   blue→green→orange accent rule, left-bordered stat cards, slate tables.

   Everything below the "ERP additions" rule at the end of this file is new
   for this product: denser transaction tables and the line-item grid an
   invoice needs. No new framework, no second component vocabulary.
   ================================================================ */
:root {
    --adm-sidebar-w: 262px;
    --adm-topbar-h: 60px;

    /* Sarthi colour scale */
    --c-blue-50: #eff6ff;  --c-blue-100: #dbeafe; --c-blue-500: #3b82f6; --c-blue-600: #2563eb; --c-blue-700: #1d4ed8;
    --c-green-50: #ecfdf5; --c-green-100: #d1fae5; --c-green-500: #22c55e; --c-green-600: #16a34a; --c-green-700: #15803d;
    --c-orange-50: #fff7ed; --c-orange-100: #ffedd5; --c-orange-500: #f97316; --c-orange-600: #ea580c; --c-orange-700: #c2410c;
    --c-purple-50: #f5f3ff; --c-purple-600: #7c3aed; --c-purple-700: #6d28d9;
    --c-rose-600: #e11d48; --c-amber-600: #d97706; --c-cyan-600: #0891b2;

    --adm-page-bg: #f4f6f9;
    --adm-line: #eef2f7;
    --adm-line-strong: #e2e8f0;
    --adm-ink: #0f172a;
    --adm-text: #334155;
    --adm-muted: #64748b;
    --adm-faint: #94a3b8;
    --adm-head-bg: #f1f5f9;
    --adm-row-hover: #f8fafc;

    /* The signature three-colour rule used under the logo and topbar. */
    --adm-accent-rule: linear-gradient(90deg, var(--c-blue-600) 0%, var(--c-green-500) 50%, var(--c-orange-500) 100%);
}

body { background: var(--adm-page-bg); color: var(--adm-text); }

/* ---------------- sidebar shell ---------------- */
.admin-sidebar {
    width: var(--adm-sidebar-w);
    position: fixed; inset: 0 auto 0 0; z-index: 1040;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    color: var(--adm-text);
    display: flex; flex-direction: column;
    border-right: 1px solid #e5e9f2;
    box-shadow: 1px 0 0 rgba(15,23,42,.02), 4px 0 18px rgba(15,23,42,.03);
}
.admin-brand {
    flex: 0 0 auto; position: relative;
    display: flex; align-items: center; justify-content: center; gap: .6rem;
    padding: .9rem 1rem;
    background: #fff; border-bottom: 1px solid var(--adm-line);
    text-decoration: none; color: var(--adm-ink);
}
.admin-brand::after {
    content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px;
    background: var(--adm-accent-rule);
}
.admin-brand img { height: 36px; width: auto; max-width: 160px; object-fit: contain; }
.admin-brand-fallback { font-weight: 700; font-size: 1rem; }

.admin-nav-scroll {
    flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
    padding: .65rem .5rem 1rem;
    scrollbar-width: thin; scrollbar-color: rgba(148,163,184,.4) transparent;
}
.admin-nav-scroll::-webkit-scrollbar { width: 6px; }
.admin-nav-scroll::-webkit-scrollbar-thumb { background: rgba(148,163,184,.4); border-radius: 3px; }

.admin-account {
    flex: 0 0 auto; border-top: 1px solid var(--adm-line);
    padding: .6rem .75rem; background: #fff;
}
.admin-account .avatar {
    width: 36px; height: 36px; border-radius: 50%; flex: 0 0 auto;
    display: grid; place-items: center; font-weight: 700; font-size: .82rem; color: #fff;
    background: linear-gradient(135deg, var(--c-blue-600), var(--c-blue-500));
}
.admin-account .name { color: var(--adm-ink); font-size: .88rem; font-weight: 600; line-height: 1.2; }
.admin-account .role { color: var(--adm-faint); font-size: .72rem; }
.admin-account .btn-link { color: inherit; }

/* ---------------- menu ---------------- */
.admin-menu { list-style: none; margin: 0; padding: 0; }
.admin-menu .section-label {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .08em;
    color: var(--adm-faint); padding: .9rem .75rem .35rem; font-weight: 700;
}
.admin-link,
.admin-group-toggle {
    display: flex; align-items: center; gap: .75rem; width: 100%;
    color: var(--adm-text); text-decoration: none;
    padding: .55rem .75rem; margin: 2px 0;
    font-size: .9rem; font-weight: 500;
    border: 0; border-radius: .6rem; background: transparent;
    text-align: left; transition: background .15s, color .15s;
}
.admin-link:hover, .admin-group-toggle:hover { background: #f1f5f9; color: var(--adm-ink); }

/* Pastel icon chip, coloured per menu group. */
.admin-nav-icon {
    flex: 0 0 30px; width: 30px; height: 30px; border-radius: 9px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: .95rem; transition: transform .15s;
    background: var(--c-blue-50); color: var(--c-blue-700);
}
.admin-link:hover .admin-nav-icon, .admin-group-toggle:hover .admin-nav-icon { transform: translateY(-1px); }
[data-color="green"]  .admin-nav-icon { background: var(--c-green-50);  color: var(--c-green-700); }
[data-color="orange"] .admin-nav-icon { background: var(--c-orange-50); color: var(--c-orange-700); }
[data-color="purple"] .admin-nav-icon { background: var(--c-purple-50); color: var(--c-purple-700); }
[data-color="rose"]   .admin-nav-icon { background: #fff1f2; color: #be123c; }
[data-color="slate"]  .admin-nav-icon { background: #f1f5f9; color: #334155; }

/* Active: solid gradient pill, icon chip goes translucent white. */
.admin-link.active,
.admin-group-toggle.has-active {
    color: #fff; font-weight: 600;
    background: linear-gradient(135deg, var(--c-blue-700) 0%, var(--c-blue-600) 100%);
    box-shadow: 0 8px 18px -6px rgba(37,99,235,.5);
}
.admin-link.active[data-color="green"], .admin-group-toggle.has-active[data-color="green"] {
    background: linear-gradient(135deg, var(--c-green-700), var(--c-green-600)); box-shadow: 0 8px 18px -6px rgba(22,163,74,.5);
}
.admin-link.active[data-color="orange"], .admin-group-toggle.has-active[data-color="orange"] {
    background: linear-gradient(135deg, var(--c-orange-700), var(--c-orange-600)); box-shadow: 0 8px 18px -6px rgba(234,88,12,.5);
}
.admin-link.active[data-color="purple"], .admin-group-toggle.has-active[data-color="purple"] {
    background: linear-gradient(135deg, var(--c-purple-700), var(--c-purple-600)); box-shadow: 0 8px 18px -6px rgba(124,58,237,.5);
}
.admin-link.active .admin-nav-icon, .admin-group-toggle.has-active .admin-nav-icon {
    background: rgba(255,255,255,.2) !important; color: #fff !important;
}
.admin-group-toggle .caret { margin-left: auto; font-size: .75rem; transition: transform .2s ease; }
.admin-group-toggle[aria-expanded="true"] .caret { transform: rotate(90deg); }

/* Submenu: indented under a soft left rule. */
.admin-submenu { list-style: none; margin: .15rem 0 .35rem 1.35rem; padding: 0 0 0 .6rem; border-left: 2px solid var(--adm-line-strong); }
.admin-sublink {
    display: flex; align-items: center; gap: .55rem;
    padding: .42rem .65rem; margin: 1px 0; border-radius: .5rem;
    color: var(--adm-muted); text-decoration: none; font-size: .86rem;
    transition: color .15s, background .15s;
}
.admin-sublink::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .45; flex: 0 0 auto; }
.admin-sublink:hover { color: var(--adm-ink); background: #f1f5f9; }
.admin-sublink.active { color: var(--c-blue-700); background: var(--c-blue-50); font-weight: 600; }
.admin-sublink.active::before { background: var(--c-blue-600); opacity: 1; }
.admin-badge {
    margin-left: auto; font-size: .68rem; font-weight: 700; line-height: 1;
    padding: .2rem .45rem; border-radius: 1rem; background: var(--c-blue-600); color: #fff;
}

/* ---------------- main column ---------------- */
.admin-main { margin-left: var(--adm-sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.admin-topbar {
    background: #fff; position: sticky; top: 0; z-index: 1020;
    min-height: var(--adm-topbar-h); border-bottom: 1px solid var(--adm-line);
    position: relative;
}
.admin-topbar::after {
    content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px;
    background: var(--adm-accent-rule);
}
.admin-page-title { font-size: 1.05rem; font-weight: 700; color: var(--adm-ink); margin: 0; }

/* Icon buttons in the topbar (bell etc). */
.admin-topbar .btn-light {
    --bs-btn-bg: #f8fafc; --bs-btn-border-color: var(--adm-line-strong);
    --bs-btn-hover-bg: #eef2ff; --bs-btn-hover-border-color: #c7d2fe; color: var(--adm-text);
}

/* ---------------- page header block ---------------- */
.page-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: .75rem; flex-wrap: wrap;
    background: #fff; border: 1px solid var(--adm-line);
    border-radius: 14px; padding: .8rem 1rem; margin-bottom: .85rem;
    box-shadow: 0 6px 18px -10px rgba(15,23,42,.08);
}
.page-head-main { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.page-head-icon {
    width: 38px; height: 38px; flex: 0 0 auto;
    display: grid; place-items: center; border-radius: .6rem;
    background: var(--c-blue-50); color: var(--c-blue-600); border: 1px solid var(--c-blue-100);
    font-size: 1.05rem;
}
.page-head h1, .page-head h4 { font-size: 1.05rem; font-weight: 700; color: var(--adm-ink); margin: 0; line-height: 1.25; }
.page-head .page-head-sub { font-size: .8rem; color: var(--adm-muted); margin: 0; line-height: 1.35; }

/* ---------------- stat cards (dashboard KPIs) ---------------- */
.stat-card {
    position: relative; overflow: hidden;
    display: flex; align-items: center; gap: .85rem;
    padding: .95rem 1rem; height: 100%;
    background: #fff; border: 1px solid var(--adm-line); border-radius: 14px;
    box-shadow: 0 6px 18px -10px rgba(15,23,42,.08);
    text-decoration: none; color: inherit;
    transition: transform .15s, box-shadow .15s, border-color .15s;
}
.stat-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c-blue-600); opacity: .85; }
.stat-card--blue::before   { background: var(--c-blue-600); }
.stat-card--green::before  { background: var(--c-green-600); }
.stat-card--orange::before { background: var(--c-orange-600); }
.stat-card--purple::before { background: var(--c-purple-600); }
.stat-card--rose::before   { background: var(--c-rose-600); }
.stat-card--amber::before  { background: var(--c-amber-600); }
.stat-card--cyan::before   { background: var(--c-cyan-600); }
.stat-card--slate::before  { background: #64748b; }
a.stat-card:hover { transform: translateY(-2px); border-color: rgba(29,78,216,.18); box-shadow: 0 14px 30px -12px rgba(29,78,216,.2); color: inherit; }
.stat-icon {
    width: 44px; height: 44px; border-radius: 12px; flex: 0 0 auto;
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.15rem;
    background: linear-gradient(135deg, #dbeafe, #bfdbfe); color: var(--c-blue-700);
}
.stat-card--green  .stat-icon { background: linear-gradient(135deg, #d1fae5, #a7f3d0); color: var(--c-green-700); }
.stat-card--orange .stat-icon { background: linear-gradient(135deg, #ffedd5, #fed7aa); color: var(--c-orange-700); }
.stat-card--purple .stat-icon { background: linear-gradient(135deg, #ede9fe, #ddd6fe); color: var(--c-purple-700); }
.stat-card--rose   .stat-icon { background: linear-gradient(135deg, #ffe4e6, #fecdd3); color: #be123c; }
.stat-card--amber  .stat-icon { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #b45309; }
.stat-card--cyan   .stat-icon { background: linear-gradient(135deg, #cffafe, #a5f3fc); color: #0e7490; }
.stat-card--slate  .stat-icon { background: linear-gradient(135deg, #e2e8f0, #cbd5e1); color: #334155; }
.stat-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.stat-label { font-size: .72rem; font-weight: 600; color: var(--adm-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
.stat-value { font-size: 1.5rem; font-weight: 800; color: var(--adm-ink); line-height: 1.1; letter-spacing: -.5px; }
.stat-sub { margin-top: 4px; font-size: .78rem; color: var(--adm-muted); }

/* ---------------- cards ---------------- */
.card {
    border: 1px solid var(--adm-line); border-radius: 14px;
    box-shadow: 0 6px 18px -10px rgba(15,23,42,.08);
    transition: box-shadow .15s ease, border-color .15s ease;
}
.card-header.bg-white { background: #fff !important; border-bottom: 1px solid var(--adm-line); }
.card-footer.bg-white { border-top: 1px solid var(--adm-line); }

/* Collapsible filter card, mirroring "Filters & Snapshot". */
.filter-card { border: 1px solid var(--adm-line); border-radius: 14px; background: #fff; margin-bottom: .85rem; box-shadow: 0 6px 18px -10px rgba(15,23,42,.08); }
.filter-card-toggle {
    width: 100%; display: flex; align-items: center; gap: .7rem;
    padding: .75rem 1rem; background: transparent; border: 0; text-align: left; color: var(--adm-ink);
}
.filter-card-toggle .fc-icon { width: 34px; height: 34px; border-radius: .55rem; display: grid; place-items: center; background: var(--c-blue-50); color: var(--c-blue-600); flex: 0 0 auto; }
.filter-card-toggle .fc-title { font-weight: 700; font-size: .95rem; }
.filter-card-toggle .fc-sub { font-size: .78rem; color: var(--adm-muted); }
.filter-card-toggle .fc-meta { margin-left: auto; font-size: .8rem; color: var(--adm-muted); display: flex; align-items: center; gap: .5rem; }
.filter-card-toggle .fc-caret { transition: transform .2s; }
.filter-card-toggle[aria-expanded="true"] .fc-caret { transform: rotate(180deg); }
.filter-card-body { padding: 0 1rem 1rem; border-top: 1px solid var(--adm-line); padding-top: .9rem; }

/* ---------------- tables ---------------- */
.table {
    --bs-table-color: var(--adm-ink);
    --bs-table-hover-bg: var(--adm-row-hover);
    --bs-table-border-color: var(--adm-line-strong);
    margin-bottom: 0;
}
.table > thead > tr > th {
    background: var(--adm-head-bg); color: #475569;
    font-weight: 600; text-transform: uppercase; letter-spacing: .05em; font-size: .72rem;
    padding: .75rem 1rem; border-bottom: 1px solid var(--adm-line-strong); white-space: nowrap;
}
.table > tbody > tr > td { padding: .85rem 1rem; border-bottom: 1px solid var(--adm-line-strong); vertical-align: middle; font-size: .9rem; }
.table > tbody > tr:last-child > td { border-bottom: 0; }
.table > tfoot > tr > td { padding: .75rem 1rem; background: var(--adm-head-bg); border-top: 1px solid var(--adm-line-strong); }

/* Row-level "chip" data used in the reference: monospace ids and soft pills. */
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .5rem; border-radius: .4rem; font-size: .74rem; font-weight: 600; background: #f1f5f9; color: #475569; }
.chip--blue { background: var(--c-blue-50); color: var(--c-blue-700); }
.chip--green { background: var(--c-green-50); color: var(--c-green-700); }
.chip--orange { background: var(--c-orange-50); color: var(--c-orange-700); }
.chip--rose { background: #fff1f2; color: #be123c; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; }

/* DataTables (loaded via CDN on list pages) — restyled to match. */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid #cbd5e1; border-radius: .5rem; padding: .3rem .55rem; font-size: .85rem; margin-left: .35rem;
}
.dataTables_wrapper .dataTables_filter input:focus { outline: 0; border-color: var(--c-blue-500); box-shadow: 0 0 0 .2rem rgba(59,130,246,.15); }
.dataTables_wrapper .dataTables_length, .dataTables_wrapper .dataTables_filter { padding: .75rem 1rem; font-size: .85rem; color: var(--adm-muted); }
.dataTables_wrapper .dataTables_info { padding: .75rem 1rem; font-size: .82rem; color: var(--adm-muted); }
.dataTables_wrapper .dataTables_paginate { padding: .5rem 1rem .75rem; }
.dataTables_wrapper .dataTables_paginate .paginate_button {
    border: 1px solid var(--adm-line-strong) !important; border-radius: .5rem; margin: 0 2px; padding: .3rem .65rem; background: #fff !important; color: var(--adm-text) !important; font-size: .82rem;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--c-blue-600) !important; border-color: var(--c-blue-600) !important; color: #fff !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover:not(.current) { background: #f1f5f9 !important; color: var(--adm-ink) !important; }
table.dataTable thead .sorting:after, table.dataTable thead .sorting_asc:after, table.dataTable thead .sorting_desc:after { opacity: .35; }
table.dataTable.no-footer { border-bottom: 0; }

/* ---------------- buttons ---------------- */
.btn { border-radius: .55rem; font-weight: 500; }
.btn-primary {
    --bs-btn-bg: var(--c-blue-600); --bs-btn-border-color: var(--c-blue-600);
    --bs-btn-hover-bg: var(--c-blue-700); --bs-btn-hover-border-color: var(--c-blue-700);
    --bs-btn-active-bg: var(--c-blue-700); --bs-btn-focus-shadow-rgb: 37, 99, 235;
    box-shadow: 0 1px 2px rgba(37,99,235,.2);
}
.btn-outline-primary {
    --bs-btn-color: var(--c-blue-700); --bs-btn-border-color: #bfdbfe;
    --bs-btn-hover-bg: var(--c-blue-600); --bs-btn-hover-border-color: var(--c-blue-600);
    --bs-btn-focus-shadow-rgb: 37, 99, 235;
}
.btn-outline-secondary { --bs-btn-color: var(--adm-text); --bs-btn-border-color: #cbd5e1; --bs-btn-hover-bg: #f1f5f9; --bs-btn-hover-color: var(--adm-ink); --bs-btn-hover-border-color: #cbd5e1; }
.btn-light { --bs-btn-bg: #f8fafc; --bs-btn-border-color: var(--adm-line-strong); --bs-btn-hover-bg: #f1f5f9; }

/* ---------------- badges (soft pills) ---------------- */
.badge { font-weight: 600; letter-spacing: .01em; }
.badge.bg-primary   { background: var(--c-blue-50) !important;   color: var(--c-blue-700) !important; }
.badge.bg-secondary { background: #f1f5f9 !important; color: #475569 !important; }
.badge.bg-success   { background: var(--c-green-50) !important;  color: var(--c-green-700) !important; }
.badge.bg-danger    { background: #fff1f2 !important; color: #be123c !important; }
.badge.bg-warning   { background: #fffbeb !important; color: #b45309 !important; }
.badge.bg-info      { background: #ecfeff !important; color: #0e7490 !important; }
.badge.bg-light     { background: #f1f5f9 !important; color: #475569 !important; }
.badge.bg-dark      { background: #1e293b !important; color: #fff !important; }

/* ---------------- forms ---------------- */
.form-control, .form-select { border-color: #cbd5e1; border-radius: .5rem; }
.form-control:focus, .form-select:focus { border-color: var(--c-blue-500); box-shadow: 0 0 0 .2rem rgba(59,130,246,.15); }
.form-label { font-weight: 500; color: var(--adm-text); }

/* ---------------- pagination ---------------- */
.page-link { color: var(--c-blue-700); border-color: var(--adm-line-strong); border-radius: .5rem; margin: 0 2px; }
.page-item.active .page-link { background: var(--c-blue-600); border-color: var(--c-blue-600); }

.admin-backdrop { display: none; }

/* ---------------- mobile ---------------- */
@media (max-width: 991.98px) {
    .admin-sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: 0 0 40px rgba(0,0,0,.25); }
    .admin-sidebar.show { transform: none; }
    .admin-main { margin-left: 0; }
    .admin-backdrop { display: block; position: fixed; inset: 0; z-index: 1035; background: rgba(15,23,42,.45); opacity: 0; pointer-events: none; transition: opacity .22s ease; }
    .admin-backdrop.show { opacity: 1; pointer-events: auto; }
    .form-control, .form-select { font-size: 16px; min-height: 44px; }
    .admin-main main { padding: 1rem !important; }
}
@media (prefers-reduced-motion: reduce) {
    .admin-sidebar, .admin-backdrop, .admin-submenu, .admin-group-toggle .caret, .filter-card-toggle .fc-caret { transition: none !important; }
}

/* ---------------- inline active/inactive switch ---------------- */
.toggle-switch { display: inline-flex; align-items: center; gap: .5rem; padding-left: 2.6rem; min-height: 24px; }
.toggle-switch .form-check-input {
    margin-left: -2.6rem; width: 2.2rem; height: 1.2rem; cursor: pointer;
    background-color: #cbd5e1; border-color: #cbd5e1; transition: background-color .15s, border-color .15s;
}
.toggle-switch .form-check-input:checked { background-color: var(--c-green-600); border-color: var(--c-green-600); }
.toggle-switch .form-check-input:focus { border-color: var(--c-blue-500); box-shadow: 0 0 0 .2rem rgba(59,130,246,.15); }
.toggle-switch .form-check-input:disabled { opacity: .55; cursor: progress; }
.toggle-switch-label {
    font-size: .78rem; font-weight: 600; cursor: pointer; user-select: none;
    color: var(--adm-muted); white-space: nowrap; min-width: 4.2rem;
}
.toggle-switch .form-check-input:checked ~ .toggle-switch-label { color: var(--c-green-700); }
/* Brief confirmation that the write landed, rather than a silent flip. */
.toggle-switch.is-saved .form-check-input { animation: tglSaved .6s ease; }
@keyframes tglSaved { 0% { box-shadow: 0 0 0 0 rgba(22,163,74,.45); } 100% { box-shadow: 0 0 0 .5rem rgba(22,163,74,0); } }
.toggle-switch.is-failed .form-check-input { border-color: #e11d48; box-shadow: 0 0 0 .2rem rgba(225,29,72,.2); }
@media (prefers-reduced-motion: reduce) { .toggle-switch.is-saved .form-check-input { animation: none; } }

/* ---------------- client logo / contact photo ---------------- */
.client-img-preview {
    width: 64px; height: 64px; flex: 0 0 64px;
    display: inline-flex; align-items: center; justify-content: center;
    background: #f1f5f9; border: 1px solid var(--adm-line-strong);
    color: var(--adm-faint); font-size: 1.5rem; overflow: hidden;
}
.client-img-preview.rounded { border-radius: .6rem; }
.client-img-preview img { width: 100%; height: 100%; object-fit: contain; }
/* A face is cropped to fill; a logo is contained so it is never chopped. */
.client-img-preview.rounded-circle img { object-fit: cover; }

.client-avatar {
    width: 40px; height: 40px; flex: 0 0 40px; border-radius: .5rem;
    display: inline-flex; align-items: center; justify-content: center;
    background: #f1f5f9; border: 1px solid var(--adm-line-strong); overflow: hidden;
}
.client-avatar img { width: 100%; height: 100%; object-fit: contain; }
.client-avatar .initials { font-weight: 700; font-size: .8rem; color: var(--adm-muted); }

/* ---------------- multi-product subscription rows ---------------- */
/* Ten columns will not fit a narrow viewport. Give the table a real minimum so
   the responsive wrapper SCROLLS instead of squeezing the numeric inputs down
   to an unusable sliver. */
.cp-rows { min-width: 1120px; }
.cp-rows td, .cp-rows th { padding-left: .5rem; padding-right: .5rem; }
.cp-rows input[type="number"] { min-width: 90px; }
.cp-rows input[type="date"] { min-width: 140px; }
.cp-rows .form-check-input { width: 1.1rem; height: 1.1rem; margin: 0; }
/* Number spinners steal width and are useless for currency — the field is
   typed into, not nudged. */
.cp-rows input[type="number"]::-webkit-outer-spin-button,
.cp-rows input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cp-rows input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.cp-rows tfoot td { border-top: 2px solid var(--adm-line-strong); background: var(--adm-head-bg); }

/* ---------------- invoice / quotation line items ---------------- */
/* Eight columns of inputs will not fit a narrow viewport. Give the table a real
   minimum so the responsive wrapper SCROLLS rather than crushing Qty and Tax %
   down to a sliver you cannot read or type into. */
.inv-items { min-width: 1040px; }
.inv-items td, .inv-items th { padding-left: .5rem; padding-right: .5rem; }
.inv-items input[type="number"] { min-width: 84px; text-align: right; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.inv-items .item-description { min-width: 200px; }
.inv-items select { min-width: 170px; }
/* Spinners eat width and are useless for money — these fields are typed into. */
.inv-items input[type="number"]::-webkit-outer-spin-button,
.inv-items input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.inv-items input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* ================================================================
   ERP additions
   ================================================================ */

/* ---------------- dense transaction tables ----------------
   An ERP list is read in bulk: forty invoice rows at a glance, not eight
   marketing cards. Tighter than the base table, still tall enough to hit
   a row action on a phone. */
.table-dense > :not(caption) > * > * { padding: .45rem .6rem; font-size: .86rem; }
.table-dense thead th {
    background: var(--adm-head-bg); color: var(--adm-muted);
    font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    white-space: nowrap; border-bottom: 1px solid var(--adm-line-strong);
}
.table-dense tbody tr:hover { background: var(--adm-row-hover); }

/* Money and quantity columns line up on the decimal point, which is the
   only way a column of figures can be scanned for an outlier. */
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.num-strong { font-weight: 600; color: var(--adm-ink); }
.num-muted { color: var(--adm-faint); }
.num-negative { color: var(--c-rose-600); }

/* A code / reference number: monospaced so transposed digits are visible. */
.ref-no {
    font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
    font-size: .82rem; color: var(--adm-ink);
}

/* ---------------- status pills ---------------- */
.pill {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .15rem .5rem; border-radius: 999px;
    font-size: .72rem; font-weight: 600; line-height: 1.5; white-space: nowrap;
}
.pill--green  { background: var(--c-green-50);  color: var(--c-green-700); }
.pill--blue   { background: var(--c-blue-50);   color: var(--c-blue-700); }
.pill--orange { background: var(--c-orange-50); color: var(--c-orange-700); }
.pill--rose   { background: #fff1f2;            color: var(--c-rose-600); }
.pill--slate  { background: #f1f5f9;            color: var(--adm-muted); }
.pill--purple { background: var(--c-purple-50); color: var(--c-purple-700); }

/* ---------------- line-item grid ----------------
   The row-per-item editor used by every transaction document. Scrolls
   inside itself so a wide row never makes the whole page scroll sideways. */
.line-items { overflow-x: auto; }
.line-items table { min-width: 860px; margin-bottom: 0; }
.line-items thead th {
    background: var(--adm-head-bg); font-size: .72rem; text-transform: uppercase;
    letter-spacing: .04em; color: var(--adm-muted); font-weight: 700; white-space: nowrap;
}
.line-items td { padding: .3rem .35rem; vertical-align: middle; }
.line-items .form-control, .line-items .form-select { font-size: .85rem; padding: .3rem .5rem; }
.line-items .form-control:focus { box-shadow: 0 0 0 .15rem rgba(37,99,235,.15); }
.line-items tfoot td { border-top: 2px solid var(--adm-line-strong); font-weight: 600; }
.line-row-drop { color: var(--adm-faint); cursor: pointer; }
.line-row-drop:hover { color: var(--c-rose-600); }

/* Totals block that sits beside the line items. */
.doc-totals { font-size: .88rem; }
.doc-totals dl { display: grid; grid-template-columns: 1fr auto; gap: .3rem .8rem; margin: 0; }
.doc-totals dt { color: var(--adm-muted); font-weight: 500; }
.doc-totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.doc-totals .grand { border-top: 1px solid var(--adm-line-strong); padding-top: .4rem; margin-top: .25rem; }
.doc-totals .grand dt, .doc-totals .grand dd { font-size: 1rem; font-weight: 700; color: var(--adm-ink); }

/* ---------------- status stepper ----------------
   Draft → Sent → Accepted, shown at the top of a document detail screen. */
.stepper { display: flex; flex-wrap: wrap; gap: .25rem; list-style: none; padding: 0; margin: 0; }
.stepper li {
    position: relative; padding: .3rem .85rem .3rem 1.4rem;
    background: #f1f5f9; color: var(--adm-muted);
    font-size: .78rem; font-weight: 600;
}
.stepper li:first-child { padding-left: .85rem; border-radius: 4px 0 0 4px; }
.stepper li:last-child { border-radius: 0 4px 4px 0; }
.stepper li::before {
    content: ""; position: absolute; left: 0; top: 0; border: 15px solid transparent;
    border-left-color: #fff; border-width: 15px 0 15px 9px;
}
.stepper li:first-child::before { display: none; }
.stepper li.done { background: var(--c-green-100); color: var(--c-green-700); }
.stepper li.done + li::before { border-left-color: var(--c-green-100); }
.stepper li.current { background: var(--c-blue-600); color: #fff; }
.stepper li.current + li::before { border-left-color: var(--c-blue-600); }
.stepper li + li::before { border-left-color: #f1f5f9; }
.stepper li.done::before, .stepper li.current::before { border-left-color: inherit; }

/* ---------------- empty state ---------------- */
.empty-state { padding: 2.5rem 1rem; text-align: center; color: var(--adm-muted); }
.empty-state i { font-size: 2.2rem; color: var(--adm-faint); display: block; margin-bottom: .6rem; }
.empty-state h6 { color: var(--adm-ink); font-weight: 600; }

/* ---------------- quota / trial banner ---------------- */
.notice-bar {
    border-radius: 8px; padding: .55rem .9rem; font-size: .85rem;
    display: flex; align-items: center; gap: .6rem; margin-bottom: 1rem;
}
.notice-bar--warn { background: var(--c-orange-50); color: var(--c-orange-700); border: 1px solid var(--c-orange-100); }
.notice-bar--info { background: var(--c-blue-50); color: var(--c-blue-700); border: 1px solid var(--c-blue-100); }
.notice-bar--danger { background: #fff1f2; color: var(--c-rose-600); border: 1px solid #ffe4e6; }

/* Impersonation banner — deliberately loud. An operator must never forget
   they are acting inside somebody else's workspace (§6). */
.impersonating-bar {
    background: repeating-linear-gradient(45deg, #7c3aed, #7c3aed 12px, #6d28d9 12px, #6d28d9 24px);
    color: #fff; font-size: .82rem; font-weight: 600;
    padding: .4rem .9rem; display: flex; align-items: center; gap: .6rem;
}
.impersonating-bar .btn { --bs-btn-padding-y: .1rem; --bs-btn-padding-x: .5rem; --bs-btn-font-size: .75rem; }

/* ---------------- keyboard hints ----------------
   Data entry is keyboard-first (§4.5), so the shortcuts have to be visible. */
kbd.hint {
    background: #fff; border: 1px solid var(--adm-line-strong); border-bottom-width: 2px;
    border-radius: 4px; padding: .05rem .3rem; font-size: .7rem; color: var(--adm-muted);
    font-family: inherit;
}

/* ---------------- print ---------------- */
@media print {
    .admin-sidebar, .admin-topbar, .no-print, .filter-card, .page-head .btn { display: none !important; }
    .admin-main { margin-left: 0 !important; }
    body { background: #fff; }
    .card { border: 0 !important; box-shadow: none !important; }
}

/* ---------------- searchable selects (Tom Select) ----------------
   The Bootstrap 5 theme makes the WRAPPER the .form-select box (border,
   radius, caret) and strips the inner .ts-control — so the overrides
   here only size the control, colour the focus ring with the brand, and
   style the dropdown, which lives in <body>. */
.ts-wrapper.form-select { min-height: calc(1.5em + .75rem + 2px); }
.ts-wrapper.form-select .ts-control { padding: .375rem 2.25rem .375rem .75rem; min-height: calc(1.5em + .75rem); line-height: 1.5; }
.ts-wrapper.form-select.form-select-sm { min-height: calc(1.5em + .5rem + 2px); }
.ts-wrapper.form-select.form-select-sm .ts-control { padding: .25rem 2rem .25rem .5rem; min-height: calc(1.5em + .5rem); font-size: .875rem; }
.ts-wrapper.form-select .ts-control .item { line-height: 1.5; }
.ts-wrapper.form-select.focus { border-color: var(--brand-primary, #86b7fe); box-shadow: 0 0 0 .25rem rgba(var(--brand-primary-rgb, 13,110,253), .18); }
.ts-wrapper.form-select.focus .ts-control { box-shadow: none; }
.ts-wrapper.form-select.disabled { background-color: #e9ecef; opacity: 1; }
.ts-wrapper.form-select.is-invalid, .is-invalid + .ts-wrapper.form-select { border-color: #dc3545; }
.ts-wrapper.form-select .ts-control input::placeholder { color: #6c757d; }
.ts-dropdown { z-index: 1090; border: 1px solid #dee2e6; border-radius: .375rem; box-shadow: 0 10px 30px -10px rgba(15,23,42,.25); font-size: .92rem; }
.ts-dropdown .dropdown-input-wrap { padding: .35rem; border-bottom: 1px solid #eef2f7; }
.ts-dropdown .dropdown-input { border: 1px solid #dee2e6; border-radius: .3rem; padding: .3rem .5rem; font-size: .9rem; width: 100%; box-shadow: none; }
.ts-dropdown .dropdown-input:focus { border-color: var(--brand-primary, #86b7fe); outline: 0; }
.ts-dropdown .option { padding: .4rem .65rem; }
.ts-dropdown .option.active { background: var(--c-blue-50, #eff6ff); color: var(--c-blue-700, #1d4ed8); }
.ts-dropdown .no-results { padding: .5rem .65rem; color: #6c757d; }
.ts-dropdown.ts-dropdown-sm { font-size: .84rem; }
.ts-wrapper.multi .ts-control > .item { background: var(--c-blue-50, #eff6ff); color: var(--c-blue-700, #1d4ed8); border-radius: .3rem; padding: .1rem .4rem; }
.ts-wrapper.multi .ts-control > .item .remove { border-left: 0; padding: 0 .3rem; }
/* A select inside a table row: no wrapping, keep the row's height. */
.table .ts-wrapper.form-select .ts-control { white-space: nowrap; overflow: hidden; }
.table .ts-wrapper.form-select .ts-control .item { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

/* ---------------- stat tiles on a phone ----------------
   The figure shrinks before it clips; the label may wrap. */
.stat-label, .stat-sub { overflow-wrap: anywhere; }
.stat-value { overflow-wrap: anywhere; }
@media (max-width: 575.98px) {
    .stat-card { gap: .6rem; padding: .8rem .8rem; }
    .stat-icon { width: 38px; height: 38px; font-size: 1rem; }
    .stat-label { font-size: .64rem; letter-spacing: .02em; }
    .stat-value { font-size: 1.15rem; }
}
.ts-wrapper.form-select .ts-control .item { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; display: block; }
/* A searchable select in an auto-width filter column is never narrower than its label. */
.ts-wrapper.form-select-sm { min-width: 9rem; }
.table .ts-wrapper.form-select-sm { min-width: 0; }
/* Six tiles across (col-xl-2) leave little room for a lakh figure: shrink it before it wraps. */
@media (min-width: 1200px) and (max-width: 1599.98px) {
    .col-xl-2 .stat-card { gap: .6rem; padding: .85rem .8rem; }
    /* The icon is the first thing to go: the figure is the point of the tile. */
    .col-xl-2 .stat-icon { display: none; }
    .col-xl-2 .stat-value { font-size: 1.12rem; letter-spacing: -.3px; }
    .col-xl-2 .stat-label { font-size: .62rem; letter-spacing: .02em; }
    .col-xl-2 .stat-sub { font-size: .7rem; }
}
