:root {
        --ink: #0f172a;
        --ink-soft: #64748b;
        --paper: #f8fafc;
        --paper-deep: #f1f5f9;
        --surface: #ffffff;
        --line: #e2e8f0;
        --green: #059669;
        --green-deep: #065f46;
        --green-soft: #ecfdf5;
        --gold: #f59e0b;
        --gold-soft: #fef3c7;
        --brick: #dc2626;
        --brick-soft: #fee2e2;
        --ok: #059669;
        --warn: #d97706;
        --r-lg: 12px;
        --r-md: 8px;
        --r-sm: 6px;
        --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.03);
        --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
        --font-display: 'Inter', system-ui, -apple-system, sans-serif;
        --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
        --primary: var(--green);
    }
    * { box-sizing: border-box; font-family: var(--font-body); }
    * { -webkit-tap-highlight-color: transparent; }
    :focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
    body { margin: 0; background-color: var(--paper); color: var(--ink); overflow-x: hidden; }

    /* Topbar & Header */
    .app-title-bar {
        width: 100%; text-align: center; padding: 0.9rem 1.2rem;
        background: var(--green-deep); position: relative;
        display: flex; align-items: center; justify-content: center;
        min-height: 60px;
    }
    .app-brand-left {
        position: absolute; left: 1.2rem; top: 50%; transform: translateY(-50%);
        display: flex; align-items: center; gap: 0.65rem;
        cursor: pointer; user-select: none;
    }
    .app-brand-left .app-logo {
        width: 42px; height: 42px; object-fit: contain;
        border-radius: 50%; background: #ffffff; padding: 2px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.25);
        flex-shrink: 0;
    }
    .app-brand-left .app-name {
        font-family: var(--font-display);
        font-weight: 800; font-size: 1.65rem; letter-spacing: .06em;
        color: var(--gold-soft); line-height: 1;
    }
    .app-title-bar h1 {
        color: var(--gold-soft); margin: 0; font-family: var(--font-display);
        font-weight: 700; font-size: 1.85rem; letter-spacing: .08em;
    }
    .cloud-status {
        position: absolute; right: 1rem; top: 50%; transform: translateY(-50%);
        font-size: 0.8rem; font-weight: 600; padding: 0.35rem 0.75rem; border-radius: 999px;
        display: flex; align-items: center; gap: 0.4rem; background: rgba(0,0,0,0.25);
        color: #fff; transition: background .3s ease;
    }
    .cloud-status.synced { color: #86efac; border: 1px solid rgba(134,239,172,0.3); }
    .cloud-status.saving { color: #fde047; border: 1px solid rgba(253,224,71,0.3); }
    .cloud-status.offline { color: #fca5a5; border: 1px solid rgba(252,165,165,0.3); }

    #dashboard {
        display: flex; flex-direction: column; align-items: center;
        min-height: 100vh; padding: 0 0 2.5rem;
    }
    #dashboard > .buttons-grid, #dashboard > #bk-warn, #dashboard > .dtabs {
        padding-left: 1.5rem; padding-right: 1.5rem;
    }

    .buttons-grid {
        display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
        gap: 1.3rem; width: 100%; max-width: 1060px; margin: 1.8rem auto 0;
    }

    .tool-btn {
        background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
        padding: 1.8rem 1.2rem; font-size: 1.05rem; font-weight: 700; letter-spacing: .02em; color: var(--ink);
        cursor: grab; transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
        box-shadow: var(--shadow-sm);
        display: flex; flex-direction: column; align-items: center; gap: 0.9rem;
        user-select: none; touch-action: manipulation;
    }
    .tool-btn:hover { transform: translateY(-3px); border-color: var(--green); box-shadow: var(--shadow); }
    .tool-btn:active { cursor: grabbing; }
    .tool-btn .icon {
        font-size: 2.1rem; width: 3.6rem; height: 3.6rem; border-radius: 50%;
        background: var(--green-soft); display: flex; align-items: center; justify-content: center;
    }
    .tool-btn[hidden] { display: none !important; }
    .tool-btn.dragging { opacity: .35; cursor: grabbing; }

    /* Digital Pay Modal */
    .digital-pay-modal-overlay {
        display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.7);
        backdrop-filter: blur(4px); z-index: 999; align-items: center; justify-content: center; padding: 1rem;
    }
    .digital-pay-modal-overlay.active { display: flex !important; }
    .digital-pay-modal-card {
        background: var(--paper); color: var(--ink); border: 1px solid var(--border);
        border-radius: var(--r); box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
        width: 100%; max-width: 480px; max-height: 92vh; overflow-y: auto; padding: 1.4rem;
    }

    /* App Views / Iframes */
    .app-view {
        display: none; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
        background: #fff; z-index: 100; flex-direction: column;
    }
    .app-view.active { display: flex; }
    .app-header {
        background: var(--green-deep); color: var(--gold-soft); padding: 0.75rem 1rem;
        display: flex; align-items: center; z-index: 101;
    }
    .back-btn {
        background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,.18);
        color: var(--gold-soft); padding: 0.5rem 1rem; border-radius: var(--r-sm);
        font-size: 0.95rem; font-weight: 700; cursor: pointer; display: flex; align-items: center; gap: 0.5rem;
    }
    .app-title { margin: 0 auto; font-weight: 700; font-size: 1.15rem; transform: translateX(-40px); color: #fff; }
    iframe { flex: 1; width: 100%; height: 100%; border: none; background: #fff; }

    /* Screens & Cards */
    .screen { display: none; min-height: 100vh; padding: 1.5rem; background: var(--paper); }
    .screen.on { display: block; }
    #scr-auth.screen {
        background: radial-gradient(circle at 50% -10%, #3a5a3f 0%, var(--green-deep) 55%, #1a2e18 100%);
        padding-top: 3.5rem;
    }
    #scr-auth .card { margin-top: 1rem; }
    .card {
        max-width: 660px; margin: 1.5rem auto; background: var(--surface);
        border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.8rem;
        box-shadow: var(--shadow-sm);
    }
    .card.wide { max-width: 980px; }
    .card h2 {
        margin: 0 0 1.1rem; font-size: 1.55rem; font-family: var(--font-display);
        font-weight: 700; color: var(--green-deep);
    }
    .card h3 {
        margin: 1.6rem 0 .7rem; font-size: 1.05rem; color: var(--green-deep);
        padding-bottom: .4rem; border-bottom: 2px solid var(--line);
    }
    .card input, .card select {
        width: 100%; padding: .65rem .8rem; margin: .25rem 0 .75rem;
        border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 1rem;
        background: #fff; color: var(--ink);
    }
    .card textarea {
        width: 100%; padding: .65rem .8rem; margin: .25rem 0 .75rem;
        border: 1px solid var(--line); border-radius: var(--r-sm); font: inherit;
        min-height: 4.2rem; background: #fff; color: var(--ink); resize: vertical;
    }
    .card input:focus, .card select:focus, .card textarea:focus {
        outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft);
    }
    .card label { display: block; font-size: .85rem; color: var(--ink-soft); font-weight: 600; }
    .card .chk label {
        display: inline-flex; gap: .4rem; align-items: center; margin-right: 1.2rem;
        font-weight: 500; color: var(--ink); cursor: pointer;
    }
    .card .chk input { width: auto; margin: 0; }
    .card button, .ubar button {
        background: var(--green); color: #fff; border: 0; border-radius: var(--r-sm);
        padding: .65rem 1.15rem; font-weight: 700; cursor: pointer; font-size: .95rem;
        transition: background .15s ease, opacity .15s ease;
    }
    .card button:hover, .ubar button:hover { background: var(--green-deep); }
    .card button:disabled { opacity: 0.5; cursor: not-allowed; }
    .card button.ghost, .ubar button.ghost { background: var(--paper-deep); color: var(--ink); }
    .card button.ghost:hover, .ubar button.ghost:hover { background: var(--line); }

    /* Tabs & Filters */
    .ptabs, .dtabs { display: flex; gap: .5rem; margin-bottom: 1.3rem; flex-wrap: wrap; }
    .dtabs { justify-content: center; margin-top: 2.2rem; margin-bottom: 1.6rem; }
    .ptabs button, .dtabs button {
        border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft);
        border-radius: 999px; padding: .6rem 1.2rem; font-weight: 700; font-size: .95rem; cursor: pointer;
        transition: all .15s ease;
    }
    .ptabs button.on, .dtabs button.on { background: var(--green); border-color: var(--green); color: #fff; }

    /* Notifications & Tables */
    .msg { margin: .6rem 0; font-weight: 600; color: var(--brick); font-size: .95rem; }
    .msg.ok { color: var(--ok); }
    .row { padding: .75rem 0; border-top: 1px solid var(--line); }
    .row small { color: var(--ink-soft); }
    .row select { width: auto; min-width: 200px; margin: .4rem .4rem 0 0; }
    .row button { margin-top: .4rem; }
    .chip {
        display: inline-block; background: var(--gold-soft); color: var(--green-deep);
        border-radius: 999px; padding: .2rem .7rem; margin: .2rem .3rem .2rem 0;
        font-size: .9rem; font-weight: 600;
    }
    .chip a { cursor: pointer; margin-left: .35rem; }

    /* Top User Bar */
    .ubar {
        display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem;
        width: 100%; background: var(--green); color: #fff; padding: .75rem 1.5rem;
        font-weight: 600; border-top: 1px solid rgba(255,255,255,.15);
    }
    .ubar-left { display: flex; flex-direction: column; justify-self: start; line-height: 1.3; }
    .ubar-left span:first-child { font-size: 1.05rem; font-weight: 700; }
    .ubar-left #ub-role { font-size: .85rem; color: var(--gold-soft); font-weight: 500; }
    .ubar-center { justify-self: center; font-size: 1.15rem; font-weight: 700; text-align: center; font-family: var(--font-display); }
    .ubar-right { display: flex; align-items: center; gap: 1rem; justify-self: end; }

    .gcols, .pcols { display: grid; gap: 1.5rem; }
    .gcols { grid-template-columns: 280px minmax(0, 1fr); }
    .gcols > *, .pcols > * { min-width: 0; max-width: 100%; }
    .pcols { grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); }
    .two-col-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; align-items: start; }
    @media (max-width: 680px) {
        .two-col-grid { grid-template-columns: 1fr; gap: 1rem; }
    }
    @media (max-width: 768px) {
        .app-title-bar {
            flex-direction: column;
            gap: 0.5rem;
            padding: 0.8rem 1rem;
        }
        .app-brand-left {
            position: static;
            transform: none;
        }
        .cloud-status {
            position: static;
            transform: none;
        }
        .gcols, .pcols { grid-template-columns: 1fr; }
        .ubar { grid-template-columns: 1fr; text-align: center; }
        .ubar-left, .ubar-center, .ubar-right { justify-self: center; align-items: center; }
        .app-title { transform: none; font-size: 1rem; }
    }

    .pick { cursor: pointer; padding: .5rem; border-radius: var(--r-sm); transition: background .15s; }
    .pick:hover { background: var(--paper); }
    .pick.sel { background: var(--green-soft); }
    .kv { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem 0; border-top: 1px solid var(--line); }
    .kv span { color: var(--ink-soft); }
    .kv b { text-align: right; }
    .rel { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .6rem; }
    .rel button { grid-column: 1/-1; justify-self: start; }

    #badge {
        display: none; flex-direction: column; justify-content: center; gap: .15rem;
        background: transparent; color: #fff; border: 0; padding: 0; font-size: .85rem;
        font-weight: 600; line-height: 1.3;
    }
    #badge span { white-space: nowrap; color: var(--gold-soft); }
    #badge b { font-size: 1.05rem; margin-left: .4rem; color: var(--gold-soft); }

    .badge-credito { display: inline-block; padding: 2px 8px; border-radius: 6px; font-weight: 700; background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
    .badge-debito { display: inline-block; padding: 2px 8px; border-radius: 6px; font-weight: 700; background: #ffebee; color: #c62828; border: 1px solid #ffcdd2; }
    .badge-pareggio { display: inline-block; padding: 2px 8px; border-radius: 6px; font-weight: 600; background: #f5f5f5; color: #616161; }
    .comp-card { background: var(--panel2); border: 1px solid var(--border); border-radius: 12px; padding: 1rem; margin-bottom: 1rem; }
    .comp-step { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; }
    .comp-step-arrow { font-size: 1.2rem; font-weight: 900; color: var(--gold); }
    .sede-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; font-size: 0.8rem; font-weight: 600; background: var(--green-soft); color: var(--green-deep); }

    #backtop {
        display: none; position: fixed; top: 8px; left: 10px; z-index: 300;
        background: var(--green-deep); color: var(--gold-soft); border: 1px solid rgba(255,255,255,.2);
        border-radius: var(--r-sm); padding: .5rem 1rem; font-size: .95rem; font-weight: 700; cursor: pointer;
        box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    }
    body.hasback { padding-top: 50px; }

    .tscroll { overflow-x: auto; margin: .4rem 0 1.2rem; }
    .tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
    .tbl th, .tbl td { padding: .55rem .7rem; text-align: left; vertical-align: top; border-top: 1px solid var(--line); }
    .tbl th { border-top: 0; border-bottom: 2px solid var(--gold); color: var(--green-deep); font-size: .84rem; font-weight: 700; white-space: nowrap; }
    .tbl .n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
    .tbl tfoot td { border-top: 2px solid var(--paper-deep); font-weight: 700; }
    .tbl tr.trpick { cursor: pointer; }
    .tbl tr.trpick:hover td { background: var(--paper); }
    .tbl tr.sel td { background: var(--green-soft); }
    .tbl tr.trpick:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
    .tbl button { padding: .35rem .7rem; font-size: .85rem; }
    .up { color: var(--ok); font-weight: 700; }
    .dn { color: var(--brick); font-weight: 700; }
    .sub { margin: .25rem 0 1rem; color: var(--ink-soft); }
    .formcol { max-width: 540px; }

    /* Toast Notification */
    .toast-popup {
        position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
        background: var(--green-deep); color: #fff; padding: 0.85rem 1.6rem; border-radius: var(--r-md);
        font-size: 0.95rem; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,0.3);
        border: 1px solid var(--gold); z-index: 500; opacity: 0; pointer-events: none;
        transition: opacity .25s ease, transform .25s ease;
    }
    /* Delegati e Uscite Anticipate */
    .delegato-card {
        background: var(--panel2);
        border: 1px solid var(--border);
        border-radius: var(--r-md);
        padding: 12px;
        margin-bottom: 10px;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    .badge-delegato-ok {
        background: rgba(16, 185, 129, 0.15);
        color: #10b981;
        font-weight: 700;
        border: 1px solid rgba(16, 185, 129, 0.3);
    }
    .badge-delegato-genitore {
        background: rgba(59, 130, 246, 0.15);
        color: #3b82f6;
        font-weight: 700;
        border: 1px solid rgba(59, 130, 246, 0.3);
    }
    .badge-delegato-warn {
        background: rgba(245, 158, 11, 0.15);
        color: #f59e0b;
        font-weight: 700;
        border: 1px solid rgba(245, 158, 11, 0.3);
    }
    .usc-quick-btn {
        padding: 6px 12px;
        font-size: 0.82rem;
        border-radius: 6px;
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        gap: 6px;
    }

    @media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

    /* Modal Generic Overlay & PWA Components */
    .modal-overlay {
        display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.75);
        backdrop-filter: blur(4px); z-index: 1000; align-items: center; justify-content: center; padding: 1rem;
    }
    .modal-overlay.active { display: flex !important; }
    .modal-overlay .modal {
        background: var(--paper); color: var(--ink); border: 1px solid var(--border);
        border-radius: var(--r); box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
        width: 100%; max-height: 92vh; overflow-y: auto; padding: 1.4rem;
    }
    .pwa-install-badge {
        background: linear-gradient(135deg, #10b981, #059669); color: #fff; border: none;
        padding: 5px 12px; border-radius: 999px; font-size: 0.8rem; font-weight: 700;
        cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
        box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35); transition: transform 0.15s, box-shadow 0.15s;
    }
    .pwa-install-badge:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(16, 185, 129, 0.45); }
    .dash-pwa-banner {
        background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(59, 130, 246, 0.12));
        border: 1px solid rgba(16, 185, 129, 0.3); border-radius: 12px; padding: 12px 18px;
        margin-bottom: 1rem; display: flex; justify-content: space-between; align-items: center;
        flex-wrap: wrap; gap: 10px;
    }

    /* =========================================================
       PROFILO UTENTE - DESIGN ESATTO DA MOCKUP PDF / IMMAGINI
       ========================================================= */
    #scr-profilo {
        display: none !important;
    }
    #scr-profilo.on {
        display: flex !important;
        background: #eae4d5 !important;
        min-height: 100vh !important;
        padding: 2rem 1.2rem !important;
        box-sizing: border-box !important;
        justify-content: center !important;
        align-items: flex-start !important;
    }
    .prof-mockup-card {
        background: #fffdfa !important;
        border: none !important;
        border-radius: 26px !important;
        max-width: 780px !important;
        margin: 0 auto !important;
        padding: 28px 34px 34px 34px !important;
        box-shadow: 0 10px 36px rgba(45, 35, 20, 0.07) !important;
        box-sizing: border-box !important;
        width: 100% !important;
        font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
    }
    .prof-mockup-header {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        margin-bottom: 20px !important;
        width: 100% !important;
    }
    .prof-avatar-icon {
        width: 52px !important;
        height: 52px !important;
        border-radius: 50% !important;
        background: #284835 !important;
        color: #ffffff !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        flex-shrink: 0 !important;
    }
    .prof-header-title {
        font-size: 1.35rem !important;
        font-weight: 700 !important;
        color: #111813 !important;
        line-height: 1.2 !important;
        margin: 0 !important;
        letter-spacing: -0.01em !important;
    }
    .prof-header-sub {
        font-size: 0.9rem !important;
        color: #5a655c !important;
        margin-top: 3px !important;
        font-weight: 400 !important;
    }
    .prof-home-btn {
        background: #d1cdc4 !important;
        color: #1f2621 !important;
        font-size: 0.9rem !important;
        font-weight: 600 !important;
        padding: 7px 22px !important;
        border-radius: 12px !important;
        border: none !important;
        cursor: pointer !important;
        transition: background 0.15s ease !important;
    }
    .prof-home-btn:hover {
        background: #c3beaf !important;
    }
    .prof-pill-tabs {
        display: flex !important;
        gap: 12px !important;
        padding-bottom: 16px !important;
        margin-bottom: 20px !important;
        border-bottom: 1.5px solid #ded7c9 !important;
        align-items: center !important;
        flex-wrap: wrap !important;
        width: 100% !important;
    }
    .prof-pill-tabs button {
        border: 1.5px solid #284835 !important;
        background: transparent !important;
        color: #284835 !important;
        border-radius: 9999px !important;
        padding: 6px 22px !important;
        font-size: 0.92rem !important;
        font-weight: 500 !important;
        cursor: pointer !important;
        transition: all 0.15s ease !important;
    }
    .prof-pill-tabs button.on {
        background: #284835 !important;
        color: #ffffff !important;
        border-color: #284835 !important;
    }
    .prof-tab-pill-sub {
        background: transparent !important;
        border: 1.5px solid #284835 !important;
        color: #284835 !important;
        border-radius: 9999px !important;
        padding: 4px 14px !important;
        font-size: 0.8rem !important;
        font-weight: 600 !important;
        cursor: pointer !important;
        transition: all 0.15s ease !important;
    }
    .prof-tab-pill-sub.active {
        background: #284835 !important;
        color: #ffffff !important;
    }
    .prof-beige-box {
        background: #eae5d8 !important;
        border-radius: 16px !important;
        padding: 20px 24px !important;
        margin-bottom: 14px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        border: none !important;
    }
    .prof-beige-box:last-child {
        margin-bottom: 0 !important;
    }
    .prof-two-cols {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0 !important;
        width: 100% !important;
    }
    @media (max-width: 680px) {
        .prof-two-cols {
            grid-template-columns: 1fr !important;
        }
    }
    .prof-col-left {
        padding-right: 24px !important;
    }
    .prof-col-right {
        padding-left: 24px !important;
        border-left: 1px solid #ded6c7 !important;
    }
    @media (max-width: 680px) {
        .prof-col-left { padding-right: 0 !important; padding-bottom: 14px !important; }
        .prof-col-right { padding-left: 0 !important; border-left: none !important; border-top: 1px solid #ded6c7 !important; padding-top: 14px !important; }
    }
    .prof-box-title {
        font-size: 1.12rem !important;
        font-weight: 700 !important;
        color: #1e2821 !important;
        margin: 0 0 14px 0 !important;
        padding: 0 !important;
        border: none !important;
    }
    .prof-field-line {
        display: flex !important;
        align-items: baseline !important;
        font-size: 0.95rem !important;
        color: #2f3832 !important;
        margin-bottom: 8px !important;
        line-height: 1.35 !important;
    }
    .prof-field-line:last-child {
        margin-bottom: 0 !important;
    }
    .prof-field-label {
        color: #2f3832 !important;
        font-weight: 400 !important;
        flex-shrink: 0 !important;
        font-size: 0.95rem !important;
        margin-right: 8px !important;
        white-space: nowrap !important;
    }
    .prof-field-val {
        color: #141a16 !important;
        font-weight: 600 !important;
        font-size: 0.95rem !important;
        word-break: break-word !important;
        padding: 1px 2px !important;
    }
    .prof-field-input {
        flex: 1 !important;
        min-width: 0 !important;
        background: transparent !important;
        border: none !important;
        border-bottom: 1px solid transparent !important;
        color: #141a16 !important;
        font-weight: 600 !important;
        font-size: 0.95rem !important;
        padding: 1px 4px !important;
        outline: none !important;
        font-family: inherit !important;
        border-radius: 4px !important;
        transition: background 0.15s ease, border-bottom 0.15s ease !important;
    }
    .prof-field-input:focus {
        background: rgba(255, 255, 255, 0.65) !important;
        border-bottom: 1.5px solid #284835 !important;
    }
    .prof-field-select {
        cursor: pointer !important;
        appearance: none !important;
        -webkit-appearance: none !important;
        background: transparent url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23284835' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E") no-repeat right 6px center !important;
        padding-right: 22px !important;
        width: auto !important;
        max-width: 100% !important;
        flex: initial !important;
    }
    input[type="date"].prof-field-input {
        font-family: inherit !important;
        font-size: 0.93rem !important;
        font-weight: 600 !important;
        color: #141a16 !important;
        padding: 1px 2px !important;
        cursor: pointer !important;
        display: inline-flex !important;
        align-items: center !important;
        max-width: 170px !important;
    }
    input[type="date"].prof-field-input::-webkit-calendar-picker-indicator {
        cursor: pointer !important;
        opacity: 0.65 !important;
        padding: 0 !important;
        margin-left: 6px !important;
        filter: invert(20%) sepia(20%) saturate(1200%) hue-rotate(95deg) brightness(80%);
    }
    input[type="date"].prof-field-input::-webkit-calendar-picker-indicator:hover {
        opacity: 1 !important;
    }
    .prof-btn-green, .prof-btn-aggiungi {
        background: #284835 !important;
        color: #ffffff !important;
        border: none !important;
        border-radius: 9999px !important;
        padding: 6px 26px !important;
        font-size: 0.9rem !important;
        font-weight: 600 !important;
        cursor: pointer !important;
        transition: opacity 0.15s ease !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    .prof-btn-green:hover, .prof-btn-aggiungi:hover {
        opacity: 0.9 !important;
    }
    .prof-filter-select {
        background: #fffdfa !important;
        border: 1px solid #c9c2b4 !important;
        border-radius: 9999px !important;
        padding: 5px 28px 5px 12px !important;
        font-size: 0.82rem !important;
        font-weight: 600 !important;
        color: #284835 !important;
        height: 32px !important;
        cursor: pointer !important;
        outline: none !important;
        appearance: none !important;
        -webkit-appearance: none !important;
        background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%23284835' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E") !important;
        background-repeat: no-repeat !important;
        background-position: right 10px center !important;
    }
    .prof-filter-pill {
        background: transparent !important;
        border: 1px solid #c9c2b4 !important;
        border-radius: 9999px !important;
        padding: 0 14px !important;
        height: 32px !important;
        font-size: 0.8rem !important;
        font-weight: 600 !important;
        color: #284835 !important;
        cursor: pointer !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        transition: all 0.15s ease !important;
    }
    .prof-filter-pill:hover {
        border-color: #284835 !important;
    }
    .prof-filter-pill.active {
        background: #284835 !important;
        border-color: #284835 !important;
        color: #ffffff !important;
    }
    .prof-table-30gg {
        width: 100% !important;
        border-collapse: collapse !important;
        font-size: 0.88rem !important;
        margin-top: 8px !important;
    }
    .prof-table-30gg th {
        text-align: left !important;
        padding: 8px 10px !important;
        font-weight: 700 !important;
        color: #111813 !important;
        border-top: 1.5px solid #111813 !important;
        border-bottom: 1.5px solid #111813 !important;
    }
    .prof-table-30gg td {
        padding: 8px 10px !important;
        color: #222222 !important;
        border-bottom: 1px solid #ded6c7 !important;
        vertical-align: middle !important;
    }

    /* =====================================================================
       MOCKUP CARICA CREDITO
       ===================================================================== */
    .carica-mockup-card {
        background: #fffdfa !important;
        border: none !important;
        border-radius: 26px !important;
        max-width: 780px !important;
        margin: 0 auto !important;
        padding: 28px 34px 34px 34px !important;
        box-shadow: 0 10px 36px rgba(45, 35, 20, 0.07) !important;
        box-sizing: border-box !important;
        width: 100% !important;
        font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
    }
    .carica-mockup-header {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding-bottom: 14px !important;
        margin-bottom: 18px !important;
        border-bottom: 1.5px solid #ded6c7 !important;
        width: 100% !important;
    }
    .carica-header-title {
        font-size: 1.65rem !important;
        font-weight: 700 !important;
        color: #284835 !important;
        margin: 0 !important;
        letter-spacing: -0.01em !important;
    }
    .carica-home-btn {
        background: #cecac0 !important;
        color: #222222 !important;
        font-size: 0.88rem !important;
        font-weight: 600 !important;
        padding: 7px 22px !important;
        border-radius: 9999px !important;
        border: none !important;
        cursor: pointer !important;
        transition: background 0.15s ease !important;
    }
    .carica-home-btn:hover {
        background: #bfbaa9 !important;
    }
    .carica-top-grid {
        display: grid !important;
        grid-template-columns: 1.15fr 1fr !important;
        gap: 20px !important;
        align-items: stretch !important;
        margin-bottom: 16px !important;
        width: 100% !important;
    }
    @media (max-width: 680px) {
        .carica-top-grid {
            grid-template-columns: 1fr !important;
            gap: 12px !important;
        }
    }
    .carica-label {
        font-size: 0.88rem !important;
        color: #3f4742 !important;
        margin-bottom: 6px !important;
        font-weight: 500 !important;
        display: block !important;
    }
    .carica-select-field, .carica-input-field {
        width: 100% !important;
        background: #ffffff !important;
        border: 1px solid #b5afa4 !important;
        border-radius: 8px !important;
        padding: 10px 14px !important;
        font-size: 0.95rem !important;
        font-family: inherit !important;
        color: #111813 !important;
        box-sizing: border-box !important;
        outline: none !important;
        transition: border-color 0.15s ease, box-shadow 0.15s ease !important;
    }
    .carica-select-field {
        cursor: pointer !important;
        appearance: none !important;
        -webkit-appearance: none !important;
        background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%23284835' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E") !important;
        background-repeat: no-repeat !important;
        background-position: right 14px center !important;
        padding-right: 36px !important;
    }
    .carica-select-field:focus, .carica-input-field:focus {
        border-color: #284835 !important;
        box-shadow: 0 0 0 2px rgba(40, 72, 53, 0.12) !important;
    }
    .carica-bal-box {
        background: #eee8dc !important;
        border-radius: 12px !important;
        padding: 12px 18px !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        gap: 4px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    .carica-bal-title {
        font-size: 0.94rem !important;
        font-weight: 700 !important;
        color: #111813 !important;
        margin-bottom: 2px !important;
    }
    .carica-bal-row {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        font-size: 0.9rem !important;
        color: #222222 !important;
    }
    .carica-bal-row span {
        color: #333333 !important;
    }
    .carica-bal-row b {
        font-weight: 700 !important;
        color: #111813 !important;
    }
    .carica-load-box {
        background: #eee8dc !important;
        border-radius: 16px !important;
        padding: 20px 24px 22px 24px !important;
        margin: 16px 0 24px 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    .carica-load-title {
        font-size: 1.18rem !important;
        font-weight: 700 !important;
        color: #111813 !important;
        margin-bottom: 14px !important;
    }
    .carica-form-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 16px 24px !important;
        width: 100% !important;
    }
    @media (max-width: 680px) {
        .carica-form-grid {
            grid-template-columns: 1fr !important;
            gap: 14px !important;
        }
    }
    .carica-btn-submit {
        background: #284835 !important;
        color: #ffffff !important;
        border: none !important;
        border-radius: 9999px !important;
        padding: 11px 48px !important;
        font-size: 0.98rem !important;
        font-weight: 700 !important;
        cursor: pointer !important;
        transition: opacity 0.15s ease !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        margin-top: 18px !important;
    }
    .carica-btn-submit:hover {
        opacity: 0.92 !important;
    }
    .carica-sec-header {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        margin-bottom: 10px !important;
        width: 100% !important;
    }
    .carica-sec-title {
        font-size: 1.25rem !important;
        font-weight: 700 !important;
        color: #111813 !important;
    }
    .carica-btn-csv {
        background: #284835 !important;
        color: #ffffff !important;
        border: none !important;
        border-radius: 9999px !important;
        padding: 7px 22px !important;
        font-size: 0.88rem !important;
        font-weight: 700 !important;
        cursor: pointer !important;
        transition: opacity 0.15s ease !important;
    }
    .carica-btn-csv:hover {
        opacity: 0.92 !important;
    }
    .carica-tbl-mov {
        width: 100% !important;
        border-collapse: collapse !important;
        font-size: 0.88rem !important;
        margin-top: 8px !important;
    }
    .carica-tbl-mov th {
        text-align: left !important;
        padding: 8px 10px !important;
        font-weight: 700 !important;
        color: #111813 !important;
        border-top: 1.5px solid #111813 !important;
        border-bottom: 1.5px solid #111813 !important;
    }
    .carica-tbl-mov td {
        padding: 8px 10px !important;
        color: #222222 !important;
    }

    /* =====================================================================
       MOCKUP ATTIVITÀ
       ===================================================================== */
    .att-mockup-card {
        background: #fffdfa !important;
        border: none !important;
        border-radius: 26px !important;
        max-width: 780px !important;
        margin: 0 auto !important;
        padding: 28px 34px 34px 34px !important;
        box-shadow: 0 10px 36px rgba(45, 35, 20, 0.07) !important;
        box-sizing: border-box !important;
        width: 100% !important;
        font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
    }
    .att-mockup-header {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding-bottom: 14px !important;
        margin-bottom: 18px !important;
        border-bottom: 1.5px solid #ded6c7 !important;
        width: 100% !important;
    }
    .att-header-title {
        font-size: 1.65rem !important;
        font-weight: 700 !important;
        color: #284835 !important;
        margin: 0 !important;
        letter-spacing: -0.01em !important;
    }
    .att-home-btn {
        background: #cecac0 !important;
        color: #222222 !important;
        font-size: 0.88rem !important;
        font-weight: 600 !important;
        padding: 7px 22px !important;
        border-radius: 9999px !important;
        border: none !important;
        cursor: pointer !important;
        transition: background 0.15s ease !important;
    }
    .att-home-btn:hover {
        background: #bfbaa9 !important;
    }
    .att-top-grid {
        display: grid !important;
        grid-template-columns: 1.15fr 1fr !important;
        gap: 20px !important;
        align-items: stretch !important;
        margin-bottom: 20px !important;
        width: 100% !important;
    }
    @media (max-width: 680px) {
        .att-top-grid {
            grid-template-columns: 1fr !important;
            gap: 12px !important;
        }
    }
    .att-label {
        font-size: 0.88rem !important;
        color: #3f4742 !important;
        margin-bottom: 6px !important;
        font-weight: 500 !important;
        display: block !important;
    }
    .att-select-field {
        width: 100% !important;
        padding: 10px 14px !important;
        border-radius: 10px !important;
        border: 1px solid #c4beaf !important;
        background: #ffffff !important;
        font-size: 0.95rem !important;
        color: #111813 !important;
        box-sizing: border-box !important;
        font-family: inherit !important;
        cursor: pointer !important;
    }
    .att-bal-box {
        background: #ebe5d8 !important;
        border-radius: 14px !important;
        padding: 12px 18px !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        box-sizing: border-box !important;
    }
    .att-bal-title {
        font-size: 0.86rem !important;
        color: #222222 !important;
        font-weight: 700 !important;
        margin-bottom: 6px !important;
    }
    .att-bal-row {
        display: flex !important;
        justify-content: space-between !important;
        font-size: 0.88rem !important;
        color: #3f4742 !important;
        line-height: 1.5 !important;
    }
    .att-bal-row b {
        color: #111813 !important;
        font-weight: 700 !important;
    }

    /* Griglia attività */
    .att-cards-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 20px !important;
        margin-bottom: 24px !important;
        width: 100% !important;
    }
    @media (max-width: 680px) {
        .att-cards-grid {
            grid-template-columns: 1fr !important;
            gap: 16px !important;
        }
    }
    .att-card-box {
        background: #ebe5d8 !important;
        border-radius: 16px !important;
        padding: 18px !important;
        box-sizing: border-box !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
    }
    .att-card-box.full-width {
        grid-column: 1 / -1 !important;
    }
    .att-card-header {
        display: flex !important;
        justify-content: space-between !important;
        align-items: baseline !important;
        margin-bottom: 4px !important;
    }
    .att-card-title {
        font-size: 1.15rem !important;
        font-weight: 700 !important;
        color: #111813 !important;
        margin: 0 !important;
    }
    .att-card-price {
        font-size: 1.15rem !important;
        font-weight: 700 !important;
        color: #111813 !important;
        white-space: nowrap !important;
    }
    .att-card-desc {
        font-size: 0.85rem !important;
        color: #5c6760 !important;
        margin-bottom: 14px !important;
        line-height: 1.35 !important;
    }

    /* Griglia sottoattività (Settimane) a 2 colonne come nel mockup */
    .att-sub-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 20px !important;
        margin: 12px 0 16px 0 !important;
    }
    @media (max-width: 600px) {
        .att-sub-grid {
            grid-template-columns: 1fr !important;
            gap: 14px !important;
        }
    }
    .att-sub-item {
        display: flex !important;
        flex-direction: column !important;
        gap: 6px !important;
    }
    .att-week-pill {
        border-radius: 9999px !important;
        padding: 7px 18px !important;
        font-size: 0.88rem !important;
        font-weight: 700 !important;
        text-align: center !important;
        cursor: pointer !important;
        border: 1.5px solid #284835 !important;
        transition: all 0.15s ease !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    .att-week-pill.selected {
        background: #284835 !important;
        color: #ffffff !important;
    }
    .att-week-pill.unselected {
        background: #ffffff !important;
        color: #284835 !important;
    }
    .att-week-pill:hover {
        opacity: 0.9 !important;
    }
    .att-sub-dates {
        font-size: 0.82rem !important;
        color: #5c6760 !important;
        text-align: left !important;
        margin: 2px 0 4px 2px !important;
    }
    .att-mensa-title {
        font-size: 0.86rem !important;
        font-weight: 700 !important;
        color: #111813 !important;
        margin-top: 4px !important;
    }
    .att-days-grid {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 6px !important;
        margin-top: 4px !important;
    }
    .att-day-pill {
        border-radius: 9999px !important;
        padding: 5px 4px !important;
        font-size: 0.78rem !important;
        font-weight: 600 !important;
        text-align: center !important;
        cursor: pointer !important;
        border: 1px solid #284835 !important;
        transition: all 0.15s ease !important;
        box-sizing: border-box !important;
        white-space: nowrap !important;
    }
    .att-day-pill.selected {
        background: #284835 !important;
        color: #ffffff !important;
    }
    .att-day-pill.unselected {
        background: #ffffff !important;
        color: #284835 !important;
    }
    .att-day-pill:hover {
        opacity: 0.9 !important;
    }

    /* Pulsante submit (Carica credito / Iscriviti) */
    .att-btn-submit {
        background: #284835 !important;
        color: #ffffff !important;
        border: none !important;
        border-radius: 10px !important;
        padding: 10px 18px !important;
        font-size: 0.94rem !important;
        font-weight: 700 !important;
        cursor: pointer !important;
        width: 100% !important;
        margin-top: 10px !important;
        transition: opacity 0.15s ease !important;
        text-align: center !important;
        box-sizing: border-box !important;
    }
    .att-btn-submit:hover {
        opacity: 0.92 !important;
    }

    /* Sezione Attività a cui sei iscritto */
    .att-enrolled-section {
        margin-top: 24px !important;
        border-top: 1.5px solid #ded6c7 !important;
        padding-top: 16px !important;
    }
    .att-sec-title {
        font-size: 1.25rem !important;
        font-weight: 700 !important;
        color: #111813 !important;
        margin: 0 0 14px 0 !important;
    }
    .att-enrolled-table {
        width: 100% !important;
        border-collapse: collapse !important;
        font-size: 0.88rem !important;
    }
    .att-enrolled-table th {
        text-align: left !important;
        padding: 8px 10px !important;
        font-weight: 700 !important;
        color: #111813 !important;
        border-top: 1.5px solid #111813 !important;
        border-bottom: 1.5px solid #111813 !important;
    }
    .att-enrolled-table td {
        padding: 8px 10px !important;
        color: #222222 !important;
        border-bottom: 1px solid #ded6c7 !important;
        vertical-align: middle !important;
    }

    @media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }