*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #243447;
  background: linear-gradient(160deg, #eef3ff 0%, #f7f9fc 45%, #e8eef8 100%);
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: min(400px, 100%);
  background: #fff;
  border-radius: 20px;
  padding: 36px 28px;
  box-shadow: 0 18px 50px rgba(55, 90, 150, 0.12);
}

.login-card h1 {
  text-align: center;
  margin-bottom: 24px;
  font-size: 26px;
  color: #1f3a5f;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-form label,
.icon-fields label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: #4a5d73;
}

input[type="text"],
input[type="password"] {
  border: 1px solid #d5deea;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
  background: #fbfcfe;
}

input[type="text"]:focus,
input[type="password"]:focus {
  border-color: #6b8fd4;
  box-shadow: 0 0 0 3px rgba(107, 143, 212, 0.18);
}

.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #4f7dd8, #3a63b8);
  color: #fff;
  box-shadow: 0 8px 20px rgba(58, 99, 184, 0.28);
}

.btn-primary:hover {
  transform: translateY(-1px);
}

.btn-lg {
  padding: 14px 36px;
  font-size: 16px;
  width: 100%;
  max-width: 280px;
}

.btn-ghost {
  background: #eef2f8;
  color: #334861;
}

.btn-ghost:hover {
  background: #e3eaf4;
}

.admin-shell {
  width: min(980px, 94vw);
  margin: 0 auto;
  padding: 36px 0 64px;
}

.admin-header h1 {
  font-size: 30px;
  color: #1f3a5f;
  margin-bottom: 14px;
}

.header-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 22px;
}

.hero-panel {
  background: linear-gradient(135deg, #ece6ff, #e8f0ff);
  border-radius: 22px;
  padding: 24px 26px;
  margin-bottom: 18px;
}

.badge {
  display: inline-block;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: #5a4f8a;
  margin-bottom: 10px;
}

.hero-panel h2 {
  font-size: 22px;
  margin-bottom: 8px;
  color: #2a3558;
}

.hero-panel p,
.hint {
  color: #5b6b82;
  line-height: 1.6;
  font-size: 14px;
}

.section {
  background: rgba(255, 255, 255, 0.72);
  border-radius: 22px;
  padding: 24px;
  margin-top: 18px;
  box-shadow: 0 10px 30px rgba(60, 90, 140, 0.06);
}

.section h2 {
  font-size: 20px;
  margin-bottom: 16px;
  color: #243b5a;
}

.visit-stats-section .block-head {
  margin-bottom: 14px;
}

.visit-stats-wrap {
  position: relative;
  min-height: 120px;
}

.visit-stats-wrap.is-loading .stats-grid {
  opacity: 0.45;
  pointer-events: none;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat-card {
  background: #fff;
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 6px 18px rgba(50, 80, 130, 0.06);
}

.stat-label {
  color: #6a7c93;
  font-size: 14px;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 34px;
  font-weight: 700;
  color: #1f3a5f;
}

@media (max-width: 900px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.alert {
  margin: 14px 0;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
}

.alert-success {
  background: #e8f8ee;
  color: #1f7a45;
}

.alert-error {
  background: #fdecec;
  color: #b42318;
}

.block {
  margin-top: 22px;
}

.block h3 {
  font-size: 17px;
  margin-bottom: 10px;
  color: #2c425e;
}

.bg-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 12px;
}

.bg-card,
.icon-card {
  background: #fff;
  border-radius: 16px;
  padding: 14px;
  border: 1px solid #e6ecf5;
}

.bg-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
}

.bg-preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: #f1f4f9;
  margin-bottom: 12px;
}

.bg-preview-mobile {
  aspect-ratio: 9 / 16;
  max-height: 280px;
  margin-inline: auto;
}

.bg-preview img,
.icon-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.file-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: #5b6b82;
}

.file-label input[type="file"] {
  font-size: 13px;
}

.icon-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 12px;
}

.icon-card {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 16px;
  align-items: start;
}

.icon-preview {
  width: 96px;
  height: 96px;
  border-radius: 22px;
  overflow: hidden;
  background: #f1f4f9;
}

.icon-fields {
  display: grid;
  gap: 10px;
}

.check-row {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
  font-size: 14px;
  color: #4a5d73;
}

.check-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.check-danger {
  color: #c2410c;
}

.block-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.block-head h3 {
  margin-bottom: 4px;
}

.coin-sync-panel {
  margin-top: 14px;
  border: 1px solid #e2e9f3;
  border-radius: 16px;
  background: #fbfdff;
  padding: 16px;
}

.coin-stat {
  font-size: 15px;
  color: #355784;
  margin-bottom: 12px;
}

.coin-stat strong {
  font-size: 22px;
  color: #1f3a5f;
}

.coin-stat-sub {
  margin-left: 8px;
  font-size: 13px;
  color: #7d92b0;
}

.coin-search-bar input {
  width: 100%;
  border: 1px solid #d5deea;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  outline: none;
  background: #fff;
  margin-bottom: 12px;
}

.coin-add-box {
  position: relative;
  margin-bottom: 16px;
  padding: 14px;
  border-radius: 14px;
  background: #eef4ff;
  border: 1px solid #d9e5f8;
}

.coin-add-title,
.coin-list-title {
  font-size: 14px;
  font-weight: 800;
  color: #1f3a5f;
  margin-bottom: 10px;
}

.coin-add-search input {
  margin-bottom: 0;
}

.coin-picker-list {
  position: absolute;
  left: 14px;
  right: 14px;
  top: calc(100% - 6px);
  z-index: 30;
  max-height: 280px;
  overflow: auto;
  background: #fff;
  border: 1px solid #d5deea;
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(40, 80, 140, 0.14);
}

.coin-picker-list[hidden] {
  display: none !important;
}

.coin-picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid #eef2f7;
}

.coin-picker-item:last-child {
  border-bottom: 0;
}

.coin-picker-item img,
.coin-picker-item .coin-thumb-fallback {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: #eef3fb;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #7d92b0;
}

.coin-picker-item div {
  flex: 1;
  min-width: 0;
}

.coin-picker-item strong {
  display: block;
  font-size: 14px;
}

.coin-picker-item small {
  color: #7d92b0;
  font-size: 12px;
}

.btn-add-coin {
  border: 0;
  background: #3b82f6;
  color: #fff;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.btn-add-coin:disabled {
  opacity: 0.55;
  cursor: wait;
}

.coin-tag {
  font-size: 12px;
  color: #64748b;
  background: #e8eef7;
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}

.coin-edit,
.coin-remove {
  border: 0;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.coin-edit {
  background: #eef5ff;
  color: #2563eb;
}

.coin-remove {
  background: #fff1f1;
  color: #dc2626;
}

.coin-sample-actions {
  margin-left: auto;
  display: inline-flex;
  gap: 6px;
  flex-shrink: 0;
}

.btn-danger {
  border: 0;
  background: #fff1f1;
  color: #dc2626;
  border-radius: 10px;
  padding: 8px 14px;
  font-weight: 700;
  cursor: pointer;
}

.suggest-empty {
  padding: 14px;
  text-align: center;
  color: #7d92b0;
  font-size: 13px;
}

.coin-list-wrap {
  position: relative;
  min-height: 120px;
}

.coin-sample-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}

.coin-sample-list.is-loading {
  opacity: 0.45;
  pointer-events: none;
}

.list-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(251, 253, 255, 0.55);
}

.list-loading[hidden] {
  display: none !important;
}

.coin-sample-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #e8eef7;
}

.coin-sample-meta {
  min-width: 0;
}

.coin-sample-item .coin-tag {
  margin-left: auto;
}

.coin-sample-item img,
.coin-sample-item .coin-thumb-fallback {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: #eef3fb;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #7d92b0;
}

.coin-sample-item strong {
  display: block;
  font-size: 14px;
}

.coin-sample-item small {
  color: #7d92b0;
  font-size: 12px;
}

.coin-table-wrap {
  margin-top: 14px;
  border: 1px solid #e2e9f3;
  border-radius: 16px;
  overflow: hidden;
  background: #fbfdff;
}

.coin-table-head,
.coin-row {
  display: grid;
  grid-template-columns: 36px 52px 110px 1fr minmax(220px, 1.4fr) 64px 72px;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
}

.coin-table-head {
  background: #eef3fb;
  color: #5b6b82;
  font-size: 12px;
  font-weight: 700;
}

.coin-row {
  background: #fff;
  border-top: 1px solid #e8eef7;
}

.coin-row.is-dragging {
  opacity: 0.55;
  background: #f3f7ff;
}

.coin-drag {
  border: 0;
  background: transparent;
  color: #9aadc6;
  cursor: grab;
  font-size: 14px;
  letter-spacing: -2px;
  padding: 6px 0;
}

.coin-thumb {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  overflow: hidden;
  background: #eef3fb;
  display: flex;
  align-items: center;
  justify-content: center;
}

.coin-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.coin-thumb-fallback {
  color: #7d92b0;
  font-weight: 800;
}

.coin-row input[type="text"] {
  width: 100%;
  border: 1px solid #d5deea;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  background: #fbfcfe;
  outline: none;
}

.coin-row input[type="text"]:focus {
  border-color: #6b8fd4;
  box-shadow: 0 0 0 3px rgba(107, 143, 212, 0.16);
}

.coin-image-fields {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.coin-file {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 12px;
  border-radius: 10px;
  background: #eef3fb;
  color: #355784;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.coin-file input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.coin-switch {
  position: relative;
  width: 42px;
  height: 24px;
  display: inline-block;
  margin: 0 auto;
}

.coin-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.coin-switch span {
  position: absolute;
  inset: 0;
  background: #c9d5e6;
  border-radius: 999px;
  cursor: pointer;
  transition: 0.2s;
}

.coin-switch span::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}

.coin-switch input:checked + span {
  background: #3b82f6;
}

.coin-switch input:checked + span::after {
  transform: translateX(18px);
}

.btn-coin-del {
  border: 0;
  background: #fff1f1;
  color: #dc2626;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.btn-coin-del:hover {
  background: #ffe4e4;
}

.coin-empty-tip {
  padding: 28px 16px;
  text-align: center;
  color: #7d92b0;
  font-size: 14px;
  grid-column: 1 / -1;
}

.pager {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid #e8eef7;
}

.pager-left select,
.pager-jump input {
  border: 1px solid #d5deea;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 13px;
  background: #fff;
}

.pager-center {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pager-right {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.pager-btn,
.pager-num {
  border: 1px solid #d5deea;
  background: #fff;
  color: #355784;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
}

.pager-num.is-active {
  background: #3b82f6;
  border-color: #3b82f6;
  color: #fff;
  font-weight: 700;
}

.pager-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pager-jump {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #5b6b82;
  margin-left: 4px;
}

.pager-jump input {
  width: 64px;
}

.admin-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 50, 80, 0.28);
  backdrop-filter: blur(2px);
}

.admin-modal[hidden] {
  display: none !important;
}

.admin-modal-card {
  width: min(420px, 92vw);
  background: #fff;
  border-radius: 16px;
  padding: 22px 20px 16px;
  box-shadow: 0 18px 40px rgba(40, 80, 140, 0.18);
}

.coin-edit-card {
  width: min(480px, 94vw);
}

.coin-edit-title {
  margin: 0 0 16px;
  font-size: 18px;
  color: #1f2a3a;
}

.coin-edit-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.coin-edit-preview img,
.coin-edit-preview .coin-thumb-fallback {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  background: #eef3fb;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #7d92b0;
  font-size: 18px;
}

.coin-edit-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #5b6b82;
}

.coin-edit-field input[type="text"],
.coin-edit-field input[type="file"] {
  width: 100%;
  border: 1.5px solid #d7e4f5;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  color: #1f2a3a;
  background: #fbfdff;
  outline: none;
}

.coin-edit-field input[type="text"]:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.coin-edit-actions {
  margin-top: 8px;
  justify-content: space-between;
}

.coin-edit-actions .btn-danger {
  margin-right: auto;
}

.coin-create-row {
  margin-top: 12px;
}

.admin-modal-card p {
  font-size: 15px;
  color: #243447;
  line-height: 1.6;
  margin-bottom: 18px;
}

.admin-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.admin-loading {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(236, 242, 250, 0.55);
  backdrop-filter: blur(2px);
}

.admin-loading[hidden] {
  display: none !important;
}

.admin-loading-box {
  background: #fff;
  border-radius: 16px;
  padding: 22px 28px;
  box-shadow: 0 14px 36px rgba(40, 80, 140, 0.14);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: #5b6b82;
}

.admin-spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid rgba(59, 130, 246, 0.2);
  border-top-color: #3b82f6;
  animation: adminSpin 0.8s linear infinite;
}

@keyframes adminSpin {
  to {
    transform: rotate(360deg);
  }
}

.save-bar {
  margin-top: 24px;
  display: flex;
  justify-content: center;
}

@media (max-width: 980px) {
  .coin-table-head {
    display: none;
  }

  .coin-row {
    grid-template-columns: 28px 48px 1fr auto;
    grid-template-areas:
      "drag thumb symbol del"
      "drag thumb name del"
      "img img img img"
      "sw sw sw sw";
  }

  .coin-drag { grid-area: drag; }
  .coin-thumb { grid-area: thumb; }
  .coin-symbol { grid-area: symbol; }
  .coin-name { grid-area: name; }
  .coin-image-fields { grid-area: img; }
  .coin-switch { grid-area: sw; margin: 0; }
  .btn-coin-del { grid-area: del; }
}

@media (max-width: 720px) {
  .stats-grid,
  .bg-grid {
    grid-template-columns: 1fr;
  }

  .icon-card {
    grid-template-columns: 1fr;
  }

  .admin-shell {
    padding-top: 24px;
  }
}
