/* ====== DESIGN TOKENS ====== */
:root {
    --primary-color: #ffcc2a; /* Vibrant Gold-Yellow */
    --primary-hover: #e6b722; /* Slightly Darker Gold hover */
    --secondary-color: #fffbeb;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --sidebar-bg: #ffffff; /* Rich White Sidebar */
    --sidebar-text: #1e293b;
    --sidebar-hover: #f1f5f9; /* Light grey hover */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --font-sans: 'Inter', sans-serif;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Tokens */
body.dark-mode {
    --primary-color: #ffff00;
    --primary-hover: #ffea00;
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --border-color: #334155;
    --sidebar-bg: #1e293b;
    --sidebar-text: #f1f5f9;
    --sidebar-hover: #334155;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

/* ====== RESET & BASE ====== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    font-size: 0.95rem;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: var(--primary-color);
}

input,
select,
textarea,
button {
    font-family: inherit;
    font-size: inherit;
}

.hidden {
    display: none !important;
}

/* ====== UTILITIES ====== */
.mt-2 {
    margin-top: 0.5rem;
}

.mt-3 {
    margin-top: 1rem;
}

.mt-4 {
    margin-top: 1.5rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-4 {
    margin-bottom: 1.5rem;
}

.pb-0 {
    padding-bottom: 0 !important;
}

.w-100 {
    width: 100%;
}

.w-50 {
    width: 50%;
}

.w-60 {
    width: 60%;
}

.w-40 {
    width: 40%;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flex-end {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
}

.row-align {
    display: flex;
    align-items: center;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.gap-sm {
    gap: 0.5rem;
}

.text-muted {
    color: var(--text-muted);
}

.text-primary {
    color: var(--primary-color);
}

.bold {
    font-weight: 700;
}

.bg-light {
    background-color: var(--secondary-color);
}

.bg-dark {
    background-color: #e2e8f0;
    color: #0f172a;
}

body.dark-mode .bg-light,
body.dark-mode .bg-dark {
    background-color: var(--border-color);
    color: var(--text-color);
}

.custom-brand-text {
    color: var(--primary-color) !important;
}

.gstin-text {
    color: var(--text-color) !important;
}

@media print {
    .custom-brand-text {
        color: #ffcc2a !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .gstin-text {
        color: #212529 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ====== BADGES ====== */
.badge {
    padding: 0.35rem 0.85rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success {
    background: var(--success-color);
    color: white;
}

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

body.dark-mode .badge-success {
    background: var(--success-color);
    color: white;
}

body.dark-mode .badge-danger {
    background: var(--danger-color);
    color: white;
}

/* ====== BUTTONS ====== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.btn-primary {
    background-color: var(--primary-color);
    color: #1e293b;
    font-weight: 600;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    color: #1e293b;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 204, 42, 0.3);
}

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

.btn-success:hover {
    background-color: #059669;
}

.btn-whatsapp {
    background-color: #25d366;
    color: white;
}

.btn-whatsapp:hover {
    background-color: #20ba5a;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.35);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

.btn-outline:hover {
    background-color: var(--secondary-color);
    border-color: var(--text-muted);
}

body.dark-mode .btn-outline:hover {
    background-color: var(--border-color);
}

.btn-transparent {
    background: none;
    color: inherit;
    border: none;
}

.btn-icon-danger {
    color: var(--danger-color);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
}

.btn-icon-danger:hover {
    background-color: #fee2e2;
}

body.dark-mode .btn-icon-danger:hover {
    background-color: rgba(239, 68, 68, 0.2);
}

.btn-block {
    width: 100%;
    padding: 0.75rem;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
}

/* ====== LOGIN PAGE ====== */
#login-view {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 10% 20%, rgba(212, 154, 0, 0.12) 0%, transparent 45%),
                radial-gradient(circle at 90% 80%, rgba(133, 100, 4, 0.15) 0%, transparent 50%),
                linear-gradient(135deg, #181403 0%, #050400 100%);
    position: relative;
    overflow: hidden;
}

#login-view::before {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    background: var(--primary-color);
    filter: blur(150px);
    opacity: 0.12;
    border-radius: 50%;
    top: -50px;
    left: -50px;
    pointer-events: none;
}

#login-view::after {
    content: '';
    position: absolute;
    width: 350px;
    height: 350px;
    background: var(--sidebar-bg);
    filter: blur(180px);
    opacity: 0.1;
    border-radius: 50%;
    bottom: -80px;
    right: -80px;
    pointer-events: none;
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 1.5rem;
    z-index: 2;
}

.login-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 1.5rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    padding: 3rem 2.5rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: var(--transition);
}

body.dark-mode .login-card {
    background: rgba(15, 23, 42, 0.8);
    border-color: rgba(255, 255, 255, 0.05);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.login-card input {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

body.dark-mode .login-card input {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(255, 255, 255, 0.1);
    color: #f1f5f9;
}

.login-card input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(212, 154, 0, 0.25);
}

.login-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.login-header h2 {
    color: var(--primary-color);
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-muted);
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.input-with-icon i {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    pointer-events: none;
}

.input-with-icon i:first-child {
    left: 0.75rem;
}

.input-with-icon #toggle-password {
    right: 0.75rem;
    left: auto;
    cursor: pointer;
    pointer-events: auto;
    transition: var(--transition);
}

.input-with-icon #toggle-password:hover {
    color: var(--primary-color);
}

.input-with-icon input {
    padding-left: 2.75rem;
    padding-right: 2.75rem;
    width: 100%;
}

.input-with-icon.no-left-icon input {
    padding-left: 0.75rem;
}

.error-msg {
    color: var(--danger-color);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    text-align: center;
    background: #fee2e2;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
}

/* ====== APP LAYOUT ====== */
#app-layout {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 250px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    border-right: 1px solid var(--border-color);
}

.sidebar-brand {
    padding: 1.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: var(--transition);
    width: 100%;
}

.nav-item:hover {
    background-color: var(--sidebar-hover);
    color: var(--text-color);
}

.nav-item.active {
    background-color: var(--primary-color);
    color: #000000;
    font-weight: 600;
    border-left: 4px solid #000000;
}

.sidebar-bottom {
    padding: 1rem 0;
    border-top: 1px solid var(--border-color);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.topbar {
    height: 60px;
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    z-index: 10;
}

.topbar h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

/* ====== CARDS ====== */
.card {
    background-color: var(--card-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.card-header h2 {
    font-size: 1.1rem;
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background-color: rgba(0, 0, 0, 0.02);
}

body.dark-mode .card-footer {
    background-color: rgba(255, 255, 255, 0.02);
}

/* ====== DASHBOARD CARDS ====== */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
}

.summary-card {
    display: flex;
    align-items: center;
    padding: 1.5rem;
    gap: 1rem;
}

.card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.card-icon.blue {
    background: linear-gradient(135deg, rgba(212, 154, 0, 0.1) 0%, rgba(212, 154, 0, 0.2) 100%);
    color: var(--primary-color);
    border: 1px solid rgba(212, 154, 0, 0.15);
}

.card-icon.green {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(16, 185, 129, 0.2) 100%);
    color: var(--success-color);
    border: 1px solid rgba(16, 185, 129, 0.15);
}

.card-icon.orange {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, rgba(245, 158, 11, 0.2) 100%);
    color: var(--warning-color);
    border: 1px solid rgba(245, 158, 11, 0.15);
}

.card-icon.purple {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.1) 0%, rgba(168, 85, 247, 0.2) 100%);
    color: #a855f7;
    border: 1px solid rgba(168, 85, 247, 0.15);
}

body.dark-mode .card-icon {
    background: var(--border-color);
}

.card-info h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.card-info p {
    font-size: 1.25rem;
    font-weight: 700;
    margin-top: 0.25rem;
}

/* ====== FORMS ====== */
.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-color);
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="password"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: var(--card-bg);
    color: var(--text-color);
    outline: none;
    transition: border-color 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

input.small-input {
    width: 60px;
    padding: 0.25rem;
    text-align: center;
    display: inline-block;
}

/* Checkboxes */
.checkbox-container {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.9rem;
    user-select: none;
    margin-bottom: 0;
}

.checkbox-container input {
    margin-right: 0.5rem;
    width: auto;
}

/* Form Sections */
.box-section {
    border: 1px solid var(--border-color);
    padding: 1.25rem;
    border-radius: var(--radius-md);
    background-color: var(--secondary-color);
}

body.dark-mode .box-section {
    background-color: var(--card-bg);
}

.box-section h3 {
    font-size: 0.95rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--primary-color);
}

.box-section h4 {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

/* Totals Box */
.totals-box {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.totals-box .form-group {
    margin-bottom: 0.5rem;
}

.grand-total-row {
    border-top: 2px solid var(--border-color);
    padding-top: 1rem;
}

/* ====== TABLES ====== */
.table-responsive {
    overflow-x: auto;
}

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

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background-color: var(--secondary-color);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-muted);
}

body.dark-mode .data-table th {
    background-color: rgba(255, 255, 255, 0.05);
}

.data-table tbody tr:hover {
    background-color: var(--bg-color);
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    width: 250px;
}

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

.search-box input {
    padding-left: 2rem;
    border-radius: 999px;
}

.date-filter-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    transition: var(--transition);
}

.date-filter-container .filter-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.date-filter-container input[type="date"] {
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
    font-size: 0.85rem;
    color: var(--text-color);
    outline: none !important;
    width: 120px;
    transition: var(--transition);
}

.date-filter-container input[type="date"]:focus {
    border-color: transparent !important;
    box-shadow: none !important;
}

.date-filter-container input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    filter: invert(0.5);
}

body.dark-mode .date-filter-container input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.8);
}

#btn-clear-date-filter {
    background: transparent;
    border: none;
    padding: 0.1rem 0.3rem;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

#btn-clear-date-filter:hover {
    color: var(--primary-color);
}

/* Products Table specific */
.products-table input {
    padding: 0.4rem;
    border: 1px solid transparent;
}

.products-table input:hover,
.products-table input:focus {
    border-color: var(--border-color);
}

/* ====== TOAST ====== */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: var(--text-color);
    color: var(--card-bg);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    animation: slideUp 0.3s ease forwards;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ====== PRINT / INVOICE PREVIEW ====== */
.invoice-print-container {
    position: relative;
    background: #fff;
    color: #000;
    width: 210mm;
    min-height: 297mm;
    margin: 0 auto 20px auto;
    padding: 10mm;
    /* Consistent margins */
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    box-sizing: border-box;
}

.invoice-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 350px;
    height: 350px;
    object-fit: contain;
    opacity: 0.07; /* Very faint watermark */
    pointer-events: none;
    z-index: 0;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
}

.copy-label-badge {
    position: absolute;
    top: 20px;
    right: 20px;
    background: #f7f9fc;
    border: 1px solid #e2e8f0;
    padding: 5px 12px;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #1e293b;
    border-radius: 4px;
}

/* These styles mostly map to your original invoice format but cleaned up */
.print-header {
    border-bottom: 3px solid var(--primary-color);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    text-align: center;
}

.company-info-area {
    display: flex;
    align-items: center;
    justify-content: center;
}

.company-details {
    text-align: left;
}

.company-name {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

#print-company-tamil-name {
    font-weight: 800;
}

.print-title {
    background: transparent;
    color: var(--primary-color);
    text-align: center;
    font-weight: 800;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

.print-two-col {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.print-box {
    border: 1px solid var(--border-color);
}

.print-box-title {
    background: transparent;
    color: var(--text-color);
    padding: 0.4rem 0.5rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.print-box-title.custom-brand-text {
    color: var(--primary-color) !important;
}

.print-inv-no-highlight {
    border: 1px solid var(--border-color);
    padding: 0.35rem 0.5rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

body.dark-mode .print-inv-no-highlight {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-color);
}

.print-block {
    padding: 0.5rem;
    font-size: 0.85rem;
    line-height: 1.6;
}

.print-grid-2-rows {
    padding: 0.5rem;
}

.print-table-wrap {
    min-height: 200px;
    margin-bottom: 0.5rem;
}

.print-items {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--border-color);
}

.print-items th,
.print-items td {
    border: 1px solid var(--border-color);
    padding: 0.4rem;
    font-size: 0.85rem;
}

.print-items th {
    background: transparent;
    color: var(--text-color);
    font-weight: bold;
    text-align: center !important;
    border: 1px solid var(--border-color);
}

.print-bottom {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.print-totals {
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.print-totals-row {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.print-totals-row:last-child {
    border-bottom: none;
}

.print-totals-row.grand {
    font-weight: 700;
    background: transparent;
    color: var(--text-color);
    font-size: 1rem;
    border-top: 2px solid var(--border-color);
}

.print-signatures {
    display: flex;
    justify-content: space-between;
    margin-top: 1rem;
}

.sig-box {
    text-align: center;
    font-size: 0.85rem;
    border-top: 1px solid #000;
    padding-top: 0.5rem;
    width: 200px;
}

.sig-box.right {
    text-align: right;
    border-top: none;
}

/* Print Media Query */
@media print {
    @page {
        margin: 0;
        size: A4 portrait;
    }

    body {
        background-color: #fff !important;
        margin: 0;
        padding: 0;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Hide all non-printable application frames */
    .sidebar,
    .topbar,
    .toast,
    .view:not(#app-layout),
    .sub-view:not(#invoice-preview-view),
    .no-print {
        display: none !important;
    }

    /* Ensure flex wrappers don't crush the height or width */
    #app-layout,
    .main-content,
    .content-area,
    #invoice-preview-view {
        display: block !important;
        width: 100% !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
        position: static !important;
    }

    #print-area {
        display: block !important;
        width: 210mm !important;
        margin: 0 auto !important;
        padding: 0 !important;
        position: static !important;
    }

    .invoice-print-container {
        width: 210mm !important;
        height: auto !important;
        min-height: auto !important;
        padding: 10mm !important;
        /* Match preview padding exactly */
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        margin: 0 !important;
        page-break-after: always;
        page-break-inside: avoid;
        box-sizing: border-box !important;
        position: relative !important;
    }

    .invoice-print-container:last-child {
        page-break-after: avoid !important;
        break-after: avoid !important;
    }

    .copy-label-badge {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .print-box-title,
    .print-items th,
    .print-totals-row.grand {
        background: transparent !important;
        background-color: transparent !important;
        color: #000000 !important;
    }

    .print-title {
        background: transparent !important;
        background-color: transparent !important;
        color: #ffcc2a !important;
        font-weight: 800 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    #print-company-name,
    #print-company-tamil-name {
        color: #ffcc2a !important;
        font-weight: 800 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .print-inv-no-highlight {
        border: 1px solid #000000 !important;
        color: #000000 !important;
    }
}

/* Responsive */
@media screen and (max-width: 768px) {
    #app-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
        padding: 0.5rem;
    }

    .sidebar-brand {
        border: none;
        padding: 0.5rem;
    }

    .sidebar-nav {
        display: flex;
        overflow-x: auto;
        padding: 0;
        flex: none;
        width: 100%;
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    .sidebar-nav::-webkit-scrollbar {
        display: none;
    }

    .nav-item {
        flex: 1;
        text-align: center;
        justify-content: center;
        min-width: 75px;
        padding: 0.5rem;
        font-size: 0.8rem;
        flex-direction: column;
        gap: 0.25rem;
    }

    .sidebar-bottom {
        display: none;
    }

    .topbar {
        padding: 0 1rem;
        height: auto;
        padding: 1rem;
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }

    .topbar-actions {
        margin-top: 0.25rem;
    }

    .content-area {
        padding: 1rem;
    }

    .grid-2,
    .grid-4 {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .print-two-col,
    .print-bottom {
        flex-direction: column;
    }

    .w-50,
    .w-60,
    .w-40 {
        width: 100%;
    }

    /* Print Template Container optimization on screen preview */
    .invoice-print-container {
        width: 100% !important;
        min-height: auto !important;
        padding: 15px !important;
        box-shadow: none !important;
        border: 1px solid var(--border-color) !important;
        margin: 0 auto 20px auto !important;
    }

    .print-table-wrap {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .print-items {
        min-width: 600px; /* Ensure table remains readable by enabling horizontal swipe inside its container */
    }

    /* Form Service Item cards on mobile */
    .products-table thead {
        display: none;
    }
    
    .products-table tbody tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
        padding: 1rem;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        background: var(--card-bg);
        margin-bottom: 1rem;
        position: relative;
    }
    
    .products-table tbody tr td {
        display: flex;
        flex-direction: column;
        border: none;
        padding: 0;
    }
    
    .products-table tbody tr td:first-child {
        grid-column: span 2;
        font-weight: 700;
        color: var(--primary-color);
        margin-bottom: 0.25rem;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid var(--border-color);
        padding-bottom: 0.5rem;
    }
    
    .products-table tbody tr td:first-child::before {
        content: "Service Item #";
    }
    
    .products-table tbody tr td:nth-child(2) {
        grid-column: span 2;
    }

    .products-table tbody tr td:nth-child(2) label {
        display: none; /* Hide service selector standard label if any */
    }
    
    .products-table tbody tr td:nth-child(3)::before {
        content: "HSN/SAC";
        font-size: 0.75rem;
        font-weight: 600;
        color: var(--text-muted);
        margin-bottom: 0.25rem;
    }
    
    .products-table tbody tr td:nth-child(4)::before {
        content: "Quantity";
        font-size: 0.75rem;
        font-weight: 600;
        color: var(--text-muted);
        margin-bottom: 0.25rem;
    }
    
    .products-table tbody tr td:nth-child(5)::before {
        content: "Rate (₹)";
        font-size: 0.75rem;
        font-weight: 600;
        color: var(--text-muted);
        margin-bottom: 0.25rem;
    }
    
    .products-table tbody tr td:nth-child(6)::before {
        content: "Amount (₹)";
        font-size: 0.75rem;
        font-weight: 600;
        color: var(--text-muted);
        margin-bottom: 0.25rem;
    }
    
    .products-table tbody tr td:nth-child(7) {
        position: absolute;
        top: 0.75rem;
        right: 0.75rem;
        z-index: 10;
    }
    
    /* Search Box & filters */
    .table-card .card-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .table-actions {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 0.75rem;
    }
    
    .search-box {
        width: 100% !important;
    }
    
    .date-filter-container {
        width: 100% !important;
        justify-content: space-between;
        border-radius: var(--radius-md) !important;
        padding: 0.5rem 0.75rem;
    }
    
    #export-csv-btn {
        width: 100%;
    }

    /* Form layouts on phone */
    .form-actions {
        flex-direction: column;
        width: 100%;
        gap: 0.75rem;
    }

    .form-actions .btn {
        width: 100%;
    }

    .totals-section .grid-2 {
        display: flex;
        flex-direction: column-reverse;
        gap: 1rem;
    }

    .sidebar-brand-footer {
        display: none !important;
    }
}

.sidebar-brand-footer {
    padding: 1.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: auto;
    border-top: 1px solid var(--border-color);
    width: 100%;
}