* {
    box-sizing: border-box;
}
body {
    margin: 0;
    padding: 0;
    font-family:
        Arial,
        Helvetica,
        sans-serif;
    background-color: #f4f6f8;
    color: #222;
}
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 30px;
}

/* =====================================================
   HEADER
   ===================================================== */
.page-title {
    display: flex;
    align-items: center;
    gap: 20px;
    background-color: white;
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow:
        0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 25px;
}
.page-title img {
    width: 120px;
    height: 120px;
    object-fit: contain;
}
.page-title h1 {
    margin: 0;
    color: #333;
}

/* =====================================================
   PANNELLI
   ===================================================== */
.search-panel,
.results-panel {
    background: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow:
        0 2px 8px rgba(0,0,0,0.08);
}
.search-panel {
    margin-bottom: 25px;
}

/* =====================================================
   GRIGLIA RICERCA
   ===================================================== */
.search-grid {
    display: grid;
    grid-template-columns:
        repeat(3, 1fr);
    gap: 18px;
}
.form-group {
    display: flex;
    flex-direction: column;
}
.form-group label {
    font-weight: bold;
    margin-bottom: 6px;
    color: #444;
}
.form-group input,
.form-group select {
    height: 40px;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 14px;
    background: white;
}
.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #1976d2;
    box-shadow:
        0 0 0 2px rgba(25,118,210,0.12);
}

/* =====================================================
   TESTO - TEMPORANEAMENTE NASCOSTO
   ===================================================== */
.search-text-hidden {
    visibility: hidden;
}

/* =====================================================
   DATE
   ===================================================== */
.date-wrapper {
    position: relative;
}
.date-display {
    width: 100%;
    height: 40px;
    padding:
        8px 40px 8px 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 14px;
    background: white;
    cursor: pointer;
}
.date-display:focus {
    outline: none;
    border-color: #1976d2;
    box-shadow:
        0 0 0 2px rgba(25,118,210,0.12);
}
.date-calendar {
    position: absolute;
    right: 0;
    top: 0;
    width: 40px;
    height: 40px;
    opacity: 0;
    cursor: pointer;
}
.calendar-icon {
    position: absolute;
    right: 10px;
    top: 10px;
    pointer-events: none;
    font-size: 18px;
}

/* =====================================================
   PULSANTI
   ===================================================== */
.buttons {
    margin-top: 20px;
    display: flex;
    gap: 10px;
}
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
}
.btn-search {
    background-color: #1976d2;
    color: white;
}
.btn-search:hover {
    background-color: #1565c0;
}
.btn-reset {
    background-color: #e0e0e0;
    color: #333;
}
.btn-reset:hover {
    background-color: #d0d0d0;
}

/* =====================================================
   RISULTATI
   ===================================================== */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}
.results-header h2 {
    margin: 0;
    font-size: 20px;
}
.result-count {
    color: #666;
    font-size: 14px;
}
.table-container {
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
th {
    background-color: #eeeeee;
    text-align: left;
    padding: 10px;
    border-bottom: 2px solid #ccc;
    white-space: nowrap;
}
td {
    padding: 10px;
    border-bottom: 1px solid #ddd;
    vertical-align: top;
}

/* =====================================================
   RIGA ATTO
   ===================================================== */
.atto-row {
    cursor: pointer;
}
.atto-row:hover {
    background-color: #eaf2fb;
}
.atto-row:focus {
    outline:
        2px solid #1976d2;
    outline-offset: -2px;
}
.col-categoria {
    width: 220px;
}
.col-numero {
    width: 100px;
    white-space: nowrap;
}
.col-data {
    width: 110px;
    white-space: nowrap;
}
.col-titolo {
    min-width: 400px;
}
.no-results {
    padding: 30px;
    text-align: center;
    color: #777;
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 900px) {
    .search-grid {
        grid-template-columns: 1fr;
    }
    .container {
        padding: 15px;
    }
    .search-panel,
    .results-panel {
        padding: 18px;
    }
    /*
     * Il campo Testo rimane nascosto anche quando
     * la griglia passa a una sola colonna.
     */
    .search-text-hidden {
        display: none;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 10px;
    }
    .page-title {
        gap: 12px;
        padding: 12px 15px;
    }
    .page-title img {
        width: 65px;
        height: 65px;
    }
    .page-title h1 {
        font-size: 24px;
    }
    .buttons {
        flex-direction: column;
    }
    .btn {
        width: 100%;
        text-align: center;
    }
    .results-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    table {
        font-size: 13px;
    }
    th,
    td {
        padding: 8px;
    }
}

/* =====================================================
   PAGINA DETTAGLIO ATTO
   ===================================================== */

.atto-panel {
    background-color: white;

    padding: 25px;

    border-radius: 8px;

    box-shadow:
        0 2px 8px rgba(0,0,0,0.08);
}

.atto-panel h2 {
    margin-top: 0;
    margin-bottom: 25px;

    font-size: 20px;

    color: #333;
}

.atto-field {
    display: flex;

    gap: 10px;

    margin-bottom: 14px;

    line-height: 1.5;
}

.atto-label {
    font-weight: bold;

    min-width: 120px;

    color: #444;
}

.atto-object {
    align-items: flex-start;
}

.allegati-title {
    margin-top: 35px !important;
    margin-bottom: 15px !important;
}

.allegati-list {
    border-top: 1px solid #ddd;
}

.allegato-item {
    padding: 12px 10px;

    border-bottom: 1px solid #ddd;
}

.allegato-item:hover {
    background-color: #eaf2fb;
}

.allegato-link {
    color: #1976d2;

    text-decoration: none;

    font-weight: bold;
}

.allegato-link:hover {
    text-decoration: underline;
}

.back-link {
    margin-top: 25px;
}

.back-link a {
    color: #1976d2;

    text-decoration: none;

    font-weight: bold;
}

.back-link a:hover {
    text-decoration: underline;
}


/* =====================================================
   RESPONSIVE - DETTAGLIO ATTO
   ===================================================== */

@media (max-width: 600px) {

    .atto-panel {
        padding: 18px;
    }

    .atto-field {
        flex-direction: column;

        gap: 3px;

        margin-bottom: 18px;
    }

    .atto-label {
        min-width: auto;
    }
}