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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0f4f8;
    color: #1F3864;
    min-height: 100vh;
}

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

/* Header */
header {
    margin-bottom: 32px;
}

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

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo {
    display: block;
    max-width: 180px;
    height: auto;
    margin: 0 auto 20px;
}

.logo-small {
    height: 40px;
    width: auto;
}

header h1 {
    font-size: 1.8rem;
    color: #1F3864;
    margin-bottom: 4px;
}

.subtitle {
    color: #595959;
    font-size: 0.95rem;
}

.btn-logout {
    padding: 6px 16px;
    font-size: 0.85rem;
    color: #595959;
    text-decoration: none;
    border: 1px solid #ccc;
    border-radius: 6px;
    transition: all 0.2s;
}

.btn-logout:hover {
    color: #C00000;
    border-color: #C00000;
}

/* Drop zone */
.drop-zone {
    border: 2px dashed #2E75B6;
    border-radius: 12px;
    padding: 40px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: #fff;
    margin-top: 24px;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: #1F3864;
    background: #F5F9FF;
}

.drop-icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

.drop-zone p {
    color: #595959;
    margin-bottom: 4px;
}

.browse-link {
    color: #2E75B6;
    text-decoration: underline;
    cursor: pointer;
    font-weight: 600;
}

.hint {
    font-size: 0.82rem;
    color: #999;
}

/* File list */
.file-list {
    margin-top: 12px;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
}

.file-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid #f0f0f0;
    gap: 12px;
}

.file-item:last-child {
    border-bottom: none;
}

.file-name {
    flex: 1;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-size {
    font-size: 0.8rem;
    color: #999;
    flex-shrink: 0;
}

.file-remove {
    background: none;
    border: none;
    color: #C00000;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    flex-shrink: 0;
}

.file-remove:hover {
    color: #900;
}

/* Period */
.period-section {
    margin-top: 24px;
}

.period-section h2,
.status-section h2 {
    font-size: 1rem;
    color: #1F3864;
    margin-bottom: 12px;
}

.period-options {
    display: flex;
    gap: 10px;
}

.period-option {
    flex: 1;
    cursor: pointer;
}

.period-option input[type="radio"] {
    display: none;
}

.period-card {
    display: block;
    padding: 14px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    text-align: center;
    transition: all 0.2s;
    background: #fff;
}

.period-card strong {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 2px;
}

.period-card small {
    color: #999;
    font-size: 0.78rem;
}

.period-option input:checked + .period-card {
    border-color: #2E75B6;
    background: #F5F9FF;
}

.custom-dates {
    display: flex;
    gap: 16px;
    margin-top: 12px;
}

.date-field {
    flex: 1;
}

.date-field label {
    display: block;
    font-size: 0.85rem;
    color: #595959;
    margin-bottom: 4px;
}

.date-field input[type="date"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.9rem;
}

/* Buttons */
.btn-generate {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 24px;
    padding: 14px;
    background: #2E75B6;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-generate:hover:not(:disabled) {
    background: #1F3864;
}

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

.btn-cancel {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-top: 8px;
    padding: 12px;
    background: #fff;
    color: #595959;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cancel:hover {
    border-color: #999;
    color: #1F3864;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Error / Feedback */
.error-msg {
    margin-top: 16px;
    padding: 12px 16px;
    background: #FFE0E0;
    color: #C00000;
    border-radius: 8px;
    font-size: 0.9rem;
    white-space: pre-wrap;
}

.feedback-box {
    margin-top: 20px;
    padding: 16px 20px;
    border-radius: 10px;
    font-size: 0.9rem;
}

.feedback-box h3 {
    font-size: 1rem;
    margin-bottom: 8px;
}

.feedback-success {
    background: #E8F4E8;
    border: 1px solid #70AD47;
    color: #1F3864;
}

.feedback-error {
    background: #FFE0E0;
    border: 1px solid #C00000;
    color: #C00000;
}

.warning-text {
    color: #B8860B;
    font-size: 0.85rem;
    margin-bottom: 8px;
    padding: 6px 10px;
    background: #FFF8E1;
    border-radius: 4px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin: 12px 0;
}

.summary-item {
    text-align: center;
    padding: 10px 6px;
    background: #fff;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.summary-item strong {
    display: block;
    font-size: 1.3rem;
    color: #2E75B6;
}

.summary-item small {
    font-size: 0.72rem;
    color: #595959;
}

.esiti-list {
    margin-top: 8px;
    font-size: 0.85rem;
}

.esiti-list ul {
    list-style: none;
    margin-top: 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
}

.esiti-list li {
    color: #595959;
}

/* Confirm overwrite */
.confirm-box {
    margin-top: 20px;
    padding: 20px;
    background: #FFF8E1;
    border: 1px solid #F4B942;
    border-radius: 10px;
}

.confirm-box h3 {
    color: #B8860B;
    margin-bottom: 8px;
}

.confirm-box p {
    font-size: 0.9rem;
    color: #595959;
    margin-bottom: 12px;
}

.confirm-actions {
    margin-top: 16px;
}

.summary-mini {
    font-size: 0.85rem;
}

.summary-mini hr {
    border: none;
    border-top: 1px solid #e0e0e0;
    margin: 12px 0;
}

/* Info box (es. avviso template, note all'admin) */
.info-box {
    background: #F5F9FF;
    border: 1px solid #C9DAF8;
    border-left: 4px solid #2E75B6;
    padding: 14px 18px;
    border-radius: 6px;
    margin: 18px 0;
    font-size: 0.92rem;
    color: #1F3864;
}

.info-box p { margin: 6px 0; }
.info-box a { color: #1F3864; font-weight: 600; }

/* Banner di stato (sopra alla pagina rep) */
.status-banner {
    padding: 12px 18px;
    border-radius: 6px;
    margin: 14px 0 18px;
    font-size: 0.95rem;
    line-height: 1.4;
    border-left: 4px solid #999;
    background: #f5f5f5;
    color: #333;
}
.status-banner-success {
    background: #E8F5E9;
    border-left-color: #43A047;
    color: #1B5E20;
}
.status-banner-warn {
    background: #FFF8E1;
    border-left-color: #F4B942;
    color: #6D4C00;
}
.status-banner-info {
    background: #E3F2FD;
    border-left-color: #2E75B6;
    color: #0D47A1;
}

/* Sezione "I tuoi report" */
.history-section {
    margin: 18px 0 24px;
}
.history-section h2 {
    font-size: 1.05rem;
    color: #1F3864;
    margin: 0 0 8px;
}
.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background: #fff;
    border: 1px solid #E0E6EF;
    border-radius: 6px;
    overflow: hidden;
}
.history-table th, .history-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #EEF1F6;
}
.history-table th {
    background: #F5F9FF;
    color: #1F3864;
    font-weight: 600;
    font-size: 0.85rem;
}
.history-table tbody tr:last-child td { border-bottom: 0; }
.history-table .row-missing td { background: #FFF8F8; color: #888; }
.history-table .row-uploaded td { background: #FFFFFF; }

.badge-ok, .badge-missing {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-ok       { background: #E8F5E9; color: #1B5E20; }
.badge-missing  { background: #F0F0F0; color: #777;    }

.link-small {
    color: #2E75B6;
    text-decoration: none;
    font-size: 0.85rem;
}
.link-small:hover { text-decoration: underline; }

/* Box istruzioni "Come risolvere" dentro l'errore */
.error-howto {
    margin-top: 14px;
    padding: 12px 14px;
    background: #FFFFFF;
    border-radius: 6px;
    border: 1px dashed #C00000;
    font-size: 0.92rem;
    color: #333;
}
.error-howto strong {
    display: block;
    margin-bottom: 6px;
    color: #C00000;
}
.error-howto ol {
    margin: 0;
    padding-left: 20px;
}
.error-howto li {
    margin: 4px 0;
}
.error-howto a {
    color: #C00000;
    font-weight: 600;
}

/* Status grid (admin) */
.status-section {
    margin-top: 28px;
}

.status-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.status-card {
    padding: 14px 16px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    background: #fff;
    transition: all 0.2s;
}

.status-card.uploaded {
    border-color: #70AD47;
    background: #f6fbf3;
}

.status-card.missing {
    border-color: #e0e0e0;
    background: #fff;
}

.status-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.status-icon {
    font-size: 1.1rem;
}

.status-header strong {
    font-size: 0.9rem;
}

.status-details {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    font-size: 0.78rem;
    color: #595959;
}

.missing-text {
    color: #C00000;
    font-style: italic;
}

.status-time {
    font-size: 0.72rem;
    color: #999;
    margin-top: 4px;
}

/* Login */
.login-box {
    max-width: 380px;
    margin: 60px auto 0;
    background: #fff;
    border-radius: 12px;
    padding: 40px 32px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    text-align: center;
}

.login-box h1 {
    font-size: 1.4rem;
    margin-bottom: 4px;
}

.login-box .subtitle {
    margin-bottom: 24px;
}

.login-box .error-msg {
    margin-top: 0;
    margin-bottom: 16px;
}

.login-field {
    text-align: left;
    margin-bottom: 16px;
}

.login-field label {
    display: block;
    font-size: 0.85rem;
    color: #595959;
    margin-bottom: 4px;
}

.login-field input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.95rem;
}

.login-field input:focus {
    outline: none;
    border-color: #2E75B6;
    box-shadow: 0 0 0 2px rgba(46,117,182,0.15);
}

/* Footer */
footer {
    margin-top: 40px;
    text-align: center;
    color: #999;
    font-size: 0.8rem;
}

/* Responsive */
@media (max-width: 500px) {
    .period-options {
        flex-direction: column;
    }
    .custom-dates {
        flex-direction: column;
    }
    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .status-grid {
        grid-template-columns: 1fr;
    }
}
