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

:root {
    --primary-blue: #1E90FF;
    --secondary-blue: #0066CC;
    --accent-orange: #FF8C00;
    --dark-bg: #0A0A0A;
    --card-bg: #1A1A1A;
    --text-primary: #FFFFFF;
    --text-secondary: #B0B0B0;
    --success-green: #00C853;
    --error-red: #FF3D00;
    --border-color: #2A2A2A;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--dark-bg) 0%, #1a1a2e 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    padding: 40px 20px;
    background: var(--card-bg);
    border-radius: 15px;
    margin-bottom: 40px;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.logo-container {
    margin-bottom: 20px;
}

#logo {
    max-width: 400px;
    height: auto;
    filter: drop-shadow(0 5px 15px rgba(30, 144, 255, 0.3));
}

h1 {
    font-size: 2.5rem;
    color: var(--primary-blue);
    margin-bottom: 10px;
    text-shadow: 0 0 20px rgba(30, 144, 255, 0.5);
}

.tagline {
    font-size: 1.2rem;
    color: var(--accent-orange);
    font-style: italic;
}

main {
    min-height: 400px;
}

.upload-section {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 40px;
    border: 2px dashed var(--primary-blue);
    transition: all 0.3s ease;
}

.upload-section.drag-over {
    border-color: var(--accent-orange);
    background: rgba(30, 144, 255, 0.1);
    transform: scale(1.02);
}

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

.upload-icon {
    width: 80px;
    height: 80px;
    color: var(--primary-blue);
    margin-bottom: 20px;
    stroke-width: 2;
}

.upload-box h2 {
    color: var(--text-primary);
    margin-bottom: 10px;
    font-size: 1.8rem;
}

.upload-box p {
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.file-types {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.btn-primary, .btn-secondary, .btn-download {
    padding: 15px 40px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-blue), var(--secondary-blue));
    color: white;
    box-shadow: 0 5px 15px rgba(30, 144, 255, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(30, 144, 255, 0.6);
}

.btn-secondary {
    background: transparent;
    color: var(--primary-blue);
    border: 2px solid var(--primary-blue);
    margin-top: 20px;
}

.btn-secondary:hover {
    background: var(--primary-blue);
    color: white;
}

.btn-download {
    background: linear-gradient(135deg, var(--accent-orange), #FF6B00);
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 auto;
    box-shadow: 0 5px 15px rgba(255, 140, 0, 0.4);
}

.btn-download svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

.btn-download:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 140, 0, 0.6);
}

.file-info {
    background: rgba(30, 144, 255, 0.1);
    border-radius: 10px;
    padding: 30px;
    border: 1px solid var(--primary-blue);
}

.file-details {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}

.file-icon {
    width: 50px;
    height: 50px;
    color: var(--primary-blue);
    stroke-width: 2;
}

.file-name {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
}

.file-size {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.results-section {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 40px;
    border: 1px solid var(--border-color);
}

.results-header {
    text-align: center;
    margin-bottom: 30px;
}

.results-header h2 {
    color: var(--primary-blue);
    font-size: 2rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: rgba(30, 144, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 25px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon svg {
    width: 30px;
    height: 30px;
    stroke-width: 2.5;
}

.stat-icon.total {
    background: rgba(30, 144, 255, 0.2);
    color: var(--primary-blue);
}

.stat-icon.valid {
    background: rgba(0, 200, 83, 0.2);
    color: var(--success-green);
}

.stat-icon.invalid {
    background: rgba(255, 61, 0, 0.2);
    color: var(--error-red);
}

.stat-icon.warning {
    background: rgba(255, 193, 7, 0.2);
    color: #FFC107;
}

.stat-content {
    flex: 1;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.errors-section, .duplicates-section {
    background: rgba(255, 61, 0, 0.05);
    border: 1px solid rgba(255, 61, 0, 0.3);
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 30px;
}

.errors-section h3 {
    color: var(--error-red);
    margin-bottom: 20px;
    font-size: 1.3rem;
}

.duplicates-section {
    background: rgba(255, 193, 7, 0.05);
    border: 1px solid rgba(255, 193, 7, 0.3);
}

.duplicates-section h3 {
    color: #FFC107;
    margin-bottom: 20px;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.detailed-errors-section {
    background: rgba(30, 144, 255, 0.05);
    border: 1px solid rgba(30, 144, 255, 0.3);
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 30px;
}

.detailed-errors-section h3 {
    color: var(--primary-blue);
    margin-bottom: 10px;
    font-size: 1.3rem;
}

.section-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.detailed-errors-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.detailed-error-item {
    background: rgba(30, 144, 255, 0.08);
    border: 1px solid rgba(30, 144, 255, 0.2);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.detailed-error-item:hover {
    border-color: var(--primary-blue);
    box-shadow: 0 4px 12px rgba(30, 144, 255, 0.2);
}

.detailed-error-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(30, 144, 255, 0.05);
}

.detailed-error-header:hover {
    background: rgba(30, 144, 255, 0.1);
}

.detailed-error-header.expanded {
    background: rgba(30, 144, 255, 0.15);
    border-bottom: 1px solid rgba(30, 144, 255, 0.3);
}

.error-row-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.error-row-number {
    background: var(--primary-blue);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.9rem;
}

.error-gauge-id {
    color: var(--text-primary);
    font-weight: 600;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
}

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

.error-count-badge {
    background: var(--error-red);
    color: white;
    padding: 5px 12px;
    border-radius: 15px;
    font-weight: 600;
    font-size: 0.85rem;
}

.expand-icon {
    width: 20px;
    height: 20px;
    stroke-width: 2.5;
    color: var(--primary-blue);
    transition: transform 0.3s ease;
}

.detailed-error-header.expanded .expand-icon {
    transform: rotate(180deg);
}

.detailed-error-content {
    padding: 20px;
    background: rgba(10, 10, 10, 0.3);
}

.error-detail-card {
    background: rgba(30, 144, 255, 0.05);
    border: 1px solid rgba(30, 144, 255, 0.2);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}

.error-detail-card:last-child {
    margin-bottom: 0;
}

.error-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(30, 144, 255, 0.2);
}

.error-field-name {
    color: var(--accent-orange);
    font-weight: 700;
    font-size: 1rem;
    font-family: 'Courier New', monospace;
}

.error-type-badge {
    background: var(--error-red);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.error-detail-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.error-detail-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.error-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
}

.error-current-value {
    color: var(--error-red);
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    padding: 8px 12px;
    background: rgba(255, 61, 0, 0.1);
    border-radius: 4px;
    border-left: 3px solid var(--error-red);
}

.error-expected-format {
    color: var(--text-primary);
    font-size: 0.9rem;
    padding: 8px 12px;
    background: rgba(30, 144, 255, 0.1);
    border-radius: 4px;
    border-left: 3px solid var(--primary-blue);
}

.error-example {
    color: var(--success-green);
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    padding: 8px 12px;
    background: rgba(0, 200, 83, 0.1);
    border-radius: 4px;
    border-left: 3px solid var(--success-green);
}

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

.error-item {
    background: rgba(255, 61, 0, 0.1);
    padding: 15px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 3px solid var(--error-red);
}

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

.error-count {
    background: var(--error-red);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
}

.duplicates-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.duplicate-item {
    background: rgba(255, 193, 7, 0.1);
    padding: 18px;
    border-radius: 8px;
    border-left: 3px solid #FFC107;
    transition: all 0.3s ease;
}

.duplicate-item:hover {
    background: rgba(255, 193, 7, 0.15);
    transform: translateX(5px);
}

.duplicate-gauge-id {
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.1rem;
    font-family: 'Courier New', monospace;
    margin-bottom: 8px;
}

.duplicate-details {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.duplicate-count {
    background: #FFC107;
    color: #000;
    padding: 4px 12px;
    border-radius: 15px;
    font-weight: 600;
    font-size: 0.85rem;
}

.duplicate-rows {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.download-section {
    text-align: center;
    margin-bottom: 30px;
}

.loading {
    text-align: center;
    padding: 60px;
    background: var(--card-bg);
    border-radius: 15px;
    border: 1px solid var(--border-color);
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(30, 144, 255, 0.2);
    border-top-color: var(--primary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

footer {
    text-align: center;
    padding: 30px;
    margin-top: 60px;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
}

@media (max-width: 768px) {
    h1 {
        font-size: 1.8rem;
    }
    
    #logo {
        max-width: 280px;
    }
    
    .upload-section, .results-section {
        padding: 20px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        padding: 20px;
    }
    
    .detailed-errors-section {
        padding: 15px;
    }
    
    .detailed-error-header {
        padding: 12px 15px;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .error-row-info {
        width: 100%;
        flex-wrap: wrap;
    }
    
    .error-summary {
        width: 100%;
        justify-content: space-between;
    }
    
    .error-detail-card {
        padding: 12px;
    }
    
    .error-field-name {
        font-size: 0.9rem;
    }
    
    .error-detail-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

.btn-rules {
    padding: 12px 30px;
    background: transparent;
    color: var(--primary-blue);
    border: 2px solid var(--primary-blue);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 150px;
}

.btn-rules svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

.btn-rules:hover {
    background: var(--primary-blue);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(30, 144, 255, 0.4);
}

.header-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: stretch;
    flex-wrap: wrap;
    margin-top: 20px;
}

.btn-logout {
    padding: 12px 30px;
    background: transparent;
    color: var(--error-red);
    border: 2px solid var(--error-red);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 150px;
}

.btn-logout svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

.btn-logout:hover {
    background: var(--error-red);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 61, 0, 0.4);
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 15px;
    max-width: 900px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 30px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    color: var(--primary-blue);
    font-size: 1.8rem;
    margin: 0;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 2.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: rgba(255, 61, 0, 0.2);
    color: var(--error-red);
}

.modal-body {
    padding: 30px;
    overflow-y: auto;
}

.rule-item {
    background: rgba(30, 144, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 20px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.rule-item:hover {
    border-color: var(--primary-blue);
    box-shadow: 0 5px 15px rgba(30, 144, 255, 0.2);
}

.rule-header {
    background: rgba(30, 144, 255, 0.1);
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
}

.rule-field {
    color: var(--accent-orange);
    font-weight: 700;
    font-size: 1.1rem;
    font-family: 'Courier New', monospace;
}

.rule-body {
    padding: 20px;
}

.rule-description {
    color: var(--text-primary);
    margin-bottom: 15px;
    font-size: 0.95rem;
    line-height: 1.6;
}

.rule-description strong {
    color: var(--primary-blue);
}

.rule-examples {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.example-valid, .example-invalid {
    padding: 12px 15px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: 'Courier New', monospace;
}

.example-valid {
    background: rgba(0, 200, 83, 0.1);
    border-left: 3px solid var(--success-green);
    color: var(--text-secondary);
}

.example-valid strong {
    color: var(--success-green);
}

.example-invalid {
    background: rgba(255, 61, 0, 0.1);
    border-left: 3px solid var(--error-red);
    color: var(--text-secondary);
}

.example-invalid strong {
    color: var(--error-red);
}

@media (max-width: 768px) {
    .modal-content {
        max-height: 90vh;
    }
    
    .modal-header {
        padding: 20px;
    }
    
    .modal-header h2 {
        font-size: 1.4rem;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .rule-field {
        font-size: 0.95rem;
    }
    
    .btn-rules {
        font-size: 0.85rem;
        padding: 10px 20px;
    }
}
