:root{
  --bg:#0b0e14;
  --panel:#111827;
  --panel-2:#0f172a;
  --panel-3:#020617;
  --border:rgba(148,163,184,.28);
  --border-strong:rgba(148,163,184,.42);
  --text:#e5e7eb;
  --muted:#9ca3af;
  --accent:#f97316;
  --accent-soft:rgba(249,115,22,.18);
  --link:#60a5fa;
  --danger:#ef4444;
  --ok:#22c55e;
  --shadow:0 18px 45px rgba(15,23,42,.65);
}

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

body.pd-dark.users-shell{
  margin:0;
  min-height:100vh;
  font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  font-size:15px;
  background:
    radial-gradient(1200px 600px at 0% 0%, rgba(249,115,22,.14), transparent 60%),
    radial-gradient(1000px 500px at 100% 0%, rgba(96,165,250,.16), transparent 55%),
    var(--bg);
  color:var(--text);
  padding-top:var(--header-h, 70px);
}

.container{
  max-width:1360px;
  margin:76px auto 36px;
  padding:0 14px 28px;
}

.pd-header{
  display:flex;
  align-items:center;
  gap:10px;
  margin-bottom:14px;
}

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  padding:8px 14px;
  border-radius:999px;
  border:1px solid transparent;
  background:#111827;
  color:var(--text);
  font-weight:600;
  font-size:14px;
  cursor:pointer;
  transition:background .15s, border-color .15s, transform .08s, box-shadow .15s;
}

.btn:hover{
  background:#1f2937;
  transform:translateY(-1px);
  box-shadow:0 8px 20px rgba(0,0,0,.35);
}

.btn-secondary{
  background:#020617;
  border-color:var(--border);
}

/* ===== Pagina lista utenti ===== */

.users-page{
  width:min(1280px, 100%);
  margin:0 auto;
}

.users-title{
  font-size:28px;
  font-weight:800;
  margin:0 0 10px;
  text-align:center;
  letter-spacing:.01em;
}

.users-sub{
  text-align:center;
  font-size:13px;
  color:var(--muted);
  margin:0 0 16px;
}

.users-stats-bar{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  justify-content:center;
  margin-bottom:14px;
  background:rgba(17,24,39,.88);
  border-radius:12px;
  padding:10px 12px;
  border:1px solid var(--border);
  box-shadow:0 10px 26px rgba(0,0,0,.38);
}

.users-stats-item{
  min-width:130px;
  padding:5px 9px;
  border-radius:8px;
  text-align:center;
  font-size:12px;
  color:var(--text);
}

.users-stats-label{
  display:block;
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:.05em;
  color:var(--muted);
  margin-bottom:2px;
}

.users-stats-value{
  font-weight:700;
  font-variant-numeric:tabular-nums;
}

.stats-banned{ border-bottom:2px solid #ef4444; }
.stats-not-activated{ border-bottom:2px solid #f97316; }
.stats-regular{ border-bottom:2px solid #22c55e; }
.stats-vip{ border-bottom:2px solid #eab308; }
.stats-mod{ border-bottom:2px solid #38bdf8; }
.stats-admin{ border-bottom:2px solid #a855f7; }

.users-controls{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  justify-content:space-between;
  align-items:center;
  margin-bottom:10px;
}

.users-search{
  display:flex;
  gap:6px;
  align-items:center;
}

.users-search input{
  background:#0f172a;
  border-radius:10px;
  border:1px solid #4b5563;
  padding:8px 12px;
  color:var(--text);
  min-width:220px;
  outline:none;
}

.users-search input:focus{
  border-color:var(--accent);
  box-shadow:0 0 0 2px var(--accent-soft);
}

.users-search button{
  border-radius:10px;
  border:1px solid var(--accent);
  background:var(--accent);
  color:#111827;
  font-weight:700;
  padding:8px 12px;
  cursor:pointer;
  font-size:13px;
}

.users-search button:hover{
  filter:brightness(1.05);
}

.users-per-page{
  font-size:12px;
  color:var(--muted);
  display:flex;
  align-items:center;
  gap:6px;
}

.users-per-page select{
  background:#0f172a;
  border-radius:8px;
  border:1px solid #4b5563;
  color:var(--text);
  padding:6px 8px;
}

.users-table-wrap{
  margin-top:6px;
  border-radius:12px;
  overflow:auto;
  background:#111827;
  box-shadow:0 12px 28px rgba(0,0,0,.45);
  border:1px solid rgba(15,23,42,.8);
}

table.users-table{
  width:100%;
  border-collapse:collapse;
  font-size:13px;
  min-width:720px;
}

.users-table thead{
  background:#1f2937;
}

.users-table th,
.users-table td{
  padding:8px 10px;
  border-bottom:1px solid #111827;
  text-align:left;
  vertical-align:middle;
}

.users-table th{
  font-weight:700;
  color:var(--accent);
  border-bottom:2px solid #374151;
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.03em;
}

.users-table tbody tr{
  cursor:pointer;
  transition:background-color .12s, transform .05s;
}

.users-table tbody tr:nth-child(even){
  background:#020617;
}

.users-table tbody tr:hover{
  background:#111827;
  transform:translateY(-1px);
}

.users-table .col-id{
  width:72px;
  font-variant-numeric:tabular-nums;
}

.users-table .col-username{
  min-width:180px;
}

.users-table .col-role{
  width:148px;
}

.users-table .col-status{
  width:128px;
}

.badge-role{
  display:inline-block;
  padding:2px 8px;
  border-radius:999px;
  font-size:11px;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:.03em;
}

.badge-regular{
  background:#0f172a;
  color:#e5e7eb;
  border:1px solid #6b7280;
}

.badge-premium{
  background:#064e3b;
  color:#bbf7d0;
  border:1px solid #22c55e;
}

.badge-moderator{
  background:#023c5a;
  color:#bae6fd;
  border:1px solid #38bdf8;
}

.badge-admin{
  background:#4a044e;
  color:#f5d0fe;
  border:1px solid #a855f7;
}

.status-pill{
  display:inline-block;
  padding:2px 8px;
  border-radius:999px;
  font-size:11px;
  font-weight:700;
  font-variant-numeric:tabular-nums;
}

.status-banned{
  background:#3b0a0a;
  color:#fecaca;
  border:1px solid #ef4444;
}

.status-deactivated{
  background:#111827;
  color:#9ca3af;
  border:1px solid #4b5563;
}

.status-ok{
  background:#022c22;
  color:#bbf7d0;
  border:1px solid #22c55e;
}

.date-cell{
  font-variant-numeric:tabular-nums;
  color:#d1d5db;
  white-space:nowrap;
}

.date-cell.muted{
  color:#6b7280;
  font-style:italic;
}

.users-pagination{
  display:flex;
  justify-content:center;
  align-items:center;
  gap:8px;
  margin-top:12px;
  font-size:13px;
}

.users-pagination button{
  border-radius:999px;
  border:1px solid #4b5563;
  background:#111827;
  color:var(--text);
  padding:6px 12px;
  font-size:12px;
  cursor:pointer;
}

.users-pagination button[disabled]{
  opacity:.4;
  cursor:default;
}

.users-pagination button:hover:not([disabled]){
  background:#1f2937;
}

.users-pagination .page-info{
  font-variant-numeric:tabular-nums;
  color:var(--muted);
}

/* ===== Popup utente ===== */

.user-modal{
  position:fixed;
  inset:0;
  display:none;
  padding:24px;
  z-index:9990;
}

.user-modal.open{
  display:flex;
  align-items:flex-start;
  justify-content:center;
  overflow-y:auto;
}

.user-modal__backdrop{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.72);
  backdrop-filter:blur(3px);
}

.user-modal__card{
  position:relative;
  z-index:1;
  width:min(860px, calc(100vw - 28px));
  margin:18px auto;
  border-radius:18px;
  border:1px solid var(--border-strong);
  background:
    linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,0)),
    linear-gradient(180deg, #0b0f18, #05070c 85%);
  box-shadow:0 22px 60px rgba(0,0,0,.68);
  overflow:hidden;
}

.user-modal__close{
  position:absolute;
  top:12px;
  right:14px;
  width:36px;
  height:36px;
  border:0;
  border-radius:999px;
  background:transparent;
  color:#cbd5e1;
  font-size:24px;
  line-height:1;
  cursor:pointer;
  z-index:3;
}

.user-modal__close:hover{
  background:rgba(255,255,255,.06);
  color:#fff;
}

.user-popup{
  padding:18px 18px 16px;
}

.user-popup__hero{
  padding:6px 12px 10px;
  text-align:center;
}

.user-popup__page-title{
  font-size:29px;
  line-height:1.05;
  font-weight:900;
  letter-spacing:.04em;
  text-transform:uppercase;
  color:#fff;
}

.user-popup__name{
  margin-top:10px;
  font-size:25px;
  font-weight:800;
  color:#f8fafc;
  word-break:break-word;
}

.user-popup__subtitle{
  margin-top:6px;
  color:var(--muted);
  font-size:13px;
  min-height:18px;
}

.user-popup__section{
  margin-top:16px;
}

.user-popup__section-title{
  margin:0 0 8px;
  padding:9px 14px;
  border-radius:10px;
  background:linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.01));
  border:1px solid rgba(148,163,184,.12);
  color:#fff;
  font-size:15px;
  font-weight:900;
  text-transform:uppercase;
  letter-spacing:.04em;
}

.user-popup__table-wrap{
  border-radius:10px;
  overflow:hidden;
  border:1px solid rgba(148,163,184,.14);
  background:rgba(17,24,39,.64);
}

.user-popup__table,
.user-popup__stats-table{
  width:100%;
  border-collapse:collapse;
}

.user-popup__table th,
.user-popup__table td,
.user-popup__stats-table th,
.user-popup__stats-table td{
  padding:8px 12px;
  border-bottom:1px solid rgba(148,163,184,.08);
  font-size:14px;
}

.user-popup__table tr:last-child th,
.user-popup__table tr:last-child td,
.user-popup__stats-table tr:last-child th,
.user-popup__stats-table tr:last-child td{
  border-bottom:none;
}

.user-popup__table th{
  width:220px;
  text-align:right;
  color:#f8fafc;
  font-weight:800;
  white-space:nowrap;
}

.user-popup__table td{
  color:#e5e7eb;
  text-align:left;
  word-break:break-word;
}

.user-popup__stats-table th{
  width:1%;
  white-space:nowrap;
  font-weight:800;
}

.stats-label-left{
  text-align:right;
  color:#f8fafc;
}

.stats-label-right{
  text-align:left;
  color:#f8fafc;
}

.stats-value-left,
.stats-value-right{
  width:140px;
  font-variant-numeric:tabular-nums;
  font-weight:800;
  color:#fb923c;
}

.stats-value-left{
  text-align:left;
}

.stats-value-right{
  text-align:right;
}

.user-popup__stats-table a{
  color:var(--link);
  text-decoration:underline;
  font-weight:800;
}

.user-popup__stats-table a:hover{
  color:#93c5fd;
}

.storage-box{
  padding:14px 14px 16px;
  border-radius:10px;
  border:1px solid rgba(148,163,184,.14);
  background:rgba(2,6,23,.48);
}

.storage-line{
  font-size:14px;
  color:#e5e7eb;
  font-variant-numeric:tabular-nums;
}

.storage-line + .storage-line{
  margin-top:6px;
}

.storage-remaining{
  color:#cbd5e1;
}

.storage-sep{
  display:inline-block;
  margin:0 5px;
  color:#94a3b8;
}

.storage-bar{
  margin-top:12px;
  height:12px;
  border-radius:999px;
  overflow:hidden;
  background:#0f172a;
  border:1px solid rgba(148,163,184,.18);
}

.storage-bar-fill{
  width:0%;
  height:100%;
  border-radius:999px;
  background:linear-gradient(90deg, #fb923c, #f97316);
  transition:width .22s ease;
}

.user-modal__footer{
  margin-top:18px;
  display:flex;
  justify-content:center;
}

.user-modal__footer button{
  border-radius:999px;
  border:1px solid var(--accent);
  background:var(--accent);
  color:#111827;
  padding:9px 16px;
  font-size:14px;
  font-weight:800;
  cursor:pointer;
}

.user-modal__footer button:hover{
  filter:brightness(1.05);
}

/* ===== Modal come pagina standalone quando popup=1 ===== */

html.users-popup-mode,
body.users-popup-mode{
  background:#05070c;
}

body.users-popup-mode{
  padding-top:0;
}

.users-popup-mode .container{
  max-width:none;
  margin:0;
  padding:0;
}

.users-popup-mode .user-modal{
  position:static;
  display:block;
  padding:0;
}

.users-popup-mode .user-modal__backdrop{
  display:none;
}

.users-popup-mode .user-modal__card{
  width:100%;
  max-width:none;
  min-height:100vh;
  margin:0;
  border-radius:0;
  border-left:0;
  border-right:0;
  border-top:0;
}

/* ===== Responsive ===== */

@media (max-width: 900px){
  .container{
    margin:72px auto 28px;
  }

  .users-controls{
    justify-content:center;
  }

  .users-search{
    width:100%;
    justify-content:center;
    flex-wrap:wrap;
  }

  .users-search input{
    min-width:min(100%, 360px);
    width:min(100%, 360px);
  }

  .user-modal{
    padding:10px;
  }

  .user-modal__card{
    width:min(100%, calc(100vw - 12px));
  }

  .user-popup__page-title{
    font-size:22px;
  }

  .user-popup__name{
    font-size:21px;
    padding-right:28px;
    padding-left:28px;
  }

  .user-popup__table th,
  .user-popup__table td{
    display:block;
    width:100%;
    text-align:left;
  }

  .user-popup__table th{
    padding-bottom:2px;
  }

  .user-popup__table td{
    padding-top:0;
    padding-bottom:10px;
  }

  .user-popup__stats-table,
  .user-popup__stats-table tbody,
  .user-popup__stats-table tr{
    display:block;
    width:100%;
  }

  .user-popup__stats-table tr{
    padding:8px 0;
    border-bottom:1px solid rgba(148,163,184,.08);
  }

  .user-popup__stats-table tr:last-child{
    border-bottom:none;
  }

  .user-popup__stats-table th,
  .user-popup__stats-table td{
    display:block;
    width:100%;
    padding:2px 12px;
    text-align:left;
  }

  .stats-value-left,
  .stats-value-right{
    text-align:left;
  }
}

.users-table .col-last,
.users-table .col-last-login{
  min-width: 170px;
}

