/* Fonts are bundled (no internet needed): IBM Plex Sans for Latin text and digits, Noto Sans Tamil for Tamil names. */
@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-style: normal; font-display: swap; src: url("../fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/ibm-plex-sans-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Noto Sans Tamil"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/noto-sans-tamil-tamil-400-normal.woff2") format("woff2"); unicode-range: U+0B80-0BFF, U+200C-200D; }
@font-face { font-family: "Noto Sans Tamil"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/noto-sans-tamil-tamil-600-normal.woff2") format("woff2"); unicode-range: U+0B80-0BFF, U+200C-200D; }
html { font-size: 14px; }

/* Theme: change these variables to re-skin the whole app (loaded after Bootstrap 5.3). */
:root {
    --brand: #0f766e;
    --brand-dark: #0b524d;
    --brand-soft: #e3f3f1;
    --accent: #c9893a;
    --page-bg: #f5f2ec;
    --bs-primary: #0f766e;
    --bs-primary-rgb: 15, 118, 110;
    --bs-link-color: #0f766e;
    --bs-link-color-rgb: 15, 118, 110;
    --bs-link-hover-color: #0b524d;
    --bs-body-bg: #f5f2ec;
    --bs-body-color: #1d2a2a;
    --bs-border-color: #dcd6ca;
    --bs-body-font-family: "IBM Plex Sans", "Noto Sans Tamil", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    --bs-body-font-size: 1rem;
    --bs-body-line-height: 1.45;
    --bs-border-radius: .65rem;
}

.btn-primary {
    --bs-btn-bg: #0f766e;
    --bs-btn-border-color: #0f766e;
    --bs-btn-hover-bg: #0b524d;
    --bs-btn-hover-border-color: #0b524d;
    --bs-btn-active-bg: #0b524d;
    --bs-btn-active-border-color: #0b524d;
    --bs-btn-disabled-bg: #0f766e;
    --bs-btn-disabled-border-color: #0f766e;
    --bs-btn-focus-shadow-rgb: 15, 118, 110;
    font-weight: 600;
}
.form-control, .form-select { background-color: #fff; }
.card { --bs-card-bg: #fff; }
.table { --bs-table-bg: transparent; }
.form-control:focus { background-color: #fff; border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(15, 118, 110, .2); }
.card { border-color: var(--bs-border-color); }

/* ---------- brand ---------- */
.brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 700; letter-spacing: .2px; color: inherit; text-decoration: none; }
.brand-mark { width: 26px; height: 26px; border-radius: 8px; display: inline-block;
    background: conic-gradient(from 210deg, var(--brand), #27a596, var(--accent), var(--brand)); }
.brand-lg { font-size: 1.25rem; }

/* ---------- login ---------- */
body.auth { background: var(--page-bg); }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-hero { background: radial-gradient(1200px 600px at 10% 0%, #17897f 0%, var(--brand) 45%, #08403c 100%);
    color: #f4fbfa; display: flex; align-items: center; padding: 3rem; position: relative; overflow: hidden; }
.login-hero::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 380px; height: 380px;
    border-radius: 50%; background: rgba(201, 137, 58, .28); }
.login-hero-inner { position: relative; z-index: 1; max-width: 460px; }
.login-hero h1 { font-size: 2.3rem; line-height: 1.2; margin: 2.2rem 0 1rem; font-weight: 700; }
.login-hero p { font-size: 1.05rem; opacity: .85; margin: 0; }
.login-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem; }
.login-card { width: 100%; max-width: 400px; box-shadow: 0 10px 30px rgba(20, 40, 38, .08); }
.login-foot { margin-top: 1.2rem; text-align: center; max-width: 380px; }

@media (max-width: 860px) {
    .login-shell { grid-template-columns: 1fr; }
    .login-hero { padding: 1.6rem; }
    .login-hero h1 { font-size: 1.5rem; margin: 1rem 0 .4rem; }
    .login-hero p, .login-hero::after { display: none; }
}

/* ---------- app shell ---------- */
.topbar { background: #fff; border-bottom: 1px solid var(--bs-border-color); }
.topbar .nav-link { color: #66757a; font-weight: 600; }
.topbar .nav-link:hover { color: var(--brand); }
.content { padding-top: 1.6rem; padding-bottom: 3rem; }
.error-box { max-width: 480px; margin: 4rem auto; }

/* ---------- diagnostics ---------- */
.diag th, .diag td { padding: .6rem .8rem; vertical-align: top; }
.diag th { width: 24%; font-weight: 600; }
.diag td { word-break: break-word; }
.diag-status { width: 76px; }

/* ---------- billing screen ---------- */
.item-results { position: absolute; z-index: 30; left: 0; right: 0; max-height: 360px; overflow-y: auto; box-shadow: 0 8px 24px rgba(20, 40, 38, .15); }
.bill-lines td, .bill-lines th { vertical-align: middle; }
.bill-lines .form-control-sm, .bill-lines .form-select { min-width: 0; }
.summary-card { position: sticky; top: 76px; }
.sum-row { display: flex; justify-content: space-between; padding: .15rem 0; }
.sum-total { font-size: 1.35rem; font-weight: 700; border-top: 1px solid var(--bs-border-color); margin-top: .35rem; padding-top: .5rem; }
.wallet-box { background: var(--brand-soft); border-radius: .6rem; padding: .6rem .7rem; margin-top: .75rem; }
.cashback-line { background: #fff7e6; border: 1px solid #f0d9a0; color: #7a5200; border-radius: .6rem; padding: .45rem .7rem; margin-top: .75rem; font-size: .9rem; }
.invoice { max-width: 760px; }
.invoice-80 { max-width: 320px; font-size: .85rem; }
.invoice-table th { font-weight: 600; }

@media print {
    .topbar, .no-print, footer { display: none !important; }
    body { background: #fff !important; }
    .content { padding: 0 !important; max-width: none !important; }
    .invoice { box-shadow: none !important; border: 0 !important; max-width: none; margin: 0; }
    .invoice-80 { max-width: 72mm; }
    .no-print-link { text-decoration: none; color: inherit !important; }
    a { color: inherit !important; text-decoration: none !important; }
}

.bill-lines td:first-child { min-width: 200px; }

@media (max-width: 768px) {
    .summary-card { position: static; }
}

/* ---------- polish ---------- */
.topbar .nav-link { white-space: nowrap; }
.topbar .who { white-space: nowrap; }
.table > thead th { font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: #66757a; border-bottom-width: 1px; }
.invoice-table > thead th, .bill-lines > thead th { color: inherit; }
.card { box-shadow: 0 1px 2px rgba(20, 40, 38, .04); }
.stat-tile .h4, .stat-tile .h5 { font-variant-numeric: tabular-nums; }
.stat-link { text-decoration: none; color: inherit; display: block; }
.stat-link:hover .card { border-color: var(--brand); }
.recent td { white-space: nowrap; }

/* ---------- billing lines: stacked cards on phones ---------- */
@media (max-width: 767.98px) {
    .bill-lines, .bill-lines tbody, .bill-lines tr, .bill-lines td { display: block; width: 100%; }
    .bill-lines thead { display: none; }
    .bill-lines tr { border-bottom: 1px solid var(--bs-border-color); padding: .6rem .75rem; position: relative; }
    .bill-lines td { border: 0; padding: .15rem 0; }
    .bill-lines td[data-label]::before { content: attr(data-label); display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: #66757a; }
    .bill-lines td[data-net] { text-align: left !important; font-size: 1.1rem; }
    .bill-lines td:last-child { position: absolute; top: .5rem; right: .6rem; width: auto; }
    .bill-lines td:first-child { min-width: 0; padding-right: 2rem; }
}

.topbar .btn { white-space: nowrap; }
.nav-pills .nav-link.active, .nav-pills .show > .nav-link { background-color: var(--brand); }
.nav-pills .nav-link { color: var(--brand); }


/* ---------- section colours (each part of a screen has its own accent) ---------- */
.section-card { border-top: 3px solid var(--sec, #94a3a0); background: var(--sec-bg, #fff) !important; --bs-card-bg: var(--sec-bg, #fff); }
.sec-blue   { --sec: #2563eb; --sec-bg: #f4f8ff; }
.sec-teal   { --sec: #0f766e; --sec-bg: #f2fbf9; }
.sec-purple { --sec: #7c3aed; --sec-bg: #f8f5ff; }
.sec-orange { --sec: #d97706; --sec-bg: #fff9ef; }
.sec-slate  { --sec: #475569; --sec-bg: #ffffff; }
.sec-green  { --sec: #15803d; --sec-bg: #f4fbf6; }
.section-title { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--sec, #475569); margin-bottom: .7rem; }
.section-card .card-header { background: transparent; }

/* Billing: customer 35% | item entry 65% */
@media (min-width: 768px) {
    .bill-top > .col-cust { flex: 0 0 auto; width: 35%; }
    .bill-top > .col-add { flex: 0 0 auto; width: 65%; }
}

/* Item type tabs */
.type-tabs { display: flex; gap: .4rem; flex-wrap: wrap; }
.type-tab { border: 1px solid var(--tc); color: var(--tc); background: #fff; border-radius: 999px; padding: .28rem .85rem; font-weight: 600; font-size: .9rem; }
.type-tab:hover { background: color-mix(in srgb, var(--tc) 10%, #fff); }
.type-tab.active { background: var(--tc); color: #fff; }
.t-service { --tc: #0f766e; } .t-product { --tc: #d97706; } .t-combo { --tc: #7c3aed; }
#itemCard.mode-SERVICE { --sec: #0f766e; --sec-bg: #f2fbf9; }
#itemCard.mode-PRODUCT { --sec: #d97706; --sec-bg: #fff9ef; }
#itemCard.mode-COMBO   { --sec: #7c3aed; --sec-bg: #f8f5ff; }
.bill-lines tr.line-SERVICE > td:first-child { border-left: 4px solid #0f766e; }
.bill-lines tr.line-PRODUCT > td:first-child { border-left: 4px solid #d97706; }
.bill-lines tr.line-COMBO   > td:first-child { border-left: 4px solid #7c3aed; }
.badge-combo { background: #ede9fe; color: #5b21b6; font-weight: 600; }

/* Invoice header: logo + company block + number/date */
.inv-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.inv-brand { display: flex; align-items: center; gap: .8rem; min-width: 0; }
.inv-brand-center { flex-direction: column; text-align: center; width: 100%; }
.inv-logo { max-height: 64px; max-width: 200px; object-fit: contain; }
.invoice-80 .inv-logo { max-height: 48px; max-width: 160px; }
.inv-company { font-size: 1.15rem; font-weight: 700; line-height: 1.2; }
.inv-line { font-size: .8rem; color: #5b6b6b; }
.inv-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: #5b6b6b; margin-top: .25rem; }
.invoice-80 .inv-head { flex-direction: column; align-items: center; text-align: center; }
.logo-preview { min-height: 90px; display: flex; align-items: center; justify-content: center; border: 1px dashed var(--bs-border-color); border-radius: .6rem; background: #fff; padding: .6rem; }
.logo-preview .inv-logo { max-height: 90px; }
@media print { .inv-logo { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }


/* ---------- dashboard tiles and charts ---------- */
.stat-tile { border-left: 4px solid var(--tc, #94a3a0); }
.stat-tile .card-body { padding: .75rem .9rem; }
.stat-icon { flex: 0 0 auto; width: 2.1rem; height: 2.1rem; border-radius: .6rem; display: inline-flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--tc, #94a3a0) 14%, #fff); color: var(--tc, #475569); font-size: 1.05rem; }
.stat-label { font-size: .78rem; color: #66757a; line-height: 1.2; }
.stat-value { font-size: 1.3rem; font-weight: 600; line-height: 1.25; font-variant-numeric: tabular-nums; }
.stat-action { font-size: .78rem; color: var(--tc, var(--brand)); font-weight: 600; margin-top: .1rem; }
.min-w-0 { min-width: 0; }
.chart-title { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #475569; margin-bottom: .5rem; }
.chart-box { position: relative; width: 100%; }


/* ---------- bill colours (set per company on the Company setup page) ---------- */
.invoice { --inv: #0f766e; --inv-text: #ffffff; border-top: 5px solid var(--inv) !important; }
.invoice .inv-company, .invoice .inv-meta .h5 { color: var(--inv); }
.invoice .inv-title { color: var(--inv); font-weight: 600; }
.invoice .inv-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; color: var(--inv); }
.invoice .invoice-table > thead > tr > th { background: var(--inv); color: var(--inv-text); border: 0; font-size: .74rem; letter-spacing: .05em; padding: .5rem .6rem; }
.invoice .invoice-table > thead > tr > th:first-child { border-radius: .4rem 0 0 .4rem; }
.invoice .invoice-table > thead > tr > th:last-child { border-radius: 0 .4rem .4rem 0; }
.invoice .sum-total { color: var(--inv); border-top: 2px solid var(--inv); }
.invoice hr { border-color: var(--inv); opacity: .35; }
.invoice-80 { border-top-width: 1px !important; }
.invoice-80 .invoice-table > thead > tr > th { background: none; color: #000; border-bottom: 1px solid #000; border-radius: 0; }
.invoice-80 .inv-company, .invoice-80 .inv-meta .h5, .invoice-80 .inv-title, .invoice-80 .inv-label, .invoice-80 .sum-total { color: #000; }
.invoice-80 .sum-total { border-top-color: #000; }
@media print {
    .invoice, .invoice * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

@media (max-width: 575.98px) {
    .stat-value { font-size: 1.1rem; white-space: nowrap; }
    .stat-tile .card-body { padding: .6rem .65rem; }
    .stat-icon { width: 1.8rem; height: 1.8rem; font-size: .95rem; }
}

/* footer: vendor name and subscription date */
.app-footer { text-align: center; color: #6c757d; font-size: .8rem; padding: 0 1rem 1.6rem; }

/* login: vendor branding under the sign-in card (the plain footer is hidden on the login page) */
.login-vendor { margin-top: 1.6rem; text-align: center; }
.login-vendor img { display: block; margin: .35rem auto .3rem; max-width: 100%; height: auto; }
body.auth .app-footer { display: none; }

/* Item picker: gender toggle + searchable dropdowns */
.pick-label { font-weight: 600; color: #374151; font-size: .9rem; }
.gender-toggle { display: inline-flex; background: #f3f4f6; border: 1px solid #e5e7eb; border-radius: 999px; padding: 3px; }
.gender-toggle button { border: 0; background: transparent; border-radius: 999px; padding: .3rem 1.1rem; font-weight: 600; color: #374151; }
.gender-toggle button.active { background: var(--sec, #0f766e); color: #fff; }
.ss { position: relative; }
.ss-btn { width: 100%; text-align: left; background: #fff; border: 1px solid #ced4da; border-radius: .375rem; padding: .375rem 2rem .375rem .75rem; position: relative; min-height: 38px; color: #212529; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ss-btn::after { content: ""; position: absolute; right: .8rem; top: 50%; margin-top: -2px; border: 5px solid transparent; border-top-color: #6b7280; }
.ss-btn.ss-empty { color: #6b7280; }
.ss-btn:disabled { background: #f3f4f6; cursor: not-allowed; }
.ss-btn:focus { outline: 0; border-color: var(--sec, #0f766e); box-shadow: 0 0 0 .2rem rgba(15, 118, 110, .15); }
.ss-panel { position: absolute; z-index: 40; left: 0; right: 0; top: 100%; margin-top: 2px; background: #fff; border: 1px solid #ced4da; border-radius: .375rem; box-shadow: 0 8px 24px rgba(20, 40, 38, .18); padding: 6px; }
.ss-list { max-height: 260px; overflow-y: auto; margin-top: 6px; }
.ss-opt { display: flex; justify-content: space-between; gap: .75rem; padding: .35rem .6rem; cursor: pointer; border-radius: .25rem; }
.ss-opt small { color: #6b7280; }
.ss-opt.hi { background: var(--sec, #0f766e); color: #fff; }
.ss-opt.hi small { color: #e5e7eb; }
.ss-none { padding: .5rem .6rem; color: #6b7280; font-size: .9rem; }

/* Customer card on the New Bill screen */
.cust-stats .cs-row { display: flex; justify-content: space-between; gap: .5rem; font-size: .9rem; padding: 1px 0; }
.cust-stats .cs-row span { color: #6b7280; }
.cust-links { display: flex; flex-wrap: wrap; gap: .25rem 1rem; font-size: .9rem; }
.cs-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #d97706; vertical-align: middle; }
