* { box-sizing: border-box; }
body { margin: 0; background: #f8fafc; color: #20242b; font-family: "Anuphan", Arial, sans-serif; }
.users-page { min-height: 100vh; padding: 20px 0 70px; background: radial-gradient(circle at top left, rgba(255,193,7,.06), transparent 28%), #f8fafc; }
.users-container { width: min(1460px, calc(100% - 32px)); margin: 0 auto; }
.users-topbar { display: flex; justify-content: flex-end; min-height: 42px; }
.users-back {
  align-self: flex-start; padding: 9px 17px; border: 1px solid #e2e8f0; border-radius: 999px;
  background: #fff; box-shadow: 0 5px 16px rgba(15,23,42,.08); color: #334155;
  font-size: 14px; font-weight: 700; text-decoration: none;
}
.users-heading { margin: 7px 0 22px; text-align: center; }
.users-heading h1 { margin: 0; font-size: clamp(32px, 4vw, 46px); }
.users-heading > span { display: block; width: 78px; height: 4px; margin: 13px auto 10px; border-radius: 99px; background: #f28a00; }
.users-heading p { margin: 0; font-size: 17px; font-weight: 700; }
.users-panel { padding: 10px 18px 26px; background: #f8fafc; }
.users-toolbar { position: relative; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 18px; min-height: 54px; }
.users-sort { justify-self: start; font-size: 14px; }
#userCount { font-size: 19px; text-align: center; }
.users-actions { display: flex; justify-self: end; gap: 8px; }
.users-actions input { width: 260px; min-height: 40px; padding: 9px 13px; border: 1px solid #cbd5e1; border-radius: 11px; font: inherit; }
.users-actions button { min-height: 40px; padding: 8px 15px; border: 0; border-radius: 11px; color: #fff; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.users-refresh { background: #0d6efd; }
.users-print { background: #9333ea; }
.users-status { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 160px; color: #475569; }
.users-status[hidden] { display: none; }
.users-spinner { width: 27px; height: 27px; border: 3px solid #bec4cc; border-top-color: #0d6efd; border-radius: 50%; animation: users-spin .7s linear infinite; }
@keyframes users-spin { to { transform: rotate(360deg); } }
.users-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px 30px; }
.user-card { min-width: 0; overflow: hidden; border-radius: 18px; background: #fff; box-shadow: 0 9px 24px rgba(34,35,58,.2); }
.user-card-inner { display: grid; grid-template-columns: 105px minmax(0, 1fr); min-height: 315px; }
.user-card-photo { position: relative; min-height: 315px; background: #edf1f5 center top / cover no-repeat; }
.user-login-count { padding: 5px 7px; background: #dc3545; color: #fff; font-size: 11px; font-weight: 800; text-align: center; }
.user-code { position: absolute; bottom: 8px; left: 50%; max-width: 92%; padding: 3px 11px; border-radius: 20px; background: #fff; color: #111; font-size: 11px; font-weight: 800; transform: translateX(-50%); overflow: hidden; text-overflow: ellipsis; }
.user-card-content { display: flex; min-width: 0; flex-direction: column; align-items: stretch; padding: 10px 12px; text-align: center; }
.user-org { margin: 0; color: #074de6; font-size: 11px; font-weight: 800; line-height: 1.4; overflow-wrap: anywhere; }
.user-position { margin: 2px 0 7px; color: #074de6; font-size: 10px; font-weight: 700; line-height: 1.35; }
.user-count-pills { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px; }
.user-pill { padding: 4px 7px; border-radius: 999px; color: #fff; font-size: 10px; font-weight: 800; }
.user-pill.primary { background: #e74c3c; } .user-pill.middle { background: #16b98e; } .user-pill.high { background: #f39c12; }
.user-complete-title { margin: 9px 0 5px; color: #ef3232; font-size: 10px; }
.user-progress p { margin: 4px 0 2px; font-size: 10px; font-weight: 600; }
.user-progress progress { width: 100%; height: 9px; overflow: hidden; border: 0; border-radius: 99px; background: #d9dde2; appearance: none; }
.user-progress progress::-webkit-progress-bar { border-radius: 99px; background: #d9dde2; }
.progress-primary::-webkit-progress-value { border-radius: 99px; background: #e74c3c; }
.progress-middle::-webkit-progress-value { border-radius: 99px; background: #1abc9c; }
.progress-high::-webkit-progress-value { border-radius: 99px; background: #f39c12; }
.progress-primary::-moz-progress-bar { background: #e74c3c; } .progress-middle::-moz-progress-bar { background: #1abc9c; } .progress-high::-moz-progress-bar { background: #f39c12; }
.user-sample { margin: 7px 0 0; color: #444; font-size: 9px; line-height: 1.45; }
.user-copy { border: 0; background: transparent; cursor: pointer; }
.user-login { display: flex; align-items: center; justify-content: center; min-height: 34px; margin-top: auto; border-radius: 4px; background: #0d6efd; color: #fff; font-size: 11px; font-weight: 800; text-decoration: none; }
.users-empty, .users-error { grid-column: 1 / -1; padding: 60px 20px; border-radius: 16px; background: #fff; color: #64748b; text-align: center; }
.users-error { color: #b91c1c; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

@media (max-width: 1200px) { .users-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } .users-toolbar { grid-template-columns: 1fr auto; } .users-actions { grid-column: 1 / -1; justify-self: stretch; } .users-actions input { flex: 1; } }
@media (max-width: 880px) { .users-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) {
  .users-container { width: min(100% - 20px, 420px); }
  .users-panel { padding: 10px; }
  .users-toolbar { display: flex; flex-direction: column; }
  .users-actions { width: 100%; flex-wrap: wrap; }
  .users-actions input { flex: 1 0 100%; width: 100%; }
  .users-actions button { flex: 1; }
  .users-grid { grid-template-columns: 1fr; }
}

@media print {
  .users-topbar, .users-actions { display: none !important; }
  .users-page { padding: 0; background: #fff; }
  .users-container { width: 100%; }
  .users-panel { background: #fff; }
  .users-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .user-card { break-inside: avoid; box-shadow: none; border: 1px solid #bbb; }
}
