/* ============================================================
   ShareDock — Foglio di stile unico
   sharedock.zandegiacomo.it
   ============================================================
   SEZIONI:
   1.  Variabili CSS e reset             (cerca: :root)
   2.  Login page                        (cerca: .login-body)
   3.  Header portale                    (cerca: .portal-header)
   4.  Dashboard / progetti grid         (cerca: .projects-grid)
   5.  Footer                            (cerca: .portal-footer)
   6.  Admin — tabs                      (cerca: .admin-tabs)
   7.  Admin — tabelle                   (cerca: .admin-table)
   8.  Admin — form inline               (cerca: .form-row)
   9.  Progetto — hub sezioni            (cerca: .sections-grid)
   10. Progetto — breadcrumb             (cerca: .breadcrumb)
   11. Documenti — upload zone           (cerca: .upload-zone)
   12. Documenti — lista file            (cerca: .files-list)
   13. Paste Ctrl+V — toast              (cerca: .paste-toast)
   14. Responsive mobile                 (cerca: @media)
   ============================================================ */

/* ============================================
   ShareDock - Stile principale
   ============================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #1a3a5c;
    --primary-light: #2563a8;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --bg: #f0f4f8;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #22c55e;
    --error: #ef4444;
    --error-bg: #fef2f2;
    --shadow: 0 4px 24px rgba(0,0,0,0.08);
    --radius: 12px;
}

body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; color: var(--text); }

/* ============================
   LOGIN PAGE
   ============================ */
.login-body {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.login-card {
    width: 100%;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 40px 36px;
    box-shadow: var(--shadow);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.logo-icon {
    font-size: 48px;
    color: var(--accent);
    margin-bottom: 8px;
}

.login-logo h1 {
    font-size: 26px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.login-logo p {
    color: var(--text-muted);
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group input[type="password"] {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    color: var(--text);
    background: #fff;
    transition: border-color 0.2s;
    outline: none;
}

.form-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.checkbox-group { margin-top: -4px; }

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-muted);
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

.btn-login {
    width: 100%;
    padding: 13px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    margin-top: 8px;
}

.btn-login:hover { background: var(--accent-hover); }
.btn-login:active { transform: scale(0.98); }

.alert {
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-error {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid #fecaca;
}

.login-footer {
    color: rgba(255,255,255,0.5);
    font-size: 12px;
}

/* ============================
   PORTAL (post-login)
   ============================ */
.portal-body {
    min-height: 100vh;
    background: var(--bg);
    display: flex;
    flex-direction: column;
}

/* Header */
.portal-header {
    background: var(--primary);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.logo-icon-sm { font-size: 20px; color: var(--accent); }

.header-user {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-name {
    font-size: 14px;
    color: rgba(255,255,255,0.85);
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge-admin {
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.btn-logout {
    background: rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.85);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-logout:hover { background: rgba(255,255,255,0.22); }

/* Main content */
.portal-main {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 24px;
}

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}

.dashboard-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}

/* Projects grid */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.project-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.project-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.project-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.project-icon { font-size: 28px; }

.project-date {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg);
    padding: 3px 8px;
    border-radius: 6px;
}

.project-name {
    font-size: 17px;
    font-weight: 700;
    color: var(--primary);
}

.project-desc {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.5;
    flex: 1;
}

.project-card-footer { margin-top: 8px; }

.btn-project {
    display: inline-block;
    padding: 8px 16px;
    background: var(--primary);
    color: #fff;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s;
}

.btn-project:hover { background: var(--primary-light); }

/* Buttons generici */
.btn-primary {
    display: inline-block;
    padding: 10px 20px;
    background: var(--accent);
    color: #fff;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    background: var(--card-bg);
    color: var(--primary);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: border-color 0.2s, background 0.2s;
}

.btn-secondary:hover {
    border-color: var(--accent);
    background: #f8faff;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
}

.empty-icon { font-size: 56px; margin-bottom: 16px; }
.empty-state p { font-size: 16px; margin-bottom: 20px; }

/* Footer */
.portal-footer {
    text-align: center;
    padding: 16px;
    color: var(--text-muted);
    font-size: 12px;
    border-top: 1px solid var(--border);
    background: var(--card-bg);
}

/* ============================
   RESPONSIVE
   ============================ */
@media (max-width: 600px) {
    .login-card { padding: 28px 20px; }
    .portal-main { padding: 20px 16px; }
    .projects-grid { grid-template-columns: 1fr; }
    .dashboard-header { flex-direction: column; align-items: flex-start; gap: 12px; }
}
/* ============================================
   ShareDock - Admin styles
   ============================================ */

/* Tabs */
.admin-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
}

.tab-btn {
    padding: 10px 22px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
    border-radius: 6px 6px 0 0;
}

.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Tab content */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Section cards */
.section-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}

.section-card h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 16px;
}

/* Form inline */
.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.form-group { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 160px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-muted); }

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group select {
    padding: 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: 7px;
    font-size: 14px;
    color: var(--text);
    background: #fff;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }

.checkbox-inline { justify-content: flex-end; padding-bottom: 2px; }
.form-action { justify-content: flex-end; min-width: auto; flex: 0; }

/* Alert success */
.alert-success {
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

/* Table */
.table-wrap { overflow-x: auto; }

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.admin-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.admin-table td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: #f8faff; }
.row-inactive td { opacity: 0.5; }

/* Badges */
.badge-client {
    background: #f1f5f9;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.badge-status {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 5px;
}

.badge-status.active { background: #f0fdf4; color: #16a34a; }
.badge-status.inactive { background: #fef2f2; color: #ef4444; }

/* User tags */
.user-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.user-tag {
    background: #eff6ff;
    color: var(--accent);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
}

/* Small buttons */
.btn-sm {
    padding: 5px 10px;
    border: none;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    white-space: nowrap;
}

.btn-sm:hover { opacity: 0.85; }
.btn-warning { background: #fef3c7; color: #92400e; }
.btn-danger { background: #fef2f2; color: #ef4444; }
.btn-success { background: #f0fdf4; color: #16a34a; }

.input-inline {
    padding: 5px 9px;
    border: 1.5px solid var(--border);
    border-radius: 5px;
    font-size: 12px;
    width: 130px;
    outline: none;
}

.input-inline:focus { border-color: var(--accent); }
.text-muted { color: var(--text-muted); font-size: 13px; }

/* Responsive */
@media (max-width: 768px) {
    .form-row { flex-direction: column; }
    .form-group { min-width: 100%; }
    .admin-table { font-size: 12px; }
    .admin-table th, .admin-table td { padding: 8px 8px; }
    .input-inline { width: 100px; }
}
/* ============================================
   ShareDock - Project & Documents styles
   ============================================ */

.back-btn {
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 20px;
    padding: 2px 8px;
    border-radius: 6px;
    transition: background 0.2s;
}
.back-btn:hover { background: rgba(255,255,255,0.15); }

.project-header-bar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
}

.project-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.project-subtitle {
    color: var(--text-muted);
    font-size: 14px;
}

/* Docs section */
.docs-section { padding: 24px; }

.docs-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.docs-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
}

.docs-count {
    background: var(--bg);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
}

/* Upload zone */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 10px;
    margin-bottom: 20px;
    transition: border-color 0.2s, background 0.2s;
    cursor: pointer;
}

.upload-zone:hover {
    border-color: var(--accent);
    background: #f0f7ff;
}

.upload-inner {
    padding: 28px 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.upload-icon { font-size: 32px; }
.upload-text { font-size: 15px; font-weight: 600; color: var(--primary); margin: 0; }
.upload-hint { font-size: 12px; color: var(--text-muted); margin: 0; }

/* Alert inline */
.alert-success-inline {
    padding: 10px 14px;
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
    border-radius: 7px;
    font-size: 13px;
    margin-bottom: 16px;
}

/* Files list */
.files-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 16px;
    border-radius: 8px;
    background: #fafafa;
    border: 1px solid var(--border);
    transition: background 0.15s;
}

.file-item:hover { background: #f0f7ff; }

.file-icon { font-size: 22px; flex-shrink: 0; }

.file-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.file-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.file-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.btn-file {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 7px;
    font-size: 16px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    background: var(--card-bg);
    border: 1px solid var(--border);
}

.btn-file:hover { transform: scale(1.08); }
.btn-view:hover { background: #eff6ff; border-color: var(--accent); }
.btn-download:hover { background: #f0fdf4; border-color: #22c55e; }
.btn-delete:hover { background: #fef2f2; border-color: #ef4444; }

/* Empty */
.files-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 15px;
}

/* Mobile */
@media (max-width: 600px) {
    .file-item { padding: 10px 12px; gap: 10px; }
    .file-name { font-size: 13px; }
    .btn-file { width: 32px; height: 32px; font-size: 14px; }
    .project-title { font-size: 18px; }
}

/* ============================================
   Hub sezioni progetto
   ============================================ */

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.breadcrumb a {
    color: var(--accent);
    text-decoration: none;
}

.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb span { color: var(--text-muted); }

.sections-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 8px;
}

.section-tile {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--card-bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 18px;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
    cursor: pointer;
}

.section-tile:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 16px rgba(59,130,246,0.12);
    transform: translateY(-2px);
}

.tile-disabled {
    opacity: 0.45;
    cursor: default;
    pointer-events: none;
}

.section-tile-icon {
    font-size: 32px;
    flex-shrink: 0;
}

.section-tile-body {
    flex: 1;
    min-width: 0;
}

.section-tile-body h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary);
    margin: 0 0 4px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-tile-body p {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.4;
}

.section-tile-arrow {
    font-size: 22px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.badge-soon {
    background: #f1f5f9;
    color: #94a3b8;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 4px;
    letter-spacing: 0.3px;
    vertical-align: middle;
}

@media (max-width: 600px) {
    .sections-grid { grid-template-columns: 1fr; }
    .section-tile { padding: 16px 14px; }
}

/* ============================================
   Paste Ctrl+V - Toast notifica
   ============================================ */

.paste-toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1e293b;
    color: #fff;
    padding: 13px 22px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.25s, transform 0.25s;
    z-index: 9999;
    pointer-events: none;
    white-space: nowrap;
}

.paste-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Hint Ctrl+V nella upload zone (solo admin) */
.upload-hint-paste {
    font-size: 12px;
    color: #94a3b8;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 5px;
}

.kbd {
    background: #e2e8f0;
    color: #475569;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 11px;
    font-family: monospace;
    font-weight: 700;
}

/* ============================================================
   15. Modal anteprima file
   ============================================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    backdrop-filter: blur(3px);
    animation: fadeInOverlay 0.18s ease;
}

@keyframes fadeInOverlay {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal-box {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 860px;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 64px rgba(0,0,0,0.35);
    animation: slideUpModal 0.2s ease;
    overflow: hidden;
}

@keyframes slideUpModal {
    from { transform: translateY(24px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* Header */
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
    flex-shrink: 0;
}

.modal-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.modal-file-icon { font-size: 22px; flex-shrink: 0; }

.modal-file-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modal-close {
    background: #f1f5f9;
    border: none;
    border-radius: 7px;
    width: 34px;
    height: 34px;
    font-size: 15px;
    cursor: pointer;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover { background: #fef2f2; color: #ef4444; }

/* Body / preview */
.modal-body {
    flex: 1;
    overflow: hidden;
    position: relative;
    min-height: 200px;
    background: #f8fafc;
}

.modal-iframe {
    width: 100%;
    height: 100%;
    min-height: 55vh;
    border: none;
    display: block;
}

.modal-img {
    width: 100%;
    height: 100%;
    min-height: 55vh;
    object-fit: contain;
    display: block;
    padding: 12px;
}

.modal-no-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 55vh;
    color: var(--text-muted);
    font-size: 15px;
    text-align: center;
    padding: 32px;
}

/* Loading spinner */
.modal-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    min-height: 55vh;
    color: var(--text-muted);
    font-size: 14px;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Footer azioni */
.modal-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: #fff;
    flex-shrink: 0;
}

.modal-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.15s, transform 0.1s;
}

.modal-btn:active { transform: scale(0.97); }

.modal-btn-print {
    background: #f1f5f9;
    color: var(--text);
}
.modal-btn-print:hover { background: #e2e8f0; }

.modal-btn-share {
    background: #eff6ff;
    color: var(--accent);
}
.modal-btn-share:hover { background: #dbeafe; }

.modal-btn-download {
    background: var(--primary);
    color: #fff;
    margin-left: auto;
}
.modal-btn-download:hover { background: var(--primary-light); }

/* Mobile */
@media (max-width: 600px) {
    .modal-overlay { padding: 0; align-items: flex-end; }

    .modal-box {
        max-width: 100%;
        max-height: 95vh;
        border-radius: 20px 20px 0 0;
    }

    .modal-iframe,
    .modal-img,
    .modal-no-preview,
    .modal-loading { min-height: 50vh; }

    .modal-file-name { font-size: 13px; }

    .modal-btn span { display: none; }
    .modal-btn { padding: 9px 14px; font-size: 18px; }
    .modal-footer { gap: 8px; }
}

/* ============================================================
   16. Modulo Attività
   ============================================================ */

.act-list-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
}

/* Filtri */
.act-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.filter-btn {
    padding: 7px 14px;
    background: var(--card-bg);
    border: 1.5px solid var(--border);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.filter-count {
    background: rgba(255,255,255,0.25);
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 11px;
}

.filter-btn:not(.active) .filter-count { background: var(--bg); color: var(--text-muted); }

/* Card attività nella lista */
.act-list { display: flex; flex-direction: column; gap: 10px; }

.act-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--card-bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
    position: relative;
    overflow: hidden;
}

.act-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    border-radius: 4px 0 0 4px;
}

.act-card.status-programma::before { background: #94a3b8; }
.act-card.status-corso::before     { background: #3b82f6; }
.act-card.status-conclusa::before  { background: #22c55e; }
.act-card.act-overdue::before      { background: #ef4444; }

.act-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 16px rgba(59,130,246,0.1);
    transform: translateX(2px);
}

.act-card.act-unread { background: #fafcff; }

.act-card-left { display: flex; align-items: flex-start; gap: 12px; flex: 1; min-width: 0; }

.unread-dot {
    width: 9px; height: 9px;
    background: var(--accent);
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 6px;
}

.act-card-body { flex: 1; min-width: 0; }

.act-card-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }

.act-status-badge {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 20px;
    letter-spacing: 0.3px;
}

.status-programma { background: #f1f5f9; color: #64748b; }
.status-corso     { background: #eff6ff; color: #2563eb; }
.status-conclusa  { background: #f0fdf4; color: #16a34a; }

.act-status-lg { font-size: 13px; padding: 5px 14px; }

.act-overdue-badge {
    font-size: 11px;
    font-weight: 700;
    color: #ef4444;
    background: #fef2f2;
    padding: 3px 9px;
    border-radius: 20px;
}

.act-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary);
    margin: 0 0 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.act-desc {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0 0 8px;
    line-height: 1.4;
}

.act-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--text-muted);
}

.act-dates { display: inline-flex; align-items: center; gap: 4px; }
.act-notes-count { color: var(--accent); font-weight: 600; }
.text-danger { color: #ef4444 !important; font-weight: 600; }
.act-card-arrow { font-size: 22px; color: var(--text-muted); flex-shrink: 0; margin-left: 8px; }

/* ── Dettaglio attività ── */
.act-detail-card {
    background: var(--card-bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
}

.act-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.act-detail-status-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.act-read-info-btn {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-muted);
    transition: background 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.act-read-info-btn:hover { background: #eff6ff; color: var(--accent); }

.act-detail-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.act-detail-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
    margin: 0 0 10px;
    line-height: 1.3;
}

.act-detail-desc {
    font-size: 15px;
    color: var(--text);
    line-height: 1.7;
    margin-bottom: 16px;
    white-space: pre-wrap;
}

.act-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.act-meta-item { display: flex; flex-direction: column; gap: 2px; }
.act-meta-label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.act-meta-item > span:last-child { font-size: 14px; font-weight: 600; color: var(--text); }

.act-closing-comment {
    margin-top: 16px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    padding: 14px 16px;
    font-size: 14px;
    color: var(--text);
    line-height: 1.6;
}
.act-closing-label { font-size: 12px; font-weight: 700; color: #16a34a; margin-bottom: 6px; }

/* ── Note / chat ── */
.notes-section { padding: 20px; }

.notes-thread {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 420px;
    overflow-y: auto;
    padding: 4px 2px 8px;
    margin-bottom: 16px;
    scroll-behavior: smooth;
}

.note-bubble {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    animation: noteIn 0.2s ease;
}

@keyframes noteIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.note-other {
    align-self: flex-start;
    background: #f1f5f9;
    border-bottom-left-radius: 3px;
}

.note-mine {
    align-self: flex-end;
    background: #eff6ff;
    border: 1px solid #dbeafe;
    border-bottom-right-radius: 3px;
}

.note-meta-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 11px;
}

.note-author { font-weight: 700; color: var(--primary); }
.note-author-me { color: var(--accent); }
.note-time { color: var(--text-muted); }

.note-del-btn {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 14px;
    padding: 0 2px;
    line-height: 1;
    opacity: 0.5;
    transition: opacity 0.15s, color 0.15s;
}
.note-del-btn:hover { opacity: 1; color: #ef4444; }

.note-text { color: var(--text); white-space: pre-wrap; }

.note-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.note-file-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(255,255,255,0.7);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s;
    color: var(--text);
}
.note-file-chip:hover { background: #fff; border-color: var(--accent); }

/* Input nota */
.note-input-area { border-top: 1px solid var(--border); padding-top: 14px; }

.note-file-preview {
    background: #eff6ff;
    border: 1px solid #dbeafe;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    color: var(--accent);
    margin-bottom: 8px;
}

.note-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.note-textarea {
    flex: 1;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    resize: none;
    font-family: inherit;
    line-height: 1.5;
    outline: none;
    transition: border-color 0.2s;
}
.note-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }

.note-input-btns { display: flex; flex-direction: column; gap: 6px; }

.note-attach-btn, .note-send-btn {
    width: 38px; height: 38px;
    border-radius: 9px;
    border: none;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.1s;
}
.note-attach-btn { background: #f1f5f9; color: var(--text-muted); }
.note-attach-btn:hover { background: #e2e8f0; }
.note-send-btn { background: var(--accent); color: #fff; }
.note-send-btn:hover { background: var(--accent-hover); }
.note-send-btn:active { transform: scale(0.92); }

/* ── Modal form ── */
.modal-form-box { max-width: 540px; }
.modal-sm-box   { max-width: 420px; }

.modal-form-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
    max-height: 60vh;
}

.mf-group { display: flex; flex-direction: column; gap: 5px; }
.mf-group label { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.mf-group input, .mf-group textarea, .mf-group select {
    padding: 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
}
.mf-group input:focus, .mf-group textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
.mf-group textarea { resize: vertical; }
.mf-row { display: flex; gap: 12px; }
.mf-row .mf-group { flex: 1; }

/* Status picker */
.status-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.status-option {
    cursor: pointer;
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    transition: border-color 0.15s;
    display: flex;
    align-items: center;
}
.status-option input[type="radio"] { display: none; }
.status-option.selected, .status-option:has(input:checked) { border-color: var(--accent); }
.status-option:hover { border-color: var(--accent); }

/* Read log */
.read-log-list { display: flex; flex-direction: column; gap: 8px; }
.read-log-item { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.read-log-item:last-child { border-bottom: none; }
.read-log-avatar {
    width: 34px; height: 34px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
}
.read-log-name { font-size: 14px; font-weight: 600; color: var(--text); }
.read-log-time { font-size: 12px; color: var(--text-muted); }

.act-files-section { padding: 20px; }

/* Mobile */
@media (max-width: 600px) {
    .act-card { padding: 12px 14px; }
    .act-title { font-size: 14px; }
    .act-detail-header { flex-direction: column; }
    .act-detail-title { font-size: 18px; }
    .mf-row { flex-direction: column; }
    .notes-thread { max-height: 300px; }
    .note-bubble { max-width: 92%; }
    .act-detail-actions { width: 100%; }
}

/* ============================================================
   17. Accordion Attività
   ============================================================ */

.act-accordion { display: flex; flex-direction: column; gap: 6px; }

.acc-item {
    background: var(--card-bg);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    transition: border-color 0.15s, box-shadow 0.15s;
    position: relative;
}

.acc-item::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
}
.acc-item.status-programma::before { background: #94a3b8; }
.acc-item.status-corso::before     { background: #3b82f6; }
.acc-item.status-conclusa::before  { background: #22c55e; }
.acc-item.act-overdue::before      { background: #ef4444; }

.acc-item.acc-open {
    border-color: var(--accent);
    box-shadow: 0 4px 16px rgba(59,130,246,0.1);
}

.acc-item.act-unread { background: #fafcff; }

/* Header riga compatta */
.acc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 12px 20px;
    cursor: pointer;
    gap: 10px;
    user-select: none;
    transition: background 0.12s;
}

.acc-header:hover { background: #f8faff; }

.acc-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.acc-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.acc-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.acc-date {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.acc-chevron {
    font-size: 18px;
    color: var(--text-muted);
    transition: transform 0.2s, color 0.15s;
    line-height: 1;
    width: 18px;
    text-align: center;
}
.acc-chevron.open { color: var(--accent); }

/* Pannello espanso */
.acc-body {
    padding: 0 20px 16px 20px;
    border-top: 1px solid var(--border);
    animation: accOpen 0.18s ease;
}

@keyframes accOpen {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.acc-desc {
    font-size: 14px;
    color: var(--text);
    line-height: 1.65;
    margin: 14px 0 12px;
    white-space: pre-wrap;
}

.acc-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.acc-meta-chip {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 3px 10px;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}
.chip-danger { background: #fef2f2; border-color: #fecaca; color: #ef4444; }

.acc-closing {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 7px;
    padding: 10px 14px;
    font-size: 13px;
    color: #15803d;
    margin-bottom: 12px;
}

/* Preview ultime note */
.acc-notes-preview {
    background: var(--bg);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.acc-notes-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 4px;
}

.acc-note-row {
    display: flex;
    align-items: baseline;
    gap: 7px;
    font-size: 13px;
    line-height: 1.4;
}
.acc-note-author { font-weight: 700; color: var(--primary); flex-shrink: 0; font-size: 12px; }
.acc-note-text   { color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-note-time   { color: var(--text-muted); font-size: 11px; flex-shrink: 0; }

/* Azioni bottom */
.acc-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
}

.acc-btn-detail {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: var(--primary);
    color: #fff;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s;
}
.acc-btn-detail:hover { background: var(--primary-light); }

/* Mobile */
@media (max-width: 600px) {
    .acc-header { padding: 11px 12px 11px 16px; }
    .acc-title  { font-size: 13px; }
    .acc-date, .act-notes-count { display: none; }
    .acc-body   { padding: 0 12px 14px; }
    .acc-note-text { max-width: 140px; }
}

/* ============================================================
   18. Note inline accordion + Notifiche
   ============================================================ */

/* Banner notifiche */
.notif-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #eff6ff;
    border: 1.5px solid #bfdbfe;
    border-radius: 10px;
    padding: 11px 16px;
    margin-bottom: 16px;
    cursor: pointer;
    animation: slideDown 0.25s ease;
}
@keyframes slideDown {
    from { opacity:0; transform:translateY(-8px); }
    to   { opacity:1; transform:translateY(0); }
}
.notif-icon { font-size: 18px; }
.notif-banner span { flex:1; font-size:14px; font-weight:600; color:#1d4ed8; }
.notif-dismiss {
    background: none; border: none; cursor: pointer;
    color: #93c5fd; font-size: 16px; padding: 2px 4px;
    border-radius: 4px; transition: color 0.15s;
}
.notif-dismiss:hover { color: #1d4ed8; }

/* Bubble unread sull'header accordion */
.acc-unread-bubble {
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    animation: popIn 0.2s ease;
}
@keyframes popIn {
    from { transform: scale(0.6); opacity:0; }
    to   { transform: scale(1);   opacity:1; }
}

/* Thread note dentro accordion */
.acc-thread-wrap {
    border: 1.5px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    margin: 12px 0;
    background: var(--bg);
}

.acc-thread {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    max-height: 280px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.acc-thread-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
}

.acc-no-notes {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    padding: 16px 8px;
    margin: 0;
}

/* Nota nella thread */
.note-bubble {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.5;
    animation: noteIn 0.18s ease;
    position: relative;
}
@keyframes noteIn {
    from { opacity:0; transform:translateY(6px); }
    to   { opacity:1; transform:translateY(0); }
}
.note-other { align-self:flex-start; background:#fff; border:1px solid var(--border); border-bottom-left-radius:3px; }
.note-mine  { align-self:flex-end;   background:#dbeafe; border:1px solid #bfdbfe;   border-bottom-right-radius:3px; }

.note-meta-top {
    display: flex; align-items: center; gap: 7px;
    margin-bottom: 3px; font-size: 11px;
}
.note-author     { font-weight:700; color: var(--primary); }
.note-author-me  { color: var(--accent); }
.note-time       { color: var(--text-muted); }
.note-text       { color: var(--text); word-break: break-word; white-space: pre-wrap; }

/* Spunte stile WhatsApp */
.note-ticks {
    display: flex;
    justify-content: flex-end;
    margin-top: 3px;
    min-height: 14px;
}
.tick {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: -2px;
}
.tick-sent { color: #94a3b8; }
.tick-read { color: #2563eb; }

/* File chip nella nota */
.note-files  { display:flex; flex-wrap:wrap; gap:5px; margin-top:7px; }
.note-file-chip {
    display: inline-flex; align-items: center; gap: 4px;
    background: rgba(255,255,255,0.75);
    border: 1px solid var(--border);
    border-radius: 6px; padding: 3px 9px;
    font-size: 12px; cursor: pointer; text-decoration: none;
    color: var(--text); transition: background 0.15s;
}
.note-file-chip:hover { background:#fff; border-color:var(--accent); }

/* Input commento in fondo al thread */
.acc-note-input-row {
    display: flex; align-items: flex-end; gap: 8px;
    padding: 8px 10px;
    border-top: 1px solid var(--border);
    background: #fff;
}
.acc-note-textarea {
    flex: 1; padding: 8px 11px;
    border: 1.5px solid var(--border);
    border-radius: 8px; font-size: 13.5px;
    font-family: inherit; line-height: 1.45;
    resize: none; outline: none; min-height: 36px;
    max-height: 100px; overflow-y: auto;
    transition: border-color 0.2s;
}
.acc-note-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }

/* Mobile */
@media (max-width: 600px) {
    .note-bubble    { max-width: 94%; }
    .acc-thread     { max-height: 220px; }
    .acc-date, .act-notes-count { display:none; }
}

/* ============================================================
   19. Foto nei commenti + Modal zoom
   ============================================================ */

/* Anteprima foto prima di inviare */
.acc-note-input-wrap { }

.note-img-preview-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px 0;
    background: #f8faff;
}

.note-img-thumb-preview {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 8px;
    border: 1.5px solid #bfdbfe;
}

.note-img-remove {
    background: #fee2e2;
    border: none;
    border-radius: 50%;
    width: 22px; height: 22px;
    cursor: pointer;
    font-size: 13px;
    color: #ef4444;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
}
.note-img-remove:hover { background: #fca5a5; }

/* Thumbnail inline nella bolla */
.note-img-wrap {
    display: inline-block;
    position: relative;
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
    margin: 2px;
    transition: transform 0.15s;
}
.note-img-wrap:hover { transform: scale(1.03); }

.note-img-thumb {
    display: block;
    max-width: 180px;
    max-height: 160px;
    width: auto; height: auto;
    object-fit: cover;
    border-radius: 8px;
    border: 1.5px solid rgba(0,0,0,0.08);
}

.note-img-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
    border-radius: 8px;
}
.note-img-wrap:hover .note-img-overlay {
    opacity: 1;
    background: rgba(0,0,0,0.25);
}

/* Modal zoom */
.modal-zoom-overlay { background: rgba(0,0,0,0.85) !important; }

.modal-zoom-box {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    max-width: min(92vw, 900px);
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    animation: modalIn 0.18s ease;
}

.modal-zoom-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
    background: var(--primary);
}

.modal-zoom-title {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.modal-zoom-body {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    padding: 16px;
    background: #111;
    flex: 1;
}

.zoom-img {
    max-width: 100%;
    max-height: calc(90vh - 80px);
    object-fit: contain;
    border-radius: 4px;
}

/* Input area aggiornata con pulsante 📎 */
.acc-note-input-row {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding: 8px 10px;
    border-top: 1px solid var(--border);
    background: #fff;
}

.note-attach-btn {
    width: 34px; height: 34px;
    background: #f1f5f9;
    border: none; border-radius: 8px;
    font-size: 15px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
    color: var(--text-muted);
}
.note-attach-btn:hover { background: #e2e8f0; }

@media (max-width: 600px) {
    .note-img-thumb    { max-width: 130px; max-height: 120px; }
    .modal-zoom-box    { max-width: 100vw; border-radius: 0; }
}

/* ============================================================
   20. Cestino
   ============================================================ */

.cestino-list { display: flex; flex-direction: column; gap: 10px; }

.cestino-card {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    background: var(--card-bg);
    border: 1.5px solid #fecaca;
    border-radius: var(--radius);
    padding: 16px 18px;
    opacity: 0.85;
    transition: border-color 0.15s, opacity 0.15s;
    overflow: hidden;
}
.cestino-card:hover { opacity: 1; border-color: #f87171; }

.cestino-card-body { flex: 1; min-width: 0; }

.cestino-card-top {
    display: flex; align-items: center; gap: 10px;
    flex-wrap: wrap; margin-bottom: 4px;
}

.cestino-deleted-by {
    font-size: 12px; color: var(--text-muted);
}

.cestino-reason {
    font-size: 13px;
    color: #dc2626;
    background: #fef2f2;
    border-radius: 6px;
    padding: 5px 10px;
    margin-top: 8px;
    display: inline-block;
}

.cestino-card-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    flex-shrink: 0;
}

@media (max-width: 600px) {
    .cestino-card { flex-direction: column; }
    .cestino-card-actions { flex-direction: row; width: 100%; }
}

/* ============================================================
   21. Modal eliminazione definitiva
   ============================================================ */

.perm-delete-warning {
    text-align: center;
    padding: 8px 0;
}
.perm-delete-icon { font-size: 40px; margin-bottom: 10px; }
.perm-delete-warning p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--text); }

.perm-delete-input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #ef4444;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 1px;
    text-align: center;
    outline: none;
    transition: box-shadow 0.2s;
    box-sizing: border-box;
}
.perm-delete-input:focus { box-shadow: 0 0 0 3px rgba(239,68,68,0.2); }

/* ============================================================
   22. Stati nota
   ============================================================ */

/* Select stato nell'input */
.acc-note-status-row {
    padding: 6px 10px 0;
    background: #fff;
}
.note-status-select {
    font-size: 12px;
    padding: 4px 8px;
    border: 1.5px solid var(--border);
    border-radius: 20px;
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s;
}
.note-status-select:focus { border-color: var(--accent); }

/* Footer bolla: badge + spunte affiancati */
.note-footer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
    gap: 8px;
    flex-wrap: wrap;
}

/* Badge stato sulla bolla */
.note-status-badge-wrap { position: relative; }

.note-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 20px;
    border: none;
    cursor: pointer;
    transition: filter 0.15s, transform 0.1s;
    white-space: nowrap;
}
.note-status-badge:hover { filter: brightness(0.95); transform: scale(1.03); }
.note-status-badge:active { transform: scale(0.97); }

/* Colori per stato */
.ns-valutare      { background: #eff6ff; color: #2563eb; }
.ns-approvato     { background: #f0fdf4; color: #16a34a; }
.ns-non-approvato { background: #fef2f2; color: #dc2626; }
.ns-rilevante     { background: #fefce8; color: #ca8a04; }
.ns-non-rilevante { background: #f8fafc; color: #94a3b8; border: 1px solid #e2e8f0; }
.ns-richiesta     { background: #f0f9ff; color: #0284c7; }
.ns-problema      { background: #fff7ed; color: #c2410c; }
.ns-risolto       { background: #f0fdf4; color: #059669; }
.ns-decisione     { background: #faf5ff; color: #7c3aed; }
.ns-interna       { background: #1e293b; color: #cbd5e1; }

/* Dropdown menu stati */
.note-status-menu {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 200;
    overflow: hidden;
    min-width: 170px;
    animation: accOpen 0.12s ease;
}

.nsm-option {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 14px;
    background: none;
    border: none;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    text-align: left;
    transition: background 0.1s;
}
.nsm-option:hover  { background: var(--bg); }
.nsm-active        { background: #eff6ff; color: var(--accent); font-weight: 700; }

@media (max-width: 600px) {
    .note-status-menu { left: auto; right: 0; min-width: 155px; }
}

/* ============================================================
   23. Badge notifiche su card progetto
   ============================================================ */

.project-card-header { position: relative; }

.project-notif-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 22px;
    height: 22px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(239,68,68,0.4);
    animation: popIn 0.25s ease;
}

.project-card-unread {
    border-color: #bfdbfe;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.08);
}

.project-card-unread .project-name {
    color: var(--primary);
}

/* ============================================================
   24. Stati documenti + log + tile badge
   ============================================================ */

/* Badge tile sull'hub progetto */
.section-tile-icon { position: relative; display: inline-block; }

.tile-badge {
    position: absolute;
    top: -8px; right: -12px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(239,68,68,0.4);
    animation: popIn 0.2s ease;
}

.tile-has-badge { border-color: #bfdbfe !important; }

/* File item v2 */
.file-item-v2 { flex-direction: column; align-items: stretch; gap: 0; padding: 0; }

.fi-main {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
}

.fi-right {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* Badge stato documento */
.doc-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 20px;
    white-space: nowrap;
}
.ds-da-revisionare { background: #eff6ff; color: #2563eb; }
.ds-in-revisione   { background: #fefce8; color: #b45309; }
.ds-approvato      { background: #f0fdf4; color: #16a34a; }
.ds-non-approvato  { background: #fef2f2; color: #dc2626; }
.ds-firmato        { background: #faf5ff; color: #7c3aed; }
.ds-sostituito     { background: #fff7ed; color: #c2410c; }
.ds-archiviato     { background: #f1f5f9; color: #64748b; }

/* Badge "visto da N" */
.doc-read-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 20px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    transition: filter 0.15s;
}
.doc-read-yes { background: #f0fdf4; color: #16a34a; }
.doc-read-no  { background: #fef2f2; color: #ef4444; }
.doc-read-badge:hover { filter: brightness(0.94); }

/* Panel espandibile (stato / log / letture) */
.fi-panel {
    border-top: 1px solid var(--border);
    padding: 12px 14px;
    background: var(--bg);
    border-radius: 0 0 var(--radius) var(--radius);
    animation: accOpen 0.15s ease;
}

.fi-panel-empty { font-size: 13px; color: var(--text-muted); margin: 0; }

/* Form cambia stato */
.status-form {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.doc-status-select {
    font-size: 13px;
    padding: 5px 10px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    outline: none;
}
.doc-status-note {
    flex: 1;
    min-width: 160px;
    font-size: 13px;
    padding: 5px 10px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    outline: none;
}
.doc-status-note:focus,
.doc-status-select:focus { border-color: var(--accent); }

/* Log stati */
.doc-log-list { display: flex; flex-direction: column; gap: 8px; }

.doc-log-entry {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 10px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
}
.doc-log-icon { font-size: 18px; flex-shrink: 0; line-height: 1.4; }
.doc-log-body { flex: 1; min-width: 0; }
.doc-log-who  { font-size: 13px; color: var(--text); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.doc-log-old  { color: var(--text-muted); text-decoration: line-through; font-size: 12px; }
.doc-log-new  { font-weight: 700; font-size: 12px; }
.doc-log-when { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.doc-log-note { font-size: 12px; color: #2563eb; margin-top: 4px; }

/* Log letture */
.doc-read-list { display: flex; flex-wrap: wrap; gap: 6px; }
.doc-read-chip {
    font-size: 12px;
    background: #f0fdf4;
    color: #15803d;
    border-radius: 20px;
    padding: 4px 10px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.doc-read-time { color: #94a3b8; font-size: 11px; }

@media (max-width: 640px) {
    .fi-right { gap: 4px; }
    .doc-status-badge { display: none; } /* mostra solo su desktop */
    .status-form { flex-direction: column; align-items: stretch; }
}

/* ============================================================
   25. Drag & Drop + Paste allegati nota (DettaglioAttività)
   ============================================================ */

.note-input-area {
    position: relative;
}

/* Overlay drag */
.note-drag-overlay {
    position: absolute;
    inset: 0;
    background: rgba(59,130,246,0.08);
    border: 2.5px dashed var(--accent);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    pointer-events: none;
    animation: accOpen 0.1s ease;
}
.note-drag-msg {
    font-size: 15px;
    font-weight: 700;
    color: var(--accent);
    background: #fff;
    padding: 10px 20px;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(59,130,246,0.15);
}
.note-drop-active {
    outline: 2.5px dashed var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius);
}

/* Anteprima file selezionato */
.note-file-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: #eff6ff;
    border: 1.5px solid #bfdbfe;
    border-radius: 8px;
    margin-bottom: 6px;
    font-size: 13px;
    color: #1d4ed8;
    flex-wrap: wrap;
}
.note-paste-thumb {
    width: 60px;
    height: 45px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #bfdbfe;
    flex-shrink: 0;
}
.note-file-remove {
    margin-left: auto;
    background: none;
    border: none;
    color: #ef4444;
    font-size: 16px;
    cursor: pointer;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 4px;
    flex-shrink: 0;
}
.note-file-remove:hover { background: #fef2f2; }

/* Suggerimento modalità input */
.note-input-hint {
    display: flex;
    gap: 14px;
    padding: 4px 2px 0;
    font-size: 11px;
    color: var(--text-muted);
    flex-wrap: wrap;
}

@media (max-width: 600px) {
    .note-input-hint { gap: 8px; font-size: 10px; }
    .note-paste-thumb { width: 48px; height: 36px; }
}

/* ============================================================
   26. Modal incolla immagine con commento
   ============================================================ */

.modal-paste-overlay {
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-paste-box {
    max-width: 440px;
    width: calc(100% - 32px);
    animation: popIn 0.2s cubic-bezier(0.34,1.56,0.64,1);
}

.paste-modal-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
}

.paste-modal-preview img {
    max-width: 100%;
    max-height: 200px;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
}

.paste-modal-fname {
    font-size: 11px;
    color: var(--text-muted);
    word-break: break-all;
    text-align: center;
}

.mf-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    outline: none;
    transition: border-color 0.15s;
    box-sizing: border-box;
}
.mf-textarea:focus { border-color: var(--accent); }

@media (max-width: 500px) {
    .paste-modal-preview img { max-height: 150px; }
    .modal-paste-box { border-radius: 16px 16px 0 0; margin-top: auto; margin-bottom: 0; }
    .modal-paste-overlay { align-items: flex-end; }
}

/* ============================================================
   27. Sezione Note progetto
   ============================================================ */

.note-cards-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 16px;
}

.note-card {
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    transition: box-shadow 0.15s;
    position: relative;
}
.note-card:hover { box-shadow: var(--shadow); }

.note-card-unread {
    border-left: 4px solid var(--accent);
    background: #f8faff;
}

.note-card-pinned {
    border-color: #f59e0b;
    background: #fffbeb;
}

.note-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.note-card-author {
    display: flex;
    align-items: center;
    gap: 10px;
}

.note-card-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    text-transform: uppercase;
}

.note-card-name {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-primary);
    display: block;
}

.note-card-time {
    font-size: 11px;
    color: var(--text-muted);
    display: block;
    margin-top: 1px;
}

.note-edited {
    font-style: italic;
    color: #94a3b8;
    margin-left: 4px;
}

.note-card-badges {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.note-pin-badge {
    font-size: 11px;
    background: #fef3c7;
    color: #92400e;
    border-radius: 20px;
    padding: 2px 8px;
    font-weight: 600;
}

.note-unread-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    display: inline-block;
    flex-shrink: 0;
}

.note-readers-chip {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 3px 10px;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}
.note-readers-chip:hover { background: #e2e8f0; color: var(--text-primary); }

.note-card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.note-card-body {
    font-size: 14px;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.6;
}

.note-card-footer {
    display: flex;
    gap: 8px;
    margin-top: 14px;
    flex-wrap: wrap;
}

/* letture lista */
.doc-read-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 260px;
    overflow-y: auto;
}

.doc-read-chip {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-primary);
    gap: 10px;
}

.doc-read-time {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* modal-sm-box */
.modal-sm-box {
    max-width: 400px;
}

/* spinner */
.modal-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px;
    color: var(--text-muted);
}
.spinner {
    width: 28px; height: 28px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 600px) {
    .note-card { padding: 14px; }
    .note-card-header { flex-direction: column; gap: 8px; }
    .note-card-badges { align-self: flex-end; }
    .note-card-footer { gap: 6px; }
    .note-card-avatar { width: 32px; height: 32px; font-size: 13px; }
}

/* ============================================================
   28. Pulsantini admin nell'header
   ============================================================ */

.header-admin-btns {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-right: 8px;
}

.btn-header-admin {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    background: #f1f5f9;
    border: 1.5px solid #e2e8f0;
    border-radius: 20px;
    text-decoration: none;
    transition: all 0.15s;
    white-space: nowrap;
}

.btn-header-admin:hover {
    background: #e2e8f0;
    color: #1a3a5c;
    border-color: #cbd5e1;
}

.btn-header-admin-active {
    background: #1a3a5c;
    color: #fff;
    border-color: #1a3a5c;
}
.btn-header-admin-active:hover {
    background: #15304f;
    color: #fff;
}

@media (max-width: 600px) {
    .btn-header-admin span,
    .btn-header-admin { font-size: 11px; padding: 4px 9px; gap: 3px; }
    .header-admin-btns { gap: 4px; margin-right: 4px; }
}

/* ============================================================
   29. Sotto-attività (SubActivities)
   ============================================================ */

.sub-act-section {}

/* Barra progresso */
.sub-progress-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 10px 0 16px;
}
.sub-progress-bar {
    flex: 1;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}
.sub-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.4s ease;
}
.sub-progress-done { background: #16a34a; }
.sub-progress-pct {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    min-width: 34px;
    text-align: right;
}

/* Lista */
.sub-act-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sub-act-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    transition: background 0.15s, opacity 0.15s;
}
.sub-act-item:hover { background: #f1f5f9; }
.sub-done {
    background: #f0fdf4 !important;
    border-color: #bbf7d0 !important;
    opacity: 0.75;
}

/* Checkbox custom */
.sub-check-wrap {
    position: relative;
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    margin-top: 1px;
    cursor: pointer;
}
.sub-check-wrap input[type="checkbox"] {
    opacity: 0;
    position: absolute;
    width: 22px;
    height: 22px;
    margin: 0;
    cursor: pointer;
    z-index: 2;
}
.sub-checkmark {
    position: absolute;
    inset: 0;
    border: 2px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sub-check-wrap input:checked ~ .sub-checkmark {
    background: #16a34a;
    border-color: #16a34a;
}
.sub-check-wrap input:checked ~ .sub-checkmark::after {
    content: '';
    display: block;
    width: 5px;
    height: 9px;
    border: 2.5px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg) translateY(-1px);
}

/* Body testo */
.sub-act-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.sub-act-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
}
.sub-done .sub-act-title {
    text-decoration: line-through;
    color: var(--text-muted);
}
.sub-act-desc {
    font-size: 12.5px;
    color: var(--text-secondary);
    line-height: 1.4;
}
.sub-act-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}
.sub-completed-by {
    color: #16a34a;
    font-weight: 600;
}

/* Bottoni azione */
.sub-act-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    align-self: center;
    opacity: 0;
    transition: opacity 0.15s;
}
.sub-act-item:hover .sub-act-actions { opacity: 1; }
.sub-btn-edit, .sub-btn-del {
    background: none;
    border: none;
    font-size: 15px;
    cursor: pointer;
    padding: 3px 5px;
    border-radius: 6px;
    transition: background 0.12s;
    line-height: 1;
}
.sub-btn-edit:hover { background: #e0f2fe; }
.sub-btn-del:hover  { background: #fee2e2; }

@media (max-width: 600px) {
    .sub-act-actions { opacity: 1; }
    .sub-act-item { padding: 8px 10px; gap: 8px; }
    .sub-act-title { font-size: 13px; }
}

/* ============================================================
   30. Galleria Foto
   ============================================================ */

/* Drop zone */
.foto-drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background: #f8fafc;
    padding: 10px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 48px;
}
.foto-drop-zone:hover,
.foto-drop-active { border-color: var(--accent); background: #eff6ff; }
.foto-drop-icon  { font-size: 20px; flex-shrink: 0; }
.foto-drop-title { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.foto-drop-hint  { font-size: 11px; color: var(--text-muted); }

/* Upload progress bar */
.foto-upload-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    padding: 10px 14px;
    background: #eff6ff;
    border-radius: 10px;
    border: 1px solid #bfdbfe;
}
.foto-upload-inner {
    flex: 1;
    height: 6px;
    background: #dbeafe;
    border-radius: 3px;
    overflow: hidden;
}
.foto-upload-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 1.5s ease;
    width: 0%;
}
.foto-upload-bar span { font-size: 12px; color: #1d4ed8; font-weight: 600; white-space: nowrap; }

/* Galleria masonry-style */
.foto-gallery {
    column-count: 2;
    column-gap: 10px;
    margin-top: 4px;
}
.foto-item {
    break-inside: avoid;
    display: inline-block;   /* fondamentale per masonry column-count */
    width: 100%;
    position: relative;
    margin-bottom: 10px;
    border-radius: 10px;
    overflow: hidden;        /* clip tutto dentro la card */
    background: #f1f5f9;
    border: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    cursor: default;
    vertical-align: top;
}
.foto-img-wrap {
    position: relative;
    display: block;
    width: 100%;
    overflow: hidden;
}
.foto-img {
    width: 100%;
    display: block;
    border-radius: 0;        /* la card stessa ha border-radius */
    transition: transform 0.25s;
}
.foto-item:hover .foto-img { transform: scale(1.03); }
.foto-overlay {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.6));
    padding: 20px 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.2s;
    border-radius: 0 0 10px 10px;
}
.foto-item:hover .foto-overlay { opacity: 1; }
.foto-meta-name { font-size: 11px; font-weight: 700; color: #fff; }
.foto-meta-date { font-size: 10px; color: rgba(255,255,255,0.8); }

/* Pulsante elimina */
.foto-del-btn {
    position: absolute;
    top: 6px; right: 6px;
    width: 26px; height: 26px;
    border-radius: 50%;
    background: rgba(0,0,0,0.55);
    color: #fff;
    border: none;
    font-size: 13px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 5;
}
.foto-item:hover .foto-del-btn { opacity: 1; }

.foto-empty {
    grid-column: 1/-1;
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
    font-size: 15px;
}

/* Controllo colonne */
.foto-cols-ctrl {
    display: flex;
    align-items: center;
    gap: 4px;
}
.foto-col-btn {
    width: 32px; height: 32px;
    border: 1.5px solid var(--border);
    background: #fff;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.12s;
    color: var(--text-muted);
    touch-action: manipulation;  /* iOS: niente double-tap zoom */
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
.foto-col-btn:hover  { background: #f1f5f9; color: var(--text-primary); }
.foto-col-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Lightbox */
.foto-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(5,10,20,0.95);
    z-index: 2000;
    display: flex;
    align-items: stretch;
    justify-content: center;
}
.lb-close {
    position: fixed;
    top: 14px; right: 14px;
    width: 36px; height: 36px;
    background: rgba(255,255,255,0.15);
    border: none; border-radius: 50%;
    color: #fff; font-size: 18px;
    cursor: pointer; z-index: 10;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s;
}
.lb-close:hover { background: rgba(255,255,255,0.28); }

/* Layout a 2 colonne */
.lb-layout {
    display: flex;
    width: 100%;
    max-width: 1200px;
    align-items: stretch;
}

/* Colonna sinistra: immagine */
.lb-left {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 24px 12px;
    min-width: 0;
}
.lb-img-wrap {
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 100%;
}
.lb-img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 8px;
    object-fit: contain;
    box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}
.lb-nav {
    position: absolute;
    top: 50%; transform: translateY(-50%);
    width: 42px; height: 42px;
    background: rgba(255,255,255,0.12);
    border: none; border-radius: 50%;
    color: #fff; font-size: 26px;
    cursor: pointer; z-index: 5;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s;
}
.lb-nav:hover { background: rgba(255,255,255,0.25); }
.lb-prev { left: 8px; }
.lb-next { right: 8px; }

/* Colonna destra: commenti */
.lb-right {
    width: 320px;
    flex-shrink: 0;
    background: #fff;
    display: flex;
    flex-direction: column;
    border-left: 1px solid #e2e8f0;
}
.lb-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px 16px 12px;
    border-bottom: 1px solid #f1f5f9;
    color: #475569;
    font-size: 12px;
}
.lb-info span { font-weight: 600; }
.lb-download {
    color: var(--accent); text-decoration: none;
    font-weight: 700; font-size: 12px; margin-top: 4px;
}
.lb-download:hover { text-decoration: underline; }

.lb-comments-title {
    padding: 10px 16px 8px;
    font-size: 13px; font-weight: 700; color: var(--primary);
    border-bottom: 1px solid #f1f5f9;
    display: flex; align-items: center; gap: 8px;
}
.lb-cmt-badge {
    background: var(--accent); color: #fff;
    font-size: 10px; padding: 1px 7px; border-radius: 10px;
    font-weight: 700;
}

.lb-comments-list {
    flex: 1; overflow-y: auto;
    padding: 8px 12px;
    display: flex; flex-direction: column; gap: 8px;
}
.lb-cmt-loading, .lb-cmt-empty {
    text-align: center; color: #94a3b8;
    font-size: 13px; padding: 20px 0;
}
.lb-cmt-item {
    background: #f8fafc; border: 1px solid #e2e8f0;
    border-radius: 8px; padding: 8px 10px;
}
.lb-cmt-header {
    display: flex; align-items: center; gap: 6px; margin-bottom: 3px;
}
.lb-cmt-author { font-size: 12px; font-weight: 700; color: var(--primary); flex: 0 0 auto; }
.lb-cmt-date   { font-size: 11px; color: #94a3b8; flex: 1; }
.lb-cmt-del {
    background: none; border: none; cursor: pointer;
    color: #cbd5e1; font-size: 11px; padding: 1px 3px;
    border-radius: 4px; transition: all 0.12s; flex-shrink: 0;
}
.lb-cmt-del:hover { background: #fff1f2; color: #e11d48; }
.lb-cmt-text   { font-size: 13px; color: #475569; line-height: 1.45; word-break: break-word; }

.lb-comment-input-row {
    display: flex; gap: 8px;
    padding: 10px 12px 14px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
}
.lb-comment-input-row input {
    flex: 1; padding: 8px 12px;
    border: 1.5px solid #e2e8f0; border-radius: 8px;
    font-size: 13px; outline: none;
    transition: border-color 0.15s;
}
.lb-comment-input-row input:focus { border-color: var(--accent); }
.lb-comment-input-row .btn-primary { flex-shrink: 0; padding: 8px 12px; font-size: 13px; }

/* Mobile iOS: lightbox a schermo intero stabile */
@media (max-width: 700px) {
    /* Usa dvh (dynamic viewport height) per iOS Safari che cambia
       altezza quando compare/sparisce la tastiera */
    .foto-lightbox {
        position: fixed;
        inset: 0;
        height: 100dvh;          /* si adatta alla tastiera */
        overflow: hidden;
        align-items: flex-start;
    }

    .lb-layout {
        flex-direction: column;
        height: 100dvh;
        overflow: hidden;
    }

    /* Immagine: occupa spazio fisso in alto */
    .lb-left {
        flex: 0 0 auto;
        padding: 48px 8px 8px;
        height: 38dvh;
        min-height: unset;
    }
    .lb-img { max-height: 36dvh; }
    .lb-nav { width: 38px; height: 38px; font-size: 22px; }

    /* Pannello commenti: occupa tutto il resto e gestisce la tastiera */
    .lb-right {
        flex: 1 1 auto;
        width: 100%;
        border-left: none;
        border-top: 1px solid #e2e8f0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        min-height: 0;
    }
    .lb-comments-list {
        flex: 1 1 auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        max-height: none;
    }
    /* Input fisso in fondo — non si sposta con la tastiera */
    .lb-comment-input-row {
        flex-shrink: 0;
        position: relative;      /* NON fixed: rimane nel flusso normale */
        padding: 10px 12px 10px;
    }
    .lb-comment-input-row input {
        font-size: 16px;         /* >= 16px: iOS non zooma al focus */
    }
}

@media (max-width: 600px) {
    /* column-count gestito da style inline — non forzare qui */
    /* foto-cols-ctrl visibile */
    .foto-del-btn  { opacity: 1; }
    .foto-overlay  { opacity: 1; }
    .lb-nav { width: 36px; height: 36px; font-size: 20px; }
    .lb-img { max-height: 70vh; }
}

/* ── Barra azioni sotto la foto ── */
.foto-actions-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: #fff;
    border-top: 1px solid var(--border);
    min-height: 36px;
}
.foto-btn-comment {
    display: flex;
    align-items: center;
    gap: 5px;
    background: #eff6ff;
    border: 1.5px solid #bfdbfe;
    cursor: pointer;
    font-size: 12px;
    color: var(--accent);
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 700;
    transition: background 0.12s, box-shadow 0.12s;
    white-space: nowrap;
}
.foto-btn-comment:hover { background: #dbeafe; box-shadow: 0 1px 4px rgba(37,99,235,0.15); }
.foto-del-btn-bar {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 15px;
    padding: 4px 6px;
    border-radius: 6px;
    color: #94a3b8;
    transition: background 0.12s, color 0.12s;
    line-height: 1;
}
.foto-del-btn-bar:hover { background: #fff1f2; color: #e11d48; }

/* ── Badge commenti sull'immagine ── */
.foto-comment-badge {
    position: absolute;
    top: 7px; left: 7px;
    background: rgba(37,99,235,0.88);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 7px;
    border-radius: 20px;
    pointer-events: none;
    backdrop-filter: blur(4px);
    box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

/* ── Modal commenti foto ── */
.modal-comments-box {
    width: 460px;
    max-width: 95vw;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
}
.comment-photo-thumb {
    text-align: center;
    padding: 10px 0 6px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
}
.comment-photo-thumb img {
    max-height: 140px;
    max-width: 100%;
    border-radius: 8px;
    object-fit: contain;
    box-shadow: 0 2px 10px rgba(0,0,0,0.12);
}
.comments-list {
    flex: 1;
    overflow-y: auto;
    min-height: 80px;
    max-height: 320px;
    padding: 2px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.comments-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    padding: 24px 0;
}
.comment-item {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 9px 12px;
    overflow: hidden;
}
.comment-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.comment-author {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary);
}
.comment-date {
    font-size: 11px;
    color: var(--text-muted);
    flex: 1;
}
.comment-del {
    background: none;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    font-size: 11px;
    padding: 1px 4px;
    border-radius: 4px;
    transition: all 0.12s;
}
.comment-del:hover { background: #fff1f2; color: #e11d48; }
.comment-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    word-break: break-word;
}
.comment-input-row {
    display: flex;
    gap: 8px;
    padding: 12px 16px 14px;
    border-top: 1px solid var(--border);
    background: #fff;
}
.comment-input-row input {
    flex: 1;
    padding: 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s;
}
.comment-input-row input:focus { border-color: var(--accent); }
.comment-input-row .btn-primary { flex-shrink: 0; padding: 9px 14px; }

/* ── Filtri temporali foto ── */
.foto-filter-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
    padding: 8px 12px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.foto-filter-mode { display: flex; gap: 4px; }
.foto-filter-btn {
    padding: 5px 14px;
    border: 1.5px solid var(--border);
    background: #fff;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.12s;
    white-space: nowrap;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
.foto-filter-btn:hover  { border-color: var(--accent); color: var(--accent); background: #eff6ff; }
.foto-filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Navigatore ‹ Periodo › */
.foto-period-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: 20px;
    padding: 2px 4px;
}
.foto-nav-btn {
    width: 28px; height: 28px;
    border: none; background: none;
    border-radius: 50%;
    font-size: 20px; line-height: 1;
    cursor: pointer; color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    transition: background 0.12s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.foto-nav-btn:hover:not(:disabled) { background: #f1f5f9; }
.foto-period-label {
    font-size: 12px; font-weight: 700;
    color: var(--primary);
    min-width: 140px; text-align: center;
    padding: 0 4px;
}

.foto-filter-sep   { width: 1px; height: 22px; background: var(--border); margin: 0 2px; }
.foto-filter-count { font-size: 11px; color: var(--text-muted); font-weight: 600; margin-left: auto; }

.foto-filter-group-label {
    display: flex; align-items: center;
    gap: 6px; font-size: 12px; color: var(--text-muted); font-weight: 600;
}
.foto-filter-group-label select {
    padding: 4px 8px;
    border: 1.5px solid var(--border); border-radius: 8px;
    font-size: 12px; background: #fff; cursor: pointer;
    color: var(--text-primary); outline: none;
}
.foto-filter-group-label select:focus { border-color: var(--accent); }

/* ── Gruppi data ── */
.foto-group { margin-bottom: 28px; }
.foto-group-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border);
}
.foto-group-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: capitalize;
}
.foto-group-count {
    font-size: 11px;
    color: var(--text-muted);
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}
.foto-gallery-group { margin: 0; }

@media (max-width: 600px) {
    .foto-filter-bar { gap: 5px; padding: 8px 10px; }
    .foto-filter-btn { padding: 4px 9px; font-size: 11px; }
    .foto-filter-sep,
    .foto-filter-group-label span { display: none; }
    .foto-filter-count { font-size: 10px; }
}

/* ============================================================
   31. MOBILE RESPONSIVE — fix globale
   ============================================================ */

/* ── Header: layout a 2 righe su mobile ─────────────────── */
@media (max-width: 640px) {

    /* Rimuovi altezza fissa, lascia crescere */
    .header-inner {
        height: auto;
        min-height: 56px;
        padding: 0 14px;
        flex-wrap: wrap;
        gap: 0;
        row-gap: 0;
    }

    /* Prima riga: brand a sinistra, logout a destra */
    .header-brand {
        font-size: 15px;
        gap: 7px;
        flex: 1;
        min-width: 0;
    }
    .logo-icon-sm { font-size: 16px; }

    /* Bottone Esci sempre visibile — sposta nella prima riga */
    .header-user {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-shrink: 0;
        order: 2;
    }
    .user-name {
        font-size: 12px;        /* compatto ma visibile */
        max-width: 90px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .badge-admin {
        display: inline-block;
        font-size: 9px;
        padding: 2px 5px;
    }
    .btn-logout {
        padding: 6px 12px;
        font-size: 12px;
        white-space: nowrap;
    }

    /* Seconda riga: pulsantini admin full-width */
    .header-admin-btns {
        order: 3;
        width: 100%;
        display: flex;
        gap: 6px;
        padding: 6px 0 8px;
        flex-wrap: wrap;
    }
    .header-admin-btns:empty { display: none; }
    .btn-header-admin {
        font-size: 11px;
        padding: 5px 10px;
        flex: 1;
        text-align: center;
        justify-content: center;
    }

    /* back-btn nell'header pagine interne */
    .header-brand .back-btn {
        font-size: 20px;
        padding: 2px 4px;
    }
}

/* ── Dashboard ───────────────────────────────────────────── */
@media (max-width: 640px) {
    .portal-main { padding: 16px 12px; }

    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 18px;
    }
    .dashboard-header h2 { font-size: 18px; }
    .dashboard-header .btn-secondary { width: 100%; text-align: center; }

    /* Griglia progetti: 1 colonna, card più compatta */
    .projects-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .project-card {
        padding: 16px;
        gap: 8px;
    }
    .project-name { font-size: 15px; }
    .project-icon { font-size: 22px; }
    .btn-project  { display: block; text-align: center; padding: 10px; font-size: 14px; }
}

/* ── Hub Progetto (section-tiles) ────────────────────────── */
@media (max-width: 640px) {
    .breadcrumb { font-size: 11px; margin-bottom: 12px; }

    .project-header-bar {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 16px;
    }
    .project-title   { font-size: 18px; }
    .project-subtitle{ font-size: 12px; }

    .section-tile {
        padding: 14px 12px;
        gap: 10px;
    }
    .section-tile-icon { font-size: 24px; min-width: 36px; }
    .section-tile-body h3  { font-size: 14px; }
    .section-tile-body p   { font-size: 12px; display: none; } /* nasconde descrizione per compattezza */
    .section-tile-arrow    { font-size: 20px; }

    /* Badge notifiche sulla tile */
    .tile-badge { font-size: 10px; padding: 2px 6px; }
}

/* ── Lista attività ──────────────────────────────────────── */
@media (max-width: 640px) {
    .act-list-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .act-list-header > div:last-child {
        display: flex;
        gap: 8px;
        width: 100%;
    }
    .act-list-header .btn-primary,
    .act-list-header .btn-secondary {
        flex: 1;
        text-align: center;
        justify-content: center;
        padding: 9px 8px;
        font-size: 13px;
    }

    /* Tabella attività → layout a card */
    .activities-table { display: none; }

    .act-cards-mobile {
        display: flex !important;
        flex-direction: column;
        gap: 10px;
    }
}
/* Desktop: nasconde la versione mobile card */
.act-cards-mobile { display: none; }

/* ── Dettaglio attività ───────────────────────────────────── */
@media (max-width: 640px) {
    .act-detail-header {
        flex-direction: column;
        gap: 8px;
    }
    .act-detail-meta {
        flex-wrap: wrap;
        gap: 6px;
    }
    .act-detail-meta > * { font-size: 12px; }

    /* Note / form commento */
    .note-form { flex-direction: column; gap: 8px; }
    .note-form .btn-primary { width: 100%; }

    /* File allegati */
    .file-drop-zone { padding: 18px 12px; }
    .file-drop-zone .drop-icon { font-size: 28px; }
}

/* ── Documenti ───────────────────────────────────────────── */
@media (max-width: 640px) {
    .docs-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .doc-list-item {
        flex-direction: column;
        gap: 6px;
        align-items: flex-start;
    }
    .doc-actions {
        display: flex;
        gap: 6px;
        width: 100%;
    }
    .doc-actions .btn-sm { flex: 1; text-align: center; }
}

/* ── Modal ───────────────────────────────────────────────── */
@media (max-width: 640px) {
    .modal-box {
        width: 96vw !important;
        max-height: 88vh;
        margin: 8px;
        border-radius: 14px;
    }
    .modal-header { padding: 14px 16px; }
    .modal-form-body { padding: 14px 16px; }
    .modal-footer { padding: 12px 16px; gap: 8px; }
    .modal-footer .btn-primary,
    .modal-footer .btn-secondary { flex: 1; }
}

/* ── Note progetto ───────────────────────────────────────── */
@media (max-width: 640px) {
    .note-card { padding: 14px; }
    .note-card-header { flex-wrap: wrap; gap: 6px; }
    .note-actions { gap: 4px; }
    .note-actions .btn-sm { padding: 5px 8px; font-size: 11px; }
}

/* ── Foto ────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .foto-filter-bar {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 5px;
        padding: 8px 10px;
    }
    .foto-filter-bar::-webkit-scrollbar { display: none; }
    .foto-filter-btn  { flex-shrink: 0; font-size: 11px; padding: 5px 10px; }
    .foto-filter-sep  { display: none; }
    .foto-filter-count{ display: none; }
    .foto-filter-group-label { flex-shrink: 0; }
    .foto-filter-group-label span { display: none; }

    /* foto-cols-ctrl visibile anche su mobile */

    /* Lightbox mobile */
    .lb-img { max-height: 60vh; border-radius: 6px; }
    .lb-info { font-size: 11px; flex-wrap: wrap; justify-content: center; gap: 8px; }
    .lb-nav  { width: 36px; height: 36px; font-size: 22px; }
    .lb-prev { left: 6px; }
    .lb-next { right: 6px; }

    .comment-photo-thumb img { max-height: 100px; }
    .comments-list { max-height: 220px; }
}

/* ── Generali utility mobile ─────────────────────────────── */
@media (max-width: 640px) {
    /* Bottoni affiancati → full-width stack */
    .btn-row-mobile {
        flex-direction: column !important;
        width: 100%;
    }
    .btn-row-mobile > * { width: 100% !important; text-align: center; }

    /* Testi troncati su card */
    .truncate-mobile {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 200px;
    }

    /* Footer più compatto */
    .portal-footer { font-size: 11px; padding: 14px; }
}

/* ── Anteprima upload in corso ── */
.foto-item-uploading .foto-img { filter: brightness(0.7); }
.foto-upload-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.25);
    border-radius: 10px 10px 0 0;
}
.foto-spinner {
    width: 32px; height: 32px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════════════════
   §32  Modal di conferma globale (sdConfirm)
   ═══════════════════════════════════════════════════════════ */
.sd-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 20, 40, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.sd-modal-box {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25), 0 2px 8px rgba(0,0,0,0.1);
    padding: 32px 28px 24px;
    max-width: 360px;
    width: 100%;
    text-align: center;
    transform: scale(0.92) translateY(12px);
    opacity: 0;
    transition: transform 0.18s cubic-bezier(.34,1.4,.64,1), opacity 0.15s ease;
}
.sd-modal-overlay.sd-in .sd-modal-box  { transform: scale(1) translateY(0); opacity: 1; }
.sd-modal-overlay.sd-out .sd-modal-box { transform: scale(0.94) translateY(8px); opacity: 0; }

.sd-modal-icon  { font-size: 40px; margin-bottom: 10px; line-height: 1; }
.sd-modal-title { font-size: 18px; font-weight: 800; color: var(--primary); margin-bottom: 8px; }
.sd-modal-msg   { font-size: 14px; color: var(--text-muted); line-height: 1.5; margin-bottom: 24px; min-height: 18px; }

.sd-modal-btns  { display: flex; gap: 10px; justify-content: center; }
.sd-btn-cancel  {
    flex: 1; padding: 10px 0;
    border: 1.5px solid var(--border);
    background: #fff; border-radius: 10px;
    font-size: 14px; font-weight: 600;
    color: var(--text-muted); cursor: pointer;
    transition: all 0.12s;
    touch-action: manipulation;
}
.sd-btn-cancel:hover { border-color: #94a3b8; color: var(--text-primary); background: #f8fafc; }

.sd-btn-confirm {
    flex: 1; padding: 10px 0;
    border: none;
    background: var(--accent); border-radius: 10px;
    font-size: 14px; font-weight: 700;
    color: #fff; cursor: pointer;
    transition: all 0.12s;
    touch-action: manipulation;
}
.sd-btn-confirm:hover  { filter: brightness(1.08); }
.sd-btn-confirm.sd-btn-danger { background: #e11d48; }
.sd-btn-confirm.sd-btn-danger:hover { background: #be123c; }

@media (max-width: 420px) {
    .sd-modal-box  { padding: 24px 18px 20px; }
    .sd-modal-icon { font-size: 34px; }
    .sd-modal-title{ font-size: 16px; }
    .sd-modal-btns { flex-direction: column-reverse; }
    .sd-btn-cancel, .sd-btn-confirm { padding: 12px 0; }
}

/* ── Sotto-attività inline nell'accordion ── */
.acc-subs-wrap {
    margin: 4px 0 6px;
    padding: 0 12px;
}
.acc-subs-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.acc-subs-title { font-size: 12px; font-weight: 700; color: var(--primary); }
.acc-subs-count { font-size: 11px; color: var(--text-muted); }
.acc-subs-bar   { flex: 1; height: 5px; background: #e2e8f0; border-radius: 99px; overflow: hidden; }
.acc-subs-fill  { height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.3s; }
.acc-sub-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 4px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
}
.acc-sub-item:last-child { border-bottom: none; }
.acc-sub-check { font-size: 14px; flex-shrink: 0; color: var(--text-muted); }
.acc-sub-done .acc-sub-check { color: #22c55e; }
.acc-sub-title  { flex: 1; color: var(--text-primary); }
.acc-sub-done .acc-sub-title { text-decoration: line-through; color: var(--text-muted); }
.acc-sub-by     { font-size: 10px; color: #94a3b8; flex-shrink: 0; }

/* ── Toggle commenti collassabile ── */
.acc-comments-section { margin: 4px 0 0; }
.acc-comments-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    text-align: left;
    transition: background 0.12s;
    touch-action: manipulation;
}
.acc-comments-toggle:hover { background: #eff6ff; }
.acc-comments-toggle-label { display: flex; align-items: center; gap: 6px; }
.acc-comments-chevron { font-size: 18px; color: var(--text-muted); transition: transform 0.2s; }
.acc-comments-chevron.open { transform: rotate(90deg); }
.acc-comments-body { border: 1px solid var(--border); border-top: none; border-radius: 0 0 8px 8px; }

/* ── Icona dettaglio nell'header accordion ── */
.acc-detail-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px; height: 28px;
    border-radius: 6px;
    background: #f1f5f9;
    color: var(--accent);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    flex-shrink: 0;
    transition: background 0.12s, color 0.12s;
    touch-action: manipulation;
}
.acc-detail-icon:hover { background: var(--accent); color: #fff; }

/* ── Pallino non-letto sulla chip commenti ── */
.acc-unread-dot {
    display: inline-block;
    width: 7px; height: 7px;
    background: #e11d48;
    border-radius: 50%;
    vertical-align: middle;
    margin-left: 3px;
    flex-shrink: 0;
}

/* ── Input aggiunta sotto-attività inline ── */
.acc-addsub-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px 8px;
}
.acc-addsub-input {
    flex: 1;
    padding: 6px 10px;
    border: 1.5px dashed var(--border);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-primary);
    background: #f8fafc;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
}
.acc-addsub-input::placeholder { color: #94a3b8; }
.acc-addsub-input:focus {
    border-color: var(--accent);
    border-style: solid;
    background: #fff;
}
.acc-addsub-btn {
    width: 28px; height: 28px;
    border: none;
    background: var(--accent);
    color: #fff;
    border-radius: 7px;
    font-size: 14px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.12s;
    touch-action: manipulation;
}
.acc-addsub-btn:hover  { background: #1d4ed8; }
.acc-addsub-btn:disabled { opacity: 0.5; cursor: default; }

/* ── Pulsante torna all'elenco (AttivitaDetail) ── */
.btn-back-list {
    margin-left: auto;
    padding: 4px 12px;
    background: #f1f5f9;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.12s, border-color 0.12s;
    touch-action: manipulation;
}
.btn-back-list:hover { background: #e2e8f0; border-color: #94a3b8; }
