:root {
  --bg: #171007;
  --bg-soft: #24180d;
  --panel: #2b1f14;
  --card: #332416;
  --ink: #f6eddc;
  --ink-soft: #d8c8ad;
  --line: #5a4227;
  --primary: #f0b90b;
  --primary-dark: #d6a309;
  --success: #0ecb81;
  --danger: #f6465d;
  --radius: 12px;
  --shadow: 0 20px 46px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  color: var(--ink);
  background:
    radial-gradient(1200px 560px at 10% -18%, rgba(255, 190, 72, 0.26), transparent 55%),
    radial-gradient(900px 420px at 92% -10%, rgba(255, 152, 48, 0.2), transparent 52%),
    linear-gradient(180deg, #171007 0%, #22160b 48%, #130d06 100%);
  font-family: "Source Han Sans SC", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: #ffd04a;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(28, 19, 10, 0.92);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand a {
  color: #fff;
  font-weight: 700;
}

.nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.nav a {
  color: var(--ink-soft);
  padding: 8px 10px;
  border-radius: 8px;
}

.nav a:hover {
  color: #fff;
  background: rgba(240, 185, 11, 0.15);
}

.userbox {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--ink-soft);
}

.container {
  width: min(1180px, 94vw);
  margin: 18px auto 42px;
  display: grid;
  gap: 14px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #312315 0%, #261b11 100%);
  box-shadow: var(--shadow);
  padding: 16px;
}

.panel h1,
.panel h2,
.panel h3 {
  margin-top: 0;
  color: #fff;
}

.hero {
  border-color: #7a5628;
  background: linear-gradient(135deg, rgba(252, 190, 64, 0.28) 0%, rgba(216, 130, 34, 0.2) 28%, #2a1c10 100%);
}

.hero h1 {
  margin: 0 0 8px;
}

.hero p {
  margin: 0;
  color: var(--ink-soft);
}

.card-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.card-grid-compact {
  grid-template-columns: repeat(auto-fit, minmax(220px, 320px));
  justify-content: start;
}

.card-grid-compact .card {
  aspect-ratio: auto;
  min-height: 168px;
  max-width: 320px;
}

.card {
  border: 1px solid #7a5628;
  border-radius: 12px;
  background: linear-gradient(180deg, #3a2817 0%, #2e2013 100%);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  aspect-ratio: 1 / 0.88;
  min-height: 210px;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-4px);
  border-color: #c58a3a;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.58);
}

.card h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
}

.card-head {
  display: grid;
  gap: 10px;
  justify-items: center;
  text-align: center;
}

.card-icon-wrap {
  width: 62px;
  height: 62px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 199, 109, 0.65);
  background: radial-gradient(circle at 30% 20%, rgba(255, 237, 198, 0.72), rgba(241, 174, 63, 0.2) 52%, rgba(73, 46, 18, 0.6) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 12px 24px rgba(0, 0, 0, 0.34);
}

.card-icon {
  font-size: 30px;
  line-height: 1;
  filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.18));
}

.card-title {
  width: 100%;
  margin: 0;
  text-align: center;
  color: #fff6e8;
}

.card-btn {
  align-self: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffd27a 0%, #f0b14d 52%, #d88b22 100%);
  color: #2a1808;
  font-weight: 700;
  padding: 9px 14px;
  cursor: pointer;
}

.btn:hover {
  background: linear-gradient(180deg, #ffe1a3 0%, #f7c56a 55%, #e39b33 100%);
}

.btn.small {
  padding: 6px 10px;
  font-size: 12px;
}

.btn.secondary {
  background: #3a2a18;
  border: 1px solid #7a5628;
  color: var(--ink);
}

.btn.secondary:hover {
  background: #4a3520;
}

.btn.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.form-grid {
  display: grid;
  gap: 10px;
  max-width: 520px;
}

.form-grid label,
.inline-form {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.form-grid label {
  flex-direction: column;
  align-items: stretch;
}

input,
select,
textarea {
  border: 1px solid #7a5628;
  border-radius: 10px;
  padding: 9px 11px;
  font: inherit;
  color: var(--ink);
  background: #21170e;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(240, 185, 11, 0.8);
  box-shadow: 0 0 0 3px rgba(240, 185, 11, 0.16);
}

.alert {
  border: 1px solid rgba(246, 70, 93, 0.45);
  background: rgba(246, 70, 93, 0.14);
  color: #ffadb9;
  border-radius: 10px;
  padding: 8px 10px;
}

.success {
  border: 1px solid rgba(14, 203, 129, 0.45);
  background: rgba(14, 203, 129, 0.12);
  color: #8ef1c8;
  border-radius: 10px;
  padding: 8px 10px;
}

.stats-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.stat-card {
  border: 1px solid #7a5628;
  border-radius: 10px;
  background: #2e2013;
  padding: 10px;
}

.stat-card .label {
  color: var(--ink-soft);
  font-size: 13px;
}

.stat-card .value {
  font-weight: 700;
  margin-top: 4px;
  color: #fff;
}

.table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 8px;
  vertical-align: top;
  white-space: nowrap;
}

.admin-container {
  width: min(1480px, 96vw);
}

.users-panel {
  padding: 20px;
  overflow: hidden;
}

.users-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.users-heading h1 {
  margin-bottom: 6px;
  font-size: clamp(24px, 3vw, 34px);
}

.users-heading__hint {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.users-heading__badge {
  flex: 0 0 auto;
  border: 1px solid rgba(240, 185, 11, 0.38);
  border-radius: 999px;
  padding: 6px 10px;
  color: #ffd989;
  background: rgba(240, 185, 11, 0.1);
  font-size: 12px;
}

.users-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 16px -20px 0;
  padding: 11px 20px;
  border-top: 1px solid rgba(122, 86, 40, 0.48);
  border-bottom: 1px solid rgba(122, 86, 40, 0.48);
  background: rgba(20, 13, 7, 0.28);
}

.users-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink-soft);
  font-size: 13px;
}

.users-summary strong {
  color: #fff;
  font-size: 16px;
}

.users-summary span {
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.users-page-size {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 13px;
}

.users-page-size select {
  min-width: 92px;
  padding: 7px 30px 7px 10px;
}

.users-table-wrap {
  margin: 0 -20px -20px;
}

.users-table {
  min-width: 1100px;
  table-layout: fixed;
}

.users-table th {
  padding: 11px 10px;
  color: #ead9bc;
  background: rgba(12, 8, 4, 0.3);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.users-table td {
  padding: 12px 10px;
  vertical-align: middle;
  white-space: normal;
}

.users-table tbody tr {
  transition: background 0.15s ease;
}

.users-table tbody tr:hover {
  background: rgba(240, 185, 11, 0.035);
}

.users-table tbody tr:last-child td {
  border-bottom: 0;
}

.users-col-id {
  width: 48px;
}

.users-table th:nth-child(2) {
  width: 15%;
}

.users-table th:nth-child(3) {
  width: 82px;
}

.users-table th:nth-child(4) {
  width: 62px;
}

.users-table th:nth-child(5) {
  width: 88px;
}

.users-table th:nth-child(6) {
  width: 205px;
}

.users-col-actions {
  width: 440px;
}

.users-id {
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.users-identity {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.users-identity strong,
.users-identity span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.users-identity strong {
  color: #fff;
  font-size: 14px;
}

.users-identity span {
  color: var(--ink-soft);
  font-size: 12px;
}

.users-modules {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 3px;
}

.users-modules em {
  display: inline-flex;
  padding: 2px 6px;
  border: 1px solid rgba(210, 151, 54, 0.38);
  border-radius: 999px;
  color: #e7c483;
  font-size: 11px;
  font-style: normal;
  line-height: 1.3;
}

.users-role {
  color: #f4dfbb;
  font-size: 13px;
}

.users-points {
  color: #ffd27a;
  font-variant-numeric: tabular-nums;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
}

.status-badge::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.status-badge.is-active {
  color: #6fe2b3;
  background: rgba(14, 203, 129, 0.1);
}

.status-badge.is-locked {
  color: #ff9cab;
  background: rgba(246, 70, 93, 0.1);
}

.status-note {
  display: block;
  margin-top: 5px;
  color: #ffd27a;
  font-size: 11px;
}

.users-dates {
  display: grid;
  gap: 5px;
  margin: 0;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.users-dates div {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 6px;
}

.users-dates dt {
  color: #a99472;
}

.users-dates dd {
  margin: 0;
  overflow: hidden;
  color: #eadfcd;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.users-actions-cell {
  background: rgba(14, 9, 5, 0.12);
}

.user-actions {
  display: grid;
  gap: 8px;
}

.user-actions__edit,
.user-actions__tools {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.compact-form {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  min-width: 0;
}

.compact-form label {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.compact-form label > span {
  color: #a99472;
  font-size: 10px;
  line-height: 1;
}

.compact-form select,
.compact-form input {
  height: 32px;
  padding: 5px 8px;
  border-radius: 7px;
  font-size: 12px;
}

.compact-form select {
  width: 126px;
}

.compact-form--points input {
  width: 66px;
}

.compact-form .btn {
  height: 32px;
  padding: 5px 9px;
  border-radius: 7px;
}

.user-actions__tools {
  flex-wrap: wrap;
  min-height: 26px;
}

.password-reset {
  min-width: 0;
}

.password-reset[open] {
  flex: 1 0 100%;
}

.password-reset summary,
.action-link {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  margin: 0;
  border: 1px solid #684a28;
  border-radius: 7px;
  padding: 4px 8px;
  color: #ead9bc;
  background: rgba(58, 42, 24, 0.72);
  font: inherit;
  font-size: 11px;
  line-height: 1.2;
  cursor: pointer;
}

.password-reset summary {
  list-style: none;
}

.password-reset summary::-webkit-details-marker {
  display: none;
}

.password-reset summary::after {
  margin-left: 5px;
  color: #b99b6c;
  content: "▾";
}

.password-reset[open] summary::after {
  transform: rotate(180deg);
}

.password-reset__form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 7px;
  width: 100%;
  margin-top: 7px;
  padding: 10px;
  border: 1px solid #7a5628;
  border-radius: 10px;
  background: #271a0f;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.password-reset__form input {
  min-width: 0;
  height: 32px;
  padding: 5px 8px;
  border-radius: 7px;
  font-size: 12px;
}

.password-reset__form .btn {
  border-radius: 7px;
}

.action-form {
  display: inline-flex;
  margin: 0;
}

.action-link:hover,
.password-reset summary:hover {
  border-color: #a97735;
  color: #fff;
  background: #4a3520;
}

.action-link:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.action-link--danger {
  border-color: rgba(246, 70, 93, 0.35);
  color: #ff9cab;
  background: rgba(246, 70, 93, 0.08);
}

.action-link--danger:hover {
  border-color: rgba(246, 70, 93, 0.65);
  color: #ffd1d8;
  background: rgba(246, 70, 93, 0.16);
}

.action-note {
  color: #9f8b6d;
  font-size: 10px;
}

.users-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 14px;
  color: var(--ink-soft);
  font-size: 12px;
}

.muted {
  color: var(--ink-soft);
  font-size: 13px;
}

.quick-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.resource-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.resource-card {
  border: 1px solid #7a5628;
  border-radius: 12px;
  background: #2e2013;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.resource-card h3 {
  margin: 0;
}

.resource-qr {
  width: 100%;
  max-width: 220px;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border: 1px solid #3a434d;
  border-radius: 10px;
}

.resource-placeholder {
  width: 100%;
  max-width: 220px;
  aspect-ratio: 1 / 1;
  border: 1px dashed #3a434d;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  font-size: 13px;
}

@media (max-width: 760px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    position: static;
  }

  .nav {
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
  }

  .nav a {
    flex: 0 0 auto;
  }

  .container {
    width: 96vw;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .resource-qr,
  .resource-placeholder {
    max-width: 100%;
  }

  .card-grid-compact {
    grid-template-columns: 1fr;
  }

  .card-grid-compact .card {
    max-width: none;
    min-height: 160px;
  }

  .card {
    aspect-ratio: auto;
    min-height: 170px;
  }

  .users-panel {
    padding: 16px;
  }

  .users-heading {
    align-items: center;
  }

  .users-heading__hint {
    max-width: 70vw;
  }

  .users-toolbar {
    align-items: flex-start;
    margin: 14px -16px 0;
    padding: 10px 16px;
  }

  .users-summary {
    display: grid;
    gap: 2px;
  }

  .users-summary span {
    padding-left: 0;
    border-left: 0;
  }

  .users-page-size {
    align-items: flex-end;
    flex-direction: column;
    gap: 4px;
  }

  .users-table-wrap {
    margin: 0 -16px -16px;
    overflow: visible;
  }

  .users-table {
    min-width: 0;
  }

  .users-table thead {
    display: none;
  }

  .users-table,
  .users-table tbody,
  .users-table tr,
  .users-table td {
    display: block;
    width: 100%;
  }

  .users-table tr {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
  }

  .users-table td {
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 10px;
    min-height: 34px;
    padding: 6px 0;
    border: 0;
  }

  .users-table td::before {
    color: #9f8b6d;
    font-size: 11px;
    content: attr(data-label);
  }

  .users-table .users-actions-cell {
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr);
    margin-top: 4px;
    padding-top: 10px;
    border-top: 1px dashed rgba(122, 86, 40, 0.42);
    background: transparent;
  }

  .user-actions__edit {
    flex-wrap: wrap;
  }

  .password-reset__form {
    grid-template-columns: 1fr;
    width: 100%;
  }
}
