:root {
  --bg: #f1f5f9;
  --sidebar: #0e141b;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #d97706;
  --accent-hover: #b45309;
  --danger: #dc2626;
  --success: #16a34a;
  --blue: #2563eb;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
button, input, select, textarea { font-family: inherit; }

/* Login Page */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0b1118 0%, #172331 100%);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: #ffffff;
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.login-logo {
  height: 58px;
  background: #141a22;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  padding: 6px;
}

.login-logo img {
  height: 100%;
  object-fit: contain;
  mix-blend-mode: lighten;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 800;
  text-align: center;
}

.login-card p {
  margin: 0 0 24px;
  font-size: 13.5px;
  color: var(--muted);
  text-align: center;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: #f8fafc;
  outline: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  background: #ffffff;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-dark {
  background: var(--sidebar);
  color: #ffffff;
}
.btn-dark:hover { background: #1e293b; }

.btn-outline {
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.btn-danger {
  background: rgba(220, 38, 38, 0.1);
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #ffffff; }

.btn-sm {
  padding: 6px 11px;
  font-size: 12.5px;
}

.err-msg {
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
  margin-top: 10px;
  text-align: center;
}

/* App Layout */
.admin-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 18px;
}

.sidebar-logo {
  height: 48px;
  background: #141b24;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 4px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-logo img {
  height: 100%;
  object-fit: contain;
  mix-blend-mode: lighten;
}

.sidebar-brand small {
  font-size: 11.5px;
  color: #94a3b8;
  text-align: center;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.side-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  border: none;
  color: #cbd5e1;
  padding: 11px 14px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all 0.18s;
}

.side-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #ffffff;
}

.side-btn.active {
  background: var(--accent);
  color: #ffffff;
}

.side-badge {
  background: rgba(255, 255, 255, 0.18);
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11.5px;
  font-family: var(--mono);
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.main-area {
  padding: 26px 32px 48px;
  max-width: 1440px;
  width: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.topbar h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
}

.stat-card span {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
}

.stat-card strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
  font-family: var(--mono);
  color: var(--text);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}

.panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar-left input,
.toolbar-left select {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  background: #f8fafc;
}

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

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

th, td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: #f8fafc;
}

.thumb-cell {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #ffffff;
  padding: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.thumb-cell img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
}

.tag-cat { background: #e2e8f0; color: #0f172a; }
.tag-green { background: rgba(22, 163, 74, 0.12); color: #15803d; }
.tag-amber { background: rgba(217, 119, 6, 0.14); color: #b45309; }
.tag-gray { background: #f1f5f9; color: #64748b; }

.pager {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

/* Modal */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

.modal-bg.open { display: flex; }

.modal-box {
  background: #ffffff;
  width: 100%;
  max-width: 860px;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: #ffffff;
  z-index: 5;
}

.modal-header h3 { margin: 0; font-size: 18px; }

.modal-body { padding: 22px 24px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  background: #ffffff;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.lang-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.lang-tab {
  border: 1px solid var(--border);
  background: #f8fafc;
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.lang-tab.active {
  background: var(--sidebar);
  border-color: var(--sidebar);
  color: #ffffff;
}

/* Multi-Image Uploader */
.uploader-box {
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 18px;
  background: #f8fafc;
  margin-bottom: 16px;
}

.uploader-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.img-gallery-editor {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
  gap: 12px;
}

.img-item-card {
  background: #ffffff;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}

.img-item-card.primary {
  border-color: var(--accent);
}

.img-item-preview {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  overflow: hidden;
  border-radius: 6px;
}

.img-item-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.img-item-controls {
  display: flex;
  justify-content: space-between;
  gap: 4px;
}

.img-mini-btn {
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text);
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 6px;
  cursor: pointer;
  white-space: nowrap;
}

.img-mini-btn:hover { background: #e2e8f0; }
.img-mini-btn.prim { background: var(--accent); color: #ffffff; border-color: var(--accent); }
.img-mini-btn.del { color: var(--danger); }

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: var(--sidebar);
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: all 0.22s;
  z-index: 3000;
}

.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
