  :root {
    /* ── HW Style Brand Colors (dal logo ufficiale) ── */
    --green: #2e8b2e;          /* HW verde primario */
    --green-dark: #1e6b1e;     /* verde scuro sidebar/topbar */
    --green-light: #e8f5e9;    /* verde chiarissimo sfondo */
    --green-bright: #3daa3d;   /* verde brillante (triangolo logo) */
    --green-accent: #4cbb4c;   /* hover / accento */

    --earth: #5a7a5a; --earth-light: #f0f5f0; --earth-dark: #3d5c3d;
    --stone: #f5f7f5; --stone-dark: #e0e8e0;
    --dark: #152415;           /* sidebar bg (verde quasi nero) */
    --dark2: #1e341e;          /* sidebar gradient */

    --gray-50: #f7f9f7; --gray-100: #eef1ee; --gray-200: #dde3dd; --gray-300: #c0cac0;
    --gray-400: #8fa48f; --gray-500: #5f755f; --gray-700: #374537; --gray-900: #1a2a1a;

    --blue: #2563eb; --amber: #c2770e; --emerald: #2e8b2e; --red: #b91c1c; --violet: #6d28d9;
    --sand: #e8eee8;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }
  body { font-family: 'Plus Jakarta Sans', 'Segoe UI', sans-serif; background: var(--gray-50); color: var(--gray-900); overflow: hidden; height: 100vh; }
  h1,h2,h3,h4 { font-family: 'Outfit', sans-serif; letter-spacing: -0.02em; }
  button { font-family: inherit; }
  input, select, textarea { font-family: inherit; }
  ::-webkit-scrollbar { width: 6px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
  input:focus, select:focus, textarea:focus { border-color: var(--green) !important; box-shadow: 0 0 0 3px rgba(46,139,46,0.14) !important; outline: none; }

  /* ── Layout ── */
  #app { display: flex; height: 100vh; }

  /* ── Sidebar ── */
  .sidebar {
    width: 260px;
    background: linear-gradient(175deg, var(--dark) 0%, var(--dark2) 60%, #1a3a1a 100%);
    display: flex; flex-direction: column; flex-shrink: 0;
    transition: width .3s cubic-bezier(.4,0,.2,1); overflow: hidden; z-index: 10;
    position: relative;
  }
  .sidebar::before {
    content: ''; position: absolute; inset: 0; opacity: 0.03; pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 5 C25 15 15 20 10 30 C15 35 25 32 30 40 C35 32 45 35 50 30 C45 20 35 15 30 5Z' fill='%23ffffff' fill-opacity='0.5'/%3E%3C/svg%3E");
    background-size: 80px 80px;
  }
  .sidebar.collapsed { width: 72px; }
  .sidebar-brand { padding: 20px 16px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid rgba(255,255,255,.07); position: relative; min-height: 76px; }
  .sidebar.collapsed .sidebar-brand { padding: 20px 14px; justify-content: center; }

  /* Logo HW Style reale */
  .brand-logo-img { height: 36px; width: auto; object-fit: contain; flex-shrink: 0; filter: brightness(0) invert(1); }
  .sidebar.collapsed .brand-logo-img { height: 28px; }
  .brand-icon {
    width: 40px; height: 40px; border-radius: 10px;
    background: linear-gradient(135deg, var(--green-bright), var(--green));
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 800; color: #fff; flex-shrink: 0; font-family: 'Outfit';
    box-shadow: 0 2px 8px rgba(46,139,46,0.4); letter-spacing: -0.5px;
  }
  .brand-text { overflow: hidden; display: flex; flex-direction: column; }
  .sidebar.collapsed .brand-text, .sidebar.collapsed .nav-label, .sidebar.collapsed .user-info, .sidebar.collapsed .toggle-text { display: none; }
  .brand-name { font-family: 'Outfit'; font-weight: 800; font-size: 16px; color: #fff; white-space: nowrap; letter-spacing: -0.3px; }
  .brand-sub { font-size: 9px; color: rgba(255,255,255,.4); white-space: nowrap; text-transform: uppercase; letter-spacing: 1.5px; font-weight: 600; margin-top: 2px; }

  nav { flex: 1; padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; position: relative; }
  .nav-btn { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 10px; border: none; cursor: pointer; font-size: 13px; font-weight: 600; background: transparent; color: rgba(255,255,255,.45); transition: all .2s; width: 100%; text-align: left; }
  .sidebar.collapsed .nav-btn { justify-content: center; padding: 10px 0; }
  .nav-btn.active { background: rgba(61,170,61,.18); color: #a8e6a8; }
  .nav-btn:hover:not(.active) { background: rgba(255,255,255,.05); color: rgba(255,255,255,.8); }
  .nav-icon { font-size: 17px; flex-shrink: 0; }

  .sidebar-footer { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.06); position: relative; }
  .sidebar.collapsed .sidebar-footer { padding: 12px; }
  .toggle-btn { width: 100%; padding: 8px; border-radius: 8px; border: 1px solid rgba(255,255,255,.08); background: rgba(255,255,255,.03); color: rgba(255,255,255,.3); cursor: pointer; font-size: 12px; transition: all .2s; }
  .toggle-btn:hover { background: rgba(255,255,255,.06); color: rgba(255,255,255,.6); }

  .sidebar-user { padding: 10px 16px 18px; border-top: 1px solid rgba(255,255,255,.06); display: flex; align-items: center; gap: 10px; position: relative; }
  .sidebar.collapsed .sidebar-user { padding: 10px; justify-content: center; }
  .avatar { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, var(--green-bright), var(--green-dark)); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 11px; font-weight: 700; flex-shrink: 0; font-family: 'Outfit'; }
  .user-name { font-size: 12px; font-weight: 600; color: rgba(255,255,255,.82); white-space: nowrap; }
  .user-role { font-size: 10px; color: rgba(255,255,255,.32); text-transform: uppercase; letter-spacing: 0.8px; font-weight: 600; }

  /* ── Main ── */
  .main { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--gray-50); }
  .topbar { height: 64px; padding: 0 28px; display: flex; align-items: center; justify-content: space-between; background: #fff; border-bottom: 1px solid var(--gray-200); flex-shrink: 0; }
  .topbar-title { font-size: 19px; font-weight: 700; color: var(--dark); }
  .topbar-actions { display: flex; align-items: center; gap: 12px; }
  .search-box { position: relative; }
  .search-box input { padding: 8px 14px 8px 36px; border-radius: 10px; border: 1px solid var(--gray-200); font-size: 13px; width: 220px; background: var(--gray-50); }
  .search-box .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 14px; }

  .btn-primary { padding: 9px 20px; border-radius: 10px; border: none; background: linear-gradient(135deg, var(--green-bright), var(--green)); color: #fff; font-weight: 700; font-size: 13px; cursor: pointer; box-shadow: 0 2px 10px rgba(46,139,46,.22); transition: all .2s; }
  .btn-primary:hover { box-shadow: 0 4px 16px rgba(46,139,46,.32); transform: translateY(-1px); }
  .btn-outline { padding: 8px 14px; border-radius: 10px; border: 1px solid var(--gray-200); background: #fff; cursor: pointer; font-size: 12px; color: var(--gray-500); transition: all .2s; }
  .btn-outline:hover { border-color: var(--gray-300); background: var(--stone); }
  .offline-badge { display:inline-flex; align-items:center; gap:4px; padding:5px 12px; border-radius:20px; background:#b00020; color:#fff; font-size:12px; font-weight:700; animation: pulse-offline 1.5s infinite; }
  @keyframes pulse-offline { 0%,100%{opacity:1} 50%{opacity:.65} }
  .content { flex: 1; overflow: auto; padding: 24px 28px; }

  /* ── Cards & Shared ── */
  .stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
  .stat-card { padding: 20px; border-radius: 14px; background: #fff; border: 1px solid var(--gray-200); box-shadow: 0 1px 3px rgba(0,0,0,.03); transition: all .25s; cursor: pointer; animation: fadeIn .4s ease; }
  .stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.06); }
  .stat-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
  .stat-icon { font-size: 26px; }
  .stat-dot { width: 8px; height: 8px; border-radius: 50%; }
  .stat-value { font-size: 28px; font-weight: 800; font-family: 'Outfit'; color: var(--dark); }
  .stat-label { font-size: 13px; color: var(--gray-500); margin-top: 4px; }
  .stat-sub { font-size: 11px; color: var(--gray-400); margin-top: 4px; }

  .badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 6px; }
  .badge-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }

  .card { background: #fff; border-radius: 14px; padding: 22px; border: 1px solid var(--gray-200); }
  .card-title { font-size: 15px; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }

  .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 22px; }
  .grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

  .filter-bar { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
  .filter-btn { padding: 8px 18px; border-radius: 10px; border: 1px solid var(--gray-200); cursor: pointer; font-size: 13px; font-weight: 600; background: #fff; color: var(--gray-500); transition: all .2s; }
  .filter-btn:hover { border-color: var(--green); color: var(--green); background: var(--green-light); }
  .filter-btn.active { background: var(--green); color: #fff; border-color: var(--green); }

  .asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
  .asset-card { border-radius: 14px; background: #fff; border: 1px solid var(--gray-200); overflow: hidden; transition: all .25s; animation: fadeIn .4s ease; }
  .asset-card:hover { transform: translateY(-3px); box-shadow: 0 8px 28px rgba(0,0,0,.07); }

  table { width: 100%; border-collapse: collapse; font-size: 13px; }
  th { padding: 11px 16px; text-align: left; font-weight: 700; color: var(--gray-500); font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px; background: var(--stone); font-family: 'Outfit'; }
  td { padding: 11px 16px; border-top: 1px solid var(--gray-100); }

  .progress-bar { height: 6px; border-radius: 3px; overflow: hidden; }
  .progress-fill { height: 100%; border-radius: 3px; transition: width .5s; }

  /* ── Modal ── */
  .modal-overlay { position: fixed; inset: 0; background: rgba(15,30,15,.6); display: flex; align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(6px); }
  .modal { width: 500px; background: #fff; border-radius: 18px; padding: 30px; box-shadow: 0 24px 64px rgba(0,0,0,.18); animation: fadeIn .3s ease; max-height: 90vh; overflow-y: auto; }
  .modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
  .modal-title { font-size: 20px; font-weight: 800; }
  .modal-close { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--gray-200); background: #fff; cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; transition: all .2s; }
  .modal-close:hover { background: var(--stone); }
  .form-group { margin-bottom: 14px; }
  .form-label { font-size: 11px; font-weight: 700; color: var(--gray-500); display: block; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; font-family: 'Outfit'; }
  .form-input { width: 100%; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--gray-200); font-size: 13px; outline: none; background: #fff; transition: all .2s; }
  .form-input:hover { border-color: var(--gray-300); }
  .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .btn-row { display: flex; gap: 10px; margin-top: 22px; }
  .btn-cancel { flex: 1; padding: 11px; border-radius: 10px; border: 1px solid var(--gray-200); background: #fff; cursor: pointer; font-size: 14px; font-weight: 600; transition: all .2s; }
  .btn-cancel:hover { background: var(--stone); }
  .btn-submit { flex: 2; padding: 11px; border-radius: 10px; border: none; cursor: pointer; font-size: 14px; font-weight: 700; background: linear-gradient(135deg, var(--green-bright), var(--green)); color: #fff; box-shadow: 0 4px 16px rgba(46,139,46,.22); transition: all .2s; }
  .btn-submit:hover { box-shadow: 0 6px 20px rgba(46,139,46,.32); transform: translateY(-1px); }

  /* ── Login ── */
  .login-bg {
    height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(145deg, #0a1a0a 0%, #152415 40%, #1e341e 70%, #152415 100%);
    position: relative; overflow: hidden;
  }
  .login-bg::before {
    content: ''; position: absolute; inset: 0; opacity: 0.025;
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M50 10 C40 25 25 35 15 50 C25 60 40 55 50 70 C60 55 75 60 85 50 C75 35 60 25 50 10Z' fill='%23ffffff'/%3E%3C/svg%3E");
    background-size: 120px 120px;
  }
  .login-bg::after {
    content: ''; position: absolute; bottom: -20%; left: -10%; width: 120%; height: 50%;
    background: radial-gradient(ellipse at center, rgba(46,139,46,0.12) 0%, transparent 70%);
  }
  .login-card { width: 420px; padding: 44px; border-radius: 22px; background: rgba(255,255,255,.04); backdrop-filter: blur(24px); border: 1px solid rgba(255,255,255,.08); box-shadow: 0 32px 64px rgba(0,0,0,.5); position: relative; z-index: 1; }
  .login-brand { text-align: center; margin-bottom: 36px; }
  .login-logo-img { height: 48px; width: auto; margin: 0 auto 16px; display: block; filter: brightness(0) invert(1); }
  .login-logo { width: 68px; height: 68px; border-radius: 18px; margin: 0 auto 16px; background: linear-gradient(135deg, var(--green-bright), var(--green)); display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 800; color: #fff; font-family: 'Outfit'; box-shadow: 0 4px 20px rgba(46,139,46,0.35); letter-spacing: -0.5px; }
  .login-title { font-size: 24px; font-weight: 800; color: #fff; margin-bottom: 6px; font-family: 'Outfit'; letter-spacing: -0.5px; }
  .login-sub { font-size: 13px; color: rgba(255,255,255,.38); font-weight: 500; }
  .login-input { width: 100%; padding: 13px 18px; border-radius: 12px; border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.06); color: #fff; font-size: 14px; outline: none; transition: all .2s; }
  .login-input:focus { background: rgba(255,255,255,.08); border-color: rgba(61,170,61,.5); }
  .login-input::placeholder { color: rgba(255,255,255,.22); }
  .login-btn { width: 100%; padding: 13px; border-radius: 12px; border: none; font-size: 15px; font-weight: 700; cursor: pointer; background: linear-gradient(135deg, var(--green-bright), var(--green)); color: #fff; margin-top: 10px; box-shadow: 0 4px 20px rgba(46,139,46,.35); transition: all .2s; font-family: 'Outfit'; }
  .login-btn:hover { box-shadow: 0 6px 28px rgba(46,139,46,.45); transform: translateY(-1px); }
  .login-btn:disabled { opacity: .6; }
  .login-demo { margin-top: 28px; padding: 16px; border-radius: 12px; background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.06); }
  .login-error { color: #fca5a5; font-size: 13px; text-align: center; margin-top: 8px; }

  /* ── Notification ── */
  .notification { position: fixed; top: 20px; right: 20px; padding: 14px 22px; border-radius: 12px; color: #fff; font-size: 14px; font-weight: 600; box-shadow: 0 8px 32px rgba(0,0,0,.2); z-index: 1000; animation: slideIn .3s ease; }
  .notification.success { background: var(--green); }
  .notification.error { background: var(--red); }

  /* ── Calendar ── */
  .cal-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 2px; }
  .cal-header { padding: 8px; text-align: center; font-size: 11px; font-weight: 700; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.5px; font-family: 'Outfit'; }
  .cal-day { min-height: 76px; padding: 6px; border-radius: 8px; border: 1px solid var(--gray-100); background: #fff; font-size: 12px; }
  .cal-day.today { border: 2px solid var(--green); background: var(--green-light); }
  .cal-event { padding: 2px 5px; border-radius: 4px; margin-bottom: 2px; font-size: 10px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; transition: opacity .2s; }
  .cal-event:hover { opacity: 0.8; }
  .cal-event.dragging { opacity: 0.4; }
  .cal-day.drag-over { background: var(--green-light) !important; border-color: var(--green) !important; }

  .row-flex { display: flex; align-items: center; gap: 10px; }
  .hidden { display: none !important; }

  @keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
  @keyframes slideIn { from { transform: translateX(80px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

  /* ── Responsive Mobile ── */
  @media (max-width: 768px) {
    body { overflow: auto; }
    #app { flex-direction: column; height: auto; min-height: 100vh; }

    /* Sidebar diventa barra top su mobile */
    .sidebar {
      width: 100% !important;
      height: auto;
      flex-direction: row;
      align-items: center;
      padding: 0 12px;
      min-height: 56px;
    }
    .sidebar::before { display: none; }
    .sidebar-brand { padding: 10px 8px; border-bottom: none; border-right: 1px solid rgba(255,255,255,.08); min-height: auto; flex-shrink: 0; }
    .sidebar.collapsed .sidebar-brand { justify-content: flex-start; }
    .brand-logo-img { height: 26px; }
    .brand-text { display: none !important; }

    nav { flex-direction: row; padding: 8px 6px; gap: 4px; flex: 1; overflow-x: auto; }
    .nav-btn { padding: 8px 10px; font-size: 11px; gap: 6px; white-space: nowrap; min-height: 40px; border-radius: 8px; justify-content: flex-start; }
    .nav-label { display: block !important; font-size: 11px; }
    .nav-icon { font-size: 15px; }
    .sidebar-footer, .sidebar-user, .toggle-btn { display: none !important; }

    /* Main content */
    .main { overflow: auto; }
    .topbar { height: 52px; padding: 0 16px; }
    .topbar-title { font-size: 16px; }
    .topbar-actions .search-box { display: none; }
    .topbar-actions .btn-primary { padding: 7px 14px; font-size: 12px; }
    .content { padding: 16px; overflow: visible; }

    /* Grids */
    .grid-2 { grid-template-columns: 1fr; gap: 12px; }
    .grid-3 { grid-template-columns: 1fr; gap: 10px; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .asset-grid { grid-template-columns: 1fr; }

    /* Modals */
    .modal-overlay { align-items: flex-end; padding: 0; }
    .modal { width: 100%; border-radius: 20px 20px 0 0; padding: 24px 20px; max-height: 88vh; }

    /* Tables scrollabili */
    .card { padding: 14px; overflow-x: auto; }
    table { min-width: 600px; }

    /* Touch targets */
    .nav-btn, .btn-primary, .btn-outline, .btn-submit, .btn-cancel, .filter-btn {
      min-height: 40px;
    }
    .filter-btn { padding: 8px 14px; font-size: 12px; }

    /* Login */
    .login-card { width: 100%; margin: 16px; padding: 32px 24px; }
  }

  @media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .stat-value { font-size: 22px; }
  }
