/* =====================================================================
   EyeQ Lekha theme (same family as the College ERP theme)
   Deep slate header, teal for actions, amber for money owed,
   IBM Plex Mono tabular numerals so amount columns line up.
   Compact density for all-day data entry; crisp bordered inputs.
   ===================================================================== */
:root {
    --ink: #10162B; --ink-2: #1B2440; --ink-3: #2A3454;
    --accent: #0E7C7B; --accent-dark: #0A5F5E; --accent-soft: #E4F2F1;
    --amber: #B26A00; --amber-soft: #FDF3E2;
    --danger: #B4322A; --danger-soft: #FBEDEC;
    --success: #1E7A4F; --success-soft: #E7F4EE;
    --canvas: #F4F6FA; --surface: #FFFFFF;
    --line: #E2E7F0; --line-strong: #CBD3E1;
    --text: #1A2138; --text-2: #5A6480; --text-3: #8A93AC;
    --radius: 6px; --shadow: 0 1px 2px rgba(16,22,43,.06), 0 4px 12px rgba(16,22,43,.05);
    --mono: 'IBM Plex Mono', ui-monospace, monospace;
    --hdr-h: 88px;
    --bs-primary: #0E7C7B; --bs-primary-rgb: 14,124,123;
    --bs-link-color: #0E7C7B; --bs-link-hover-color: #0A5F5E; --bs-link-color-rgb: 14,124,123;
    --bs-border-color: #CBD3E1; --bs-body-font-size: 13px;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--canvas); color: var(--text); font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 13px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; } a:hover { color: var(--accent-dark); }
h1, h2, h3, h4, h5, h6 { font-weight: 600; letter-spacing: -.01em; }
kbd { font-family: var(--mono); font-size: 10px; padding: 1px 4px; background: rgba(255,255,255,.18); border-radius: 3px; }
.num, td.num, th.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* ---------- bootstrap tuning */
.btn { font-size: 12.5px; border-radius: var(--radius); font-weight: 500; }
.btn-sm { padding: .2rem .55rem; font-size: 12px; }
.btn-primary { --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent); --bs-btn-hover-bg: var(--accent-dark); --bs-btn-hover-border-color: var(--accent-dark); --bs-btn-active-bg: var(--accent-dark); --bs-btn-active-border-color: var(--accent-dark); --bs-btn-disabled-bg: var(--accent); --bs-btn-disabled-border-color: var(--accent); }
.btn-outline-primary { --bs-btn-color: var(--accent); --bs-btn-border-color: var(--accent); --bs-btn-hover-bg: var(--accent); --bs-btn-hover-border-color: var(--accent); --bs-btn-active-bg: var(--accent-dark); }
.btn-success { --bs-btn-bg: var(--success); --bs-btn-border-color: var(--success); --bs-btn-hover-bg: #17603e; --bs-btn-hover-border-color: #17603e; }
.btn-light { --bs-btn-bg: #fff; --bs-btn-border-color: var(--line-strong); --bs-btn-hover-bg: var(--canvas); --bs-btn-hover-border-color: var(--line-strong); }
.text-primary { color: var(--accent) !important; }
.text-bg-primary { background: var(--accent) !important; color: #fff !important; }
.border-primary { border-color: var(--accent) !important; }
.form-control, .form-select { font-size: 13px; border: 1px solid var(--line-strong); border-radius: var(--radius); color: var(--text); background-color: #fff; }
.form-control-sm, .form-select-sm { font-size: 12.5px; padding: .22rem .5rem; min-height: 29px; }
.form-select-sm { padding-right: 1.8rem; }
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(14,124,123,.18); }
.form-control[readonly] { background: var(--canvas); }
.form-label { font-size: 11.5px; color: var(--text-2); font-weight: 600; margin-bottom: 2px; }
.form-text { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-check-input { border-color: var(--line-strong); }
.form-check-label { font-size: 12.5px; }
.req::after { content: " *"; color: var(--danger); }
.row.g-2 { --bs-gutter-y: .45rem; --bs-gutter-x: .6rem; }
.input-group-text { font-size: 12px; border-color: var(--line-strong); background: var(--canvas); }
.modal-header { padding: .6rem .9rem; background: var(--canvas); border-bottom: 1px solid var(--line); }
.modal-title { font-size: 15px; }
.modal-body { padding: .8rem .9rem; }
.modal-footer { padding: .5rem .9rem; }
.nav-tabs .nav-link { font-size: 12.5px; padding: .4rem .8rem; color: var(--text-2); }
.nav-tabs .nav-link.active { color: var(--accent-dark); font-weight: 600; }
.alert { padding: .5rem .8rem; font-size: 12.5px; }
.badge { font-weight: 600; }
.dropdown-menu { font-size: 12.5px; border-color: var(--line); box-shadow: var(--shadow); border-radius: var(--radius); }
.dropdown-item { padding: .3rem .8rem; }
.dropdown-item:active { background: var(--accent); }

/* ---------- header: top bar + horizontal nav */
.app-header { position: sticky; top: 0; z-index: 1030; }
.topbar { height: 46px; background: var(--ink); color: #C7CEE0; display: flex; align-items: center; gap: 12px; padding: 0 14px; }
.brand { display: flex; gap: 9px; align-items: center; color: #fff; text-decoration: none; }
.brand:hover { color: #fff; }
.brand-mark { width: 30px; height: 30px; border-radius: 7px; background: linear-gradient(135deg, var(--accent), #14A3A1); display: grid; place-items: center; font-weight: 700; color: #fff; font-size: 13px; flex: 0 0 auto; }
.brand b { display: block; font-size: 14px; line-height: 1.1; }
.brand small { color: #8A93AC; font-size: 10.5px; }
.co-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 100px; background: var(--ink-2); color: #fff; font-size: 12px; font-weight: 600; border: 1px solid var(--ink-3); }
.co-chip:hover { color: #fff; background: var(--ink-3); }
.fy-chip { padding: 3px 9px; border-radius: 100px; background: rgba(14,124,123,.25); color: #9FE0DE; font-family: var(--mono); font-size: 11px; font-weight: 600; }
.topbar .btn-light { --bs-btn-bg: var(--ink-2); --bs-btn-color: #fff; --bs-btn-border-color: var(--ink-3); --bs-btn-hover-bg: var(--ink-3); --bs-btn-hover-color: #fff; --bs-btn-hover-border-color: var(--ink-3); --bs-btn-active-bg: var(--ink-3); --bs-btn-active-color: #fff; }
.topnav { background: var(--surface); border-bottom: 1px solid var(--line-strong); box-shadow: 0 1px 2px rgba(16,22,43,.04); padding: 0 8px; display: flex; align-items: center; min-height: 40px; }
.topnav > ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 2px; }
.topnav > ul > li { position: relative; }
.topnav > ul > li > a { display: flex; align-items: center; gap: 6px; padding: 10px 11px; color: var(--text); font-weight: 600; font-size: 12.5px; border-bottom: 2px solid transparent; white-space: nowrap; }
.topnav > ul > li > a i { color: var(--text-2); font-size: 14px; }
.topnav > ul > li > a .bi-chevron-down { font-size: 9px; color: var(--text-3); }
.topnav > ul > li:hover > a, .topnav > ul > li.open > a { color: var(--accent-dark); background: var(--accent-soft); }
.topnav > ul > li.active > a { color: var(--accent-dark); border-bottom-color: var(--accent); }
.topnav > ul > li.active > a i { color: var(--accent); }
.topnav .menu { display: none; position: absolute; top: 100%; left: 0; min-width: 230px; background: #fff; border: 1px solid var(--line-strong); border-radius: 0 0 var(--radius) var(--radius); box-shadow: 0 10px 24px rgba(16,22,43,.12); padding: 6px; z-index: 1040; }
.topnav { position: relative; }
.topnav > ul > li.has-mega { position: static; }
.topnav .menu.mega { display: none; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 4px 10px; left: 8px; right: 8px; min-width: 0; padding: 10px; border-radius: var(--radius); max-height: calc(100vh - 70px); overflow-y: auto; }
.topnav > ul > li:hover > .menu, .topnav > ul > li.open > .menu { display: block; }
.topnav > ul > li:hover > .menu.mega, .topnav > ul > li.open > .menu.mega { display: grid; }
.topnav .menu a { display: flex; align-items: center; gap: 8px; padding: 6px 9px; color: var(--text); border-radius: 5px; font-size: 12.5px; white-space: nowrap; }
.topnav .menu a i { color: var(--text-3); width: 16px; text-align: center; }
.topnav .menu a:hover { background: var(--accent-soft); color: var(--accent-dark); }
.topnav .menu a:hover i { color: var(--accent); }
.topnav .menu a.active { background: var(--accent); color: #fff; } .topnav .menu a.active i { color: #fff; }
.topnav .menu .mh { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); font-weight: 700; padding: 6px 9px 3px; }
.topnav .menu hr { margin: 4px 0; border-color: var(--line); opacity: 1; }
.topnav .menu kbd { margin-left: auto; background: var(--canvas); color: var(--text-2); }
.nav-toggle { display: none; }
@media (max-width: 991px) {
    :root { --hdr-h: 46px; }
    .nav-toggle { display: inline-flex; }
    .topnav { display: none; position: fixed; top: 46px; left: 0; right: 0; bottom: 0; overflow-y: auto; align-items: stretch; padding: 6px; }
    .topnav.show { display: block; }
    .topnav > ul { flex-direction: column; }
    .topnav .menu, .topnav .menu.mega { position: static; min-width: 0; box-shadow: none; border: 0; grid-template-columns: 1fr; padding: 0 0 0 14px; }
    .topbar .hide-sm { display: none !important; }
}
.content { padding: 12px 14px 20px; max-width: 1680px; margin: 0 auto; }

/* ---------- page parts */
.page-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.page-head h1 { font-size: 17px; font-weight: 700; margin: 0; }
.page-head .sub { color: var(--text-2); font-size: 12px; }
.page-head .actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); background: var(--surface); }
.card-header { background: var(--surface); border-bottom: 1px solid var(--line); font-weight: 600; font-size: 12.5px; padding: .45rem .75rem; }
.card-body { padding: .65rem .75rem; }
.card-footer { background: var(--canvas); padding: .45rem .75rem; }
.filters { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 10px; margin-bottom: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: end; box-shadow: var(--shadow); }
.filters .f { display: flex; flex-direction: column; min-width: 130px; }
.filters label { font-size: 11px; color: var(--text-2); margin-bottom: 1px; font-weight: 600; }

/* ---------- tables (compact) */
.table { font-size: 12.5px; margin-bottom: 0; --bs-table-hover-bg: var(--accent-soft); }
.table > :not(caption) > * > * { padding: .28rem .45rem; border-bottom-color: var(--line); }
.table thead th { background: #EEF1F7; color: var(--text-2); font-weight: 700; white-space: nowrap; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid var(--line-strong); }
.table td { vertical-align: middle; }
.table .btn-sm { padding: .1rem .38rem; }
tr.r-bold td { font-weight: 600; }
tr.r-group td { font-weight: 700; background: #F5F7FB; }
tr.r-total td, tfoot tr td { font-weight: 700; background: #E9EEF6; }
tr.r-header td { font-weight: 700; background: var(--accent-soft); color: var(--accent-dark); text-transform: uppercase; font-size: 11px; letter-spacing: .05em; }
tr.r-muted td { color: var(--text-2); font-style: italic; font-size: 11.5px; }
tr[data-link] { cursor: pointer; }
.dt-container { font-size: 12.5px; }
.dt-container .dt-search input { min-width: 220px; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: .2rem .5rem; }
.dt-container .dt-length select { width: auto; border: 1px solid var(--line-strong); border-radius: var(--radius); }
.dt-container .dt-layout-row { margin: 4px 0 !important; }
.dt-container .dt-paging .dt-paging-button { padding: .15rem .55rem !important; }
.dt-container .page-item.active .page-link { background: var(--accent); border-color: var(--accent); }
.dt-container .page-link { color: var(--accent); font-size: 12px; padding: .2rem .55rem; }
.amount-due { color: var(--amber); font-weight: 600; }

/* ---------- dashboard */
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; height: 100%; box-shadow: var(--shadow); }
.kpi .l { color: var(--text-2); font-size: 11.5px; display: flex; gap: 6px; align-items: center; font-weight: 600; }
.kpi .v { font-size: 18px; font-weight: 600; margin-top: 2px; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.kpi i { font-size: 15px; }
.quick a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 6px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); font-size: 12px; font-weight: 600; box-shadow: var(--shadow); }
.quick a i { font-size: 18px; color: var(--accent); }
.quick a:hover { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- bill entry */
.inv-head .form-label { margin-bottom: 1px; }
.inv-grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.inv-grid th { background: var(--ink-2); color: #fff; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; padding: 5px 5px; white-space: nowrap; border: 1px solid var(--ink-3); position: sticky; top: var(--hdr-h); z-index: 3; }
.inv-grid td { border: 1px solid var(--line-strong); padding: 0; background: #fff; vertical-align: top; height: 30px; }
.inv-grid tr:focus-within td { background: #F2FAF9; }
.inv-grid input:not([type=checkbox]) { width: 100%; height: 29px; border: 0; background: transparent; padding: 3px 6px; font-size: 13px; color: var(--text); }
.inv-grid input:not([type=checkbox]):focus { outline: 2px solid var(--accent); outline-offset: -2px; background: #fff; }
.inv-grid input.num { font-family: var(--mono); }
.inv-grid input:disabled { background: var(--canvas); color: var(--text-3); }
.inv-grid td.c { text-align: center; vertical-align: middle; }
.inv-grid td.ro { text-align: right; padding: 5px 7px; font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--text); vertical-align: middle; }
.inv-grid td.sr { text-align: center; color: var(--text-3); font-size: 11.5px; vertical-align: middle; }
.inv-grid .ts-wrapper { height: auto; }
.inv-grid .ts-wrapper .ts-control { border: 0; box-shadow: none !important; border-radius: 0; padding: 4px 6px; min-height: 29px; background: transparent; font-size: 13px; }
.inv-grid .ts-wrapper.focus .ts-control { outline: 2px solid var(--accent); outline-offset: -2px; background: #fff; }
.inv-grid .info { font-size: 10.5px; color: var(--text-3); padding: 0 6px 2px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inv-grid .info:empty { display: none; }
.inv-grid tfoot td { background: #E9EEF6; font-weight: 700; padding: 5px 7px; }
.inv-grid .del { border: 0; background: none; color: var(--text-3); width: 100%; height: 29px; }
.inv-grid .del:hover { color: var(--danger); }
/* Desktop: no scroll wrapper, so the column header can stick under the page header while scrolling long bills.
   Small screens: horizontal scroll, header not sticky (a scrolling ancestor would become the sticky container). */
.grid-wrap { overflow: visible; }
@media (max-width: 1199px) { .grid-wrap { overflow-x: auto; } .grid-wrap .inv-grid { min-width: 980px; } .grid-wrap .inv-grid th { position: static; } }
.grid-tools { display: flex; gap: 6px; padding: 6px 8px; border-top: 1px solid var(--line); align-items: center; }
.totals { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; box-shadow: var(--shadow); }
.totals .t { display: flex; justify-content: space-between; padding: 2px 0; font-size: 12.5px; }
.totals .t span:last-child { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.totals .net { border-top: 2px solid var(--ink); margin-top: 5px; padding-top: 6px; font-size: 18px; font-weight: 700; color: var(--ink); }
.scan-box { background: var(--accent-soft); border: 1px dashed var(--accent); border-radius: var(--radius); padding: 3px 10px; }
.scan-box input { font-size: 14px; letter-spacing: .05em; font-family: var(--mono); }
.party-info { font-size: 11.5px; color: var(--text-2); min-height: 16px; }
.party-info b { color: var(--text); }
.save-bar { position: sticky; bottom: 0; background: rgba(244,246,250,.97); padding: 7px 0; border-top: 1px solid var(--line-strong); margin-top: 8px; z-index: 5; }
.save-bar .net-big { font-family: var(--mono); font-size: 18px; font-weight: 700; color: var(--ink); }
.ch-table td { padding: 2px 4px !important; }
.ch-table input, .ch-table select { min-height: 27px !important; }
.lbl-inline { display: grid; grid-template-columns: 1fr; }
.doc-badge { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-weight: 600; background: var(--accent-soft); color: var(--accent-dark); padding: 2px 9px; border-radius: 100px; font-size: 12px; }
.ret-hint { font-size: 10.5px; color: var(--amber); padding: 0 6px; }

/* ---------- misc */
.badge-soft { background: #EEF1F7; color: var(--text-2); font-weight: 600; border: 1px solid var(--line); }
.logo-prev { max-height: 80px; max-width: 220px; border: 1px dashed var(--line-strong); padding: 4px; border-radius: var(--radius); background: #fff; }
.perm-table td, .perm-table th { text-align: center; } .perm-table td:first-child, .perm-table th:first-child { text-align: left; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(900px 500px at 10% 0%, rgba(14,124,123,.18), transparent), linear-gradient(160deg, #10162B 0%, #1B2440 100%); }
.login-card { width: 370px; max-width: 94vw; background: #fff; border-radius: 10px; padding: 26px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.empty { text-align: center; color: var(--text-2); padding: 34px 10px; }
.empty i { font-size: 30px; display: block; margin-bottom: 6px; color: var(--line-strong); }
.swal2-popup { font-size: 13px !important; }
.swal2-confirm { background: var(--accent) !important; }
.ts-wrapper.form-select, .ts-wrapper.single .ts-control { min-height: 29px; }
.ts-control { border-color: var(--line-strong) !important; border-radius: var(--radius) !important; font-size: 12.5px; padding: 4px 8px !important; }
.ts-wrapper.focus .ts-control { border-color: var(--accent) !important; box-shadow: 0 0 0 2px rgba(14,124,123,.18) !important; }
.ts-dropdown { font-size: 12.5px; border-color: var(--line-strong); box-shadow: 0 8px 20px rgba(16,22,43,.14); z-index: 2000; }
.ts-dropdown .active { background: var(--accent-soft); color: var(--accent-dark); }
.ts-dropdown .option { padding: 4px 8px; }
@media print { .app-header, .save-bar, .filters, .page-head .actions { display: none !important; } .content { padding: 0; } .card { border: 0; box-shadow: none; } }
