:root {
    --brand-color: #2563eb;
    --bg: #f3f4f6;
    --card-bg: #ffffff;
    --text: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --error: #dc2626;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.page {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 16px 48px;
}

.progress-bar-track {
    position: sticky;
    top: 0;
    height: 4px;
    background: var(--border);
    z-index: 10;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--brand-color);
    transition: width 0.25s ease;
}

.app-header {
    padding: 32px 0 8px;
}

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

.app-header-logo {
    flex: 1 1 0;
    display: flex;
    align-items: center;
}

.logo-img {
    height: 64px;
    width: auto;
    display: block;
}

.app-header-title {
    flex: 2 1 0;
    text-align: center;
}

.app-header-help {
    flex: 1 1 0;
    text-align: right;
    font-size: 0.85rem;
}

.app-header-help a {
    color: var(--brand-color);
    text-decoration: none;
    font-weight: 600;
}

.app-header-help a:hover {
    text-decoration: underline;
}

.app-header h1 {
    margin: 0 0 4px;
    color: var(--brand-color);
    font-size: 1.6rem;
}

.subtitle {
    color: var(--text-muted);
    margin: 0;
}

@media (max-width: 600px) {
    .app-header-row {
        flex-direction: column;
        text-align: center;
    }
    .app-header-help {
        text-align: center;
        order: 3;
    }
}

.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 28px;
    margin-top: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.field {
    margin-bottom: 22px;
}

.field label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    margin-bottom: 6px;
}

.field-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--brand-color);
    color: #fff;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.required-mark {
    color: var(--error);
}

.hint {
    margin: 0 0 6px 30px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

input[type="text"],
textarea,
select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    background: #fff;
    color: var(--text);
}

input[type="text"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--brand-color);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-color) 20%, transparent);
}

textarea {
    resize: vertical;
}

.field.has-error input,
.field.has-error textarea {
    border-color: var(--error);
}

.error-msg {
    margin: 6px 0 0 30px;
    color: var(--error);
    font-size: 0.85rem;
}

.ticket-lookup-field {
    padding: 14px 16px;
    background: #f8fafc;
    border: 1px dashed var(--border);
    border-radius: 10px;
}

.lookup-status {
    margin: 8px 0 0 0;
    font-size: 0.85rem;
    min-height: 1.1em;
}

.lookup-status.loading {
    color: var(--text-muted);
}

.lookup-status.success {
    color: #16a34a;
    font-weight: 600;
}

.lookup-status.error {
    color: var(--error);
}

.actions {
    margin-top: 28px;
    text-align: right;
}

.btn-submit {
    display: inline-block;
    background: var(--brand-color);
    color: #fff;
    border: none;
    padding: 12px 28px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: filter 0.15s ease;
}

.btn-submit:hover {
    filter: brightness(0.92);
}

.app-footer {
    margin-top: 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.app-footer a {
    color: var(--brand-color);
    font-weight: 600;
}

.confirm-card,
.error-card {
    text-align: center;
    margin-top: 60px;
}

.confirm-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    margin-top: 12px;
}

.btn-secondary {
    display: inline-block;
    background: transparent;
    color: var(--brand-color);
    border: 1px solid var(--brand-color);
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
}

.btn-secondary:hover {
    background: color-mix(in srgb, var(--brand-color) 8%, transparent);
}

.confirm-icon,
.error-icon,
.info-icon {
    width: 56px;
    height: 56px;
    line-height: 56px;
    border-radius: 50%;
    margin: 0 auto 16px;
    font-size: 1.6rem;
    font-weight: bold;
}

.confirm-icon {
    background: #dcfce7;
    color: #16a34a;
}

.error-icon {
    background: #fee2e2;
    color: var(--error);
}

.info-icon {
    background: #dbeafe;
    color: var(--brand-color);
    font-style: italic;
    font-weight: 700;
}

@media (max-width: 480px) {
    .card { padding: 20px; }
    .actions { text-align: stretch; }
    .btn-submit { width: 100%; text-align: center; }
}

/* --- Canale segnalazioni utenti finali (/s) --- */
.field[hidden] { display: none; }
.contesto { margin: 0 0 20px; }
.scelte-tipo { display: flex; flex-wrap: wrap; gap: 8px 24px; }
.scelta-tipo { font-weight: normal; cursor: pointer; }
.actions .btn-secondary { margin-right: 12px; }
.elenco-azioni { margin-bottom: 20px; }
.elenco-vuoto { color: #6b7280; }
.elenco-segnalazioni { list-style: none; margin: 0 0 16px; padding: 0; }
.elenco-segnalazioni li + li { border-top: 1px solid #e5e7eb; }
.elenco-segnalazioni a { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; padding: 14px 4px; color: inherit; text-decoration: none; }
.elenco-segnalazioni a:hover { background: #f9fafb; }
.seg-numero { color: #6b7280; font-variant-numeric: tabular-nums; }
.seg-titolo { font-weight: 600; overflow-wrap: anywhere; }
.seg-meta, .seg-stato { grid-column: 2; }
.seg-meta { color: #6b7280; font-size: 0.9em; }
.stato { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.85em; font-weight: 600; margin-right: 8px; }
.stato-ricevuta { background: #e0e7ff; color: #3730a3; }
.stato-attesa { background: #fef3c7; color: #92400e; }
.stato-carico { background: #dbeafe; color: #1e40af; }
.stato-risolta { background: #dcfce7; color: #166534; }
.stato-chiusa, .stato-nd { background: #f3f4f6; color: #4b5563; }
.stato-dettaglio { color: #4b5563; font-size: 0.9em; }
.seg-dettaglio-titolo { margin: 0 0 8px; overflow-wrap: anywhere; }
.seg-dettaglio-stato { margin-bottom: 16px; }
.seg-dati { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 20px; }
.seg-dati dt { color: #6b7280; }
.seg-dati dd { margin: 0; }
.seg-testo { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 6px; padding: 12px; }
.riga-contesto { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 6px 16px; margin: 0 0 20px; }
.riga-contesto .contesto { margin: 0; flex: 1 1 240px; min-width: 0; }
.link-guida { display: inline-flex; align-items: center; gap: 6px; flex: 0 1 auto; margin-left: auto; font-size: 0.9em; color: var(--brand-color); text-decoration: none; white-space: nowrap; }
.link-guida:hover { text-decoration: underline; }
.link-guida svg { width: 16px; height: 16px; flex: none; }
@media (max-width: 520px) { .link-guida { white-space: normal; margin-left: 0; } }
.nowrap { white-space: nowrap; }

/* --- Questionari nel canale segnalazioni (/s/questionari) --- */
.q-avviso { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; margin: 0 0 20px; padding: 14px 16px; background: color-mix(in srgb, var(--brand-color) 8%, #fff); border: 1px solid color-mix(in srgb, var(--brand-color) 35%, #fff); border-left: 4px solid var(--brand-color); border-radius: 8px; }
.q-avviso p { margin: 0; flex: 1 1 280px; }
.q-avviso .btn-submit { padding: 10px 20px; }
.q-avviso-fatto { margin: 0 0 20px; color: var(--text-muted); font-size: 0.9em; }
.q-avviso-fatto a { color: var(--brand-color); font-weight: 600; }
.q-intro { margin: 0 0 20px; }
.q-intro p { margin: 0 0 8px; }
.q-gia-risposto { margin: 0 0 20px; padding: 10px 14px; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 8px; color: #166534; }
.q-riepilogo-errori { margin: 0 0 16px; }
.q-sezione { margin: 0 0 8px; }
.q-sezione h2 { font-size: 1.1rem; color: var(--brand-color); margin: 28px 0 14px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.q-domanda { border: none; padding: 0; margin: 0 0 24px; min-width: 0; }
.q-testo { font-weight: 600; padding: 0; margin-bottom: 10px; }
.q-numero { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.q-domanda .error-msg { margin-left: 0; }
.q-domanda.has-error .q-testo { color: var(--error); }
.field.q-domanda label { display: inline-flex; font-weight: normal; margin: 0; cursor: pointer; }
.q-scelte { display: flex; flex-direction: column; gap: 8px; }
.q-scelta input, .q-punto input, .q-cella input { margin: 0 8px 0 0; }
.q-punti { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.q-estremi { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; font-size: 0.85rem; color: var(--text-muted); }
.q-griglia { width: 100%; border-collapse: collapse; font-size: 0.95em; }
.q-griglia th, .q-griglia td { padding: 8px 6px; border-bottom: 1px solid var(--border); }
.q-griglia thead th { font-weight: 600; font-size: 0.85rem; color: var(--text-muted); text-align: center; vertical-align: bottom; }
.q-griglia tbody th { font-weight: normal; text-align: left; }
.q-griglia td { text-align: center; }
.q-griglia .q-cella input { margin: 0; }
.q-opz-stretto { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.q-area { margin-top: 2px; }
.q-contatore { margin: 4px 0 0; text-align: right; }
@media (max-width: 600px) {
    .q-griglia thead { display: none; }
    .q-griglia, .q-griglia tbody, .q-griglia tr, .q-griglia th, .q-griglia td { display: block; width: auto; }
    .q-griglia tr { padding: 10px 0; border-bottom: 1px solid var(--border); }
    .q-griglia th, .q-griglia td { border: none; padding: 2px 0; text-align: left; }
    .q-griglia tbody th { font-weight: 600; margin-bottom: 4px; }
    .q-griglia td { display: inline-block; margin-right: 14px; }
    .q-griglia .q-cella input { margin-right: 6px; }
    .q-opz-stretto { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
}
