/* 后台管理 — Modern Minimalist (Notion / Linear inspired) */
:root {
  --bg: #f8f9fa;
  --bg-white: #ffffff;
  --bg-hover: #f1f3f5;
  --border: #e9ecef;
  --border-focus: #868e96;
  --text: #212529;
  --text-secondary: #868e96;
  --text-muted: #adb5bd;
  --accent: #228be6;
  --accent-light: #e7f5ff;
  --accent-hover: #1c7ed6;
  --danger: #fa5252;
  --danger-light: #fff5f5;
  --ok: #40c057;
  --ok-light: #ebfbee;
  --warning: #fab005;
  --warning-light: #fff9db;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.07);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --transition: 0.15s ease;
}

@keyframes adminFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--accent-hover);
}

/* ── Header ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 0 1.5rem;
  height: 52px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.app-header h1 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* ── Main content ── */
.app-main {
  width: min(1080px, 100% - 48px);
  margin: 1.5rem auto 3rem;
  animation: adminFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* ── Panels ── */
.panel {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s;
}

.panel:hover {
  box-shadow: var(--shadow-md);
}

.panel h2 {
  margin: 0 0 1.15rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* ── Form elements ── */
label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
  font-weight: 500;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-white);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34, 139, 230, 0.1);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

textarea {
  min-height: 72px;
  resize: vertical;
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23868e96' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  padding-right: 2rem;
}

.form-control {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-white);
  color: var(--text);
  font: inherit;
}

.form-grid {
  display: grid;
  gap: 0.85rem;
}

@media (min-width: 640px) {
  .form-grid.cols-2 {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.98);
}

.btn-gold {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-gold:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-ghost {
  background: var(--bg-white);
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  border-color: #ced4da;
}

.btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
}

.btn-danger {
  background: var(--danger-light);
  border-color: rgba(250, 82, 82, 0.2);
  color: var(--danger);
}

.btn-danger:hover {
  background: rgba(250, 82, 82, 0.12);
  border-color: rgba(250, 82, 82, 0.35);
}

/* ── Status badges ── */
.status {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.status-pending {
  color: #e67700;
  background: var(--warning-light);
}

.status-awaiting_payment {
  color: var(--accent);
  background: var(--accent-light);
}

.status-paid {
  color: #2b8a3e;
  background: var(--ok-light);
}

.status-cancelled {
  color: var(--danger);
  background: var(--danger-light);
}

/* ── Table ── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

th,
td {
  text-align: left;
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg);
  position: sticky;
  top: 52px;
  z-index: 5;
}

tr {
  transition: background var(--transition);
}

tbody tr:hover {
  background: var(--bg-hover);
}

tbody tr:last-child td {
  border-bottom: none;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* ── Messages ── */
.msg {
  margin-top: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.msg.err {
  color: var(--danger);
}

.msg.ok {
  color: var(--ok);
}

/* ── Login bar ── */
.login-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.login-bar input[type="password"],
.login-bar input[type="text"] {
  width: 160px;
  padding: 0.4rem 0.6rem;
  font-size: 0.82rem;
}

.login-bar label {
  margin-bottom: 0;
  font-size: 0;
}

.login-bar label input {
  font-size: 0.82rem;
}

/* ── User bar ── */
#user-bar {
  gap: 8px;
}

#user-bar #user-display {
  color: var(--text);
  font-weight: 500;
  font-size: 0.82rem;
}

/* ── Change password panel ── */
#changepw-panel {
  max-width: 400px;
  margin: 1.25rem auto;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-white);
  box-shadow: var(--shadow-md);
  animation: adminFadeIn 0.3s ease both;
}

#changepw-panel h3 {
  margin: 0 0 0.85rem;
  font-size: 0.92rem;
  color: var(--text);
  font-weight: 600;
}

#changepw-panel label {
  display: block;
  margin-bottom: 0.65rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

#changepw-panel input {
  margin-top: 0.2rem;
}

.hidden {
  display: none !important;
}

/* ── Local server hint ── */
.local-server-hint {
  margin: 0 0 1rem;
  padding: 0.65rem 1rem;
  background: var(--warning-light);
  color: #5c4813;
  font-size: 0.82rem;
  line-height: 1.5;
  text-align: center;
  border-radius: var(--radius);
  border: 1px solid rgba(250, 176, 5, 0.2);
}

.local-server-hint strong {
  color: #e67700;
}

.local-server-hint a {
  color: var(--accent);
  text-decoration: underline;
}

.local-server-hint code {
  font-size: 0.85em;
  padding: 0.1em 0.35em;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 3px;
}

/* ── Pay page ── */
.pay-hero {
  text-align: center;
  margin-bottom: 2rem;
  padding: 2rem 0;
}

.pay-hero .amount {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text);
  margin: 0.75rem 0 0.25rem;
  letter-spacing: -0.02em;
}

.pay-note {
  font-size: 0.82rem;
  color: var(--text-secondary);
  max-width: 36rem;
  margin: 1rem auto 0;
  line-height: 1.6;
}

/* ── Pay page status ── */
.pay-status-badge {
  display: inline-block;
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid rgba(34, 139, 230, 0.15);
}

.pay-status-badge.paid {
  background: var(--ok-light);
  color: #2b8a3e;
  border-color: rgba(64, 192, 87, 0.15);
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .app-header {
    padding: 0 1rem;
    height: 48px;
  }

  .app-main {
    width: calc(100% - 24px);
    margin-top: 1rem;
  }

  .panel {
    padding: 1rem;
  }

  .login-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .login-bar input[type="password"],
  .login-bar input[type="text"] {
    width: 100%;
  }

  table {
    font-size: 0.76rem;
  }

  th, td {
    padding: 0.4rem 0.3rem;
  }

  th {
    top: 48px;
  }
}
