:root {
  --brand: #2478eb;
  --brand-strong: #1c60d8;
  --brand-soft: #eff6ff;
  --navy: #061a33;
  --navy-soft: #0b2447;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --bg: #f4f7fb;
  --card: #ffffff;
  --success: #059669;
  --success-soft: #ecfdf5;
  --warning: #b45309;
  --warning-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --shadow: 0 18px 50px -24px rgba(15, 23, 42, 0.28);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body.modal-open { overflow: hidden; }

button, input, select, textarea { font: inherit; }

button { cursor: pointer; }

a { color: inherit; text-decoration: none; }

[hidden] { display: none !important; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2em;
}

/* Login */
.login-shell {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 16% 16%, rgba(34, 211, 238, 0.2), transparent 30%),
    radial-gradient(circle at 84% 18%, rgba(36, 120, 235, 0.28), transparent 36%),
    linear-gradient(145deg, #061a33 0%, #0b2447 54%, #123a6b 100%);
}

.login-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.09) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), transparent 92%);
}

.login-card {
  position: relative;
  width: min(100%, 430px);
  padding: 34px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 36px 100px -30px rgba(0, 0, 0, 0.55);
}

.login-brand,
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-brand img,
.sidebar-brand img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.login-brand strong,
.sidebar-brand strong {
  display: block;
  font-size: 15px;
  color: var(--navy);
}

.login-brand span,
.sidebar-brand span {
  display: block;
  margin-top: 2px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.login-copy { margin-top: 34px; }
.login-copy h1 { margin: 0; font-size: 30px; letter-spacing: -0.03em; }
.login-copy p:last-child { margin: 8px 0 0; color: var(--muted); }

.login-form { margin-top: 26px; display: grid; gap: 16px; }

.login-form label { display: grid; gap: 7px; }
.login-form label span { font-size: 12px; font-weight: 600; color: #334155; }

.login-form input,
.form-field input,
.form-field select,
.form-field textarea,
.spec-row input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #fff;
  padding: 11px 13px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.login-form input:focus,
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus,
.spec-row input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(36, 120, 235, 0.1);
}

.form-error {
  margin: 0;
  padding: 9px 12px;
  border: 1px solid #fecaca;
  border-radius: 10px;
  background: var(--danger-soft);
  color: #b91c1c;
  font-size: 12px;
}

.login-back {
  display: inline-block;
  margin-top: 22px;
  color: var(--muted);
  font-size: 12px;
  transition: color 0.18s;
}
.login-back:hover { color: var(--brand); }

/* Admin layout */
.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 10% 10%, rgba(34, 211, 238, 0.1), transparent 30%),
    linear-gradient(180deg, #061a33 0%, #0b2447 100%);
  color: #cbd5e1;
}

.sidebar-brand { padding: 4px 8px 24px; border-bottom: 1px solid rgba(255, 255, 255, 0.09); }
.sidebar-brand img { filter: brightness(0) invert(1); }
.sidebar-brand strong { color: #fff; }
.sidebar-brand span { color: #94a3b8; }

.sidebar-nav { display: grid; gap: 6px; margin-top: 24px; }

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 13px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #94a3b8;
  text-align: left;
  font-weight: 600;
  transition: background 0.18s, color 0.18s;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav-item.active { background: rgba(36, 120, 235, 0.2); color: #fff; box-shadow: inset 0 0 0 1px rgba(96, 178, 250, 0.22); }

.nav-dot { width: 7px; height: 7px; border-radius: 999px; background: currentColor; opacity: 0.75; }
.nav-item.active .nav-dot { background: #67e8f9; box-shadow: 0 0 0 4px rgba(103, 232, 249, 0.12); }

.sidebar-footer {
  margin-top: auto;
  padding: 18px 8px 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  display: grid;
  gap: 10px;
  font-size: 12px;
}
.sidebar-footer a { color: #94a3b8; transition: color 0.18s; }
.sidebar-footer a:hover { color: #fff; }
.logout-link { padding: 0; border: 0; background: transparent; color: #94a3b8; text-align: left; transition: color 0.18s; }
.logout-link:hover { color: #fca5a5; }

.main { min-width: 0; padding: 32px; }

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}
.topbar h1 { margin: 0; font-size: 28px; letter-spacing: -0.03em; }
.page-description { margin: 7px 0 0; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.panel-card {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin: 0; font-size: 17px; }
.panel-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

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

.data-table { width: 100%; border-collapse: collapse; min-width: 860px; }
.data-table th {
  padding: 13px 18px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-align: left;
  white-space: nowrap;
}
.data-table td { padding: 14px 18px; border-top: 1px solid var(--line); vertical-align: middle; }
.data-table tbody tr:hover { background: #f8fbff; }
.actions-col { width: 150px; }
.actions { display: flex; gap: 7px; }

.thumb {
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 10px;
  object-fit: cover;
  background: #f8fafc;
}
.thumb-placeholder {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
}
.muted { color: var(--muted); font-size: 11px; }
.strong { font-weight: 600; }
.file-link { color: var(--brand); font-size: 12px; }
.file-link:hover { text-decoration: underline; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-green { background: var(--success-soft); color: var(--success); }
.badge-gray { background: #f1f5f9; color: var(--muted); }
.badge-amber { background: var(--warning-soft); color: var(--warning); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 14px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  transition: background 0.18s, border-color 0.18s, color 0.18s, transform 0.18s;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 8px 20px -10px rgba(36, 120, 235, 0.6); }
.btn-primary:hover { background: var(--brand-strong); }
.btn-secondary { border-color: var(--line-strong); background: #fff; color: #334155; }
.btn-secondary:hover { border-color: #93c5fd; color: var(--brand); }
.btn-danger { border-color: #fecaca; background: var(--danger-soft); color: var(--danger); }
.btn-sm { padding: 6px 10px; font-size: 11px; }
.btn-block { width: 100%; padding: 12px 16px; font-size: 14px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; padding: 24px; }
.form-field { display: grid; gap: 7px; }
.form-field.full { grid-column: 1 / -1; }
.form-field > span { font-size: 12px; font-weight: 600; color: #334155; }
.form-field small { color: var(--muted); font-size: 11px; }
.form-field textarea { min-height: 96px; resize: vertical; }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 10px; padding-top: 4px; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(2, 6, 23, 0.66);
  backdrop-filter: blur(5px);
}
.modal {
  width: min(100%, 920px);
  max-height: 92vh;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 40px 100px -30px rgba(0, 0, 0, 0.6);
}
.modal-narrow { width: min(100%, 620px); }
.modal-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(10px);
}
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-close { border: 0; background: transparent; color: var(--muted); font-size: 24px; line-height: 1; }
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 24px; }
.modal-footer {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(10px);
}

.cover-editor { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.cover-preview {
  width: 116px;
  height: 94px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 11px;
}
.cover-preview img { width: 100%; height: 100%; object-fit: cover; }
.cover-actions { display: grid; gap: 6px; }
.hint { color: var(--muted); font-size: 11px; }

.spec-section { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 20px; }
.spec-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.spec-section-head h3 { margin: 0; font-size: 15px; }
.spec-rows { display: grid; gap: 10px; }
.spec-row { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr auto; gap: 8px; align-items: center; }
.spec-row input { padding: 9px 10px; font-size: 12px; }
.spec-remove { border: 1px solid #fecaca; border-radius: 9px; background: var(--danger-soft); color: var(--danger); padding: 8px 10px; font-size: 11px; }

/* Toast */
.toast-root {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 120;
  display: grid;
  gap: 10px;
  pointer-events: none;
}
.toast {
  min-width: 220px;
  max-width: 360px;
  padding: 12px 15px;
  border: 1px solid #bbf7d0;
  border-radius: 12px;
  background: #f0fdf4;
  color: #166534;
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: toast-in 0.22s ease-out both;
}
.toast.error { border-color: #fecaca; background: #fef2f2; color: #b91c1c; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 18px; }
  .sidebar-brand { padding-bottom: 16px; }
  .sidebar-nav { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 16px; }
  .nav-item { justify-content: center; padding: 9px 8px; font-size: 12px; }
  .nav-dot { display: none; }
  .sidebar-footer { grid-template-columns: 1fr 1fr; margin-top: 16px; }
  .main { padding: 20px; }
  .topbar { flex-direction: column; }
  .topbar-actions { width: 100%; }
  .form-grid { grid-template-columns: 1fr; padding: 18px; }
  .spec-row { grid-template-columns: 1fr 1fr; }
  .spec-row .spec-remove { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  .login-card { padding: 24px; }
  .sidebar-nav { grid-template-columns: 1fr; }
  .panel-head { flex-direction: column; }
  .panel-head .btn { width: 100%; }
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; }
}
.nav-count {
  margin-left: auto;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #f43f5e;
  color: #fff;
  font-size: 10px;
  line-height: 18px;
  text-align: center;
}

.messages-table { min-width: 1120px; }
.message-content {
  max-width: 360px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #475569;
  font-size: 12px;
  line-height: 1.7;
}
