* { box-sizing: border-box; }

body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background: #f5f5f5;
    color: #222;
}

.topbar {
    background: #0077b6;
    color: white;
    padding: 24px 20px;
    text-align: center;
}

.topbar h1 {
    margin: 0 0 4px 0;
    font-size: 24px;
}

.topbar p {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
}

#app {
    max-width: 480px;
    margin: 0 auto;
    padding: 16px;
}

.card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.card h2 {
    margin: 0 0 4px 0;
    font-size: 18px;
    color: #222;
    text-align: center;
}

.card h3 {
    margin: 20px 0 8px 0;
    font-size: 15px;
    color: #555;
}

.hint {
    font-size: 13px;
    color: #777;
    margin: 0 0 14px 0;
}

.campo {
    margin-bottom: 14px;
}

.campo label {
    display: block;
    font-size: 13px;
    color: #555;
    margin-bottom: 4px;
}

.campo input,
.campo select {
    width: 100%;
    padding: 10px;
    font-size: 15px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: white;
}

.opzioni label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 0;
    border-top: 1px solid #eee;
    font-size: 14px;
}

.opzioni label:first-child {
    border-top: none;
}

.opzioni input {
    margin-top: 2px;
}

.sub {
    font-size: 12px;
    color: #999;
}

.btn-primario {
    width: 100%;
    padding: 14px;
    background: #0077b6;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    margin-bottom: 20px;
}

.btn-primario:active {
    opacity: 0.85;
}

.hidden {
    display: none !important;
}

#output {
    font-family: Arial, sans-serif;
}

#output h2 {
    color: #003366;
    font-size: 20px;
    margin: 0 0 4px 0;
    border-bottom: 2px solid #003366;
    padding-bottom: 8px;
}

.indice-dvr {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 12px 0 20px 0;
    padding-bottom: 12px;
    border-bottom: 1px solid #ddd;
}

.indice-dvr a {
    font-size: 12px;
    color: #003366;
    background: #e6eef7;
    padding: 5px 10px;
    border-radius: 14px;
    text-decoration: none;
    white-space: nowrap;
}

.indice-dvr a:hover {
    background: #c8d8ea;
}

#output h3 {
    color: #003366;
    font-size: 16px;
    margin: 24px 0 4px 0;
}

#output h4 {
    font-size: 14px;
    margin: 14px 0 6px 0;
    color: #444;
}

.tabella-dvr {
    width: 100%;
    max-width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    margin: 8px 0 16px 0;
    font-size: 12px;
}

.tabella-dvr th {
    background: #1f76a3;
    color: white;
    text-align: left;
    padding: 6px;
    border: 1px solid #1f76a3;
    font-weight: bold;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.tabella-dvr td {
    padding: 6px;
    border: 1px solid #ddd;
    vertical-align: top;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.tabella-dvr .col-stato {
    text-align: center;
    width: 30px;
    font-size: 15px;
}

.tabella-regolamento th:first-child,
.tabella-regolamento td:first-child {
    width: 24px;
    text-align: center;
}

.stato-ok {
    color: #1e7e34;
}

.stato-ko {
    color: #b3261e;
}

.stato-warn {
    color: #a35a00;
}

.toggle-2 {
    display: flex;
    gap: 8px;
}

.toggle-2-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toggle-2 label, .toggle-2-col label {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: white;
    font-size: 14px;
    text-align: center;
}

.toggle-2-col label {
    justify-content: flex-start;
    text-align: left;
}

.toggle-2 input, .toggle-2-col input {
    width: auto;
}

.riga {
    font-size: 13px;
    color: #444;
    margin: 0 0 8px 0;
    line-height: 1.5;
}

.avviso {
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
    font-size: 13px;
}

.avviso-danger {
    background: #fdecea;
    color: #b3261e;
}

.avviso-warning {
    background: #fff4e5;
    color: #a35a00;
}

.avviso-success {
    background: #e6f4ea;
    color: #1e7e34;
}

/* ===== STAMPA / SALVA COME PDF ===== */
@media print {
    body * {
        visibility: hidden;
    }
    #output, #output * {
        visibility: visible;
    }
    #output {
        position: absolute;
        left: 0;
        top: 0;
        width: 100% !important;
        max-width: 100% !important;
        padding: 0;
        margin: 0;
    }
    #app {
        max-width: 100% !important;
        padding: 0 !important;
    }
    header.topbar, #btnReset, .indice-dvr, #genBtn {
        display: none !important;
    }
    .tabella-dvr {
        font-size: 11px;
        page-break-inside: auto;
    }
    .tabella-dvr tr {
        page-break-inside: avoid;
    }
    .avviso {
        page-break-inside: avoid;
    }
    #output h2, #output h3 {
        page-break-after: avoid;
    }
    @page {
        margin: 15mm 12mm;
    }
}