/* ==========================================================================
   AURA JEWELS - DELIVERY CHALLAN & INVENTORY SYSTEM STYLESHEET
   ========================================================================== */

:root {
    /* Color Palette */
    --bg-dark: #090D16;
    --bg-card: #121827;
    --bg-card-hover: #1A2235;
    --bg-input: #1A2234;
    --border-color: #2D3748;
    --border-gold: rgba(212, 175, 55, 0.35);
    
    /* Gold Accents */
    --gold-primary: #D4AF37;
    --gold-light: #F3E5AB;
    --gold-dark: #AA7C11;
    --gold-gradient: linear-gradient(135deg, #BF953F 0%, #FCF6BA 25%, #B38728 50%, #FBF5B7 75%, #AA771C 100%);
    
    /* Text Colors */
    --text-main: #F1F5F9;
    --text-muted: #94A3B8;
    --text-dim: #64748B;
    
    /* Status Colors */
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #3B82F6;
    --purple: #8B5CF6;

    /* Fonts & Radii */
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-main: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
    --shadow-gold: 0 0 15px rgba(212, 175, 55, 0.25);
}

/* Reset & Global */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--text-main);
    font-weight: 600;
}

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

.gold-icon {
    color: var(--gold-primary);
}

.text-green { color: var(--success); }
.text-blue { color: var(--info); }
.text-right { text-align: right; }
.required::after { content: " *"; color: var(--danger); }

/* Layout App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header Navbar */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(18, 24, 39, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-gold);
    padding: 0.75rem 1.75rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-logo i {
    font-size: 1.8rem;
}

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

.brand-name {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 1px;
    background: var(--gold-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

/* Navigation Tabs */
.header-nav {
    display: flex;
    gap: 0.5rem;
    background: rgba(10, 14, 23, 0.6);
    padding: 0.35rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.nav-btn.active {
    background: var(--gold-primary);
    color: #000;
    font-weight: 600;
    box-shadow: var(--shadow-gold);
}

.nav-btn.hidden {
    display: none !important;
}

/* Header Right Options */
.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.role-selector-card {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-md);
}

.role-icon {
    color: var(--gold-primary);
    font-size: 1.1rem;
}

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

.role-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.role-dropdown {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
}

.role-dropdown option {
    background: var(--bg-card);
    color: var(--text-main);
}

.sync-badge {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
}

.sync-badge.synced {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.4);
    color: var(--success);
}

.sync-badge.syncing {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: var(--warning);
}

/* App Main Content & Tabs */
.app-content {
    flex: 1;
    padding: 1.75rem 2rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

.tab-pane {
    display: none;
    animation: fadeIn 0.25s ease-in-out;
}

.tab-pane.active {
    display: block;
}

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

/* Section Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 1rem;
}

.page-header h2 {
    font-size: 1.6rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.section-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.2rem;
}

.action-buttons {
    display: flex;
    gap: 0.75rem;
}

/* Buttons System */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background: var(--gold-primary);
    color: #000;
}
.btn-primary:hover {
    background: #e5be3c;
    box-shadow: var(--shadow-gold);
}

.btn-glow {
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.4);
}

.btn-gold {
    background: rgba(212, 175, 55, 0.15);
    color: var(--gold-primary);
    border: 1px solid var(--border-gold);
}
.btn-gold:hover {
    background: var(--gold-primary);
    color: #000;
}

.btn-secondary {
    background: #2D3748;
    color: var(--text-main);
}
.btn-secondary:hover {
    background: #3F4D63;
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}
.btn-ghost:hover {
    border-color: var(--text-muted);
    color: var(--text-main);
}

.btn-green {
    background: #10B981;
    color: #fff;
}
.btn-green:hover { background: #059669; }

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

.btn-icon {
    padding: 0.5rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
}

/* KPI Cards Grid */
.kpi-grid, .dashboard-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 1200px) {
    .kpi-grid, .dashboard-kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .kpi-grid, .dashboard-kpi-grid {
        grid-template-columns: 1fr;
    }
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    box-shadow: var(--shadow-main);
}

.kpi-icon, .kpi-icon-box {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}
.kpi-icon.gold, .bg-gold-subtle { background: rgba(212, 175, 55, 0.15); color: var(--gold-primary); }
.kpi-icon.blue, .bg-blue-subtle { background: rgba(59, 130, 246, 0.15); color: var(--info); }
.kpi-icon.green, .bg-green-subtle { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.kpi-icon.purple, .bg-purple-subtle { background: rgba(139, 92, 246, 0.15); color: var(--purple); }

.kpi-data, .kpi-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.kpi-value {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.2;
}

.kpi-title {
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* Filter & Search Bar */
.filter-card, .table-toolbar {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    padding: 0.5rem 0.9rem;
    border-radius: var(--radius-sm);
    flex: 1;
    min-width: 260px;
}

.search-box input {
    background: transparent;
    border: none;
    color: var(--text-main);
    outline: none;
    width: 100%;
    font-family: var(--font-body);
}

.select-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.select-box select, input, textarea {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s ease;
}

select:focus, input:focus, textarea:focus {
    border-color: var(--gold-primary);
}

/* Cards & Tables */
.shadow-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-main);
}

.card-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.88rem;
}

.data-table th {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    font-weight: 600;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    vertical-align: middle;
}

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

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success { background: rgba(16, 185, 129, 0.15); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-info { background: rgba(59, 130, 246, 0.15); color: var(--info); border: 1px solid rgba(59, 130, 246, 0.3); }
.badge-purple { background: rgba(139, 92, 246, 0.15); color: var(--purple); border: 1px solid rgba(139, 92, 246, 0.3); }

/* Form Grids & Layouts */
.form-grid {
    display: grid;
    gap: 1.25rem;
}
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-group label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
}

.required::after, th.required::after {
    content: " *";
    color: #ef4444;
    font-weight: bold;
}

.input-readonly {
    background: rgba(255, 255, 255, 0.03) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    color: var(--gold-primary) !important;
    font-weight: 700;
}

.input-hint {
    font-size: 0.72rem;
    color: var(--text-dim);
}

.highlight-select {
    border-color: var(--border-gold) !important;
    background: rgba(212, 175, 55, 0.05) !important;
}

/* Recipient Address Preview Box */
.address-preview-card {
    margin-top: 1rem;
    background: rgba(212, 175, 55, 0.04);
    border: 1px dashed var(--border-gold);
    border-radius: var(--radius-sm);
    padding: 1rem 1.25rem;
}

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

.preview-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.preview-text {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-main);
    margin-top: 0.2rem;
}

/* Jewellery Item Grid Table */
.table-responsive {
    overflow-x: auto;
    margin: 0 -1.5rem;
    padding: 0 1.5rem;
}

.grid-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1200px;
}

.grid-table th {
    background: #1A2234;
    color: var(--gold-light);
    font-size: 0.75rem;
    padding: 0.6rem;
    border: 1px solid var(--border-color);
    text-align: center;
}

.grid-table td {
    border: 1px solid var(--border-color);
    padding: 0.4rem;
    vertical-align: middle;
}

.grid-table input, .grid-table select {
    width: 100%;
    padding: 0.35rem 0.4rem;
    font-size: 0.82rem;
    border-radius: 4px;
}

.item-val-input {
    background: rgba(212, 175, 55, 0.08) !important;
    font-weight: 700;
    color: var(--gold-primary);
}

/* Summary Grid Footer */
.form-summary-grid {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 2rem;
}

.summary-totals-box {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    font-size: 0.88rem;
    color: var(--text-muted);
}

.divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 0.75rem 0;
}

.grand-total-row {
    font-size: 1.2rem;
    color: var(--text-main);
    padding-top: 0.75rem;
    border-top: 2px solid var(--border-gold);
}

.amount-words-box {
    margin-top: 1rem;
    background: rgba(212, 175, 55, 0.06);
    border: 1px solid var(--border-gold);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
}

.amount-words-text {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--gold-light);
    margin-top: 0.2rem;
}

/* Sub Navigation Tabs for Masters */
.sub-nav-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.sub-tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
}

.sub-tab-btn.active {
    background: rgba(212, 175, 55, 0.15);
    color: var(--gold-primary);
    border: 1px solid var(--border-gold);
}

.subtab-pane {
    display: none;
}

.subtab-pane.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

.subtab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

/* Party Cards List */
.party-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(450px, 1fr));
    gap: 1.5rem;
}

.party-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: var(--shadow-main);
}

.party-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 0.75rem;
}

.party-meta {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.address-item-chip {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    margin-top: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Modals System */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1.5rem;
}

.hidden, .modal-overlay.hidden {
    display: none !important;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-gold);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 550px;
    padding: 1.75rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
    max-height: 90vh;
    overflow-y: auto;
}

.max-w-700 { max-width: 700px; }
.max-w-800 { max-width: 800px; }
.max-w-900 { max-width: 950px; }
.max-w-fullscreen { max-width: 95vw; width: 95vw; max-height: 92vh; }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 0.75rem;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}
.modal-close:hover { color: var(--text-main); }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 1rem;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 2000;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-main);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.88rem;
    animation: slideIn 0.3s ease;
}

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-info { border-left: 4px solid var(--info); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Code Snippet Box */
.code-preview-container {
    background: #0B0E17;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1rem;
    max-height: 320px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 0.78rem;
    color: #A7F3D0;
}

.sheets-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    font-size: 0.85rem;
    margin-top: 0.75rem;
}

.sheets-list code {
    color: var(--gold-primary);
    background: rgba(212, 175, 55, 0.1);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
}

.header-logo-img {
    max-height: 38px;
    max-width: 120px;
    object-fit: contain;
    border-radius: 4px;
}

.logo-preview-box {
    width: 60px;
    height: 40px;
    border: 1px dashed var(--border-color);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.2);
}

.logo-preview-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.permission-checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    background: rgba(0, 0, 0, 0.2);
    padding: 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.chk-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    cursor: pointer;
    color: var(--text-main);
}

.chk-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--gold-primary);
    cursor: pointer;
}

.hidden { display: none !important; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.my-4 { margin-top: 1rem; margin-bottom: 1rem; }

/* ==========================================================================
   PRINT & PDF SPECIFIC STYLES
   ========================================================================== */
.pdf-container-scroll {
    max-height: 75vh;
    overflow-y: auto;
    background: #fff;
    padding: 1.5rem;
    border-radius: var(--radius-sm);
}

.printable-doc, .pdf-container {
    background: transparent;
    color: #1a1a1a;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10px;
    line-height: 1.35;
    width: 100% !important;
    max-width: 190mm !important;
    box-sizing: border-box !important;
    margin: 0 auto !important;
    border: none !important;
    padding: 0 !important;
}

.pdf-page-copy {
    background: #ffffff !important;
    color: #1a1a1a !important;
    font-family: Arial, Helvetica, sans-serif;
    padding: 8mm !important;
    font-size: 10px;
    line-height: 1.35;
    border: none !important;
    width: 100% !important;
    max-width: 190mm !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8) !important;
    border-radius: 4px !important;
    box-sizing: border-box !important;
    margin: 0 auto 24px auto !important;
    position: relative;
    page-break-after: always;
    break-after: page;
    page-break-inside: avoid;
    break-inside: avoid;
}

.pdf-page-copy:last-child {
    margin-bottom: 0 !important;
    page-break-after: avoid;
    break-after: avoid;
}

.doc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2px solid #000;
    padding-bottom: 10px;
}

.doc-brand-left {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.pdf-logo-img {
    max-height: 50px;
    max-width: 140px;
    object-fit: contain;
}

.doc-company h1 {
    font-size: 16px;
    color: #000;
    margin-bottom: 2px;
    font-weight: 700;
}

.pdf-trade-sub {
    font-size: 10px;
    color: #444;
    font-style: italic;
}

.doc-company p {
    color: #444;
    font-size: 10px;
}

.doc-title-badge {
    text-align: right;
}

.doc-title-badge h2 {
    font-size: 16px;
    color: #000;
}

.rule-ref {
    font-size: 9px;
    color: #666;
}

.copy-type {
    font-size: 9px;
    font-weight: bold;
    border: 1px solid #000;
    padding: 2px 6px;
    display: inline-block;
    margin-top: 4px;
}

.doc-meta-grid, .doc-address-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.meta-box, .address-box {
    border: 1px solid #ccc;
    padding: 8px;
    border-radius: 4px;
    background: #fafafa;
}

.address-box h4 {
    font-size: 10px;
    color: #666;
    border-bottom: 1px solid #eee;
    padding-bottom: 4px;
    margin-bottom: 4px;
}

.meta-table {
    width: 100%;
}
.meta-table td {
    padding: 2px 4px;
}

.doc-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    margin-top: 10px;
}

.doc-table th {
    background: #f0f0f0;
    border: 1px solid #000;
    padding: 5px 2px;
    font-size: 8.5px;
    overflow: hidden;
    word-wrap: break-word;
}

.doc-table td {
    border: 1px solid #ccc;
    padding: 4px 2px;
    text-align: center;
    font-size: 8.5px;
    word-wrap: break-word;
    overflow: hidden;
}

.doc-summary-grid {
    display: grid;
    grid-template-columns: 1fr 230px;
    gap: 12px;
}

.terms-heading {
    font-size: 9.5px;
    font-weight: bold;
    margin-bottom: 3px;
}

.terms-text {
    font-size: 9px;
    color: #222;
    line-height: 1.45;
    word-break: break-word;
    margin-bottom: 6px;
}

.bank-details-pdf-box {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 9.5px;
}

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

.totals-table td {
    padding: 4px 6px;
    border-bottom: 1px solid #eee;
    text-align: right;
}

.grand-row td {
    border-top: 2px solid #000;
    font-size: 12px;
    color: #000;
}

.doc-words-bar {
    background: #f5f5f5;
    border: 1px solid #ddd;
    padding: 6px;
    font-size: 10px;
}

.doc-signatures {
    display: flex;
    justify-content: space-between;
}

.sig-box {
    width: 220px;
    font-size: 9.5px;
}

.pdf-footer-note {
    border-top: 1px solid #eee;
    padding-top: 6px;
    color: #777;
    font-size: 8.5px;
}

.pdf-cancelled-watermark {
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-35deg);
    font-size: 58px;
    font-weight: 900;
    color: rgba(220, 38, 38, 0.28);
    border: 6px dashed rgba(220, 38, 38, 0.35);
    padding: 10px 36px;
    text-transform: uppercase;
    letter-spacing: 6px;
    pointer-events: none;
    z-index: 999;
    border-radius: 8px;
    font-family: 'Outfit', sans-serif;
    white-space: nowrap;
}

.pdf-cancelled-banner {
    background: #dc2626;
    color: #ffffff;
    text-align: center;
    font-weight: 800;
    font-size: 11px;
    padding: 4px 10px;
    margin-bottom: 8px;
    letter-spacing: 1px;
    text-transform: uppercase;
    border-radius: 3px;
}

/* GRANULAR USER RIGHTS & PERMISSION MATRIX STYLES */
.perm-preset-bar {
    display: flex;
    gap: 6px;
    align-items: center;
}

.permission-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.permission-card {
    background: var(--bg-card-alt, #1e293b);
    border: 1px solid var(--border-color, #334155);
    border-radius: 6px;
    padding: 10px 14px;
}

.permission-card-header {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-gold, #f59e0b);
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.permission-checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.perm-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px 6px;
    background: rgba(0,0,0,0.15);
    border-radius: 4px;
}

.perm-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted, #94a3b8);
}

.perm-options {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
}

.perm-options label {
    font-size: 0.8rem;
    color: var(--text-color, #f8fafc);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin: 0;
}

.perm-options input[type="checkbox"] {
    accent-color: var(--accent-gold, #f59e0b);
    width: 15px;
    height: 15px;
    cursor: pointer;
}

@page {
    size: A4 portrait;
    margin: 0mm;
}

@media print {
    html, body {
        width: 210mm !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
        overflow: visible !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

@media print {
    @page {
        size: A4 portrait;
        margin: 0;
    }

    body {
        background: #ffffff !important;
        color: #000000 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Isolated Root Print Mount Rules for window.print() */
    body.in-standalone-print-mode > *:not(#standalone-print-root) {
        display: none !important;
    }

    body.in-standalone-print-mode #standalone-print-root {
        display: block !important;
        visibility: visible !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        background: #ffffff !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    body.in-standalone-print-mode #standalone-print-root * {
        visibility: visible !important;
    }

    /* Collapse all background app headers, tabs, content sections, and toasts to ZERO height */
    .app-header, .app-content, .toast-container, .firebase-lock-banner, .modal-header, .pdf-modal-card > .modal-header, .action-buttons {
        display: none !important;
    }

    .modal-overlay, .modal-card, .pdf-modal-card, .pdf-container-scroll, #modal-declaration-pdf, #modal-challan-pdf, #modal-pdf {
        position: static !important;
        display: block !important;
        background: #ffffff !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        box-shadow: none !important;
        max-height: none !important;
        max-width: 100% !important;
        width: 100% !important;
        overflow: visible !important;
        height: auto !important;
        transform: none !important;
    }

    #printable-challan, #printable-challan *, 
    .pdf-container, .pdf-container *, 
    .pdf-page-copy, .pdf-page-copy *,
    #printable-declaration-document, #printable-declaration-document *,
    .printable-document, .printable-document *,
    .letterhead-document, .letterhead-document * {
        visibility: visible !important;
    }

    #printable-challan, .pdf-container, #printable-declaration-document, .printable-document, .letterhead-document {
        position: relative !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        max-width: 190mm !important;
        margin: 0 auto !important;
        padding: 0 !important;
        box-sizing: border-box !important;
        border: none !important;
        background: #ffffff !important;
        color: #000000 !important;
        box-shadow: none !important;
    }

    .pdf-page-copy {
        position: relative !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        max-width: 190mm !important;
        margin: 0 auto !important;
        padding: 6mm 8mm !important;
        box-sizing: border-box !important;
        border: none !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        background: #ffffff !important;
        color: #000000 !important;
        page-break-after: always !important;
        break-after: page !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    .pdf-page-copy:last-child {
        page-break-after: avoid !important;
        break-after: avoid !important;
    }

    .doc-table th {
        background-color: #f0f0f0 !important;
        color: #000000 !important;
        border: 1px solid #000000 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .doc-table td {
        border: 1px solid #444444 !important;
        color: #000000 !important;
    }

    .copy-type, .doc-words-bar, .bank-details-pdf-box {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .modal-header, .modal-footer, .app-header, .app-sidebar, .tab-pane, .toast, .action-buttons {
        display: none !important;
    }
}

