/* ==========================================================================
   DESIGN SYSTEM & VARIABLES
   ========================================================================== */
:root {
    /* Fonts */
    --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    
    /* Layout */
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 20px;
    --transition-speed: 0.25s;
    --transition-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    
    /* DANFE Styling Variables (standardized for realistic invoice print/view) */
    --danfe-bg: #ffffff;
    --danfe-text: #000000;
    --danfe-border-color: #000000;
    --danfe-font: Courier, monospace;
}

/* Dark Theme (Default) */
body.dark-theme {
    --bg-app: #090a0f;
    --bg-surface: #121420;
    --bg-surface-elevated: #1a1d2e;
    --bg-input: #171926;
    
    --border-color: #23273a;
    --border-color-hover: #373d5a;
    
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --primary: #06b6d4;
    --primary-rgb: 6, 182, 212;
    --primary-hover: #0891b2;
    
    --secondary: #8b5cf6;
    --secondary-rgb: 139, 92, 246;
    
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.6);
    --glass-blur: blur(12px);
    --glass-bg: rgba(18, 20, 32, 0.7);
}

/* Light Theme */
body.light-theme {
    --bg-app: #f4f6fa;
    --bg-surface: #ffffff;
    --bg-surface-elevated: #fcfdfe;
    --bg-input: #f1f3f7;
    
    --border-color: #e2e8f0;
    --border-color-hover: #cbd5e1;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --primary: #0891b2;
    --primary-rgb: 8, 145, 178;
    --primary-hover: #0e7490;
    
    --secondary: #7c3aed;
    --secondary-rgb: 124, 58, 237;
    
    --success: #059669;
    --danger: #dc2626;
    --warning: #d97706;
    
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 16px 48px rgba(15, 23, 42, 0.12);
    --glass-blur: blur(12px);
    --glass-bg: rgba(255, 255, 255, 0.8);
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-app);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background-color var(--transition-speed), color var(--transition-speed);
    overflow-x: hidden;
}

select option {
    background-color: var(--bg-surface-elevated);
    color: var(--text-primary);
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Scrollbar Styles */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-app);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--border-color-hover);
}

/* Card Style Utility */
.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    transition: transform var(--transition-speed), border-color var(--transition-speed), box-shadow var(--transition-speed);
}

.card:hover {
    border-color: var(--border-color-hover);
    box-shadow: var(--shadow-md);
}

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

.btn-secondary {
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}
.btn-secondary:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
}

.btn-danger {
    background-color: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
}
.btn-danger:hover {
    background-color: var(--danger);
    color: white;
    transform: translateY(-1px);
}

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

.btn-icon {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition-speed);
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-icon:hover {
    border-color: var(--primary);
    color: var(--primary);
    background-color: rgba(var(--primary-rgb), 0.08);
}

.badge {
    background-color: rgba(var(--primary-rgb), 0.15);
    color: var(--primary);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
}

/* ==========================================================================
   HEADER SECTION
   ========================================================================== */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 20px;
}

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

.logo-icon {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 10px;
    border-radius: var(--border-radius-md);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-text h1 {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(to right, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-text .sub-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    display: block;
}

/* ==========================================================================
   UPLOAD / DROP ZONE
   ========================================================================== */
.upload-section {
    padding: 12px;
}

.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    position: relative;
    background-color: rgba(var(--primary-rgb), 0.01);
    transition: all var(--transition-speed);
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--primary);
    background-color: rgba(var(--primary-rgb), 0.04);
    box-shadow: 0 0 15px rgba(var(--primary-rgb), 0.15);
}

.file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.upload-icon {
    color: var(--primary);
    margin-bottom: 16px;
    opacity: 0.8;
    transition: transform var(--transition-speed);
}

.drop-zone:hover .upload-icon {
    transform: translateY(-4px);
    opacity: 1;
}

.drop-zone h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.drop-zone p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.drop-zone p span {
    color: var(--primary);
    font-weight: 600;
    text-decoration: underline;
}

.drop-zone .info-tag {
    font-size: 0.75rem;
    color: var(--text-muted);
    background-color: var(--bg-surface-elevated);
    padding: 4px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

/* ==========================================================================
   DASHBOARD SECTION
   ========================================================================== */
.dashboard-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
    animation: fadeIn var(--transition-speed) ease;
}

/* KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.kpi-card {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 20px;
}

.kpi-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius-sm);
    color: white;
}

.kpi-icon.total-invoices {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

.kpi-icon.total-amount {
    background: linear-gradient(135deg, #10b981, #047857);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.kpi-icon.total-taxes {
    background: linear-gradient(135deg, #f59e0b, #b45309);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}

.kpi-icon.total-products {
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.25);
}

.kpi-data {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.kpi-title {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kpi-value {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

/* Charts */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 20px;
}

@media (max-width: 768px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

.chart-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chart-card h3 {
    font-size: 1rem;
    font-weight: 700;
    border-left: 3px solid var(--primary);
    padding-left: 8px;
}

.chart-wrapper {
    position: relative;
    width: 100%;
    height: 250px;
}

/* ==========================================================================
   FILTERS & TABLE SECTION
   ========================================================================== */
.table-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: fadeIn var(--transition-speed) ease;
}

.table-header-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
}

.table-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.table-title h2 {
    font-size: 1.15rem;
    font-weight: 800;
}

.table-actions {
    display: flex;
    gap: 10px;
}

/* Filters */
.filters-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 16px;
}

.search-box {
    position: relative;
    width: 100%;
}

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

.search-box input {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 12px 12px 12px 42px;
    font-family: var(--font-main);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all var(--transition-speed);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.filter-group select, .filter-group input {
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 10px;
    font-family: var(--font-main);
    color: var(--text-primary);
    font-size: 0.8rem;
    outline: none;
    transition: border-color var(--transition-speed);
}

.filter-group select:focus, .filter-group input:focus {
    border-color: var(--primary);
}

/* Responsive Table */
.table-responsive {
    overflow-x: auto;
    width: 100%;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
}

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

.data-table th {
    background-color: var(--bg-surface-elevated);
    color: var(--text-secondary);
    font-weight: 700;
    padding: 14px 16px;
    border-bottom: 2px solid var(--border-color);
    cursor: pointer;
    user-select: none;
    transition: background-color var(--transition-speed);
}

.data-table th:hover {
    background-color: var(--bg-input);
    color: var(--text-primary);
}

.data-table th .sort-icon::after {
    content: " ↕";
    font-size: 0.75rem;
    opacity: 0.4;
}

.data-table th.sort-asc .sort-icon::after {
    content: " ▲";
    opacity: 1;
    color: var(--primary);
}

.data-table th.sort-desc .sort-icon::after {
    content: " ▼";
    opacity: 1;
    color: var(--primary);
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    max-width: 250px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-table tbody tr {
    transition: background-color var(--transition-speed);
}

.data-table tbody tr:hover {
    background-color: rgba(var(--primary-rgb), 0.03);
}

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

.data-table .action-cell {
    white-space: nowrap;
}

/* Pagination Panel */
.pagination-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    padding-top: 12px;
}

.pagination-info {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* ==========================================================================
   EMPTY STATE
   ========================================================================== */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.empty-illustration {
    color: var(--text-muted);
    background-color: var(--bg-surface-elevated);
    padding: 20px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    margin-bottom: 8px;
}

.empty-state h2 {
    font-size: 1.25rem;
    font-weight: 700;
}

.empty-state p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    max-width: 420px;
    line-height: 1.5;
}

/* ==========================================================================
   DETAILED XML MODAL VIEWER
   ========================================================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: none;
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: var(--glass-blur);
    animation: fadeIn var(--transition-speed) ease;
}

.modal-container {
    position: relative;
    width: 92%;
    max-width: 1200px;
    height: 90vh;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1001;
    animation: slideUp 0.3s var(--transition-bounce);
}

.modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-surface-elevated);
}

.modal-header-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-header-title h2 {
    font-size: 1.15rem;
    font-weight: 800;
}

.modal-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-tabs {
    display: flex;
    background-color: var(--bg-surface-elevated);
    border-bottom: 1px solid var(--border-color);
    padding: 0 16px;
    gap: 8px;
    overflow-x: auto;
}

.tab-btn {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 14px 16px;
    font-family: var(--font-main);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-speed);
    white-space: nowrap;
}

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

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.modal-body {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    background-color: var(--bg-app);
}

.tab-content {
    display: none;
    animation: fadeIn var(--transition-speed) ease;
}

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

/* Grid layout in modal */
.grid-2-col {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

@media (max-width: 768px) {
    .grid-2-col {
        grid-template-columns: 1fr;
    }
}

.card-inner {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.card-inner h3 {
    font-size: 1rem;
    font-weight: 700;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 6px;
}

.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }

/* ==========================================================================
   DANFE PAPER VIEW
   ========================================================================== */
.danfe-paper {
    background-color: var(--danfe-bg);
    color: var(--danfe-text);
    padding: 15px;
    border: 1px solid var(--danfe-border-color);
    border-radius: 2px;
    font-family: var(--danfe-font);
    font-size: 8px;
    line-height: 1.1;
    width: 100%;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    margin: 0 auto;
    max-width: 950px;
}

.danfe-paper * {
    font-family: var(--danfe-font) !important;
}

.danfe-header-block {
    display: grid;
    grid-template-columns: 3fr 2fr 3.5fr;
    border: 1px solid var(--danfe-border-color);
    margin-bottom: 4px;
}

.danfe-logo-area {
    display: flex;
    padding: 4px;
    border-right: 1px solid var(--danfe-border-color);
    gap: 8px;
}

.danfe-mock-logo {
    width: 48px;
    height: 48px;
    border: 1px solid var(--danfe-border-color);
    font-weight: 900;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
}

.danfe-emitente-info h3 {
    font-size: 9px;
    font-weight: 700;
    margin-bottom: 2px;
}

.danfe-emitente-info p {
    font-size: 7px;
}

.danfe-doc-title {
    border-right: 1px solid var(--danfe-border-color);
    text-align: center;
    padding: 4px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.danfe-doc-title h2 {
    font-size: 14px;
    font-weight: 900;
}

.danfe-dir-io {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 3px 0;
}

.danfe-io-box {
    border: 1px solid var(--danfe-border-color);
    font-size: 11px;
    font-weight: bold;
    padding: 2px 5px;
}

.danfe-io-desc {
    font-size: 6px;
    text-align: left;
}

.danfe-n-serie {
    font-size: 8px;
}

.danfe-barcodes {
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.danfe-barcode-graphic {
    height: 24px;
    border: 1px solid var(--danfe-border-color);
    background-color: #000;
    position: relative;
    overflow: hidden;
}

.barcode-lines {
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        90deg,
        #fff,
        #fff 2px,
        #000 2px,
        #000 5px
    );
}

.danfe-key-data {
    font-size: 7px;
}

.danfe-key-data p {
    letter-spacing: 0.5px;
    font-weight: bold;
    font-size: 7.5px;
    word-break: break-all;
}

.danfe-auth-data {
    font-size: 6px;
    text-align: center;
    border-top: 1px dashed var(--danfe-border-color);
    padding-top: 2px;
}

/* DANFE row utilities */
.danfe-row-3, .danfe-row-4, .danfe-row-5, .danfe-row-6 {
    display: flex;
    border-left: 1px solid var(--danfe-border-color);
    border-right: 1px solid var(--danfe-border-color);
    border-bottom: 1px solid var(--danfe-border-color);
}

.danfe-col {
    flex: 1;
    padding: 2px 4px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.danfe-col:not(:last-child) {
    border-right: 1px solid var(--danfe-border-color);
}

.danfe-label {
    font-size: 5.5px;
    font-weight: bold;
    text-transform: uppercase;
    color: #444;
    display: block;
    margin-bottom: 1px;
}

.danfe-val {
    font-size: 7.5px;
    font-weight: 700;
    word-break: break-all;
}

.danfe-val.highlight-val {
    font-size: 9px;
    font-weight: bold;
}

.danfe-val-long {
    font-size: 7px;
    line-height: 1.2;
    white-space: pre-line;
}

.danfe-section-title {
    font-size: 7px;
    font-weight: 900;
    margin-top: 6px;
    margin-bottom: 2px;
    text-transform: uppercase;
    text-align: left;
}

.danfe-dest-block, .danfe-tax-block, .danfe-transp-block, .danfe-additional-block {
    border-top: 1px solid var(--danfe-border-color);
}

.danfe-additional-block {
    display: flex;
    border-left: 1px solid var(--danfe-border-color);
    border-right: 1px solid var(--danfe-border-color);
    border-bottom: 1px solid var(--danfe-border-color);
}

/* DANFE Items table */
.danfe-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--danfe-border-color);
    margin-bottom: 4px;
}

.danfe-table th {
    background-color: #f0f0f0;
    border-bottom: 1px solid var(--danfe-border-color);
    border-right: 1px solid var(--danfe-border-color);
    font-size: 5.5px;
    font-weight: bold;
    padding: 3px;
    text-align: left;
}

.danfe-table th:last-child {
    border-right: none;
}

.danfe-table td {
    border-bottom: 1px solid #ddd;
    border-right: 1px solid var(--danfe-border-color);
    font-size: 6.5px;
    padding: 2.5px 3px;
    vertical-align: middle;
}

.danfe-table td:last-child {
    border-right: none;
}

.danfe-table tbody tr:last-child td {
    border-bottom: none;
}

/* Detailed tax grids */
.taxes-summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.tax-sum-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 16px;
}

.tax-sum-card h4 {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 6px;
    margin-bottom: 10px;
}

.tax-sum-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    margin-bottom: 6px;
}

.tax-sum-row strong {
    color: var(--text-primary);
}

/* Simple/Internal Tables */
.simple-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.simple-table th {
    color: var(--text-secondary);
    font-weight: 700;
    border-bottom: 1px solid var(--border-color);
    padding: 8px 4px;
    text-align: left;
}

.simple-table td {
    padding: 10px 4px;
    border-bottom: 1px solid var(--border-color);
}

.simple-table tr:last-child td {
    border-bottom: none;
}

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

/* Payment summary */
.payment-summary-block {
    display: flex;
    gap: 16px;
}

.pay-kpi {
    flex: 1;
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 12px;
}

.pay-kpi span {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

.pay-kpi h2 {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--success);
    margin-top: 4px;
}

.pay-kpi h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 4px;
}

.transp-detail-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.transp-detail-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 6px;
}

.transp-detail-item .lbl {
    color: var(--text-secondary);
}

/* XML raw syntax code block */
.xml-viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.xml-code-wrapper {
    background-color: #0b0c10;
    border: 1px solid #1f2235;
    border-radius: var(--border-radius-sm);
    padding: 16px;
    max-height: 450px;
    overflow: auto;
}

.xml-code {
    font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
    font-size: 0.8rem;
    color: #e2e8f0;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Syntax tags */
.xml-tag { color: #f43f5e; }
.xml-attr-name { color: #fb923c; }
.xml-attr-val { color: #10b981; }
.xml-text { color: #f1f5f9; }

/* ==========================================================================
   ANIMATIONS & KEYFRAMES
   ========================================================================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* ==========================================================================
   LANGUAGE SELECTOR
   ========================================================================== */
.language-selector {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.language-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 32px 8px 12px;
    border-radius: var(--border-radius-sm);
    font-family: var(--font-main);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    transition: all var(--transition-speed);
}

.language-selector::after {
    content: "";
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid var(--text-secondary);
    pointer-events: none;
    transition: border-color var(--transition-speed);
}

.language-selector:hover::after {
    border-top-color: var(--primary);
}

.language-select:hover {
    border-color: var(--primary);
    background-color: rgba(var(--primary-rgb), 0.05);
}

.language-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.2);
}

/* ==========================================================================
   PRINT CSS (Rules for clean PDF printing)
   ========================================================================== */
@media print {
    body {
        background-color: white !important;
        color: black !important;
    }
    
    .app-container, .modal-backdrop, .modal-header, .modal-tabs, .modal-body > *:not(#danfe-tab), .btn, header {
        display: none !important;
    }
    
    .modal, .modal-container {
        position: relative !important;
        width: 100% !important;
        height: auto !important;
        border: none !important;
        box-shadow: none !important;
        background: transparent !important;
        overflow: visible !important;
    }
    
    .modal-body {
        padding: 0 !important;
        background: white !important;
        overflow: visible !important;
    }
    
    #detail-modal {
        display: block !important;
    }
    
    #danfe-tab {
        display: block !important;
    }
    
    .danfe-paper {
        border: 1px solid black !important;
        box-shadow: none !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        page-break-after: always;
    }
}
