/* ============================================================
   DEBORAH — STILE COMUNE DELL'ECOSISTEMA PAPERPIXELS
   Fonte: 06-STILE-COMUNE.md (repo ppx-ecosistema). Fa fede l'Hub.
   Un solo CSS a sezioni commentate. Font Inter, icone emoji.
   ============================================================ */

/* ---------- 1. VARIABILI (palette comune, accento lime) ---------- */
:root {
    --accento:      #C7EF02;  /* Drive Lime (stesso dell'Hub, scelta di Manu).
                                 MAI per testi lunghi; sopra l'accento testo NERO */
    --accento-scuro:#A8CB02;  /* hover dell'accento */
    --ink:          #010101;  /* testo principale */
    --grafite:      #181818;  /* superfici scure: sidebar, testate app */
    --mist:         #F6F6F4;  /* sfondo pagina */
    --grigio:       #6C6C6C;  /* testo secondario/label */
    --bianco:       #FFFFFF;  /* superfici: card, input */
    --bordo:        #E6E6E2;
    --bordo-input:  #CFCFCB;
    /* semantici (uguali sui due portali, non si toccano) */
    --ok-bg:#EAF3DE; --ok-testo:#3B6D11; --ok-bordo:#97C459;
    --no-bg:#FCEBEB; --no-testo:#A32D2D; --no-bordo:#F09595;
    --attesa-bg:#FAEEDA; --attesa-testo:#854F0B; --attesa-bordo:#EF9F27;
    --info-bg:#E6F1FB; --info-testo:#185FA5; --info-bordo:#85B7EB;

    /* --- ALIAS DI TRANSIZIONE: i nomi vecchi di Deborah, mappati sulla
       palette comune. I template interni li usano ancora: NON rimuovere
       finché tutte le pagine non sono migrate. --accent NON è il lime
       (illeggibile come testo): è il blu semantico info. --- */
    --bg: var(--mist);
    --card: var(--bianco);
    --muted: var(--grigio);
    --line: var(--bordo);
    --line2: #EFEFEC;
    --accent: var(--info-testo);
    --accent-soft: var(--info-bg);
    --good: var(--ok-testo);   --good-soft: var(--ok-bg);
    --bad: var(--no-testo);    --bad-soft: var(--no-bg);
    --warn: var(--attesa-testo); --warn-soft: var(--attesa-bg);
}

/* ---------- 2. BASE (Inter 16px, link, reset) ---------- */
* { box-sizing: border-box; }
html { font-size: 16px; }
body {
    margin: 0; background: var(--mist); color: var(--ink);
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.5;
}
a { color: var(--info-testo); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 3. LAYOUT: sidebar sinistra + contenuto ---------- */
.layout { display: flex; min-height: 100vh; }
.contenuto { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top {
    display: flex; align-items: center; gap: .9rem; min-height: 52px;
    padding: 0 2rem; background: var(--bianco); border-bottom: 1px solid var(--bordo);
}
.top h1 { margin: 0; font-size: 1.05rem; font-weight: 700; letter-spacing: -.01em; }
.top .date { color: var(--grigio); font-size: .78rem; text-transform: capitalize; margin-top: .1rem; }
.content { padding: 1.2rem 2rem 3rem; max-width: 1500px; margin: 0 auto; width: 100%; }

/* ---------- 4. SIDEBAR (grafite 236px — il pezzo caratterizzante) ---------- */
.sidebar {
    width: 236px; flex: 0 0 236px; background: var(--grafite);
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    display: flex; flex-direction: column; padding: 14px 10px;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: #3a3a3a; border-radius: 3px; }
.sb-brand { text-align: center; padding: 6px 0 14px; }
.sb-brand img { width: min(40%, 96px); height: auto; display: block; margin: 0 auto 6px; }
.sb-brand .nome { color: #fff; font-size: 15px; font-weight: 800; }
.sb-brand .lineetta {
    width: 34px; height: 3px; border-radius: 2px; background: var(--accento);
    margin: 6px auto 0;
}
.sb-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sb-nav a {
    display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px;
    border-radius: 8px; font-size: 13.5px; color: #d5d5d2; white-space: nowrap;
}
.sb-nav a .ic { width: 20px; flex: 0 0 20px; text-align: center; }
.sb-nav a:hover { background: #262626; color: #fff; text-decoration: none; }
/* Voce ATTIVA: sfondo accento + indicatore laterale e testo scritto a mano.
   Migliorìa d'ecosistema 07 §3-ter: se una variabile del tema arrivasse vuota,
   con il solo sfondo la voce attiva diventerebbe scura su scuro (illeggibile).
   Qui il colore del testo è un valore fisso, non una variabile. */
.sb-nav a.on {
    background: var(--accento, #C7EF02); color: #010101; font-weight: 600;
    box-shadow: inset 3px 0 0 #010101;
}
.sb-nav .badge { margin-left: auto; }
/* gruppi richiudibili (Fase C: personalizzazione; la struttura è già pronta) */
.sb-nav details > summary {
    display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px;
    border-radius: 8px; font-size: 13.5px; color: #d5d5d2; cursor: pointer;
    list-style: none;
}
.sb-nav details > summary::after { content: '▶'; margin-left: auto; font-size: 9px; transition: transform .15s; }
.sb-nav details[open] > summary::after { transform: rotate(90deg); }
.sb-nav details > summary:hover { background: #262626; color: #fff; }
.sb-nav details .sotto { margin-left: 20px; border-left: 1px solid #313131; padding-left: 6px; }
.sb-nav details .sotto a { height: 32px; font-size: 13px; }
.sb-etichetta { color: #8a8a86; font-size: 10px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; padding: 10px 10px 4px; }
.sb-utente {
    border-top: 1px solid #313131; margin-top: 10px; padding: 10px 10px 4px;
    color: #d5d5d2; font-size: 12.5px; display: flex; align-items: center; gap: 8px;
}
.sb-utente .n { font-weight: 600; color: #fff; line-height: 1.2; }
.sb-utente .r { color: #8a8a86; font-size: 11px; }
.sb-utente .esci { margin-left: auto; color: #d5d5d2; font-size: 15px; }
.sb-online { color: #8a8a86; font-size: 11px; padding: 4px 10px 0; }

/* ---------- 5. COMPONENTI ---------- */
/* Card */
.card {
    background: var(--bianco); border: 1px solid var(--bordo); border-radius: 12px;
    padding: 20px; margin-bottom: 16px;
}
.card h3, .card-title { margin: 0 0 .8rem; font-size: 15px; font-weight: 700; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }

/* Card-sezione e tile (pagine indice) */
.sez-card, .tile {
    display: block; background: var(--bianco); border: 1px solid var(--bordo);
    border-radius: 12px; padding: 20px; color: inherit;
}
.sez-card:hover, .tile:hover { border-color: var(--bordo-input); text-decoration: none; }
.sez-card .t, .tile .t { font-weight: 700; color: var(--ink); font-size: 1rem; }
.sez-card p, .tile p { color: var(--grigio); font-size: .85rem; margin: .3rem 0 0; line-height: 1.45; }
.sez-card .stato { display: inline-block; font-size: .7rem; padding: .15rem .6rem; border-radius: 20px;
    background: var(--ok-bg); color: var(--ok-testo); margin-bottom: .5rem; }
.sez-card .stato.rosso { background: var(--no-bg); color: var(--no-testo); }
.sez-card .stato.ambra { background: var(--attesa-bg); color: var(--attesa-testo); }

/* Stat-card (i numeri chiave; ex .kpi) */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 0 0 1rem; }
.kpi {
    background: var(--bianco); border: 1px solid var(--bordo); border-radius: 12px;
    padding: 16px; border-bottom: 3px solid var(--accento);
}
.kpi .n { font-size: 28px; font-weight: 800; }
.kpi .l { color: var(--grigio); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; margin-top: .25rem; }
.kpi.good .n { color: var(--ok-testo); } .kpi.bad .n { color: var(--no-testo); }

/* Tabelle */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--bordo); vertical-align: middle; }
th { color: var(--grigio); font-weight: 600; font-size: 11px; text-transform: uppercase;
     letter-spacing: .05em; background: #FAFAF8; }
td.r, th.r { text-align: right; }
tr:hover td { background: #FAFAF8; }

/* Pill (ex .tag) e badge */
.tag, .pill { font-size: 12px; font-weight: 500; padding: 3px 12px; border-radius: 20px; display: inline-block; }
.tag.EMESSA, .tag.good, .pill-ok { background: var(--ok-bg); color: var(--ok-testo); }
.tag.RICEVUTA, .tag.warn, .pill-attesa { background: var(--attesa-bg); color: var(--attesa-testo); }
.tag.ALTRO { background: #EFEFEC; color: var(--grigio); }
.tag.late, .tag.bad, .pill-no { background: var(--no-bg); color: var(--no-testo); margin-left: .4rem; }
.pill-accento { background: var(--accento); color: var(--ink); }
.badge { background: #dc2626; color: #fff; border-radius: 8px; font-size: 10px; font-weight: 700;
    padding: 2px 8px; min-width: 1.1rem; text-align: center; text-transform: uppercase; line-height: 1.4; }

/* Bottoni */
.btn {
    display: inline-block; padding: 8px 16px; border: 1px solid transparent; border-radius: 8px;
    background: var(--accento); color: var(--ink); cursor: pointer;
    font-size: 14px; font-weight: 700; font-family: inherit;
}
.btn:hover { background: var(--accento-scuro); text-decoration: none; }
.btn.ghost { background: var(--bianco); border-color: var(--bordo-input); color: var(--ink); font-weight: 500; }
.btn.ghost:hover { background: var(--mist); }
.btn.danger { background: var(--bianco); border-color: var(--no-bordo); color: var(--no-testo); font-weight: 500; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.lk { background: none; border: 0; cursor: pointer; font-size: inherit; color: var(--info-testo); padding: 0 .15rem; }

/* Form */
input, select, textarea {
    font-family: inherit; font-size: 14px; padding: 7px 10px;
    border: 1px solid var(--bordo-input); border-radius: 8px;
    background: var(--bianco); color: var(--ink);
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--ink);
    box-shadow: 0 0 0 3px rgba(199, 239, 2, .35);
}
input[type=checkbox] { accent-color: var(--accento); }

/* Pillole filtro */
.pillole { display: inline-flex; gap: .25rem; background: #EFEFEC; border-radius: 20px; padding: .25rem; }
.pillola { padding: .4rem .95rem; border-radius: 16px; font-size: .85rem; color: var(--ink);
    cursor: pointer; border: 0; background: transparent; text-decoration: none; }
.pillola:hover { background: #E4E4E0; text-decoration: none; }
.pillola.on { background: var(--accento); color: var(--ink); font-weight: 600; }

/* Flash (semantici) */
.flash { background: var(--ok-bg); border: 1px solid var(--ok-bordo); color: var(--ok-testo);
    padding: .65rem .95rem; border-radius: 10px; margin-bottom: 1rem; }

/* Vari (già in uso nei template) */
.muted { color: var(--grigio); font-size: .88rem; }
.sub { color: #9a9a96; font-size: .76rem; }
.inizialone { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
    font-size: .78rem; font-weight: 700; flex: 0 0 34px; }
.pastello0 { background: #dbeafe; color: #1d4ed8; } .pastello1 { background: #dcfce7; color: #15803d; }
.pastello2 { background: #fce7f3; color: #be185d; } .pastello3 { background: #fef3c7; color: #b45309; }
.pastello4 { background: #ede9fe; color: #6d28d9; } .pastello5 { background: #cffafe; color: #0e7490; }
.vuoto { background: var(--info-bg); border: 1px solid var(--info-bordo); border-radius: 12px;
    padding: 2.2rem 1.5rem; text-align: center; color: var(--ink); }
.vuoto .titolo { font-weight: 700; margin: .4rem 0 .2rem; }
.vuoto .sotto { color: var(--grigio); font-size: .88rem; }

/* ---------- 6. BOLLA CHAT (contenitore stile PDor; personalità: la portinaia) ---------- */
.debw-bubble {
    position: fixed; right: 24px; bottom: 24px; width: 160px; height: 160px;
    border-radius: 50%; background: var(--grafite); border: 4px solid var(--accento);
    cursor: pointer; z-index: 1200; overflow: hidden; padding: 0;
    box-shadow: 0 10px 28px rgba(0,0,0,.28); transition: transform .15s;
}
.debw-bubble:hover { transform: scale(1.04); }
.debw-bubble img { width: 100%; height: 100%; object-fit: cover; display: block; }
.debw-panel {
    position: fixed; right: 24px; bottom: 196px; width: 340px; height: 460px;
    max-width: calc(100vw - 44px); max-height: 70vh;
    background: var(--bianco); border: 1px solid var(--bordo); border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0,0,0,.22); display: none; flex-direction: column;
    z-index: 1200; overflow: hidden;
}
.debw-panel.on { display: flex; }
.debw-head {
    display: flex; align-items: center; gap: .5rem; padding: .55rem .8rem;
    background: var(--grafite); color: #fff; border-bottom: 3px solid var(--accento);
}
.debw-head img.avatar { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--accento); object-fit: cover; }
.debw-head .nm { font-weight: 700; font-size: 14px; }
.debw-head .sp { margin-left: auto; display: flex; gap: .6rem; }
.debw-head button { background: none; border: 0; cursor: pointer; color: #d5d5d2; font-size: .8rem; }
.debw-body { padding: .6rem .7rem; overflow-y: auto; flex: 1; background: var(--bianco); }
.debw-msg { padding: .55rem .75rem; border-radius: 11px; margin: .4rem 0; line-height: 1.55;
    font-size: 13px; border: 1px solid var(--bordo); }
.debw-msg.u { background: var(--accento); color: var(--ink); border-color: var(--accento-scuro); margin-left: 1.4rem; }
.debw-msg.d { background: var(--mist); margin-right: 1.4rem; }
.debw-msg .who { font-size: .64rem; color: var(--grigio); text-transform: uppercase;
    margin-bottom: .2rem; letter-spacing: .04em; }
.debw-msg.u .who { color: rgba(1,1,1,.55); }
.debw-foot { display: flex; gap: .4rem; padding: .55rem .6rem; border-top: 1px solid var(--bordo); }
.debw-foot textarea { flex: 1; min-height: 40px; max-height: 130px; resize: none; font-size: 13px; }
.debw-spin { width: 14px; height: 14px; border: 3px solid var(--bordo); border-top-color: var(--accento-scuro);
    border-radius: 50%; display: inline-block; vertical-align: middle; animation: debgiro .8s linear infinite; }
@keyframes debgiro { to { transform: rotate(360deg); } }
@media (max-width: 640px) { .debw-bubble { width: 96px; height: 96px; } .debw-panel { bottom: 132px; } }
@media print { .debw-bubble, .debw-panel { display: none !important; } }

/* ---------- 7. LOGIN ---------- */
body.login-page {
    min-height: 100vh; display: flex; flex-direction: column; align-items: center;
    justify-content: center; padding: 1.5rem; background: var(--mist);
    background-image: repeating-linear-gradient(-45deg, transparent, transparent 28px,
        rgba(24,24,24,.025) 28px, rgba(24,24,24,.025) 32px);
}
.login-card {
    width: 340px; max-width: 92vw; padding: 2.2rem 2rem; text-align: center;
    background: var(--bianco); border: 1px solid var(--bordo); border-radius: 12px;
}
.login-card .icona { width: 84px; height: 84px; border-radius: 20px; object-fit: contain; margin: 0 auto .6rem; display: block; }
.login-card .nome { font-size: 26px; font-weight: 800; }
.login-card .lineetta { width: 46px; height: 4px; border-radius: 2px; background: var(--accento); margin: 8px auto 10px; }
.login-card .sotto { color: var(--grigio); font-size: 13px; margin: 0 0 1.2rem; }
.login-card input { width: 100%; margin: .35rem 0; text-align: left; }
.login-card .btn { width: 100%; margin-top: .8rem; padding: 13px; border-radius: 8px; }
.login-card .err { background: var(--no-bg); border: 1px solid var(--no-bordo); color: var(--no-testo);
    padding: .6rem .8rem; border-radius: 10px; font-size: .9rem; margin-bottom: .5rem; text-align: left; }

/* ---------- 6-bis. PERSONALIZZA MENU (standard §4) ---------- */
.sb-strumenti { border-top: 1px solid #313131; margin-top: 8px; padding-top: 6px; }
.sb-strumenti a {
    display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px;
    border-radius: 8px; font-size: 12.5px; color: #8a8a86;
}
.sb-strumenti a:hover { background: #262626; color: #fff; text-decoration: none; }
.sb-strumenti a .ic { width: 20px; flex: 0 0 20px; text-align: center; }
.sb-pers-pan { padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.sb-pers-pan button {
    background: #262626; color: #d5d5d2; border: 1px solid #3a3a3a; border-radius: 8px;
    padding: 6px 10px; font-size: 12.5px; cursor: pointer; text-align: left;
}
.sb-pers-pan button:hover { color: #fff; }
.sb-pers-pan label { color: #8a8a86; font-size: 11px; }
.sb-pers-pan select { width: 100%; margin-top: 3px; background: #262626; color: #d5d5d2;
    border-color: #3a3a3a; font-size: 12.5px; }
.sb-nav.modifica a[data-id] { cursor: grab; }
.sb-nav a .pers-strum { margin-left: auto; display: inline-flex; gap: 2px; }
.sb-nav a .pers-strum button { background: none; border: 0; cursor: pointer; font-size: 12px; padding: 0 2px; }
.sb-nav a.nascosta { opacity: .38; }
.sb-nav a.in-volo { opacity: .5; outline: 1px dashed var(--accento); }
.sb-nav summary.bersaglio { background: #2e3a00; outline: 1px dashed var(--accento); }
.sb-pref-clone { font-weight: 600; }

/* ---------- 6-ter. CONFERME PERICOLOSE (codice a 4 cifre, standard §7) ---------- */
.codice-velo { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1300;
    display: flex; align-items: center; justify-content: center; padding: 1rem; }
.codice-card { background: var(--bianco); border-radius: 14px; padding: 1.4rem;
    width: 360px; max-width: 94vw; text-align: center; }
.codice-card .conseguenze { margin: 0 0 .9rem; font-size: .95rem; }
.codice-box { background: var(--grafite); color: var(--accento); border-radius: 10px;
    font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
    font-size: 44px; font-weight: 700; letter-spacing: .1em; padding: .5rem 0; user-select: none; }
.codice-box.rosso { color: #F09595; }
.codice-card input { width: 160px; text-align: center; font-size: 20px; margin: .9rem 0 .2rem;
    letter-spacing: .3em; }
.codice-azioni { display: flex; gap: .6rem; justify-content: center; margin-top: .8rem; }

/* ---------- 6-quater. PATTERN TRASCINA-E-SPOSTA (06-STILE-COMUNE §10) ----------
   Classi condivise alla lettera con l'Hub: .trascinato, .bersaglio,
   .non-valido, .org-avviso. */
.trascinato { opacity: .4; }
.bersaglio {
    border-color: var(--accento) !important;
    box-shadow: 0 0 0 3px rgba(199, 239, 2, .35);
    background: #FCFFF2 !important;
}
.non-valido { border-color: var(--no-bordo) !important; box-shadow: 0 0 0 2px var(--no-bg); }
[draggable="true"] { cursor: grab; }
[draggable="true"]:active { cursor: grabbing; }
.org-avviso {
    position: fixed; right: 24px; bottom: 24px; z-index: 1400;
    background: var(--grafite); color: #fff; border-radius: 10px;
    padding: .7rem .9rem; max-width: 340px; font-size: .88rem;
    box-shadow: 0 10px 28px rgba(0,0,0,.28); display: none;
    align-items: center; gap: .7rem;
}
.org-avviso.mostra { display: flex; }
.org-avviso button {
    background: var(--accento); color: var(--ink); border: 0; border-radius: 8px;
    padding: 4px 10px; font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap;
}

/* ---------- 7-bis. MODALITÀ APP (cookie modalita_app da /avvio) ---------- */
.app-mode .sidebar { display: none; }
.app-mode .top {
    background: var(--grafite); color: #fff; border-bottom: 3px solid var(--accento);
    position: sticky; top: 0; z-index: 30;
}
.app-mode .top h1 { color: #fff; }
.app-mode .top .date { color: #8a8a86; }
.app-mode .content { padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
.app-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1100;
    display: flex; background: var(--grafite);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    border-top: 1px solid #313131;
}
.app-bar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 8px 0 6px; color: #d5d5d2; font-size: 11px; text-decoration: none;
}
.app-bar a .ic { font-size: 19px; line-height: 1; }
.app-bar a.on { color: var(--accento); font-weight: 600; }
.app-altro { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1150; display: none; }
.app-altro.on { display: flex; align-items: flex-end; }
.app-altro-card {
    background: var(--bianco); width: 100%; border-radius: 14px 14px 0 0;
    padding: 12px 14px calc(70px + env(safe-area-inset-bottom, 0px));
    display: flex; flex-direction: column; gap: 2px;
}
.app-altro-card a {
    display: block; padding: 13px 10px; border-radius: 12px; color: var(--ink);
    font-size: 15px; border-bottom: 1px solid var(--line2);
}
.app-altro-card a:hover { background: var(--mist); text-decoration: none; }
.app-mode .debw-bubble { width: 96px; height: 96px; bottom: calc(78px + env(safe-area-inset-bottom, 0px)); }
.app-mode .debw-panel { bottom: calc(186px + env(safe-area-inset-bottom, 0px)); }

/* ---------- 8. MOBILE (provvisorio: la vera app arriva in Fase B) ---------- */
@media (max-width: 780px) {
    .layout { flex-direction: column; }
    .sidebar { width: 100%; flex: 0 0 auto; height: auto; position: static; padding: 8px; }
    .sb-brand img { display: none; }
    .sb-brand { display: flex; align-items: center; gap: 8px; padding: 2px 6px 8px; }
    .sb-brand .lineetta { margin: 0; }
    .sb-nav { flex-direction: row; overflow-x: auto; }
    .sb-nav a { flex: 0 0 auto; }
    .sb-utente, .sb-online, .sb-etichetta { display: none; }
    .top, .content { padding-left: 1rem; padding-right: 1rem; }
}
@media (max-height: 760px) { .sb-brand img { width: 68px; } }
@media (max-height: 600px) { .sb-brand img { display: none; } }
