  :root {
    --bg: #0d0f14;
    --surface: #161921;
    --surface2: #1e2330;
    --surface3: #252c3d;
    --border: #2a3147;
    --border2: #384060;
    --accent: #8b1a1a;
    --accent2: #a83232;
    --accent-dim: rgba(139,26,26,0.10);
    --green: #3ecf8e;
    --green-dim: rgba(62,207,142,0.12);
    --orange: #f5a623;
    --orange-dim: rgba(245,166,35,0.12);
    --red: #f05b5b;
    --red-dim: rgba(240,91,91,0.12);
    --purple: #a78bfa;
    --purple-dim: rgba(167,139,250,0.12);
    --text: #e8eaf2;
    --text2: #8b92aa;
    --text3: #5a617a;
    --mono: 'DM Mono', monospace;
    --font: 'DM Sans', sans-serif;
    --radius: 10px;
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }
  
  body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    overflow: hidden;
  }

  /* SIDEBAR */
  .sidebar {
    width: 240px;
    min-height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 100;
  }

  .sidebar-logo {
    padding: 28px 20px 24px;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-logo .brand {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
  }
  .sidebar-logo .brand span { color: var(--accent); }
  .sidebar-logo .sub {
    font-size: 11px;
    color: var(--text3);
    margin-top: 3px;
    font-family: var(--mono);
    text-transform: uppercase;
    letter-spacing: 1px;
  }

  .nav-section {
    padding: 16px 12px 8px;
  }
  .nav-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    padding: 0 8px;
    margin-bottom: 6px;
  }
  .nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text2);
    font-size: 13.5px;
    font-weight: 500;
    transition: all 0.15s;
    margin-bottom: 2px;
    user-select: none;
  }
  .nav-item:hover { background: var(--surface2); color: var(--text); }
  .nav-item.active { background: var(--accent-dim); color: var(--accent2); }
  .nav-item .icon { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }
  .nav-badge {
    margin-left: auto;
    background: var(--surface3);
    color: var(--text2);
    font-size: 10px;
    font-family: var(--mono);
    padding: 2px 7px;
    border-radius: 20px;
    min-width: 22px;
    text-align: center;
  }
  .nav-item.active .nav-badge { background: var(--accent); color: #fff; }

  .sidebar-footer {
    margin-top: auto;
    padding: 16px 12px;
    border-top: 1px solid var(--border);
  }
  .version-tag {
    font-size: 11px;
    color: var(--text3);
    font-family: var(--mono);
    text-align: center;
  }

  /* MAIN */
  .main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
  }

  .topbar {
    height: 60px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 28px;
    gap: 16px;
    flex-shrink: 0;
  }
  .page-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    flex: 1;
  }
  .topbar-actions { display: flex; gap: 10px; align-items: center; }

  .btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
    white-space: nowrap;
  }
  .btn-primary {
    background: var(--accent);
    color: #fff;
  }
  .btn-primary:hover { background: var(--accent2); }
  .btn-secondary {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
  }
  .btn-secondary:hover { background: var(--surface3); border-color: var(--border2); }
  .btn-danger { background: var(--red-dim); color: var(--red); border: 1px solid rgba(240,91,91,0.2); }
  .btn-danger:hover { background: var(--red); color: #fff; }
  .btn-success { background: var(--green-dim); color: var(--green); border: 1px solid rgba(62,207,142,0.2); }
  .btn-success:hover { background: var(--green); color: #fff; }
  .btn-sm { padding: 5px 11px; font-size: 12px; }
  .btn-icon { padding: 8px; gap: 0; }

  /* CONTENT */
  .content {
    flex: 1;
    overflow-y: auto;
    padding: 28px;
  }

  /* PAGE */
  .page { display: none; }
  .page.active { display: block; }

  /* CARDS */
  .card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
  }
  .card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
  }
  .card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
  }
  .card-sub {
    font-size: 12px;
    color: var(--text3);
    margin-top: 2px;
  }

  /* STATS */
  .stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
  }
  .stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    position: relative;
    overflow: hidden;
  }
  .stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
  }
  .stat-card.blue::before { background: var(--accent); }
  .stat-card.green::before { background: var(--green); }
  .stat-card.orange::before { background: var(--orange); }
  .stat-card.purple::before { background: var(--purple); }
  .stat-icon {
    font-size: 22px;
    margin-bottom: 12px;
  }
  .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    font-family: var(--mono);
    line-height: 1;
  }
  .stat-label {
    font-size: 12px;
    color: var(--text3);
    margin-top: 6px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  /* TABLE */
  .table-wrap { overflow-x: auto; }
  table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
  }
  thead th {
    background: var(--surface2);
    color: var(--text3);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 10.5px;
    letter-spacing: 0.8px;
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
  }
  tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
  }
  tbody tr:hover { background: var(--surface2); }
  tbody td {
    padding: 12px 14px;
    color: var(--text);
    vertical-align: middle;
  }
  .td-mono { font-family: var(--mono); font-size: 12px; color: var(--text2); }
  .empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text3);
  }
  .empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
  .empty-state p { font-size: 14px; }

  /* BADGES */
  .badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
  }
  .badge-blue { background: var(--accent-dim); color: var(--accent2); }
  .badge-green { background: var(--green-dim); color: var(--green); }
  .badge-orange { background: var(--orange-dim); color: var(--orange); }
  .badge-red { background: var(--red-dim); color: var(--red); }
  .badge-purple { background: var(--purple-dim); color: var(--purple); }
  .badge-gray { background: var(--surface3); color: var(--text2); }

  /* FORMS */
  .form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
  .form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
  .form-full { grid-column: 1 / -1; }
  .form-group { display: flex; flex-direction: column; gap: 6px; }
  .form-group label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  .form-control {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 12px;
    color: var(--text);
    font-family: var(--font);
    font-size: 13.5px;
    transition: border-color 0.15s;
    width: 100%;
  }
  .form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
  }
  .form-control::placeholder { color: var(--text3); }
  textarea.form-control { resize: vertical; min-height: 90px; }
  select.form-control option { background: var(--surface2); }

  /* MODAL */
  .modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 20px;
    overflow-y: auto;
  }
  .modal-overlay.open { display: flex; }
  .modal {
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: 14px;
    width: 100%;
    max-width: 700px;
    box-shadow: var(--shadow);
    animation: modalIn 0.2s ease;
    margin: auto;
  }
  .modal-lg { max-width: 900px; }
  @keyframes modalIn {
    from { opacity: 0; transform: translateY(-16px) scale(0.98); }
    to { opacity: 1; transform: none; }
  }
  .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
  }
  .modal-title { font-size: 16px; font-weight: 600; }
  .modal-close {
    background: var(--surface2);
    border: none;
    color: var(--text2);
    width: 32px; height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
  }
  .modal-close:hover { background: var(--red-dim); color: var(--red); }
  .modal-body { padding: 24px; }
  .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
  }

  /* SEARCH BAR */
  .search-bar {
    position: relative;
    flex: 1;
    max-width: 320px;
  }
  .search-bar input {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px 8px 36px;
    color: var(--text);
    font-family: var(--font);
    font-size: 13px;
  }
  .search-bar input:focus { outline: none; border-color: var(--accent); }
  .search-bar .search-icon {
    position: absolute;
    left: 11px; top: 50%;
    transform: translateY(-50%);
    color: var(--text3);
    font-size: 14px;
  }

  /* ASSET TYPE ICONS */
  .asset-icon {
    width: 34px; height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
  }

  /* SECTION TABS */
  .tabs {
    display: flex;
    gap: 4px;
    background: var(--surface2);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 20px;
    width: fit-content;
  }
  .tab {
    padding: 7px 16px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    color: var(--text2);
    transition: all 0.15s;
    user-select: none;
  }
  .tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,0.3); }
  .tab:hover:not(.active) { color: var(--text); }

  /* REPORT PRINT */
  .report-section { margin-bottom: 24px; }
  .report-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
  }
  .report-meta {
    font-size: 12px;
    color: var(--text3);
    font-family: var(--mono);
    margin-bottom: 20px;
  }
  .report-kpi {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 20px;
  }
  .kpi-box {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    text-align: center;
  }
  .kpi-val {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent2);
    font-family: var(--mono);
  }
  .kpi-lbl { font-size: 11px; color: var(--text3); margin-top: 3px; text-transform: uppercase; letter-spacing: 0.5px; }

  /* DIVIDER */
  .divider {
    height: 1px;
    background: var(--border);
    margin: 20px 0;
  }

  /* INLINE EDIT CHIP */
  .chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--surface3);
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 12px;
    color: var(--text2);
    font-family: var(--mono);
    margin: 2px;
  }
  .chip .chip-del {
    cursor: pointer;
    color: var(--text3);
    font-size: 14px;
    line-height: 1;
  }
  .chip .chip-del:hover { color: var(--red); }

  /* SCROLLBAR */
  ::-webkit-scrollbar { width: 6px; height: 6px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 10px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--text3); }

  /* TOAST */
  .toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
  }
  .toast {
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: 10px;
    padding: 12px 18px;
    font-size: 13px;
    color: var(--text);
    box-shadow: var(--shadow);
    animation: toastIn 0.3s ease;
    max-width: 340px;
    pointer-events: auto;
  }
  .toast.success { border-left: 3px solid var(--green); }
  .toast.error { border-left: 3px solid var(--red); }
  @keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: none; }
  }

  /* =============================================
     RESPONSIVE — TABLET & MOBILE
  ============================================= */

  /* Overlay per chiudere la sidebar su mobile */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 90;
    backdrop-filter: blur(2px);
  }
  .sidebar-overlay.open { display: block; }

  /* Hamburger button (visibile solo su mobile) */
  .hamburger {
    display: none;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 36px; height: 36px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 18px;
    color: var(--text);
  }

  /* Bottom nav bar (mobile only) */
  .bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 62px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 200;
    padding: 0 4px;
    align-items: stretch;
  }
  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    cursor: pointer;
    padding: 6px 4px;
    border-radius: 10px;
    color: var(--text3);
    transition: all 0.15s;
    position: relative;
    margin: 6px 2px;
  }
  .bottom-nav-item.active { background: var(--accent-dim); color: var(--accent2); }
  .bottom-nav-item .bn-icon { font-size: 20px; line-height: 1; }
  .bottom-nav-item .bn-label { font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
  .bottom-nav-item .bn-badge {
    position: absolute;
    top: 4px; right: 8px;
    background: var(--accent);
    color: #fff;
    font-size: 9px;
    font-family: var(--mono);
    padding: 1px 5px;
    border-radius: 20px;
    min-width: 16px;
    text-align: center;
    display: none;
  }
  .bottom-nav-item .bn-badge.visible { display: block; }

  /* FAB — Floating Action Button (mobile) */
  .fab {
    display: none;
    position: fixed;
    bottom: 76px; right: 20px;
    width: 52px; height: 52px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    z-index: 150;
    box-shadow: 0 4px 20px rgba(139,26,26,0.5);
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
  }
  .fab:active { transform: scale(0.93); }

  /* ---- TABLET (≤900px) ---- */
  @media (max-width: 900px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid-3 { grid-template-columns: 1fr; }

    /* Dashboard 2-col grid → stack */
    #page-dashboard > div[style*="grid-template-columns:1fr 1fr"] {
      display: flex !important;
      flex-direction: column;
    }

    /* Topbar */
    .topbar { padding: 0 16px; }
    .content { padding: 16px; }
  }

  /* ---- MOBILE (≤640px) ---- */
  @media (max-width: 640px) {
    /* Hide desktop sidebar, show hamburger & bottom nav */
    .sidebar { 
      position: fixed;
      left: -260px;
      top: 0; bottom: 0;
      width: 260px;
      z-index: 95;
      transition: left 0.25s cubic-bezier(.4,0,.2,1);
      box-shadow: none;
    }
    .sidebar.mobile-open {
      left: 0;
      box-shadow: 4px 0 32px rgba(0,0,0,0.5);
    }
    .hamburger { display: flex; }
    .bottom-nav { display: flex; }
    .fab { display: flex; }

    /* Body padding for bottom nav */
    body { padding-bottom: 62px; overflow-y: auto; }
    .main { overflow: visible; display: flex; flex-direction: column; min-height: calc(100vh - 62px); }
    .content { overflow-y: visible; padding-bottom: 80px; }

    /* Topbar compact */
    .topbar { 
      height: 52px;
      padding: 0 12px;
      gap: 10px;
    }
    .page-title { font-size: 14px; }
    /* Hide topbar action buttons (use FAB instead) */
    .topbar-actions { display: none; }

    /* Content padding */
    .content { padding: 12px 12px 16px; }

    /* Stats 2x2 */
    .stats-grid { 
      grid-template-columns: 1fr 1fr;
      gap: 10px;
      margin-bottom: 14px;
    }
    .stat-card { padding: 14px; }
    .stat-value { font-size: 22px; }
    .stat-label { font-size: 10px; }
    .stat-icon { font-size: 18px; margin-bottom: 8px; }

    /* Cards */
    .card { padding: 14px; margin-bottom: 12px; }
    .card-header { flex-direction: column; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
    .card-header .search-bar { max-width: 100%; width: 100%; }

    /* Tabs scroll */
    .tabs {
      overflow-x: auto;
      width: 100%;
      -webkit-overflow-scrolling: touch;
      scrollbar-width: none;
      padding: 4px;
    }
    .tabs::-webkit-scrollbar { display: none; }
    .tab { white-space: nowrap; padding: 6px 14px; font-size: 12px; }

    /* Tables → card list on mobile */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table { min-width: 560px; }

    /* For interventi table (more columns) */
    #tbody-interventi ~ * table,
    .table-wrap table { min-width: 500px; }

    /* Modal full screen on mobile */
    .modal-overlay {
      padding: 0;
      align-items: flex-end;
    }
    .modal, .modal.modal-lg {
      max-width: 100%;
      width: 100%;
      border-radius: 20px 20px 0 0;
      max-height: 92vh;
      display: flex;
      flex-direction: column;
    }
    .modal-body {
      overflow-y: auto;
      flex: 1;
      -webkit-overflow-scrolling: touch;
    }
    .modal-header { padding: 16px 18px; }
    .modal-body { padding: 16px 18px; }
    .modal-footer { padding: 12px 18px; }
    .modal-footer .btn { flex: 1; justify-content: center; }

    /* Form grids single column */
    .form-grid, .form-grid-3 { grid-template-columns: 1fr; }

    /* Dashboard panels stack */
    #page-dashboard > div[style*="grid-template-columns"] {
      display: flex !important;
      flex-direction: column;
      gap: 12px;
    }

    /* Report page selects */
    #page-report > div[style*="grid-template-columns"] {
      display: flex !important;
      flex-direction: column;
      gap: 12px;
    }

    /* Report output mobile fixes */
    #report-output .card { padding: 14px; }
    #report-output [style*="grid-template-columns:1fr 1fr"] {
      display: flex !important;
      flex-direction: column;
      gap: 12px;
    }
    #report-output [style*="grid-template-columns: 1fr 1fr"] {
      display: flex !important;
      flex-direction: column;
      gap: 12px;
    }
    #report-output .report-kpi {
      grid-template-columns: 1fr 1fr !important;
      gap: 8px;
    }
    #report-output .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    #report-output table { min-width: 480px; font-size: 12px; }
    #report-output [style*="justify-content:flex-end"] {
      flex-wrap: wrap;
      gap: 8px;
    }
    #report-output .btn { flex: 1; justify-content: center; min-width: 120px; }

    /* Asset tabs compact */
    #asset-tabs { margin-bottom: 12px; }

    /* Table header hide less important cols on mobile */
    .td-hide-mobile { display: none; }

    /* Toast bottom adjustment */
    .toast-container { bottom: 80px; right: 12px; left: 12px; }
    .toast { max-width: 100%; }

    /* Buttons in tables: icon only */
    .btn.btn-sm.btn-icon { width: 32px; height: 32px; padding: 0; }
  }

  /* ---- SMALL MOBILE (≤380px) ---- */
  @media (max-width: 380px) {
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .stat-card { padding: 12px; }
    .stat-value { font-size: 20px; }
    .content { padding: 10px; }
  }

  .text-accent { color: var(--accent2); }
  .text-green { color: var(--green); }
  .text-orange { color: var(--orange); }
  .text-red { color: var(--red); }
  .text-muted { color: var(--text2); }
  .text-xs { font-size: 11px; }
  .mono { font-family: var(--mono); }
  .fw-600 { font-weight: 600; }
  .mt-2 { margin-top: 8px; }
  .mt-4 { margin-top: 16px; }
  .flex { display: flex; }
  .flex-center { display: flex; align-items: center; }
  .gap-2 { gap: 8px; }
  .gap-3 { gap: 12px; }

  /* GCAL */
  .gcal-btn {
    background: linear-gradient(135deg, #1a73e8, #34a853);
    color: #fff;
    border: none;
  }
  .gcal-btn:hover { opacity: 0.88; }
  .gcal-loader {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .6s linear infinite;
    vertical-align: middle;
  }
  @keyframes spin { to { transform: rotate(360deg); } }

  .software-warning {
    background: var(--orange-dim);
    border: 1px solid rgba(245,166,35,0.25);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 12.5px;
    color: var(--orange);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .expiry-soon { color: var(--orange); font-weight: 600; }
  .expiry-expired { color: var(--red); font-weight: 600; }

  /* CHECKLIST */
  .cl-sezione { margin-bottom: 22px; }
  .cl-sezione-title {
    font-size: 12px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .8px; color: var(--text3); margin-bottom: 10px;
    padding-bottom: 6px; border-bottom: 1px solid var(--border);
  }
  .cl-item {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 10px 0; border-bottom: 1px solid var(--border);
  }
  .cl-item:last-child { border-bottom: none; }
  .cl-item-label { flex: 1; font-size: 13.5px; color: var(--text); line-height: 1.4; }
  .cl-item-sub { font-size: 11px; color: var(--text3); margin-top: 2px; }
  .cl-radio-group { display: flex; gap: 6px; flex-shrink: 0; }
  .cl-radio { display: none; }
  .cl-radio-label {
    padding: 4px 10px; border-radius: 6px; font-size: 11px; font-weight: 600;
    cursor: pointer; border: 1px solid var(--border); color: var(--text2);
    background: var(--surface2); transition: all .15s; white-space: nowrap;
  }
  .cl-radio:checked + .cl-radio-label { border-color: transparent; }
  .cl-radio.ok:checked + .cl-radio-label { background: var(--green-dim); color: var(--green); border-color: rgba(62,207,142,.3); }
  .cl-radio.warn:checked + .cl-radio-label { background: var(--orange-dim); color: var(--orange); border-color: rgba(245,166,35,.3); }
  .cl-radio.ko:checked + .cl-radio-label { background: var(--red-dim); color: var(--red); border-color: rgba(240,91,91,.3); }
  .cl-radio.na:checked + .cl-radio-label { background: var(--surface3); color: var(--text3); border-color: var(--border2); }
  .cl-progress {
    background: var(--surface2); border-radius: 4px; height: 6px;
    margin-bottom: 16px; overflow: hidden;
  }
  .cl-progress-bar { height: 100%; border-radius: 4px; transition: width .3s; background: var(--green); }
  .cl-esito-badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600;
  }
  .cl-esito-ok { background: var(--green-dim); color: var(--green); }
  .cl-esito-warn { background: var(--orange-dim); color: var(--orange); }
  .cl-esito-ko { background: var(--red-dim); color: var(--red); }
  /* card hover checklist */
  #page-checklist .card[onclick]:hover { border-color: var(--accent2); transform: translateY(-2px); transition: all .2s; }
  /* AI analysis badge */
  .cl-ai-detail { animation: fadeInUp .3s ease; }
  @keyframes fadeInUp { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:translateY(0); } }
  #btn-ai-analisi { background: linear-gradient(135deg, #8b1a1a, #c0392b); border:none; transition: all .2s; }
  #btn-ai-analisi:hover:not(:disabled) { background: linear-gradient(135deg, #a83232, #e74c3c); transform:translateY(-1px); }
  #btn-ai-analisi:disabled { opacity:.6; cursor:not-allowed; transform:none; }

  /* TIMER INTERVENTO */
  .timer-box {
    background: var(--surface2);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    transition: border-color .2s;
  }
  .timer-box.running { border-color: var(--green); background: var(--green-dim); }
  .timer-box.paused  { border-color: var(--orange); background: var(--orange-dim); }
  .timer-box.stopped { border-color: var(--accent2); background: var(--accent-dim); }
  .timer-display {
    font-family: 'Courier New', monospace;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text);
    min-width: 100px;
    user-select: none;
  }
  .timer-box.running .timer-display { color: var(--green); }
  .timer-box.paused  .timer-display { color: var(--orange); }
  .timer-controls { display: flex; gap: 6px; align-items: center; }
  .timer-btn {
    width: 34px; height: 34px; border-radius: 8px;
    border: 1.5px solid var(--border); background: var(--surface);
    color: var(--text); font-size: 14px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all .15s;
  }
  .timer-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,.15); }
  .timer-btn:disabled { opacity: .3; cursor: not-allowed; }
  .timer-btn-start { background: var(--green-dim); border-color: var(--green); color: var(--green); }
  .timer-btn-pause  { background: var(--orange-dim); border-color: var(--orange); color: var(--orange); }
  .timer-btn-stop   { background: var(--red-dim); border-color: var(--red); color: var(--red); }
  .timer-btn-reset  { background: var(--surface2); color: var(--text3); }
  .timer-status {
    font-size: 10px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .6px; color: var(--text3); flex: 1;
  }
  .timer-box.running .timer-status { color: var(--green); }
  .timer-box.paused  .timer-status { color: var(--orange); }
  .timer-box.stopped .timer-status { color: var(--accent2); }

  /* SHARE BUTTONS */
  .btn-share-wa {
    background: #25d366; color: #fff; border: none;
    display: inline-flex; align-items: center; gap: 7px;
  }
  .btn-share-wa:hover { background: #1da851; }
  .btn-share-email {
    background: var(--surface2); color: var(--text);
    border: 1px solid var(--border);
  }
  .btn-share-email:hover { background: var(--surface3); border-color: var(--border2); }

  /* ====== LOGIN SCREEN ====== */
  #login-screen {
    position: fixed; inset: 0; z-index: 9999;
    background: var(--bg);
    display: flex; align-items: center; justify-content: center;
  }
  #login-screen.hidden { display: none; }
  .login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 48px 40px;
    width: 100%; max-width: 400px;
    box-shadow: 0 8px 48px rgba(0,0,0,0.6);
    display: flex; flex-direction: column; align-items: center; gap: 0;
  }
  .login-logo {
    font-size: 26px; font-weight: 700; letter-spacing: -1px;
    margin-bottom: 4px;
  }
  .login-logo span { color: var(--accent2); }
  .login-sub {
    font-size: 12px; color: var(--text3); margin-bottom: 32px;
  }
  .login-title {
    font-size: 18px; font-weight: 600; margin-bottom: 24px;
    color: var(--text);
  }
  .login-field {
    width: 100%; margin-bottom: 14px;
  }
  .login-field label {
    display: block; font-size: 12px; font-weight: 600;
    color: var(--text2); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .5px;
  }
  .login-field input {
    width: 100%; padding: 10px 14px;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text); font-size: 14px;
    font-family: var(--font); outline: none; transition: border .2s;
  }
  .login-field input:focus { border-color: var(--accent2); }
  .login-btn {
    width: 100%; padding: 12px; margin-top: 8px;
    background: var(--accent); color: #fff; border: none;
    border-radius: var(--radius); font-size: 15px; font-weight: 600;
    cursor: pointer; transition: background .2s;
  }
  .login-btn:hover { background: var(--accent2); }
  .login-error {
    background: var(--red-dim); border: 1px solid var(--red);
    color: var(--red); border-radius: 8px; padding: 10px 14px;
    font-size: 13px; width: 100%; margin-bottom: 4px; display: none;
  }
  .login-error.show { display: block; }
  .login-footer {
    margin-top: 24px; font-size: 11px; color: var(--text3); text-align: center;
  }
  /* user badge in topbar */
  .user-badge {
    display: flex; align-items: center; gap: 8px;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 20px; padding: 5px 12px 5px 8px;
    font-size: 13px; font-weight: 500; cursor: pointer;
    transition: border .2s;
  }
  .user-badge:hover { border-color: var(--accent2); }
  .user-avatar {
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--accent); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; overflow: hidden;
  }
  .user-avatar img { width: 100%; height: 100%; object-fit: cover; }
  @media (max-width: 640px) {
    .login-card { padding: 32px 22px; margin: 16px; }
  
  /* ====== REPORT STYLES ====== */
  #report-output { margin-top: 24px; }
  .report-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    max-width: 800px;
  }
  .report-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border);
  }
  .report-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 4px;
  }
  .report-section {
    margin-bottom: 24px;
  }
  .report-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--text3);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
  }
  .report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
  }
  .report-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
  }
  .report-table td:first-child {
    color: var(--text3);
    width: 35%;
    font-weight: 500;
  }
  .report-table td:last-child {
    color: var(--text);
  }
  /* Detail table (usata anche in modal dettaglio) */
  .detail-table { width: 100%; border-collapse: collapse; font-size: 13px; }
  .detail-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
  .detail-label { color: var(--text3); width: 35%; font-weight: 500; }
  .detail-table td:last-child { color: var(--text); }
  /* Dash rows */
  .dash-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    gap: 12px;
  }
  .dash-row:last-child { border-bottom: none; }
  /* Secret value */
  .secret-val { font-family: var(--mono); font-size: 12px; }
  .btn-reveal { background: none; border: none; cursor: pointer; margin-left: 6px; font-size: 14px; }
  /* Type badge */
  .type-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    padding: 3px 8px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 99px;
    white-space: nowrap;
  }
  /* Importo preview */
  #i-importo-preview {
    font-size: 13px;
    font-weight: 600;
    color: var(--green);
    margin-top: 6px;
  }

}
  /* Report page scroll fix */
  #page-report { min-height: auto; }
  #report-output { margin-top: 24px; padding-bottom: 40px; }


  /* ====== PRINT STYLES ====== */
  @media print {
    .sidebar, .topbar, .bottom-nav, .fab,
    .topbar-actions, #topbar-actions,
    .btn, button { display: none !important; }
    body { background: #fff !important; color: #000 !important; overflow: visible !important; display: block !important; }
    .main { overflow: visible !important; height: auto !important; display: block !important; }
    .content { overflow: visible !important; padding: 0 !important; display: block !important; }
    .page { display: none !important; }
    #page-report { display: block !important; }
    #report-output { display: block !important; }
    .report-card { border: none !important; padding: 0 !important; background: #fff !important; }
    .report-header h2, .report-section-title { color: #000 !important; }
    .report-table td { color: #000 !important; border-color: #ccc !important; }
    .report-section { page-break-inside: avoid; }
  }
