/* =====================================================================
   Invoice OCR & Bill Entry System - custom styles
   ===================================================================== */

:root {
    --sidebar-width: 250px;
    --sidebar-bg: #16213e;
    --sidebar-bg-alt: #0f172a;
    --sidebar-active: #0ea5e9;
    --accent: #16213e;
    --muted: #6c757d;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: #f4f6fb;
    color: #1f2937;
    scroll-behavior: smooth;
}

/* ---------------------------------------------------------------
   Skip to content (accessibility)
   --------------------------------------------------------------- */
.skip-link {
    position: fixed;
    top: -100%;
    left: 1rem;
    z-index: 10000;
    background: var(--sidebar-active);
    color: #fff;
    padding: .75rem 1.25rem;
    border-radius: 0 0 .5rem .5rem;
    font-weight: 600;
    text-decoration: none;
    transition: top .2s ease;
}
.skip-link:focus {
    top: 0;
    outline: 3px solid #f59e0b;
    outline-offset: 2px;
}

/* ---------------------------------------------------------------
   Back to top button
   --------------------------------------------------------------- */
.back-to-top {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity .25s ease, visibility .25s ease, transform .25s ease;
    box-shadow: 0 4px 14px rgba(14, 165, 233, .35);
}
.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.back-to-top:hover {
    transform: translateY(-2px);
}

/* ---------------------------------------------------------------
   Layout wrapper
   --------------------------------------------------------------- */
.app-wrapper { display: flex; min-height: 100vh; }

.app-sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-alt));
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 1040;
    transition: margin-left .25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.brand-icon {
    font-size: 1.7rem;
    color: var(--sidebar-active);
}
.brand-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: 8px;
    flex-shrink: 0;
}
.brand-text { line-height: 1.15; }
.brand-text strong { color: #fff; font-size: 1.05rem; display: block; }
.brand-text small { color: #94a3b8; font-size: .72rem; letter-spacing: .08em; }

.dashboard-logo {
    height: 56px;
    max-width: 120px;
    object-fit: contain;
    border-radius: 10px;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem .5rem; }
.sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .65rem 1rem;
    margin-bottom: .2rem;
    color: #cbd5e1;
    text-decoration: none;
    border-radius: .5rem;
    font-size: .93rem;
    transition: background .15s ease, color .15s ease;
}
.sidebar-nav .nav-item i { font-size: 1.1rem; width: 1.3rem; text-align: center; }
.sidebar-nav .nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar-nav .nav-item.active {
    background: var(--sidebar-active);
    color: #fff;
    box-shadow: 0 4px 12px rgba(14, 165, 233, .35);
}
.sidebar-nav .nav-item .nav-badge {
    margin-left: auto;
    background: #ef4444;
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    min-width: 1.35rem;
    height: 1.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 1rem;
    padding: 0 .4rem;
    animation: pulse-badge 1.6s ease-in-out infinite;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, .08);
    text-align: center;
}

.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.app-navbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .8rem 1.5rem;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .05);
}

.app-content { padding: 1.5rem; flex: 1; }

.messages-area { margin-bottom: 1.25rem; }

/* ---------------------------------------------------------------
   Cards
   --------------------------------------------------------------- */
.stat-card {
    border: 0;
    border-radius: 1rem;
    color: #fff;
    overflow: hidden;
    position: relative;
    box-shadow: 0 6px 16px rgba(15, 23, 42, .12);
}
.stat-card .stat-icon {
    position: absolute;
    right: 1rem;
    bottom: .5rem;
    font-size: 3.4rem;
    opacity: .22;
}
.stat-card .stat-label { font-size: .85rem; opacity: .9; text-transform: uppercase; letter-spacing: .05em; }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; }

.bg-gradient-primary { background: linear-gradient(135deg, #0ea5e9, #2563eb); }
.bg-gradient-success { background: linear-gradient(135deg, #22c55e, #059669); }
.bg-gradient-warning { background: linear-gradient(135deg, #f59e0b, #d97706); }
.bg-gradient-danger  { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.bg-gradient-dark    { background: linear-gradient(135deg, #334155, #0f172a); }

.card { border-radius: .85rem; border: 0; box-shadow: 0 2px 8px rgba(15,23,42,.06); }
.card-header { background: #fff; border-bottom: 1px solid #eef1f6; font-weight: 600; }
.card .table { margin-bottom: 0; }
.card .table thead th {
    background: #f8fafc;
    color: #475569;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid #e5e7eb;
}

/* ---------------------------------------------------------------
   Tables / misc
   --------------------------------------------------------------- */
.table-hover tbody tr:hover { background: #f1f5ff; }

.badge-pill { padding: .45em .75em; border-radius: 2rem; }

.drop-zone {
    border: 2px dashed #cbd5e1;
    border-radius: 1rem;
    background: #f8fafc;
    padding: 2.5rem 1rem;
    text-align: center;
    transition: all .2s ease;
    cursor: pointer;
}
.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--sidebar-active);
    background: #f0f9ff;
}
.drop-zone i { font-size: 3rem; color: var(--sidebar-active); }
.drop-zone .upload-icon { transition: transform .2s ease; }
.drop-zone:hover .upload-icon { transform: translateY(-4px); }

/* ---------------------------------------------------------------
   Upload tabs
   --------------------------------------------------------------- */
.upload-tabs .nav-link {
    border-radius: .6rem .6rem 0 0;
    font-weight: 600;
    color: #64748b;
}
.upload-tabs .nav-link.active {
    color: #0ea5e9;
    background: #f0f9ff;
    border-bottom-color: #f0f9ff;
}

/* ---------------------------------------------------------------
   Import preview
   --------------------------------------------------------------- */
.import-meta-box {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: .7rem;
    padding: .75rem 1rem;
    min-height: 3.6rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    transition: transform .15s ease, box-shadow .15s ease;
}
.import-meta-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(15, 23, 42, .08);
}
.import-meta-box small { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }
.import-table tfoot td { border-top-width: 2px; }

/* ---------------------------------------------------------------
   Loading spinner overlay
   --------------------------------------------------------------- */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(2px);
}
.loading-overlay.show { display: flex; }
.loading-box {
    background: #fff;
    border-radius: 1rem;
    padding: 2rem 2.5rem;
    text-align: center;
    box-shadow: 0 12px 32px rgba(0,0,0,.25);
}

/* ---------------------------------------------------------------
   Bill entry page
   --------------------------------------------------------------- */
.items-table input, .items-table select {
    min-width: 90px;
    font-size: .9rem;
}
.items-table .row-total { font-weight: 600; }

/* ---------------------------------------------------------------
   Excel-like cell navigation
   --------------------------------------------------------------- */
.items-table td.cell-selected {
    box-shadow: inset 0 0 0 2px #0d6efd;
}
.items-table td.cell-selected input {
    outline: none;
}
.items-table td.cell-selected input:focus {
    box-shadow: none;
}
.excel-hint {
    font-size: .75rem;
    color: #6c757d;
    padding: 4px 8px;
    user-select: none;
}
.excel-hint kbd {
    font-size: .7rem;
    padding: 1px 5px;
    border: 1px solid #adb5bd;
    border-radius: 3px;
    background: #f8f9fa;
    box-shadow: 0 1px 0 #adb5bd;
}

/* ---------------------------------------------------------------
   Print friendly invoice
   --------------------------------------------------------------- */
.print-paper {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: .5rem;
    max-width: 794px;   /* A4 @96dpi */
    margin: 0 auto;
    padding: 2rem 2.5rem;
}
.letterhead-text h1 { font-size: 2.2rem; letter-spacing: .06em; }
.letterhead-text h3 { color: #475569; letter-spacing: .12em; }
.invoice-table th { background: #16213e !important; color: #fff; }
.invoice-table td, .invoice-table th { padding: .55rem .75rem; border: 1px solid #dee2e6; }
.totals-box td { padding: .4rem .75rem; }
.grand-total-row td { background: #16213e !important; color: #fff; font-weight: 700; }

/* ---------------------------------------------------------------
   Login page (admin / user / register)
   --------------------------------------------------------------- */
.auth-wrapper {
    min-height: 100vh;
    min-height: 100dvh;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #0f172a;
    padding: 2.5rem 1rem;
    overflow: hidden;
}
.auth-wrapper::before,
.auth-wrapper::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    z-index: 0;
    pointer-events: none;
}
.auth-wrapper::before {
    width: 540px;
    height: 540px;
    background: rgba(37, 99, 235, .35);
    top: -160px;
    left: -140px;
}
.auth-wrapper::after {
    width: 480px;
    height: 480px;
    background: rgba(124, 58, 237, .30);
    bottom: -150px;
    right: -130px;
}
.auth-wrapper > * { position: relative; z-index: 1; }
.auth-wrapper-split { flex-direction: column; }
.auth-alert { max-width: 900px; width: 100%; animation: fadeInUp .35s ease both; }

/* Brand header */
.auth-brand { text-align: center; margin-bottom: 2.2rem; }
.auth-brand-tile {
    width: 66px;
    height: 66px;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 1.1rem;
    font-size: 2.1rem;
    color: #fff;
    background: linear-gradient(135deg, #0ea5e9, #2563eb);
    box-shadow: 0 12px 32px rgba(14, 165, 233, .45);
}
.auth-brand h2 {
    color: #f8fafc;
    font-weight: 700;
    letter-spacing: .5px;
}
.auth-brand .auth-tagline { color: #94a3b8; font-size: .95rem; }

/* 3-box login page */
.auth-cards { max-width: 1140px; width: 100%; }
.auth-cards .col-lg-4, .auth-cards .col-md-6 { display: flex; }
.auth-card {
    width: 100%;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 1.25rem;
    box-shadow: 0 24px 60px rgba(2, 6, 23, .45);
    padding: 1.75rem 1.75rem 1.6rem;
    border-top: 5px solid transparent;
    cursor: pointer;
    transition: transform .22s ease, box-shadow .22s ease;
}
.auth-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 30px 70px rgba(2, 6, 23, .5);
}
.auth-card-admin { border-top-color: #2563eb; }
.auth-card-user { border-top-color: #059669; }
.auth-card-register { border-top-color: #7c3aed; }
.auth-card-standalone { max-width: 430px; margin: 0 auto; }
.auth-card-links a { color: #2563eb; text-decoration: none; }
.auth-card-links a:hover { text-decoration: underline; }
.auth-card-active {
    outline: 3px solid #f59e0b;
    outline-offset: 3px;
}

/* Collapsible form on each card */
.auth-collapse {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows .3s ease;
}
.auth-collapse > .auth-collapse-inner { overflow: hidden; min-height: 0; }
.auth-card-open .auth-collapse { grid-template-rows: 1fr; }

/* Chevron affordance */
.auth-chevron {
    margin-left: auto;
    color: #94a3b8;
    font-size: 1.1rem;
    transition: transform .3s ease, color .2s ease;
}
.auth-card:hover .auth-chevron { color: #0ea5e9; }
.auth-card-open .auth-chevron { transform: rotate(180deg); color: #0ea5e9; }

/* Card header */
.auth-card-head {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #eef2f7;
}
.auth-icon {
    width: 3rem;
    height: 3rem;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: .9rem;
    font-size: 1.35rem;
    color: #fff;
}
.auth-card-admin .auth-icon { background: linear-gradient(135deg, #2563eb, #0ea5e9); }
.auth-card-user .auth-icon { background: linear-gradient(135deg, #22c55e, #059669); }
.auth-card-register .auth-icon { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.auth-card-head h5 { margin: 0; font-weight: 700; color: #0f172a; }
.auth-card-head p { margin: 0; font-size: .8rem; color: #64748b; }

/* Role feature ticks */
.auth-features {
    list-style: none;
    padding: 0;
    margin: 0 0 1.1rem;
}
.auth-features li { font-size: .82rem; color: #475569; margin-bottom: .35rem; }
.auth-features li i { color: #059669; margin-right: .45rem; }

/* Form controls */
.auth-card .form-label { font-size: .82rem; font-weight: 600; color: #334155; }
.auth-card .form-control, .auth-card .form-select {
    border-radius: .65rem;
    padding: .55rem .8rem;
    border-color: #e2e8f0;
    font-size: .92rem;
    box-shadow: none;
}
.auth-card .form-control:focus, .auth-card .form-select:focus {
    border-color: #0ea5e9;
    box-shadow: 0 0 0 .2rem rgba(14, 165, 233, .14);
}
.auth-card .input-group { border-radius: .65rem; overflow: hidden; }
.auth-card .input-group-text {
    background: #f1f5f9;
    border-color: #e2e8f0;
    color: #64748b;
}

/* Action buttons */
.btn-admin, .btn-user, .btn-register {
    border: 0;
    color: #fff;
    font-weight: 600;
    border-radius: .65rem;
    box-shadow: 0 8px 20px rgba(2, 6, 23, .18);
    transition: filter .15s ease, transform .15s ease, box-shadow .15s ease;
}
.btn-admin { background: linear-gradient(135deg, #2563eb, #0ea5e9); }
.btn-user { background: linear-gradient(135deg, #22c55e, #059669); }
.btn-register { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.btn-admin:hover, .btn-user:hover, .btn-register:hover {
    color: #fff;
    filter: brightness(1.07);
    transform: translateY(-1px);
}

.auth-footer { color: #94a3b8; font-size: .85rem; }

.btn-auth-home {
    border: 1px solid rgba(148, 163, 184, .45);
    color: #cbd5e1;
    background: transparent;
    border-radius: .65rem;
    font-weight: 600;
    padding: .55rem 1.4rem;
    transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.btn-auth-home:hover {
    color: #fff;
    border-color: #94a3b8;
    background: rgba(148, 163, 184, .12);
}

/* Keep tall auth forms (register) scrollable on short screens */
@media (max-height: 760px) {
    .auth-wrapper {
        display: block;
        overflow-y: auto;
        padding: 2rem 1rem;
    }
    .auth-wrapper::before,
    .auth-wrapper::after { display: none; }
    .auth-brand { margin-bottom: 1.5rem; }
    .auth-card { margin: 0 auto; }
}

/* ---------------------------------------------------------------
   Responsive sidebar
   --------------------------------------------------------------- */
@media (max-width: 991.98px) {
    .app-sidebar { margin-left: calc(-1 * var(--sidebar-width)); position: fixed; }
    .app-sidebar.open { margin-left: 0; box-shadow: 0 0 40px rgba(0,0,0,.3); }
}
@media (max-width: 575.98px) {
    .app-content { padding: 1rem; }
    .stat-card .stat-value { font-size: 1.4rem; }
    .app-navbar { padding: .6rem .75rem; }
    .template-preview { height: 190px; }
    .items-table { font-size: .82rem; }
}

/* Animations */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fadeInUp .4s ease both; }

@keyframes pulse-badge {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, .5); }
    50%      { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

/* Scroll-reveal */
.reveal { opacity: 0; transform: translateY(22px); transition: opacity .5s ease, transform .5s ease; }
.reveal.visible { opacity: 1; transform: translateY(0); }
.reveal-delay-1 { transition-delay: .08s; }
.reveal-delay-2 { transition-delay: .16s; }
.reveal-delay-3 { transition-delay: .24s; }

/* Animated counters */
.stat-value.counter { font-variant-numeric: tabular-nums; }

/* Card hover micro-interactions */
.card-lift { transition: transform .18s ease, box-shadow .18s ease; }
.card-lift:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px rgba(15, 23, 42, .14);
}

/* Staggered list fade for tables */
@keyframes rowIn {
    from { opacity: 0; transform: translateX(-8px); }
    to   { opacity: 1; transform: translateX(0); }
}
.stagger-rows tbody tr { animation: rowIn .35s ease both; }
.stagger-rows tbody tr:nth-child(1) { animation-delay: .02s; }
.stagger-rows tbody tr:nth-child(2) { animation-delay: .06s; }
.stagger-rows tbody tr:nth-child(3) { animation-delay: .10s; }
.stagger-rows tbody tr:nth-child(4) { animation-delay: .14s; }
.stagger-rows tbody tr:nth-child(5) { animation-delay: .18s; }
.stagger-rows tbody tr:nth-child(6) { animation-delay: .22s; }
.stagger-rows tbody tr:nth-child(7) { animation-delay: .26s; }
.stagger-rows tbody tr:nth-child(8) { animation-delay: .30s; }

@media (prefers-reduced-motion: reduce) {
    .reveal, .animate-in, .stagger-rows tbody tr,
    .auth-card, .auth-card-split { animation: none !important; transition: none !important; }
}

/* =====================================================================
   Landing page (index.html)
   ===================================================================== */
.landing-body {
    background: #f8fafc;
    color: #0f172a;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* Navbar */
.landing-nav {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: rgba(2, 6, 23, .92);
    backdrop-filter: blur(8px);
    padding: .7rem 0;
}
.landing-brand {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    text-decoration: none;
    color: #f8fafc;
}
.landing-brand strong { display: block; line-height: 1.1; font-size: 1rem; }
.landing-brand small { color: #94a3b8; font-size: .72rem; letter-spacing: 1px; text-transform: uppercase; }
.landing-brand-icon {
    width: 2.3rem;
    height: 2.3rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: .7rem;
    font-size: 1.25rem;
    color: #fff;
    background: linear-gradient(135deg, #0ea5e9, #2563eb);
    box-shadow: 0 6px 18px rgba(14, 165, 233, .4);
}
.landing-nav-links a {
    color: #cbd5e1;
    text-decoration: none;
    font-size: .9rem;
    margin: 0 .85rem;
    transition: color .15s ease;
}
.landing-nav-links a:hover { color: #38bdf8; }

/* Buttons */
.btn-landing-primary {
    background: linear-gradient(135deg, #0ea5e9, #2563eb);
    color: #fff;
    border: 0;
    font-weight: 600;
    border-radius: .6rem;
    box-shadow: 0 8px 20px rgba(37, 99, 235, .35);
    transition: filter .15s ease, transform .15s ease;
}
.btn-landing-primary:hover { color: #fff; filter: brightness(1.08); transform: translateY(-1px); }
.btn-landing-outline {
    background: transparent;
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, .55);
    font-weight: 600;
    border-radius: .6rem;
    transition: all .15s ease;
}
.btn-landing-outline:hover {
    color: #fff;
    background: rgba(56, 189, 248, .15);
    border-color: #38bdf8;
}

/* Hero */
.landing-hero {
    position: relative;
    overflow: hidden;
    background: #0f172a;
    padding: 5.5rem 0 5rem;
}
.landing-hero::before {
    content: '';
    position: absolute;
    width: 560px;
    height: 560px;
    border-radius: 50%;
    background: rgba(37, 99, 235, .30);
    filter: blur(100px);
    top: -180px;
    left: -160px;
}
.landing-hero::after {
    content: '';
    position: absolute;
    width: 480px;
    height: 480px;
    border-radius: 50%;
    background: rgba(124, 58, 237, .25);
    filter: blur(100px);
    bottom: -170px;
    right: -140px;
}
.landing-hero .container { position: relative; z-index: 1; }
.landing-eyebrow {
    display: inline-block;
    color: #38bdf8;
    font-weight: 600;
    font-size: .8rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-bottom: .8rem;
}
.landing-title {
    color: #f8fafc;
    font-weight: 800;
    font-size: clamp(2.1rem, 4.5vw, 3.4rem);
    line-height: 1.15;
}
.text-gradient {
    background: linear-gradient(90deg, #38bdf8, #a78bfa);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.landing-lead { color: #cbd5e1; font-size: 1.05rem; margin-top: 1rem; max-width: 560px; }
.landing-stats { display: flex; gap: 1.8rem; }
.landing-stats b { display: block; color: #f8fafc; font-size: 1rem; }
.landing-stats span { color: #94a3b8; font-size: .8rem; }

/* Hero visual: mock invoice */
.landing-hero-visual { position: relative; }
.invoice-mock {
    position: relative;
    background: #fff;
    border-radius: 1.1rem;
    box-shadow: 0 30px 80px rgba(2, 6, 23, .6);
    padding: 1.4rem;
    max-width: 440px;
    margin-left: auto;
    transform: perspective(900px) rotateY(-6deg);
}
.mock-head {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding-bottom: .9rem;
    border-bottom: 2px solid #1e293b;
    margin-bottom: .9rem;
}
.mock-logo { width: 46px; height: 46px; border-radius: 8px; object-fit: cover; }
.mock-head h5 { margin: 0; font-weight: 800; font-size: 1rem; }
.mock-head small { color: #64748b; font-size: .72rem; }
.mock-row {
    display: flex;
    justify-content: space-between;
    font-size: .8rem;
    padding: .18rem 0;
}
.mock-row span { color: #64748b; }
.mock-row b { color: #0f172a; }
.mock-table {
    margin-top: .8rem;
    border-top: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
}
.mt-head, .mt-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    font-size: .78rem;
    padding: .3rem .4rem;
}
.mt-head { background: #f1f5f9; font-weight: 700; }
.mt-total {
    display: flex;
    justify-content: space-between;
    padding: .5rem .4rem;
    font-size: .85rem;
}
.mt-total b { color: #0ea5e9; font-size: 1rem; }
.mock-seal {
    position: absolute;
    right: 1.1rem;
    bottom: 4.4rem;
    width: 96px;
    opacity: .9;
    pointer-events: none;
}
.landing-hero-badge {
    position: absolute;
    left: -1.2rem;
    bottom: -1.1rem;
    background: #fff;
    color: #059669;
    font-weight: 600;
    font-size: .85rem;
    padding: .6rem 1rem;
    border-radius: .7rem;
    box-shadow: 0 14px 40px rgba(2, 6, 23, .35);
}

/* Generic sections */
.landing-section { padding: 5rem 0; }
.landing-section-head { text-align: center; max-width: 640px; margin: 0 auto 3rem; }
.landing-section-head h2 { font-weight: 800; }
.landing-section-head p { color: #64748b; }
.landing-h2 { font-weight: 800; }
.landing-muted { color: #64748b; }

/* Login cards on landing */
.landing-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 1.1rem;
    box-shadow: 0 18px 50px rgba(15, 23, 42, .08);
    padding: 1.7rem;
    border-top: 5px solid transparent;
    transition: transform .2s ease, box-shadow .2s ease;
}
.landing-card:hover { transform: translateY(-5px); box-shadow: 0 26px 60px rgba(15, 23, 42, .14); }
.landing-card-admin { border-top-color: #2563eb; }
.landing-card-user { border-top-color: #059669; }
.landing-card-register { border-top-color: #7c3aed; }
.landing-card-head h5 { font-weight: 700; margin: .9rem 0 .15rem; }
.landing-card-head p { color: #64748b; font-size: .84rem; }
.landing-card-icon {
    width: 3rem;
    height: 3rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: .9rem;
    font-size: 1.4rem;
    color: #fff;
}
.landing-card-admin .landing-card-icon { background: linear-gradient(135deg, #2563eb, #0ea5e9); }
.landing-card-user .landing-card-icon { background: linear-gradient(135deg, #22c55e, #059669); }
.landing-card-register .landing-card-icon { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.landing-check { list-style: none; padding: 0; margin: 0 0 1.2rem; }
.landing-check li { font-size: .85rem; color: #475569; margin-bottom: .4rem; }
.landing-check li i { color: #059669; margin-right: .45rem; }
.landing-btn-admin {
    background: linear-gradient(135deg, #2563eb, #0ea5e9);
    color: #fff; border: 0; font-weight: 600; border-radius: .6rem;
    padding: .6rem .9rem;
}
.landing-btn-admin:hover { color: #fff; filter: brightness(1.08); }
.landing-btn-user {
    background: linear-gradient(135deg, #22c55e, #059669);
    color: #fff; border: 0; font-weight: 600; border-radius: .6rem;
    padding: .6rem .9rem;
}
.landing-btn-user:hover { color: #fff; filter: brightness(1.08); }
.landing-btn-register {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: #fff; border: 0; font-weight: 600; border-radius: .6rem;
    padding: .6rem .9rem;
}
.landing-btn-register:hover { color: #fff; filter: brightness(1.08); }

/* Feature chips (section 3 visual) */
.landing-features { background: #fff; }
.landing-feature-visual {
    background: #f1f5f9;
    border-radius: 1.2rem;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}
.feature-chip {
    display: flex;
    align-items: center;
    gap: .9rem;
    background: #fff;
    border-radius: .9rem;
    padding: .95rem 1.1rem;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .08);
}
.feature-chip-icon {
    width: 2.7rem;
    height: 2.7rem;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: .8rem;
    font-size: 1.25rem;
    color: #fff;
    background: linear-gradient(135deg, #0ea5e9, #2563eb);
}
.feature-chip b { display: block; font-size: .95rem; }
.feature-chip small { color: #64748b; }
.landing-feature-list li { font-size: .95rem; margin-bottom: .55rem; }

/* Process steps (section 4) */
.landing-process { background: #f1f5f9; }
.landing-step {
    position: relative;
    background: #fff;
    border-radius: 1.1rem;
    padding: 1.8rem 1.4rem 1.4rem;
    height: 100%;
    box-shadow: 0 12px 36px rgba(15, 23, 42, .07);
    transition: transform .2s ease;
}
.landing-step:hover { transform: translateY(-4px); }
.landing-step-num {
    position: absolute;
    top: -14px;
    left: 1.2rem;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #0ea5e9);
    color: #fff;
    font-weight: 700;
    font-size: .9rem;
    box-shadow: 0 6px 16px rgba(37, 99, 235, .4);
}
.landing-step-icon { font-size: 1.6rem; color: #2563eb; }
.landing-step h6 { font-weight: 700; margin: .7rem 0 .35rem; }
.landing-step p { color: #64748b; font-size: .87rem; margin: 0; }

/* Footer */
.landing-footer {
    background: #0f172a;
    color: #94a3b8;
    padding: 3.5rem 0 0;
}
.landing-footer-title {
    color: #f8fafc;
    font-weight: 700;
    font-size: .85rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 1rem;
}
.landing-footer a {
    display: block;
    color: #94a3b8;
    text-decoration: none;
    font-size: .9rem;
    margin-bottom: .5rem;
    transition: color .15s ease;
}
.landing-footer a:hover { color: #38bdf8; }
.landing-footer p { font-size: .9rem; }
.landing-footer-bottom {
    margin-top: 2.5rem;
    padding: 1.2rem 0;
    border-top: 1px solid rgba(148, 163, 184, .2);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: .5rem;
    font-size: .8rem;
}
.landing-version { color: #64748b; }

@media (max-width: 991.98px) {
    .invoice-mock { margin: 0 auto; }
    .landing-hero-badge { left: 50%; transform: translateX(-50%); }
    .landing-stats { flex-wrap: wrap; }
}

/* Mobile sidebar backdrop (app pages) */
@media (max-width: 991.98px) {
    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(2, 6, 23, .55);
        z-index: 1035;
        opacity: 0;
        visibility: hidden;
        transition: opacity .25s ease, visibility .25s ease;
    }
    .sidebar-backdrop.show { opacity: 1; visibility: visible; }
}

/* Small phones: landing page */
@media (max-width: 575.98px) {
    .landing-nav { padding: .55rem 0; }
    .landing-nav .container { flex-wrap: wrap; gap: .5rem; }
    .landing-brand-icon { width: 2rem; height: 2rem; font-size: 1.05rem; }
    .landing-brand strong { font-size: .9rem; }
    .landing-brand small { display: none; }
    .landing-nav .btn { padding: .35rem .65rem; font-size: .8rem; }
    .landing-hero { padding: 3.5rem 0 3.2rem; }
    .landing-title { font-size: 1.9rem; }
    .landing-lead { font-size: .98rem; }
    .landing-section { padding: 3.5rem 0; }
    .landing-hero-badge { bottom: -1rem; font-size: .78rem; white-space: nowrap; }
    .invoice-mock { max-width: 100%; transform: none; }
    .mock-seal { width: 72px; right: .8rem; bottom: 4rem; }
    .landing-footer-bottom { flex-direction: column; text-align: center; }
}

/* ---------------------------------------------------------------
   Demo template picker (Custom Made)
   --------------------------------------------------------------- */
.template-picker-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 1.25rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: .8rem;
    box-shadow: 0 10px 26px rgba(15, 23, 42, .06);
}
.template-picker-title {
    display: flex;
    align-items: center;
    gap: .9rem;
    min-width: 0;
}
.template-picker-title h4 {
    font-weight: 700;
    color: #0f172a;
}
.template-picker-icon {
    width: 2.8rem;
    height: 2.8rem;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: .75rem;
    color: #fff;
    font-size: 1.3rem;
    background: linear-gradient(135deg, #0ea5e9, #2563eb);
    box-shadow: 0 10px 22px rgba(14, 165, 233, .28);
}
.template-picker-grid > [class*="col-"] {
    display: flex;
}
.template-card {
    display: flex;
    flex-direction: column;
    gap: .85rem;
    width: 100%;
    min-height: 100%;
    padding: .85rem;
    border: 1px solid #dbe3ee;
    border-radius: .75rem;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 10px 26px rgba(15, 23, 42, .07);
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease, background .15s ease;
}
.template-card:hover {
    border-color: #0ea5e9;
    box-shadow: 0 16px 36px rgba(15, 23, 42, .12);
    transform: translateY(-3px);
}
.template-card-selected {
    border-color: #0ea5e9 !important;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, .16), 0 16px 36px rgba(15, 23, 42, .10);
    background: #f8fcff;
}
.template-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
    width: 100%;
}
.template-preview-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #1d4ed8;
    flex-shrink: 0;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.template-preview-btn:hover {
    background: #0ea5e9;
    border-color: #0ea5e9;
    color: #fff;
}
.template-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .35rem .65rem;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #475569;
    font-size: .78rem;
    font-weight: 700;
    line-height: 1;
}
.template-chip-active {
    border-color: #0ea5e9;
    background: #e0f2fe;
    color: #0369a1;
}
.template-swatch {
    display: block;
    width: 100%;
    height: 34px;
    border-radius: .4rem;
    border: 1px solid rgba(0,0,0,.12);
}
.template-name {
    display: block;
    font-size: .98rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
}
.template-card-selected .template-name { color: var(--accent); }

/* Template picker page preview cards */
.template-pick-card {
    color: inherit;
    text-decoration: none;
}
.template-pick-card:hover { color: inherit; }
.template-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 4 / 3;
    min-height: 225px;
    border-radius: .55rem;
    border: 1px solid #d8e0eb;
    overflow: hidden;
    padding: 14px;
    background:
        linear-gradient(135deg, rgba(14, 165, 233, .08), rgba(15, 23, 42, .03)),
        #eef2f7;
}
.template-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: .35rem;
    box-shadow: 0 6px 18px rgba(15, 23, 42, .18);
    background: #fff;
}
.template-card-body {
    width: 100%;
    min-height: 3.1rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: .2rem;
}
.template-meta {
    display: block;
    color: #64748b;
    font-size: .82rem;
    line-height: 1.25;
}
.template-action {
    width: 100%;
    min-height: 2.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .2rem;
    margin-top: auto;
    padding: .45rem .75rem;
    border-radius: .55rem;
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: .88rem;
    font-weight: 700;
    text-align: center;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.template-card:hover .template-action,
.template-card-selected .template-action {
    background: #0ea5e9;
    border-color: #0ea5e9;
    color: #fff;
}
/* Side-by-side "Use this template" + Preview buttons on template cards */
.template-card-actions {
    width: 100%;
    margin-top: auto;
    display: flex;
    align-items: stretch;
    gap: .5rem;
}
.template-card-actions .template-action-link {
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.template-card-actions .template-preview-btn {
    width: auto;
    height: auto;
    border-radius: .375rem;
    flex-shrink: 0;
    white-space: nowrap;
}
.template-picker-note {
    display: flex;
    align-items: flex-start;
    gap: .45rem;
    color: #64748b;
    font-size: .88rem;
    line-height: 1.5;
    padding: .85rem 1rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: .7rem;
}
.template-picker-note i {
    color: #0ea5e9;
    margin-top: .1rem;
}
.template-picker-note a {
    color: #2563eb;
    font-weight: 600;
    text-decoration: none;
}
.template-picker-note a:hover { text-decoration: underline; }

@media (max-width: 767.98px) {
    .template-picker-head {
        align-items: flex-start;
        flex-direction: column;
    }
    .template-picker-head .btn {
        width: 100%;
        justify-content: center;
    }
    .template-preview {
        height: auto;
        min-height: 210px;
    }
}

/* Line items column customization dropdown */
.column-menu { min-width: 210px; }
.column-menu .form-check { padding-left: 1.9rem; }
.column-menu .form-check-input { margin-top: .28rem; }

/* ---------------------------------------------------------------
   Bill entry form themed to match the selected invoice template.
   The CSS variables are set on #billEntryRoot from the selected
   template's palette (server-rendered, updated by JS on sync).
   --------------------------------------------------------------- */
#billEntryRoot.bill-entry-themed .card-header {
    background: var(--tp-primary, #1b3a6b);
    border-color: transparent;
    color: #fff;
}
#billEntryRoot.bill-entry-themed .company-header,
#billEntryRoot.bill-entry-themed .selected-template-card {
    border-left: 4px solid var(--tp-accent, #2f6fb3);
}
#billEntryRoot.bill-entry-themed .items-table thead th {
    background: var(--tp-primary, #1b3a6b);
    color: #fff;
}
#billEntryRoot.bill-entry-themed .grand-total-row td {
    color: var(--tp-accent, #2f6fb3);
}
#billEntryRoot.bill-entry-themed .btn-primary {
    background-color: var(--tp-primary, #1b3a6b);
    border-color: var(--tp-primary, #1b3a6b);
}
#billEntryRoot.bill-entry-themed .btn-primary:hover,
#billEntryRoot.bill-entry-themed .btn-primary:focus,
#billEntryRoot.bill-entry-themed .btn-primary:active {
    background-color: var(--tp-accent, #2f6fb3);
    border-color: var(--tp-accent, #2f6fb3);
}

/* ===================================================================
   Table Theme – theme-menu swatches + table variant classes
   =================================================================== */
.theme-menu .theme-swatch {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 3px;
    vertical-align: middle;
    margin-right: 6px;
    border: 1px solid rgba(0,0,0,.15);
}
.theme-swatch.theme-default { background: #f8f9fa; }
.theme-swatch.theme-simple  { background: #fff; }
.theme-swatch.theme-border  { background: linear-gradient(135deg, #dee2e6 50%, #fff 50%); }
.theme-swatch.theme-modern  { background: linear-gradient(135deg, #0d6efd 50%, #fff 50%); }
.theme-swatch.theme-minimal { background: #f8f9fa; border-style: dashed; }

/* Default (Bootstrap default – no extra overrides needed) */
.items-table.theme-default {}

/* Simple – light rows, no outer border, subtle hover */
.items-table.theme-simple {
    border: none;
}
.items-table.theme-simple thead th {
    background-color: #fff;
    border-bottom: 2px solid #dee2e6;
}
.items-table.theme-simple td,
.items-table.theme-simple th {
    border-color: #f0f0f0;
}
.items-table.theme-simple tbody tr:hover {
    background-color: #f8f9fa;
}

/* Border – pronounced borders, striped rows */
.items-table.theme-border {
    border: 2px solid #495057;
}
.items-table.theme-border td,
.items-table.theme-border th {
    border: 1.5px solid #495057;
}
.items-table.theme-border thead th {
    background-color: #343a40;
    color: #fff;
    border-color: #343a40;
}
.items-table.theme-border tbody tr:nth-child(even) {
    background-color: #f1f3f5;
}

/* Modern – primary-blue header, rounded-ish feel */
.items-table.theme-modern {
    border: none;
    border-collapse: separate;
    border-spacing: 0;
}
.items-table.theme-modern thead th {
    background-color: #0d6efd;
    color: #fff;
    border: none;
    font-weight: 600;
}
.items-table.theme-modern td {
    border: none;
    border-bottom: 1px solid #e9ecef;
}
.items-table.theme-modern tbody tr:hover {
    background-color: #e7f1ff;
}

/* Minimal – dashed borders, muted tones */
.items-table.theme-minimal {
    border: 1px dashed #ced4da;
}
.items-table.theme-minimal td,
.items-table.theme-minimal th {
    border: 1px dashed #dee2e6;
}
.items-table.theme-minimal thead th {
    background-color: #f8f9fa;
    font-weight: 600;
    text-transform: uppercase;
    font-size: .8rem;
    letter-spacing: .5px;
}
.items-table.theme-minimal tbody tr:hover {
    background-color: #f8f9fa;
}

/* ===================================================================
   Table Theme – totals section styles (bill-entry & invoice detail)
   The totals table also receives the theme-* class so that these
   descendant selectors match.
   =================================================================== */
.theme-simple .grand-total-row td {
    border-top: 2px solid #dee2e6;
}
.theme-border .grand-total-row td {
    border-top: 2px solid #495057;
}
.theme-modern .grand-total-row td {
    border-top: 2px solid #0d6efd;
}
.theme-minimal .grand-total-row td {
    border-top: 2px dashed #ced4da;
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* ===================================================================
   Table Theme – bill-entry page overrides
   #billEntryRoot.bill-entry-themed sets header background via CSS
   custom properties (template theme).  When a table theme is active
   the theme's own header colours must win.  Same specificity (1-2-2)
   but later source order ensures these override the bill-entry-themed
   rules above.
   =================================================================== */
#billEntryRoot .items-table.theme-simple thead th {
    background-color: #fff;
    color: #212529;
    border-bottom: 2px solid #dee2e6;
}
#billEntryRoot .items-table.theme-border thead th {
    background-color: #343a40;
    color: #fff;
}
#billEntryRoot .items-table.theme-modern thead th {
    background-color: #0d6efd;
    color: #fff;
    border: none;
    font-weight: 600;
}
#billEntryRoot .items-table.theme-minimal thead th {
    background-color: #f8f9fa;
    color: #495569;
    font-weight: 600;
    text-transform: uppercase;
    font-size: .8rem;
    letter-spacing: .5px;
}
#billEntryRoot .items-table.theme-simple td,
#billEntryRoot .items-table.theme-simple th {
    border-color: #f0f0f0;
}
#billEntryRoot .items-table.theme-border td,
#billEntryRoot .items-table.theme-border th {
    border: 1.5px solid #495057;
}
#billEntryRoot .items-table.theme-border tbody tr:nth-child(even) {
    background-color: #f1f3f5;
}
#billEntryRoot .items-table.theme-modern td {
    border: none;
    border-bottom: 1px solid #e9ecef;
}
#billEntryRoot .items-table.theme-modern tbody tr:hover {
    background-color: #e7f1ff;
}
#billEntryRoot .items-table.theme-minimal td,
#billEntryRoot .items-table.theme-minimal th {
    border: 1px dashed #dee2e6;
}
#billEntryRoot .items-table.theme-minimal tbody tr:hover {
    background-color: #f8f9fa;
}
/* Totals overrides inside bill-entry */
#billEntryRoot .theme-simple .grand-total-row td {
    border-top: 2px solid #dee2e6;
}
#billEntryRoot .theme-border .grand-total-row td {
    border-top: 2px solid #495057;
}
#billEntryRoot .theme-modern .grand-total-row td {
    border-top: 2px solid #0d6efd;
}
#billEntryRoot .theme-minimal .grand-total-row td {
    border-top: 2px dashed #ced4da;
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* ===================================================================
   Column Drag & Drop Reordering
   =================================================================== */
.column-drag-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 500px;
}

.column-drag-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    cursor: default;
    transition: box-shadow .15s, border-color .15s, background .15s;
    user-select: none;
}

.column-drag-item:hover {
    border-color: #adb5bd;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.column-drag-item.dragging {
    opacity: .5;
    border-color: #0d6efd;
    background: #e7f1ff;
}

.column-drag-item.drag-over-top {
    border-color: #0d6efd;
    background: #f0f7ff;
    box-shadow: inset 0 2px 0 -1px #0d6efd;
}

.column-drag-item.drag-over-bottom {
    border-color: #0d6efd;
    background: #f0f7ff;
    box-shadow: inset 0 -2px 0 -1px #0d6efd;
}

.drag-handle {
    cursor: grab;
    color: #6c757d;
    font-size: 1.1rem;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 3px;
    transition: color .15s, background .15s;
}

.drag-handle:hover {
    color: #333;
    background: #e9ecef;
}

.drag-handle:active {
    cursor: grabbing;
}

/* Drag the live table column headers to reorder the items table */
.items-table .col-drag-th {
    cursor: grab;
    user-select: none;
    white-space: nowrap;
}
.items-table .col-drag-th.th-dragging {
    opacity: .5;
    background: #e7f1ff;
}
.items-table .col-drag-th.th-drop-before {
    box-shadow: inset 3px 0 0 0 #0d6efd;
}
.items-table .col-drag-th.th-drop-after {
    box-shadow: inset -3px 0 0 0 #0d6efd;
}

/* ===================================================================
   Calculation Configuration Panel
   =================================================================== */
#calcConfigPanel {
    border: 1px solid #dee2e6;
    max-width: 600px;
}

.calc-formula-row .form-control-sm {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: .85rem;
}

.calc-formula-row code {
    background: #f1f3f5;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: .82rem;
}

/* ===================================================================
   Mobile Responsive Improvements
   =================================================================== */

/* Touch-friendly tap targets (44px minimum) */
@media (pointer: coarse) {
    .btn { min-height: 44px; }
    .page-link { min-height: 44px; display: flex; align-items: center; }
    .dropdown-item { padding: .65rem 1rem; }
    .nav-item { padding: .75rem 1rem; }
}

/* Invoice list: hide less important columns on tablet */
@media (max-width: 991.98px) {
    .invoice-list-hide-md { display: none !important; }
}

/* Invoice list: card layout on mobile */
@media (max-width: 767.98px) {
    .invoice-mobile-card {
        display: block !important;
    }
    .invoice-mobile-card .card-body {
        padding: .85rem;
    }
    .invoice-mobile-card .card-body + .card-body {
        border-top: 1px solid #eef1f6;
    }
    .invoice-desktop-row { display: none !important; }
}

/* Bill entry items table on mobile */
@media (max-width: 575.98px) {
    .items-table input, .items-table select {
        min-width: 70px;
        font-size: .82rem;
        padding: .3rem .4rem;
    }
    .items-table .row-total { font-size: .82rem; }
}

/* Confirm delete modal */
#confirmDeleteModal .modal-content {
    border-radius: .85rem;
    border: 0;
    box-shadow: 0 16px 48px rgba(15, 23, 42, .18);
}
#confirmDeleteModal .modal-header {
    padding-bottom: 0;
}
#confirmDeleteModal .modal-body {
    color: #475569;
}

/* ===================================================================
   Invoice Setup: smooth reveal of the Form Settings section
   =================================================================== */
html {
    scroll-behavior: smooth;
}
#formSettings {
    scroll-margin-top: 90px;
}
.flash-highlight {
    animation: setupFlashHighlight .9s ease-out;
}
@keyframes setupFlashHighlight {
    0%   { box-shadow: 0 0 0 3px rgba(13, 110, 253, .35); }
    100% { box-shadow: 0 0 0 0 rgba(13, 110, 253, 0); }
}

/* ===================================================================
   Professional HTML Invoice (Preview / Print)
   =================================================================== */
.invoice-preview-page {
    max-width: 900px;
    margin: 0 auto;
}

.invoice-sheet {
    --c-primary: #1b3a6b;
    --c-accent: #2f6fb3;
    --c-light: #f4f8ff;
    --c-secondary: #e8efff;
    width: 210mm;
    max-width: 100%;
    min-height: 297mm;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    background: #fff;
    color: #1f2937;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    border: 1px solid #e5e7eb;
    border-radius: .55rem;
    box-shadow: 0 12px 32px rgba(15, 23, 42, .10);
    padding: var(--sheet-top, 48px) 34px 28px;
    position: relative;
    overflow: hidden;
}

.invoice-band {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 10px;
    background: var(--c-primary);
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: flex-start;
    padding-bottom: 18px;
    margin-top: 6px;
    border-bottom: 2px solid var(--c-primary);
}

.invoice-company {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    flex: 1;
    min-width: 0;
}

.invoice-logo {
    max-height: 64px;
    max-width: 96px;
    object-fit: contain;
    border-radius: .35rem;
}

.invoice-company-name {
    font-size: 21px;
    font-weight: 700;
    color: var(--c-primary);
    line-height: 1.2;
}

.invoice-company-addr {
    font-size: 12px;
    color: #505d70;
    margin-top: 2px;
    line-height: 1.45;
}

.invoice-company-contact {
    font-size: 12px;
    color: #505d70;
    margin-top: 5px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
}

.invoice-title-block {
    text-align: right;
    flex-shrink: 0;
}

.invoice-title {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--c-primary);
}

.invoice-title-no,
.invoice-title-date {
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    margin-top: 2px;
}

.invoice-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin: 22px 0;
}

.invoice-details-col {
    border: 1px solid #dbe1ea;
    border-radius: .4rem;
    overflow: hidden;
}

.invoice-details-head {
    background: var(--c-light);
    color: var(--c-primary);
    font-size: 13px;
    font-weight: 700;
    padding: 7px 14px;
    border-bottom: 1px solid var(--c-secondary);
}

.invoice-details-body {
    padding: 10px 14px;
    font-size: 13.5px;
    line-height: 1.55;
}

.invoice-details-body .lbl {
    color: #64748b;
    font-weight: 600;
}

/* When the Customer Details box is hidden, keep Invoice Details but drop
   the surrounding box design and align fields neatly in a grid. */
.invoice-details--compact {
    grid-template-columns: 1fr;
    gap: 0;
}

.invoice-details--compact .invoice-details-col {
    border: none;
    border-radius: 0;
    background: transparent;
}

.invoice-details--compact .invoice-details-head {
    display: none;
}

.invoice-details--compact .invoice-details-body {
    padding: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: repeat(3, auto);
    grid-auto-flow: column;
    gap: 8px 40px;
}

.invoice-details--compact .invoice-details-body > div {
    display: flex;
    align-items: baseline;
    min-width: 0;
}

.invoice-details--compact .invoice-details-body .lbl {
    flex: 0 0 130px;
}

/* Line items table */
.invoice-items {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    page-break-inside: auto;
}

.invoice-items thead th {
    background: var(--c-primary);
    color: #fff;
    font-weight: 700;
    text-align: left;
    padding: 9px 10px;
    border: 1px solid var(--c-primary);
}

.invoice-items tbody td {
    padding: 7px 10px;
    border: 1px solid #dbe1ea;
    vertical-align: top;
    line-height: 1.4;
    word-break: break-word;
}

.invoice-items tbody tr:nth-child(even) td {
    background: var(--c-light);
}

.invoice-items tbody tr {
    page-break-inside: avoid;
}

.invoice-items .align-end {
    text-align: right;
}

.invoice-items tfoot td {
    padding: 8px 10px;
    border: 1px solid #dbe1ea;
}

.invoice-items .total-row td {
    background: #f8fafc;
    font-weight: 600;
}

.invoice-items .grand-total-row td {
    background: var(--c-primary);
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    border-color: var(--c-primary);
}

/* Payment status badges */
.pay-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    padding: 0.3em 0.7em;
    border-radius: 999px;
    vertical-align: middle;
}
.pay-paid,
.pay-method-upi,
.pay-method-bank {
    background: #e7f6ec;
    color: #198754;
    border: 1px solid #b7e2c5;
}
.pay-partial {
    background: #fff7e6;
    color: #b45309;
    border: 1px solid #f3d7a4;
}
.pay-unpaid {
    background: #fdeaea;
    color: #b91c1c;
    border: 1px solid #f3b9b9;
}
.pay-overdue {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #f5c6c6;
}
.pay-method-cash {
    background: #eef2ff;
    color: #4f46e5;
    border: 1px solid #c7d2fe;
}
.pay-method-card {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}
.pay-method-other {
    background: #f4f4f5;
    color: #52525b;
    border: 1px solid #d4d4d8;
}

.invoice-items .grand-total-row .align-end {
    color: #fff;
}

.invoice-remarks {
    margin-top: 18px;
    font-size: 13px;
    color: #334155;
    line-height: 1.5;
}

.invoice-thanks {
    text-align: center;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 2px;
    color: var(--c-primary);
    margin: 24px 0 30px;
}

.invoice-signatures {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
}

.invoice-signatures .sig {
    font-size: 12px;
    color: #64748b;
    border-top: 1px solid #9ca3af;
    padding-top: 8px;
    width: 46%;
}

.invoice-signatures .sig-right {
    text-align: right;
}

.invoice-footer {
    margin-top: 26px;
    padding-top: 12px;
    border-top: 1px solid #e5e7eb;
    text-align: right;
    font-size: 12px;
    color: #9aa5b5;
}

.invoice-sheet.theme + .invoice-sheet.theme {
    margin-top: 32px;
}

.invoice-page-mark {
    margin-top: auto;
    padding-top: 12px;
    text-align: right;
    font-size: 11px;
    color: #9aa5b5;
}

/* Template page-background image (matches the generated PDF) */
.invoice-sheet > * {
    position: relative;
    z-index: 1;
}

.invoice-sheet.has-bg {
    background: transparent;
    border: 0;
}

.invoice-bg {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    pointer-events: none;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

/* Pin the footer to the bottom of the A4 sheet */
.invoice-footer {
    margin-top: auto;
}

/* ===================================================================
   Print styles – print ONLY the invoice sheet, hide the app UI.
   =================================================================== */
@media print {
    @page {
        size: A4;
        margin: 10mm;
    }

    html, body {
        background: #fff !important;
        height: auto !important;
        overflow: visible !important;
    }

    .app-sidebar,
    .app-navbar,
    .back-to-top,
    .no-print,
    .messages-area,
    .skip-link {
        display: none !important;
    }

    .app-wrapper,
    .app-main,
    .app-content {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
        width: auto !important;
        height: auto !important;
        overflow: visible !important;
    }

    .invoice-sheet {
        width: 100%;
        min-height: 0;
        margin: 0;
        padding: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        max-width: 100%;
        page-break-after: auto;
    }

    .invoice-sheet.theme + .invoice-sheet.theme {
        margin-top: 0;
        page-break-before: always;
    }

    /* Keep rows and headings from splitting awkwardly across pages */
    .invoice-header,
    .invoice-details,
    .invoice-items thead,
    .invoice-items tfoot,
    .invoice-remarks,
    .invoice-thanks,
    .invoice-signatures,
    .invoice-footer {
        page-break-inside: avoid;
    }
}
