:root {
  --primary: #5c50e1;
  --primary-hover: #4a41c9;
  --primary-soft: rgba(92, 80, 225, 0.12);
  --danger: #e84848;
  --danger-soft: rgba(232, 72, 72, 0.1);
  --text: #1a1d26;
  --text-muted: #5c6378;
  --border: #e4e7ef;
  --bg: #eef1f8;
  --surface: #ffffff;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(26, 29, 38, 0.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

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

.app-header {
  background: linear-gradient(135deg, #5c50e1 0%, #7c6cf0 50%, #5c50e1 100%);
  color: #fff;
  box-shadow: 0 4px 20px rgba(92, 80, 225, 0.35);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.brand {
  font-weight: 700;
  font-size: 1rem;
  color: #fff !important;
  letter-spacing: -0.02em;
  text-decoration: none !important;
}
.brand:hover {
  opacity: 0.92;
}

.nav-toggle {
  display: none;
  margin-left: auto;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.2);
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0;
}
.nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: #fff;
  border-radius: 1px;
}

.main-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.main-nav a {
  color: rgba(255, 255, 255, 0.92);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none !important;
}
.main-nav a:hover {
  background: rgba(255, 255, 255, 0.18);
}

.header-user {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.user-chip {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.95);
  background: rgba(255, 255, 255, 0.15);
  padding: 6px 12px;
  border-radius: 999px;
  max-width: 100%;
}

.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 90;
}

@media (max-width: 768px) {
  .nav-toggle {
    display: inline-flex;
  }

  .main-nav {
    display: none;
    order: 10;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    padding: 8px 0 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
  }

  .main-nav a {
    padding: 12px 14px;
    border-radius: 10px;
  }

  .header-user {
    display: none;
    order: 11;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    padding-bottom: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    padding-top: 12px;
    gap: 10px;
  }

  .header-user form {
    width: 100%;
  }

  .header-user .btn-sm {
    width: 100%;
    justify-content: center;
  }

  body.nav-open .main-nav,
  body.nav-open .header-user {
    display: flex;
  }

  body.nav-open .nav-backdrop {
    display: block;
  }
}

.app-main {
  padding: 20px 16px 48px;
}

.wrap {
  max-width: 1120px;
  margin: 0 auto;
}

.page-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

@media (max-width: 480px) {
  .page-card {
    padding: 18px 16px;
  }
}

.page-card > h2:first-child,
.page-card > h1:first-child {
  margin-top: 0;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

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

.flash {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 14px;
  font-size: 14px;
  border: 1px solid transparent;
}

.flash.ok {
  background: #e8faf0;
  color: #0d6832;
  border-color: #b7eb8f;
}

.flash.err {
  background: #fff2f0;
  color: #a61d24;
  border-color: #ffccc7;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 10px;
  text-decoration: none !important;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  transition: transform 0.05s ease, filter 0.15s ease;
}
.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: #fff !important;
}
.btn-primary:hover {
  filter: brightness(1.06);
}

.btn-secondary {
  background: #e8eaf2;
  color: var(--text) !important;
}
.btn-secondary:hover {
  background: #dde0ea;
}

.btn-blue {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  color: #fff !important;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}
.btn-blue:hover {
  filter: brightness(1.08);
}

.btn-danger {
  background: var(--danger);
  color: #fff !important;
}
.btn-danger:hover {
  filter: brightness(1.05);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.2);
  color: #fff !important;
  border: 1px solid rgba(255, 255, 255, 0.35);
}
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.3);
}

.btn-outline {
  background: var(--primary-soft);
  color: var(--primary) !important;
  border: 1px solid rgba(92, 80, 225, 0.35);
}
.btn-outline:hover {
  background: rgba(92, 80, 225, 0.2);
}

.header-user .btn-ghost {
  white-space: nowrap;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.filter-form {
  margin-bottom: 20px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.filter-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 14px;
}

.filter-field .filter-label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--text);
}

.filter-field input[type="date"],
.filter-field input[type="text"],
.filter-field select {
  width: 100%;
  max-width: none;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
}

.filter-field select {
  background: var(--surface);
}

.filter-field--compact {
  flex: 0 0 auto;
  width: 148px;
}

.filter-field--compact input[type="date"] {
  max-width: 148px;
}

.filter-field--creator {
  flex: 0 0 auto;
  width: 132px;
  min-width: 104px;
}

.filter-field--creator select {
  max-width: 132px;
}

.filter-field--stretch {
  flex: 1 1 168px;
  min-width: 140px;
  max-width: 280px;
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  flex: 0 0 auto;
  margin-left: auto;
}

.pagination-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.pagination-info {
  font-size: 14px;
}

label {
  display: block;
  margin-top: 14px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}

input[type="text"],
input[type="number"],
input[type="password"],
textarea {
  width: 100%;
  max-width: 520px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

textarea {
  min-height: 200px;
  resize: vertical;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
}

.table-wrap {
  overflow-x: auto;
  margin: 16px 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
}

table.data-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table thead {
  background: linear-gradient(180deg, #f8f9fc 0%, #f0f2f7 100%);
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

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

.data-table tbody tr:hover {
  background: #fafbff;
}

.data-table code {
  font-size: 12px;
  word-break: break-all;
}

.row-actions {
  white-space: nowrap;
}

.stack-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.row-actions form {
  display: inline;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* ----- Login page ----- */
body.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: radial-gradient(ellipse 120% 80% at 50% -20%, rgba(92, 80, 225, 0.35), transparent),
    linear-gradient(180deg, #e8ebf6 0%, var(--bg) 45%);
}

.login-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 32px 28px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow), 0 0 0 1px var(--border);
}

.login-card h1 {
  font-size: 1.35rem;
  margin: 0 0 8px;
  text-align: center;
}

.login-card .sub {
  margin: 0 0 22px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.login-card label {
  margin-top: 16px;
}

.login-card input[type="text"],
.login-card input[type="password"] {
  max-width: none;
  margin-top: 6px;
}

.login-card button[type="submit"] {
  width: 100%;
  margin-top: 24px;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.login-card button[type="submit"]:hover {
  filter: brightness(1.06);
}

.radio-stack {
  margin-top: 8px;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 28px;
}

.radio-stack label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 0;
  font-weight: 500;
  cursor: pointer;
}

.radio-stack input[type="radio"] {
  width: auto;
  max-width: none;
  flex-shrink: 0;
  accent-color: var(--primary);
}

.radio-stack code {
  font-size: 13px;
  background: #f4f5fb;
  padding: 4px 10px;
  border-radius: 8px;
}

/* ----- 浮层确认框（替换原生 confirm） ----- */
body.qp-modal-open {
  overflow: hidden;
}

.qp-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-bottom));
  background: rgba(26, 29, 38, 0.42);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

.qp-modal-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

.qp-modal {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 20px 56px rgba(26, 29, 38, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.06) inset;
  padding: 22px 22px 18px;
  transform: translateY(14px) scale(0.97);
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

.qp-modal-backdrop.is-open .qp-modal {
  transform: translateY(0) scale(1);
}

.qp-modal--accent-danger {
  border-top: 3px solid var(--danger);
}

.qp-modal-title {
  margin: 0 0 10px;
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.qp-modal-msg {
  margin: 0 0 22px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-muted);
}

.qp-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
