:root{
  --blue:#159bd7;
  --blue-dark:#0879b4;
  --ink:#0f172a;
  --muted:#64748b;
  --line:#dbe7f3;
  --soft:#f5f9fd;
  --ok:#18a566;
  --warn:#d89b16;
  --danger:#d94b4b;
  --white:#ffffff;
}

*{box-sizing:border-box}

body{
  margin:0;
  font-family:system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;
  background:
    radial-gradient(circle at top left,rgba(21,155,215,.15),transparent 32%),
    linear-gradient(135deg,#f7fbff,#eef6fb);
  color:var(--ink);
}

button,input{
  font:inherit;
}

.app-shell{
  min-height:100vh;
  display:grid;
  grid-template-columns:260px 1fr;
}

.sidebar{
  background:rgba(255,255,255,.78);
  border-right:1px solid var(--line);
  padding:22px 18px;
  backdrop-filter:blur(14px);
}

.brand{
  display:flex;
  gap:12px;
  align-items:center;
  margin-bottom:32px;
}

.brand-mark{
  width:46px;
  height:46px;
  border-radius:16px;
  display:grid;
  place-items:center;
  background:linear-gradient(135deg,var(--blue),#7dd3fc);
  color:#fff;
  font-weight:900;
}

.brand strong{
  display:block;
  font-size:18px;
}

.brand span{
  display:block;
  color:var(--muted);
  font-size:13px;
}

.nav{
  display:grid;
  gap:8px;
}

.nav-item{
  border:0;
  width:100%;
  text-align:left;
  padding:12px 14px;
  border-radius:14px;
  background:transparent;
  color:#334155;
  cursor:pointer;
  font-weight:700;
}

.nav-item.active,
.nav-item:hover{
  background:#e8f4ff;
  color:var(--blue-dark);
}

.main{
  padding:28px;
}

.topbar{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:18px;
  margin-bottom:22px;
}

.eyebrow{
  margin:0 0 4px;
  color:var(--blue-dark);
  text-transform:uppercase;
  letter-spacing:.08em;
  font-size:12px;
  font-weight:900;
}

h1,h2,p{
  margin-top:0;
}

h1{
  margin-bottom:0;
  font-size:clamp(28px,4vw,44px);
  letter-spacing:-.04em;
}

h2{
  margin-bottom:4px;
}

.top-actions,
.quick-actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

.primary-btn,
.ghost-btn{
  border:0;
  border-radius:14px;
  padding:11px 16px;
  cursor:pointer;
  font-weight:900;
}

.primary-btn{
  background:linear-gradient(135deg,var(--blue),var(--blue-dark));
  color:white;
  box-shadow:0 12px 28px rgba(21,155,215,.22);
}

.ghost-btn{
  background:white;
  color:var(--blue-dark);
  border:1px solid var(--line);
}

.stats-grid{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:14px;
  margin-bottom:18px;
}

.stat-card{
  background:white;
  border:1px solid var(--line);
  border-radius:24px;
  padding:22px;
  box-shadow:0 16px 36px rgba(15,23,42,.06);
  border-bottom:4px solid var(--blue);
}

.stat-card span{
  display:block;
  color:var(--muted);
  font-weight:800;
  margin-bottom:8px;
}

.stat-card strong{
  font-size:42px;
  letter-spacing:-.05em;
}

.stat-card.ok{border-bottom-color:var(--ok)}
.stat-card.warning{border-bottom-color:var(--warn)}
.stat-card.danger{border-bottom-color:var(--danger)}

.content-grid{
  display:grid;
  grid-template-columns:minmax(0,1.45fr) minmax(340px,.55fr);
  gap:18px;
  align-items:start;
}

.panel{
  background:rgba(255,255,255,.86);
  border:1px solid var(--line);
  border-radius:28px;
  padding:20px;
  box-shadow:0 18px 44px rgba(15,23,42,.07);
}

.panel-head{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:14px;
  margin-bottom:14px;
}

.panel-head p{
  color:var(--muted);
  margin-bottom:0;
}

#searchInput{
  width:min(360px,100%);
  border:1px solid var(--line);
  border-radius:14px;
  padding:12px 14px;
  background:white;
  outline:none;
}

.filters{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-bottom:14px;
}

.filter{
  border:1px solid var(--line);
  background:white;
  border-radius:999px;
  padding:8px 12px;
  cursor:pointer;
  font-weight:800;
  color:#334155;
}

.filter.active{
  background:var(--ink);
  color:white;
}

.table-wrap{
  overflow:auto;
}

table{
  width:100%;
  border-collapse:collapse;
  min-width:680px;
}

th,td{
  text-align:left;
  padding:13px 10px;
  border-bottom:1px solid #e7eef7;
  vertical-align:middle;
}

th{
  font-size:12px;
  color:var(--muted);
  text-transform:uppercase;
  letter-spacing:.06em;
}

.member-name{
  font-weight:900;
}

.member-email{
  display:block;
  color:var(--muted);
  font-size:13px;
  margin-top:2px;
}

.badge{
  display:inline-flex;
  align-items:center;
  border-radius:999px;
  padding:6px 10px;
  font-size:12px;
  font-weight:900;
  background:#eef6ff;
  color:var(--blue-dark);
}

.badge.ok{
  background:#eafaf2;
  color:var(--ok);
}

.badge.warning{
  background:#fff7df;
  color:#9a6a00;
}

.badge.danger{
  background:#fff0f0;
  color:var(--danger);
}

.open-btn{
  border:0;
  background:#eef6ff;
  color:var(--blue-dark);
  border-radius:12px;
  padding:9px 12px;
  cursor:pointer;
  font-weight:900;
}

.empty-state{
  padding:28px 8px;
  color:var(--muted);
}

.hidden{
  display:none;
}

.detail-head{
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:flex-start;
  margin-bottom:18px;
}

.status-pill{
  border-radius:999px;
  padding:8px 11px;
  font-size:12px;
  font-weight:900;
  background:#eef6ff;
  color:var(--blue-dark);
  white-space:nowrap;
}

.status-pill.attivo{
  background:#eafaf2;
  color:var(--ok);
}

.status-pill.da-rinnovare{
  background:#fff7df;
  color:#9a6a00;
}

.status-pill.scaduto{
  background:#fff0f0;
  color:var(--danger);
}

.info-list{
  display:grid;
  gap:8px;
  margin-bottom:16px;
}

.info-list p{
  display:flex;
  justify-content:space-between;
  gap:12px;
  margin:0;
  padding:10px 0;
  border-bottom:1px solid #eef3f8;
}

.info-list span{
  color:var(--muted);
  font-weight:700;
}

.info-list strong{
  text-align:right;
}

.card-preview{
  overflow:hidden;
  border-radius:24px;
  background:linear-gradient(160deg,var(--blue),#0f7fb8);
  color:white;
  box-shadow:0 18px 34px rgba(21,155,215,.28);
  margin:18px 0;
}

.card-top{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:16px 18px;
  background:rgba(255,255,255,.16);
  font-weight:900;
}

.card-body{
  padding:18px;
}

.card-body small{
  display:block;
  opacity:.82;
  font-weight:900;
  letter-spacing:.08em;
  margin-bottom:4px;
}

.card-body strong{
  display:block;
  font-size:26px;
  line-height:1.05;
  margin-bottom:18px;
}

.qr-box{
  width:130px;
  height:130px;
  margin:12px auto;
  background:#fff;
  border-radius:12px;
  display:flex;
  align-items:center;
  justify-content:center;
}

.qr-box canvas{
  width:110px !important;
  height:110px !important;
}

#qrCanvas{
  width:126px!important;
  height:126px!important;
}

#cardNumber{
  display:block;
  text-align:center;
  font-weight:800;
  opacity:.9;
}

@media(max-width:980px){
  .app-shell{
    grid-template-columns:1fr;
  }

  .sidebar{
    position:static;
    border-right:0;
    border-bottom:1px solid var(--line);
  }

  .nav{
    grid-template-columns:repeat(5,minmax(120px,1fr));
    overflow:auto;
  }

  .stats-grid{
    grid-template-columns:repeat(2,1fr);
  }

  .content-grid{
    grid-template-columns:1fr;
  }
}

@media(max-width:640px){
  .main{
    padding:18px 12px;
  }

  .topbar,
  .panel-head{
    display:block;
  }

  .top-actions{
    margin-top:14px;
  }

  .stats-grid{
    grid-template-columns:1fr;
  }

  .panel{
    border-radius:22px;
    padding:16px;
  }

  h1{
    font-size:30px;
  }

  #searchInput{
    margin-top:12px;
  }
}
.modal-overlay{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.4);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:999;
}

.modal{
  background:white;
  border-radius:24px;
  padding:24px;
  width:min(520px,90%);
}

.form-grid{
  display:grid;
  gap:10px;
  margin:14px 0;
}

.form-grid input,
.form-grid select{
  padding:12px;
  border-radius:12px;
  border:1px solid var(--line);
}

.modal-actions{
  display:flex;
  justify-content:flex-end;
  gap:10px;
}
.modal-overlay.hidden{
  display:none !important;
}
.modal-overlay.hidden{
  display:none !important;
}

.quick-actions button{
  padding:10px 12px;
  border-radius:10px;
  border:1px solid #dbe7f3;
  background:#fff;
  cursor:pointer;
  font-weight:700;
}

.quick-actions button:hover{
  background:#f0f7ff;
}

.status-pill{
  display:inline-block;
  padding:6px 10px;
  border-radius:999px;
  font-size:12px;
  font-weight:900;
  margin-bottom:10px;
}

.status-pill.attivo{
  background:#eafaf2;
  color:#18a566;
}

.status-pill.da-rinnovare{
  background:#fff7df;
  color:#9a6a00;
}

.status-pill.scaduto{
  background:#fff0f0;
  color:#d94b4b;
}

.badge.ok{
  background:#eafaf2;
  color:#18a566;
}

.badge.warning{
  background:#fff7df;
  color:#9a6a00;
}

.badge.danger{
  background:#fff0f0;
  color:#d94b4b;
}
#whatsappBtn{
  background:#25D366;
  color:#fff;
  border:none;
  padding:10px 14px;
  border-radius:10px;
  font-weight:700;
  cursor:pointer;
}

#whatsappBtn:hover{
  background:#1ebe5d;
}