/* 确保 hidden 属性优先于任何 display 声明 */
[hidden] { display: none !important; }

/* ---------- 通用按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}

.btn:hover { border-color: #c7d2fe; color: var(--brand); }

.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.btn.primary:hover { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }

.btn.ghost { background: transparent; }

.btn.danger { color: #dc2626; }
.btn.danger:hover { border-color: #fca5a5; background: #fef2f2; color: #dc2626; }

.btn.block { width: 100%; height: 42px; }

.btn.sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12.5px;
  border-radius: 7px;
}

.btn:disabled { opacity: .55; cursor: not-allowed; }

.icon-btn {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  border-radius: 8px;
}

.icon-btn:hover { background: #f1f2f4; color: var(--text); }

/* ---------- 登录 ---------- */
.admin-body { background: var(--bg); }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px 28px 24px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 700;
}

.login-sub {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 13px;
}

.login-card input {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14.5px;
  font-family: inherit;
  outline: none;
}

.login-card input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.login-err {
  min-height: 18px;
  margin: 10px 0 0;
  color: #dc2626;
  font-size: 13px;
}

.login-tip {
  margin: 14px 0 0;
  color: #9ca3af;
  font-size: 12px;
  line-height: 1.5;
}

/* ---------- 管理页 ---------- */
.admin-view { min-height: 100vh; }

.admin-header {
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}

.admin-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 64px;
}

.admin-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.admin-title strong { font-size: 16px; }

.muted-sm { color: var(--muted); font-size: 12.5px; }

.admin-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-main { padding: 24px 20px 60px; }

.table-wrap {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.table th {
  text-align: left;
  padding: 12px 14px;
  background: #fafbfc;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-weight: 500;
  font-size: 12.5px;
  white-space: nowrap;
}

.table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f2f4;
  vertical-align: middle;
}

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

.table tr:hover td { background: #fcfdff; }

.cell-title { font-weight: 500; }
.cell-sub {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 12px;
}

.badge.on { background: #ecfdf5; color: #047857; }
.badge.off { background: #f3f4f6; color: #6b7280; }
.badge.pin { background: #fff4e5; color: #b45309; }

.row-actions { display: flex; gap: 5px; flex-wrap: nowrap; }
.row-actions .btn.sm { padding: 0 8px; font-size: 12px; }

.table-empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal[hidden] { display: none; }

.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(2px);
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, .22);
}

.modal-head {
  position: sticky;
  top: 0;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--line);
  z-index: 1;
}

.modal-head h2 { margin: 0; font-size: 16px; font-weight: 600; }

.modal-body { padding: 18px 22px 20px; }

.field { display: block; margin-bottom: 14px; }

.field > span {
  display: block;
  margin-bottom: 6px;
  font-size: 12.5px;
  color: var(--muted);
}

.field > span em { color: #dc2626; font-style: normal; }

.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}

.field textarea { resize: vertical; min-height: 84px; }

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field.check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 22px;
}

.field.check input { width: 16px; height: 16px; }
.field.check span { margin: 0; font-size: 13.5px; color: var(--text); }

.form-err {
  min-height: 18px;
  margin: 0 0 8px;
  color: #dc2626;
  font-size: 13px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 6px;
}

@media (max-width: 720px) {
  .admin-bar { height: auto; padding: 12px 0; flex-direction: column; align-items: flex-start; }
  .admin-actions { width: 100%; }
  .admin-actions .btn { flex: 1 1 auto; }
  .table th:nth-child(4),
  .table td:nth-child(4) { display: none; }
  .cell-sub { max-width: 180px; }
  .field-row { grid-template-columns: 1fr; }
  .field.check { padding-top: 0; }
}

/* ================= v2 新增：图片与动态行 ================= */

.modal-card.wide { max-width: 660px; }

.hint {
  margin: 6px 0 0;
  color: #9ca3af;
  font-size: 12px;
  line-height: 1.5;
}

/* 表格封面缩略图 */
.thumb {
  width: 54px;
  height: 32px;
  border-radius: 6px;
  overflow: hidden;
  background: #f1f4f9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.thumb img { width: 100%; height: 100%; object-fit: cover; }

.thumb-ph { color: #a3aec2; font-size: 10.5px; }

/* 封面选择器 */
.cover-picker {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafbfd;
}

.cover-preview {
  flex: 0 0 168px;
  width: 168px;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background: #eef2f8;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e6eaf0;
}

.cover-preview img { width: 100%; height: 100%; object-fit: cover; }
.cover-preview .ph { color: #a3aec2; font-size: 12px; }

.cover-side { flex: 1; min-width: 0; }

.cover-side input {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

.cover-side input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(26, 95, 208, .1);
}

.cover-btns { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

/* 动态行 */
.dyn-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }

.dyn-row {
  display: grid;
  gap: 8px;
  align-items: center;
}

.dyn-row input,
.dyn-row select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  background: #fff;
  color: var(--text);
  min-width: 0;
}

.dyn-row input:focus,
.dyn-row select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(26, 95, 208, .1);
}

.dyn-row.btn-dyn { grid-template-columns: 110px 1fr 68px 28px; }
.dyn-row.field-dyn { grid-template-columns: 100px 1fr 28px; }

.icon-x {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 7px;
  color: #9ca3af;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: all .15s;
}

.icon-x:hover { border-color: #fca5a5; color: #dc2626; background: #fef2f2; }

/* 轮播行 */
.banner-rows { display: flex; flex-direction: column; gap: 14px; margin-bottom: 12px; }

.banner-row {
  display: flex;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafbfd;
}

.banner-thumb {
  flex: 0 0 140px;
  width: 140px;
  aspect-ratio: 1920 / 620;
  border-radius: 7px;
  overflow: hidden;
  background: #eef2f8;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e6eaf0;
}

.banner-thumb img { width: 100%; height: 100%; object-fit: cover; }

.banner-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }

.banner-fields input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 12.5px;
  font-family: inherit;
  outline: none;
  background: #fff;
}

.banner-fields input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(26, 95, 208, .1);
}

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }

@media (max-width: 720px) {
  .cover-picker { flex-direction: column; }
  .cover-preview { width: 100%; flex: none; }
  .dyn-row.btn-dyn { grid-template-columns: 1fr 1fr; }
  .dyn-row.btn-dyn .icon-x { grid-column: 2; justify-self: end; }
  .dyn-row.field-dyn { grid-template-columns: 90px 1fr 28px; }
  .banner-row { flex-direction: column; }
  .banner-thumb { width: 100%; flex: none; }
  .row-2 { grid-template-columns: 1fr; }
}
