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

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #eef2ff;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --success: #10b981;
    --success-light: #ecfdf5;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --info: #3b82f6;
    --info-light: #eff6ff;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --white: #ffffff;
    --sidebar-width: 240px;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: #4f46e5;
    --right-sidebar-width: 280px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius: 8px;
    --radius-lg: 12px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    font-size: 15px;
    line-height: 1.65;
    min-height: 100vh;
}

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

/* ===== LOGIN PAGE ===== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--sidebar-bg);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 50%, rgba(79,70,229,0.15) 0%, transparent 50%),
                radial-gradient(circle at 70% 50%, rgba(16,185,129,0.1) 0%, transparent 50%);
    animation: subtle-move 20s ease-in-out infinite alternate;
}

@keyframes subtle-move {
    0% { transform: translate(0, 0); }
    100% { transform: translate(-2%, -1%); }
}

.login-container { width: 100%; max-width: 420px; padding: 1rem; position: relative; z-index: 1; }

.login-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
}

.login-header { text-align: center; margin-bottom: 2rem; }
.login-header h1 { font-size: 1.875rem; color: var(--gray-900); font-weight: 700; letter-spacing: -0.025em; }
.login-header p { color: var(--gray-500); margin-top: 0.5rem; font-size: 1rem; }

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

/* ===== LEFT SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--white);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 200;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: transform 0.3s ease, width 0.25s ease;
}

.sidebar-brand {
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand-icon {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.sidebar-brand-text {
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.875rem;
    border-radius: var(--radius);
    color: var(--gray-400);
    font-size: 0.9375rem;
    font-weight: 500;
    transition: all 0.15s;
    text-decoration: none;
}

.sidebar-nav a:hover {
    background: var(--sidebar-hover);
    color: var(--white);
    text-decoration: none;
}

.sidebar-nav a.active {
    background: var(--sidebar-active);
    color: var(--white);
}

.sidebar-nav .nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1rem;
}

.sidebar-section {
    padding: 1.25rem 1.25rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gray-500);
}

.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius);
    color: var(--gray-400);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s;
    text-decoration: none;
}

.sidebar-footer a:hover {
    background: var(--sidebar-hover);
    color: var(--white);
    text-decoration: none;
}

/* ===== MAIN CONTENT ===== */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.25s ease;
}

/* ===== TOP BAR ===== */
.topbar {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 0 1.5rem;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-title {
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--gray-800);
}

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

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--gray-600);
}

.topbar-avatar {
    width: 32px;
    height: 32px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8125rem;
}

.mobile-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--gray-600);
    font-size: 1.25rem;
}

/* ===== CONTENT AREA ===== */
.content-area {
    display: flex;
    flex: 1;
}

.main-content {
    flex: 1;
    padding: 1.75rem 2rem;
    min-width: 0;
}

/* ===== RIGHT SIDEBAR ===== */
.right-sidebar {
    width: var(--right-sidebar-width);
    background: var(--white);
    border-left: 1px solid var(--gray-200);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    overflow-y: auto;
    flex-shrink: 0;
}

.right-sidebar-widget {
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: 1rem;
    border: 1px solid var(--gray-200);
}

.right-sidebar-widget h3 {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    margin-bottom: 0.75rem;
}

.widget-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5625rem 0;
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.875rem;
}

.widget-item:last-child { border-bottom: none; }

.widget-item-label { color: var(--gray-600); }
.widget-item-value { font-weight: 600; color: var(--gray-900); }

.widget-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5625rem 0.75rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    transition: all 0.15s;
    text-decoration: none;
    margin-bottom: 0.25rem;
}

.widget-link:hover {
    background: var(--white);
    color: var(--primary);
    text-decoration: none;
}

.widget-link .link-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.widget-link .link-icon.blue { background: var(--info-light); color: var(--info); }
.widget-link .link-icon.green { background: var(--success-light); color: var(--success); }
.widget-link .link-icon.purple { background: var(--primary-light); color: var(--primary); }
.widget-link .link-icon.orange { background: var(--warning-light); color: var(--warning); }

.recent-bill-item {
    display: block;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--gray-200);
    text-decoration: none;
    transition: all 0.15s;
}

.recent-bill-item:last-child { border-bottom: none; }
.recent-bill-item:hover { text-decoration: none; }

.recent-bill-item .bill-num {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--gray-800);
}

.recent-bill-item .bill-customer {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.recent-bill-item .bill-amount {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--primary);
    float: right;
    margin-top: -1.75rem;
}

/* ===== CONTAINER (for non-sidebar pages like print) ===== */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* ===== CARDS ===== */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.75rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--gray-200);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 0.875rem;
    border-bottom: 1px solid var(--gray-100);
}

.card-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-800);
}

/* ===== FORMS ===== */
.form-group { margin-bottom: 1.125rem; }
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4375rem;
    font-size: 0.875rem;
    color: var(--gray-700);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.9375rem;
    transition: all 0.15s;
    background: var(--white);
    color: var(--gray-900);
    height: auto;
    min-height: 44px;
}

.form-group select {
    min-height: 44px;
}

.form-group textarea {
    min-height: auto;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.125rem;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    gap: 0.4375rem;
    text-decoration: none;
    min-height: 42px;
}

.btn:hover { text-decoration: none; }

.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); box-shadow: var(--shadow-sm); }

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

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

.btn-secondary { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-200); }

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

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; border-radius: 6px; min-height: 34px; }
.btn-block { width: 100%; padding: 0.75rem; font-size: 1rem; min-height: 48px; }

/* ===== ALERTS ===== */
.alert {
    padding: 0.875rem 1.125rem;
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    font-size: 0.9375rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.alert-error { background: var(--danger-light); color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: var(--success-light); color: var(--success); border: 1px solid #a7f3d0; }

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

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

table th, table td {
    padding: 0.8125rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.9375rem;
}

table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-600);
    white-space: nowrap;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 0.875rem 1rem;
}

table tbody tr { transition: background 0.1s; }
table tbody tr:hover { background: var(--primary-light); }
table:not(.bill-table) tbody tr:nth-child(even) { background: var(--gray-50); }
table:not(.bill-table) tbody tr:nth-child(even):hover { background: var(--primary-light); }
.bill-table tbody tr:hover { background: transparent; }

table input {
    width: 100%;
    padding: 0.5rem 0.625rem;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 0.9375rem;
    min-height: 40px;
}

table input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(79,70,229,0.1);
}

table input[type="number"] { text-align: right; }

.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--gray-500); }

/* ===== SUMMARY ===== */
.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 0.625rem 0;
    font-size: 0.9375rem;
    color: var(--gray-600);
}

.summary-row.total {
    font-weight: 700;
    font-size: 1.1875rem;
    color: var(--gray-900);
    border-top: 2px solid var(--gray-300);
    padding-top: 0.875rem;
    margin-top: 0.375rem;
}

/* ===== BILL PRINT VIEW ===== */
.bill-letterhead {
    text-align: center;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--gray-900);
}

.bill-letterhead img {
    width: 100%;
    height: auto;
}

.bill-letterhead-text {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding: 0.75rem 0;
    border-bottom: 3px double #1a1a1a;
}

.lh-logo-col {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-right: 1rem;
    border-right: 1.5px solid #ccc;
}

.bill-letterhead-logo {
    max-height: 70px;
    max-width: 90px;
    width: auto;
    height: auto;
    object-fit: contain;
}

.lh-info-col {
    flex: 1;
    text-align: left;
}

.lh-info-col.lh-info-full {
    text-align: center;
}

.bill-letterhead-name {
    font-size: 1.4rem;
    font-weight: 800;
    color: #111;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-bottom: 0.35rem;
    line-height: 1.2;
}

.lh-info-full .bill-letterhead-name {
    font-size: 1.6rem;
}

.lh-details {
    display: flex;
    flex-wrap: wrap;
    gap: 0.1rem 0;
    flex-direction: column;
}

.lh-info-full .lh-details {
    align-items: center;
}

.lh-detail-item {
    font-size: 0.8rem;
    color: #444;
    line-height: 1.45;
}

.lh-detail-item.lh-gst {
    font-weight: 700;
    color: #222;
    margin-top: 0.1rem;
}

.bill-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ===== PAGE HEADER ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.75rem;
}

.page-header h1 {
    font-size: 1.625rem;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.025em;
}

/* ===== SEARCH BAR ===== */
.search-bar {
    display: flex;
    gap: 0.625rem;
    margin-bottom: 1.25rem;
}

.search-bar input {
    flex: 1;
    padding: 0.625rem 1rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.9375rem;
    background: var(--white);
    min-height: 44px;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 3.5rem 1.5rem;
    color: var(--gray-400);
}

.empty-state h3 { font-size: 1.125rem; color: var(--gray-500); }
.empty-state p { margin-top: 0.5rem; font-size: 0.9375rem; }

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: #b45309; }
.badge-info { background: var(--info-light); color: var(--info); }

/* ===== STAT CARDS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stats-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    text-align: center;
    border: 1px solid var(--gray-200);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary);
}

.stat-card.stat-paid::before { background: var(--success); }
.stat-card.stat-pending::before { background: var(--warning); }

.stat-value {
    font-size: 1.625rem;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.025em;
}

.stat-label {
    font-size: 0.8125rem;
    color: var(--gray-500);
    margin-top: 0.375rem;
    font-weight: 500;
}

/* ===== PAGINATION ===== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.375rem;
    margin-top: 1rem;
}

/* ===== MOBILE OVERLAY ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 150;
}

/* ===== BILL TYPE TOGGLE ===== */
.bill-type-toggle {
    display: flex;
    gap: 1rem;
    margin-top: 0.25rem;
}
.bill-type-toggle .type-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem 1.25rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
    text-align: center;
}
.bill-type-toggle .type-option:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}
.bill-type-toggle .type-option input[type="radio"] {
    display: none;
}
.bill-type-toggle .type-option input[type="radio"]:checked + .type-label {
    color: var(--primary);
}
.bill-type-toggle .type-option:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-light);
}
.bill-type-toggle .type-label {
    font-weight: 600;
    font-size: 0.875rem;
}
.bill-type-toggle .type-option small {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 2px;
}

/* ===== BADGE STYLES ===== */
.badge-type {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.badge-page {
    background: #e0e7ff;
    color: #3730a3;
}
.badge-product {
    background: #fce7f3;
    color: #9d174d;
}

/* ===== EARNINGS PAGE ===== */
.earnings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.earnings-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    text-align: center;
}
.earnings-value {
    font-size: 1.625rem;
    font-weight: 700;
    color: var(--gray-900);
}
.earnings-label {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-top: 4px;
}
.month-chart-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}
.month-chart-bar .month-label {
    width: 80px;
    font-size: 0.8125rem;
    color: var(--gray-600);
    text-align: right;
}
.month-chart-bar .bar-wrap {
    flex: 1;
    background: var(--gray-100);
    border-radius: 4px;
    height: 24px;
    overflow: hidden;
}
.month-chart-bar .bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.3s;
    min-width: 2px;
}
.month-chart-bar .bar-value {
    width: 80px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--gray-700);
}

/* ===== A4 BILL STYLES ===== */
.print-only-text { display: none; }

.bill-a4-wrapper {
    display: flex;
    justify-content: center;
}

.bill-a4-page {
    width: 210mm;
    min-height: auto;
    background: var(--white);
    padding: 15mm 18mm;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #1a1a1a;
    line-height: 1.5;
}

.bill-a4-page .bill-letterhead {
    text-align: center;
    margin-bottom: 6mm;
    padding-bottom: 4mm;
    border-bottom: 2px solid #1a1a1a;
}

.bill-a4-page .bill-letterhead img {
    width: 100%;
    height: auto;
    display: block;
}

.bill-details-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6mm;
    font-size: 10pt;
}

.bill-details-left,
.bill-details-right {
    line-height: 1.8;
}

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

.bill-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 6mm;
    font-size: 9.5pt;
}

.bill-table th {
    background: #f0f0f0 !important;
    border: 1px solid #333;
    padding: 6px 10px;
    font-weight: 600;
    font-size: 9pt;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #333;
}

.bill-table td {
    border: 1px solid #ccc;
    padding: 6px 10px;
    border-bottom: 1px solid #ccc;
}

.bill-table tbody tr:hover {
    background: transparent;
}

.bill-summary {
    max-width: 250px;
    margin-left: auto;
    margin-top: 4mm;
    font-size: 10pt;
}

.bill-summary-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid #eee;
}

.bill-summary-row.bill-summary-total {
    font-weight: 700;
    font-size: 11pt;
    border-top: 2px solid #333;
    border-bottom: none;
    padding-top: 6px;
    margin-top: 2px;
}

.bill-footer-section {
    margin-top: 20mm;
    display: flex;
    justify-content: flex-end;
}

.bill-signature {
    text-align: center;
    min-width: 160px;
}

.signature-line {
    border-bottom: 1px solid #333;
    margin-bottom: 4px;
    height: 30px;
}

.bill-signature p {
    font-size: 8.5pt;
    color: #555;
}

/* ===== FILTER BAR ===== */
.filter-bar {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.filter-bar-row {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.125rem;
    gap: 0.75rem;
}

.filter-label {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-400);
    flex-shrink: 0;
}

.filter-tabs {
    display: flex;
    background: var(--gray-100);
    border-radius: 6px;
    padding: 3px;
    gap: 2px;
    flex-shrink: 0;
}

.filter-tab {
    padding: 0.4375rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--gray-500);
    border-radius: 4px;
    text-decoration: none;
    transition: all 0.15s;
    white-space: nowrap;
}

.filter-tab:hover {
    color: var(--gray-700);
    background: var(--white);
    text-decoration: none;
}

.filter-tab.active {
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 1px 2px rgba(79,70,229,0.3);
}

.filter-tab.active:hover {
    background: var(--primary-dark);
    color: var(--white);
}

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

.filter-form {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.filter-range {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.filter-range-sep {
    font-size: 0.75rem;
    color: var(--gray-400);
    padding: 0 0.125rem;
}

.filter-input {
    padding: 0.4375rem 0.625rem;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 0.8125rem;
    background: var(--gray-50);
    color: var(--gray-700);
    height: 38px;
    transition: all 0.15s;
}

.filter-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(79,70,229,0.1);
    background: var(--white);
}

.filter-active {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background: var(--primary-light);
    border-top: 1px solid rgba(79,70,229,0.1);
    font-size: 0.8125rem;
    color: var(--primary-dark);
}

.filter-clear-btn {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--primary);
    text-decoration: none;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    transition: all 0.15s;
}

.filter-clear-btn:hover {
    background: rgba(79,70,229,0.1);
    text-decoration: none;
}

/* ===== REPORT GRID ===== */
.report-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

/* ===== SIDEBAR TOGGLE (Desktop) ===== */
.sidebar-toggle-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--gray-600);
    font-size: 1.25rem;
    border-radius: 6px;
    transition: all 0.15s;
}

.sidebar-toggle-btn:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.nav-text {
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.2s ease, width 0.25s ease;
}

@media (min-width: 769px) {
    .sidebar-toggle-btn { display: flex; }

    .sidebar-collapsed .sidebar {
        width: 60px;
        overflow: hidden;
    }

    .sidebar-collapsed .sidebar .sidebar-brand-text,
    .sidebar-collapsed .sidebar .sidebar-section {
        opacity: 0;
        width: 0;
        overflow: hidden;
        display: none;
    }

    .sidebar-collapsed .sidebar .nav-text {
        opacity: 0;
        width: 0;
        overflow: hidden;
        position: absolute;
        pointer-events: none;
    }

    .sidebar-collapsed .sidebar .sidebar-brand {
        justify-content: center;
        padding: 1.25rem 0.5rem;
    }

    .sidebar-collapsed .sidebar .sidebar-nav a,
    .sidebar-collapsed .sidebar .sidebar-footer a {
        justify-content: center;
        padding: 0.625rem;
        gap: 0;
    }

    .sidebar-collapsed .sidebar .sidebar-nav a .nav-icon,
    .sidebar-collapsed .sidebar .sidebar-footer a .nav-icon {
        width: 28px;
        height: 28px;
        font-size: 1.2rem;
    }

    .sidebar-collapsed .sidebar .sidebar-nav,
    .sidebar-collapsed .sidebar .sidebar-footer {
        padding: 0.5rem 0.375rem;
    }

    .sidebar-collapsed .main-wrapper {
        margin-left: 60px;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    @page {
        size: A4 portrait;
        margin: 12mm 15mm;
    }

    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

    body { background: white !important; margin: 0; padding: 0; }

    .sidebar, .topbar, .right-sidebar, .no-print, .bill-actions, .sidebar-overlay,
    .page-header, .app-layout > .sidebar-overlay, .filter-bar, .sidebar-toggle-btn { display: none !important; }

    .app-layout, .main-wrapper, .content-area, .main-content {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    .bill-a4-wrapper {
        display: block;
    }

    .bill-a4-page {
        width: 100%;
        padding: 0;
        border: none !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        margin: 0;
    }

    .bill-table th {
        background: #f0f0f0 !important;
    }

    .no-print-link { display: none !important; }
    .print-only-text { display: inline !important; }

    .card { box-shadow: none; border: none; padding: 0; margin: 0; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
    .right-sidebar { display: none; }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.active {
        display: block;
    }

    .main-wrapper {
        margin-left: 0;
    }

    .mobile-toggle {
        display: flex;
    }

    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .stats-grid-3 { grid-template-columns: repeat(3, 1fr); }

    .main-content { padding: 1rem; }

    .page-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }

    .form-row { grid-template-columns: 1fr; }

    .search-bar { flex-direction: column; }

    .filter-bar-row { flex-wrap: wrap; padding: 0.75rem; gap: 0.5rem; }
    .filter-label { display: none; }
    .filter-tabs { width: 100%; justify-content: center; }
    .filter-controls { width: 100%; flex-wrap: wrap; justify-content: stretch; }
    .filter-form { flex: 1; min-width: 0; }
    .filter-form .filter-input { width: 100%; }
    .filter-range { flex: 2; flex-wrap: wrap; }
    .filter-range .filter-input { flex: 1; min-width: 90px; }
    .report-grid { grid-template-columns: 1fr; }

    .sidebar-toggle-btn { display: none !important; }
}

@media (max-width: 480px) {
    .stats-grid, .stats-grid-3 { grid-template-columns: 1fr 1fr; }
    .earnings-grid { grid-template-columns: 1fr 1fr; }
    .stat-value { font-size: 1.25rem; }
    .earnings-value { font-size: 1.25rem; }
    table th, table td { padding: 0.5rem 0.5rem; font-size: 0.8125rem; }
}

.bill-modern {
    font-family: 'Inter', sans-serif;
    border: 2px solid #2563eb;
    border-radius: 4px;
}
.bill-modern .bill-letterhead {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}
.bill-modern .bill-letterhead-text {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
    background: #f0f5ff;
    border-radius: 4px 4px 0 0;
    padding: 0.75rem 1rem;
}
.bill-modern .bill-letterhead-text .bill-letterhead-name {
    color: #1e40af;
}
.bill-modern .bill-info-table {
    background: #2563eb !important;
    color: #fff;
    padding: 4mm;
    border-radius: 0;
    margin-bottom: 6mm;
    border-collapse: separate !important;
    border-spacing: 0;
}
.bill-modern .bill-info-table td {
    color: #fff !important;
    padding: 3px 4mm !important;
    border: none !important;
    background: #2563eb !important;
}
.bill-modern .bill-info-table strong {
    color: #fff !important;
    font-weight: 700;
}
.bill-modern .bill-table tbody td {
    border-color: #e5e7eb;
    color: #1f2937;
}
.bill-modern .bill-table {
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}
.bill-modern .bill-table thead {
    background: #2563eb;
}
.bill-modern .bill-table thead th {
    color: #fff !important;
    background: #2563eb !important;
    border-color: #3b82f6;
    font-weight: 600;
}
.bill-modern .bill-table tbody tr:nth-child(even) {
    background: #f8fafc;
}
.bill-modern table:last-of-type td {
    border: none !important;
}
@media print {
    .bill-modern {
        border: 2px solid #2563eb !important;
    }
    .bill-modern .bill-info-table {
        background: #2563eb !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .bill-modern .bill-info-table td {
        color: #fff !important;
        background: #2563eb !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .bill-modern .bill-info-table strong {
        color: #fff !important;
    }
    .bill-modern .bill-table thead {
        background: #2563eb !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .bill-modern .bill-table thead th {
        color: #fff !important;
    }
    .bill-modern .bill-table tbody td {
        color: #1f2937 !important;
    }
}

/* ===== CLASSIC TEMPLATE ===== */
.bill-classic {
    font-family: Georgia, 'Times New Roman', Times, serif;
    border-top: 4px double #5c1a1a;
    border-bottom: 4px double #5c1a1a;
    border-left: 1px solid #d4c5a9;
    border-right: 1px solid #d4c5a9;
}
.bill-classic .bill-letterhead {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}
.bill-classic .bill-letterhead-text {
    flex-direction: row-reverse;
    border-bottom: 3px double #5c1a1a;
    margin-bottom: 0;
    padding-bottom: 0.75rem;
}
.bill-classic .bill-letterhead-text .lh-logo-col {
    padding-right: 0;
    padding-left: 1rem;
    border-right: none;
    border-left: 1.5px solid #d4c5a9;
}
.bill-classic .bill-letterhead-text .lh-info-col {
    text-align: right;
}
.bill-classic .bill-letterhead-name {
    color: #5c1a1a;
    font-family: Georgia, 'Times New Roman', Times, serif;
    letter-spacing: 2px;
}
.bill-classic .lh-detail-item {
    color: #6b5b3e;
}
.bill-classic .bill-info-table td {
    border: none !important;
    padding: 3px 4mm !important;
    color: #3d2b1f !important;
}
.bill-classic .bill-info-table strong {
    color: #5c1a1a !important;
}
.bill-classic .bill-table {
    border: 1px solid #b8a88a;
}
.bill-classic .bill-table thead {
    background: #f5f0e8;
}
.bill-classic .bill-table thead th {
    color: #5c1a1a !important;
    border: 1px solid #b8a88a;
    border-bottom: 3px double #5c1a1a;
    font-family: Georgia, 'Times New Roman', Times, serif;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: #f5f0e8 !important;
}
.bill-classic .bill-table tbody td {
    border-color: #d4c5a9;
    color: #3d2b1f;
}
.bill-classic .bill-table tbody tr:nth-child(even) {
    background: #faf8f4;
}
.bill-classic .bill-summary-row {
    border-bottom-color: #d4c5a9;
}
.bill-classic .bill-summary-row.bill-summary-total {
    border-top-color: #5c1a1a;
    color: #5c1a1a;
}
.bill-classic .signature-line {
    border-bottom-color: #5c1a1a;
}

@media print {
    .bill-classic {
        border-top: 4px double #5c1a1a !important;
        border-bottom: 4px double #5c1a1a !important;
    }
    .bill-classic .bill-table thead {
        background: #f5f0e8 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .bill-classic .bill-table thead th {
        color: #5c1a1a !important;
        background: #f5f0e8 !important;
    }
    .bill-classic .bill-table tbody tr:nth-child(even) {
        background: #faf8f4 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ===== PROFESSIONAL TEMPLATE ===== */
.bill-professional {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    border: 1px solid #e2e8f0;
}
.bill-professional .bill-letterhead {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}
.bill-professional .bill-letterhead-text {
    background: #1e293b;
    color: #fff;
    padding: 1rem 1.25rem;
    border-bottom: none;
    margin-bottom: 0;
    border-radius: 0;
}
.bill-professional .bill-letterhead-text .lh-logo-col {
    border-right-color: rgba(255,255,255,0.2);
}
.bill-professional .bill-letterhead-name {
    color: #fff;
}
.bill-professional .lh-detail-item {
    color: #cbd5e1;
}
.bill-professional .lh-detail-item.lh-gst {
    color: #e2e8f0;
}
.bill-professional .bill-info-table {
    background: #f8fafc !important;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 6mm;
}
.bill-professional .bill-info-table td {
    border: none !important;
    padding: 4px 4mm !important;
    color: #334155 !important;
}
.bill-professional .bill-info-table strong {
    color: #1e293b !important;
}
.bill-professional .bill-table {
    border: 1px solid #e2e8f0;
}
.bill-professional .bill-table thead {
    background: #1e293b;
}
.bill-professional .bill-table thead th {
    color: #fff !important;
    border: 1px solid #334155;
    font-weight: 600;
    letter-spacing: 0.05em;
    background: #1e293b !important;
}
.bill-professional .bill-table tbody td {
    border-color: #e2e8f0;
    color: #1e293b;
}
.bill-professional .bill-table tbody tr:nth-child(even) {
    background: #f8fafc;
}
.bill-professional .bill-summary-row {
    border-bottom-color: #e2e8f0;
}
.bill-professional .bill-summary-row.bill-summary-total {
    border-top-color: #1e293b;
    color: #1e293b;
}
.bill-professional .signature-line {
    border-bottom-color: #1e293b;
}
.bill-professional .bill-footer-section {
    border-top: 2px solid #e2e8f0;
    padding-top: 4mm;
}

@media print {
    .bill-professional .bill-letterhead-text {
        background: #1e293b !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .bill-professional .bill-letterhead-name {
        color: #fff !important;
    }
    .bill-professional .lh-detail-item {
        color: #cbd5e1 !important;
    }
    .bill-professional .lh-detail-item.lh-gst {
        color: #e2e8f0 !important;
    }
    .bill-professional .bill-info-table td {
        color: #334155 !important;
    }
    .bill-professional .bill-info-table strong {
        color: #1e293b !important;
    }
    .bill-professional .bill-table thead {
        background: #1e293b !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .bill-professional .bill-table thead th {
        color: #fff !important;
        background: #1e293b !important;
    }
    .bill-professional .bill-table tbody td {
        color: #1e293b !important;
    }
    .bill-professional .bill-table tbody tr:nth-child(even) {
        background: #f8fafc !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .bill-professional .bill-info-table {
        background: #f8fafc !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ===== ELEGANT TEMPLATE ===== */
.bill-elegant {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    border: none;
    border-top: 3px solid #0d9488;
}
.bill-elegant .bill-letterhead {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}
.bill-elegant .bill-letterhead-text {
    flex-direction: column;
    align-items: center;
    text-align: center;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 0;
    padding-bottom: 1rem;
    gap: 0.5rem;
}
.bill-elegant .bill-letterhead-text .lh-logo-col {
    padding-right: 0;
    border-right: none;
    margin-bottom: 0.25rem;
}
.bill-elegant .bill-letterhead-text .lh-info-col {
    text-align: center;
}
.bill-elegant .lh-details {
    align-items: center;
}
.bill-elegant .bill-letterhead-name {
    color: #0f766e;
    letter-spacing: 3px;
    font-weight: 700;
}
.bill-elegant .lh-detail-item {
    color: #64748b;
}
.bill-elegant .bill-info-table {
    margin-bottom: 6mm;
}
.bill-elegant .bill-info-table td {
    border: none !important;
    padding: 4px 4mm !important;
    color: #475569 !important;
}
.bill-elegant .bill-info-table strong {
    color: #0f766e !important;
}
.bill-elegant .bill-table {
    border: none;
}
.bill-elegant .bill-table thead {
    background: transparent;
}
.bill-elegant .bill-table thead th {
    background: transparent !important;
    color: #0f766e !important;
    border: none;
    border-bottom: 2px solid #0d9488;
    font-weight: 600;
    letter-spacing: 0.06em;
    padding: 8px 10px;
}
.bill-elegant .bill-table tbody td {
    border: none;
    border-bottom: 1px solid #f1f5f9;
    padding: 8px 10px;
    color: #334155;
}
.bill-elegant .bill-table tbody tr:last-child td {
    border-bottom: 1px solid #e2e8f0;
}
.bill-elegant .bill-table tbody tr:nth-child(even) {
    background: transparent;
}
.bill-elegant .bill-summary-row {
    border-bottom-color: #f1f5f9;
}
.bill-elegant .bill-summary-row.bill-summary-total {
    border-top: 2px solid #0d9488;
    color: #0f766e;
}
.bill-elegant .signature-line {
    border-bottom-color: #0d9488;
}
.bill-elegant .bill-footer-section {
    margin-top: 25mm;
}

@media print {
    .bill-elegant {
        border-top: 3px solid #0d9488 !important;
    }
    .bill-elegant .bill-table thead th {
        color: #0f766e !important;
        border-bottom: 2px solid #0d9488 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
