/* ========== 全局样式 ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-page: #f5f1e8;
  --bg-card: #ffffff;
  --bg-input: #f8f5ef;
  --bg-hover: #faf7f0;
  --gold: #b8860b;
  --gold-bright: #8b6914;
  --gold-light: #d4a955;
  --gold-dim: #a0926a;
  --red-jx3: #c8403a;
  --text-main: #3a3228;
  --text-dim: #7a7165;
  --text-muted: #b0a89a;
  --border-gold: rgba(184, 134, 11, 0.25);
  --border-dim: rgba(184, 134, 11, 0.12);
  --border-light: #e5dfd3;
  --green-active: #2d9d78;
  --red-busy: #d4453e;
  --shadow-card: 0 2px 12px rgba(184, 134, 11, 0.08);
  --shadow-hover: 0 4px 20px rgba(184, 134, 11, 0.12);
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: var(--bg-page);
  color: var(--text-main);
  min-height: 100vh;
  position: relative;
}

/* 背景纹理 */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(212, 169, 85, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 90%, rgba(200, 64, 58, 0.04) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ========== 前台提交页 ========== */
.submit-container {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.submit-card {
  width: 100%;
  max-width: 480px;
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: 6px;
  padding: 40px 36px;
  position: relative;
  box-shadow: var(--shadow-card);
}

/* 卡片顶部装饰角 */
.submit-card::before,
.submit-card::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid var(--gold);
}
.submit-card::before {
  top: -1px; left: -1px;
  border-right: none;
  border-bottom: none;
  border-top-left-radius: 6px;
}
.submit-card::after {
  bottom: -1px; right: -1px;
  border-left: none;
  border-top: none;
  border-bottom-right-radius: 6px;
}

.card-title {
  text-align: center;
  font-size: 26px;
  font-weight: 700;
  color: var(--gold-bright);
  letter-spacing: 4px;
  margin-bottom: 6px;
}

.card-subtitle {
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 2px;
  margin-bottom: 32px;
}

/* 分隔线 */
.divider {
  display: flex;
  align-items: center;
  margin: 0 0 28px 0;
  gap: 10px;
}
.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-gold), transparent);
}
.divider span {
  color: var(--gold-dim);
  font-size: 12px;
  letter-spacing: 1px;
}

/* 表单 */
.form-group {
  margin-bottom: 22px;
}

.form-label {
  display: block;
  font-size: 14px;
  color: var(--gold-bright);
  margin-bottom: 8px;
  letter-spacing: 1px;
  font-weight: 600;
}

.form-input,
.form-select {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  color: var(--text-main);
  font-size: 15px;
  font-family: inherit;
  transition: all 0.2s ease;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(184, 134, 11, 0.1);
  background: #fff;
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23b8860b' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

.form-select option {
  background: var(--bg-card);
  color: var(--text-main);
}

/* 按钮 */
.btn-submit {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 100%);
  border: none;
  border-radius: 4px;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 8px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.btn-submit:hover {
  box-shadow: 0 4px 20px rgba(184, 134, 11, 0.3);
  transform: translateY(-1px);
}

.btn-submit:active {
  transform: translateY(0);
}

/* 成功提示 */
.toast {
  position: fixed;
  top: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: var(--bg-card);
  border: 1px solid var(--gold);
  border-radius: 6px;
  padding: 14px 28px;
  color: var(--gold-bright);
  font-size: 15px;
  z-index: 9999;
  transition: transform 0.3s ease;
  box-shadow: var(--shadow-hover);
  font-weight: 600;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  border-color: var(--red-jx3);
  color: var(--red-busy);
}

/* ========== 登录页 ========== */
.login-container {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: 6px;
  padding: 40px 36px;
  position: relative;
  box-shadow: var(--shadow-card);
}

.login-card::before,
.login-card::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid var(--gold);
}
.login-card::before {
  top: -1px; left: -1px;
  border-right: none;
  border-bottom: none;
  border-top-left-radius: 6px;
}
.login-card::after {
  bottom: -1px; right: -1px;
  border-left: none;
  border-top: none;
  border-bottom-right-radius: 6px;
}

/* ========== 后台管理页 ========== */
.admin-container {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 20px 24px;
  max-width: 1200px;
  margin: 0 auto;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--border-gold);
}

.admin-header h1 {
  font-size: 22px;
  color: var(--gold-bright);
  letter-spacing: 3px;
}

.admin-header .logout-btn {
  padding: 8px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: 4px;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.admin-header .logout-btn:hover {
  border-color: var(--red-jx3);
  color: var(--red-busy);
  background: #fff5f5;
}

/* 统计栏 */
.stats-bar {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 16px 20px;
  text-align: center;
  box-shadow: var(--shadow-card);
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
  letter-spacing: 1px;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--gold-bright);
}

.stat-card.active .stat-value {
  color: var(--green-active);
}

.stat-card.idle .stat-value {
  color: var(--text-dim);
}

/* 筛选栏 */
.filter-bar {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-group label {
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 1px;
  white-space: nowrap;
  font-weight: 600;
}

.filter-select {
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  color: var(--text-main);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23b8860b' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  min-width: 120px;
}

.filter-select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(184, 134, 11, 0.1);
}

.filter-select option {
  background: var(--bg-card);
}

/* 数据表格 */
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  overflow-x: auto;
  box-shadow: var(--shadow-card);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 800px;
}

thead {
  background: var(--bg-input);
}

th {
  padding: 14px 16px;
  text-align: left;
  font-size: 13px;
  color: var(--gold-bright);
  letter-spacing: 1px;
  border-bottom: 2px solid var(--border-gold);
  white-space: nowrap;
  font-weight: 600;
}

td {
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-light);
}

tbody tr {
  transition: background 0.15s;
}

tbody tr:hover {
  background: var(--bg-hover);
}

tbody tr:last-child td {
  border-bottom: none;
}

/* 状态标签 */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid;
  font-family: inherit;
}

.status-badge.unused {
  background: #f0ede8;
  border-color: #d5d0c8;
  color: var(--text-dim);
}

.status-badge.in_use {
  background: #e8f7f2;
  border-color: #a8dcc8;
  color: var(--green-active);
}

.status-badge:hover {
  opacity: 0.8;
  transform: scale(1.02);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.status-badge.unused .status-dot {
  background: var(--text-dim);
}

.status-badge.in_use .status-dot {
  background: var(--green-active);
  box-shadow: 0 0 6px var(--green-active);
}

/* 操作按钮 */
.action-group {
  display: flex;
  gap: 6px;
}

.btn-edit {
  padding: 5px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-gold);
  border-radius: 4px;
  color: var(--gold-bright);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-edit:hover {
  background: var(--gold-light);
  color: #fff;
  border-color: var(--gold);
}

.btn-delete {
  padding: 5px 12px;
  background: #fff5f5;
  border: 1px solid rgba(200, 64, 58, 0.2);
  border-radius: 4px;
  color: var(--red-busy);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-delete:hover {
  background: var(--red-jx3);
  color: #fff;
  border-color: var(--red-jx3);
}

/* 复制按钮 */
.btn-copy {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: 3px;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  margin-left: 6px;
  vertical-align: middle;
}

.btn-copy:hover {
  background: var(--gold-light);
  color: #fff;
  border-color: var(--gold);
}

.btn-copy.copied {
  background: var(--green-active);
  color: #fff;
  border-color: var(--green-active);
}

.copy-icon {
  width: 12px;
  height: 12px;
  display: inline-block;
}

/* 可复制单元格 */
.copyable {
  display: flex;
  align-items: center;
  gap: 2px;
}

.copyable .cell-text {
  flex: 1;
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 15px;
}

/* 密码单元格 */
.password-cell {
  font-family: "SF Mono", "Consolas", monospace;
  letter-spacing: 1px;
}

/* ========== 编辑弹窗 ========== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal-overlay.show {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: 8px;
  padding: 32px 28px;
  position: relative;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--gold-bright);
  letter-spacing: 2px;
  margin-bottom: 24px;
  text-align: center;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.btn-save {
  flex: 1;
  padding: 12px;
  background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 100%);
  border: none;
  border-radius: 4px;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.btn-save:hover {
  box-shadow: 0 4px 16px rgba(184, 134, 11, 0.3);
}

.btn-cancel {
  flex: 1;
  padding: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  color: var(--text-dim);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-cancel:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

/* 响应式 */
@media (max-width: 600px) {
  .submit-card,
  .login-card,
  .modal-card {
    padding: 30px 20px;
  }
  .card-title {
    font-size: 22px;
  }
  .stats-bar {
    flex-direction: column;
  }
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .admin-container {
    padding: 16px 12px;
  }
}
