/* Foglio di stile unico, servito da nginx in produzione. */

:root {
    --blu-scuro: #17365d;
    --blu: #2563eb;
    --bordo: #e5e7eb;
    --testo-tenue: #64748b;
    --sfondo: #f3f6fa;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--sfondo);
    color: #1f2937;
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.45;
}

.header { background: var(--blu-scuro); color: #fff; padding: 18px 30px; }
.header-inner {
    max-width: 1400px; margin: auto;
    display: flex; justify-content: space-between; align-items: center;
    gap: 16px; flex-wrap: wrap;
}
.header h1 { margin: 0; font-size: 25px; }
.header a { color: #fff; text-decoration: none; }
.user-area { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

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

.card {
    background: #fff; border: 1px solid var(--bordo); border-radius: 12px;
    padding: 22px; margin-bottom: 20px; box-shadow: 0 2px 8px rgba(15, 23, 42, .04);
}
.login-card { max-width: 420px; margin: 70px auto; }
.login-card label { display: block; margin: 14px 0 6px; font-weight: 600; }
.login-card input { width: 100%; }

input, select {
    border: 1px solid #d1d5db; border-radius: 7px; padding: 10px; font-size: 14px;
    font-family: inherit;
}

button, .btn {
    border: 0; border-radius: 7px; padding: 10px 16px; background: var(--blu);
    color: #fff; cursor: pointer; font-size: 14px; font-weight: 600;
}
button:hover { background: #1d4ed8; }
.btn-link { background: none; padding: 0; font-weight: 600; text-decoration: underline; }
.btn-link:hover { background: none; }
form.inline { display: inline; }

table { width: 100%; border-collapse: collapse; }
th { background: #f8fafc; text-align: left; white-space: nowrap; }
th, td { padding: 13px 10px; border-bottom: 1px solid var(--bordo); vertical-align: middle; }
tr:hover td { background: #f8fafc; }

a { color: var(--blu); text-decoration: none; font-weight: 600; }

.badge { display: inline-block; padding: 4px 9px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.ok { background: #dcfce7; color: #166534; }
.warn { background: #fef3c7; color: #92400e; }
.danger { background: #fee2e2; color: #991b1b; }
.info { background: #dbeafe; color: #1e40af; }

.avviso { padding: 14px; border-radius: 8px; margin-bottom: 16px; }
.avviso.error { background: #fee2e2; color: #991b1b; }
.avviso.success { background: #dcfce7; color: #166534; }

.stats-grid { display: grid; grid-template-columns: repeat(5, minmax(140px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: #fff; border: 1px solid var(--bordo); border-radius: 12px; padding: 16px; }
.stat .label { color: var(--testo-tenue); font-size: 13px; font-weight: 700; }
.stat .value { font-size: 30px; font-weight: 800; margin-top: 3px; }

.dashboard-title {
    display: flex; justify-content: space-between; align-items: flex-end;
    gap: 16px; margin-bottom: 18px; flex-wrap: wrap;
}
.dashboard-title h2 { margin: 0; font-size: 26px; }
.dashboard-subtitle { color: var(--testo-tenue); margin-top: 4px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.btn { border-radius: 7px; padding: 10px 16px; display: inline-block; text-decoration: none; font-weight: 600; }
.btn-secondary { background: #475569; color: #fff; }
.btn-secondary:hover { background: #334155; }
.btn-light { background: #e2e8f0; color: #0f172a; }
.btn-light:hover { background: #cbd5e1; }

.titolo-elenco { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.titolo-elenco h2 { margin: 0; }
.azioni-paginazione { display: flex; gap: 8px; }

.filtri {
    display: grid;
    grid-template-columns: minmax(260px, 2fr) repeat(3, minmax(150px, 1fr)) auto;
    gap: 10px; align-items: end;
}
.filtri label { display: block; font-size: 12px; font-weight: 700; color: #475569; margin-bottom: 5px; }
.filtri input, .filtri select { width: 100%; }

.progress-track { height: 8px; background: var(--bordo); border-radius: 99px; overflow: hidden; margin-bottom: 4px; min-width: 130px; }
.progress-fill { height: 100%; background: var(--blu); border-radius: 99px; }
.muted { color: var(--testo-tenue); font-size: 12px; }

.paginazione { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; flex-wrap: wrap; }

@media (max-width: 1100px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
    .filtri { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
    .filtri { grid-template-columns: 1fr; }
}

/* --- dettaglio pratica --- */
.intestazione-pratica h2 { margin: 0 0 8px; font-size: 22px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.practice-layout {
    display: grid;
    grid-template-columns: minmax(320px, 420px) minmax(600px, 1fr);
    gap: 20px;
    align-items: start;
}

.metadata-card { position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow-y: auto; }
.metadata-title { font-size: 20px; font-weight: bold; margin-bottom: 18px; }

.info-groups { display: flex; flex-direction: column; gap: 12px; }
.info-box { border: 1px solid #dbe3ee; border-radius: 12px; background: #fff; overflow: hidden; }
.info-box > summary {
    cursor: pointer; list-style: none; font-weight: 800;
    padding: 16px 18px; background: #f7f9fc; user-select: none;
}
.info-box > summary::-webkit-details-marker { display: none; }
.info-box > summary::after { content: "+"; float: right; font-size: 20px; line-height: 18px; }
.info-box[open] > summary::after { content: "−"; }
.info-box[open] > summary { border-bottom: 1px solid var(--bordo); }
.info-box .metadata { padding: 4px 16px 12px; }

.metadata-row { padding: 10px 0; border-bottom: 1px solid var(--bordo); }
.metadata-row:last-child { border-bottom: 0; }
.metadata-label { color: var(--testo-tenue); font-size: 11px; font-weight: 700; text-transform: uppercase; margin-bottom: 3px; }
.metadata-value { font-size: 14px; word-break: break-word; }

.table-wrap { overflow-x: auto; }
.controls-table { table-layout: fixed; }
.controls-table th:nth-child(1) { width: 28%; }
.controls-table th:nth-child(2) { width: 47%; }
.controls-table th:nth-child(3) { width: 25%; }
.controls-table td { vertical-align: top; }
.control-text { line-height: 1.5; white-space: pre-line; }
.esito-select { width: 100%; min-width: 150px; margin-bottom: 8px; }
.controls-table textarea {
    width: 100%; min-height: 100px; font-family: inherit; font-size: 14px;
    border: 1px solid #d1d5db; border-radius: 7px; padding: 10px;
}
.small { font-size: 12px; color: var(--testo-tenue); }

.sospendi-box {
    margin-top: 14px; padding: 12px; background: #fff7ed;
    border: 1px solid #fed7aa; border-radius: 8px;
}
.sospendi-box.critica { border-left: 4px solid #dc2626; }
.sospendi-box label { display: flex; gap: 10px; align-items: flex-start; color: #9a3412; font-weight: 600; }
.sospendi-box input { min-width: auto; margin-top: 3px; }

.save-bar {
    position: sticky; bottom: 0; background: #fff; padding: 15px;
    border-top: 1px solid var(--bordo); margin-top: 20px;
    box-shadow: 0 -3px 10px rgba(0,0,0,.05);
}

@media (max-width: 1000px) {
    .practice-layout { grid-template-columns: 1fr; }
    .metadata-card { position: static; max-height: none; }
}

/* --- barra strumenti e assegnazione --- */
.form-import { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.form-import input[type="file"] { min-width: 220px; font-size: 13px; }
.form-assegna { display: flex; gap: 6px; margin-top: 6px; }
.form-assegna select { min-width: 130px; }
.form-assegna button { padding: 8px 12px; font-size: 13px; }

/* --- checklist per documento (v9) --- */
.avviso.warning { background: #fef3c7; color: #92400e; }
.testo-a-capo { white-space: pre-line; }
.document-checklist { display: flex; flex-direction: column; gap: 14px; }
.document-box { border: 1px solid #dbe3ee; border-radius: 12px; overflow: hidden; }
.document-box-header {
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
    background: #f8fafc; padding: 12px 16px; border-bottom: 1px solid var(--bordo);
}
.document-box-header h3 { margin: 0; font-size: 16px; }
.document-box-body { padding: 12px 16px; }
.document-questions { margin: 0 0 10px; padding-left: 20px; line-height: 1.5; }
.document-guidance { margin: 8px 0; }
.document-guidance > summary { cursor: pointer; color: var(--blu); font-weight: 600; font-size: 14px; }
.document-result { display: grid; grid-template-columns: minmax(150px, 1fr) 3fr; gap: 12px; margin-top: 10px; }
.document-result label { display: block; font-size: 12px; font-weight: 700; color: #475569; margin-bottom: 5px; }
.document-result textarea {
    width: 100%; min-height: 70px; font-family: inherit; font-size: 14px;
    border: 1px solid #d1d5db; border-radius: 7px; padding: 10px;
}
.storico > summary { cursor: pointer; font-weight: 700; }
@media (max-width: 700px) {
    .document-result { grid-template-columns: 1fr; }
}

/* --- 2FA --- */
.qr { display: flex; justify-content: center; margin: 14px 0; }
.qr svg { width: 220px; height: 220px; }
.chiave-2fa { font-family: monospace; font-size: 16px; letter-spacing: 1px; word-break: break-all; }
.codici-backup { columns: 2; font-family: monospace; font-size: 17px; line-height: 1.8; }
.login-card ol { padding-left: 20px; }
