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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0f2f5;
    color: #333;
    line-height: 1.5;
}

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

/* Header */
.header {
    background: #1a365d;
    color: #fff;
    padding: 12px 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 1.3rem;
    font-weight: 600;
}

.header h1 span {
    color: #75e0e0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.9rem;
}

.header-right a {
    color: #cbd5e0;
    text-decoration: none;
}

.header-right a:hover {
    color: #fff;
}

/* Card */
.card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    padding: 24px;
    margin-bottom: 20px;
}

.card h2 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: #1a365d;
}

/* Upload */
.upload-area {
    border: 2px dashed #cbd5e0;
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: #1a365d;
    background: #f7fafc;
}

.upload-area p {
    color: #718096;
    margin-top: 8px;
    font-size: 0.9rem;
}

.upload-area .icon {
    font-size: 2.5rem;
    color: #a0aec0;
}

.upload-area .filename {
    margin-top: 12px;
    font-weight: 600;
    color: #1a365d;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 24px;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
}

.btn-primary {
    background: #1a365d;
    color: #fff;
}

.btn-primary:hover {
    background: #2a4a7f;
}

.btn-primary:disabled {
    background: #a0aec0;
    cursor: not-allowed;
}

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

.btn-secondary {
    background: #4a5568;
    color: #fff;
}

.btn-secondary:hover {
    background: #2d3748;
}

.btn-danger {
    background: #c53030;
    color: #fff;
}

.btn-danger:hover {
    background: #9b2c2c;
}

td.actions {
    white-space: nowrap;
    text-align: center;
}

td.actions form {
    margin-left: 4px;
}

/* Flash */
.flash {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.flash-error {
    background: #fed7d7;
    color: #c53030;
    border: 1px solid #feb2b2;
}

.flash-success {
    background: #c6f6d5;
    color: #276749;
    border: 1px solid #9ae6b4;
}

/* Report */
.report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.badge-ok {
    background: #c6f6d5;
    color: #276749;
}

.badge-ko {
    background: #fed7d7;
    color: #c53030;
}

.badge-warn {
    background: #fefcbf;
    color: #975a16;
}

/* Summary */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.summary-item {
    background: #f7fafc;
    border-radius: 6px;
    padding: 12px;
    text-align: center;
}

.summary-item .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a365d;
}

.summary-item .label {
    font-size: 0.8rem;
    color: #718096;
    margin-top: 2px;
}

/* Error list */
.error-list {
    list-style: none;
}

.error-list li {
    padding: 8px 12px;
    border-left: 3px solid #c53030;
    background: #fff5f5;
    margin-bottom: 6px;
    border-radius: 0 4px 4px 0;
    font-size: 0.88rem;
}

.error-list li.warning {
    border-left-color: #d69e2e;
    background: #fffff0;
}

.error-list li .record-ref {
    font-weight: 600;
    color: #1a365d;
}

/* History table */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

th, td {
    padding: 10px 12px;
    text-align: center;
    border-bottom: 1px solid #e2e8f0;
}

th {
    background: #f7fafc;
    font-weight: 600;
    color: #4a5568;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

tr:hover {
    background: #f7fafc;
}

/* Login */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-box {
    background: #fff;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 380px;
}

.login-box h1 {
    text-align: center;
    color: #1a365d;
    margin-bottom: 24px;
    font-size: 1.3rem;
}

.login-box h1 span {
    color: #75e0e0;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #4a5568;
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: #1a365d;
    box-shadow: 0 0 0 3px rgba(26,54,93,0.1);
}

.btn-block {
    width: 100%;
}

/* Loading */
.loading {
    display: none;
    text-align: center;
    padding: 20px;
}

.loading.active {
    display: block;
}

.spinner {
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid #e2e8f0;
    border-top-color: #1a365d;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Tipo controllo grid */
.tipo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.tipo-card {
    display: block;
    background: #f7fafc;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 24px 20px;
    text-align: center;
    text-decoration: none;
    color: #333;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}

.tipo-card:hover {
    border-color: #1a365d;
    box-shadow: 0 4px 12px rgba(26, 54, 93, 0.15);
    transform: translateY(-2px);
}

.tipo-codice {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1a365d;
}

.tipo-anno {
    font-size: 1.1rem;
    font-weight: 600;
    color: #4a5568;
    margin-top: 2px;
}

.tipo-desc {
    font-size: 0.85rem;
    color: #718096;
    margin-top: 8px;
}

/* Tipo corrente badge in header */
.tipo-corrente {
    display: inline-block;
    background: rgba(255,255,255,0.15);
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
}

.tipo-corrente a {
    margin-left: 6px;
    font-size: 0.75rem;
    opacity: 0.7;
}

.tipo-corrente a:hover {
    opacity: 1;
}

/* Footer */
.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    padding: 10px 0;
    font-size: 0.75rem;
    color: #a0aec0;
    background: #f0f2f5;
}

.footer a {
    color: #a0aec0;
    text-decoration: none;
}

.footer a:hover {
    color: #4a5568;
}

/* Responsive */
@media (max-width: 600px) {
    .header .container {
        flex-direction: column;
        gap: 8px;
    }
    .card { padding: 16px; }
    .upload-area { padding: 24px; }
    .summary-grid { grid-template-columns: repeat(2, 1fr); }
}
