:root {
  --bg: #f5ebe1;
  --panel: #fcfaf7;
  --panel-soft: #f5f1eb;
  --panel-border: rgba(255, 255, 255, 0.5);
  --input-border: #e8e1d7;
  --text: #3e3228;
  --muted: #7d736a;
  --accent: #a85a41;
  --accent-dark: #914d37;
  --danger: #9e3e3e;
  --danger-dark: #853434;
  --dark: #2d241e;
  --shadow: 0 8px 24px rgba(62, 50, 40, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-size: 16px;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
}

.page-shell {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px;
}

.login-shell {
  max-width: 560px;
  padding-top: 0;
  padding-bottom: 0;
}

.hidden,
.modal-backdrop.hidden {
  display: none;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-card {
  width: min(100%, 460px);
  padding: 32px;
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(255, 252, 247, 0.98), rgba(241, 231, 219, 0.95));
  box-shadow: var(--shadow);
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 32px;
  border: 1px solid var(--panel-border);
  border-radius: 32px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 36px;
  font-weight: 800;
  letter-spacing: 0;
}

h2 {
  font-size: 20px;
  line-height: 28px;
  font-weight: 700;
}

.hero-copy {
  max-width: 680px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.hero-stat {
  width: 144px;
  min-width: 144px;
  padding: 20px;
  min-height: 112px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  border-radius: 24px;
  background: #362c27;
  color: #fff;
  box-shadow: 0 14px 30px rgba(54, 44, 39, 0.16);
}

.hero-stat span {
  display: block;
  margin-bottom: 4px;
  font-size: 36px;
  line-height: 40px;
  font-weight: 700;
}

.hero-stat small {
  color: #a89f95;
  font-size: 12px;
}

.hero-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
}

.current-user {
  padding: 6px 16px;
  border-radius: 999px;
  background: #ebe5de;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 1fr);
  gap: 24px;
  margin-top: 24px;
}

.panel {
  padding: 32px;
  border: 1px solid var(--panel-border);
  border-radius: 32px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel.full-width {
  grid-column: 1 / -1;
  min-height: 500px;
}

.generate-panel {
  grid-column: 1 / -1;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.panel-head-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 0 24px;
}

.page-info {
  color: var(--muted);
  font-size: 14px;
  min-width: 130px;
  white-space: nowrap;
}

.grid-two,
.grid-three {
  display: grid;
  gap: 24px;
  margin-top: 24px;
}

.grid-two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 0;
  font-size: 14px;
  color: var(--muted);
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--input-border);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  line-height: 20px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
}

.panel-head select {
  width: 128px !important;
  max-width: 144px;
  padding: 8px 16px;
  border-radius: 999px;
}

#pageSize {
  width: 96px !important;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 32px;
}

.compact-actions {
  margin-top: 20px;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 8px 20px;
  cursor: pointer;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  transition: opacity 0.15s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

button:hover {
  opacity: 0.92;
}

button:disabled {
  cursor: not-allowed;
  color: #a69e96;
  opacity: 0.7;
}

button.primary {
  padding: 12px 32px;
  background: var(--accent);
  color: #fff7f0;
  box-shadow: 0 10px 22px rgba(168, 90, 65, 0.18);
}

button.primary:hover {
  background: var(--accent-dark);
}

button.ghost {
  background: #eae4dd;
  color: var(--text);
}

button.danger {
  background: var(--danger);
  color: #fff;
}

button.danger:hover {
  background: var(--danger-dark);
}

button.copy-active {
  background: #e6efff;
  color: #1d5ee6;
}

.table-actions button[data-action="copy-code"] {
  border: 1px solid var(--input-border);
  background: #fff;
}

.table-actions button.copy-active[data-action="copy-code"] {
  border-color: transparent;
  background: #e6efff;
}

.toast-root {
  position: fixed;
  right: 18px;
  left: 18px;
  bottom: 18px;
  z-index: 30;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}

.toast-item {
  align-self: flex-end;
  width: min(100%, 440px);
  padding: 12px 14px;
  border-radius: 14px;
  color: #f8efe5;
  line-height: 1.45;
  background: #241914;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

.toast-item.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-success {
  background: linear-gradient(135deg, #206b4a, #2d8a5f);
}

.toast-warning {
  background: linear-gradient(135deg, #d39a25, #f1ad2b);
}

.toast-error {
  background: linear-gradient(135deg, #7f1e22, #ae1f24);
}

.api-note {
  margin-top: 16px;
  padding: 20px;
  border-radius: 16px;
  background: var(--panel-soft);
}

.panel > h2 + .api-note {
  margin-top: 24px;
}

.api-note p {
  margin: 0 0 12px;
  font-size: 14px;
}

.api-note code {
  display: block;
  padding: 12px 14px;
  overflow-x: auto;
  border-radius: 8px;
  background: var(--dark);
  color: #d8cdc2;
  font-size: 12px;
  line-height: 16px;
}

.api-note code span {
  margin-right: 8px;
  color: #a48f7a;
}

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

.user-table-wrap {
  margin-top: 24px;
}

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

th,
td {
  padding: 20px 10px;
  border-bottom: 1px solid #f0ebe3;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
  font-weight: 400;
}

td {
  font-size: 14px;
  line-height: 20px;
}

tbody tr {
  transition: background 0.15s ease;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.52);
}

td:nth-child(2) {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

td:nth-child(7),
td:nth-child(8),
td:nth-child(9) {
  color: var(--muted);
}

th:last-child,
td:last-child {
  text-align: right;
}

.empty {
  text-align: center;
  color: var(--muted);
}

.table-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.table-actions button {
  min-width: 56px;
  height: 30px;
  padding: 6px 14px;
  font-size: 12px;
  line-height: 18px;
}

.muted-action {
  display: inline-block;
  min-width: 56px;
  text-align: center;
  color: var(--muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
}

.status-unused {
  background: #e5f3e9;
  color: #2f7e4d;
}

.status-used {
  background: #faecec;
  color: #b04c58;
}

.status-copied {
  background: #e6efff;
  color: #1d5ee6;
}

.status-expired {
  background: #f0f0f0;
  color: #707070;
}

.role-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
}

.role-admin {
  background: #e9edf7;
  color: #36548b;
}

.role-user {
  background: #e8f3ed;
  color: #2c7650;
}

.password-action {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-width: 260px;
}

.password-action input {
  min-width: 0;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 18px;
}

.password-action button {
  height: 34px;
  min-width: 56px;
  padding: 6px 14px;
  font-size: 12px;
  line-height: 18px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(62, 50, 40, 0.4);
  backdrop-filter: blur(6px);
}

.modal {
  width: min(100%, 400px);
  padding: 32px;
  border: 1px solid #fff;
  border-radius: 24px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(62, 50, 40, 0.22);
}

.user-modal {
  width: min(96vw, 1100px);
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.modal-head-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin: -48px 0 24px;
}

.modal-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-title-row h3 {
  margin: 0;
  font-size: 20px;
}

.modal-icon {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 999px;
  background: #faecec;
  color: #b04c58;
  font-weight: 800;
}

.user-modal-icon {
  background: #e8f3ed;
  color: #2c7650;
}

.modal p {
  margin: 0 0 28px 52px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
}

@media (max-width: 920px) {
  .layout,
  .grid-two,
  .grid-three {
    grid-template-columns: 1fr;
  }

  .hero {
    flex-direction: column;
    align-items: start;
  }

  .hero-stat {
    width: 100%;
  }

  .hero-actions {
    align-items: start;
  }

  .panel-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .panel-head-actions,
  .pagination {
    flex-wrap: wrap;
    width: 100%;
  }

  .modal-head-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
    margin: 0 0 24px;
  }
}
