* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, sans-serif;
  background: #F5F4ED;
  color: #2C2C2A;
  line-height: 1.6;
  font-size: 14px;
}

.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 28px;
}

/* ===== Header ===== */
header {
  background: #FFFFFF;
  border-bottom: 1px solid #E8E6DC;
  padding: 18px 0;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

header h1 {
  font-size: 22px;
  font-weight: 700;
  color: #26215C;
  letter-spacing: -0.3px;
}

.subtitle {
  font-size: 13px;
  color: #8B8A85;
  margin-top: 3px;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ===== Buttons ===== */
button {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

button:active {
  transform: translateY(1px);
}

.btn-secondary {
  background: #FFFFFF;
  color: #2C2C2A;
  border: 1px solid #D5D2C5;
}

.btn-secondary:hover {
  background: #F5F4ED;
  border-color: #B8B5A8;
}

.btn-primary {
  background: #534AB7;
  color: white;
  box-shadow: 0 1px 2px rgba(83, 74, 183, 0.2);
}

.btn-primary:hover {
  background: #3C3489;
  box-shadow: 0 2px 6px rgba(83, 74, 183, 0.3);
}

.btn-danger {
  background: #E24B4A;
  color: white;
  box-shadow: 0 1px 2px rgba(226, 75, 74, 0.2);
}

.btn-danger:hover {
  background: #A32D2D;
}

.btn-success {
  background: #2D9070;
  color: white;
  box-shadow: 0 1px 2px rgba(45, 144, 112, 0.2);
}

.btn-success:hover {
  background: #085041;
}

/* ===== KPI Grid ===== */
/* ===== KPI Grid (Redesign) ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr) 1.4fr repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}

@media (max-width: 1200px) {
  .kpi-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 700px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.kpi-card {
  background: #FFFFFF;
  border: 1px solid #E8E6DC;
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100px;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: #534AB7;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  border-color: #C5C0F5;
}

.kpi-card:hover::before {
  opacity: 1;
}

.kpi-card.warning::before { background: #854F0B; }
.kpi-card.pending::before { background: #185FA5; }
.kpi-card.plus::before { background: #D4AF37; }

.kpi-card.warning {
  border-color: #FAEEDA;
  background: #FFFBF5;
}

.kpi-card.pending {
  border-color: #E6F1FB;
  background: #F8FBFE;
}

.kpi-card.plus {
  border-color: #F7E58A;
  background: linear-gradient(135deg, #FFFCEB 0%, #FFF8D6 100%);
}

.kpi-label {
  font-size: 12px;
  color: #8B8A85;
  margin-bottom: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: #26215C;
  letter-spacing: -0.5px;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ตัว KPI Volume — ปรับให้ตัวเลขเล็กลงนิดหน่อยเพราะตัวเลขยาว */
.kpi-card.volume .kpi-value {
  font-size: 22px;
}

.kpi-card.warning .kpi-value { color: #854F0B; }
.kpi-card.plus .kpi-value { color: #92710A; }
.kpi-card.pending .kpi-value { color: #185FA5; }

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid #E8E6DC;
  margin-bottom: 18px;
  overflow-x: auto;
}

.tab {
  background: transparent;
  color: #8B8A85;
  padding: 12px 20px;
  border-radius: 8px 8px 0 0;
  border: none;
  font-weight: 500;
  font-size: 14px;
  position: relative;
  bottom: -2px;
}

.tab:hover {
  color: #2C2C2A;
  background: #FAFAF7;
}

.tab.active {
  color: #534AB7;
  font-weight: 600;
  border-bottom: 2px solid #534AB7;
  background: #FFFFFF;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ===== Card ===== */
.card {
  background: #FFFFFF;
  border: 1px solid #E8E6DC;
  border-radius: 12px;
  padding: 24px 28px;
}

.card h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
  color: #2C2C2A;
}

.muted {
  font-size: 13px;
  color: #8B8A85;
  margin-bottom: 16px;
}

/* ===== Tables ===== */
.table-wrapper {
  overflow-x: auto;
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table thead tr {
  border-bottom: 2px solid #E8E6DC;
  background: #FAFAF7;
}

table th {
  text-align: left;
  padding: 14px 12px;
  color: #6B6A65;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

table td {
  padding: 14px 12px;
  border-bottom: 1px solid #F1EFE8;
  vertical-align: middle;
}

table tbody tr {
  transition: background 0.1s ease;
}

table tbody tr:hover {
  background: #FAFAF7;
}

/* ===== Badges ===== */
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 4px 12px;
  border-radius: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.badge-active { background: #E1F5EE; color: #085041; }
.badge-pending { background: #F1EFE8; color: #444441; }
.badge-warning { background: #FAEEDA; color: #854F0B; }
.badge-danger { background: #FCEBEB; color: #791F1F; }
.badge-plus { background: #FFF8D6; color: #92710A; border: 1px solid #F7E58A; }
.badge-staff { background: #E8E6FC; color: #3C3489; border: 1px solid #C5C0F5; }

/* ===== Action buttons in table ===== */
.action-btns {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.action-btn {
  font-size: 12px;
  padding: 6px 12px;
  font-weight: 500;
}

.icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: #FFFFFF;
  color: #2C2C2A;
  border: 1px solid #D5D2C5;
}

.icon-btn:hover {
  background: #F5F4ED;
  border-color: #B8B5A8;
}

.icon-btn.icon-staff:hover {
  background: #E8E6FC;
  border-color: #C5C0F5;
}

.icon-btn.icon-staff.active {
  background: #E8E6FC;
  border-color: #C5C0F5;
  color: #3C3489;
}

.icon-btn.icon-delete:hover {
  background: #FCEBEB;
  border-color: #E24B4A;
  color: #791F1F;
}

.empty {
  text-align: center;
  padding: 60px 20px;
  color: #8B8A85;
  font-size: 14px;
}

/* ===== Search & Filter ===== */
.search-input {
  font-size: 13px;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid #D5D2C5;
  background: #FFFFFF;
  min-width: 280px;
  max-width: 360px;
  flex: 1;
  font-family: inherit;
  transition: all 0.15s ease;
}

.search-input:focus {
  outline: none;
  border-color: #534AB7;
  box-shadow: 0 0 0 3px rgba(83, 74, 183, 0.1);
}

.filter-select {
  font-size: 13px;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid #D5D2C5;
  background: #FFFFFF;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-select:hover {
  border-color: #B8B5A8;
}

.filter-select:focus {
  outline: none;
  border-color: #534AB7;
}

/* ===== Nickname cell ===== */
.nickname-cell {
  cursor: pointer;
  padding: 8px 12px !important;
  border-radius: 6px;
  transition: background 0.1s ease;
  position: relative;
}

.nickname-cell:hover {
  background: #F8F7FE !important;
}

.nickname-cell .edit-icon {
  opacity: 0;
  transition: opacity 0.15s ease;
  font-size: 11px;
  margin-left: 4px;
  color: #888;
}

.nickname-cell:hover .edit-icon {
  opacity: 1;
}

.nickname-empty {
  color: #B8B5A8;
  font-style: italic;
  font-size: 12px;
}

.nickname-input {
  width: 100%;
  padding: 6px 10px;
  border: 2px solid #534AB7;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

/* ===== Leaderboard ===== */
.lb-row {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px 20px;
  border: 1px solid #E8E6DC;
  border-radius: 10px;
  margin-bottom: 10px;
  background: #FFFFFF;
  transition: all 0.15s ease;
}

.lb-row:hover {
  background: #FAFAF7;
  transform: translateX(2px);
}

.lb-row.gold {
  background: linear-gradient(90deg, #FFFCEB 0%, #FFFFFF 100%);
  border-color: #F7E58A;
}

.lb-rank {
  font-size: 24px;
  font-weight: 700;
  color: #534AB7;
  width: 56px;
  text-align: center;
  flex-shrink: 0;
}

.lb-rank.rank-1 { color: #D4AF37; }
.lb-rank.rank-2 { color: #A0A0A0; }
.lb-rank.rank-3 { color: #CD7F32; }

.lb-info { flex: 1; min-width: 0; }

.lb-name {
  font-weight: 600;
  font-size: 15px;
  color: #2C2C2A;
  margin-bottom: 4px;
}

.lb-uid {
  font-family: monospace;
  font-size: 12px;
  color: #888780;
}

.lb-volume { text-align: right; flex-shrink: 0; }

.lb-vol-num {
  font-size: 19px;
  font-weight: 700;
  color: #085041;
}

.lb-vol-label {
  font-size: 11px;
  color: #888780;
}

.lb-bar {
  width: 200px;
  height: 8px;
  background: #F1EFE8;
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
}

.lb-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #534AB7 0%, #7F77DD 100%);
  border-radius: 4px;
}

.lb-row.gold .lb-bar-fill {
  background: linear-gradient(90deg, #D4AF37 0%, #F7E58A 100%);
}

/* ===== Modal ===== */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(20, 20, 30, 0.55);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

.modal-content {
  background: #FFF;
  border-radius: 14px;
  padding: 28px;
  max-width: 600px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.modal-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: #26215C;
}

.btn-close {
  background: transparent;
  font-size: 26px;
  color: #888;
  padding: 0 10px;
  line-height: 1;
}

.btn-close:hover {
  color: #2C2C2A;
}

.upload-zone {
  border: 2px dashed #D5D2C5;
  border-radius: 12px;
  padding: 44px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
}

.upload-zone:hover, .upload-zone.dragging {
  border-color: #534AB7;
  background: #F8F7FE;
}

#selected-file {
  margin-top: 14px;
  padding: 12px 16px;
  background: #E1F5EE;
  color: #085041;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
}

.upload-summary, .upload-result {
  background: #FAFAF7;
  border: 1px solid #E8E6DC;
  border-radius: 10px;
  padding: 18px;
  font-size: 13px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #E8E6DC;
}

.summary-row:last-child { border-bottom: none; }

.summary-label { color: #6B6A65; }
.summary-value { font-weight: 600; }

.summary-value.green { color: #085041; }
.summary-value.red { color: #791F1F; }
.summary-value.orange { color: #854F0B; }

/* ===== Log Badges ===== */
.badge-grant { background: #E1F5EE; color: #085041; }
.badge-revoke { background: #FCEBEB; color: #791F1F; }
.badge-plus-grant { background: #FFF8D6; color: #92710A; }
.badge-plus-revoke { background: #FAEEDA; color: #854F0B; }
.badge-inactive { background: #F1EFE8; color: #444441; }
.badge-sync { background: #E6F1FB; color: #0C447C; }

/* ===== Sortable column header ===== */
table th[onclick] {
  user-select: none;
  cursor: pointer;
}

table th[onclick]:hover {
  color: #534AB7;
  background: #F1EFE8;
}

/* ===== Pagination ===== */
#members-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #F1EFE8;
}

#members-pagination button {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
}

#members-pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ===== Section toolbar ===== */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .container { padding: 0 16px; }
  .card { padding: 18px 20px; }
  table { font-size: 13px; }
  table td, table th { padding: 12px 8px; }
}

/* ===== Container ขยายให้กว้างขึ้น ===== */
.container {
  max-width: 1480px;
}

/* ===== Table column widths ===== */
#members-table th,
#members-table td {
  white-space: nowrap;
}

#members-table th:nth-child(2),
#members-table td:nth-child(2) {
  min-width: 160px;
}

#members-table th:nth-child(3),
#members-table td:nth-child(3) {
  min-width: 140px;
  white-space: normal;
}

#members-table th:nth-child(4),
#members-table td:nth-child(4) {
  min-width: 200px;
}

#members-table th:nth-child(5),
#members-table td:nth-child(5) {
  min-width: 120px;
  text-align: right;
}

/* ===== UID copy button ===== */
.uid-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.uid-text {
  font-family: 'Segoe UI', 'Tahoma', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: #2C2C2A;
  letter-spacing: 0.2px;
  font-variant-numeric: tabular-nums;
}

.btn-copy {
  width: 26px;
  height: 26px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #F5F4ED;
  color: #534AB7;
  border: 1px solid #E8E6DC;
  border-radius: 5px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-copy:hover {
  background: #EEEDFE;
  border-color: #534AB7;
}

.btn-copy.copied {
  background: #E1F5EE;
  border-color: #2D9070;
  color: #085041;
}

/* ===== Volume cell ===== */
.volume-cell {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.volume-high { color: #085041; }
.volume-mid { color: #2C2C2A; }
.volume-low { color: #888780; }

/* ===== Header Layout (Fixed) ===== */
header {
  padding: 18px 0 20px;
}

header .container {
  display: block !important;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid #F1EFE8;
}

.header-top > div:first-child {
  flex: 1;
}

.header-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  align-items: stretch;
}

.action-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: #FAFAF7;
  border: 1px solid #E8E6DC;
  border-radius: 10px;
}

.group-title {
  font-size: 11px;
  font-weight: 700;
  color: #6B6A65;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 4px;
}

.group-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.action-btn-large {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #D5D2C5;
  background: #FFFFFF;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
  min-height: 56px;
  gap: 2px;
}

.action-btn-large:hover {
  border-color: #534AB7;
  background: #F8F7FE;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.action-btn-large.primary {
  background: #534AB7;
  border-color: #534AB7;
}

.action-btn-large.primary:hover {
  background: #3C3489;
  border-color: #3C3489;
}

.action-btn-large.primary .btn-title,
.action-btn-large.primary .btn-desc {
  color: #FFFFFF;
}

.action-btn-large.primary .btn-desc {
  opacity: 0.85;
}

.btn-title {
  font-size: 13px;
  font-weight: 600;
  color: #2C2C2A;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  display: block;
}

.btn-desc {
  font-size: 10.5px;
  color: #8B8A85;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  display: block;
}

@media (max-width: 1280px) {
  .header-actions {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 700px) {
  .header-actions {
    grid-template-columns: 1fr;
  }
  .header-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}

/* ===== Dropdown Notify ===== */
.notify-dropdown {
  position: relative;
  display: inline-block;
}

.notify-trigger {
  background: #FFFBF5;
  color: #854F0B;
  border: 1px solid #FAEEDA;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.notify-trigger:hover {
  background: #FAEEDA;
  border-color: #854F0B;
}

.notify-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: white;
  border: 1px solid #E8E6DC;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  min-width: 220px;
  z-index: 100;
  overflow: hidden;
}

.notify-dropdown.open .notify-menu {
  display: block;
}

.notify-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  color: #2C2C2A;
  border-bottom: 1px solid #F1EFE8;
  transition: background 0.1s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.notify-item:last-child {
  border-bottom: none;
}

.notify-item:hover {
  background: #F8F7FE;
}

.notify-item .emoji {
  font-size: 16px;
  flex-shrink: 0;
}

.notify-item .label {
  flex: 1;
}

.notify-trigger.reacted {
  background: #E1F5EE;
  color: #085041;
  border-color: #2D9070;
}

.notify-trigger.reacted:hover {
  background: #C5E8D9;
  border-color: #085041;
}

/* ===== Reject button (ไม่ผ่านลิงค์) ===== */
.btn-reject {
  background: #FFFBF5;
  color: #854F0B;
  border: 1px solid #FAEEDA;
}

.btn-reject:hover {
  background: #FAEEDA;
  border-color: #854F0B;
  color: #5A3508;
}

/* ===== Edit Discord Tag inline ===== */
.discord-tag-cell:hover {
  background: #F8F7FE;
}

.discord-tag-cell .edit-icon {
  opacity: 0;
  transition: opacity 0.15s ease;
  font-size: 11px;
  margin-left: 4px;
}

.discord-tag-cell:hover .edit-icon {
  opacity: 0.6;
}

.discord-tag-input {
  width: 100%;
  padding: 4px 8px;
  border: 2px solid #534AB7;
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  outline: none;
}

/* ===== Edit Discord Tag inline ===== */
.discord-tag-cell:hover {
  background: #F8F7FE;
}

.discord-tag-cell .edit-icon {
  opacity: 0;
  transition: opacity 0.15s ease;
  font-size: 11px;
  margin-left: 4px;
}

.discord-tag-cell:hover .edit-icon {
  opacity: 0.6;
}

.discord-tag-input {
  width: 100%;
  padding: 4px 8px;
  border: 2px solid #534AB7;
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  outline: none;
}
/* ===== Multi-UID badges / buttons ===== */
.uid-extra-btn {
  background: #EEF0FF;
  color: #534AB7;
  border: 1px solid #C8C4ED;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  margin-left: 4px;
}
.uid-extra-btn:hover { background: #DCDFFF; }

.uid-warn-badge {
  display: inline-block;
  margin-left: 4px;
  font-size: 12px;
  cursor: help;
}

.badge-left-server {
  display: inline-block;
  background: #FBE9E7;
  color: #791F1F;
  border: 1px solid #F4C7C2;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 600;
  margin-left: 4px;
  cursor: help;
}

.volume-cell-2line {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  cursor: help;
}
.volume-last-month {
  font-size: 11px;
  color: #888780;
  font-weight: 400;
}
