/* ====== PALETTE (dal logo YGGDRA) ====== */
:root {
    --purple:        #8B2FE0;   /* viola principale */
    --purple-dark:   #6A1FB0;
    --purple-light:  #A85CEA;
    --purple-50:     #F4ECFD;
    --magenta:       #C724B1;   /* fine gradiente */
    --amber:         #F4A521;   /* accento secondario */
    --amber-50:      #FEF3E2;
    --grad:          linear-gradient(135deg, #8B2FE0 0%, #C724B1 100%);
    --ink:           #1C1530;   /* testo scuro */
    --muted:         #7A7390;
    --line:          #ECE8F2;
    --bg:            #F2EEFA;   /* sfondo lavanda tenue */
    --white:         #FFFFFF;
    --green:         #1FAE6A;
    --red:           #E0445B;
    /* colori su superficie gradiente (sidebar/header) */
    --on-grad:       rgba(255,255,255,.92);
    --on-grad-dim:   rgba(255,255,255,.62);
    --on-grad-hover: rgba(255,255,255,.14);
    --on-grad-line:  rgba(255,255,255,.16);
    --sidebar-w:     256px;
    --header-h:      68px;
    --radius:        14px;
    --shadow:        0 1px 3px rgba(28,21,48,.06), 0 10px 30px rgba(106,31,176,.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }

/* ====== SIDEBAR ====== */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--grad);
    border-right: 0;
    display: flex;
    flex-direction: column;
    z-index: 30;
    transition: width .22s ease;
}
.header, .main { transition: left .22s ease, margin-left .22s ease; }

/* ---- Stato collassato ---- */
body.sidebar-collapsed { --sidebar-w: 76px; }
body.sidebar-collapsed .sidebar__brand { justify-content: center; padding: 0; gap: 0; }
body.sidebar-collapsed .sidebar__brand .name,
body.sidebar-collapsed .nav__label,
body.sidebar-collapsed .nav__item .badge { display: none; }
body.sidebar-collapsed .nav__item { justify-content: center; gap: 0; font-size: 0; }
body.sidebar-collapsed .nav__item svg { font-size: 0; }
/* la freccia del toggle ruota quando è collassata */
body.sidebar-collapsed .collapse-btn svg { transform: rotate(180deg); }
.sidebar__brand {
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 22px;
    border-bottom: 1px solid var(--on-grad-line);
}
.sidebar__brand .mark {
    width: 30px; height: 30px;
    flex-shrink: 0;
}
.sidebar__brand .mark path,
.sidebar__brand .mark circle { stroke: #fff; }
.sidebar__brand .name {
    font-weight: 800;
    font-size: 21px;
    letter-spacing: .5px;
    color: #fff;
}
.sidebar__nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
}
.nav__label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--on-grad-dim);
    padding: 14px 12px 8px;
}
.nav__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 10px;
    color: var(--on-grad);
    font-size: 14.5px;
    font-weight: 500;
    margin-bottom: 2px;
    transition: background .15s, color .15s;
}
.nav__item svg { width: 19px; height: 19px; flex-shrink: 0; }
.nav__item:hover { background: var(--on-grad-hover); color: #fff; }
.nav__item.is-active {
    background: rgba(255,255,255,.16);
    color: #fff;
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--amber);
}
.nav__item .badge {
    margin-left: auto;
    background: var(--amber);
    color: #5a3a00;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
}
.nav__item.is-active .badge { background: var(--amber); color: #5a3a00; }

/* Footer della sidebar (pulsante comprimi/espandi) */
.sidebar__foot {
    padding: 12px;
    border-top: 1px solid var(--on-grad-line);
    display: flex;
}
body.sidebar-collapsed .sidebar__foot { justify-content: center; padding: 12px 0; }

/* ====== HEADER ====== */
.header {
    position: fixed;
    top: 0; right: 0;
    left: var(--sidebar-w);
    height: var(--header-h);
    background: var(--grad);
    display: flex;
    align-items: center;
    padding: 0 28px;
    z-index: 20;
}
.header__title h1 { font-size: 19px; font-weight: 700; color: #fff; }
.header__title p  { font-size: 13px; color: var(--on-grad-dim); margin-top: 2px; }
.header__actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 14px;
}
.search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--on-grad-hover);
    border: 1px solid var(--on-grad-line);
    border-radius: 10px;
    padding: 9px 14px;
    width: 240px;
}
.search input { border: 0; background: none; outline: none; font-size: 14px; width: 100%; color: #fff; }
.search input::placeholder { color: var(--on-grad-dim); }
.search svg { width: 16px; height: 16px; color: var(--on-grad-dim); }
.icon-btn {
    position: relative;
    width: 40px; height: 40px;
    display: grid; place-items: center;
    border-radius: 10px;
    border: 1px solid var(--on-grad-line);
    background: var(--on-grad-hover);
    cursor: pointer;
    color: #fff;
}
.icon-btn:hover { background: rgba(255,255,255,.24); }
.icon-btn .dot {
    position: absolute; top: 8px; right: 9px;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--amber);
    border: 2px solid var(--magenta);
}
.profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-left: 14px;
    border-left: 1px solid var(--on-grad-line);
    cursor: pointer;
}
.profile img {
    width: 40px; height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,.5);
}
/* Avatar generico quando l'utente non ha una foto profilo */
.profile__ph {
    width: 40px; height: 40px;
    border-radius: 50%;
    display: grid; place-items: center;
    background: var(--on-grad-hover);
    border: 2px solid rgba(255,255,255,.5);
    color: #fff;
}
.profile__ph svg { width: 22px; height: 22px; }
.profile__meta { line-height: 1.2; }
.profile__meta .n { font-size: 14px; font-weight: 600; color: #fff; }
.profile__meta .r { font-size: 12px; color: var(--on-grad-dim); }

/* ====== MAIN ====== */
.main {
    margin-left: var(--sidebar-w);
    padding: calc(var(--header-h) + 28px) 28px 40px;
}

/* KPI cards */
.kpis {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    margin-bottom: 24px;
}
.card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.kpi { padding: 20px; }
.kpi__top { display: flex; align-items: center; justify-content: space-between; }
.kpi__icon {
    width: 42px; height: 42px;
    border-radius: 11px;
    display: grid; place-items: center;
    background: var(--purple-50);
    color: var(--purple);
}
.kpi__icon svg { width: 21px; height: 21px; }
.kpi__icon.amber  { background: var(--amber-50);          color: var(--amber); }
.kpi__icon.green  { background: rgba(31,174,106,.12);     color: var(--green); }
.kpi__icon.magenta{ background: rgba(199,36,177,.10);     color: var(--magenta); }
/* striscia di colore in cima alla card KPI */
.kpi { position: relative; overflow: hidden; }
.kpi::before {
    content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: var(--purple);
}
.kpi.k-amber::before   { background: var(--amber); }
.kpi.k-green::before   { background: var(--green); }
.kpi.k-magenta::before { background: var(--magenta); }
.kpi__label { font-size: 13px; color: var(--muted); margin-top: 16px; }
.kpi__value { font-size: 26px; font-weight: 800; margin-top: 4px; letter-spacing: -.5px; }
.trend { font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; margin-top: 8px; }
.trend.up   { color: var(--green); }
.trend.down { color: var(--red); }

/* Row split */
.grid-2 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 18px;
    margin-bottom: 24px;
}
.panel { padding: 22px; }
.panel__head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px;
}
.panel__head h2 { font-size: 16px; font-weight: 700; }
.seg {
    display: flex; gap: 4px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 3px;
}
.seg button {
    border: 0; background: none; cursor: pointer;
    font-size: 12.5px; font-weight: 600; color: var(--muted);
    padding: 5px 12px; border-radius: 6px;
}
.seg button.is-active { background: var(--white); color: var(--purple-dark); box-shadow: var(--shadow); }

/* Line chart (SVG) */
.chart { width: 100%; }
.chart svg { width: 100%; height: 240px; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-x { font-size: 11px; fill: var(--muted); font-weight: 500; }
.chart .line-in  { fill: none; stroke: var(--purple); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart .line-out { fill: none; stroke: var(--amber); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 5 5; }
.chart .area-in  { fill: url(#areaGrad); }
.chart .dot { fill: #fff; stroke: var(--purple); stroke-width: 2.5; transition: r .15s; }
.chart .dot:hover { r: 6; }
.legend { display: flex; gap: 18px; }
.legend span { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* Donut / balance */
.balance { text-align: center; }
.donut {
    width: 170px; height: 170px;
    border-radius: 50%;
    margin: 8px auto 18px;
    background: conic-gradient(var(--purple) 0 64%, var(--amber) 64% 84%, var(--purple-light) 84% 100%);
    display: grid; place-items: center;
    position: relative;
}
.donut::after {
    content: ""; position: absolute;
    width: 116px; height: 116px;
    background: var(--white); border-radius: 50%;
}
.donut__c { position: relative; z-index: 1; }
.donut__c .v { font-size: 24px; font-weight: 800; }
.donut__c .l { font-size: 12px; color: var(--muted); }
.balance__row { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; font-size: 14px; border-top: 1px solid var(--line); }
.balance__row .k { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.balance__row .k i { width: 9px; height: 9px; border-radius: 3px; }
.balance__row .vv { font-weight: 700; }

/* Table */
.table-wrap { padding: 0; overflow: hidden; }
.table-wrap .panel__head { padding: 22px 22px 16px; margin: 0; }
table { width: 100%; border-collapse: collapse; }
thead th {
    text-align: left;
    font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px;
    color: var(--muted); font-weight: 700;
    padding: 12px 22px; background: var(--bg);
    border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
tbody td { padding: 15px 22px; font-size: 14px; border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--purple-50); }
.tx { display: flex; align-items: center; gap: 12px; }
.tx__ic { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; background: var(--purple-50); color: var(--purple); flex-shrink: 0; }
.tx__ic svg { width: 17px; height: 17px; }
.tx__t { font-weight: 600; }
.tx__s { font-size: 12.5px; color: var(--muted); }
.amount { font-weight: 700; text-align: right; }
.amount.pos { color: var(--green); }
.amount.neg { color: var(--red); }
.pill {
    font-size: 12px; font-weight: 600;
    padding: 4px 10px; border-radius: 20px;
    display: inline-block;
}
.pill.ok   { background: rgba(31,174,106,.12); color: var(--green); }
.pill.wait { background: rgba(224,68,91,.10); color: var(--red); }
.pill.run  { background: var(--purple-50); color: var(--purple-dark); }

.btn {
    background: var(--purple); color: #fff;
    border: 0; border-radius: 9px;
    padding: 9px 16px; font-size: 13.5px; font-weight: 600;
    cursor: pointer; display: inline-flex; align-items: center; gap: 7px;
    box-shadow: 0 6px 16px rgba(139,47,224,.28);
}
.btn:hover { background: var(--purple-dark); }
.btn svg { width: 16px; height: 16px; }

/* ====== NAV MOBILE (hamburger + overlay del drawer) ====== */
/* Hamburger: nascosto su desktop, visibile solo sotto il breakpoint mobile */
.nav-toggle { display: none; }

/* Overlay scuro dietro al drawer: invisibile finché il menù non è aperto */
.nav-overlay {
    position: fixed; inset: 0;
    background: rgba(15,12,25,.5);
    opacity: 0; visibility: hidden; pointer-events: none;
    transition: opacity .25s ease;
    z-index: 25;
}
body.nav-open .nav-overlay { opacity: 1; visibility: visible; pointer-events: auto; }

@media (max-width: 1100px) {
    .kpis { grid-template-columns: repeat(2,1fr); }
    .grid-2 { grid-template-columns: 1fr; }
}

/* ====== MOBILE: sidebar -> drawer off-canvas ====== */
@media (max-width: 860px) {
    :root { --sidebar-w: 0px; }          /* l'offset di header/main si annulla */

    /* Hamburger visibile, header e main a tutta larghezza */
    .nav-toggle { display: grid; }
    .search { display: none; }
    .header { left: 0; padding: 0 16px; gap: 10px; }
    .header__title h1 { font-size: 17px; }
    .header__title p { display: none; }
    .header__actions { gap: 10px; }
    .profile { padding-left: 10px; }
    .profile__meta { display: none; }
    .main { margin-left: 0; padding: calc(var(--header-h) + 18px) 16px 32px; }

    /* La sidebar diventa un pannello che scorre da sinistra */
    .sidebar {
        width: 256px;
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: 6px 0 28px rgba(15,12,25,.22);
    }
    body.nav-open .sidebar { transform: translateX(0); }

    /* Dentro al drawer si ignora lo stato "collassato" salvato da desktop */
    .sidebar__foot { display: none; }
    body.sidebar-collapsed .sidebar__brand { justify-content: flex-start; padding: 0 22px; gap: 10px; }
    body.sidebar-collapsed .sidebar__brand .name,
    body.sidebar-collapsed .nav__label,
    body.sidebar-collapsed .nav__item .badge { display: block; }
    body.sidebar-collapsed .nav__item { justify-content: flex-start; gap: 12px; font-size: 14.5px; }
    body.sidebar-collapsed .nav__item svg { font-size: 14.5px; }

    /* Tabelle: scroll orizzontale invece di sforare il viewport */
    .table-wrap,
    .voci-card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table-wrap table,
    .voci-card .voci-table { min-width: 560px; }

    /* Form: i campi affiancati passano in colonna */
    .form-row { flex-wrap: wrap; }
    .form-row .form-group { flex: 1 1 100%; }
}

/* ====== SCHERMI MOLTO STRETTI ====== */
@media (max-width: 560px) {
    .kpis, .kpis.kpis-3 { grid-template-columns: 1fr; }
    .modal__foot { flex-wrap: wrap; }
}

/* =====================================================================
   COMPONENTI CONDIVISI (consolidati dai vecchi blocchi <style> inline)
   ===================================================================== */

/* ---- Stato vuoto / celle / link ---- */
.empty-state{ padding:40px 22px; text-align:center; color:var(--muted); font-size:14px; }
.muted-cell{ color:var(--muted); }
.doc-link{ color:var(--purple-dark); font-weight:600; }
.doc-link:hover{ text-decoration:underline; }
.section-gap{ margin-top:26px; }

/* ---- Pagine segnaposto (index, impostazioni) ---- */
.placeholder{ padding:48px 22px; text-align:center; color:var(--muted); }
.placeholder__icon{ width:64px; height:64px; margin:0 auto 18px; display:grid; place-items:center; border-radius:16px; background:var(--purple-50); color:var(--purple); }
.placeholder__icon svg{ width:30px; height:30px; }
.placeholder h2{ font-size:20px; color:var(--ink); margin-bottom:8px; }
.placeholder p{ font-size:14px; max-width:420px; margin:0 auto; }

/* ---- Form (usati nelle modali) ---- */
.form-group{ margin-bottom:16px; }
.form-group label{ display:block; font-size:13px; font-weight:600; margin-bottom:6px; color:#3a3a47; }
.form-control{ width:100%; box-sizing:border-box; padding:10px 12px; border:1px solid #d8d8e2; border-radius:9px; font-size:14px; font-family:inherit; }
.form-control:focus{ outline:none; border-color:#8B2FE0; box-shadow:0 0 0 3px rgba(139,47,224,.15); }
textarea.form-control{ resize:vertical; min-height:80px; }
.form-row{ display:flex; gap:12px; }
.form-row .form-group{ flex:1; }
.form-hint{ font-size:12px; color:var(--muted); margin-top:5px; }

/* ---- Bottoni modale ---- */
.btn-secondary{ background:#f3f3f8; color:#3a3a47; border:0; padding:10px 18px; border-radius:9px; cursor:pointer; font-size:14px; font-weight:600; }
.btn-secondary:hover{ background:#e8e8f0; }
.btn-primary{ background:#8B2FE0; color:#fff; border:0; padding:10px 18px; border-radius:9px; cursor:pointer; font-size:14px; font-weight:600; }
.btn-primary:hover{ background:#7a25c9; }

/* ---- Modale (overlay + card). Larghezza: default 560px, modificatori lg/sm ---- */
.modal-overlay{ position:fixed; inset:0; background:rgba(15,12,25,.55); display:none; align-items:flex-start; justify-content:center; padding:40px 16px; z-index:1000; overflow-y:auto; }
.modal-overlay.is-open{ display:flex; }
.modal{ background:#fff; width:100%; max-width:560px; border-radius:14px; box-shadow:0 20px 60px rgba(0,0,0,.25); overflow:hidden; animation:modalIn .18s ease; }
.modal--lg{ max-width:640px; }
.modal--sm{ max-width:520px; }
@keyframes modalIn{ from{ transform:translateY(-12px); opacity:0; } to{ transform:translateY(0); opacity:1; } }
.modal__head{ display:flex; align-items:center; justify-content:space-between; padding:18px 22px; border-bottom:1px solid #ececf3; }
.modal__head h3{ margin:0; font-size:18px; }
.modal__close{ background:none; border:0; cursor:pointer; font-size:24px; line-height:1; color:#8a8a99; padding:4px 8px; border-radius:8px; }
.modal__close:hover{ background:#f3f3f8; color:#333; }
.modal__body{ padding:22px; }
.modal__foot{ display:flex; justify-content:flex-end; gap:10px; padding:16px 22px; border-top:1px solid #ececf3; background:#fafafd; }

/* ---- Progetti: voci di spesa nel modale ---- */
.voci-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:8px; }
.voci-head label{ margin:0; font-size:13px; font-weight:600; color:#3a3a47; }
/* Bottone "Analisi": riempie in altezza la colonna così da pareggiare
   il box dell'input accanto (la label fittizia allinea la partenza in alto) */
/* Riga filtri centrata rispetto alla card: i campi non crescono a riempire
   tutta la larghezza, così il gruppo dei tre controlli resta centrato */
.filtri{ justify-content:center; flex-wrap:wrap; text-align:left; }
.filtri .form-group{ flex:0 1 340px; }
.filtri .form-group--btn{ flex:0 0 auto; }

.form-group--btn{ display:flex; flex-direction:column; align-items:flex-start; align-self:stretch; }
/* flex:1 ne fissa l'altezza (pareggia il campo accanto); aspect-ratio allarga
   la larghezza in proporzione, mantenendo le proporzioni originali del bottone */
#btnAnalisi{ flex:1 1 auto; width:auto; aspect-ratio:2.2; padding-top:0; padding-bottom:0; justify-content:center; }

/* Link-azione compatto (es. "Seleziona tutti" accanto a una label) */
.link-mini{ background:none; border:0; padding:0; margin-left:8px; cursor:pointer; color:#8B2FE0; font-size:12px; font-weight:600; }
.link-mini:hover{ text-decoration:underline; }

.voce-row{ display:flex; gap:8px; margin-bottom:8px; align-items:center; }
.voce-row .voce-desc{ flex:1 1 auto; }
/* Tom Select sull'input descrizione voce: occupa lo spazio disponibile e si allinea agli altri campi */
.voce-row .ts-wrapper{ flex:1 1 auto; min-width:0; }
.voce-row .ts-wrapper .ts-control{ min-height:38px; }
.voce-row .voce-importo{ flex:0 0 140px; }
.voce-remove{ flex:0 0 auto; background:#fdeaea; color:#c0392b; border:0; cursor:pointer; width:36px; height:38px; border-radius:9px; font-size:18px; line-height:1; }
.voce-remove:hover{ background:#f9d6d6; }
.btn-add-voce{ background:#f3ecfc; color:#8B2FE0; border:1px dashed #c9a9f0; padding:8px 14px; border-radius:9px; cursor:pointer; font-size:13px; font-weight:600; }
.btn-add-voce:hover{ background:#ebddfb; }
.voci-total{ margin-top:12px; text-align:right; font-size:14px; color:#3a3a47; }
.voci-total strong{ font-size:16px; }

/* ---- Utenti: bottoni azione in tabella + badge ruolo ---- */
.btn-modifica, .btn-elimina{ border:0; cursor:pointer; font-size:13px; font-weight:600; padding:7px 12px; border-radius:8px; }
.btn-modifica{ background:var(--purple-50); color:var(--purple-dark); }
.btn-modifica:hover{ background:#ebddfb; }
.btn-elimina{ background:#fdeaea; color:#c0392b; }
.btn-elimina:hover{ background:#f9d6d6; }
.btn-elimina:disabled{ opacity:.45; cursor:not-allowed; }
.role-badge{ font-size:12px; font-weight:600; padding:4px 10px; border-radius:20px; display:inline-block; background:var(--purple-50); color:var(--purple-dark); }
.you-tag{ font-size:11px; color:var(--muted); margin-left:6px; }

/* ---- Dettaglio progetto ---- */
.page-top{ display:flex; align-items:center; gap:14px; margin-bottom:22px; }
.back-link{ display:inline-flex; align-items:center; gap:6px; font-size:13.5px; font-weight:600; color:var(--purple-dark); background:var(--white); border:1px solid var(--line); border-radius:9px; padding:8px 14px; }
.back-link:hover{ background:var(--purple-50); }
.page-top h1{ font-size:22px; font-weight:800; }
.page-top .sub{ font-size:13px; color:var(--muted); margin-top:2px; }
.kpis.kpis-3{ grid-template-columns:repeat(3,1fr); }
.voci-card{ padding:0; overflow:hidden; }
.voci-card .panel__head{ padding:20px 22px 14px; margin:0; }
.voci-table{ width:100%; border-collapse:collapse; }
.voci-table th{ text-align:left; font-size:11px; text-transform:uppercase; letter-spacing:.5px; color:var(--muted); font-weight:700; padding:10px 22px; background:var(--bg); border-top:1px solid var(--line); border-bottom:1px solid var(--line); }
.voci-table th.num, .voci-table td.num{ text-align:right; }
.voci-table td{ padding:12px 22px; font-size:13.5px; border-bottom:1px solid var(--line); }
.voci-table tr:last-child td{ border-bottom:0; }
.voce-nome{ font-weight:600; }
.voce-bar{ height:6px; border-radius:6px; background:var(--line); margin-top:7px; overflow:hidden; }
.voce-bar > i{ display:block; height:100%; background:var(--purple); border-radius:6px; }
.voce-bar.over > i{ background:var(--red); }
.speso-val{ font-weight:700; }
.speso-val.over{ color:var(--red); }
.row-actions{ display:flex; gap:6px; justify-content:flex-end; }
.btn-icon{ border:0; cursor:pointer; width:32px; height:32px; border-radius:8px; display:grid; place-items:center; background:var(--bg); color:var(--muted); }
.btn-icon:hover{ background:var(--purple-50); color:var(--purple-dark); }
.btn-icon.danger:hover{ background:#fdeaea; color:var(--red); }
.btn-icon svg{ width:16px; height:16px; }

/* =====================================================================
   SCHERMATE DI AUTENTICAZIONE (login / logout)
   ===================================================================== */
body.auth{ min-height:100vh; display:grid; place-items:center; background:var(--grad); padding:24px; }
.auth-card{ width:100%; max-width:400px; background:var(--white); border-radius:var(--radius); box-shadow:0 20px 60px rgba(0,0,0,.25); overflow:hidden; animation:authIn .2s ease; }
@keyframes authIn{ from{ transform:translateY(-10px); opacity:0; } to{ transform:translateY(0); opacity:1; } }
.auth-card__head{ text-align:center; padding:34px 32px 6px; }
.auth-brand{ display:flex; align-items:center; justify-content:center; gap:10px; margin-bottom:18px; }
.auth-brand .mark{ width:34px; height:34px; }
.auth-brand .name{ font-weight:800; font-size:22px; letter-spacing:.5px; color:var(--purple); }
.auth-card__head h1{ font-size:20px; color:var(--ink); }
.auth-card__head p{ font-size:14px; color:var(--muted); margin-top:4px; }
.auth-card__body{ padding:24px 32px 32px; }
.auth-field{ margin-bottom:16px; }
.auth-field label{ display:block; font-size:13px; font-weight:600; margin-bottom:6px; color:var(--ink); }
.auth-input{ width:100%; box-sizing:border-box; padding:11px 14px; border:1px solid var(--line); border-radius:10px; font-size:14px; font-family:inherit; background:#fff; color:var(--ink); }
.auth-input:focus{ outline:none; border-color:var(--purple); box-shadow:0 0 0 3px rgba(139,47,224,.15); }
.auth-btn{ width:100%; border:0; border-radius:10px; cursor:pointer; padding:12px; font-size:15px; font-weight:700; color:#fff; background:var(--grad); box-shadow:0 8px 20px rgba(139,47,224,.30); }
.auth-btn:hover{ filter:brightness(1.05); }
a.auth-btn{ display:inline-block; width:auto; padding:12px 28px; text-decoration:none; }
.auth-alert{ background:rgba(224,68,91,.10); color:var(--red); border-radius:10px; padding:10px 14px; font-size:13px; font-weight:600; margin-bottom:18px; text-align:center; }
.auth-msg{ text-align:center; padding:38px 32px; }
.auth-msg .icon{ width:60px; height:60px; margin:0 auto 18px; display:grid; place-items:center; border-radius:50%; background:var(--purple-50); color:var(--purple); }
.auth-msg .icon svg{ width:30px; height:30px; }
.auth-msg h1{ font-size:20px; color:var(--ink); margin-bottom:8px; }
.auth-msg p{ font-size:14px; color:var(--muted); max-width:280px; margin:0 auto; }

/* =====================================================================
   PAGINA PROFILO
   ===================================================================== */
.profile-photo{ display:flex; flex-direction:column; align-items:center; text-align:center; gap:18px; padding:8px 0; }
.profile-photo__avatar{ width:140px; height:140px; border-radius:50%; overflow:hidden; background:var(--purple-50); display:grid; place-items:center; border:3px solid var(--white); box-shadow:var(--shadow); }
.profile-photo__avatar img{ width:100%; height:100%; object-fit:cover; }
.profile-photo__ph{ color:var(--purple); display:grid; place-items:center; }
.profile-photo__ph svg{ width:56px; height:56px; }
.profile-photo__actions{ display:flex; gap:10px; justify-content:center; flex-wrap:wrap; }
.profile-photo .form-hint{ text-align:center; }
.form-sep{ border:0; border-top:1px solid var(--line); margin:6px 0 18px; }

/* Rende cliccabile il blocco profilo nell'header */
a.profile{ cursor:pointer; }
a.profile:hover .profile__meta .n{ text-decoration:underline; }

/* =====================================================================
   ALLEGATI — dropzone (drag & drop) + lista file nel modale movimento
   ===================================================================== */
.dropzone{ border:2px dashed #c9bfe0; border-radius:11px; background:#faf8fe; padding:20px 16px; text-align:center; color:var(--muted); cursor:pointer; transition:border-color .15s, background .15s; display:flex; flex-direction:column; align-items:center; gap:8px; }
.dropzone:hover{ border-color:var(--purple-light); background:var(--purple-50); }
.dropzone:focus{ outline:none; border-color:var(--purple); box-shadow:0 0 0 3px rgba(139,47,224,.15); }
.dropzone.is-drag{ border-color:var(--purple); background:var(--purple-50); color:var(--purple-dark); }
.dropzone svg{ width:30px; height:30px; color:var(--purple); }
.dropzone__text{ font-size:14px; color:#3a3a47; }
.dropzone__browse{ color:var(--purple-dark); font-weight:700; text-decoration:underline; }
.dropzone__hint{ font-size:12px; color:var(--muted); }

.allegati-list{ list-style:none; margin:12px 0 0; padding:0; display:flex; flex-direction:column; gap:8px; }
.allegato-item{ display:flex; align-items:center; gap:10px; padding:8px 10px; border:1px solid var(--line); border-radius:9px; background:#fff; font-size:13.5px; }
.allegato-item.is-staged{ background:#f4ecfd; border-color:#dcc8f6; }
.allegato-ic{ flex:0 0 auto; width:26px; height:26px; display:grid; place-items:center; border-radius:7px; background:var(--purple-50); color:var(--purple-dark); }
.allegato-ic svg{ width:15px; height:15px; }
.allegato-nome{ flex:1 1 auto; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--ink); font-weight:600; }
a.allegato-nome:hover{ color:var(--purple-dark); text-decoration:underline; }
.allegato-dim{ flex:0 0 auto; font-size:12px; color:var(--muted); }
.allegato-del{ flex:0 0 auto; border:0; cursor:pointer; width:26px; height:26px; border-radius:7px; background:#fdeaea; color:#c0392b; font-size:18px; line-height:1; }
.allegato-del:hover{ background:#f9d6d6; }

/* Indicatore allegati nella colonna "Doc" della tabella movimenti */
.doc-clip{ display:inline-flex; align-items:center; gap:3px; color:var(--purple-dark); font-weight:600; font-size:13px; }
.doc-clip svg{ width:15px; height:15px; }
a.doc-clip:hover{ text-decoration:underline; }
