/* =========================================================
   Fibra — foglio di stile
   I colori sono variabili CSS generate dal tema (Theme::css)
   ========================================================= */
:root {
    --c-primary: #3f4651; --c-primary-text: #fff; --c-secondary: #7a828e; --c-accent: #e0a526;
    --c-bg: #f4f5f7; --c-surface: #fff; --c-surface-alt: #f8f9fb; --c-text: #1f2430; --c-muted: #6b7280; --c-border: #e3e6eb;
    --c-success: #16a34a; --c-warning: #d97706; --c-danger: #dc2626; --c-info: #0284c7;
    --c-sidebar-bg: #1f2329; --c-sidebar-text: #c9ced6; --c-sidebar-active: #e0a526;
    --c-topbar-bg: #fff; --c-topbar-text: #1f2430; --c-header-bg: #fff; --c-header-text: #1f2430;
    --c-hero-from: #23272e; --c-hero-to: #4a525e; --c-hero-text: #fff; --c-footer-bg: #1f2329; --c-footer-text: #c9ced6;
    --c-auth-from: #23272e; --c-auth-to: #4a525e;
    --radius: 10px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
    --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 4px 14px rgba(16, 24, 40, .05);
    --shadow-lg: 0 18px 50px rgba(16, 24, 40, .18);
    --sidebar-w: 256px;
    --primary-soft: color-mix(in srgb, var(--c-primary) 11%, transparent);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.55; color: var(--c-text); background: var(--c-bg); -webkit-font-smoothing: antialiased; }
img { max-width: 100%; }
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; font-weight: 650; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.35rem; } h3 { font-size: 1.05rem; } h4 { font-size: .95rem; }
p { margin: 0 0 1em; }
hr { border: 0; border-top: 1px solid var(--c-border); margin: 18px 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .86em; background: var(--c-surface-alt); border: 1px solid var(--c-border); padding: 1px 5px; border-radius: 4px; }
[hidden] { display: none !important; }
.icon { flex-shrink: 0; vertical-align: middle; }
.muted { color: var(--c-muted); }
.small { font-size: .86rem; } .tiny { font-size: .75rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.text-right { text-align: right; } .text-center { text-align: center; }
.text-success { color: var(--c-success); } .text-danger { color: var(--c-danger); }
.nowrap { white-space: nowrap; }
.mt { margin-top: 16px; } .mt-sm { margin-top: 8px; }
.lead { font-size: 1.08rem; font-weight: 500; }
.label-sm { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--c-muted); font-weight: 600; margin-bottom: 6px; }
.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.container-narrow { max-width: 900px; }
.inline { display: inline; }

/* ---------- Bottoni ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 16px; font: inherit; font-size: .92rem; font-weight: 550; line-height: 1.2;
    border-radius: var(--radius); border: 1px solid transparent; cursor: pointer; background: var(--c-surface-alt); color: var(--c-text); text-decoration: none !important; transition: background .15s, border-color .15s, box-shadow .15s, color .15s; white-space: nowrap; }
.btn:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--c-primary); color: var(--c-primary-text); }
.btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--c-primary) 86%, #000); }
.btn-outline { background: var(--c-surface); border-color: var(--c-border); color: var(--c-text); }
.btn-outline:hover { border-color: var(--c-primary); color: var(--c-primary); }
.btn-ghost { background: transparent; color: var(--c-text); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-light { background: #fff; color: #1f2430; }
.btn-light:hover { background: #f1f1f1; }
.btn-danger { background: var(--c-danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--c-danger) 85%, #000); }
.btn-danger-outline { background: transparent; border-color: color-mix(in srgb, var(--c-danger) 45%, transparent); color: var(--c-danger); }
.btn-danger-outline:hover:not(:disabled) { background: color-mix(in srgb, var(--c-danger) 8%, transparent); }
.btn-sm { padding: 6px 11px; font-size: .84rem; }
.btn-lg { padding: 12px 22px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 7px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn-row.center { justify-content: center; }
.link-btn { background: none; border: 0; padding: 0; color: var(--c-primary); cursor: pointer; font: inherit; font-size: .88rem; }
.link-btn:hover { text-decoration: underline; }

/* ---------- Form ---------- */
.form .field, .field { margin-bottom: 16px; }
label { font-weight: 550; font-size: .88rem; display: inline-block; margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=search], input:not([type]), select, textarea {
    width: 100%; font: inherit; font-size: .95rem; color: var(--c-text); background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius);
    padding: 9px 12px; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--primary-soft); }
input:disabled, select:disabled { background: var(--c-surface-alt); color: var(--c-muted); }
textarea { resize: vertical; min-height: 70px; }
textarea.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .84rem; line-height: 1.5; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
input[type=file] { font-size: .86rem; max-width: 100%; }
input[type=range] { width: 100%; accent-color: var(--c-primary); }
input[type=checkbox], input[type=radio] { accent-color: var(--c-primary); width: 16px; height: 16px; margin: 0; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.hint { display: block; margin-top: 5px; font-size: .8rem; color: var(--c-muted); }
.field-error { color: var(--c-danger); font-size: .82rem; margin-top: 5px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 450; font-size: .88rem; margin: 6px 0 12px; cursor: pointer; }
.input-group { display: flex; gap: 6px; }
.input-group input { flex: 1; }
.input-icon { position: relative; flex: 1; min-width: 200px; }
.input-icon .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--c-muted); }
.input-icon input { padding-left: 36px; }
.input-suffix, .input-prefix { display: flex; align-items: stretch; }
.input-suffix input { border-radius: var(--radius) 0 0 var(--radius); }
.input-prefix input { border-radius: 0 var(--radius) var(--radius) 0; }
.input-suffix span, .input-prefix span { display: flex; align-items: center; padding: 0 12px; background: var(--c-surface-alt); border: 1px solid var(--c-border); color: var(--c-muted); font-weight: 600; }
.input-suffix span { border-left: 0; border-radius: 0 var(--radius) var(--radius) 0; }
.input-prefix span { border-right: 0; border-radius: var(--radius) 0 0 var(--radius); }
.input-code { font-size: 1.45rem !important; letter-spacing: .32em; text-align: center; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 8px; }
.sticky-actions { position: sticky; bottom: 0; z-index: 5; background: color-mix(in srgb, var(--c-bg) 92%, transparent); backdrop-filter: blur(6px); padding: 12px 0; margin-top: 0; border-top: 1px solid var(--c-border); }
.form-section { padding-bottom: 6px; margin-bottom: 18px; border-bottom: 1px dashed var(--c-border); }
.form-section:last-of-type { border-bottom: 0; }
.form-section h4, .form-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; color: var(--c-muted); margin: 4px 0 14px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form input, .inline-form select { width: auto; flex: 1; min-width: 140px; }
.inline-form .btn { flex: none; }

/* campo di ricerca con suggerimenti (combobox) */
.combo { position: relative; }
.combo-control { position: relative; }
.combo-control > .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--c-muted); pointer-events: none; }
.combo-control input { padding-left: 36px; padding-right: 38px; }
.combo-clear { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); display: inline-flex; padding: 5px; border: 0; background: none; color: var(--c-muted); border-radius: 6px; cursor: pointer; }
.combo-clear:hover { color: var(--c-text); background: var(--primary-soft); }
.combo-loading .combo-control > .icon { animation: combo-pulse .8s ease-in-out infinite alternate; }
@keyframes combo-pulse { from { opacity: .3; } to { opacity: 1; } }
.combo-invalid input[data-combo-input] { border-color: var(--c-danger); }
.combo-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 45; list-style: none; margin: 0; padding: 5px; max-height: 330px; overflow-y: auto;
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.combo-list [role=option] { display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.combo-list [role=option].active { background: var(--primary-soft); }
.combo-list [role=option].current .combo-label::after { content: " ✓"; color: var(--c-primary); }
.combo-label { font-weight: 550; font-size: .92rem; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.combo-sub { font-size: .78rem; color: var(--c-muted); }
.combo-list mark { background: color-mix(in srgb, var(--c-accent) 30%, transparent); color: inherit; border-radius: 2px; padding: 0 1px; }
.combo-note { padding: 8px 10px; font-size: .8rem; color: var(--c-muted); }
.combo-create { border-top: 1px solid var(--c-border); margin-top: 4px; padding: 6px 4px 2px; }
.combo-create a { display: block; padding: 6px 6px; border-radius: 6px; font-size: .88rem; font-weight: 550; }
.combo-create a:hover { background: var(--primary-soft); text-decoration: none; }

/* switch */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: none; }
.switch input[type=checkbox] { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: color-mix(in srgb, var(--c-muted) 45%, transparent); border-radius: 22px; transition: .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--c-primary); }
.switch input:checked + span::before { transform: translateX(18px); }
.switch input:disabled + span { opacity: .6; cursor: not-allowed; }
.switch-row { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }

/* radio cards */
.radio-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 18px; }
.radio-card { position: relative; display: block; margin: 0; cursor: pointer; font-weight: 400; }
.radio-card input { position: absolute; opacity: 0; }
.radio-card > span { display: flex; flex-direction: column; gap: 3px; padding: 14px 16px; border: 2px solid var(--c-border); border-radius: var(--radius); background: var(--c-surface); transition: .15s; height: 100%; }
.radio-card > span .icon { color: var(--c-primary); margin-bottom: 4px; }
.radio-card small { color: var(--c-muted); font-size: .82rem; }
.radio-card input:checked + span { border-color: var(--c-primary); background: var(--primary-soft); }
.radio-card input:focus-visible + span { box-shadow: 0 0 0 3px var(--primary-soft); }
.radio-card input:disabled + span { opacity: .5; cursor: not-allowed; }
.radio-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.radio-line { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius); font-weight: 450; cursor: pointer; margin: 0; }
.radio-line:hover { background: var(--c-surface-alt); }

/* ---------- Griglie ---------- */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.grid-2.tight, .grid-3.tight, .grid-4.tight { gap: 0 16px; }
.span-2 { grid-column: span 2; }
.align-start { align-items: start; }
.grid-2 > .card, .grid-3 > .card { margin-bottom: 0; }
.grid-2 + .card, .grid-3 + .card, .grid-2 + .grid-2, .grid-2 + .summary-grid, .grid-3 + .card { margin-top: 20px; }
.grid-2.align-start > div > .card + .card { margin-top: 20px; }
.grid-2.align-start > div > .card { margin-bottom: 0; }

/* ---------- Card ---------- */
.card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: calc(var(--radius) + 2px); padding: 20px 22px; box-shadow: var(--shadow-sm); margin-bottom: 20px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h3 { margin: 0; display: flex; align-items: center; gap: 8px; }
.card-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--c-border); }
.card-highlight { border: 2px solid var(--c-primary); background: color-mix(in srgb, var(--c-primary) 4%, var(--c-surface)); }
.danger-zone { border-color: color-mix(in srgb, var(--c-danger) 35%, var(--c-border)); }
.danger-zone h3 { color: var(--c-danger); }
.form-card { max-width: 920px; }
.empty { text-align: center; padding: 34px 20px; color: var(--c-muted); }
.empty .icon { color: var(--c-muted); opacity: .6; margin-bottom: 8px; }
.empty h3 { color: var(--c-text); }
.empty.small { padding: 14px; }
td.empty { padding: 26px; }

/* ---------- Alert ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: .92rem; border: 1px solid; position: relative; }
.alert > .icon { margin-top: 2px; }
.alert > div { flex: 1; }
.alert-success { background: color-mix(in srgb, var(--c-success) 9%, var(--c-surface)); border-color: color-mix(in srgb, var(--c-success) 30%, transparent); color: color-mix(in srgb, var(--c-success) 60%, var(--c-text)); }
.alert-danger, .alert-error { background: color-mix(in srgb, var(--c-danger) 8%, var(--c-surface)); border-color: color-mix(in srgb, var(--c-danger) 30%, transparent); color: color-mix(in srgb, var(--c-danger) 65%, var(--c-text)); }
.alert-warning { background: color-mix(in srgb, var(--c-warning) 10%, var(--c-surface)); border-color: color-mix(in srgb, var(--c-warning) 35%, transparent); color: color-mix(in srgb, var(--c-warning) 55%, var(--c-text)); }
.alert-info { background: color-mix(in srgb, var(--c-info) 8%, var(--c-surface)); border-color: color-mix(in srgb, var(--c-info) 28%, transparent); color: color-mix(in srgb, var(--c-info) 55%, var(--c-text)); }
.alert a { color: inherit; font-weight: 600; text-decoration: underline; }
.alert-close { background: none; border: 0; font-size: 1.3rem; line-height: 1; cursor: pointer; color: inherit; opacity: .6; padding: 0 2px; }
.alert-close:hover { opacity: 1; }

/* ---------- Badge ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--c-surface-alt); color: var(--c-muted); border: 1px solid var(--c-border); white-space: nowrap; }
.badge-primary { background: var(--primary-soft); color: var(--c-primary); border-color: transparent; }
.badge-success { background: color-mix(in srgb, var(--c-success) 13%, transparent); color: var(--c-success); border-color: transparent; }
.badge-danger { background: color-mix(in srgb, var(--c-danger) 12%, transparent); color: var(--c-danger); border-color: transparent; }
.badge-warning { background: color-mix(in srgb, var(--c-warning) 14%, transparent); color: var(--c-warning); border-color: transparent; }
.badge-info { background: color-mix(in srgb, var(--c-info) 12%, transparent); color: var(--c-info); border-color: transparent; }

/* ---------- Tabelle ---------- */
.table-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--c-muted); font-weight: 600; padding: 10px 10px; border-bottom: 1px solid var(--c-border); white-space: nowrap; }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table-hover tbody tr[data-href] { cursor: pointer; }
.table-hover tbody tr:hover td { background: var(--c-surface-alt); }
.table tfoot th { font-size: .85rem; text-transform: none; letter-spacing: 0; color: var(--c-text); background: var(--c-surface-alt); border-top: 2px solid var(--c-border); }
.table-calc td, .table-calc th { white-space: nowrap; }
.table-logs td { vertical-align: top; }
.log-pre { background: var(--c-surface-alt); border: 1px solid var(--c-border); border-radius: 6px; padding: 10px; font-size: .78rem; overflow-x: auto; white-space: pre-wrap; word-break: break-all; margin: 6px 0 0; }
.pagination { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; margin-top: 16px; }
.pagination a, .pagination .dots { min-width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; padding: 0 8px; font-size: .88rem; }
.pagination a { border: 1px solid var(--c-border); color: var(--c-text); text-decoration: none; }
.pagination a.active { background: var(--c-primary); color: var(--c-primary-text); border-color: var(--c-primary); }

/* ---------- Toolbar / tabs ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px 14px; }
.toolbar select { width: auto; min-width: 160px; }
.tabs-scroll { overflow-x: auto; margin-bottom: 18px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--c-border); min-width: max-content; }
.tabs a { padding: 10px 14px; color: var(--c-muted); font-weight: 550; font-size: .9rem; border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none; display: flex; align-items: center; gap: 6px; }
.tabs a:hover { color: var(--c-text); }
.tabs a.active { color: var(--c-primary); border-bottom-color: var(--c-primary); }
.tabs .count { background: var(--c-surface-alt); border: 1px solid var(--c-border); border-radius: 999px; font-size: .72rem; padding: 0 7px; color: var(--c-muted); }
.segmented { display: flex; background: var(--c-surface-alt); border: 1px solid var(--c-border); border-radius: var(--radius); padding: 3px; gap: 3px; margin-bottom: 18px; flex-wrap: wrap; }
.segmented a { flex: 1; text-align: center; padding: 7px 10px; border-radius: calc(var(--radius) - 2px); font-size: .85rem; color: var(--c-muted); font-weight: 550; text-decoration: none; white-space: nowrap; }
.segmented a.active { background: var(--c-surface); color: var(--c-text); box-shadow: var(--shadow-sm); }
.segmented.compact { margin: 0; }

/* =========================================================
   Layout area riservata
   ========================================================= */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--c-sidebar-bg); color: var(--c-sidebar-text); position: fixed; top: 0; bottom: 0; left: 0; display: flex; flex-direction: column; z-index: 40; transition: transform .25s; }
.impersonate-bar ~ .app .sidebar { top: 44px; }
.sidebar-head { padding: 18px 20px; border-bottom: 1px solid color-mix(in srgb, var(--c-sidebar-text) 12%, transparent); }
.sidebar .brand, .sidebar .brand-name { color: #fff; color: color-mix(in srgb, var(--c-sidebar-text) 30%, #fff); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 12px 20px; }
.nav-group { font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; padding: 16px 10px 6px; opacity: .55; font-weight: 700; }
.nav-link { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: var(--radius); color: var(--c-sidebar-text); font-size: .9rem; font-weight: 500; text-decoration: none !important; margin-bottom: 2px; transition: background .15s, color .15s; }
.nav-link:hover { background: color-mix(in srgb, var(--c-sidebar-text) 10%, transparent); color: #fff; }
.nav-link.active { background: color-mix(in srgb, var(--c-sidebar-active) 18%, transparent); color: var(--c-sidebar-active); font-weight: 600; box-shadow: inset 3px 0 0 var(--c-sidebar-active); }
.sidebar-foot { padding: 14px 20px; font-size: .74rem; opacity: .6; border-top: 1px solid color-mix(in srgb, var(--c-sidebar-text) 12%, transparent); }
.sidebar-foot a { color: inherit; }
.app-main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; height: 62px; background: var(--c-topbar-bg); color: var(--c-topbar-text); border-bottom: 1px solid var(--c-border); display: flex; align-items: center; gap: 12px; padding: 0 24px; }
.topbar .btn-ghost { color: var(--c-topbar-text); }
.topbar-toggle { display: none; }
.topbar-title { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0; transition: opacity .2s; }
.scrolled .topbar-title { opacity: 1; }
.content { padding: 26px 28px 40px; max-width: 1400px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0 0 4px; font-size: 1.55rem; }
.page-head h1 small { font-size: .7em; font-weight: 500; }
.page-head p { margin: 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.impersonate-bar { position: sticky; top: 0; z-index: 60; height: 44px; display: flex; align-items: center; justify-content: center; gap: 12px; background: var(--c-warning); color: #fff; font-size: .88rem; padding: 0 16px; }
.impersonate-bar form { margin: 0; }
.impersonate-bar ~ .app .topbar { top: 44px; }

/* menu utente */
.dropdown { position: relative; }
.user-menu { display: flex; align-items: center; gap: 10px; background: none; border: 0; cursor: pointer; padding: 5px 8px; border-radius: var(--radius); color: var(--c-topbar-text); font: inherit; text-align: left; }
.user-menu:hover { background: color-mix(in srgb, var(--c-topbar-text) 7%, transparent); }
.user-menu-name { display: flex; flex-direction: column; font-size: .88rem; font-weight: 600; line-height: 1.2; }
.user-menu-name small { font-weight: 400; opacity: .65; font-size: .75rem; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: var(--shadow-lg); min-width: 210px; padding: 6px; display: none; z-index: 50; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 6px; color: var(--c-text); font-size: .9rem; text-decoration: none; }
.dropdown-menu a:hover { background: var(--c-surface-alt); }
.dropdown-sep { height: 1px; background: var(--c-border); margin: 5px 0; }

/* avatar */
.avatar { border-radius: 50%; object-fit: cover; flex: none; display: inline-block; }
.avatar-initials { display: inline-flex; align-items: center; justify-content: center; background: var(--primary-soft); color: var(--c-primary); font-weight: 700; }
.avatar-edit { display: flex; gap: 20px; align-items: center; }
.avatar-edit p { margin-bottom: 10px; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-list { list-style: none; margin: 0; padding: 0; }
.user-list li { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--c-border); }
.user-list li:last-child { border-bottom: 0; }
.user-list li > div:nth-child(2) { flex: 1; min-width: 0; }
.user-summary { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0 0 14px; font-size: .9rem; }
.dl dt { color: var(--c-muted); }
.dl dd { margin: 0; }

/* stat */
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-bottom: 20px; }
.stat { display: flex; gap: 14px; align-items: center; margin: 0; color: var(--c-text); text-decoration: none !important; transition: box-shadow .15s, transform .15s; }
a.stat:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.stat-icon { width: 46px; height: 46px; border-radius: var(--radius); background: var(--primary-soft); color: var(--c-primary); display: flex; align-items: center; justify-content: center; flex: none; }
.stat-icon-success { background: color-mix(in srgb, var(--c-success) 12%, transparent); color: var(--c-success); }
.stat-icon-danger { background: color-mix(in srgb, var(--c-danger) 11%, transparent); color: var(--c-danger); }
.stat-value { font-size: 1.45rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: .84rem; color: var(--c-muted); }

/* onboarding */
.onboarding h3 { margin-bottom: 12px; }
.steps { list-style: none; padding: 0; margin: 0; display: flex; gap: 12px; flex-wrap: wrap; }
.steps li { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border: 1px solid var(--c-border); border-radius: var(--radius); flex: 1; min-width: 200px; }
.steps li span { width: 26px; height: 26px; border-radius: 50%; background: var(--primary-soft); color: var(--c-primary); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; }
.steps li.done { opacity: .65; }
.steps li.done span { background: var(--c-success); color: #fff; }

/* aziende */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 20px; }
.cards-grid .card { margin: 0; display: flex; flex-direction: column; }
.company-card-head, .company-inline { display: flex; gap: 14px; align-items: center; }
.company-card-head { margin-bottom: 14px; }
.company-card-head h3 { margin: 0 0 2px; }
.company-inline h3 { margin: 0; }
.company-logo { width: 56px; height: 56px; border-radius: var(--radius); border: 1px solid var(--c-border); background: #fff; display: flex; align-items: center; justify-content: center; overflow: hidden; flex: none; }
.company-logo img { max-width: 100%; max-height: 100%; object-fit: contain; padding: 4px; }
.company-logo span { font-weight: 700; color: var(--c-primary); }
.company-logo.sm { width: 42px; height: 42px; }
.company-logo.xs { width: 30px; height: 30px; font-size: .75rem; }
.meta-list { list-style: none; padding: 0; margin: 0; font-size: .87rem; color: var(--c-muted); flex: 1; }
.meta-list li { display: flex; gap: 8px; align-items: center; padding: 3px 0; }
.logo-upload { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.logo-preview { width: 140px; height: 90px; border: 1px dashed var(--c-border); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; background: #fff; overflow: hidden; }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* calcoli */
.company-section .card-head { padding-bottom: 12px; border-bottom: 1px solid var(--c-border); }
.items-head, .item-row { display: grid; grid-template-columns: minmax(140px, 1.6fr) minmax(205px, 1.45fr) minmax(108px, .85fr) minmax(108px, .85fr) minmax(60px, .45fr) minmax(88px, .62fr) minmax(130px, 1fr) 40px; gap: 10px; align-items: center; }
.items-head { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--c-muted); font-weight: 600; padding: 0 0 8px; border-bottom: 1px solid var(--c-border); margin-bottom: 10px; }
.item-row { padding: 6px 0; }
.item-row .field { margin: 0; }
.item-row .m-label { display: none; }
.item-result { text-align: right; font-size: .85rem; line-height: 1.35; }
.item-result strong { display: block; font-size: .95rem; }
.item-result .text-success { font-size: .8rem; }
.item-row input[data-item-setup]:disabled { background: var(--c-surface-alt); }
.item-row input[data-item-margin]:not(:placeholder-shown) { border-color: var(--c-accent); background: color-mix(in srgb, var(--c-accent) 8%, var(--c-surface)); }
.badge-custom { background: color-mix(in srgb, var(--c-accent) 18%, transparent); color: color-mix(in srgb, var(--c-accent) 60%, var(--c-text)); border-color: transparent; }
[data-item-add] { margin-top: 12px; }
.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 20px; }
.summary-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.item-result .setup-line { display: block; margin-top: 3px; padding-top: 3px; border-top: 1px dashed var(--c-border); }
.row-sub td { border-top: 0 !important; padding-top: 2px !important; }
.row-sub td:first-child { padding-left: 22px; color: var(--c-muted); }
.table tr.row-has-sub td { border-bottom: 0; }
.card .summary-grid { margin-bottom: 0; }
.summary-box { border: 1px solid var(--c-border); border-radius: calc(var(--radius) + 2px); padding: 18px; background: var(--c-surface); box-shadow: var(--shadow-sm); }
.summary-box h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--c-muted); margin-bottom: 12px; }
.summary-box dl { display: grid; grid-template-columns: 1fr auto; gap: 7px 10px; margin: 0; font-size: .9rem; }
.summary-box dt { color: var(--c-muted); }
.summary-box dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.summary-box dd.profit { color: var(--c-success); font-weight: 700; font-size: 1.12rem; }
.summary-box.highlight { background: var(--c-primary); border-color: var(--c-primary); color: var(--c-primary-text); }
.summary-box.highlight h4, .summary-box.highlight dt { color: color-mix(in srgb, var(--c-primary-text) 75%, transparent); }
.summary-box.highlight dd.profit { color: var(--c-primary-text); }
.summary-box .empty-note { color: var(--c-muted); font-size: .85rem; grid-column: 1 / -1; }
.info-cards .card { margin-bottom: 0; }
.info-cards + .card, .info-cards + .summary-grid { margin-top: 20px; }

/* 2FA */
.backup-codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 14px 0; }
.backup-codes code { font-size: 1rem; padding: 8px; text-align: center; letter-spacing: .06em; background: var(--c-surface); }
.setup-steps { padding-left: 20px; font-size: .9rem; }
.setup-steps li { margin-bottom: 6px; }
.secret { word-break: break-all; font-size: .85rem; }
.qr-box { display: flex; justify-content: center; padding: 14px; background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius); margin-bottom: 14px; }
#qrcode img, #qrcode canvas { display: block; }

/* modale e cropper */
.modal { position: fixed; inset: 0; background: rgba(10, 14, 20, .55); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-dialog { background: var(--c-surface); border-radius: calc(var(--radius) + 4px); width: 100%; max-width: 440px; box-shadow: var(--shadow-lg); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--c-border); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--c-border); }
.cropper { position: relative; width: 320px; height: 320px; max-width: 100%; margin: 0 auto; border-radius: var(--radius); overflow: hidden; background: #111; touch-action: none; cursor: grab; }
.cropper:active { cursor: grabbing; }
.cropper canvas { display: block; width: 100%; height: 100%; }
.cropper-mask { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle at center, transparent 0, transparent 149px, rgba(0,0,0,.55) 150px); }
.cropper-mask::after { content: ""; position: absolute; left: 50%; top: 50%; width: 300px; height: 300px; transform: translate(-50%, -50%); border: 2px solid rgba(255,255,255,.85); border-radius: 50%; }
.cropper-controls { display: flex; align-items: center; gap: 10px; margin: 14px 0 6px; }
.cropper-controls .btn { font-size: 1.2rem; width: 36px; height: 36px; }

/* grafico */
.chart svg { width: 100%; height: 250px; display: block; }
.chart .bar { fill: var(--c-primary); opacity: .85; }
.chart .bar-accent { fill: var(--c-accent); }
.chart g:hover .bar { opacity: 1; }
.chart .grid-line { stroke: var(--c-border); stroke-width: 1; }
.chart .axis { fill: var(--c-muted); font-size: 11px; }
.legend { font-size: .8rem; color: var(--c-muted); display: flex; align-items: center; gap: 6px; }
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-left: 8px; }
.lg-primary { background: var(--c-primary); } .lg-accent { background: var(--c-accent); }
.bar-list { display: flex; flex-direction: column; gap: 11px; }
.bar-item-head { display: flex; justify-content: space-between; font-size: .88rem; margin-bottom: 4px; gap: 10px; }
.bar-track { height: 7px; background: var(--c-surface-alt); border-radius: 6px; overflow: hidden; }
.bar-track div { height: 100%; background: var(--c-primary); border-radius: 6px; }

/* liste di controllo */
.check-list { list-style: none; padding: 0; margin: 0 0 16px; }
.check-list li { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--c-border); font-size: .9rem; }
.check-list li:last-child { border-bottom: 0; }
.check-list li .icon { margin-top: 3px; }
.check-list li.ok .icon { color: var(--c-success); }
.check-list li.ko .icon { color: var(--c-danger); }
.check-list li.warn .icon { color: var(--c-warning); }

/* tema */
.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.preset { background: var(--c-surface); border: 2px solid var(--c-border); border-radius: var(--radius); padding: 8px; cursor: pointer; text-align: left; font: inherit; color: var(--c-text); transition: .15s; }
.preset:hover { border-color: var(--c-secondary); }
.preset.active { border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.preset-swatch { display: flex; height: 38px; border-radius: 6px; overflow: hidden; margin-bottom: 7px; border: 1px solid rgba(0,0,0,.08); }
.preset-swatch i { flex: 1; }
.preset-name { font-size: .85rem; font-weight: 600; }
.theme-layout { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 20px; align-items: start; }
.theme-preview-wrap { position: sticky; top: 82px; }
.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px 16px; }
.color-field { display: flex; align-items: center; gap: 10px; margin: 0; font-weight: 450; font-size: .86rem; cursor: pointer; }
.color-field input[type=color] { width: 42px; height: 34px; border: 1px solid var(--c-border); border-radius: 8px; padding: 2px; background: var(--c-surface); cursor: pointer; flex: none; }
.color-field span { display: flex; flex-direction: column; line-height: 1.25; }
.color-field code { font-size: .72rem; background: none; border: 0; padding: 0; color: var(--c-muted); }
.theme-preview { --p-radius: var(--radius); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--c-border); font-size: 12px; }
.tp-app { display: flex; height: 230px; }
.tp-sidebar { width: 110px; background: var(--tp-sidebar_bg, var(--c-sidebar-bg)); color: var(--tp-sidebar_text, var(--c-sidebar-text)); padding: 10px 8px; }
.tp-brand { display: flex; align-items: center; gap: 6px; font-weight: 700; margin-bottom: 12px; color: #fff; }
.tp-brand span { width: 16px; height: 16px; border-radius: 4px; background: var(--tp-primary, var(--c-primary)); }
.tp-link { padding: 5px 7px; border-radius: 5px; margin-bottom: 3px; }
.tp-link.active { color: var(--tp-sidebar_active, var(--c-sidebar-active)); background: color-mix(in srgb, var(--tp-sidebar_active, var(--c-sidebar-active)) 18%, transparent); font-weight: 600; }
.tp-main { flex: 1; background: var(--tp-bg, var(--c-bg)); display: flex; flex-direction: column; }
.tp-topbar { background: var(--tp-topbar_bg, var(--c-topbar-bg)); color: var(--tp-topbar_text, var(--c-topbar-text)); padding: 9px 12px; font-weight: 600; border-bottom: 1px solid var(--tp-border, var(--c-border)); }
.tp-body { padding: 12px; }
.tp-card { background: var(--tp-surface, var(--c-surface)); border: 1px solid var(--tp-border, var(--c-border)); border-radius: var(--tp-radius, var(--radius)); padding: 12px; color: var(--tp-text, var(--c-text)); }
.tp-title { font-weight: 700; }
.tp-muted { color: var(--tp-muted, var(--c-muted)); margin-bottom: 9px; }
.tp-btns, .tp-badges { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.tp-btn { background: var(--tp-primary, var(--c-primary)); color: var(--tp-primary_text, var(--c-primary-text)); padding: 5px 10px; border-radius: var(--tp-radius, var(--radius)); font-weight: 600; }
.tp-btn-accent { background: var(--tp-accent, var(--c-accent)); }
.tp-badges span { padding: 2px 8px; border-radius: 99px; font-weight: 600; font-size: 11px; }
.tp-ok { color: var(--tp-success, var(--c-success)); background: color-mix(in srgb, var(--tp-success, var(--c-success)) 14%, transparent); }
.tp-warn { color: var(--tp-warning, var(--c-warning)); background: color-mix(in srgb, var(--tp-warning, var(--c-warning)) 14%, transparent); }
.tp-err { color: var(--tp-danger, var(--c-danger)); background: color-mix(in srgb, var(--tp-danger, var(--c-danger)) 14%, transparent); }
.tp-public { border-top: 1px solid var(--c-border); }
.tp-header { background: var(--tp-header_bg, var(--c-header-bg)); color: var(--tp-header_text, var(--c-header-text)); padding: 8px 12px; font-weight: 600; border-bottom: 1px solid var(--tp-border, var(--c-border)); }
.tp-hero { background: linear-gradient(135deg, var(--tp-hero_from, var(--c-hero-from)), var(--tp-hero_to, var(--c-hero-to))); color: var(--tp-hero_text, var(--c-hero-text)); padding: 22px 12px; font-weight: 700; font-size: 14px; }
.tp-footer { background: var(--tp-footer_bg, var(--c-footer-bg)); color: var(--tp-footer_text, var(--c-footer-text)); padding: 9px 12px; }

/* immagini admin */
.image-slot { height: 150px; border: 1px dashed var(--c-border); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; margin-bottom: 12px; overflow: hidden; background: var(--c-surface-alt); }
.image-slot img { max-height: 100%; max-width: 100%; object-fit: contain; }
.image-slot.checker { background: repeating-conic-gradient(#e9ecef 0% 25%, #fff 0% 50%) 50% / 18px 18px; }

/* editor legale */
.grid-legal { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.editor-toolbar { display: flex; gap: 3px; flex-wrap: wrap; }
.editor-toolbar button { border: 1px solid var(--c-border); background: var(--c-surface); border-radius: 6px; padding: 3px 9px; cursor: pointer; font-size: .8rem; color: var(--c-text); }
.editor-toolbar button:hover { border-color: var(--c-primary); }
.preview-pane { max-height: 640px; overflow: auto; margin-top: 10px; }
.placeholder-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--c-border); background: var(--c-surface-alt); border-radius: 999px; padding: 3px 10px; font-size: .74rem; cursor: pointer; font-family: ui-monospace, Menlo, monospace; color: var(--c-text); }
.chip:hover { border-color: var(--c-primary); color: var(--c-primary); }

/* prose (pagine legali) */
.prose { font-size: .97rem; line-height: 1.7; }
.prose h2 { font-size: 1.18rem; margin-top: 1.7em; padding-top: .3em; }
.prose h2:first-child { margin-top: 0; }
.prose ul { padding-left: 1.3em; }
.prose li { margin-bottom: .45em; }
.prose table { width: 100%; border-collapse: collapse; margin: 1em 0; font-size: .9rem; }
.prose th, .prose td { border: 1px solid var(--c-border); padding: 8px 10px; text-align: left; vertical-align: top; }
.prose th { background: var(--c-surface-alt); }
.ph-missing { background: color-mix(in srgb, var(--c-danger) 12%, transparent); color: var(--c-danger); padding: 0 4px; border-radius: 4px; font-size: .85em; }

/* captcha */
.captcha-internal { margin-bottom: 16px; }
.captcha-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.captcha-img { border-radius: 8px; border: 1px solid var(--c-border); background: #fff; }
.captcha-box { margin-bottom: 16px; min-height: 20px; }
.captcha-note { font-size: .72rem; color: var(--c-muted); }
.grecaptcha-badge { visibility: hidden; }

/* =========================================================
   Sito pubblico
   ========================================================= */
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 750; font-size: 1.12rem; color: var(--c-header-text); text-decoration: none !important; }
.brand img { display: block; width: auto; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--c-primary); color: var(--c-primary-text); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; flex: none; }
.site-header { background: var(--c-header-bg); color: var(--c-header-text); border-bottom: 1px solid color-mix(in srgb, var(--c-header-text) 10%, transparent); position: sticky; top: 0; z-index: 30; }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 68px; gap: 16px; }
.site-nav { display: flex; align-items: center; gap: 18px; }
.site-nav > a:not(.btn) { color: var(--c-header-text); font-weight: 550; font-size: .93rem; }
.site-main { min-height: 50vh; }
.hero { background: linear-gradient(135deg, var(--c-hero-from), var(--c-hero-to)); color: var(--c-hero-text); padding: 90px 0; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; width: 520px; height: 520px; border-radius: 50%; right: -160px; top: -200px; background: color-mix(in srgb, var(--c-accent) 14%, transparent); filter: blur(40px); pointer-events: none; }
.hero-inner { display: grid; grid-template-columns: 1.1fr 1fr; gap: 50px; align-items: center; position: relative; z-index: 1; }
.hero-inner.hero-center { grid-template-columns: 1fr; text-align: center; max-width: 860px; }
.hero h1 { font-size: clamp(2rem, 4.2vw, 3.1rem); line-height: 1.12; margin-bottom: 18px; letter-spacing: -.02em; }
.hero p { font-size: 1.15rem; opacity: .88; max-width: 640px; }
.hero-center p { margin-left: auto; margin-right: auto; }
.hero-badge { display: inline-block; padding: 5px 13px; border-radius: 999px; background: color-mix(in srgb, var(--c-hero-text) 14%, transparent); font-size: .82rem; font-weight: 600; margin-bottom: 18px; letter-spacing: .02em; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
.hero-center .hero-actions { justify-content: center; }
.hero-media img { border-radius: calc(var(--radius) + 6px); box-shadow: 0 30px 70px rgba(0,0,0,.35); width: 100%; }
.section { padding: 70px 0; }
.section-alt { background: var(--c-surface); border-top: 1px solid var(--c-border); }
.section-head { text-align: center; max-width: 680px; margin: 0 auto 40px; }
.section-head h2 { font-size: 1.85rem; letter-spacing: -.01em; }
.features { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.feature { padding: 28px; margin: 0; transition: transform .2s, box-shadow .2s; }
.feature:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.feature-icon { width: 50px; height: 50px; border-radius: 12px; background: var(--primary-soft); color: var(--c-primary); display: flex; align-items: center; justify-content: center; margin-bottom: 18px; }
.cta-box { display: flex; justify-content: space-between; align-items: center; gap: 24px; flex-wrap: wrap; background: var(--c-bg); border: 1px solid var(--c-border); border-radius: calc(var(--radius) + 6px); padding: 34px 38px; }
.cta-box h2 { margin-bottom: 6px; }
.cta-box p { margin: 0; max-width: 620px; }
.page-hero { background: linear-gradient(135deg, var(--c-hero-from), var(--c-hero-to)); color: var(--c-hero-text); padding: 46px 0 40px; }
.page-hero h1 { margin: 0 0 4px; font-size: 2rem; }
.page-hero p { margin: 0; opacity: .8; }
.page-hero + .section { padding-top: 30px; }
.legal-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.legal-tabs a { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--c-border); background: var(--c-surface); color: var(--c-text); font-size: .88rem; font-weight: 550; text-decoration: none; }
.legal-tabs a.active { background: var(--c-primary); border-color: var(--c-primary); color: var(--c-primary-text); }
.site-footer { background: var(--c-footer-bg); color: var(--c-footer-text); padding: 54px 0 0; font-size: .9rem; }
.site-footer a { color: var(--c-footer-text); opacity: .85; }
.site-footer a:hover { opacity: 1; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 34px; padding-bottom: 36px; }
.footer-brand { font-weight: 750; font-size: 1.1rem; margin-bottom: 10px; color: color-mix(in srgb, var(--c-footer-text) 30%, #fff); }
.footer-about p { opacity: .8; max-width: 420px; }
.footer-title { font-weight: 700; margin-bottom: 12px; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; opacity: .7; }
.footer-links { list-style: none; margin: 0; padding: 0; }
.footer-links li { margin-bottom: 8px; }
.footer-social { display: flex; gap: 14px; flex-wrap: wrap; }
.footer-extra { padding-bottom: 24px; opacity: .85; }
.footer-bottom { border-top: 1px solid color-mix(in srgb, var(--c-footer-text) 14%, transparent); padding: 18px 0; font-size: .8rem; opacity: .75; }
.footer-bottom .container { display: flex; flex-direction: column; gap: 4px; }

/* =========================================================
   Pagine di accesso
   ========================================================= */
.auth-wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 100vh; }
.auth-side { background: linear-gradient(135deg, var(--c-auth-from), var(--c-auth-to)); background-size: cover; background-position: center; color: #fff; position: relative; }
.auth-side-inner { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; justify-content: space-between; padding: 44px 52px; }
.auth-side .brand, .auth-side .brand-name { color: #fff; }
.auth-side-text h2 { font-size: clamp(1.6rem, 2.6vw, 2.4rem); line-height: 1.15; letter-spacing: -.01em; max-width: 480px; }
.auth-side-text p { opacity: .85; max-width: 460px; font-size: 1.05rem; }
.auth-side-foot { font-size: .8rem; opacity: .7; }
.auth-main { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 40px 24px; background: var(--c-bg); }
.auth-mobile-brand { display: none; margin-bottom: 24px; }
.auth-card { width: 100%; max-width: 420px; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: calc(var(--radius) + 6px); padding: 34px 32px; box-shadow: var(--shadow); }
.auth-card-head { text-align: center; margin-bottom: 24px; }
.auth-card-head h1 { font-size: 1.5rem; margin-bottom: 6px; }
.auth-card-head p { margin: 0; }
.auth-icon { width: 54px; height: 54px; margin: 0 auto 14px; border-radius: 14px; background: var(--primary-soft); color: var(--c-primary); display: flex; align-items: center; justify-content: center; }
.auth-note { text-align: center; font-size: .85rem; color: var(--c-muted); margin: 18px 0 0; }
.auth-links { margin-top: 22px; font-size: .82rem; color: var(--c-muted); text-align: center; }
.auth-links a { color: var(--c-muted); }
.error-code { font-size: 4rem; font-weight: 800; color: var(--c-primary); line-height: 1; margin-bottom: 10px; }

/* =========================================================
   Cookie bar
   ========================================================= */
.cookiebar { position: fixed; z-index: 90; background: var(--c-surface); color: var(--c-text); border: 1px solid var(--c-border); box-shadow: var(--shadow-lg); padding: 20px 22px; font-size: .9rem; display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.cookiebar-bottom, .cookiebar-top { left: 16px; right: 16px; border-radius: calc(var(--radius) + 4px); }
.cookiebar-bottom { bottom: 16px; } .cookiebar-top { top: 16px; }
.cookiebar-box-left, .cookiebar-box-right { bottom: 16px; width: 400px; max-width: calc(100% - 32px); border-radius: calc(var(--radius) + 4px); flex-direction: column; align-items: stretch; }
.cookiebar-box-left { left: 16px; } .cookiebar-box-right { right: 16px; }
.cookiebar-center { left: 50%; top: 50%; transform: translate(-50%, -50%); width: 560px; max-width: calc(100% - 32px); border-radius: calc(var(--radius) + 6px); flex-direction: column; align-items: stretch; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45), var(--shadow-lg); }
.cookiebar-main { flex: 1; min-width: 260px; padding-right: 20px; }
.cookiebar-title { font-weight: 700; font-size: 1rem; display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.cookiebar p { margin: 0; color: var(--c-muted); }
.cookiebar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.cookiebar-close { position: absolute; top: 8px; right: 10px; background: none; border: 0; font-size: 1.5rem; line-height: 1; color: var(--c-muted); cursor: pointer; padding: 2px 6px; }
.cookiebar-prefs { width: 100%; display: flex; flex-direction: column; gap: 10px; padding: 12px 0 2px; border-top: 1px solid var(--c-border); }
.cookie-cat { display: flex; gap: 12px; align-items: flex-start; font-weight: 400; margin: 0; cursor: pointer; }
.cookie-cat > span:last-child { display: flex; flex-direction: column; }
.cookie-cat small { color: var(--c-muted); font-size: .82rem; }

/* =========================================================
   Installer
   ========================================================= */
.layout-installer { background: var(--c-bg); }
.installer { max-width: 760px; margin: 0 auto; padding: 40px 18px; }
.installer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 26px; }
.installer-head .brand-name { color: var(--c-text); }
.installer-steps { display: flex; list-style: none; padding: 0; margin: 0 0 22px; gap: 6px; }
.installer-steps li { flex: 1; display: flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--c-muted); font-weight: 550; padding: 9px 10px; border-radius: var(--radius); background: var(--c-surface); border: 1px solid var(--c-border); }
.installer-steps li span { width: 22px; height: 22px; border-radius: 50%; background: var(--c-surface-alt); border: 1px solid var(--c-border); display: inline-flex; align-items: center; justify-content: center; font-size: .75rem; flex: none; }
.installer-steps li.current { border-color: var(--c-primary); color: var(--c-text); }
.installer-steps li.current span { background: var(--c-primary); color: var(--c-primary-text); border-color: var(--c-primary); }
.installer-steps li.done span { background: var(--c-success); color: #fff; border-color: var(--c-success); }
.installer-card { padding: 30px 32px; }
.installer-card h1 { font-size: 1.45rem; margin-bottom: 18px; }
.installer-foot { text-align: center; color: var(--c-muted); font-size: .8rem; }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 1200px) {
    .theme-layout { grid-template-columns: 1fr; }
    .theme-preview-wrap { position: static; }
    .summary-grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1080px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .items-head { display: none; }
    .item-row { grid-template-columns: 1fr 1fr; gap: 8px 12px; padding: 14px; border: 1px solid var(--c-border); border-radius: var(--radius); margin-bottom: 10px; background: var(--c-surface-alt); }
    .item-row .field:first-child { grid-column: 1 / -1; }
    .item-row .m-label { display: block; font-size: .78rem; }
    .item-result { text-align: left; }
    .grid-legal { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
    .sidebar-open .sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }
    .app-main { margin-left: 0; }
    .topbar-toggle { display: inline-flex; }
    .topbar { padding: 0 14px; }
    .content { padding: 20px 16px 40px; }
    .user-menu-name { display: none; }
    .hero-inner { grid-template-columns: 1fr; }
    .features { grid-template-columns: 1fr; }
    .footer-grid { grid-template-columns: 1fr 1fr; }
    .footer-about { grid-column: 1 / -1; }
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-side { display: none; }
    .auth-mobile-brand { display: block; }
    .auth-mobile-brand .brand { color: var(--c-text); }
    .grid-3 { grid-template-columns: 1fr; }
    .summary-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
    body { font-size: 14.5px; }
    .grid-2, .grid-4 { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .stats-grid { grid-template-columns: 1fr; }
    .summary-grid.four { grid-template-columns: 1fr; }
    .card { padding: 16px; }
    .table-wrap { margin: 0 -16px; padding: 0 16px; }
    .page-head h1 { font-size: 1.3rem; }
    .cards-grid { grid-template-columns: 1fr; }
    .hero { padding: 60px 0; }
    .section { padding: 46px 0; }
    .cta-box { padding: 24px; }
    .footer-grid { grid-template-columns: 1fr; }
    .auth-card { padding: 26px 20px; }
    .cookiebar { padding: 18px 16px; }
    .cookiebar-bottom, .cookiebar-top { left: 8px; right: 8px; }
    .cookiebar-actions .btn { flex: 1; }
    .installer-steps { flex-wrap: wrap; }
    .installer-card { padding: 22px 18px; }
    .avatar-edit { flex-direction: column; text-align: center; }
    .avatar-edit .btn-row { justify-content: center; }
    .toolbar .input-icon { min-width: 100%; }
    .toolbar select { flex: 1; }
}

/* stampa (codici di emergenza) */
@media print {
    .sidebar, .topbar, .page-actions, .btn, .cookiebar, .impersonate-bar, form { display: none !important; }
    .app-main { margin: 0; }
    .card { box-shadow: none; border: 0; }
}
