:root {
  --bg: #0f1419;
  --panel: #1a2332;
  --border: #2a3544;
  --text: #e8edf4;
  --muted: #8b9bb4;
  --accent: #5b9fd4;
  --accent-hover: #7ab3e0;
  --danger: #e05c5c;
  --success: #4caf82;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }

#app { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
}

.brand {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 24px;
  color: var(--accent);
}

.nav-link {
  display: block;
  padding: 10px 12px;
  color: var(--muted);
  text-decoration: none;
  border-radius: 8px;
  margin-bottom: 4px;
}

.nav-link:hover, .nav-link.active {
  background: rgba(91, 159, 212, 0.15);
  color: var(--text);
}

.logout-btn {
  margin-top: auto;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.main { flex: 1; display: flex; flex-direction: column; }

.topbar {
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar .help-tip-btn {
  margin-left: 0;
}

.topbar .env-tag {
  margin-left: auto;
}

.topbar h1 { margin: 0; font-size: 22px; }

.env-tag {
  font-size: 12px;
  color: var(--muted);
  background: var(--panel);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.page-content { padding: 24px 28px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.stat-item {
  background: rgba(255,255,255,0.03);
  border-radius: 10px;
  padding: 16px;
}

.stat-item strong { display: block; font-size: 28px; margin-top: 6px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

th { color: var(--muted); font-weight: 500; }

button, .btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

button:hover { background: var(--accent-hover); }

button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

button.danger { background: var(--danger); }

button.active, .actions button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.admin-busy {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 25, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}

.admin-busy-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px 28px;
  max-width: 420px;
  text-align: center;
}

.admin-busy-progress {
  margin-top: 16px;
  text-align: left;
}

.admin-busy-progress-bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.admin-busy-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #7dd3fc);
  border-radius: 999px;
  transition: width 0.35s ease;
}

.admin-busy-countdown {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.seed-list-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 16px;
  overflow: hidden;
}

.seed-list-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border: none;
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.seed-list-toggle:hover {
  background: rgba(255, 255, 255, 0.07);
}

.seed-list-toggle-icon {
  width: 1em;
  display: inline-block;
  color: var(--muted);
}

.seed-list-body {
  padding: 0 14px 14px;
}

.seed-list-panel.collapsed .seed-list-body {
  display: none;
}

.seed-list {
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0;
}

.seed-item {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
  cursor: pointer;
}

.seed-item:last-child { border-bottom: none; }

.seed-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  margin: 2px 0 0;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--accent);
}

.seed-meta {
  flex: 1;
  min-width: 0;
  width: 100%;
}

.seed-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  line-height: 1.4;
}

.seed-name-text {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.seed-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.45;
  word-break: break-word;
}

.seed-summary {
  color: var(--muted);
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.5;
}

.seed-search-row input {
  margin-bottom: 0;
}

.seed-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.seed-filters button {
  font-size: 13px;
  padding: 6px 10px;
}

.btn-group-title {
  font-size: 13px;
  color: var(--muted);
  margin: 16px 0 8px;
}

.init-desc {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
  line-height: 1.5;
}

.images-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.images-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stat-chip {
  font-size: 13px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
}

.stat-chip strong {
  color: var(--text);
  font-weight: 600;
}

.stat-chip-accent {
  border-color: rgba(91, 159, 212, 0.45);
  background: rgba(91, 159, 212, 0.12);
  color: var(--accent);
}

.stat-chip-accent strong { color: var(--accent); }

.images-toolbar-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}

.images-toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
}

.images-toolbar-block {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.images-toolbar-end {
  margin-left: auto;
}

.toolbar-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.images-sort-select {
  width: auto;
  min-width: 148px;
  margin-bottom: 0;
  font-size: 13px;
  padding: 6px 10px;
}

.btn-toggle-group {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.btn-toggle {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
}

.btn-toggle + .btn-toggle {
  border-left: 1px solid var(--border);
}

.btn-toggle:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.btn-toggle.active {
  background: var(--accent);
  color: #fff;
}

.images-filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
}

.filter-tab:hover {
  color: var(--text);
  border-color: rgba(91, 159, 212, 0.4);
}

.filter-tab.active {
  background: rgba(91, 159, 212, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-text {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  padding: 4px 8px;
  cursor: pointer;
}

.btn-text:hover { text-decoration: underline; }

.images-batch-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.batch-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.batch-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 2px;
}

.btn-mini {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  line-height: 1.2;
}

.btn-mini:hover:not(:disabled) { background: var(--accent-hover); }

.btn-mini.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-mini.secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
}

.btn-mini.danger {
  background: transparent;
  border: 1px solid rgba(224, 92, 92, 0.55);
  color: #f0a0a0;
}

.btn-mini.danger:hover:not(:disabled) {
  background: rgba(224, 92, 92, 0.15);
}

.btn-mini:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.images-grid {
  display: grid;
  gap: 14px;
}

.images-grid.view-small {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.images-grid.view-large {
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}

.image-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.image-card-preview {
  position: relative;
  background: var(--bg);
}

.image-card-preview img {
  width: 100%;
  object-fit: cover;
  display: block;
  background: var(--bg);
}

.image-card-preview.small img { height: 130px; }
.image-card-preview.large img { height: 240px; }

.image-card-check {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: rgba(15, 20, 25, 0.55);
  border-radius: 6px;
}

.image-card-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
  margin: 0;
}

.image-status-badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
}

.image-status-badge.pending { background: rgba(224, 92, 92, 0.88); }
.image-status-badge.published { background: rgba(72, 160, 104, 0.9); }
.image-status-badge.deleted { background: rgba(120, 120, 128, 0.9); }

.storage-bar-wrap { margin: 8px 0; }
.storage-bar-label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.storage-bar {
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}
.storage-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #6bc98a);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.storage-warn { color: #e05c5c; font-size: 13px; margin: 8px 0 0; }

.images-cleanup-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.cleanup-days-label { font-size: 13px; color: var(--muted); }
.cleanup-hint { font-size: 12px; color: var(--muted); }

.image-card-body {
  padding: 10px 12px 12px;
}

.image-card-meta {
  font-size: 12px;
  line-height: 1.45;
  margin-bottom: 10px;
}

.image-meta-line {
  color: var(--muted);
  margin-bottom: 4px;
}

.image-url-line {
  display: block;
  width: 100%;
  text-align: left;
  font-size: 11px;
  color: var(--accent);
  background: rgba(91, 159, 212, 0.08);
  border: 1px solid rgba(91, 159, 212, 0.2);
  border-radius: 6px;
  padding: 6px 8px;
  margin-top: 6px;
  cursor: pointer;
  word-break: break-all;
  line-height: 1.35;
}

.image-url-line:hover {
  background: rgba(91, 159, 212, 0.14);
}

.image-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.image-card-actions .btn-mini {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
}

@media (max-width: 900px) {
  .images-toolbar-end {
    margin-left: 0;
  }

  .images-toolbar-row {
    flex-direction: column;
    align-items: stretch;
  }

  .images-filter-tabs {
    order: 3;
  }
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  width: 100%;
  margin-bottom: 10px;
}

.form-row { margin-bottom: 12px; }

.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
  pointer-events: auto;
}

body.login-open #app {
  visibility: hidden;
  pointer-events: none;
  user-select: none;
}

.login-card {
  position: relative;
  z-index: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 360px;
  max-width: calc(100vw - 32px);
  pointer-events: auto;
}

.login-card h2 { margin: 0 0 8px; }
.login-card p { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.login-label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}
.login-card input[type="password"],
.login-card #passwordInput {
  display: block;
  width: 100%;
  box-sizing: border-box;
  background: #fff;
  color: #111;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 16px;
  line-height: 1.4;
  margin-bottom: 12px;
  pointer-events: auto;
  -webkit-user-select: text;
  user-select: text;
  caret-color: #111;
}
.login-error { color: var(--danger); font-size: 13px; margin-top: 10px; }

.thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg);
}

.submission-thumb {
  width: 96px;
  height: 96px;
  border: 1px solid var(--border);
}

.image-preview-hit {
  cursor: zoom-in;
}

.admin-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.admin-lightbox.hidden { display: none !important; }

.admin-lightbox img {
  max-width: min(96vw, 1200px);
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
}

.admin-lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  border: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 28px;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  cursor: pointer;
}

.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.badge {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(91,159,212,0.2);
  color: var(--accent);
}

.news-refresh-card { margin-top: 16px; }
.news-refresh-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.news-refresh-phase { font-size: 13px; color: var(--muted); }
.news-refresh-countdown { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.news-refresh-summary { margin: 8px 0; padding: 8px 12px; border-radius: 8px; font-size: 13px; }
.news-refresh-ok { background: rgba(72, 187, 120, 0.15); color: #2f855a; }
.news-refresh-err { background: rgba(245, 101, 101, 0.15); color: #c53030; }
.news-source-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.news-source-row { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: rgba(255,255,255,0.02); }
.news-source-row.ok { border-color: rgba(72, 187, 120, 0.35); }
.news-source-row.err { border-color: rgba(245, 101, 101, 0.45); background: rgba(245, 101, 101, 0.06); }
.news-source-row.run { border-color: rgba(91, 159, 212, 0.45); }
.news-source-row.pending { opacity: 0.72; }
.news-source-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.news-source-cat { font-size: 11px; padding: 2px 6px; border-radius: 4px; background: rgba(91,159,212,0.15); color: var(--accent); }
.news-source-meta { font-size: 12px; color: var(--muted); margin-top: 4px; word-break: break-word; }
.news-errors-box { margin-top: 12px; padding: 12px; border-radius: 8px; border: 1px solid rgba(245, 101, 101, 0.4); background: rgba(0,0,0,0.2); }
.news-errors-box.hidden { display: none !important; }
.news-errors-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-weight: 600; }
.news-errors-pre { margin: 0; font-size: 12px; white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow: auto; }

@media (max-width: 768px) {
  #app { flex-direction: column; }
  .sidebar { width: 100%; }
}
