/* ==========================================================================
   CSS Styling - Dhanam Jayam Engineering Billing System
   Contains: 1. Core design tokens & resetting
             2. Premium dark-glass Dashboard UI
             3. High-fidelity pixel-perfect Print Replica (@media print)
   ========================================================================== */

:root {
    /* Theme color palette - Premium Lite Theme */
    --bg-dark-900: #f1f5f9;        /* Soft slate/grey body background */
    --bg-dark-800: #ffffff;        /* Pure white sidebar, forms, and cards background */
    --bg-dark-700: #f8fafc;        /* Alternate card / input backgrounds */
    --bg-dark-600: #cbd5e1;        /* Inactive items / scrollbar thumbs */
    
    --primary-color: #0284c7;      /* Sky blue / primary accent */
    --primary-hover: #0369a1;
    --primary-glow: rgba(2, 132, 199, 0.1);
    
    --text-main: #0f172a;          /* Dark slate main text */
    --text-muted: #64748b;         /* Muted grey text */
    --text-dark: #0f172a;
    
    --border-color: rgba(15, 23, 42, 0.08); /* Soft slate border */
    --border-focus: rgba(2, 132, 199, 0.4);
    
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    --font-dashboard: 'Outfit', sans-serif;
    --font-invoice: 'Inter', 'Helvetica Neue', Arial, sans-serif;
    --transition-speed: 0.25s;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-dark-900);
    color: var(--text-main);
    font-family: var(--font-dashboard);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-dark-900);
}
::-webkit-scrollbar-thumb {
    background: var(--bg-dark-600);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* ==========================================================================
   1. Dashboard Shell Layout
   ========================================================================== */

.app-container {
    display: flex;
    min-height: 100vh;
    width: 100vw;
}

/* Sidebar Styling */
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, var(--bg-dark-800) 0%, var(--bg-dark-700) 100%);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
}

.sidebar-brand {
    padding: 0 24px 28px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
}

.brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #3b82f6 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 800;
    font-size: 1.1rem;
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

.brand-name {
    display: flex;
    flex-direction: column;
}

.brand-name span {
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
    color: var(--text-main);
}

.brand-name small {
    font-size: 0.7rem;
    color: var(--primary-color);
    font-weight: 600;
    letter-spacing: 1px;
}

.sidebar-nav {
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.nav-item {
    background: transparent;
    border: none;
    outline: none;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    color: var(--text-muted);
    font-family: var(--font-dashboard);
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    transition: all var(--transition-speed) ease;
}

.nav-item:hover {
    color: var(--text-main);
    background: rgba(15, 23, 42, 0.03);
}

.nav-item.active {
    color: var(--primary-color);
    font-weight: 600;
    background: linear-gradient(90deg, var(--primary-glow) 0%, rgba(2, 132, 199, 0.01) 100%);
    border-left: 3px solid var(--primary-color);
    padding-left: 13px; /* Offset for border */
}

.nav-item i {
    width: 20px;
    height: 20px;
}

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.profile-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--bg-dark-600);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    padding: 8px;
}

.profile-info {
    display: flex;
    flex-direction: column;
}

.profile-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}

.profile-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Main Content Wrapper */
.main-content {
    margin-left: 260px;
    flex-grow: 1;
    padding: 40px;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--bg-dark-900) 0%, var(--bg-dark-700) 100%);
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 36px;
}

.header-title h1 {
    font-size: 1.85rem;
    font-weight: 700;
    background: linear-gradient(90deg, var(--text-main) 0%, #334155 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-title p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 4px;
}

/* ==========================================================================
   2. Components & Buttons
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-dashboard);
    font-weight: 600;
    font-size: 0.9rem;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition-speed) ease;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 6px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(6, 182, 212, 0.3);
}

.btn-secondary {
    background: var(--bg-dark-700);
    color: var(--text-main);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-dark-600);
    border-color: rgba(255, 255, 255, 0.15);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.btn-text {
    background: transparent;
    color: var(--primary-color);
    padding: 4px 8px;
}

.btn-text:hover {
    color: var(--primary-hover);
    background: rgba(6, 182, 212, 0.08);
}

/* Panels */
.panel {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.04);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 14px;
}

.panel-header h2 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-main);
}

/* Tabs */
.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   3. Form Inputs
   ========================================================================== */

.input-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-grow: 1;
    width: 100%;
    margin-bottom: 16px;
}

.input-row .input-group {
    margin-bottom: 0;
}

label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="date"],
select,
textarea {
    width: 100%;
    background-color: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--bg-dark-600);
    color: var(--text-main);
    padding: 10px 14px;
    font-size: 0.9rem;
    font-family: var(--font-dashboard);
    border-radius: 8px;
    outline: none;
    transition: all var(--transition-speed) ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background-color: #ffffff;
}

.select-quick {
    max-width: 250px;
    font-size: 0.8rem;
    padding: 6px 10px;
}

.form-help-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Form Grids */
.form-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    align-items: start;
}

.form-column {
    display: flex;
    flex-direction: column;
}

.span-2 {
    grid-column: span 2;
}

/* ==========================================================================
   4. Tables (Form & Dashboard)
   ========================================================================== */

.table-responsive {
    overflow-x: auto;
    width: 100%;
}

.dashboard-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.dashboard-table th {
    padding: 12px 16px;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-color);
}

.dashboard-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.88rem;
    color: var(--text-main);
}

.dashboard-table tbody tr:hover {
    background-color: rgba(15, 23, 42, 0.02);
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 0 !important;
}

/* Items Form Table styling */
.items-form-table {
    width: 100%;
    border-collapse: collapse;
}

.items-form-table th {
    padding: 10px 8px;
    text-align: left;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-color);
}

.items-form-table td {
    padding: 8px 6px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.04);
}

.items-form-table input,
.items-form-table select {
    padding: 6px 10px;
    font-size: 0.85rem;
}

.btn-action-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-speed) ease;
}

.btn-action-icon:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.btn-action-icon.view:hover,
.btn-action-icon.edit:hover {
    color: var(--primary-color);
    background: var(--primary-glow);
}

.btn-action-icon.print:hover {
    color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

/* Search Box */
.search-box {
    position: relative;
    max-width: 300px;
    width: 100%;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.search-box input {
    padding-left: 38px;
    font-size: 0.85rem;
}

/* ==========================================================================
   5. Summary and Calculations Block
   ========================================================================== */

.summary-flex {
    display: flex;
    justify-content: space-between;
    gap: 30px;
    margin-top: 10px;
}

.summary-column {
    flex-grow: 1;
    width: 50%;
}

.values-column {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 360px;
}

.calc-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-muted);
    padding-bottom: 8px;
    border-bottom: 1px dashed rgba(15, 23, 42, 0.06);
}

.calc-row span:last-child {
    color: var(--text-main);
    font-weight: 500;
}

.total-row {
    font-size: 1.15rem;
    color: var(--text-main);
    border-bottom: none;
    font-weight: 700;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

.total-row span:last-child {
    color: var(--primary-color);
    font-weight: 800;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

/* ==========================================================================
   6. Statistics Section
   ========================================================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-dark-800);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform var(--transition-speed) ease;
    box-shadow: 0 4px 15px rgba(15, 23, 42, 0.03);
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: rgba(15, 23, 42, 0.12);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon i {
    width: 24px;
    height: 24px;
}

.stat-icon.purple { background: rgba(147, 51, 234, 0.1); color: #a855f7; }
.stat-icon.blue { background: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.stat-icon.green { background: rgba(16, 185, 129, 0.1); color: #10b981; }
.stat-icon.orange { background: rgba(249, 115, 22, 0.1); color: #f97316; }

.stat-info h3 {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-info p {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text-main);
    margin-top: 4px;
}

.d-none {
    display: none !important;
}

/* ==========================================================================
   7. Printable Invoice Replica Container Styling (Screen Preview)
   ========================================================================== */

/* Hidden on screen inside normal app container, but readable for printing */
#printInvoiceLayout {
    display: none;
}

/* Container that holds the pages (useful for spacing them on screen) */
.print-layout {
    font-family: var(--font-invoice);
    color: var(--text-dark);
    width: 210mm;
    margin: 20px auto;
    box-sizing: border-box;
}

/* Strict A4 page wrapper styling */
.print-page-wrapper {
    width: 210mm;
    height: 295.5mm;
    background-color: white !important;
    padding: 15mm 15mm 15mm 15mm !important;
    position: relative !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    page-break-after: always;
    page-break-inside: avoid;
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.15);
    margin-bottom: 20px; /* Space out copies on screen preview */
}

.print-page-wrapper:last-child {
    page-break-after: avoid;
    margin-bottom: 0;
}

@media print {
    .print-page-wrapper {
        box-shadow: none !important;
        margin: 0 !important;
    }
}

/* Decorative Teal Accents */
.print-teal-accents {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 12px;
    display: flex;
    justify-content: space-between;
    padding: 0 15mm;
    box-sizing: border-box;
}

.print-teal-accents.bottom {
    top: auto;
    bottom: 0;
}

.accent-bar-1 {
    width: 20%;
    height: 6px;
    background-color: #00828A; /* Teal from brand */
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
}

.accent-bar-2 {
    width: 75%;
    height: 4px;
    background-color: #00A6B4;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
}

.print-teal-accents.bottom .accent-bar-1,
.print-teal-accents.bottom .accent-bar-2 {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
}

/* Side margin accents mirroring the image (converted to HTML divs for PDF canvas capture compatibility) */
.print-side-accent-left {
    position: absolute;
    top: 50px;
    left: 0;
    width: 6px;
    height: 250px;
    background-color: #00828A;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
    z-index: 10;
}

.print-side-accent-right {
    position: absolute;
    bottom: 50px;
    right: 0;
    width: 6px;
    height: 150px;
    background-color: #00A6B4;
    border-top-left-radius: 4px;
    border-bottom-left-radius: 4px;
    z-index: 10;
}

.invoice-container {
    padding-top: 10px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Invoice Header */
.invoice-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}

.header-left {
    width: 65%;
}

.invoice-title {
    font-size: 1.55rem;
    font-weight: 700;
    color: #027A88; /* Match color of image header */
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.invoice-desc-line {
    font-size: 0.78rem;
    line-height: 1.35;
    color: #475569;
}

.invoice-desc-line.bold {
    font-weight: 700;
    color: #1e293b;
    margin-top: 2px;
}

.header-right {
    width: 32%;
    text-align: right;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.page-number {
    font-size: 0.75rem;
    color: #64748b;
    margin-bottom: 25px;
}

.tax-invoice-label {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 2px;
}

.invoice-number-val {
    font-size: 1.15rem;
    font-weight: 700;
    color: #0369a1; /* invoice color steel blue */
    margin-bottom: 4px;
}

.invoice-date-val {
    font-size: 0.76rem;
    color: #334155;
    font-weight: 500;
}

.invoice-date-val span {
    font-weight: 700;
}

/* Customer billing info */
.client-info-grid {
    display: flex;
    border-top: 1px solid #94a3b8;
    border-bottom: 1px solid #94a3b8;
    margin-bottom: 16px;
}

.client-column-left {
    width: 65%;
    border-right: 1px solid #94a3b8;
    padding: 10px 0;
    padding-right: 12px;
}

.bill-to-header {
    font-size: 0.78rem;
    font-weight: 700;
    color: #027A88;
    margin-bottom: 6px;
}

.client-company-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 4px;
}

.client-address {
    font-size: 0.78rem;
    line-height: 1.35;
    color: #475569;
    margin-bottom: 6px;
}

.client-meta-line {
    font-size: 0.78rem;
    color: #334155;
}

.client-meta-line.bold {
    font-weight: 700;
}

.client-column-right {
    width: 35%;
    padding: 10px 0;
    padding-left: 12px;
}

.meta-table {
    width: 100%;
    border-collapse: collapse;
}

.meta-table td {
    font-size: 0.78rem;
    padding: 3px 0;
    color: #334155;
}

.meta-table td:first-child {
    font-weight: 600;
    width: 100px;
}

.meta-table td span {
    font-weight: 500;
}

/* Printable Items Table */
.print-items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 12px;
}

.print-items-table th {
    background-color: #f8fafc;
    border: 1px solid #cbd5e1;
    padding: 8px 6px;
    font-size: 0.76rem;
    font-weight: 700;
    color: #1e293b;
    text-align: center;
}

.print-items-table th:nth-child(2) {
    text-align: left;
}

.print-items-table td {
    border-left: 1px solid #cbd5e1;
    border-right: 1px solid #cbd5e1;
    padding: 6px 8px;
    font-size: 0.76rem;
    color: #334155;
    vertical-align: top;
    height: 24px; /* Default row spacing */
}

/* Spacer rows style to force table height */
.print-items-table tr.spacer-row td {
    height: 24px;
}

.print-items-table .text-center {
    text-align: center;
}

.print-items-table .text-right {
    text-align: right;
}

.print-items-table tfoot td {
    padding: 6px 8px;
    font-size: 0.76rem;
    border: 1px solid #cbd5e1;
}

.print-items-table tfoot tr.total-row-main td {
    border-top: 2px solid #94a3b8;
    background-color: #f8fafc;
}

.print-items-table tfoot tr.grand-total-row td {
    background-color: #f1f5f9;
    font-size: 0.85rem;
}

.print-items-table tfoot tr.grand-total-row td:last-child {
    color: #0f172a;
}

/* Words statement */
.words-container {
    font-size: 0.78rem;
    color: #334155;
    border-bottom: 1px solid #cbd5e1;
    padding-bottom: 10px;
    margin-bottom: 12px;
}

.words-container span {
    text-transform: uppercase;
}

/* Bank details & signature blocks layout */
.bottom-invoice-section {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: auto; /* Push to the very bottom */
    padding-bottom: 10px;
}

.customer-signature-block {
    width: 45%;
    text-align: left;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.customer-signature-block .sign-space {
    height: 55px;
}

.customer-signature-block .sign-title {
    font-size: 0.76rem;
    font-weight: 700;
    color: #0f172a;
    border-top: 1px dashed #cbd5e1;
    padding-top: 5px;
    display: inline-block;
    width: 140px;
}

.bank-details-block {
    width: 50%;
    margin-bottom: 15px;
}

.bank-title-label {
    font-size: 0.76rem;
    font-weight: 700;
    color: #027A88;
    margin-bottom: 4px;
}

.bank-detail-line {
    font-size: 0.75rem;
    line-height: 1.35;
    color: #475569;
}

.bank-detail-line.bold {
    font-weight: 700;
    color: #0f172a;
}

.signature-block {
    width: 45%;
    text-align: right;
}

.sign-org {
    font-size: 0.78rem;
    font-style: italic;
    font-weight: 700;
    color: #027A88;
    margin-bottom: 45px;
}

.sign-name {
    font-size: 0.8rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 2px;
}

.sign-title {
    font-size: 0.72rem;
    color: #64748b;
    font-weight: 500;
}

.bold {
    font-weight: 700;
}

/* ==========================================================================
   8. Responsive Layout Tweaks for Dashboard
   ========================================================================== */

@media (max-width: 1024px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    .span-2 {
        grid-column: span 1;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 70px;
        padding: 16px 0;
    }
    .sidebar-brand {
        padding: 0 10px 20px 10px;
        justify-content: center;
    }
    .brand-name {
        display: none;
    }
    .nav-item span, .profile-info {
        display: none;
    }
    .nav-item {
        justify-content: center;
        padding: 12px;
    }
    .main-content {
        margin-left: 70px;
        padding: 20px;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .input-row {
        flex-direction: column;
        gap: 0;
    }
    .input-row .input-group {
        margin-bottom: 16px;
    }
    .summary-flex {
        flex-direction: column;
        gap: 16px;
    }
    .summary-column {
        width: 100%;
    }
}

/* ==========================================================================
   8a. In-App Invoice Preview Styling
   ========================================================================== */

.preview-actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 24px;
    margin-bottom: 24px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.04);
}

.preview-actions-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.preview-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

.preview-checkbox-label input {
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color);
    cursor: pointer;
}


/* Centering wrapper for invoice A4 preview */
.invoice-preview-wrapper {
    width: 100%;
    overflow-x: auto;
    padding: 10px 0 30px 0;
    display: flex;
    justify-content: center;
}

#previewInvoiceCard {
    width: 210mm !important;
    background: transparent !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    position: relative !important;
    box-sizing: border-box !important;
    overflow: visible !important; /* Allow multiple pages to scroll/show */
}

/* Ensure inside the preview card that the invoice-container fills A4 height precisely */
#previewInvoiceCard .invoice-container {
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
}

/* ==========================================================================
   9. Pure Print Media Formatting Rules
   ========================================================================== */

@media print {
    /* Set page dimension */
    @page {
        size: A4 portrait;
        margin: 0;
    }

    /* Reset core layout and margins */
    html, body {
        margin: 0 !important;
        padding: 0 !important;
        width: 210mm !important;
        box-sizing: border-box !important;
    }

    body {
        background-color: white !important;
        color: black !important;
        min-height: auto;
    }

    /* Hide the entire app dashboard chrome and lock screen */
    #appChrome, #loginScreen {
        display: none !important;
    }

    /* Unhide print invoice and size to A4 */
    #printInvoiceLayout {
        display: block !important;
        width: 210mm;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
        background: transparent !important;
        overflow: visible !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .print-page-wrapper {
        width: 210mm !important;
        margin: 0 !important;
        box-shadow: none !important;
        border: none !important;
        height: 295.5mm !important; /* Safety buffer to prevent rounding margins overflow causing empty pages */
        page-break-after: always;
        page-break-inside: avoid;
    }

    .print-page-wrapper:last-child {
        page-break-after: avoid;
    }
    
    /* Ensure the browser prints colored backgrounds and borders */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Prevent text selections or page break weirdness */
    .invoice-container {
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }

    /* Keep items table aligned */
    .print-items-table td {
        border-bottom: none !important;
    }
}

/* ==========================================================================
   10. Login Screen Styling
   ========================================================================== */

.login-screen-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, var(--bg-dark-900) 0%, var(--bg-dark-600) 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    overflow: hidden;
}

/* Floating Ambient Background Gradient Shapes */
.login-bg-shapes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -1;
}

.shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: floatAnimation 20s infinite alternate ease-in-out;
}

.shape-1 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(2, 132, 199, 0.4) 0%, rgba(2, 132, 199, 0) 70%);
    top: 10%;
    left: 15%;
    animation-duration: 22s;
}

.shape-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(0, 166, 180, 0.3) 0%, rgba(0, 166, 180, 0) 70%);
    bottom: 10%;
    right: 15%;
    animation-duration: 28s;
}

.shape-3 {
    width: 250px;
    height: 250px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.3) 0%, rgba(59, 130, 246, 0) 70%);
    top: 45%;
    left: 45%;
    animation-duration: 16s;
}

@keyframes floatAnimation {
    0% { transform: translateY(0) scale(1) rotate(0deg); }
    50% { transform: translateY(-30px) scale(1.1) rotate(180deg); }
    100% { transform: translateY(30px) scale(0.9) rotate(360deg); }
}

.login-card {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 20px;
    width: 100%;
    max-width: 410px;
    padding: 40px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.08),
                inset 0 1px 0 rgba(255, 255, 255, 0.5);
    display: flex;
    flex-direction: column;
    animation: loginCardFadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.login-card:hover {
    box-shadow: 0 30px 60px rgba(15, 23, 42, 0.12),
                inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.login-card.shake {
    animation: cardShake 0.4s ease-in-out;
}

@keyframes cardShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

@keyframes loginCardFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    text-align: center;
    margin-bottom: 24px;
}

.login-logo {
    width: 68px;
    height: 68px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #3b82f6 100%);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    margin: 0 auto 16px auto;
    box-shadow: 0 8px 20px rgba(2, 132, 199, 0.25);
    transition: transform 0.3s ease;
}

.login-card:hover .login-logo {
    transform: scale(1.05) rotate(5deg);
}

.login-logo i {
    width: 30px;
    height: 30px;
}

.login-header h2 {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: var(--text-main);
    margin-bottom: 2px;
}

.login-header small {
    font-size: 0.75rem;
    color: var(--primary-color);
    font-weight: 700;
    letter-spacing: 1.5px;
    display: block;
    margin-bottom: 12px;
}

.login-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 6px;
}

.login-header p {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.input-with-icon {
    position: relative;
    width: 100%;
}

.input-with-icon i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
    transition: color 0.3s ease;
}

.input-with-icon input {
    padding-left: 42px;
    padding-right: 42px;
    background-color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(15, 23, 42, 0.12);
    height: 44px;
    font-size: 0.92rem;
    transition: all 0.3s ease;
}

.input-with-icon input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px var(--primary-glow);
    background-color: #ffffff;
}

.input-with-icon input:focus + i {
    color: var(--primary-color);
}

.password-toggle-btn {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 4px;
    transition: all var(--transition-speed) ease;
}

.password-toggle-btn:hover {
    color: var(--text-main);
    background-color: rgba(15, 23, 42, 0.05);
}

.password-toggle-btn i {
    width: 18px;
    height: 18px;
    pointer-events: none;
}

.login-error-msg {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.15);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 16px;
    color: var(--danger);
    font-size: 0.8rem;
    font-weight: 500;
}

.login-error-msg i {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.login-btn {
    width: 100%;
    height: 46px;
    font-size: 0.98rem;
    margin-top: 10px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #3b82f6 100%);
    color: white;
    border: none;
    box-shadow: 0 8px 20px rgba(2, 132, 199, 0.25);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(2, 132, 199, 0.35);
    background: linear-gradient(135deg, var(--primary-hover) 0%, #2563eb 100%);
}

.login-btn:active {
    transform: translateY(0);
}
