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

:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #3b82f6;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-secondary);
    min-height: 100vh;
    padding: 0;
    color: var(--text-primary);
    font-size: 12px;
    line-height: 1.4;
}

.container {
    max-width: 100%;
    margin: 0;
    background: var(--bg-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    color: white;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow-sm);
}

header h1 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

header p {
    font-size: 11px;
    opacity: 0.9;
    font-weight: 400;
    margin-top: 2px;
}

.results-section {
    padding: 0;
    flex: 1;
    background: var(--bg-secondary);
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 12px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
}

.results-header h2 {
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

.stats {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.stat-item {
    background: var(--bg-secondary);
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    min-width: 100px;
}

.stat-item strong {
    display: block;
    color: var(--primary-color);
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 2px;
}

.stat-item span {
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filters {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    padding: 0 16px;
    flex-wrap: wrap;
}

.filters input,
.filters select {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 12px;
    background: var(--bg-primary);
    color: var(--text-primary);
    flex: 1;
    min-width: 150px;
    transition: all 0.2s ease;
}

.filters input:focus,
.filters select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.table-container {
    overflow-x: auto;
    border-top: 1px solid var(--border-color);
    background: var(--bg-primary);
    max-width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-primary);
    min-width: 1200px;
}

thead {
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

th {
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-tertiary);
    white-space: nowrap;
}

.header-filter {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 100%;
    outline: none;
}

.header-filter:hover {
    color: var(--primary-color);
}

.header-filter option {
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 8px;
    font-weight: normal;
    text-transform: none;
    letter-spacing: normal;
}

/* Narrow columns - 1% width */
th.col-num,
th.col-op,
th.col-doc-num,
th.col-date {
    width: 1%;
    min-width: 40px;
}

td:nth-child(1),
td:nth-child(3),
td:nth-child(4),
td:nth-child(5) {
    width: 1%;
    min-width: 40px;
}

tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background 0.1s ease;
}

tbody tr:hover {
    background: #f8fafc;
}

tbody tr:nth-child(even) {
    background: var(--bg-secondary);
}

tbody tr:nth-child(even):hover {
    background: #f1f5f9;
}

td {
    padding: 6px 10px;
    font-size: 11px;
    color: var(--text-primary);
    white-space: nowrap;
}

td:first-child {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 10px;
}

/* Color coding for operation types */
.operation-svop {
    color: var(--info-color);
    font-weight: 500;
}

.operation-opdds {
    color: var(--success-color);
    font-weight: 500;
}

.operation-ddspk {
    color: var(--warning-color);
    font-weight: 500;
}

.operation-ddspr {
    color: var(--danger-color);
    font-weight: 500;
}

/* Currency badges */
.currency-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.currency-bgn {
    background: #dbeafe;
    color: #1e40af;
}

.currency-eur {
    background: #d1fae5;
    color: #065f46;
}

.currency-ron {
    background: #fef3c7;
    color: #92400e;
}

.currency-usd {
    background: #e0e7ff;
    color: #3730a3;
}

/* Amount formatting */
.amount {
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    font-size: 11px;
}

.amount-positive {
    color: var(--success-color);
}

.amount-negative {
    color: var(--danger-color);
}

/* File name column */
.file-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 10px;
    color: var(--text-secondary);
}

/* Description column */
.description {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Customer info */
.customer-info {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 12px;
}

.error {
    background: #fef2f2;
    color: #991b1b;
    padding: 8px 12px;
    border-radius: 4px;
    margin: 12px 16px;
    border-left: 3px solid var(--danger-color);
    font-size: 12px;
}

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

.empty-state svg {
    width: 32px;
    height: 32px;
    margin-bottom: 8px;
    opacity: 0.4;
}

.empty-state p {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Floating Upload Panel */
.upload-panel {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 360px;
    max-height: 500px;
    background: var(--bg-primary);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.upload-panel.collapsed {
    transform: translateY(calc(100% - 48px));
}

.upload-panel.hidden {
    transform: translateY(calc(100% + 24px));
    opacity: 0;
    pointer-events: none;
}

.upload-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    user-select: none;
}

.upload-panel-header span {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.upload-panel-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.upload-panel-toggle:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.upload-panel.collapsed .upload-panel-toggle svg {
    transform: rotate(180deg);
}

.upload-panel-content {
    padding: 12px;
    overflow-y: auto;
    max-height: 450px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.upload-panel.collapsed .upload-panel-content {
    display: none;
}

.upload-area-compact {
    border: 2px dashed var(--border-color);
    border-radius: 6px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.upload-area-compact:hover {
    border-color: var(--primary-color);
    background: var(--bg-tertiary);
}

.upload-area-compact.dragover {
    border-color: var(--primary-color);
    background: #eff6ff;
    border-style: solid;
}

.upload-area-compact svg {
    color: var(--primary-color);
    opacity: 0.7;
}

.upload-area-compact span {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
}

.file-list-compact {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 200px;
    overflow-y: auto;
}

.file-tag {
    background: var(--primary-color);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 11px;
    font-weight: 500;
}

.file-tag .remove {
    cursor: pointer;
    font-weight: 600;
    opacity: 0.9;
    font-size: 14px;
    line-height: 1;
    padding: 0 4px;
}

.file-tag .remove:hover {
    opacity: 1;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-compact {
    padding: 6px 12px;
    font-size: 11px;
    width: 100%;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Responsive design */
@media (min-width: 1400px) {
    .container {
        max-width: 1600px;
        margin: 0 auto;
    }
    
    table {
        min-width: 1400px;
    }
}

@media (min-width: 1920px) {
    .container {
        max-width: 1800px;
    }
    
    table {
        min-width: 1600px;
    }
}

@media (max-width: 1200px) {
    .table-container {
        overflow-x: scroll;
    }
    
    table {
        min-width: 1000px;
    }
    
    .upload-panel {
        width: 320px;
    }
}

@media (max-width: 768px) {
    header {
        padding: 10px 12px;
    }
    
    header h1 {
        font-size: 14px;
    }
    
    .results-header {
        padding: 10px 12px;
    }
    
    .results-header h2 {
        font-size: 13px;
    }
    
    .stats {
        width: 100%;
    }
    
    .stat-item {
        flex: 1;
        min-width: 0;
        padding: 6px 8px;
    }
    
    .stat-item strong {
        font-size: 14px;
    }
    
    .filters {
        padding: 0 12px;
        flex-direction: column;
    }
    
    .filters input,
    .filters select {
        width: 100%;
        min-width: 0;
    }
    
    table {
        font-size: 10px;
        min-width: 800px;
    }
    
    th, td {
        padding: 6px 8px;
    }
    
    .upload-panel {
        width: calc(100% - 24px);
        right: 12px;
        bottom: 12px;
    }
}

/* Scrollbar styling */
.table-container::-webkit-scrollbar,
.file-list-compact::-webkit-scrollbar,
.upload-panel-content::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.table-container::-webkit-scrollbar-track,
.file-list-compact::-webkit-scrollbar-track,
.upload-panel-content::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.table-container::-webkit-scrollbar-thumb,
.file-list-compact::-webkit-scrollbar-thumb,
.upload-panel-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.table-container::-webkit-scrollbar-thumb:hover,
.file-list-compact::-webkit-scrollbar-thumb:hover,
.upload-panel-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
