:root {
    --colore-primario: #1a3d5c;
    --colore-primario-scuro: #0f2740;
    --colore-sfondo: #f4f6f8;
    --colore-bordo: #d6dde3;
    --colore-testo: #1f2937;
    --colore-errore: #b3261e;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Helvetica Neue", Arial, sans-serif;
    background: var(--colore-sfondo);
    color: var(--colore-testo);
}

.topbar {
    background: var(--colore-primario);
    color: white;
}

.topbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 2rem;
}

.brand {
    color: white;
    font-weight: 700;
    text-decoration: none;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.brand-logo {
    height: 0.16em;
    width: auto;
    max-width: 0.4em;
    object-fit: contain;
}

.topbar nav { display: flex; gap: 1.25rem; flex: 1; }
.topbar nav a { color: #dbe7f0; text-decoration: none; }
.topbar nav a:hover { color: white; text-decoration: underline; }

.user-box { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; }

.link-button {
    background: none;
    border: none;
    color: #dbe7f0;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
    font-size: inherit;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

h1 { color: var(--colore-primario-scuro); }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.button, button[type="submit"], fieldset button {
    background: var(--colore-primario);
    color: white;
    border: none;
    padding: 0.55rem 1.1rem;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    font-size: 0.95rem;
}

.button:hover, button[type="submit"]:hover { background: var(--colore-primario-scuro); }

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.data-table th, .data-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--colore-bordo);
    text-align: left;
}

.data-table thead { background: #eaeff3; }

.riga-totale { font-weight: 700; background: #f7f9fa; }

.azioni a, .azioni form { display: inline-block; margin-right: 0.75rem; }
.azioni-header { display: flex; gap: 0.75rem; }

.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: capitalize;
}
.badge-bozza { background: #e5e7eb; color: #374151; }
.badge-in_revisione { background: #fef3c7; color: #92400e; }
.badge-approvato { background: #d1fae5; color: #065f46; }
.badge-inviato { background: #dbeafe; color: #1e40af; }

.form-standard, .login-box {
    background: white;
    padding: 1.5rem;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    max-width: 720px;
}

.form-standard fieldset {
    border: 1px solid var(--colore-bordo);
    border-radius: 4px;
    margin-bottom: 1.25rem;
}

.form-standard legend { font-weight: 600; color: var(--colore-primario-scuro); padding: 0 0.4rem; }

.riquadro-selezionabile {
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
}
.riquadro-selezionabile .checkbox-line { margin-bottom: 0.2rem; }
.bottone-vedi-testo { color: var(--colore-primario); font-size: 0.78rem; margin-left: 1.6rem; }
.testo-espandibile {
    margin: 0.4rem 0 0 1.6rem;
    width: calc(100% - 1.6rem);
    max-width: 640px;
}
textarea.testo-espandibile { font-size: 0.85rem; font-family: inherit; }
.testo-espandibile.testo-clausola-sola-lettura {
    background: #f8f9fa;
    border: 1px solid var(--colore-bordo);
    border-radius: 4px;
    padding: 0.6rem 0.75rem;
    font-size: 0.85rem;
    white-space: pre-wrap;
    color: #374151;
}

.form-standard label {
    display: block;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.form-standard input, .form-standard select, .form-standard textarea {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--colore-bordo);
    border-radius: 4px;
    font-size: 0.95rem;
}

.checkbox-line { display: flex; align-items: center; gap: 0.5rem; }
.checkbox-line input { width: auto; }

.azioni-form { display: flex; gap: 1rem; align-items: center; }
.azioni-stato { margin-top: 1.5rem; display: flex; gap: 1rem; flex-wrap: wrap; }

.form-inline-commento {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}
.form-inline-commento textarea { min-width: 260px; }

.errore { color: var(--colore-errore); font-weight: 600; }

.link-button-pericolo {
    color: #b91c1c;
    font-size: 0.85rem;
}
.link-button-pericolo:hover { color: #7f1d1d; }

.riquadro-attenzione {
    background: #fff7ed;
    border: 1px solid #fdba74;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1.5rem;
}

.testo-clausola-anteprima {
    max-width: 420px;
    font-size: 0.85rem;
    color: #4b5563;
    white-space: normal;
}

.riquadro-info {
    background: white;
    padding: 1rem;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 1.5rem;
    display: flex;
    gap: 1rem;
    align-items: center;
}

.scheda-dati {
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-top: 1.5rem;
}
.scheda-dati dt { font-weight: 600; color: var(--colore-primario-scuro); margin-top: 0.5rem; }
.scheda-dati dd { margin: 0 0 0.25rem 0; }

.filtro-form { display: flex; gap: 1.5rem; margin-bottom: 1rem; }
.filtro-form label { font-size: 0.9rem; }

.hint { font-size: 0.8rem; color: #6b7280; margin-top: 1rem; }

.griglia-impostazioni {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}
.scheda-impostazione {
    display: block;
    padding: 1.2rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.scheda-impostazione:hover {
    border-color: var(--colore-primario, #1a3d5c);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
.scheda-impostazione h2 { margin: 0 0 0.4rem; font-size: 1.05rem; color: var(--colore-primario-scuro); }
.scheda-impostazione p { margin: 0; font-size: 0.85rem; color: #6b7280; }
.logo-attuale { max-width: 200px; max-height: 100px; display: block; margin-bottom: 0.75rem; }

.campo-da-completare {
    border: 2px solid #d97706 !important;
    background: #fff7ed;
}

.badge-attenzione {
    display: inline-block;
    background: #fde68a;
    color: #78350f;
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
    margin-right: 0.4rem;
}

.ia-assist {
    background: white;
    padding: 1.25rem 1.5rem;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 1.5rem;
    max-width: 720px;
}
.ia-assist h2 { font-size: 1.1rem; color: var(--colore-primario-scuro); margin-top: 0; }
.ia-assist label { display: block; margin: 0.75rem 0 0.25rem; font-size: 0.9rem; }
.ia-assist textarea {
    width: 100%;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--colore-bordo);
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.9rem;
}
#area_prompt { margin: 0.5rem 0; }
#area_prompt textarea { background: #f7f9fa; }

.cella-catalogo { position: relative; margin-bottom: 0.35rem; }
.bottone-sfoglia-catalogo {
    color: var(--colore-primario);
    font-size: 0.78rem;
    margin-top: 0.15rem;
}
.categoria-sfoglia { font-size: 0.85rem; }
.categoria-sfoglia summary {
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    font-weight: 600;
    background: #f3f5f7;
    border-bottom: 1px solid #f0f0f0;
}
.categoria-sfoglia summary small { font-weight: 400; color: #6b7280; }
.suggerimenti-catalogo {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 30;
    background: white;
    border: 1px solid var(--colore-bordo);
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    width: 320px;
    max-height: 240px;
    overflow-y: auto;
}
.suggerimenti-catalogo:empty {
    border: none;
    box-shadow: none;
}
.suggerimento-catalogo {
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    font-size: 0.85rem;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
}
.suggerimento-catalogo:hover { background: #eaeff3; }
.suggerimento-vuoto { color: #6b7280; cursor: default; }
.suggerimento-vuoto:hover { background: none; }
.prezzo-suggerimento { color: #6b7280; white-space: nowrap; }
.categoria-suggerimento { color: #6b7280; font-weight: 400; }
