/* =========================================================
   Struttura base dell'applicazione.
   I temi (public/themes/<slug>/theme.css) ridefiniscono le variabili
   e aggiungono gli effetti propri dello stile grafico.
   ========================================================= */
:root {
    --c-primary: #0066cc;
    --c-primary-dark: #0052a3;
    --c-primary-soft: #dbeafe;
    --c-accent: #ffd700;
    --c-accent-dark: #e6c200;
    --c-accent-text: #1e293b;
    --c-coral: #ff6b6b;
    --c-coral-dark: #e65a5a;
    --c-teal: #4ecdc4;
    --c-teal-dark: #3bb5ad;
    --c-purple: #a78bfa;
    --c-bg: #f8fafc;
    --c-surface: #ffffff;
    --c-surface-2: #f1f5f9;
    --c-text: #1e293b;
    --c-muted: #64748b;
    --c-border: #e2e8f0;
    --c-success: #16a34a;
    --c-success-soft: #dcfce7;
    --c-warning: #b45309;
    --c-warning-soft: #fef3c7;
    --c-danger: #dc2626;
    --c-danger-soft: #fee2e2;
    --c-info-soft: #e0f2fe;
    --c-sidebar: #ffffff;
    --c-sidebar-text: #475569;

    --font-head: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

    --radius-xl: 1.5rem;
    --radius-lg: 1rem;
    --radius-md: .75rem;
    --radius-sm: .5rem;
    --radius-pill: 999px;

    --btn-depth: 0px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow-md: 0 8px 24px -12px rgba(15, 23, 42, .18);
    --shadow-lg: 0 25px 50px -12px rgba(15, 23, 42, .15);
    --ease-pop: cubic-bezier(.175, .885, .32, 1.275);
    --t-fast: .2s ease;
    --sidebar-w: 268px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.55;
    color: var(--c-text);
    background: var(--c-bg);
    min-height: 100vh;
}
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: clamp(1.6rem, 2.4vw, 2.2rem); font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; font-weight: 700; display: flex; align-items: center; gap: .5rem; }
h3 { font-size: 1.02rem; font-weight: 700; }
p { margin: 0 0 .75rem; }
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
code, .mono, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; }
pre { white-space: pre-wrap; word-break: break-word; background: var(--c-surface-2); padding: .5rem; border-radius: var(--radius-sm); }
hr { border: 0; border-top: 1px solid var(--c-border); margin: 1rem 0; }
.muted { color: var(--c-muted); }
.small, small { font-size: .82rem; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 1rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.danger-text { color: var(--c-danger) !important; }
.success-text { color: var(--c-success) !important; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--c-surface); padding: .5rem 1rem; z-index: 100; }
.skip-link:focus { left: 1rem; }
:focus-visible { outline: 3px solid var(--c-primary); outline-offset: 2px; }
.icon { width: 1.15em; height: 1.15em; flex: none; }

/* ---------- Sfondo decorativo (attivato dai temi) ---------- */
.bg-decor { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; display: none; }

/* ---------- Layout app ---------- */
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
    background: var(--c-sidebar); border-right: 1px solid var(--c-border);
    display: flex; flex-direction: column; padding: 1.25rem .9rem; z-index: 40;
    overflow-y: auto; transition: transform var(--t-fast);
}
.brand { display: flex; align-items: center; gap: .7rem; padding: .25rem .5rem 1.25rem; color: var(--c-text); text-decoration: none !important; }
.brand-icon { width: 2.75rem; height: 2.75rem; border-radius: 1rem; background: var(--c-primary); color: #fff; display: grid; place-items: center; flex: none; }
.brand-icon .icon { width: 1.4rem; height: 1.4rem; }
.brand-text { font-family: var(--font-head); font-weight: 800; font-size: 1.05rem; line-height: 1.15; }
.nav { display: flex; flex-direction: column; gap: .2rem; flex: 1; }
.nav-link {
    display: flex; align-items: center; gap: .7rem; padding: .62rem .8rem; border-radius: var(--radius-md);
    color: var(--c-sidebar-text); font-weight: 600; font-size: .92rem; text-decoration: none !important;
    transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
    border: 0; background: none; width: 100%; cursor: pointer; text-align: left; font-family: inherit;
}
.nav-link:hover { background: var(--c-surface-2); color: var(--c-text); }
.nav-link.active { background: var(--c-primary-soft); color: var(--c-primary); }
.nav-link .count { margin-left: auto; background: var(--c-coral); color: #fff; border-radius: var(--radius-pill); font-size: .72rem; padding: 0 .45rem; }
.nav-section { margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed var(--c-border); display: flex; flex-direction: column; gap: .2rem; }
.nav-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--c-muted); padding: 0 .8rem .35rem; font-weight: 700; }
.sidebar-footer { border-top: 1px solid var(--c-border); padding-top: .75rem; display: flex; flex-direction: column; gap: .2rem; }
.sidebar-footer form { margin: 0; }

.shell { margin-left: var(--sidebar-w); min-height: 100vh; position: relative; z-index: 1; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 1rem;
    padding: .75rem 1.75rem; background: color-mix(in srgb, var(--c-bg) 82%, transparent);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--c-border);
}
.topbar-title { flex: 1; min-width: 0; }
.breadcrumbs { display: flex; flex-wrap: wrap; gap: .35rem; font-size: .85rem; color: var(--c-muted); }
.breadcrumbs a { color: var(--c-muted); font-weight: 600; }
.breadcrumbs span:last-child { color: var(--c-text); font-weight: 700; }
.breadcrumbs .sep { opacity: .5; }
.topbar-user { display: flex; align-items: center; gap: .75rem; }
.user-chip { display: flex; align-items: center; gap: .55rem; }
.avatar { width: 2.2rem; height: 2.2rem; border-radius: 50%; background: var(--c-teal); color: #fff; display: grid; place-items: center; font-weight: 800; }
.user-meta { display: flex; flex-direction: column; line-height: 1.1; }
.user-meta small { color: var(--c-muted); }
.nav-toggle { display: none; }
.bell { position: relative; }
.bell .dot { position: absolute; top: -4px; right: -4px; background: var(--c-coral); color: #fff; border-radius: var(--radius-pill); font-size: .65rem; min-width: 1.1rem; height: 1.1rem; display: grid; place-items: center; padding: 0 .25rem; }
.main { padding: 1.75rem; max-width: 1320px; width: 100%; }
.backdrop { display: none; }

/* ---------- Intestazioni pagina ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-head h1 { margin: .25rem 0 .25rem; }
.page-head p { margin: 0; }
.pill { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .8rem; border-radius: var(--radius-pill); background: var(--c-primary-soft); color: var(--c-primary); font-size: .78rem; font-weight: 700; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; align-items: center; }
.toolbar input, .toolbar select { flex: 1 1 200px; max-width: 360px; }

/* ---------- Card e griglie ---------- */
.card {
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-xl);
    padding: 1.4rem; box-shadow: var(--shadow-sm); margin-bottom: 1.25rem; position: relative;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card.narrow { max-width: 560px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .75rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.table-card { padding: .5rem 0 0; overflow: hidden; }
/* Un dropdown aperto dentro la tabella non deve essere tagliato dal bordo della card */
.table-card:has(details.dropdown[open]) { overflow: visible; }
.table-card .card-head { padding: .9rem 1.4rem 0; }
.card-link { display: block; color: inherit; text-decoration: none !important; }
.card-top { display: flex; justify-content: space-between; gap: .5rem; margin-bottom: .75rem; flex-wrap: wrap; }
.card-icon { width: 3rem; height: 3rem; border-radius: 1rem; display: grid; place-items: center; margin-bottom: .9rem; }
.card-icon .icon { width: 1.5rem; height: 1.5rem; }
.icon-blue { background: var(--c-primary-soft); color: var(--c-primary); }
.icon-yellow { background: #fef9c3; color: #a16207; }
.icon-teal { background: #ccfbf1; color: #0f766e; }
.icon-coral { background: #ffe4e6; color: #be123c; }
.mini-stats { display: flex; flex-wrap: wrap; gap: .75rem; font-size: .85rem; color: var(--c-muted); margin-top: .75rem; }
.mini-stats strong { color: var(--c-text); }
.limit-line { margin-top: .75rem; padding-top: .6rem; border-top: 1px dashed var(--c-border); color: var(--c-muted); display: flex; align-items: center; gap: .35rem; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.25rem; margin-bottom: 1.25rem; }
.cards-grid .card { margin-bottom: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.grid-2.wide-left { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; }
.grid-2 > .card, .grid-3 > .card, .stack > .card { margin-bottom: 0; }
.grid-2, .grid-3 { margin-bottom: 1.25rem; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.stack-sm { display: flex; flex-direction: column; gap: .5rem; }
.quote-box { background: var(--c-surface); border-left: 5px solid var(--c-accent); border-radius: var(--radius-md); padding: .9rem 1.1rem; margin-bottom: 1.25rem; font-size: .9rem; box-shadow: var(--shadow-sm); }

/* ---------- KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.kpi-grid.compact .kpi { padding: .8rem 1rem; }
.kpi-grid.compact .kpi strong { font-size: 1.1rem; }
.kpi {
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-lg);
    padding: 1.1rem 1.2rem; display: flex; flex-direction: column; gap: .2rem; position: relative; overflow: hidden;
}
.kpi-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--c-muted); }
.kpi strong { font-family: var(--font-head); font-size: 1.45rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi strong small { font-size: .9rem; color: var(--c-muted); }
.kpi small { color: var(--c-muted); }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--kpi-c, var(--c-border)); }
.kpi-blue { --kpi-c: var(--c-primary); }
.kpi-teal { --kpi-c: var(--c-teal); }
.kpi-yellow { --kpi-c: var(--c-accent); }
.kpi-coral { --kpi-c: var(--c-coral); }
.kpi-dark { --kpi-c: var(--c-text); }
.kpi-danger { --kpi-c: var(--c-danger); background: var(--c-danger-soft); }

/* ---------- Pulsanti ---------- */
.btn {
    --btn-bg: var(--c-surface-2); --btn-fg: var(--c-text); --btn-shadow: var(--c-border);
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
    padding: .62rem 1.15rem; border-radius: var(--radius-md); border: 1px solid transparent;
    background: var(--btn-bg); color: var(--btn-fg); font-weight: 700; font-size: .9rem; font-family: inherit;
    cursor: pointer; text-decoration: none !important; line-height: 1.2; white-space: nowrap;
    box-shadow: 0 var(--btn-depth) 0 0 var(--btn-shadow);
    transition: transform .2s, box-shadow .2s, background .2s, filter .2s;
}
.btn:hover { filter: brightness(1.04); }
.btn:active { transform: translateY(min(var(--btn-depth), 4px)); box-shadow: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { --btn-bg: var(--c-primary); --btn-fg: #fff; --btn-shadow: var(--c-primary-dark); }
.btn-accent { --btn-bg: var(--c-accent); --btn-fg: var(--c-accent-text); --btn-shadow: var(--c-accent-dark); }
.btn-danger { --btn-bg: var(--c-coral); --btn-fg: #fff; --btn-shadow: var(--c-coral-dark); }
.btn-ghost { --btn-bg: var(--c-surface); --btn-fg: var(--c-text); --btn-shadow: var(--c-border); border-color: var(--c-border); }
.btn-sm { padding: .42rem .8rem; font-size: .82rem; }
.btn-lg { padding: .9rem 1.6rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon {
    display: inline-grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: var(--radius-sm);
    background: transparent; border: 1px solid transparent; color: var(--c-muted); cursor: pointer; font-size: 1.1rem; line-height: 1;
    transition: background var(--t-fast), color var(--t-fast); text-decoration: none !important; font-family: inherit;
}
.btn-icon:hover { background: var(--c-surface-2); color: var(--c-text); }
.link-button { background: none; border: 0; color: var(--c-primary); cursor: pointer; font: inherit; padding: 0; }
.inline-form { display: inline; margin: 0; }
.as-button { font-family: inherit; }

/* ---------- Badge e chip ---------- */
.badge { display: inline-flex; align-items: center; gap: .25rem; padding: .16rem .6rem; border-radius: var(--radius-pill); font-size: .74rem; font-weight: 700; white-space: nowrap; }
.badge-muted { background: var(--c-surface-2); color: var(--c-muted); }
.badge-info { background: var(--c-info-soft); color: #0369a1; }
.badge-success { background: var(--c-success-soft); color: var(--c-success); }
.badge-warning { background: var(--c-warning-soft); color: var(--c-warning); }
.badge-danger { background: var(--c-danger-soft); color: var(--c-danger); }
.badge-dark { background: var(--c-text); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: .25rem; background: var(--c-surface-2); border-radius: var(--radius-pill); padding: .2rem .35rem .2rem .75rem; font-size: .85rem; }
.chip-x { border: 0; background: transparent; cursor: pointer; color: var(--c-muted); font-size: 1rem; padding: 0 .3rem; }
.chip-add { display: inline-flex; gap: .3rem; }
.chip-add input { width: 240px; }

/* ---------- Alert ---------- */
.alert { display: flex; gap: .75rem; align-items: flex-start; padding: .85rem 1rem; border-radius: var(--radius-md); margin-bottom: 1rem; border: 1px solid transparent; font-size: .92rem; }
.alert > div { flex: 1; }
.alert .icon { margin-top: .15rem; }
.alert-success { background: var(--c-success-soft); color: #14532d; border-color: #bbf7d0; }
.alert-error { background: var(--c-danger-soft); color: #7f1d1d; border-color: #fecaca; }
.alert-warning { background: var(--c-warning-soft); color: #78350f; border-color: #fde68a; }
.alert-info { background: var(--c-info-soft); color: #0c4a6e; border-color: #bae6fd; }
.alert-close { background: none; border: 0; cursor: pointer; color: inherit; opacity: .6; padding: 0; }

/* ---------- Form ---------- */
.form-grid { display: grid; gap: .9rem 1rem; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); }
.form-grid.cols-2 { --cols: 2; }
.form-grid.cols-3 { --cols: 3; }
.form-grid.cols-4 { --cols: 4; }
.span-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field label, .fieldset legend { font-weight: 700; font-size: .84rem; }
.field .req { color: var(--c-coral); }
.field .help { color: var(--c-muted); font-size: .78rem; }
.field .error { color: var(--c-danger); font-size: .8rem; font-weight: 600; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--c-danger); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], input[type=url], select, textarea {
    width: 100%; padding: .62rem .8rem; border: 1.5px solid var(--c-border); border-radius: var(--radius-sm);
    background: var(--c-surface); color: var(--c-text); font: inherit; font-size: .92rem;
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c-primary) 18%, transparent); }
input[readonly], input:disabled { background: var(--c-surface-2); color: var(--c-muted); }
textarea { resize: vertical; min-height: 2.6rem; }
input[type=file] { font: inherit; font-size: .85rem; padding: .45rem; border: 1.5px dashed var(--c-border); border-radius: var(--radius-sm); background: var(--c-surface-2); width: 100%; }
.check { display: inline-flex; gap: .5rem; align-items: flex-start; font-size: .9rem; cursor: pointer; }
.check input { margin-top: .2rem; width: 1.05rem; height: 1.05rem; accent-color: var(--c-primary); }
.fieldset { border: 1px solid var(--c-border); border-radius: var(--radius-lg); padding: 1rem 1.1rem 1.1rem; margin: 0; }
.fieldset legend { padding: 0 .4rem; font-size: .95rem; font-family: var(--font-head); }
.form-inline { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.form-inline .grow { flex: 1 1 220px; width: auto; }
.w-xs { width: 90px !important; }
.inline-label { display: inline-flex; align-items: center; gap: .35rem; font-size: .82rem; font-weight: 600; }
.code-input { font-size: 1.4rem !important; letter-spacing: .35em; text-align: center; font-family: ui-monospace, monospace !important; }
.strength { height: 6px; border-radius: 3px; background: var(--c-surface-2); overflow: hidden; margin-top: -.5rem; }
.strength span { display: block; height: 100%; width: 0; background: var(--c-coral); transition: width .3s, background .3s; }
output.calc-total { display: block; padding: .62rem 0; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- Tabelle ---------- */
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .73rem; text-transform: uppercase; letter-spacing: .05em; color: var(--c-muted); font-weight: 700; padding: .65rem 1rem; border-bottom: 1px solid var(--c-border); background: var(--c-surface-2); }
.table td { padding: .75rem 1rem; border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: color-mix(in srgb, var(--c-primary-soft) 45%, transparent); }
.table-compact td, .table-compact th { padding: .5rem .7rem; }
.table tfoot td { font-weight: 700; background: var(--c-surface-2); border-top: 2px solid var(--c-border); }
.card:not(.table-card) .table th:first-child, .card:not(.table-card) .table td:first-child { padding-left: .4rem; }
.empty-row { text-align: center; color: var(--c-muted); padding: 2rem !important; }
.group-row td { background: color-mix(in srgb, var(--c-accent) 14%, var(--c-surface)); font-weight: 700; font-style: italic; font-size: .82rem; }
.row-warning td { background: var(--c-warning-soft); }
.edit-row td { background: var(--c-surface-2); }
.w-progress { display: inline-flex; flex-direction: column; gap: .15rem; min-width: 110px; }
.w-progress.wide { min-width: 220px; }
.pagination { display: flex; gap: .3rem; justify-content: center; margin-top: 1rem; }
.pagination a { padding: .3rem .7rem; border-radius: var(--radius-sm); border: 1px solid var(--c-border); }
.pagination a.active { background: var(--c-primary); color: #fff; }

/* ---------- Liste ---------- */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .45rem; }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .45rem 0; border-bottom: 1px dashed var(--c-border); }
.timeline { list-style: none; margin: 0 0 1rem; padding: 0; font-size: .85rem; display: flex; flex-direction: column; gap: .4rem; }
.todo { list-style: none; padding: 0; margin: 0 0 .75rem; display: flex; flex-direction: column; gap: .4rem; }
.todo-link { display: flex; align-items: center; gap: .4rem; padding: .35rem 0; font-size: .88rem; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1rem; margin: 0; font-size: .9rem; }
.dl dt { color: var(--c-muted); font-weight: 600; }
.dl dd { margin: 0; }
.dl-cols dd { font-variant-numeric: tabular-nums; }
.codes { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; }
.codes code { display: block; padding: .5rem; background: var(--c-surface-2); border-radius: var(--radius-sm); text-align: center; font-size: 1rem; letter-spacing: .08em; }
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-list li a { display: flex; gap: .8rem; align-items: flex-start; padding: .85rem .5rem; border-bottom: 1px solid var(--c-border); color: inherit; text-decoration: none; }
.notif-list li a:hover { background: var(--c-surface-2); }
.notif-dot { width: .6rem; height: .6rem; border-radius: 50%; margin-top: .45rem; background: transparent; flex: none; }
.notif-list li.unread .notif-dot { background: var(--c-coral); }
.notif-list li.unread strong { color: var(--c-primary); }
.notif-body { flex: 1; display: flex; flex-direction: column; }
.notif-body span { color: var(--c-muted); font-size: .88rem; }
.notif-list time { color: var(--c-muted); font-size: .78rem; white-space: nowrap; }
.empty { text-align: center; color: var(--c-muted); padding: 2rem 1rem; }
.empty .icon { width: 2.5rem; height: 2.5rem; opacity: .4; margin-bottom: .5rem; }

/* ---------- Dropdown (details) ---------- */
details > summary { cursor: pointer; font-weight: 700; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details:not(.dropdown) > summary::before { content: "▸ "; color: var(--c-muted); }
details[open]:not(.dropdown) > summary::before { content: "▾ "; }
details > summary.btn::before { content: none !important; }
.dropdown { position: relative; display: inline-block; }
.dropdown > summary { list-style: none; }
.dropdown-menu {
    position: absolute; right: 0; top: calc(100% + .35rem); min-width: 220px; z-index: 20;
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg); padding: .4rem; display: flex; flex-direction: column; gap: .15rem;
}
.dropdown-menu.wide { min-width: 280px; padding: .75rem; }
.dropdown-item { display: block; width: 100%; text-align: left; background: none; border: 0; padding: .55rem .7rem; border-radius: var(--radius-sm); font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer; color: var(--c-text); }
.dropdown-item:hover { background: var(--c-surface-2); }
.dropdown-menu .inline-form { display: block; }
.danger-zone { border-color: var(--c-danger-soft); }
.danger-zone > summary { color: var(--c-danger); }

/* ---------- Stepper stato lettera ---------- */
.stepper { list-style: none; display: flex; gap: .5rem; padding: 0; margin: 0 0 1.25rem; flex-wrap: wrap; counter-reset: s; }
.stepper li { flex: 1 1 120px; display: flex; align-items: center; gap: .5rem; padding: .6rem .8rem; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-md); font-weight: 700; font-size: .85rem; color: var(--c-muted); }
.stepper li span { width: 1.6rem; height: 1.6rem; border-radius: 50%; display: grid; place-items: center; background: var(--c-surface-2); font-size: .78rem; }
.stepper li.done { color: var(--c-success); }
.stepper li.done span { background: var(--c-success); color: #fff; }
.stepper li.current { color: var(--c-primary); border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-primary-soft); }
.stepper li.current span { background: var(--c-primary); color: #fff; }
.stepper li.cancelled { text-decoration: line-through; opacity: .6; }

/* ---------- Grafici SVG ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart-label { font-size: 11.5px; fill: var(--c-text); font-weight: 600; }
.chart-value { font-size: 10.5px; fill: var(--c-muted); font-variant-numeric: tabular-nums; }
.chart-legend { font-size: 12px; fill: var(--c-text); font-weight: 600; }
.chart-axis { stroke: var(--c-border); stroke-width: 1; }
.chart-line { stroke: var(--c-text); }
.chart-dot { fill: var(--c-surface); stroke: var(--c-text); stroke-width: 2; }
.s1 { fill: var(--c-primary); stroke: var(--c-primary); }
.s2 { fill: var(--c-coral); stroke: var(--c-coral); }
.s3 { fill: var(--c-teal); stroke: var(--c-teal); }
.donut { display: block; margin: .5rem auto 0; }
.donut .donut-value { fill: none; }
.donut-track { stroke: var(--c-surface-2); }
.donut-pct { font-family: var(--font-head); font-size: 24px; font-weight: 800; fill: var(--c-text); }
.donut-label { font-size: 11px; fill: var(--c-muted); font-weight: 600; }
.progress { width: 100%; height: 8px; display: block; }
.progress-track { fill: var(--c-surface-2); }
.progress-over { fill: var(--c-danger); }
.progress-limit { fill: var(--c-text); }
.legend { display: flex; gap: .9rem; align-items: center; font-size: .8rem; color: var(--c-muted); flex-wrap: wrap; margin-top: .5rem; }
.legend .lg { width: .8rem; height: .8rem; border-radius: 3px; display: inline-block; }
.legend .lg.s2 { background: var(--c-coral); } .legend .lg.s3 { background: var(--c-teal); }
.legend .lg.line { height: 3px; background: var(--c-text); }

/* ---------- Budget ---------- */
.budget-cat .card-head h2 { font-size: 1.05rem; }
.cat-code { display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: .6rem; background: var(--c-accent); color: var(--c-accent-text); font-weight: 900; }
.cat-meta { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.budget-cat.is-over { border-color: var(--c-danger); box-shadow: 0 0 0 3px var(--c-danger-soft); }
.budget-form { display: flex; flex-direction: column; gap: .75rem; }

/* ---------- Immagini carta intestata ---------- */
.image-slot { display: flex; flex-direction: column; gap: .5rem; }
.image-preview { height: 120px; border: 1.5px dashed var(--c-border); border-radius: var(--radius-md); display: grid; place-items: center; background: repeating-conic-gradient(var(--c-surface-2) 0 25%, var(--c-surface) 0 50%) 0 0 / 16px 16px; overflow: hidden; }
.image-preview img { max-height: 110px; max-width: 95%; object-fit: contain; }
.image-preview.faded img { opacity: .25; }

/* ---------- Editor lettere ---------- */
.editor { border: 1.5px solid var(--c-border); border-radius: var(--radius-lg); overflow: hidden; background: var(--c-surface); }
.editor-toolbar { display: flex; flex-wrap: wrap; gap: .25rem; padding: .5rem; border-bottom: 1px solid var(--c-border); background: var(--c-surface-2); }
.editor-toolbar button { min-width: 2.1rem; height: 2.1rem; border: 1px solid var(--c-border); background: var(--c-surface); border-radius: var(--radius-sm); cursor: pointer; font: inherit; font-size: .88rem; }
.editor-toolbar button:hover { background: var(--c-primary-soft); }
.editor-toolbar .sep { width: 1px; background: var(--c-border); margin: 0 .25rem; }
.editor-body { display: grid; grid-template-columns: minmax(0, 1fr) 280px; min-height: 520px; }
.editor-paper { background: var(--c-surface-2); padding: 1.25rem; overflow: auto; }
.editor-content { background: #fff; color: #1f2937; max-width: 794px; margin: 0 auto; min-height: 700px; padding: 56px 60px; box-shadow: var(--shadow-md); font-family: "Noto Sans", Arial, sans-serif; font-size: 14px; line-height: 1.55; outline: none; border-radius: 4px; }
.editor-content p { margin: 0 0 10px; }
.editor-content ul, .editor-content ol { margin: 0 0 10px 22px; padding: 0; }
.editor-content .align-left { text-align: left; } .editor-content .align-center { text-align: center; } .editor-content .align-right { text-align: right; } .editor-content .align-justify { text-align: justify; }
.editor-content .ph-tag { background: #fef08a; color: #854d0e; border-radius: 4px; padding: 0 3px; font-family: ui-monospace, monospace; font-size: 12px; white-space: nowrap; cursor: default; user-select: all; }
.ph-panel { border-left: 1px solid var(--c-border); padding: .9rem; overflow-y: auto; max-height: 760px; background: var(--c-surface); }
.ph-panel details { margin-bottom: .6rem; }
.ph-panel summary { font-size: .85rem; margin-bottom: .35rem; }
.ph-list { display: flex; flex-direction: column; gap: .25rem; }
.ph-btn { text-align: left; border: 1px solid var(--c-border); background: var(--c-surface); border-radius: var(--radius-sm); padding: .35rem .55rem; font: inherit; font-size: .8rem; cursor: pointer; }
.ph-btn:hover { background: #fef9c3; border-color: var(--c-accent); }

/* ---------- Temi (anteprima) ---------- */
.theme-card.is-active { border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-primary-soft); }
.theme-swatch { display: flex; gap: .35rem; margin-bottom: .75rem; }
.theme-swatch span { width: 2.2rem; height: 2.2rem; border-radius: .7rem; }
.theme-swatch-nnm span:nth-child(1) { background: #0066cc; } .theme-swatch-nnm span:nth-child(2) { background: #ffd700; } .theme-swatch-nnm span:nth-child(3) { background: #ff6b6b; } .theme-swatch-nnm span:nth-child(4) { background: #4ecdc4; }
.theme-swatch-neutro span:nth-child(1) { background: #1f2937; } .theme-swatch-neutro span:nth-child(2) { background: #2563eb; } .theme-swatch-neutro span:nth-child(3) { background: #e5e7eb; } .theme-swatch-neutro span:nth-child(4) { background: #f9fafb; }
.theme-swatch-custom span { background: var(--c-border); }

/* ---------- Pagine di autenticazione ---------- */
body.auth { display: grid; place-items: center; padding: 2rem 1rem; }
.auth-wrap { width: 100%; max-width: 460px; position: relative; z-index: 1; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: .7rem; margin-bottom: 1.5rem; }
.auth-brand .brand-text { font-size: 1.3rem; }
.auth-card { background: var(--c-surface); border-radius: var(--radius-xl); padding: 2rem; box-shadow: var(--shadow-lg); border: 1px solid var(--c-border); }
.auth-title { font-size: 1.8rem; margin-bottom: .4rem; }
.auth-foot { text-align: center; color: var(--c-muted); font-size: .8rem; margin-top: 1.25rem; display: flex; gap: .35rem; justify-content: center; align-items: center; }
.qr-box { display: flex; gap: 1rem; align-items: center; background: var(--c-surface-2); padding: 1rem; border-radius: var(--radius-lg); margin: 1rem 0; flex-wrap: wrap; justify-content: center; }
.qr-box img { background: #fff; border-radius: .75rem; padding: .25rem; }
.secret { display: block; margin-top: .35rem; font-size: 1rem; letter-spacing: .08em; word-break: break-all; background: var(--c-surface); padding: .45rem .6rem; border-radius: var(--radius-sm); }
.error-page { text-align: center; }
.error-code { font-family: var(--font-head); font-size: 5rem; font-weight: 900; color: var(--c-primary); line-height: 1; margin-bottom: 1rem; }
.select-card { display: flex; flex-direction: column; }
.select-card.is-active { border-color: var(--c-teal); }
.select-card .btn { margin-top: auto; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .grid-3 { grid-template-columns: 1fr 1fr; }
    .grid-2.wide-left { grid-template-columns: 1fr; }
    .form-grid.cols-4 { --cols: 2; }
    .editor-body { grid-template-columns: 1fr; }
    .ph-panel { border-left: 0; border-top: 1px solid var(--c-border); max-height: 320px; }
}
@media (max-width: 860px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    body.nav-open .sidebar { transform: none; }
    body.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 35; }
    .shell { margin-left: 0; }
    .nav-toggle { display: inline-grid; }
    .topbar { padding: .6rem 1rem; }
    .user-meta { display: none; }
    .main { padding: 1rem; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .form-grid.cols-2, .form-grid.cols-3, .form-grid.cols-4 { --cols: 1; }
    .span-2 { grid-column: auto; }
    .editor-content { padding: 24px; min-height: 400px; }

    .card { padding: 1.1rem; border-radius: var(--radius-lg); }
}
@media print {
    .sidebar, .topbar, .actions, .bg-decor { display: none !important; }
    .shell { margin: 0; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Correzioni */
.btn-icon.nav-toggle { display: none; }
@media (max-width: 860px) { .btn-icon.nav-toggle { display: inline-grid; } }
.auth-card form + p, .auth-card form + form { margin-top: 1.4rem; }

/* ---------- Icona info con tooltip ---------- */
.info-tip {
    display: inline-grid; place-items: center; width: 1.1rem; height: 1.1rem; margin-left: .3rem; border-radius: 50%;
    background: var(--c-primary-soft); color: var(--c-primary); font: italic 800 .72rem/1 Georgia, serif;
    cursor: help; position: relative; vertical-align: middle; text-transform: none; letter-spacing: 0;
}
.info-tip::after {
    content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + .5rem); transform: translateX(-50%) translateY(4px);
    width: max-content; max-width: 280px; padding: .6rem .75rem; border-radius: var(--radius-sm);
    background: var(--c-text); color: #fff; font: 500 .8rem/1.4 var(--font-body); text-align: left; white-space: normal;
    box-shadow: var(--shadow-lg); opacity: 0; visibility: hidden; transition: opacity .15s, transform .15s; z-index: 50; pointer-events: none;
}
.info-tip:hover::after, .info-tip:focus::after, .info-tip:focus-visible::after { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }
.fieldset .form-grid > .field:first-child .info-tip::after { left: 0; transform: translateY(4px); }
.fieldset .form-grid > .field:first-child .info-tip:hover::after, .fieldset .form-grid > .field:first-child .info-tip:focus::after { transform: translateY(0); }

/* ---------- Righe cofinanziamento ---------- */
.cof-box { border: 1.5px dashed var(--c-border); border-radius: var(--radius-lg); padding: 1rem; margin: 1rem 0; background: var(--c-surface-2); }
.cof-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .6rem; }
.cof-head h3 { margin: 0; display: flex; align-items: center; }
.cof-rows { display: flex; flex-direction: column; gap: .5rem; }
.cof-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) 90px; gap: .5rem; align-items: center; }
.cof-row.is-deleted input[type=text] { text-decoration: line-through; opacity: .5; }
.cof-total { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; margin-top: .9rem; padding-top: .75rem; border-top: 1px dashed var(--c-border); font-size: .9rem; color: var(--c-muted); }
.cof-total strong { color: var(--c-text); font-variant-numeric: tabular-nums; }
.cof-total span:last-child strong { color: var(--c-primary); font-size: 1.05rem; }
@media (max-width: 860px) { .cof-row { grid-template-columns: 1fr; } }
.cof-total .cof-sep { flex-basis: 100%; height: 0; }
.cof-total span:nth-child(3) strong { color: var(--c-text); font-size: 1rem; }

/* Tooltip dentro le card KPI: niente ritaglio e card in primo piano durante l'hover */
.kpi { overflow: visible; box-shadow: inset 5px 0 0 var(--kpi-c, var(--c-border)); }
.kpi::before { display: none; }
.kpi:hover, .kpi:focus-within { z-index: 20; }
.kpi .info-tip::after { left: 0; transform: translateY(4px); }
.kpi .info-tip:hover::after, .kpi .info-tip:focus::after { transform: translateY(0); }
.cash-table td:first-child { white-space: normal; }
.cash-table .group-row td { font-style: normal; }
.table-card .card-body { padding: 1rem 1.4rem 1.2rem; }

/* ---------- Dettaglio voce di budget nella lettera ---------- */
.voce-panel { border: 2px solid var(--c-primary-soft); background: color-mix(in srgb, var(--c-primary-soft) 35%, var(--c-surface)); border-radius: var(--radius-lg); padding: 1rem 1.1rem; }
.voce-panel.is-over { border-color: var(--c-danger); background: var(--c-danger-soft); }
.voce-head { margin-bottom: .6rem; font-family: var(--font-head); }
.voce-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .6rem; }
.voce-grid > div { background: var(--c-surface); border-radius: var(--radius-md); padding: .6rem .75rem; display: flex; flex-direction: column; gap: .1rem; }
.voce-grid span { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--c-muted); font-weight: 700; }
.voce-grid strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.voce-grid small { color: var(--c-muted); }
.voce-grid .voce-this { box-shadow: inset 0 0 0 2px var(--c-primary); }
.voce-grid .voce-after { box-shadow: inset 0 0 0 2px var(--c-teal); }
.voce-panel.is-over .voce-after { box-shadow: inset 0 0 0 2px var(--c-danger); }
.voce-bar { margin: .8rem 0 .4rem; height: 10px; }
.voce-msg { margin: 0; font-weight: 700; }
.voce-lettere { margin-top: .8rem; }
.voce-lettere h4 { margin: 0 0 .4rem; font-size: .85rem; }
.backup-menu { min-width: 320px; }
.backup-menu hr { margin: .6rem 0; }

/* ---------- Popup (dialog) ---------- */
dialog.modal { border: 0; padding: 0; border-radius: var(--radius-xl); width: min(640px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); background: var(--c-surface); color: var(--c-text); box-shadow: var(--shadow-lg); overflow: hidden; }
dialog.modal.modal-lg { width: min(860px, calc(100vw - 2rem)); }
dialog.modal.modal-xl { width: min(1180px, calc(100vw - 2rem)); }
dialog.modal::backdrop { background: rgba(15, 23, 42, .45); backdrop-filter: blur(3px); }
dialog.modal[open] { display: flex; flex-direction: column; animation: modal-in .25s var(--ease-pop); }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-form { display: flex; flex-direction: column; min-height: 0; max-height: calc(100vh - 2rem); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 1.4rem; border-bottom: 1px solid var(--c-border); }
.modal-head h2 { margin: 0; }
.modal-body { padding: 1.2rem 1.4rem; overflow-y: auto; flex: 1; min-height: 0; }
.modal-foot { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .9rem 1.4rem; border-top: 1px solid var(--c-border); background: var(--c-surface-2); flex-wrap: wrap; }

/* ---------- Nessuno scroll orizzontale nelle card: le tabelle si adattano alla larghezza ---------- */
.table-scroll { overflow-x: visible; }
.table td, .table th { overflow-wrap: anywhere; }
.table td.num, .table th.num { overflow-wrap: normal; }

/* =====================================================================
   Pagina Budget — lista voci compatta (stesso markup su tutti gli schermi)
   ===================================================================== */
.actions-center { justify-content: center; }
.bcat { padding: 1.1rem 1.2rem .6rem; }
.bcat.is-over { border-color: var(--c-danger); box-shadow: 0 0 0 3px var(--c-danger-soft); }
.bcat-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: .4rem .8rem; margin-bottom: .6rem; }
.bcat-info { min-width: 0; }
.bcat-info h2 { margin: 0; font-size: 1.02rem; line-height: 1.25; }
.bcat-info small { display: block; }
.bcat-bar { display: block; max-width: 220px; margin-top: .3rem; }
.bcat-total { font-size: 1.1rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bcat-actions { display: flex; gap: .1rem; }
.cat-code.sm { width: 1.6rem; height: 1.6rem; font-size: .8rem; border-radius: .5rem; box-shadow: none; transform: none; }

.vgroup { font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: var(--c-muted); padding: .55rem .2rem .25rem; border-top: 1px dashed var(--c-border); margin-top: .2rem; }
.vgroup:first-of-type { border-top: 0; }
.vlist { list-style: none; margin: 0; padding: 0; }
.vitem { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: .3rem .9rem; padding: .6rem .2rem; border-top: 1px solid var(--c-border); }
.vlist .vitem:first-child { border-top: 0; }
.vmain { all: unset; cursor: pointer; min-width: 0; display: flex; flex-direction: column; gap: .2rem; border-radius: var(--radius-sm); padding: .15rem .3rem; margin: -.15rem -.3rem; }
.vmain:hover .vtitle { color: var(--c-primary); }
.vmain:focus-visible { outline: 3px solid var(--c-primary); }
.vtitle { font-weight: 700; line-height: 1.3; display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; overflow-wrap: anywhere; }
.vmeta { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .6rem; font-size: .8rem; color: var(--c-muted); }
.vmeta .rap { font-size: .72rem; padding: .05rem .5rem; }
.vnames { display: inline-flex; align-items: center; gap: .25rem; max-width: 100%; }
.vnames .icon { width: .95em; height: .95em; color: var(--c-primary); }
.vamount { display: flex; flex-direction: column; align-items: flex-end; gap: .15rem; min-width: 110px; }
.vamount strong { font-variant-numeric: tabular-nums; white-space: nowrap; }
.vamount small { font-size: .7rem; white-space: nowrap; }
.vbar { display: block; width: 90px; }
.vactions { display: flex; align-items: center; gap: .05rem; }
.vactions .btn-icon { width: 2rem; height: 2rem; }
.vmore .dropdown-menu { min-width: 230px; }
.vmore .dropdown-item { display: flex; align-items: center; gap: .5rem; text-decoration: none !important; }

.bcat-empty-list { padding: 1rem 1.2rem; }
.bcat-empty-list h3 { margin: 0 0 .6rem; text-transform: uppercase; letter-spacing: .06em; font-size: .72rem; }
.catchips { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: .5rem; }
.catchip { display: flex; align-items: center; gap: .5rem; padding: .35rem .4rem .35rem .5rem; border: 1px solid var(--c-border); border-radius: var(--radius-md); background: var(--c-surface-2); min-width: 0; }
.catchip-name { flex: 1; min-width: 0; font-size: .85rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.catchip .btn-icon { width: 1.9rem; height: 1.9rem; }

/* Popup dettagli voce */
.info-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.info-kpis > div { background: var(--c-surface-2); border-radius: var(--radius-md); padding: .7rem .8rem; display: flex; flex-direction: column; gap: .1rem; }
.info-kpis span { font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--c-muted); }
.info-kpis strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.info-kpis small { color: var(--c-muted); font-size: .78rem; }
.info-dl { margin-bottom: 1rem; }
.info-block { border-top: 1px solid var(--c-border); padding-top: .8rem; margin-top: .8rem; }
.info-block h4 { margin: 0 0 .4rem; display: flex; align-items: center; gap: .4rem; font-size: .9rem; }
.info-names { white-space: pre-line; font-size: .88rem; margin: 0; overflow-wrap: anywhere; }
.info-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.info-list li { display: flex; flex-wrap: wrap; gap: .2rem .8rem; font-size: .85rem; padding: .45rem .6rem; background: var(--c-surface-2); border-radius: var(--radius-sm); }
.info-list li span { color: var(--c-muted); }
.info-list li span:last-child { margin-left: auto; color: var(--c-text); font-weight: 700; font-variant-numeric: tabular-nums; }

/* Popup inserimento multiplo */
.mrows { display: flex; flex-direction: column; gap: .8rem; }
.mrow { border: 1.5px solid var(--c-border); border-radius: var(--radius-lg); padding: .7rem .9rem .8rem; background: var(--c-surface); }
.mrow:focus-within { border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-primary-soft); }
.mrow-top { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; }
.mrow-num { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--c-muted); }
.mrow-tot { margin-left: auto; font-variant-numeric: tabular-nums; }
.mgrid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: .55rem .7rem; }
.g-desc { grid-column: span 6; } .g-cat { grid-column: span 3; } .g-grp { grid-column: span 3; }
.g-rap { grid-column: span 3; } .g-q { grid-column: span 2; } .g-u { grid-column: span 2; } .g-c { grid-column: span 3; } .g-f { grid-column: span 2; }
.mf { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.mf > span { font-size: .7rem; font-weight: 700; color: var(--c-muted); text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mf input, .mf select { padding: .5rem .6rem; font-size: .9rem; }
.mrow-extra { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .5rem 1.2rem; margin-top: .6rem; }
.mrow-names { flex: 1 1 260px; }
.mrow-names > summary { font-size: .85rem; display: inline-flex; align-items: center; gap: .35rem; color: var(--c-primary); }
.mrow-names > summary::before { content: none !important; }
.mrow-names textarea { margin-top: .4rem; font-size: .88rem; }
.madd { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .8rem; }
.madd .btn { flex: 1 1 200px; border-style: dashed; }

/* Topbar: breadcrumb su una riga con puntini di sospensione */
.breadcrumbs { flex-wrap: nowrap; overflow: hidden; white-space: nowrap; }
.breadcrumbs > a, .breadcrumbs > span:not(.sep) { overflow: hidden; text-overflow: ellipsis; max-width: 32ch; flex: 0 1 auto; min-width: 0; }
.breadcrumbs > span:last-child { flex-shrink: 0; }

@media (max-width: 900px) {
    .g-desc { grid-column: span 12; } .g-cat, .g-grp { grid-column: span 6; }
    .g-rap { grid-column: span 6; } .g-f { grid-column: span 6; }
    .g-q, .g-u { grid-column: span 3; } .g-c { grid-column: span 6; }
}
@media (max-width: 640px) {
    .breadcrumbs > :not(:last-child) { display: none; }
    .page-head h1 { font-size: 1.35rem; line-height: 1.15; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
    /* Azioni di pagina: primaria a tutta larghezza, secondarie compatte su due colonne */
    .page-head .actions { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .5rem; }
    .page-head .actions > * { width: 100%; min-width: 0; }
    .page-head .actions .btn { padding: .6rem .7rem; font-size: .85rem; white-space: normal; text-align: center; }
    .page-head .actions > .btn-accent:first-child { grid-column: 1 / -1; }
    .page-head .actions > .btn:last-child:nth-child(even) { grid-column: 1 / -1; }
    /* KPI: una colonna, etichetta e valore sulla stessa riga */
    .kpi-grid { grid-template-columns: minmax(0, 1fr); gap: .5rem; }
    .kpi { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 0 .8rem; padding: .75rem 1rem; }
    .kpi .kpi-label { grid-column: 1; }
    .kpi strong { grid-column: 2; grid-row: 1 / span 2; font-size: 1.1rem; text-align: right; white-space: nowrap; }
    .kpi small { grid-column: 1; }
    .bcat { padding: .9rem .8rem .4rem; }
    .bcat-head { grid-template-columns: auto minmax(0, 1fr) auto; }
    .bcat-total { grid-column: 2; grid-row: 2; font-size: 1rem; }
    .bcat-actions { grid-column: 3; grid-row: 1; }
    /* Voce: descrizione a tutta larghezza, sotto importo a sinistra e azioni a destra */
    .vitem { grid-template-columns: minmax(0, 1fr) auto; gap: .35rem .5rem; }
    .vmain { grid-column: 1 / -1; }
    .vamount { grid-column: 1; grid-row: 2; flex-direction: row; align-items: center; justify-content: flex-start; gap: .5rem; min-width: 0; }
    .vbar { width: 60px; }
    .vactions { grid-column: 2; grid-row: 2; }
    .info-kpis { grid-template-columns: 1fr 1fr; }
    .info-kpis > div:last-child { grid-column: 1 / -1; }
    .mgrid { gap: .5rem; }
    .g-cat, .g-grp, .g-rap, .g-f, .g-c { grid-column: span 12; }
    .g-q, .g-u { grid-column: span 6; }
    dialog.modal { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; }
    .modal-form { max-height: 100dvh; height: 100%; }
    .modal-foot { flex-direction: column-reverse; align-items: stretch; }
    .modal-foot .actions { justify-content: stretch; }
    .modal-foot .actions .btn { flex: 1; }
}

/* =====================================================================
   Pagina progetto — quadro economico compatto, popup per incassi/cofinanziamenti/spese
   ===================================================================== */
.proj-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .9rem; }
.proj-meta .icon { vertical-align: -2px; }
.ref-box { background: var(--c-surface); border: 1px solid var(--c-border); border-left: 5px solid var(--c-accent); border-radius: var(--radius-md); padding: .6rem 1rem; margin-bottom: 1rem; font-size: .88rem; }
.ref-box > summary { list-style: none; cursor: pointer; }
.ref-box > summary::before { content: none !important; }
.ref-box > summary::after { content: " ▾"; color: var(--c-muted); }
.ref-box[open] > summary::after { content: " ▴"; }
.ref-box[open] .ref-short { display: none; }
.ref-box p { margin: .5rem 0 0; }

.summary { padding: 1rem 1.2rem; }
.sum-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; }
.sum-item { display: flex; flex-direction: column; gap: .15rem; padding: .2rem 1rem; border-left: 1px solid var(--c-border); min-width: 0; }
.sum-item:first-child { border-left: 0; padding-left: .2rem; }
.sum-label { font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--c-muted); white-space: nowrap; }
.sum-item strong { font-family: var(--font-head); font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sum-item small { font-size: .74rem; color: var(--c-muted); line-height: 1.35; }
.sum-item.is-neg strong { color: var(--c-danger); }
.sum-bars { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem 1.4rem; margin-top: .9rem; padding-top: .8rem; border-top: 1px dashed var(--c-border); }
.sum-bars > div { display: grid; grid-template-columns: auto minmax(40px, 1fr) auto; align-items: center; gap: .6rem; font-size: .8rem; }
.sum-bars span { color: var(--c-muted); font-weight: 600; white-space: nowrap; }
.sum-bars b { font-variant-numeric: tabular-nums; }

.catlist { list-style: none; margin: .8rem 0 0; padding: 0; display: flex; flex-direction: column; }
.catlist li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .2rem .8rem; padding: .55rem 0; border-top: 1px solid var(--c-border); }
.catlist li:first-child { border-top: 0; }
.catlist li.is-over strong { color: var(--c-danger); }
.catlist-name { font-weight: 600; min-width: 0; }
.catlist-name small { display: block; font-weight: 500; }
.catlist strong { font-variant-numeric: tabular-nums; white-space: nowrap; }
.catlist-bar { grid-column: 2 / -1; max-width: 260px; }

.count-pill { display: inline-grid; place-items: center; min-width: 1.35rem; height: 1.35rem; padding: 0 .35rem; border-radius: var(--radius-pill); background: var(--c-surface-2); font-size: .72rem; font-weight: 800; }
.cash-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 1.4rem; align-items: start; }
.entrate { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.entrate li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .15rem .8rem; align-items: center; font-size: .86rem; }
.entrate li > span:first-child small { display: block; color: var(--c-muted); font-size: .74rem; }
.entrate li .progress { grid-column: 1 / -1; height: 6px; }
.entrate .ent-head { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 800; color: var(--c-muted); padding-top: .4rem; border-top: 1px dashed var(--c-border); }
.entrate .ent-head:first-child { border-top: 0; padding-top: 0; }
.entrate .ent-head strong { color: var(--c-text); font-size: .9rem; letter-spacing: 0; }
.ent-val { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.cash-dl { margin-top: 1rem; padding-top: .8rem; border-top: 1px solid var(--c-border); font-size: .86rem; }
.cash-dl dd { text-align: right; font-variant-numeric: tabular-nums; }

.vmain-static { min-width: 0; display: flex; flex-direction: column; gap: .2rem; }
a.vlink { color: inherit; text-decoration: none !important; border-radius: var(--radius-sm); }
a.vlink:hover .vtitle { color: var(--c-primary); }
.vstatus { gap: .3rem; flex-wrap: wrap; justify-content: flex-end; }

.plain-list { list-style: none; margin: 0 0 .6rem; padding: 0; display: flex; flex-direction: column; }
.plain-list li { display: flex; justify-content: space-between; align-items: center; gap: .8rem; padding: .55rem 0; border-top: 1px solid var(--c-border); font-size: .9rem; }
.plain-list li:first-child { border-top: 0; }
.plain-list li small { display: block; }
.dlg-form { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--c-border); }
.dlg-form h3 { margin: 0; }

@media (max-width: 1100px) {
    .sum-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: .9rem; }
    .sum-item:nth-child(4) { border-left: 0; padding-left: .2rem; }
    .cash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .summary { padding: .9rem; }
    .sum-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); row-gap: .8rem; }
    .sum-item { border-left: 0; padding: 0 .2rem; }
    .sum-item:nth-child(odd) { padding-right: .6rem; }
    .sum-item:first-child { grid-column: 1 / -1; }
    .sum-item strong { font-size: 1.1rem; }
    .sum-bars { grid-template-columns: 1fr; gap: .45rem; }
    .sum-bars > div { grid-template-columns: 8.5rem minmax(40px, 1fr) auto; }
    .card-head .actions { width: 100%; }
    .card-head .actions .btn { flex: 1 1 auto; }
    .catlist-bar { max-width: none; }
    .vstatus { grid-column: 2; grid-row: 2; }
}

/* Pagina progetto su telefono: niente grafici illeggibili, azioni affiancate */
@media (max-width: 640px) {
    .cat-chart, .cash-chart { display: none; }
    .card-head .actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
    .card-head .actions > .muted { grid-column: 1 / -1; }
    .card-head .actions > :only-child { grid-column: 1 / -1; }
    .page-head .actions:has(> details.dropdown) { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
    .page-head .actions:has(> details.dropdown) > .btn-accent:first-child { grid-column: 1 / -1; }
    .page-head .actions > details.dropdown { width: auto; }
    .page-head .actions > details.dropdown > summary { height: 100%; }
}

/* ---------- Conto alla rovescia chiusura bando ---------- */
.proj-head { flex-wrap: nowrap; align-items: flex-start; }
.proj-head .head-main { flex: 1 1 auto; min-width: 0; }
.head-side { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: .7rem; }
.countdown { --cd: var(--c-teal); --cd-soft: color-mix(in srgb, var(--c-teal) 14%, var(--c-surface)); background: var(--cd-soft); border: 2px solid color-mix(in srgb, var(--cd) 45%, transparent); border-radius: var(--radius-lg); padding: .6rem .9rem .65rem; min-width: 260px; }
.countdown.cd-vicino { --cd: var(--c-accent-dark); --cd-soft: color-mix(in srgb, var(--c-accent) 22%, var(--c-surface)); }
.countdown.cd-urgente { --cd: var(--c-coral); --cd-soft: color-mix(in srgb, var(--c-coral) 14%, var(--c-surface)); }
.countdown.cd-chiuso { --cd: var(--c-muted); --cd-soft: var(--c-surface-2); }
.cd-main { display: flex; align-items: center; gap: .7rem; }
.cd-num { font-family: var(--font-head); font-size: 2.3rem; line-height: 1; font-weight: 800; color: var(--cd); font-variant-numeric: tabular-nums; }
.cd-num .icon { width: 2rem; height: 2rem; }
.cd-txt { display: flex; flex-direction: column; font-weight: 800; font-size: .95rem; line-height: 1.2; }
.cd-txt small { font-weight: 600; font-size: .75rem; color: var(--c-muted); }
.cd-bar { height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--cd) 18%, transparent); margin-top: .55rem; overflow: hidden; }
.cd-bar span { display: block; height: 100%; width: 0; background: var(--cd); border-radius: 3px; transition: width .6s var(--ease-pop); }
.cd-sub { margin-top: .45rem; font-size: .75rem; color: var(--c-muted); font-weight: 600; display: flex; align-items: center; gap: .3rem; }
.cd-sub .icon { width: .95em; height: .95em; }
.countdown.cd-urgente .cd-num { animation: cd-pulse 2s ease-in-out infinite; }
@keyframes cd-pulse { 50% { transform: scale(1.08); } }
.head-side .actions { flex-wrap: wrap; justify-content: flex-end; }
.proj-head .head-main h1 { overflow-wrap: anywhere; }
/* Schermi medi (con sidebar): titolo a tutta larghezza, sotto countdown e azioni affiancati */
@media (max-width: 1320px) {
    .proj-head { flex-wrap: wrap; }
    .proj-head .head-main { flex-basis: 100%; }
    .head-side { width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; }
    .head-side .countdown { flex: 1 1 280px; max-width: 460px; min-width: 0; }
    .head-side .actions { flex: 0 1 auto; }
}
/* Telefono: tutto in colonna, azioni sulla griglia a due colonne */
@media (max-width: 640px) {
    .head-side { flex-direction: column; align-items: stretch; }
    .head-side .countdown { max-width: none; flex: none; }
    .head-side .actions { justify-content: stretch; }
}

/* ---------- Scelta a elenco (radio come card) ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.choice-list { border: 0; padding: 0; margin: 0; display: grid; gap: .5rem; max-height: 55vh; overflow-y: auto; }
.choice { display: flex; align-items: flex-start; gap: .7rem; padding: .7rem .85rem; border: 2px solid var(--c-border); border-radius: var(--radius-md); background: var(--c-surface); cursor: pointer; transition: border-color .15s, background .15s; }
.choice:hover { border-color: color-mix(in srgb, var(--c-primary) 45%, var(--c-border)); }
.choice:has(input:checked) { border-color: var(--c-primary); background: color-mix(in srgb, var(--c-primary) 7%, var(--c-surface)); }
.choice input { margin-top: .2rem; accent-color: var(--c-primary); flex: none; }
.choice span { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.choice strong { line-height: 1.25; overflow-wrap: anywhere; }
.choice small { font-size: .78rem; }

/* ---------- Elenco progetti ---------- */
.proj-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 1.25rem; margin-bottom: 1.25rem; }
.proj-card { display: flex; flex-direction: column; min-width: 0; margin-bottom: 0; }
.pc-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .7rem; min-width: 0; }
.pc-ente { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; }
.pc-top > .badge:last-child { flex: none; }
.pc-title { margin: 0 0 .4rem; line-height: 1.25; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pc-desc { margin: 0; }
.pc-foot { margin-top: auto; padding-top: .9rem; }
.pc-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
.pc-stats div { display: flex; flex-direction: column; min-width: 0; }
.pc-stats small { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--c-muted); font-weight: 700; }
.pc-stats strong { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.pc-bar { height: 6px; border-radius: 3px; background: var(--c-surface-2); margin: .6rem 0 .7rem; overflow: hidden; }
.pc-bar span { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--c-primary); }
.pc-dates { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .3rem .75rem; padding-top: .6rem; border-top: 1px dashed var(--c-border); font-size: .8rem; font-weight: 600; }
.pc-days { display: inline-flex; align-items: center; gap: .3rem; color: var(--c-teal); }
.pc-days .icon { width: 1em; height: 1em; }
.pc-days.cd-vicino { color: var(--c-accent-dark); }
.pc-days.cd-urgente { color: var(--c-coral); }
.pc-days.cd-chiuso { color: var(--c-muted); }
@media (max-width: 640px) {
    .proj-grid { gap: .9rem; }
    .pc-stats strong { font-size: .92rem; }
}

/* ---------- Voci di budget: numero risorse umane ---------- */
.mgrid .g-c { grid-column: span 2; } .mgrid .g-f { grid-column: span 1; } .mgrid .g-r { grid-column: span 2; }
.vres { display: inline-flex; align-items: center; gap: .25rem; font-weight: 700; color: var(--c-text); background: var(--c-surface-2); border-radius: var(--radius-pill); padding: .05rem .5rem; font-size: .72rem; white-space: nowrap; }
.vres .icon { width: .95em; height: .95em; color: var(--c-primary); }
.vres.over { background: color-mix(in srgb, var(--c-coral) 15%, var(--c-surface)); color: var(--c-coral); }
.vres.over .icon { color: var(--c-coral); }
@media (max-width: 900px) {
    .mgrid .g-c, .mgrid .g-f, .mgrid .g-r { grid-column: span 4; }
}
@media (max-width: 640px) {
    .mgrid .g-c { grid-column: span 12; }
    .mgrid .g-f, .mgrid .g-r { grid-column: span 6; }
}
.voce-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.warning-text { color: var(--c-accent-dark); font-weight: 700; }

/* Breadcrumb: su schermi medi restano solo gli ultimi livelli, leggibili */
@media (max-width: 1280px) {
    .breadcrumbs > :nth-last-child(n+6) { display: none; }
}
@media (max-width: 1000px) {
    .breadcrumbs > :nth-last-child(n+4) { display: none; }
    .breadcrumbs > a { max-width: 22ch; }
}

/* ---------- Panoramica associazione: elenco progetti a tutta larghezza ---------- */
.plist { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.pl-row { display: grid; grid-template-columns: minmax(0, 1fr) 130px 170px 70px 210px; align-items: center; gap: 1rem; padding: .8rem 1rem; border: 1px solid var(--c-border); border-radius: var(--radius-md); background: var(--c-surface); color: inherit; text-decoration: none; transition: border-color .15s, transform .15s; }
.pl-row:hover { border-color: var(--c-primary); transform: translateY(-1px); }
.pl-main { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.pl-title { line-height: 1.3; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pl-sub { font-size: .8rem; color: var(--c-muted); display: flex; align-items: center; gap: .4rem; min-width: 0; }
.pl-ente { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pl-stat { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.pl-stat > small { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--c-muted); font-weight: 700; white-space: nowrap; }
.pl-stat > strong { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pl-imp .pc-bar { margin: .35rem 0 0; }
.pl-date { align-items: flex-start; }
.pl-date .pc-days { font-size: .82rem; font-weight: 700; }
.pl-date small { text-transform: none; letter-spacing: 0; font-weight: 600; }
.side-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 1.25rem; align-items: start; margin-top: 1.25rem; }
.side-grid > .card { margin-bottom: 0; }
@media (max-width: 1200px) {
    .pl-row { grid-template-columns: minmax(0, 1fr) 120px 150px 60px; }
    .pl-date { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; gap: .2rem .9rem; align-items: center; padding-top: .5rem; border-top: 1px dashed var(--c-border); }
}
@media (max-width: 720px) {
    .pl-row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem .8rem; padding: .8rem .85rem; }
    .pl-main { grid-column: 1 / -1; }
    .pl-date { grid-column: 1 / -1; justify-content: space-between; }
}
.kpi-grid.kpi-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1200px) { .kpi-grid.kpi-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .kpi-grid.kpi-4 { grid-template-columns: minmax(0, 1fr); } }
.scad-list li { display: flex; flex-direction: column; gap: .1rem; }
.scad-list a { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.3; }
.scad-list small { display: inline-flex; align-items: center; gap: .25rem; font-size: .78rem; }
.scad-list .icon { width: .95em; height: .95em; }
@media (max-width: 720px) {
    .pl-row { grid-template-columns: minmax(0, 1fr) auto; }
    .pl-imp { grid-column: 1 / -1; grid-row: 3; }
    .pl-let { align-items: flex-end; }
}

/* ---------- Crediti del progettista ---------- */
.credit-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: .75rem; }
.credit { border: 1px solid var(--c-border); border-radius: var(--radius-md); padding: .75rem .9rem; background: var(--c-surface); display: flex; flex-direction: column; gap: .35rem; }
.credit-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.credit-head strong { font-size: .9rem; }
.credit-avail { font-family: var(--font-head); font-weight: 800; font-size: 1.35rem; color: var(--c-teal); white-space: nowrap; }
.credit-avail small { font-size: .7rem; font-weight: 700; color: var(--c-muted); }
.credit .pc-bar { margin: 0; }
.credit-low { border-color: color-mix(in srgb, var(--c-accent) 60%, var(--c-border)); }
.credit-low .credit-avail { color: var(--c-accent-dark); }
.credit-out { border-color: color-mix(in srgb, var(--c-coral) 55%, var(--c-border)); background: color-mix(in srgb, var(--c-coral) 6%, var(--c-surface)); }
.credit-out .credit-avail { color: var(--c-coral); }
.credit-out .pc-bar span { background: var(--c-coral); }
.mov-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.mov-list li { display: grid; grid-template-columns: 3rem minmax(0, 1fr) auto; gap: .75rem; align-items: center; padding: .55rem 0; border-bottom: 1px dashed var(--c-border); }
.mov-list li:last-child { border-bottom: 0; }
.mov-q { font-family: var(--font-head); font-weight: 800; text-align: center; border-radius: var(--radius-pill); padding: .1rem .4rem; font-size: .85rem; }
.mov-q.neg { background: color-mix(in srgb, var(--c-coral) 14%, var(--c-surface)); color: var(--c-coral); }
.mov-q.pos { background: color-mix(in srgb, var(--c-teal) 16%, var(--c-surface)); color: var(--c-teal); }
.mov-main { display: flex; flex-direction: column; min-width: 0; }
.mov-main small { overflow-wrap: anywhere; }
.mov-date { text-align: right; font-size: .75rem; }
.credit-chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.credit-chips .chip { font-size: .75rem; padding: .1rem .5rem; white-space: nowrap; }
.credit-chips .chip-out { background: color-mix(in srgb, var(--c-coral) 15%, var(--c-surface)); color: var(--c-coral); }
.btn.is-locked { opacity: .55; cursor: not-allowed; }
@media (max-width: 640px) {
    .mov-list li { grid-template-columns: 2.6rem minmax(0, 1fr); }
    .mov-date { grid-column: 2; text-align: left; }
}

/* ---------- Guida all'uso (progettista) ---------- */
.guide-banner { display: flex; align-items: center; gap: 1rem; color: inherit; text-decoration: none !important; border-color: var(--c-accent); background: linear-gradient(100deg, #fffbea, var(--c-surface) 60%); }
.guide-banner-icon { flex: none; width: 3.2rem; height: 3.2rem; border-radius: 1rem; display: grid; place-items: center; background: var(--c-accent); color: var(--c-accent-text); }
.guide-banner-icon .icon { width: 1.6rem; height: 1.6rem; }
.guide-banner-text { flex: 1; display: flex; flex-direction: column; gap: .15rem; }
.guide-banner-text strong { font-family: var(--font-head); font-size: 1.08rem; }

.guide, .guide-panel { scroll-margin-top: 6rem; }
/* Schede dei capitoli */
.guide-tabs { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .6rem; margin-bottom: 1.25rem; }
.guide-tab { display: flex; align-items: center; gap: .65rem; padding: .6rem .75rem; min-height: 3.6rem; background: var(--c-surface); border: 2px solid var(--c-border); border-radius: var(--radius-lg); color: var(--c-text); text-decoration: none !important; transition: border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast); }
.guide-tab:hover { border-color: var(--c-primary-soft); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.guide-tab.active { border-color: var(--c-primary); background: var(--c-primary-soft); box-shadow: var(--shadow-md); }
.guide-tab-icon { flex: none; width: 2.2rem; height: 2.2rem; border-radius: .75rem; display: grid; place-items: center; }
.guide-tab-icon .icon { width: 1.1rem; height: 1.1rem; }
.guide-tab-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.guide-tab-text small { color: var(--c-muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.guide-tab-text strong { font-size: .88rem; }
.guide-tab.active .guide-tab-text small { color: var(--c-primary); }
/* Selettore su schermi piccoli */
.guide-picker { display: none; flex-direction: column; gap: .35rem; margin-bottom: 1rem; font-weight: 700; font-size: .85rem; color: var(--c-muted); }
.guide-picker select { width: 100%; font-size: 1rem; font-weight: 700; color: var(--c-text); padding: .8rem 1rem; }
/* Senza JavaScript i capitoli restano tutti visibili uno sotto l'altro */
.guide.is-tabbed .guide-panel[hidden] { display: none; }

.guide-panel { padding: 1.75rem; }
.guide-panel-head { display: flex; gap: 1rem; align-items: flex-start; padding-bottom: 1.25rem; margin-bottom: .5rem; border-bottom: 1px solid var(--c-border); }
.guide-panel-title { min-width: 0; }
.guide-panel-title small { font-weight: 700; text-transform: uppercase; letter-spacing: .04em; font-size: .75rem; }
.guide-panel-title h2 { font-size: 1.6rem; margin: .15rem 0 .4rem; }
.guide-panel-title p { margin: 0; font-size: 1.05rem; color: var(--c-muted); max-width: 760px; }
.guide-chapter-num { flex: none; width: 3.2rem; height: 3.2rem; border-radius: 1rem; display: grid; place-items: center; font-family: var(--font-head); font-weight: 800; font-size: 1.5rem; }

/* Parti del capitolo */
.guide-part { padding: 1.5rem 0; }
.guide-part + .guide-part { border-top: 1px dashed var(--c-border); }
.guide-part-head { margin-bottom: .75rem; }
.guide-part-label { display: inline-block; font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--c-primary); margin-bottom: .2rem; }
.guide-part-head h3 { font-size: 1.2rem; margin: 0; }
.guide-part-text { max-width: 760px; font-size: 1rem; }
.guide-part-body { display: flex; flex-direction: column; gap: 1.25rem; }
.guide-part-body.is-side { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 360px); gap: 2rem; align-items: start; }
.guide-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .9rem; max-width: 760px; }
.guide-steps li { display: flex; gap: .8rem; align-items: flex-start; }
.guide-steps p { margin: .15rem 0 0; font-size: 1.02rem; line-height: 1.6; }
.guide-num { flex: none; width: 1.9rem; height: 1.9rem; border-radius: 50%; display: grid; place-items: center; background: #ff3b3b; color: #fff; font-weight: 800; font-size: .92rem; box-shadow: 0 0 0 3px #fff, 0 2px 6px rgba(15, 23, 42, .2); }
.guide-shot { margin: 0; }
.guide-shot a { position: relative; display: block; border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--c-border); box-shadow: var(--shadow-md); background: var(--c-surface-2); cursor: zoom-in; }
.guide-shot img { display: block; width: 100%; height: auto; }
.guide-zoom-hint { position: absolute; right: .6rem; bottom: .6rem; display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .7rem; border-radius: var(--radius-pill); background: rgba(15, 23, 42, .78); color: #fff; font-size: .8rem; font-weight: 700; }
.guide-zoom-hint .icon { width: 1rem; height: 1rem; }
.guide-shot figcaption { margin-top: .45rem; text-align: center; color: var(--c-muted); font-size: .82rem; }

.guide-flow { margin-top: .5rem; padding: 1.1rem 1.2rem; border-radius: var(--radius-lg); background: var(--c-surface-2); }
.guide-flow-steps { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .6rem; counter-reset: gf; }
.guide-flow-steps li { counter-increment: gf; padding: .7rem .8rem; background: var(--c-surface); border-radius: var(--radius-md); border: 1px solid var(--c-border); display: flex; flex-direction: column; gap: .2rem; font-size: .88rem; }
.guide-flow-steps li strong::before { content: counter(gf) ". "; color: var(--c-primary); }
.guide-flow-steps li span { color: var(--c-muted); }

.guide-tips { margin-top: 1rem; padding: 1rem 1.2rem; border-radius: var(--radius-lg); background: var(--c-info-soft); }
.guide-tips h3 { display: flex; align-items: center; gap: .4rem; font-size: 1rem; margin: 0 0 .5rem; color: #0369a1; }
.guide-tips h3 .icon { width: 1.2rem; height: 1.2rem; }
.guide-tips ul { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: .45rem; }
.guide-tips li.is-warn { color: var(--c-warning); }
.guide-tips li.is-warn::marker { content: "⚠ "; }

.guide-faq { display: flex; flex-direction: column; gap: .5rem; padding-top: 1.25rem; }
.guide-faq details { padding: .9rem 1rem; border: 1px solid var(--c-border); border-radius: var(--radius-md); background: var(--c-surface); }
.guide-faq details p { margin: .6rem 0 0; }

.guide-pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--c-border); }
.guide-pager-link { display: flex; flex-direction: column; gap: .1rem; padding: .75rem 1.1rem; border: 2px solid var(--c-border); border-radius: var(--radius-lg); color: var(--c-text); text-decoration: none !important; max-width: 48%; transition: border-color var(--t-fast); }
.guide-pager-link:hover { border-color: var(--c-primary); }
.guide-pager-link small { color: var(--c-muted); font-weight: 700; }
.guide-pager-link.is-next { margin-left: auto; text-align: right; background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.guide-pager-link.is-next small { color: rgba(255, 255, 255, .85); }

/* Immagine ingrandita */
dialog.guide-lightbox { border: 0; padding: 0; width: min(1320px, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); border-radius: var(--radius-xl); background: var(--c-surface); box-shadow: var(--shadow-lg); }
dialog.guide-lightbox[open] { display: flex; flex-direction: column; }
dialog.guide-lightbox::backdrop { background: rgba(15, 23, 42, .6); backdrop-filter: blur(3px); }
.guide-lightbox-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem .6rem .6rem 1.1rem; border-bottom: 1px solid var(--c-border); font-weight: 700; }
.guide-lightbox-body { overflow: auto; flex: 1; background: var(--c-surface-2); -webkit-overflow-scrolling: touch; }
.guide-lightbox-body img { display: block; width: 100%; height: auto; cursor: zoom-in; }
dialog.guide-lightbox.zoomed .guide-lightbox-body img { width: auto; max-width: none; cursor: zoom-out; }
.guide-lightbox-hint { margin: 0; padding: .5rem 1rem; text-align: center; font-size: .82rem; color: var(--c-muted); }

@media (max-width: 1100px) {
    .guide-part-body.is-side { grid-template-columns: 1fr; }
    .guide-part-body.is-side .guide-shot { max-width: 380px; }
}
@media (max-width: 860px) {
    .guide.is-tabbed .guide-tabs { display: none; }
    .guide.is-tabbed .guide-picker { display: flex; }
    .guide-panel { padding: 1.1rem; }
    .guide-panel-head { gap: .75rem; }
    .guide-panel-title h2 { font-size: 1.3rem; }
    .guide-panel-title p { font-size: 1rem; }
    .guide-chapter-num { width: 2.6rem; height: 2.6rem; font-size: 1.2rem; }
}
@media (max-width: 640px) {
    .guide-banner { flex-wrap: wrap; }
    .guide-banner .btn { width: 100%; justify-content: center; }
    .guide-pager { flex-direction: column-reverse; }
    .guide-pager-link { max-width: none; }
    .guide-pager-link.is-next { margin-left: 0; }
    .guide-pager > span:empty { display: none; }
    dialog.guide-lightbox { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; margin: 0; }
}
