:root {
      --bg-color: #f8fafc;
      --card-bg: #ffffff;
      --text-main: #0f172a;
      --text-muted: #64748b;
      --border-color: #e2e8f0;
      
      /* Input & Dropdowns */
      --input-bg: #ffffff;
      --input-text: #0f172a;
      --input-border: #cbd5e1;

      /* Righe Tabella Alternate */
      --table-row-even: #ffffff;
      --table-row-odd: #f8fafc;
      --table-row-hover: #f1f5f9;

      --primary: #3b82f6;
      --primary-hover: #2563eb;
      --warning: #f59e0b;
      --warning-hover: #d97706;
      --danger: #ef4444;
      --danger-hover: #dc2626;
      --success: #10b981;
      --archive: #8b5cf6;
      --radius: 10px;
      --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    }

    * { box-sizing: border-box; font-family: 'Inter', sans-serif; margin: 0; padding: 0; }
    body { 
      background-color: var(--bg-color); 
      color: var(--text-main); 
      padding: 15px; 
      overflow-x: hidden; 
      transition: background-color 0.3s ease, color 0.3s ease; 
    }
    
    .container { max-width: 1400px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; width: 100%; }

    /* Modal / Form Login */
    .login-overlay {
      position: fixed;
      top: 0; left: 0; width: 100vw; height: 100vh;
      background: rgba(15, 23, 42, 0.75);
      backdrop-filter: blur(4px);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 9999;
    }
    .login-card {
      background: var(--card-bg);
      padding: 30px;
      border-radius: var(--radius);
      box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
      width: 100%;
      max-width: 420px;
      display: flex;
      flex-direction: column;
      gap: 16px;
      border: 1px solid var(--border-color);
    }
    .login-card h2 { text-align: center; color: var(--text-main); font-size: 1.4rem; }
    
    /* Header Responsive con Logo ed Ente */
    .header { 
      display: flex; 
      flex-direction: column; 
      gap: 15px; 
      border-bottom: 2px solid var(--border-color); 
      padding-bottom: 15px; 
    }
    @media (min-width: 768px) {
      .header { flex-direction: row; justify-content: space-between; align-items: center; }
    }
    
    .brand-container {
      display: flex;
      align-items: center;
      gap: 12px;
    }

    .ente-logo-wrapper {
      background-color: #ffffff;
      padding: 4px 8px;
      border-radius: 8px;
      border: 1px solid var(--border-color);
      display: inline-flex;
      align-items: center;
      justify-content: center;
      max-height: 52px;
      box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    }

    .ente-logo-img {
      max-height: 44px;
      max-width: 120px;
      object-fit: contain;
      display: block;
    }

    .header-titles {
      display: flex;
      flex-direction: column;
    }

    .header h1 { font-size: 1.5rem; font-weight: 700; color: var(--text-main); line-height: 1.2; }
    .ente-nome-text { font-size: 0.85rem; font-weight: 600; color: var(--primary); text-transform: uppercase; letter-spacing: 0.04em; }
    
    .user-info-bar {
      display: flex;
      align-items: center;
      gap: 10px;
      background: var(--card-bg);
      padding: 6px 12px;
      border-radius: 8px;
      border: 1px solid var(--border-color);
      font-size: 0.82rem;
      color: var(--text-main);
    }
    .role-badge {
      padding: 2px 8px;
      border-radius: 12px;
      font-size: 0.72rem;
      font-weight: 700;
      text-transform: uppercase;
    }
    .role-admin { background: #fee2e2; color: #dc2626; }
    .role-dirigente { background: #fef3c7; color: #d97706; }
    .role-operator { background: #dbeafe; color: #2563eb; }
    .role-operator_self, .role-operator_sector { background: #dbeafe; color: #2563eb; }

    .tabs {
      white-space: nowrap; display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; width: 100%; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
    .tab-btn {
      flex: 0 0 auto;
      white-space: nowrap;
      text-align: center;
      background: var(--card-bg);
      border: 1px solid var(--border-color);
      padding: 8px 11px;
      font-size: 0.80rem;
      line-height: 1.2;
      font-weight: 600;
      color: var(--text-muted);
      cursor: pointer;
      border-radius: var(--radius);
      transition: all 0.2s ease;
    }
    .tab-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
    .tab-btn:hover:not(.active) { background: var(--table-row-hover); color: var(--text-main); }
    .tab-btn-action { font-weight: 700; }
    .tab-btn-icon { min-width: 38px; width: 38px; padding-left: 8px; padding-right: 8px; font-size: 1rem; }
    .tab-btn-action:hover { transform: translateY(-1px); }

    .tab-content { display: none; }
    .tab-content.active { display: flex; flex-direction: column; gap: 20px; }

    /* Cards */
    .card {
      background: var(--card-bg);
      padding: 18px;
      border-radius: var(--radius);
      box-shadow: var(--shadow-md);
      border: 1px solid var(--border-color);
      width: 100%;
    }
    @media (min-width: 768px) { .card { padding: 24px; } }

    .card-compact { padding: 14px 18px !important; }

    .card-title {
      font-size: 1.1rem;
      font-weight: 600;
      margin-bottom: 18px;
      color: var(--text-main);
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      align-items: center;
      justify-content: space-between;
    }

    .card-compact .card-title { margin-bottom: 10px; }

    /* Form Responsive */
    .form-grid {
      display: grid;
      grid-template-columns: 1fr;
      gap: 10px;
      align-items: flex-end;
    }
    @media (min-width: 576px) { .form-grid { grid-template-columns: repeat(2, 1fr); } }
    @media (min-width: 992px) { .form-grid { grid-template-columns: repeat(4, 1fr); } }

    .form-group { display: flex; flex-direction: column; gap: 3px; }
    .form-group.full-width { grid-column: 1 / -1; }

    label { font-size: 0.72rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
    
    input, select, textarea {
      padding: 8px 10px;
      border: 1px solid var(--input-border);
      border-radius: 6px;
      font-size: 0.85rem;
      background-color: var(--input-bg) !important;
      color: var(--input-text) !important;
      outline: none;
      width: 100%;
      transition: border-color 0.2s, box-shadow 0.2s;
    }

    select option {
      background-color: #ffffff !important;
      color: #0f172a !important;
    }

    textarea#oggetto {
      resize: vertical;
      min-height: 55px;
      max-height: 250px;
      line-height: 1.4;
    }

    textarea#commentoFinale {
      resize: vertical;
      min-height: 45px;
      max-height: 180px;
      line-height: 1.35;
    }

    input[type="color"] {
      padding: 2px 4px;
      height: 36px;
      cursor: pointer;
    }

    input:focus, select:focus, textarea:focus {
      border-color: var(--primary);
      box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
    }

    .action-group-inline {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      width: 100%;
      min-height: 36px;
    }

    .checkbox-container {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      cursor: pointer;
      font-size: 0.85rem;
      font-weight: 600;
      color: var(--text-main);
      user-select: none;
    }
    .checkbox-container input { width: 16px; height: 16px; cursor: pointer; }

    /* BARRA FILTRI RESPONSIVA */
    .filters-row {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      background: var(--table-row-odd);
      padding: 12px;
      border-radius: 8px;
      border: 1px solid var(--border-color);
      margin-bottom: 18px;
      align-items: flex-end;
      width: 100%;
    }

    .filter-item {
      display: flex;
      flex-direction: column;
      gap: 3px;
      flex: 1 1 130px;
      min-width: 110px;
    }

    .filter-item.filter-search {
      flex: 2 1 180px;
      min-width: 160px;
    }

    .filter-item input,
    .filter-item select {
      padding: 6px 8px;
      font-size: 0.82rem;
    }

    /* Buttons */
    .btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 7px 12px;
      border: none;
      border-radius: 6px;
      font-size: 0.85rem;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.2s;
      gap: 4px;
      text-decoration: none;
      white-space: nowrap;
    }
    .btn-sm { padding: 4px 8px; font-size: 0.78rem; }
    .btn-icon-only { width: 30px; min-width: 30px; height: 30px; padding: 4px; display: inline-flex; align-items: center; justify-content: center; }
    .btn-primary { background: var(--primary); color: white; }
    .btn-primary:hover { background: var(--primary-hover); }
    .btn-warning { background: #fef3c7; color: var(--warning-hover); }
    .btn-warning:hover { background: var(--warning); color: white; }
    .btn-danger { background: #fee2e2; color: var(--danger); }
    .btn-danger:hover { background: var(--danger); color: white; }
    .btn-secondary { background: #e2e8f0; color: #1e293b; }
    .btn-secondary:hover { background: #cbd5e1; }
    .btn-success { background: #dcfce7; color: #15803d; }
    .btn-success:hover { background: var(--success); color: white; }
    
    .btn-archive { background: #f3e8ff; color: #6b21a8; }
    .btn-archive:hover { background: #8b5cf6; color: white; }

    .btn-highlight { background: #fef9c3; color: #854d0e; border: 1px solid #fde047; }
    .btn-highlight:hover { background: #fde047; }
    .btn-highlight.active { background: #eab308; color: white; border-color: #ca8a04; }

    .actions-cell { 
      display: flex; 
      gap: 4px; 
      flex-wrap: nowrap !important; 
      align-items: center;
      white-space: nowrap;
    }

    /* TABELLA CON SFONDO RIGHE ALTERNATO */
    .table-responsive { overflow-x: auto; margin-top: 10px; border-radius: 6px; width: 100%; border: 1px solid var(--border-color); }
    table { width: 100%; border-collapse: collapse; font-size: 0.85rem; text-align: left; }

    /* v116.7 - tabella Task in Lavorazione: occupa sempre lo spazio disponibile,
       senza scrollbar orizzontale. La distribuzione viene adattata ai breakpoint. */
    .active-tasks-table { overflow-x: hidden; width: 100%; }
    .active-tasks-table table { table-layout: fixed; width: 100%; min-width: 0; }
    .active-tasks-table th,
    .active-tasks-table td { box-sizing: border-box; min-width: 0; }
    /* Distribuzione desktop: l'area Azioni ha spazio reale per tutti i comandi. */
    .active-tasks-table th:nth-child(1), .active-tasks-table td:nth-child(1) { width: 27%; }
    .active-tasks-table th:nth-child(2), .active-tasks-table td:nth-child(2) { width: 14%; }
    .active-tasks-table th:nth-child(3), .active-tasks-table td:nth-child(3) { width: 7%; }
    .active-tasks-table th:nth-child(4), .active-tasks-table td:nth-child(4) { width: 10%; }
    .active-tasks-table th:nth-child(5), .active-tasks-table td:nth-child(5) { width: 10%; }
    .active-tasks-table th:nth-child(6), .active-tasks-table td:nth-child(6) { width: 7%; }
    .active-tasks-table th:nth-child(7), .active-tasks-table td:nth-child(7) { width: 3%; text-align:center; }
    .active-tasks-table th:nth-child(8), .active-tasks-table td:nth-child(8) { width: 3%; text-align:center; }
    .active-tasks-table th:nth-child(9), .active-tasks-table td:nth-child(9) { width: 19%; }
    .active-tasks-table td:not(.oggetto-cell):not(.actions-cell) { overflow: hidden; text-overflow: ellipsis; }

    .table-icon-header {
      text-align: center !important;
      font-size: 1rem;
      padding-left: 4px !important;
      padding-right: 4px !important;
    }
    .table-icon-header:hover { color: var(--text-main); }
    /* Azioni: mai comprimere o ritagliare i pulsanti. L'allineamento a destra rende
       visibile l'intero gruppo anche quando la tabella si restringe. */
    .active-tasks-table .actions-cell,
    #tab-storico .actions-cell {
      width: 100%;
      min-width: 0;
      max-width: none;
      white-space: nowrap;
      display: flex;
      align-items: center;
      justify-content: flex-end;
      gap: 4px;
      overflow: visible;
      box-sizing: border-box;
    }
    .active-tasks-table .actions-cell .btn-icon-only,
    #tab-storico .actions-cell .btn-icon-only {
      flex: 0 0 27px;
      width: 27px;
      min-width: 27px;
      max-width: 27px;
      height: 27px;
      min-height: 27px;
      padding: 2px;
      box-sizing: border-box;
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }

    /* A tablet: Allegato e Link diventano solo icone nell'intestazione e le
       relative colonne vengono nascoste per lasciare spazio ai comandi. */
    @media (max-width: 1024px) {
      .active-tasks-table th:nth-child(7), .active-tasks-table td:nth-child(7),
      .active-tasks-table th:nth-child(8), .active-tasks-table td:nth-child(8) { display: none; }
      .active-tasks-table th:nth-child(1), .active-tasks-table td:nth-child(1) { width: 30%; }
      .active-tasks-table th:nth-child(2), .active-tasks-table td:nth-child(2) { width: 16%; }
      .active-tasks-table th:nth-child(3), .active-tasks-table td:nth-child(3) { width: 8%; }
      .active-tasks-table th:nth-child(4), .active-tasks-table td:nth-child(4) { width: 11%; }
      .active-tasks-table th:nth-child(5), .active-tasks-table td:nth-child(5) { width: 11%; }
      .active-tasks-table th:nth-child(6), .active-tasks-table td:nth-child(6) { width: 9%; }
      .active-tasks-table th:nth-child(9), .active-tasks-table td:nth-child(9) { width: 15%; }
    }

    @media (max-width: 860px) {
      .active-tasks-table th:nth-child(5), .active-tasks-table td:nth-child(5) { display: none; }
      .active-tasks-table th:nth-child(1), .active-tasks-table td:nth-child(1) { width: 32%; }
      .active-tasks-table th:nth-child(2), .active-tasks-table td:nth-child(2) { width: 18%; }
      .active-tasks-table th:nth-child(3), .active-tasks-table td:nth-child(3) { width: 9%; }
      .active-tasks-table th:nth-child(4), .active-tasks-table td:nth-child(4) { width: 13%; }
      .active-tasks-table th:nth-child(6), .active-tasks-table td:nth-child(6) { width: 13%; }
      .active-tasks-table th:nth-child(9), .active-tasks-table td:nth-child(9) { width: 15%; }
    }

    
    th {
      background-color: var(--table-row-odd);
      color: var(--text-muted);
      font-weight: 600;
      padding: 10px 12px;
      border-bottom: 2px solid var(--border-color);
      white-space: nowrap;
    }

    th.sortable {
      cursor: pointer;
      user-select: none;
      transition: background-color 0.2s;
    }
    th.sortable:hover {
      background-color: var(--table-row-hover);
      color: var(--text-main);
    }

    tbody tr:nth-child(even) { background-color: var(--table-row-even); }
    tbody tr:nth-child(odd) { background-color: var(--table-row-odd); }
    tbody tr:hover { background-color: var(--table-row-hover) !important; }

    td {
      padding: 10px 12px;
      border-bottom: 1px solid var(--border-color);
      color: var(--text-main);
      white-space: nowrap;
    }

    td.oggetto-cell {
      white-space: normal;
      width: 38% !important;
      min-width: 0 !important;
      max-width: none !important;
      line-height: 1.35;
      word-break: break-word;
      overflow: hidden;
    }

    .task-object-trigger {
      display: -webkit-box;
      width: 100%;
      max-width: 100%;
      margin: 0;
      padding: 0;
      border: 0;
      background: transparent;
      color: var(--text-main);
      font: inherit;
      font-size: inherit;
      line-height: 1.35;
      text-align: left;
      cursor: pointer;
      overflow: hidden;
      text-overflow: ellipsis;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      line-clamp: 2;
    }
    .task-object-trigger:hover,
    .task-object-trigger:focus-visible {
      text-decoration: underline;
      text-decoration-thickness: 1px;
      text-underline-offset: 2px;
      outline: none;
    }

    .task-object-mobile-trigger {
      display: inline;
      margin: 0;
      padding: 0;
      border: 0;
      background: transparent;
      color: inherit;
      font: inherit;
      text-align: left;
      cursor: pointer;
    }
    .task-object-mobile-trigger:focus-visible {
      outline: 2px solid var(--primary, #2563eb);
      outline-offset: 2px;
      border-radius: 3px;
    }


    .deadline-cell { white-space: nowrap; line-height: 1.15; }
    .deadline-cell span { display: block; }
    .deadline-cell small { display: block; font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }
    th:first-child, td:first-child { width: 52px; }
    .actions-cell { width: auto; }

    tr.task-highlighted {
      background-color: #fefce8 !important;
      border-left: 4px solid #eab308;
    }
    tr.task-highlighted td {
      color: #713f12 !important;
    }

    @media (max-width: 1024px) {
      .col-hide-md { display: none; }
    }

    /* Mobile Card Layout */
    .mobile-cards-container {
      display: none;
      flex-direction: column;
      gap: 12px;
      width: 100%;
    }

    .task-card-mobile {
      background: var(--card-bg);
      border: 1px solid var(--border-color);
      border-radius: 8px;
      padding: 14px;
      display: flex;
      flex-direction: column;
      gap: 8px;
      box-shadow: 0 1px 3px rgba(0,0,0,0.05);
      transition: all 0.2s;
    }
    
    .task-card-mobile.task-highlighted {
      background-color: #fefce8 !important;
      border: 2px solid #eab308;
      color: #713f12;
    }

    .task-card-mobile-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      border-bottom: 1px dashed var(--border-color);
      padding-bottom: 6px;
    }
    .task-card-mobile-body {
      display: flex;
      flex-direction: column;
      gap: 6px;
      font-size: 0.85rem;
    }
    .task-card-mobile-footer {
      display: flex;
      justify-content: flex-end;
      gap: 8px;
      padding-top: 8px;
      border-top: 1px solid var(--border-color);
      flex-wrap: wrap;
    }

    @media (max-width: 768px) {
      .table-desktop-only { display: none; }
      .mobile-cards-container { display: flex; }
      .header { gap: 10px; padding-bottom: 10px; }
      .brand-container { min-width: 0; }
      .header-titles { min-width: 0; }
      .header h1 { font-size: 1.2rem; }
      .user-info-bar { width: 100%; flex-wrap: wrap; }
      .tabs {
      white-space: nowrap; gap: 5px; padding-bottom: 3px; }
      .tab-btn { padding: 7px 9px; font-size: 0.76rem; }
      .tab-btn-icon { min-width: 36px; width: 36px; }
      .card { padding: 12px; }
      .filters-row { grid-template-columns: 1fr !important; }
      .filter-item[style] { border-left: 0 !important; border-top: 1px solid var(--border-color); padding-left: 0 !important; padding-top: 8px; }
      .task-card-mobile-footer .actions-cell { width: 100%; justify-content: flex-end; }
      .btn-icon-only { width: 34px; min-width: 34px; height: 34px; }
    }

    /* Badges */
    .badge {
      padding: 4px 8px;
      border-radius: 20px;
      font-size: 0.72rem;
      font-weight: 600;
      display: inline-block;
    }
    .badge-aperto { background: #3B82F6; color: #fff; }
    .badge-in-corso { background: #F59E0B; color: #fff; }
    .badge-in-revisione { background: #8B5CF6; color: #fff; }
    .badge-completato { background: #22C55E; color: #fff; }
    
    .badge-p-bassa { background: #f1f5f9; color: #475569; }
    .badge-p-media { background: #e0f2fe; color: #0369a1; }
    .badge-p-alta { background: #ffedd5; color: #c2410c; }
    .badge-p-urgente { background: #ffe4e6; color: #e11d48; }

    .operator-badge {
      padding: 3px 10px;
      border-radius: 12px;
      font-size: 0.75rem;
      font-weight: 600;
      display: inline-block;
    }

    .sector-badge {
      background: #e2e8f0;
      color: #334155;
      padding: 3px 8px;
      border-radius: 4px;
      font-size: 0.75rem;
      font-weight: 600;
    }

    .flex-row { display: flex; gap: 10px; align-items: flex-end; }
    .editing-banner {
      background-color: #fef3c7;
      color: #92400e;
      padding: 4px 10px;
      border-radius: 6px;
      font-size: 0.8rem;
      font-weight: 600;
      display: none;
      align-items: center;
      gap: 8px;
    }

    .restricted-banner {
      background-color: #fef2f2;
      border: 1px solid #fecaca;
      color: #991b1b;
      padding: 12px;
      border-radius: 6px;
      font-size: 0.85rem;
      font-weight: 500;
    }

    .file-tag {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      background: #e2e8f0;
      padding: 3px 8px;
      border-radius: 4px;
      font-size: 0.78rem;
      color: #334155;
      text-decoration: none;
      max-width: 140px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .file-tag:hover { background: #cbd5e1; }

    .link-preview {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      font-size: 0.75rem;
      font-weight: 600;
      color: var(--primary);
      text-decoration: underline;
      margin-top: 3px;
      word-break: break-all;
    }
    .link-preview:hover { color: var(--primary-hover); }

    /* Calendario Styles */
    .calendar-controls {
      display: flex;
      flex-wrap: wrap;
      gap: 12px;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 15px;
    }
    .calendar-controls h3 { font-size: 1.2rem; text-transform: capitalize; }
    
    .view-selector {
      display: flex;
      gap: 4px;
      background: var(--table-row-odd);
      padding: 3px;
      border-radius: 6px;
    }
    .view-btn {
      border: none;
      background: transparent;
      padding: 6px 12px;
      font-size: 0.8rem;
      font-weight: 600;
      border-radius: 4px;
      cursor: pointer;
      color: var(--text-muted);
    }
    .view-btn.active { background: var(--card-bg); color: var(--text-main); box-shadow: var(--shadow-md); }

    .calendar-grid-month {
      display: grid;
      grid-template-columns: repeat(7, 1fr);
      gap: 1px;
      background-color: var(--border-color);
      border: 1px solid var(--border-color);
      border-radius: 8px;
      overflow: hidden;
    }

    .calendar-day-name {
      background: var(--table-row-odd);
      padding: 10px 5px;
      text-align: center;
      font-weight: 600;
      font-size: 0.8rem;
      color: var(--text-muted);
    }

    .calendar-cell {
      background: var(--card-bg);
      min-height: 90px;
      padding: 6px;
      display: flex;
      flex-direction: column;
      gap: 4px;
    }
    .calendar-cell.other-month { opacity: 0.5; }
    .calendar-cell.today { background: #eff6ff; }

    .calendar-vertical-week {
      display: flex;
      flex-direction: column;
      gap: 10px;
    }

    .week-row {
      background: var(--card-bg);
      border: 1px solid var(--border-color);
      border-radius: 8px;
      padding: 10px 14px;
      display: flex;
      flex-direction: column;
      gap: 8px;
    }
    @media (min-width: 600px) {
      .week-row { flex-direction: row; align-items: flex-start; }
    }
    .week-row.today { background: #eff6ff; border-color: #bfdbfe; }

    .week-day-header {
      min-width: 140px;
      display: flex;
      flex-direction: column;
      gap: 2px;
    }

    .week-day-title { font-size: 0.95rem; font-weight: 700; color: var(--text-main); text-transform: capitalize; }
    .today .week-day-title { color: var(--primary); }

    .week-day-date { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; }

    .week-events-container {
      flex: 1;
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      min-height: 28px;
      align-items: center;
    }

    .empty-day-text { font-size: 0.78rem; color: var(--text-muted); font-style: italic; }

    .day-number { font-size: 0.8rem; font-weight: 700; color: var(--text-muted); margin-bottom: 2px; }
    .today .day-number { color: var(--primary); }

    .cal-event {
      padding: 5px 10px;
      border-radius: 6px;
      font-size: 0.78rem;
      font-weight: 600;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 8px;
      box-shadow: 0 1px 2px rgba(0,0,0,0.05);
      transition: transform 0.1s;
    }
    .cal-event:hover { transform: translateY(-1px); }
    .cal-event-time { font-size: 0.7rem; opacity: 0.85; font-weight: 500; }

    /* TEMI PREDEFINITI */
    body.theme-dark {
      --bg-color: #0f172a;
      --card-bg: #1e293b;
      --text-main: #f8fafc;
      --text-muted: #94a3b8;
      --border-color: #334155;
      
      --table-row-even: #1e293b;
      --table-row-odd: #0f172a;
      --table-row-hover: #334155;
    }
    body.theme-slate {
      --bg-color: #e2e8f0;
      --card-bg: #ffffff;
      --text-main: #0f172a;
      --text-muted: #475569;
      --border-color: #cbd5e1;

      --table-row-even: #ffffff;
      --table-row-odd: #f1f5f9;
      --table-row-hover: #e2e8f0;
    }
    body.theme-warm {
      --bg-color: #fef3c7;
      --card-bg: #fffbeb;
      --text-main: #451a03;
      --text-muted: #78350f;
      --border-color: #fde68a;

      --table-row-even: #fffbeb;
      --table-row-odd: #fef3c7;
      --table-row-hover: #fde68a;
    }
    body.theme-emerald {
      --bg-color: #d1fae5;
      --card-bg: #ecfdf5;
      --text-main: #064e3b;
      --text-muted: #047857;
      --border-color: #a7f3d0;

      --table-row-even: #ecfdf5;
      --table-row-odd: #d1fae5;
      --table-row-hover: #a7f3d0;
    }
.task-action-panel{display:flex;align-items:center;justify-content:space-between;gap:18px;padding:10px 0}
.task-action-help{font-size:.82rem;color:var(--text-muted);margin-top:4px}
@media(max-width:600px){.task-action-panel{flex-direction:column;align-items:stretch}.task-action-panel .btn{width:100%}}

/* v17: nome ente e nome applicativo sempre su una sola riga */
header .brand,
header .brand-title,
header .brand-subtitle,
header .app-title,
header .ente-name,
header .app-name,
header .nome-ente,
header .nome-applicativo,
header h1,
header h2 {
    white-space: nowrap !important;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

/* Evita che l'intestazione crei righe aggiuntive su schermi stretti */
header .brand,
header .brand-content,
header .header-brand {
    min-width: 0;
}

/* v18: login completamente opaco */
#loginOverlay {
    background: #f5f7fa !important;
    background-color: #f5f7fa !important;
    opacity: 1 !important;
}
#loginOverlay .login-card,
#loginOverlay .login-box,
#loginOverlay .login-container,
#loginOverlay .card {
    background: #ffffff !important;
    background-color: #ffffff !important;
    opacity: 1 !important;
}

/* v19: identità ente/applicativo nella schermata di login */
.login-identity {
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.login-logo-wrap {
  width: 100%;
  justify-content: center;
  align-items: center;
  margin-bottom: 4px;
}
.login-logo {
  display: block;
  max-width: 110px;
  max-height: 80px;
  width: auto;
  height: auto;
  object-fit: contain;
}
.login-ente-name,
.login-app-name {
  width: 100%;
  white-space: nowrap !important;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}
.login-ente-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}
.login-app-name {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--primary);
}

/* v20: intestazione desktop/mobile - ente e applicativo su una sola riga */
.app-header, .top-header, header {
  min-width: 0;
}
.app-header *, .top-header *, header * {
  box-sizing: border-box;
}
.app-header .brand, .top-header .brand, header .brand,
.app-header .brand-name, .top-header .brand-name, header .brand-name,
.app-header .entity-name, .top-header .entity-name, header .entity-name,
.app-header .app-title, .top-header .app-title, header .app-title,
.app-header .app-name, .top-header .app-name, header .app-name {
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  word-break: keep-all !important;
  overflow-wrap: normal !important;
  line-height: 1.15 !important;
}

/* Se l'identità è contenuta in colonne flex/grid, impedirne il restringimento
   fino al punto di generare una seconda riga. */
header .brand, header .header-brand, header .brand-content,
.app-header .brand, .top-header .brand {
  min-width: max-content;
}

/* Su mobile il testo resta su una sola riga e, se necessario, scorre/tronca,
   senza alterare la disposizione del menu. */
@media (max-width: 700px) {
  header .brand, header .header-brand, header .brand-content,
  .app-header .brand, .top-header .brand {
    min-width: 0;
    max-width: 100%;
  }
  header .brand-name, header .entity-name, header .app-title, header .app-name,
  .app-header .brand-name, .app-header .entity-name,
  .app-header .app-title, .app-header .app-name,
  .top-header .brand-name, .top-header .entity-name,
  .top-header .app-title, .top-header .app-name {
    display: block !important;
    width: 100%;
    white-space: nowrap !important;
  }
}

/* v21 - FIX DEFINITIVO: identità nell'header principale su una sola riga */
.header .brand-container {
  flex: 0 0 auto !important;
  min-width: max-content !important;
  max-width: none !important;
  white-space: nowrap !important;
}
.header .header-titles {
  display: flex !important;
  flex-direction: column !important;
  flex: 0 0 auto !important;
  width: max-content !important;
  min-width: max-content !important;
  max-width: none !important;
  white-space: nowrap !important;
}
.header .header-titles .ente-nome-text,
.header .header-titles h1 {
  display: block !important;
  width: max-content !important;
  max-width: none !important;
  min-width: max-content !important;
  white-space: nowrap !important;
  word-break: keep-all !important;
  overflow-wrap: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  line-height: 1.15 !important;
}

/* Il nome dell'ente non viene più spezzato in "Comune di" + "Limana". */
.header .ente-nome-text {
  white-space: nowrap !important;
}

/* Gestione Task non viene più spezzato in "Gestione" + "Task". */
.header .header-titles h1 {
  white-space: nowrap !important;
}

/* Su mobile il blocco identità resta compatto, mentre il menu può scorrere
   orizzontalmente senza provocare la rottura delle due righe identificative. */
@media (max-width: 767px) {
  .header .brand-container {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }
  .header .header-titles {
    min-width: 0 !important;
    width: auto !important;
    max-width: calc(100vw - 90px) !important;
  }
  .header .header-titles .ente-nome-text,
  .header .header-titles h1 {
    width: auto !important;
    min-width: 0 !important;
    max-width: 100% !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
}

/* v22: menu principale allineato a sinistra */
.header .tabs {
  justify-content: flex-start !important;
  margin-left: 0 !important;
  margin-right: auto !important;
  width: 100% !important;
  text-align: left !important;
}
.header .tabs .tab-btn {
  flex: 0 0 auto !important;
}

/* v23: menu principale allineato a destra */
.header .tabs {
  justify-content: flex-end !important;
  margin-left: auto !important;
  margin-right: 0 !important;
  width: 100% !important;
  text-align: right !important;
}
.header .tabs .tab-btn {
  flex: 0 0 auto !important;
}



/* v118.17 - Cestino: stesso contenitore e stessa densita delle tabelle Task */
#tab-cestino { width:100%; max-width:100%; align-self:stretch; }
#tab-cestino .trash-card { width:100%; max-width:100%; align-self:stretch; }
.trash-tasks-table { overflow-x:hidden; width:100%; max-width:100%; margin-top:10px; }
.trash-tasks-table table { width:100%; max-width:100%; table-layout:fixed; min-width:0; }
.trash-tasks-table th,.trash-tasks-table td { box-sizing:border-box; min-width:0; vertical-align:middle; }
.trash-tasks-table th:nth-child(1),.trash-tasks-table td:nth-child(1){width:auto;}
.trash-tasks-table th:nth-child(2),.trash-tasks-table td:nth-child(2){width:150px;}
.trash-tasks-table th:nth-child(3),.trash-tasks-table td:nth-child(3){width:115px;}
.trash-tasks-table th:nth-child(4),.trash-tasks-table td:nth-child(4){width:125px;}
.trash-tasks-table th:nth-child(5),.trash-tasks-table td:nth-child(5){width:110px;}
.trash-tasks-table th:nth-child(6),.trash-tasks-table td:nth-child(6){width:125px;text-align:center;}
.trash-tasks-table td.actions-cell{white-space:nowrap;text-align:center;vertical-align:middle;overflow:visible;}
.trash-tasks-table .actions-cell .btn-icon-only{display:inline-flex;vertical-align:middle;align-items:center;justify-content:center;width:27px;min-width:27px;height:27px;min-height:27px;padding:2px;margin:0 2px;box-sizing:border-box;}
.trash-tasks-table .task-object-meta-line{display:flex;align-items:center;gap:7px;min-width:0;margin-bottom:3px;}
.trash-tasks-table .task-id-inline{font-weight:700;white-space:nowrap;}
.trash-tasks-table .trash-status-inline{font-size:.76rem;color:var(--text-muted);white-space:nowrap;}
.trash-tasks-table .task-object-title-line{min-width:0;line-height:1.35;overflow:hidden;}
.trash-tasks-table .task-object-title-line strong{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.trash-tasks-table td:not(.oggetto-cell):not(.actions-cell){overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
@media(max-width:1024px){
 .trash-tasks-table th:nth-child(3),.trash-tasks-table td:nth-child(3),.trash-tasks-table th:nth-child(5),.trash-tasks-table td:nth-child(5){display:none;}
 .trash-tasks-table th:nth-child(2),.trash-tasks-table td:nth-child(2){width:19%;}
 .trash-tasks-table th:nth-child(4),.trash-tasks-table td:nth-child(4){width:16%;}
 .trash-tasks-table th:nth-child(6),.trash-tasks-table td:nth-child(6){width:16%;}
}
@media(max-width:700px){
 .trash-tasks-table{overflow-x:hidden;}
 .trash-tasks-table table{font-size:.82rem;}
 .trash-tasks-table th:nth-child(2),.trash-tasks-table td:nth-child(2){display:none;}
 .trash-tasks-table th:nth-child(1),.trash-tasks-table td:nth-child(1){width:58%;}
 .trash-tasks-table th:nth-child(4),.trash-tasks-table td:nth-child(4){width:22%;}
 .trash-tasks-table th:nth-child(6),.trash-tasks-table td:nth-child(6){width:20%;}
 .trash-tasks-table .actions-cell .btn-icon-only{width:28px;min-width:28px;height:28px;min-height:28px;margin:0 1px;}
}

/* v25 - Storico: struttura tabella coerente con le celle generate dal renderer */
#tab-storico table { table-layout: auto; }
#tab-storico th:first-child, #tab-storico td:first-child { width: 52px; }
#tab-storico .actions-cell { width: 145px; min-width:145px; white-space: nowrap; }

/* v30: stato task cliccabile */
/* v66: colori stati uniformi anche nella pagina Task in Lavorazione */
.status-clickable{
  cursor:pointer;
  border:0;
  font:inherit;
  padding:4px 9px;
  border-radius:20px;
  font-weight:600;
  display:inline-block;
  color:#fff !important;
  -webkit-appearance:none;
  appearance:none;
  transition:transform .12s ease,filter .12s ease,box-shadow .12s ease;
}
.status-clickable.badge-aperto{background:#3B82F6 !important;color:#fff !important;}
.status-clickable.badge-in-corso{background:#F59E0B !important;color:#fff !important;}
.status-clickable.badge-in-revisione{background:#8B5CF6 !important;color:#fff !important;}
.status-clickable.badge-completato{background:#22C55E !important;color:#fff !important;}
.status-clickable:hover{transform:translateY(-1px);filter:brightness(.96);box-shadow:0 1px 4px rgba(0,0,0,.16)}
.status-clickable:active{transform:translateY(0);}
.status-clickable:focus-visible{outline:2px solid var(--primary);outline-offset:2px}




/* v115.1 - Ottimizzazione mobile: filtri compatti, header elastico e touch target */
.filter-details > summary {
  display: none;
}
.filter-details .filters-row {
  width: 100%;
}
.filter-details-hint {
  display: none;
}

@media (max-width: 767px) {
  .filter-details {
    margin-bottom: 2px;
  }
  .filter-details > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text-main);
    font-size: .82rem;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
    user-select: none;
  }
  .filter-details > summary::-webkit-details-marker { display: none; }
  .filter-details > summary::after {
    content: '⌄';
    font-size: 1rem;
    line-height: 1;
    transition: transform .15s ease;
  }
  .filter-details[open] > summary::after { transform: rotate(180deg); }
  .filter-details-hint {
    display: inline;
    margin-left: auto;
    color: var(--text-muted);
    font-size: .68rem;
    font-weight: 500;
  }
  .filter-details .filters-row {
    margin-top: 8px;
  }

  /* Header: nessuna larghezza minima che possa comprimere logo, titolo o menu. */
  .header .brand-container {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    flex: 0 1 auto !important;
    overflow: hidden;
  }
  .header .header-titles {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    flex: 1 1 auto !important;
    overflow: hidden;
  }
  .header .header-titles .ente-nome-text,
  .header .header-titles h1 {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
  .header .user-info-bar {
    width: 100%;
    box-sizing: border-box;
    justify-content: flex-start;
    min-width: 0;
  }

  /* Schede task: meno alte senza sacrificare leggibilità. */
  .task-card-mobile {
    padding: 11px;
    gap: 6px;
  }
  .task-card-mobile-body {
    gap: 4px;
    font-size: .82rem;
  }
  .task-card-mobile-footer {
    gap: 6px;
    padding-top: 7px;
  }
  .task-card-mobile-footer .btn-icon-only,
  .task-card-mobile-footer .actions-cell .btn-icon-only {
    width: 38px;
    min-width: 38px;
    height: 38px;
  }
}

/* v42 - Responsive hardening: smartphone, tablet e touch */
html { width: 100%; max-width: 100%; overflow-x: hidden; }
body { min-width: 0; }
img, video, canvas, svg { max-width: 100%; }

/* I campi file non devono creare overflow sui browser mobile. */
input[type="file"] { min-width: 0; max-width: 100%; font-size: .82rem; }

/* Il calendario mensile resta leggibile: su smartphone può scorrere
   orizzontalmente senza allargare l'intera pagina. */
#calendarContainer { width: 100%; min-width: 0; }
@media (max-width: 600px) {
  #calendarContainer { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .calendar-grid-month { min-width: 490px; }
  .calendar-cell { min-height: 72px; padding: 4px; }
  .calendar-day-name { padding: 7px 2px; font-size: .70rem; }
  .cal-event { min-width: 0; padding: 4px 6px; gap: 4px; font-size: .70rem; }
  .cal-event span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cal-event-time { font-size: .64rem; white-space: nowrap; }
  .calendar-controls { gap: 8px; }
  .calendar-controls > div:first-child,
  .view-selector { max-width: 100%; overflow-x: auto; }
  .calendar-controls .btn { min-height: 38px; }
  .view-btn { min-height: 36px; white-space: nowrap; }
}

/* Touch target e spaziatura più comodi sui telefoni. */
@media (max-width: 480px) {
  body { padding: 10px; }
  .container { gap: 12px; }
  .card { padding: 10px; }
  .card-title { font-size: 1rem; margin-bottom: 12px; }
  .filters-row { padding: 9px; gap: 8px; margin-bottom: 12px; }
  .filter-item, .filter-item.filter-search { min-width: 0; width: 100%; flex: 1 1 100%; }
  input, select, textarea { font-size: .9rem; min-height: 40px; }
  textarea#oggetto, textarea#commentoFinale { min-height: 80px; }
  .btn { min-height: 40px; }
  .tab-btn { min-height: 38px; }
  .task-card-mobile { padding: 12px; }
  .task-card-mobile-footer { justify-content: flex-start; }
  .task-card-mobile-footer .actions-cell { justify-content: flex-start; }
}

/* Allegato + Link: contenitore dedicato per garantire sempre la stessa riga
   e la stessa larghezza dei due campi, indipendentemente dal posizionamento
   automatico della griglia principale. */
.form-grid .form-attachment-link-row {
  grid-column: 1 / -1;
  grid-row: 4;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.form-grid .form-attachment-link-row .form-group {
  min-width: 0;
}

.form-grid .form-attachment-link-row input[type="file"],
.form-grid .form-attachment-link-row input[type="url"] {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

@media (max-width: 575px) {
  .form-grid .form-attachment-link-row {
    grid-template-columns: 1fr;
  }
}

.task-link-preview{display:inline-flex;align-items:center;margin-top:7px;font-size:.9rem;font-weight:600;text-decoration:none;cursor:pointer}.task-link-preview:hover{text-decoration:underline}
.task-list-link{font-weight:600;text-decoration:none;white-space:nowrap}.task-list-link:hover{text-decoration:underline}


/* Struttura esplicita a righe del form Nuovo/Modifica Task */
.task-form-rows {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
}
.task-form-row {
    display: grid;
    width: 100%;
    min-width: 0;
    gap: 14px 12px;
    align-items: start;
}
.task-form-row-four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.task-form-row-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.task-form-row-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.task-form-row .task-field { min-width: 0; }
.task-form-row .task-span-full { grid-column: 1 / -1; }
.task-form-row input[type="file"],
.task-form-row input[type="url"] {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}
.task-form-row .task-empty { visibility: hidden; }
@media (max-width: 991px) {
    .task-form-row-four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 575px) {
    .task-form-row-four,
    .task-form-row-three,
    .task-form-row-two { grid-template-columns: 1fr; }
    .task-form-row .task-empty { display: none; }
}

/* v55 - Menu principale ottimizzato per smartphone.
   Su desktop resta invariato; su telefoni diventa un menu compatto apribile. */
.mobile-menu-toggle { display: none !important; visibility: hidden !important; }

@media (max-width: 767px) {
  .header {
    gap: 10px;
  }

  .user-info-bar {
    width: 100%;
    box-sizing: border-box;
    justify-content: space-between;
    gap: 7px;
    padding: 7px 9px;
    flex-wrap: nowrap;
  }

  .user-info-bar > span:first-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .user-info-bar .btn {
    flex: 0 0 auto;
  }

  .mobile-menu-toggle {
    display: flex !important;
    visibility: visible !important;
    width: 100%;
    min-height: 42px;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--card-bg);
    color: var(--text-main);
    font: inherit;
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
  }

  .mobile-menu-toggle::after {
    content: '▾';
    font-size: .95rem;
    transition: transform .15s ease;
  }

  .mobile-menu-toggle.is-open::after {
    transform: rotate(180deg);
  }

  .mobile-menu-toggle.is-open {
    border-color: var(--primary);
  }

  .header .tabs {
    display: none;
    width: 100% !important;
    box-sizing: border-box;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start !important;
    gap: 6px;
    margin: 0 !important;
    padding: 8px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: visible;
  }

  .header .tabs.mobile-open {
    display: flex;
  }

  .header .tabs .tab-btn,
  .header .tabs .tab-btn-action {
    width: 100%;
    min-height: 42px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 9px 12px;
    font-size: .86rem;
    text-align: left;
    border-radius: 7px;
  }

  .header .tabs .tab-btn-icon {
    width: 100%;
    min-width: 0;
    padding-left: 12px;
    padding-right: 12px;
    font-size: .9rem;
  }

  .header .tabs .tab-btn:hover:not(.active) {
    transform: none;
  }
}


/* Popup inserimento Commento Finale / Esito al completamento */
body.modal-open { overflow: hidden; }
.completion-modal { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; padding: 20px; box-sizing: border-box; }
.completion-modal-backdrop { position: absolute; inset: 0; z-index: 0; background: rgba(0,0,0,.48); }
.completion-modal-card { position: relative; z-index: 1; width: min(620px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: var(--card-bg, #fff); color: var(--text-main, #1f2937); border: 1px solid var(--border-color, #e5e7eb); border-radius: 12px; box-shadow: 0 18px 50px rgba(0,0,0,.25); }
.completion-modal-header { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:16px 20px; border-bottom:1px solid var(--border-color, #e5e7eb); }
.completion-modal-header h2 { margin:0; font-size:1.15rem; }
.completion-modal-close { border:0; background:transparent; color:inherit; font-size:1.7rem; line-height:1; cursor:pointer; padding:4px 8px; }
.completion-modal-body { padding:20px; }
.completion-modal-body label { display:block; margin-bottom:7px; font-weight:700; }
.completion-modal-body label span { color:#b91c1c; }
.completion-task-label { margin:0 0 16px; font-weight:700; }
.completion-modal-body textarea { display:block; position:relative; z-index:2; width:100%; min-height:130px; box-sizing:border-box; resize:vertical; padding:10px 12px; border:1px solid var(--border-color, #d1d5db); border-radius:8px; background:var(--input-bg, #fff); color:inherit; font:inherit; }
.completion-modal-body textarea:focus { outline:2px solid var(--primary, #2563eb); outline-offset:1px; }
.completion-modal-footer { display:flex; justify-content:flex-end; gap:10px; padding:14px 20px 18px; border-top:1px solid var(--border-color, #e5e7eb); }
@media (max-width:575px){ .completion-modal { padding:10px; } .completion-modal-card { max-height:calc(100vh - 20px); } .completion-modal-footer { flex-direction:column-reverse; } .completion-modal-footer .btn { width:100%; } }

/* v65: colori Stato Workflow uniformi e visibili anche nel campo select */
#stato.state-select-aperto, #stato.state-select-in-corso, #stato.state-select-in-revisione, #stato.state-select-completato {
  color:#fff !important; font-weight:600; border-width:2px;
}
#stato.state-select-aperto { background:#3B82F6 !important; border-color:#3B82F6 !important; }
#stato.state-select-in-corso { background:#F59E0B !important; border-color:#F59E0B !important; }
#stato.state-select-in-revisione { background:#8B5CF6 !important; border-color:#8B5CF6 !important; }
#stato.state-select-completato { background:#22C55E !important; border-color:#22C55E !important; }
#stato option[value="Aperto"] { background:#3B82F6; color:#fff; }
#stato option[value="In Corso"] { background:#F59E0B; color:#fff; }
#stato option[value="In Revisione"] { background:#8B5CF6; color:#fff; }
#stato option[value="Completato"] { background:#22C55E; color:#fff; }

/* v67: colori Priorità uniformi anche nel campo select di Nuovo/Modifica Task */
#priorita.priority-select-bassa, #priorita.priority-select-media, #priorita.priority-select-alta, #priorita.priority-select-urgente {
  color:#fff !important; font-weight:600; border-width:2px;
}
#priorita.priority-select-bassa { background:#64748B !important; border-color:#64748B !important; }
#priorita.priority-select-media { background:#0EA5E9 !important; border-color:#0EA5E9 !important; }
#priorita.priority-select-alta { background:#F97316 !important; border-color:#F97316 !important; }
#priorita.priority-select-urgente { background:#DC2626 !important; border-color:#DC2626 !important; }
#priorita option[value="Bassa"] { background:#64748B; color:#fff; }
#priorita option[value="Media"] { background:#0EA5E9; color:#fff; }
#priorita option[value="Alta"] { background:#F97316; color:#fff; }
#priorita option[value="Urgente"] { background:#DC2626; color:#fff; }

/* v67: badge priorità più immediatamente distinguibili */
.badge-p-bassa { background:#64748B !important; color:#fff !important; }
.badge-p-media { background:#0EA5E9 !important; color:#fff !important; }
.badge-p-alta { background:#F97316 !important; color:#fff !important; }
.badge-p-urgente { background:#DC2626 !important; color:#fff !important; }

/* v68: rifinitura visuale stati/priorità e titolo Oggetto nel form */
.status-clickable {
  font-size: 0.72rem !important;
  line-height: 1.2 !important;
  padding: 4px 8px !important;
  font-weight: 600 !important;
}

/* Priorità: stessi colori definiti per i badge anche nel select Nuovo/Modifica */
#priorita.priority-select-bassa { background:#64748B !important; border-color:#64748B !important; color:#fff !important; }
#priorita.priority-select-media { background:#0EA5E9 !important; border-color:#0EA5E9 !important; color:#fff !important; }
#priorita.priority-select-alta { background:#F97316 !important; border-color:#F97316 !important; color:#fff !important; }
#priorita.priority-select-urgente { background:#DC2626 !important; border-color:#DC2626 !important; color:#fff !important; }

/* Oggetto: evidenziato in grassetto nel form Nuovo/Modifica */
.task-form-row-1 #oggetto {
  font-weight: 700;
}
.task-form-row-1 label[for="oggetto"] {
  font-weight: 700 !important;
}

/* v69 - Evidenziazione campo Oggetto Attività / Task */
.form-group.task-object-field label {
  font-weight: 700 !important;
}
.form-group.task-object-field textarea#oggetto {
  background: #DBEAFE !important;
  border: 3px solid #3B82F6 !important;
  color: #0F172A !important;
  font-weight: 700 !important;
  min-height: 88px;
  width: 100%;
  box-sizing: border-box;
  box-shadow: inset 0 0 0 1px rgba(59,130,246,.18);
}
.form-group.task-object-field textarea#oggetto:focus {
  background: #DBEAFE !important;
  border-color: #2563EB !important;
  box-shadow: 0 0 0 4px rgba(37,99,235,.18), inset 0 0 0 1px rgba(37,99,235,.2) !important;
  outline: none;
}

/* v69+ - evidenziazione scadenze dei task non archiviati */
.deadline-overdue { color: #DC2626 !important; font-weight: 700 !important; }
.deadline-soon { color: #F97316 !important; font-weight: 700 !important; }
#scadenza.deadline-overdue { color: #DC2626 !important; font-weight: 700 !important; }
#scadenza.deadline-soon { color: #F97316 !important; font-weight: 700 !important; }


/* v71 - allegati multipli fino a 3 */
.task-attachments-list{display:flex;flex-direction:column;gap:7px;margin-top:8px}
.task-attachment-item{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.task-attachment-link{font-size:.82rem;font-weight:600;text-decoration:none;word-break:break-word}
.task-attachment-link:hover{text-decoration:underline}
.task-attachment-delete{padding:4px 8px!important}
.task-attachments-field input[type=file]{width:100%;box-sizing:border-box}


/* Popup per la visualizzazione completa dell'oggetto del task */
.object-modal { position: fixed; inset: 0; z-index: 10000; display: flex; align-items: center; justify-content: center; padding: 20px; box-sizing: border-box; }
.object-modal-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.52); }
.object-modal-card { position: relative; z-index: 1; width: min(760px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: var(--card-bg, #fff); color: var(--text-main, #1f2937); border: 1px solid var(--border-color, #e5e7eb); border-radius: 14px; box-shadow: 0 22px 60px rgba(0,0,0,.28); }
.object-modal-header { display:flex; align-items:center; justify-content:space-between; gap:14px; padding:17px 20px; border-bottom:1px solid var(--border-color, #e5e7eb); }
.object-modal-header h2 { margin:0; font-size:1.15rem; }
.object-modal-close { border:0; background:transparent; color:inherit; font-size:1.75rem; line-height:1; cursor:pointer; padding:4px 8px; border-radius:6px; }
.object-modal-close:hover, .object-modal-close:focus-visible { background:var(--table-row-hover, #f3f4f6); outline:none; }
.object-modal-meta { display:flex; flex-wrap:wrap; gap:8px 18px; padding:12px 20px 0; color:var(--text-muted, #6b7280); font-size:.88rem; font-weight:500; }
.object-modal-meta-item { display:inline-flex; align-items:baseline; gap:4px; }
.object-modal-meta-item strong { color:var(--text-main, #1f2937); font-weight:700; }
.object-modal-body { padding:16px 20px 22px; }
.object-modal-text { margin:0; white-space:pre-wrap; overflow-wrap:anywhere; word-break:break-word; font-size:1rem; line-height:1.6; }
@media (max-width:1024px) and (min-width:769px){
  .active-tasks-table th:nth-child(1), .active-tasks-table td:nth-child(1){width:31%;}
  .active-tasks-table th:nth-child(2), .active-tasks-table td:nth-child(2){width:15%;}
  .active-tasks-table th:nth-child(3), .active-tasks-table td:nth-child(3){width:8%;}
  .active-tasks-table th:nth-child(4), .active-tasks-table td:nth-child(4){width:11%;}
  .active-tasks-table th:nth-child(5), .active-tasks-table td:nth-child(5){width:10%;}
  .active-tasks-table th:nth-child(6), .active-tasks-table td:nth-child(6){width:8%;}
  .active-tasks-table th:nth-child(9), .active-tasks-table td:nth-child(9){width:17%;}
  .active-tasks-table .actions-cell .btn-icon-only{width:26px;min-width:26px;max-width:26px;height:26px;min-height:26px;}
}
@media (max-width:575px){ .object-modal { padding:10px; } .object-modal-card { max-height:calc(100vh - 20px); border-radius:12px; } .object-modal-header { padding:14px 16px; } .object-modal-meta { padding:10px 16px 0; } .object-modal-body { padding:14px 16px 20px; } }

/* v85 - selezione multipla settori */
.sector-checklist{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:8px;padding:10px;border:1px solid var(--border,#d1d5db);border-radius:8px;background:var(--surface,#fff);max-height:190px;overflow:auto}.sector-check-item{display:flex;align-items:center;gap:9px;padding:9px 10px;border:1px solid transparent;border-radius:7px;cursor:pointer;user-select:none}.sector-check-item:hover{background:rgba(59,130,246,.06);border-color:rgba(59,130,246,.18)}.sector-check-item input{width:17px;height:17px;flex:0 0 auto}.sector-checklist-empty{padding:10px;color:var(--text-muted,#6b7280)}

/* v99 - azioni Salva/Annulla affiancate ad Archivia task e allineate a destra */
.task-form-actions-row .task-archive-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 16px;
  margin-top: 4px;
}
.task-form-actions-row .task-form-actions-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-left: auto;
}
.task-form-actions-row .checkbox-container {
  margin: 0;
  flex: 0 0 auto;
}
@media (max-width: 575px) {
  .task-form-actions-row .task-archive-actions {
    align-items: stretch;
  }
  .task-form-actions-row .task-form-actions-right {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}


/* v115.1 - rifinitura finale smartphone */
@media (max-width: 480px) {
  .header .brand-container { gap: 8px; }
  .ente-logo-wrapper { max-width: 72px; max-height: 46px; padding: 3px 5px; }
  .ente-logo-img { max-width: 62px; max-height: 38px; }
  .header h1 { font-size: 1.08rem; }
  .ente-nome-text { font-size: .72rem; }
  .user-info-bar { gap: 7px; padding: 6px 8px; font-size: .78rem; }
  .mobile-menu-toggle { min-height: 42px; }
  .task-card-mobile .badge { font-size: .68rem; padding: 3px 7px; }
  .task-card-mobile-footer .btn-icon-only { width: 38px; min-width: 38px; height: 38px; }
}

/* ID task: identificativo compatto, senza occupare una colonna dedicata */
.task-id-inline{display:inline-flex;align-items:center;margin-right:7px;padding:2px 6px;border:1px solid var(--border-color);border-radius:6px;font-size:.72rem;font-weight:700;color:var(--text-muted);background:var(--surface-2,#f8fafc);vertical-align:middle;white-space:nowrap}
.task-id-display{display:inline-flex;align-items:center;padding:6px 9px;border:1px solid var(--border-color);border-radius:7px;font-size:.78rem;font-weight:700;color:var(--text-muted);background:var(--surface-2,#f8fafc);white-space:nowrap}
@media(max-width:650px){.task-id-display{align-self:flex-start}.task-archive-actions{flex-wrap:wrap}.task-id-inline{font-size:.68rem;padding:2px 5px}}

/* v116.9 - distribuzione definitiva tabella Task in Lavorazione
   La struttura segue lo Storico: colonne secondarie compatte, Oggetto elastico,
   Azioni con spazio garantito. Nessuna scrollbar orizzontale. */
.active-tasks-table {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}
.active-tasks-table table {
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
}
.active-tasks-table th,
.active-tasks-table td {
  box-sizing: border-box;
  overflow-wrap: anywhere;
  word-break: break-word;
}
/* Colonne desktop: l'Oggetto occupa automaticamente tutto lo spazio residuo. */
.active-tasks-table th:nth-child(1),
.active-tasks-table td:nth-child(1) { width: auto; }
.active-tasks-table th:nth-child(2),
.active-tasks-table td:nth-child(2) { width: 150px; }
.active-tasks-table th:nth-child(3),
.active-tasks-table td:nth-child(3) { width: 78px; text-align: center; }
.active-tasks-table th:nth-child(4),
.active-tasks-table td:nth-child(4) { width: 105px; }
.active-tasks-table th:nth-child(5),
.active-tasks-table td:nth-child(5) { width: 110px; }
.active-tasks-table th:nth-child(6),
.active-tasks-table td:nth-child(6) { width: 82px; text-align: center; }
.active-tasks-table th:nth-child(7),
.active-tasks-table td:nth-child(7),
.active-tasks-table th:nth-child(8),
.active-tasks-table td:nth-child(8) { width: 42px; text-align: center; }
.active-tasks-table th:nth-child(9),
.active-tasks-table td:nth-child(9) { width: 140px; }

.active-tasks-table th:nth-child(1) { text-align: left; }
.active-tasks-table th:nth-child(2),
.active-tasks-table th:nth-child(3),
.active-tasks-table th:nth-child(4),
.active-tasks-table th:nth-child(5),
.active-tasks-table th:nth-child(6),
.active-tasks-table th:nth-child(7),
.active-tasks-table th:nth-child(8),
.active-tasks-table th:nth-child(9) { vertical-align: middle; }

.active-tasks-table .actions-cell {
  width: 140px;
  min-width: 140px;
  max-width: 140px;
  padding-left: 6px;
  padding-right: 6px;
  display: flex;
  flex-wrap: nowrap !important;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  white-space: nowrap;
  overflow: visible;
}
.active-tasks-table .actions-cell .btn-icon-only {
  flex: 0 0 28px;
  width: 28px;
  min-width: 28px;
  max-width: 28px;
  height: 28px;
  min-height: 28px;
  max-height: 28px;
  padding: 2px;
}
.active-tasks-table .oggetto-cell,
.active-tasks-table .oggetto-cell .task-object-trigger {
  min-width: 0;
}
.active-tasks-table .oggetto-cell .task-object-trigger {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
}
.active-tasks-table .file-tag,
.active-tasks-table .task-list-link {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

@media (max-width: 1100px) and (min-width: 861px) {
  .active-tasks-table th:nth-child(2), .active-tasks-table td:nth-child(2) { width: 135px; }
  .active-tasks-table th:nth-child(4), .active-tasks-table td:nth-child(4) { width: 98px; }
  .active-tasks-table th:nth-child(5), .active-tasks-table td:nth-child(5) { width: 98px; }
  .active-tasks-table th:nth-child(9), .active-tasks-table td:nth-child(9) { width: 136px; }
  .active-tasks-table .actions-cell { width:136px; min-width:136px; max-width:136px; }
}

@media (max-width: 860px) and (min-width: 769px) {
  .active-tasks-table th:nth-child(5), .active-tasks-table td:nth-child(5) { display:none; }
  .active-tasks-table th:nth-child(2), .active-tasks-table td:nth-child(2) { width: 145px; }
  .active-tasks-table th:nth-child(3), .active-tasks-table td:nth-child(3) { width: 72px; }
  .active-tasks-table th:nth-child(4), .active-tasks-table td:nth-child(4) { width: 96px; }
  .active-tasks-table th:nth-child(6), .active-tasks-table td:nth-child(6) { width: 82px; }
  .active-tasks-table th:nth-child(9), .active-tasks-table td:nth-child(9) { width: 136px; }
  .active-tasks-table .actions-cell { width:136px; min-width:136px; max-width:136px; }
}

/* v117.0 - Azioni Task: centratura verticale e nessuna linea sotto il gruppo */
.active-tasks-table tbody td {
  vertical-align: middle;
}
.active-tasks-table tbody td.actions-cell {
  vertical-align: middle !important;
  border-bottom: 0 !important;
  padding-top: 10px;
  padding-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 100%;
}
.active-tasks-table tbody td.actions-cell .btn-icon-only {
  margin: 0;
  align-self: center;
  vertical-align: middle;
}

/* v117.1 - Azioni: centratura verticale e nessuna linea sotto la cella.
   Vale sia per Task in Lavorazione sia per Storico. */
.active-tasks-table td.actions-cell,
#tab-storico td.actions-cell {
  vertical-align: middle !important;
  border-bottom: 0 !important;
  padding-top: 10px;
  padding-bottom: 10px;
}
.active-tasks-table td.actions-cell > .actions-cell,
#tab-storico td.actions-cell > .actions-cell {
  align-self: center;
}

/* v117.2 - Azioni realmente centrate verticalmente nelle righe delle tabelle.
   La cella resta una normale table-cell: il flex direttamente sul TD alterava
   l'altezza/allineamento della riga. */
.active-tasks-table td.actions-cell,
#tab-storico td.actions-cell {
  display: table-cell !important;
  width: 100%;
  vertical-align: middle !important;
  text-align: center !important;
  border-bottom: none !important;
  padding-top: 10px;
  padding-bottom: 10px;
  white-space: nowrap;
  overflow: visible !important;
}
.active-tasks-table td.actions-cell .btn-icon-only,
#tab-storico td.actions-cell .btn-icon-only {
  display: inline-flex;
  vertical-align: middle;
  margin: 0 2px;
}

/* v117.3 - Storico allineato alla tabella Task in Lavorazione.
   Stessa griglia, stesse proporzioni e stessa gestione delle colonne.
   La colonna Oggetto resta elastica; Azioni ha uno spazio dedicato. */
.historical-tasks-table {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}
.historical-tasks-table table {
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
}
.historical-tasks-table th,
.historical-tasks-table td {
  box-sizing: border-box;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.historical-tasks-table th:nth-child(1),
.historical-tasks-table td:nth-child(1) { width: auto; }
.historical-tasks-table th:nth-child(2),
.historical-tasks-table td:nth-child(2) { width: 150px; }
.historical-tasks-table th:nth-child(3),
.historical-tasks-table td:nth-child(3) { width: 78px; text-align: center; }
.historical-tasks-table th:nth-child(4),
.historical-tasks-table td:nth-child(4) { width: 105px; }
.historical-tasks-table th:nth-child(5),
.historical-tasks-table td:nth-child(5) { width: 110px; }
.historical-tasks-table th:nth-child(6),
.historical-tasks-table td:nth-child(6) { width: 82px; text-align: center; }
.historical-tasks-table th:nth-child(7),
.historical-tasks-table td:nth-child(7),
.historical-tasks-table th:nth-child(8),
.historical-tasks-table td:nth-child(8) { width: 42px; text-align: center; }
.historical-tasks-table th:nth-child(9),
.historical-tasks-table td:nth-child(9) { width: 140px; }
.historical-tasks-table th { vertical-align: middle; }
.historical-tasks-table th:nth-child(1) { text-align: left; }
.historical-tasks-table .actions-cell {
  display: table-cell !important;
  width: 140px;
  min-width: 140px;
  max-width: 140px;
  padding: 10px 6px;
  text-align: center !important;
  vertical-align: middle !important;
  border-bottom: 0 !important;
  white-space: nowrap;
  overflow: visible !important;
}
.historical-tasks-table .actions-cell .btn-icon-only {
  display: inline-flex;
  vertical-align: middle;
  margin: 0 2px;
}
.historical-tasks-table .oggetto-cell,
.historical-tasks-table .oggetto-cell .task-object-trigger { min-width: 0; }
.historical-tasks-table .oggetto-cell .task-object-trigger {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
}
.historical-tasks-table .file-tag,
.historical-tasks-table .task-list-link {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}
@media (max-width: 1100px) and (min-width: 861px) {
  .historical-tasks-table th:nth-child(2), .historical-tasks-table td:nth-child(2) { width: 135px; }
  .historical-tasks-table th:nth-child(4), .historical-tasks-table td:nth-child(4) { width: 98px; }
  .historical-tasks-table th:nth-child(5), .historical-tasks-table td:nth-child(5) { width: 98px; }
  .historical-tasks-table th:nth-child(9), .historical-tasks-table td:nth-child(9) { width: 136px; }
  .historical-tasks-table .actions-cell { width:136px; min-width:136px; max-width:136px; }
}
@media (max-width: 860px) and (min-width: 769px) {
  .historical-tasks-table th:nth-child(5), .historical-tasks-table td:nth-child(5) { display:none; }
  .historical-tasks-table th:nth-child(2), .historical-tasks-table td:nth-child(2) { width: 145px; }
  .historical-tasks-table th:nth-child(3), .historical-tasks-table td:nth-child(3) { width: 72px; }
  .historical-tasks-table th:nth-child(4), .historical-tasks-table td:nth-child(4) { width: 96px; }
  .historical-tasks-table th:nth-child(6), .historical-tasks-table td:nth-child(6) { width: 82px; }
  .historical-tasks-table th:nth-child(9), .historical-tasks-table td:nth-child(9) { width:136px; }
  .historical-tasks-table .actions-cell { width:136px; min-width:136px; max-width:136px; }
}


/* v117.4 - Storico: distribuzione reale al 100% dello spazio disponibile.
   L'Oggetto riceve lo spazio maggiore; le colonne compatte e Azioni hanno
   larghezze proporzionate, evitando spazio vuoto a destra. */
@media (min-width: 1101px) {
  .historical-tasks-table { width:100%; max-width:100%; overflow:hidden; }
  .historical-tasks-table table { width:100%; max-width:100%; table-layout:fixed; }
  .historical-tasks-table th:nth-child(1), .historical-tasks-table td:nth-child(1) { width:32% !important; }
  .historical-tasks-table th:nth-child(2), .historical-tasks-table td:nth-child(2) { width:15% !important; }
  .historical-tasks-table th:nth-child(3), .historical-tasks-table td:nth-child(3) { width:7% !important; }
  .historical-tasks-table th:nth-child(4), .historical-tasks-table td:nth-child(4) { width:10% !important; }
  .historical-tasks-table th:nth-child(5), .historical-tasks-table td:nth-child(5) { width:10% !important; }
  .historical-tasks-table th:nth-child(6), .historical-tasks-table td:nth-child(6) { width:9% !important; }
  .historical-tasks-table th:nth-child(7), .historical-tasks-table td:nth-child(7) { width:3% !important; }
  .historical-tasks-table th:nth-child(8), .historical-tasks-table td:nth-child(8) { width:3% !important; }
  .historical-tasks-table th:nth-child(9), .historical-tasks-table td:nth-child(9) { width:11% !important; }
}


.admin-only-access-log{display:none}
.access-log-title{display:flex;align-items:center;justify-content:space-between;gap:12px}.access-log-title>span{display:inline-flex;align-items:center;gap:7px}.access-log-table-wrap{max-height:520px;overflow:auto}.access-log-table-wrap table{table-layout:fixed}.access-log-table-wrap th:nth-child(1),.access-log-table-wrap td:nth-child(1){width:16%}.access-log-table-wrap th:nth-child(2),.access-log-table-wrap td:nth-child(2){width:14%}.access-log-table-wrap th:nth-child(3),.access-log-table-wrap td:nth-child(3){width:13%}.access-log-table-wrap th:nth-child(4),.access-log-table-wrap td:nth-child(4){width:17%}.access-log-table-wrap th:nth-child(5),.access-log-table-wrap td:nth-child(5){width:40%}.access-user-agent{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.access-result{display:inline-flex;align-items:center;gap:5px;font-size:.78rem;font-weight:600;white-space:nowrap}.access-success{color:#15803d}.access-failed{color:#b91c1c}.password-modal-card{max-width:520px}.password-modal-body{display:flex;flex-direction:column;gap:12px}@media(max-width:767px){.access-log-table-wrap{max-height:none}.access-log-table-wrap table{min-width:760px}.access-log-title{align-items:flex-start}.access-log-title .btn{white-space:nowrap}.file-tag .attachment-name{max-width:150px}}

/* v118 - stile moderno esclusivamente per allegati e link */
.file-tag,.attachment-list-link{display:inline-flex;align-items:center;gap:5px;max-width:100%;text-decoration:none}.file-tag .attachment-icon,.attachment-list-link .attachment-icon{display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;width:20px;height:20px;border:1px solid color-mix(in srgb,var(--primary,#2563eb) 28%,var(--border-color,#d1d5db));border-radius:6px;background:color-mix(in srgb,var(--primary,#2563eb) 8%,transparent);color:var(--primary,#2563eb)}.file-tag .attachment-icon .ui-icon,.attachment-list-link .attachment-icon .ui-icon{width:13px;height:13px;vertical-align:0}.attachment-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}@media(max-width:767px){.file-tag .attachment-name{max-width:150px}}

.ui-icon{width:1.05em;height:1.05em;display:inline-block;vertical-align:-.16em;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;flex:0 0 auto}.table-icon-header .ui-icon{width:16px;height:16px;vertical-align:-3px}.task-link-preview .ui-icon{width:16px;height:16px;vertical-align:-3px}

/* v118.3 - indicatori compatti allegati/link direttamente nel task */
.task-resource-indicators{display:inline-flex;align-items:center;gap:5px;margin-left:7px;vertical-align:middle;white-space:nowrap}
.resource-dot{display:inline-flex;align-items:center;justify-content:center;width:9px;height:9px;min-width:9px;border-radius:50%;text-decoration:none;box-shadow:0 0 0 2px var(--surface,#fff);transition:transform .15s ease,box-shadow .15s ease}
.resource-dot-attachment{background:#2563eb}
.resource-dot-link{background:#16a34a}
.resource-dot:hover,.resource-dot:focus-visible{transform:scale(1.35);box-shadow:0 0 0 2px var(--surface,#fff),0 0 0 3px currentColor;outline:none}
.active-tasks-table th:nth-child(7),.active-tasks-table td:nth-child(7),.active-tasks-table th:nth-child(8),.active-tasks-table td:nth-child(8),.historical-tasks-table th:nth-child(7),.historical-tasks-table td:nth-child(7),.historical-tasks-table th:nth-child(8),.historical-tasks-table td:nth-child(8){display:none!important}
.active-tasks-table th:nth-child(1),.active-tasks-table td:nth-child(1){width:30%!important}
.active-tasks-table th:nth-child(2),.active-tasks-table td:nth-child(2){width:16%!important}
.active-tasks-table th:nth-child(3),.active-tasks-table td:nth-child(3){width:8%!important}
.active-tasks-table th:nth-child(4),.active-tasks-table td:nth-child(4){width:11%!important}
.active-tasks-table th:nth-child(5),.active-tasks-table td:nth-child(5){width:11%!important}
.active-tasks-table th:nth-child(6),.active-tasks-table td:nth-child(6){width:9%!important}
.active-tasks-table th:nth-child(9),.active-tasks-table td:nth-child(9){width:15%!important}
.historical-tasks-table th:nth-child(1),.historical-tasks-table td:nth-child(1){width:34%!important}
.historical-tasks-table th:nth-child(2),.historical-tasks-table td:nth-child(2){width:16%!important}
.historical-tasks-table th:nth-child(3),.historical-tasks-table td:nth-child(3){width:8%!important}
.historical-tasks-table th:nth-child(4),.historical-tasks-table td:nth-child(4){width:10%!important}
.historical-tasks-table th:nth-child(5),.historical-tasks-table td:nth-child(5){width:10%!important}
.historical-tasks-table th:nth-child(6),.historical-tasks-table td:nth-child(6){width:9%!important}
.historical-tasks-table th:nth-child(9),.historical-tasks-table td:nth-child(9){width:13%!important}
@media(max-width:767px){.task-resource-indicators{gap:4px;margin-left:6px}.resource-dot{width:8px;height:8px;min-width:8px}}

/* v118.4 - impostazioni amministratore più leggibili */
.settings-page-intro{display:flex;align-items:flex-start;justify-content:space-between;gap:18px;padding:4px 2px 18px}
.settings-page-kicker,.settings-section-kicker{font-size:.68rem;letter-spacing:.09em;font-weight:700;text-transform:uppercase;color:var(--text-muted)}
.settings-page-intro h2{margin:4px 0 5px;font-size:1.35rem}.settings-page-intro p{margin:0;max-width:760px;color:var(--text-muted);font-size:.88rem;line-height:1.5}
.settings-section-card{overflow:hidden}.settings-section-heading{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:16px}.settings-section-heading .card-title{margin:2px 0 0}.settings-section-badge{font-size:.72rem;font-weight:600;padding:5px 9px;border:1px solid var(--border-color);border-radius:999px;color:var(--text-muted);background:var(--surface-2,#f8fafc);white-space:nowrap}
.settings-form{display:flex;flex-direction:column;gap:16px}.settings-form .form-grid{gap:14px}.settings-form-actions{display:flex;justify-content:flex-end;padding-top:2px}.settings-info-box{padding:11px 13px;border:1px solid var(--border-color);border-radius:10px;background:var(--surface-2,#f8fafc);color:var(--text-muted);font-size:.84rem;line-height:1.45;margin-bottom:14px}.settings-field-highlight{display:flex;align-items:center;justify-content:space-between;gap:18px;padding:13px 14px;border:1px solid var(--border-color);border-radius:10px;background:var(--surface-2,#f8fafc)}.settings-field-highlight label{font-weight:600}.settings-field-highlight small{display:block;margin-top:3px}.settings-number-wrap{display:flex;align-items:center;gap:8px;flex:0 0 auto}.settings-number-wrap input{width:100px}.settings-number-wrap span{font-size:.82rem;color:var(--text-muted)}
.recurrence-inline-indicator{display:inline-flex;vertical-align:middle;margin-left:7px}.oggetto-cell .recurrence-list-indicator{display:none}
.admin-only-nav{min-width:42px;justify-content:center}
@media(max-width:700px){.settings-page-intro{padding-bottom:12px}.settings-section-heading{align-items:flex-start}.settings-field-highlight{align-items:flex-start;flex-direction:column}.settings-number-wrap{width:100%}.settings-number-wrap input{width:110px}.settings-form-actions{justify-content:stretch}.settings-form-actions .btn{width:100%}}


/* v118.5 - metadati ricorrenza sulla stessa riga dell'ID e maggiore spazio all'Oggetto */
.task-object-line{display:flex;align-items:flex-start;gap:7px;width:100%;min-width:0;}
.task-object-line .task-id-inline,.task-object-line .recurrence-inline-indicator,.task-object-line .task-resource-indicators{flex:0 0 auto;}
.task-object-line .task-object-trigger{flex:1 1 auto;width:auto;min-width:0;}
.task-object-line .recurrence-inline-indicator{margin-left:0;align-self:flex-start;}
.task-object-line .task-resource-indicators{margin-left:0;align-self:flex-start;}
.task-object-line .recurrence-badge{white-space:nowrap;}
.resource-dot{width:12px;height:12px;min-width:12px;}
@media(max-width:767px){.resource-dot{width:10px;height:10px;min-width:10px;}}
/* Le colonne Allegati e Link sono ora rappresentate dai pallini accanto all'Oggetto. */
.active-tasks-table th:nth-child(7),.active-tasks-table td:nth-child(7),
.active-tasks-table th:nth-child(8),.active-tasks-table td:nth-child(8),
.historical-tasks-table th:nth-child(7),.historical-tasks-table td:nth-child(7),
.historical-tasks-table th:nth-child(8),.historical-tasks-table td:nth-child(8){display:table-cell;}
.active-tasks-table th:nth-child(n+7),.active-tasks-table td:nth-child(n+7),
.historical-tasks-table th:nth-child(n+7),.historical-tasks-table td:nth-child(n+7){display:none;}
.active-tasks-table th:nth-child(1),.active-tasks-table td:nth-child(1),
.historical-tasks-table th:nth-child(1),.historical-tasks-table td:nth-child(1){width:auto !important;}
.active-tasks-table th:nth-child(2),.active-tasks-table td:nth-child(2),
.historical-tasks-table th:nth-child(2),.historical-tasks-table td:nth-child(2){width:15% !important;}
.active-tasks-table th:nth-child(3),.active-tasks-table td:nth-child(3),
.historical-tasks-table th:nth-child(3),.historical-tasks-table td:nth-child(3){width:8% !important;}
.active-tasks-table th:nth-child(4),.active-tasks-table td:nth-child(4),
.historical-tasks-table th:nth-child(4),.historical-tasks-table td:nth-child(4){width:11% !important;}
.active-tasks-table th:nth-child(5),.active-tasks-table td:nth-child(5),
.historical-tasks-table th:nth-child(5),.historical-tasks-table td:nth-child(5){width:11% !important;}
.active-tasks-table th:nth-child(6),.active-tasks-table td:nth-child(6),
.historical-tasks-table th:nth-child(6),.historical-tasks-table td:nth-child(6){width:9% !important;}
.active-tasks-table th:nth-child(7),.active-tasks-table td:nth-child(7),
.historical-tasks-table th:nth-child(7),.historical-tasks-table td:nth-child(7){width:15% !important;}
@media(max-width:860px) and (min-width:768px){
 .active-tasks-table th:nth-child(1),.active-tasks-table td:nth-child(1),.historical-tasks-table th:nth-child(1),.historical-tasks-table td:nth-child(1){width:auto !important;}
 .active-tasks-table th:nth-child(2),.active-tasks-table td:nth-child(2),.historical-tasks-table th:nth-child(2),.historical-tasks-table td:nth-child(2){width:16% !important;}
 .active-tasks-table th:nth-child(3),.active-tasks-table td:nth-child(3),.historical-tasks-table th:nth-child(3),.historical-tasks-table td:nth-child(3){width:9% !important;}
 .active-tasks-table th:nth-child(4),.active-tasks-table td:nth-child(4),.historical-tasks-table th:nth-child(4),.historical-tasks-table td:nth-child(4){width:12% !important;}
 .active-tasks-table th:nth-child(5),.active-tasks-table td:nth-child(5),.historical-tasks-table th:nth-child(5),.historical-tasks-table td:nth-child(5){width:12% !important;}
 .active-tasks-table th:nth-child(6),.active-tasks-table td:nth-child(6),.historical-tasks-table th:nth-child(6),.historical-tasks-table td:nth-child(6){width:10% !important;}
 .active-tasks-table th:nth-child(7),.active-tasks-table td:nth-child(7),.historical-tasks-table th:nth-child(7),.historical-tasks-table td:nth-child(7){width:14% !important;}
}

/* v118.6 - allineamento intestazione Azioni con i comandi delle righe */
.active-tasks-table table,
.historical-tasks-table table { table-layout: fixed; width: 100%; }
.active-tasks-table th:nth-child(1), .active-tasks-table td:nth-child(1),
.historical-tasks-table th:nth-child(1), .historical-tasks-table td:nth-child(1) { width: 31% !important; }
.active-tasks-table th:nth-child(2), .active-tasks-table td:nth-child(2),
.historical-tasks-table th:nth-child(2), .historical-tasks-table td:nth-child(2) { width: 15% !important; }
.active-tasks-table th:nth-child(3), .active-tasks-table td:nth-child(3),
.historical-tasks-table th:nth-child(3), .historical-tasks-table td:nth-child(3) { width: 8% !important; }
.active-tasks-table th:nth-child(4), .active-tasks-table td:nth-child(4),
.historical-tasks-table th:nth-child(4), .historical-tasks-table td:nth-child(4) { width: 11% !important; }
.active-tasks-table th:nth-child(5), .active-tasks-table td:nth-child(5),
.historical-tasks-table th:nth-child(5), .historical-tasks-table td:nth-child(5) { width: 11% !important; }
.active-tasks-table th:nth-child(6), .active-tasks-table td:nth-child(6),
.historical-tasks-table th:nth-child(6), .historical-tasks-table td:nth-child(6) { width: 9% !important; }
.active-tasks-table th:nth-child(7), .active-tasks-table td:nth-child(7),
.historical-tasks-table th:nth-child(7), .historical-tasks-table td:nth-child(7) {
  display: table-cell !important;
  width: 15% !important;
}
.active-tasks-table th:nth-child(7),
.historical-tasks-table th:nth-child(7) {
  text-align: center !important;
  vertical-align: middle !important;
  white-space: nowrap;
}
.active-tasks-table td.actions-cell,
.historical-tasks-table td.actions-cell {
  display: table-cell !important;
  width: 15% !important;
  min-width: 0;
  max-width: none;
  padding: 10px 6px;
  text-align: center !important;
  vertical-align: middle !important;
  white-space: nowrap;
  border-bottom: 0 !important;
  overflow: visible !important;
}
.active-tasks-table td.actions-cell .btn-icon-only,
.historical-tasks-table td.actions-cell .btn-icon-only {
  display: inline-flex;
  vertical-align: middle;
  margin: 0 2px;
}
@media(max-width:860px) and (min-width:768px) {
  .active-tasks-table th:nth-child(1), .active-tasks-table td:nth-child(1),
  .historical-tasks-table th:nth-child(1), .historical-tasks-table td:nth-child(1) { width: 29% !important; }
  .active-tasks-table th:nth-child(2), .active-tasks-table td:nth-child(2),
  .historical-tasks-table th:nth-child(2), .historical-tasks-table td:nth-child(2) { width: 16% !important; }
  .active-tasks-table th:nth-child(3), .active-tasks-table td:nth-child(3),
  .historical-tasks-table th:nth-child(3), .historical-tasks-table td:nth-child(3) { width: 9% !important; }
  .active-tasks-table th:nth-child(4), .active-tasks-table td:nth-child(4),
  .historical-tasks-table th:nth-child(4), .historical-tasks-table td:nth-child(4) { width: 12% !important; }
  .active-tasks-table th:nth-child(5), .active-tasks-table td:nth-child(5),
  .historical-tasks-table th:nth-child(5), .historical-tasks-table td:nth-child(5) { width: 12% !important; }
  .active-tasks-table th:nth-child(6), .active-tasks-table td:nth-child(6),
  .historical-tasks-table th:nth-child(6), .historical-tasks-table td:nth-child(6) { width: 10% !important; }
  .active-tasks-table th:nth-child(7), .active-tasks-table td:nth-child(7),
  .historical-tasks-table th:nth-child(7), .historical-tasks-table td:nth-child(7) { width: 12% !important; }
}

/* v118.7 - prima colonna task: ID/ricorrenza, oggetto e risorse su righe separate */
.oggetto-cell .task-object-meta-line{display:flex;align-items:center;gap:7px;min-height:20px;width:100%;line-height:1.2;}
.oggetto-cell .task-object-title-line{display:block;width:100%;min-width:0;margin-top:3px;}
.oggetto-cell .task-object-title-line .task-object-trigger{display:block;width:100%;min-width:0;margin:0;padding:0;text-align:left;overflow:hidden;text-overflow:ellipsis;white-space:normal;}
.oggetto-cell .task-object-resources-line{display:block;width:100%;min-height:16px;margin-top:4px;}
.oggetto-cell .task-object-resources-line .task-resource-indicators{margin-left:0;}
.oggetto-cell .recurrence-inline-indicator{margin-left:0;}


/* v118.10 - Calendari settimanale e mensile estesi verticalmente fino allo spazio utile dello schermo */
@media (min-width: 768px) {
  .calendar-card-fullheight {
    min-height: calc(100vh - 150px);
    display: flex;
    flex-direction: column;
  }

  .calendar-card-fullheight .calendar-controls {
    flex: 0 0 auto;
  }

  .calendar-card-fullheight #calendarContainer {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .calendar-card-fullheight .calendar-grid-month {
    flex: 1 1 auto;
    min-height: 0;
    grid-template-rows: 38px repeat(6, minmax(0, 1fr));
  }

  .calendar-card-fullheight .calendar-cell {
    min-height: 0;
    height: auto;
    overflow: hidden;
  }

  .calendar-card-fullheight .calendar-vertical-week {
    flex: 1 1 auto;
    min-height: 0;
    gap: 6px;
  }

  .calendar-card-fullheight .week-row {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
  }

  .calendar-card-fullheight .week-events-container {
    min-height: 0;
    overflow: auto;
    align-content: flex-start;
  }
}

@media (max-width: 767px) {
  .calendar-card-fullheight {
    min-height: calc(100vh - 120px);
  }
}


/* v118.14 - Anteprima link nel form Nuovo/Modifica Task */
.task-link-preview {
  display:inline-flex;
  align-items:center;
  gap:7px;
  width:max-content;
  max-width:100%;
  margin-top:8px;
  padding:7px 11px;
  border:1px solid color-mix(in srgb,var(--primary,#3b82f6) 22%,var(--border-color,#e2e8f0));
  border-radius:8px;
  background:color-mix(in srgb,var(--primary,#3b82f6) 7%,var(--card-bg,#fff));
  color:var(--primary,#2563eb);
  font-size:.84rem;
  font-weight:600;
  text-decoration:none;
  line-height:1.2;
}
.task-link-preview:hover {
  background:color-mix(in srgb,var(--primary,#3b82f6) 12%,var(--card-bg,#fff));
  text-decoration:none;
}
.task-link-preview .ui-icon { width:16px; height:16px; flex:0 0 auto; }
@media(max-width:575px){
  .task-link-preview { max-width:100%; }
}

.admin-backup-card .backup-actions{display:flex;flex-wrap:wrap;gap:10px;align-items:center;margin:14px 0}.backup-upload-label{cursor:pointer;display:inline-flex;align-items:center}.backup-status{min-height:22px;margin:8px 0 12px;font-size:.9rem}.backup-status a{font-weight:700}.backup-status strong{word-break:break-all}
@media(max-width:767px){.admin-backup-card .backup-actions{flex-direction:column;align-items:stretch}.admin-backup-card .backup-actions .btn{width:100%;justify-content:center}}
