:root {
  --bg: #f3f4f6;
  --bg-2: #e9ebf0;
  --panel: #ffffff;
  --ink: #0b0d10;
  --muted: #5c6370;
  --line: rgba(11, 13, 16, 0.08);
  --accent: #0b0d10;
  --accent-2: #1c2430;
  --highlight: #c4a574;
  --danger: #b42318;
  --ok: #067647;
  --chip: #eef0f4;
  --shadow: 0 1px 0 rgba(11, 13, 16, 0.04), 0 18px 40px rgba(11, 13, 16, 0.06);
  --radius: 18px;
  --font: "Manrope", "Noto Sans SC", sans-serif;
  --display: "Syne", "Manrope", "Noto Sans SC", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sidebar: #0b0d10;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1000px 520px at 100% -8%, rgba(196, 165, 116, 0.14), transparent 55%),
    radial-gradient(700px 420px at 0% 0%, rgba(28, 36, 48, 0.05), transparent 50%),
    linear-gradient(180deg, #f7f8fa 0%, var(--bg) 45%, var(--bg-2) 100%);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--accent-2); }

.app-shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
  background:
    radial-gradient(500px 280px at 20% 0%, rgba(196, 165, 116, 0.14), transparent 60%),
    linear-gradient(180deg, #14181f 0%, var(--sidebar) 100%);
  color: #f4f5f7;
  padding: 28px 18px;
  display: flex; flex-direction: column; gap: 32px;
  border-right: 1px solid rgba(255,255,255,0.06);
}
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 10px; }
.brand strong {
  display: block; font-family: var(--display); font-size: 16px;
  letter-spacing: -0.03em; font-weight: 700;
}
.brand small {
  color: rgba(244, 245, 247, 0.55); font-size: 11px; letter-spacing: 0.04em;
}
.brand-mark {
  width: 30px; height: 30px; min-width: 30px; min-height: 30px;
  border-radius: 8px; overflow: hidden; flex: 0 0 30px;
  background: #11151b;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}
.brand-mark img {
  width: 30px !important; height: 30px !important;
  max-width: 30px; max-height: 30px;
  object-fit: cover; display: block;
}
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  color: rgba(244, 245, 247, 0.62); padding: 11px 14px; border-radius: 12px;
  font-weight: 600; font-size: 14px; transition: .18s ease;
}
.nav a:hover, .nav a.active {
  background: rgba(255,255,255,0.07); color: #fff;
}
.nav a.active {
  box-shadow: inset 2px 0 0 var(--highlight);
}
.sidebar-foot { margin-top: auto; padding: 10px 12px; display: grid; gap: 10px; }
.user-chip { font-size: 13px; color: rgba(244,245,247,0.5); }
.logout {
  color: rgba(244,245,247,0.72); font-size: 13px; font-weight: 600;
  letter-spacing: 0.02em;
}
.logout:hover { color: #fff; }

.main { padding: 28px 32px 48px; animation: rise .45s ease both; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.topbar h1 {
  margin: 0; font-family: var(--display); font-size: 32px;
  letter-spacing: -0.04em; font-weight: 700;
}
.content { display: grid; gap: 16px; }

.panel {
  background: rgba(255,255,255,0.92); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px;
  backdrop-filter: blur(8px);
}
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.panel h2 {
  margin: 0 0 14px; font-family: var(--display); font-size: 18px;
  letter-spacing: -0.02em; font-weight: 700;
}
.panel-head h2 { margin: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat-card {
  background: rgba(255,255,255,0.92); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
  transition: transform .2s ease;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card span {
  color: var(--muted); font-size: 12px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.stat-card strong {
  display: block; font-family: var(--display); font-size: 34px;
  margin-top: 10px; letter-spacing: -0.04em;
}

.grid-2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; }
.grid-2-inner, .grid-3-inner { display: grid; gap: 12px; }
.grid-2-inner { grid-template-columns: 1fr 1fr; }
.grid-3-inner { grid-template-columns: 1fr 1fr 1fr; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  text-align: left; padding: 12px 8px; border-bottom: 1px solid var(--line); vertical-align: top;
}
.table th {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); font-weight: 700;
}
.muted { color: var(--muted); }
.small { font-size: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 999px; padding: 11px 18px; font: inherit; font-weight: 700;
  cursor: pointer; text-decoration: none; transition: transform .18s ease, background .18s ease;
}
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--accent-2); color: #fff; transform: translateY(-1px); }
.btn-secondary { background: var(--chip); color: var(--ink); }
.btn-secondary:hover { background: #e3e6ec; color: var(--ink); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; }

label { display: grid; gap: 7px; font-size: 12px; color: var(--muted); font-weight: 650; letter-spacing: 0.02em; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font: inherit; color: var(--ink); background: #fff;
  outline: none; transition: box-shadow .15s ease, border-color .15s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: rgba(11,13,16,0.28);
  box-shadow: 0 0 0 4px rgba(11,13,16,0.05);
}
textarea { resize: vertical; line-height: 1.5; }
.stack { display: grid; gap: 14px; }
.stack-sm { display: grid; gap: 8px; }
.actions, .form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.form-actions { justify-content: flex-end; margin-top: 8px; }

.alert { padding: 13px 15px; border-radius: 12px; font-size: 14px; font-weight: 550; }
.alert-success { background: #ecfdf3; color: var(--ok); border: 1px solid #abefc6; }
.alert-error { background: #fef3f2; color: var(--danger); border: 1px solid #fecdca; }

.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-ok { background: #ecfdf3; color: var(--ok); }
.badge-muted { background: var(--chip); color: var(--muted); }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { width: auto; min-width: 140px; }
.row-actions { display: flex; gap: 12px; align-items: center; }
.row-actions form { margin: 0; }
.link-danger, .link-btn {
  background: none; border: 0; padding: 0; font: inherit; cursor: pointer;
  color: var(--ink); font-weight: 650;
}
.link-danger { color: var(--danger); }

.code, pre.code {
  font-family: var(--mono); font-size: 12px;
  background: #11151b; color: #e8e4db;
  padding: 16px; border-radius: 14px; overflow: auto; white-space: pre-wrap; line-height: 1.6;
  border: 1px solid rgba(255,255,255,0.06);
}
.key { font-family: var(--mono); font-size: 12px; word-break: break-all; }
.api-box { display: grid; gap: 10px; }
.api-box p { margin: 0; color: var(--muted); }

.tier-table { display: grid; gap: 8px; }
.tier-head, .tier-row { display: grid; grid-template-columns: 1fr 1fr 1fr 36px; gap: 8px; align-items: center; }
.tier-head { font-size: 11px; color: var(--muted); padding: 0 4px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 700; }
.inline-row { display: grid; grid-template-columns: 1fr 1fr 36px; gap: 8px; align-items: center; }
#flavors-rows .inline-row { grid-template-columns: 1fr 36px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 12px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-size: 18px; color: var(--muted);
}
.hint { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.cover-preview img { max-width: 160px; border-radius: 14px; margin-top: 8px; border: 1px solid var(--line); }
.field-label {
  display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 8px;
}

/* Multi-image gallery */
.image-gallery { margin-top: 6px; }
.image-gallery.is-busy { opacity: 0.6; pointer-events: none; }
.image-gallery__list {
  display: flex; flex-wrap: wrap; gap: 10px; min-height: 0; margin-bottom: 10px;
}
.image-gallery__item {
  position: relative;
  width: 96px; height: 96px;
  border-radius: 14px; overflow: hidden;
  border: 1px solid var(--line);
  background: var(--chip);
  cursor: grab;
  user-select: none;
  box-shadow: 0 1px 2px rgba(16,24,40,0.04);
}
.image-gallery__item.is-dragging { opacity: 0.55; cursor: grabbing; }
.image-gallery__item.is-over { outline: 2px solid var(--accent, #c4a574); }
.image-gallery__item.is-cover { border-color: #0b0d10; }
.image-gallery__item img {
  width: 96px !important; height: 96px !important;
  max-width: 96px; max-height: 96px;
  object-fit: cover; display: block; pointer-events: none;
}
.image-gallery__badge {
  position: absolute; left: 6px; top: 6px;
  background: #0b0d10; color: #fff;
  font-size: 10px; font-weight: 700; letter-spacing: 0.04em;
  padding: 3px 7px; border-radius: 999px;
}
.image-gallery__remove {
  position: absolute; right: 4px; top: 4px;
  width: 22px; height: 22px; border: 0; border-radius: 999px;
  background: rgba(11,13,16,0.72); color: #fff;
  font-size: 14px; line-height: 1; cursor: pointer;
  display: grid; place-items: center;
}
.image-gallery__remove:hover { background: #b42318; }
.image-gallery__add {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 40px; padding: 0 14px;
  border: 1px dashed rgba(11,13,16,0.22);
  border-radius: 12px; background: #fff;
  font-size: 13px; font-weight: 700; cursor: pointer; color: var(--ink);
}
.image-gallery__add:hover { border-color: #0b0d10; }
.image-gallery__add input[type="file"] { display: none; }
.pagination { display: flex; gap: 6px; margin-top: 14px; }
.pagination a {
  min-width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 999px; background: var(--chip); color: var(--ink); font-weight: 700;
}
.pagination a.active { background: var(--ink); color: #fff; }

.preview-box {
  min-height: 180px; background: var(--chip); border: 1px dashed rgba(11,13,16,0.14);
  border-radius: 14px; padding: 14px; font-size: 13px; line-height: 1.5;
}
.result-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.result-list .ok { color: var(--ok); }
.result-list .bad { color: var(--danger); }

.login-body {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(800px 420px at 85% 10%, rgba(196,165,116,0.22), transparent 55%),
    radial-gradient(700px 500px at 10% 90%, rgba(11,13,16,0.18), transparent 50%),
    linear-gradient(145deg, #11151b 0%, #1c2430 45%, #0b0d10 100%);
}
.login-card {
  width: 100%; max-width: 420px; background: rgba(255,255,255,0.96);
  border: 1px solid rgba(255,255,255,0.2); border-radius: 24px; padding: 32px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.35);
  animation: rise .5s ease both;
}
.login-brand { display: flex; gap: 14px; align-items: center; margin-bottom: 24px; }
.login-brand .brand-mark {
  width: 36px; height: 36px; min-width: 36px; min-height: 36px;
  border-radius: 10px; flex: 0 0 36px;
}
.login-brand .brand-mark img {
  width: 36px !important; height: 36px !important;
  max-width: 36px; max-height: 36px;
}
.login-brand h1 {
  margin: 0; font-family: var(--display); font-size: 28px;
  letter-spacing: -0.04em; font-weight: 700;
}
.login-brand p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }

.inline-edit { display: flex; gap: 8px; align-items: center; margin: 0; }
.inline-edit input[type="text"] { min-width: 120px; }
.inline-edit.compact input { padding: 6px 8px; }

.queue-list { display: grid; gap: 14px; }
.queue-card {
  display: block;
  border: 1px solid var(--line); border-radius: 18px; padding: 16px; background: #fff;
  transition: transform .2s ease, box-shadow .2s ease;
}
.queue-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.queue-body--full { min-width: 0; }
.queue-body h3 {
  margin: 0 0 10px; font-family: var(--display); font-size: 20px;
  letter-spacing: -0.03em; font-weight: 700;
}
.queue-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.queue-meta span {
  background: var(--chip); border-radius: 999px; padding: 5px 11px;
  font-size: 12px; color: var(--muted); font-weight: 650;
}
.queue-details { margin: 6px 0; font-size: 13px; }
.queue-details summary { cursor: pointer; color: var(--ink); font-weight: 700; }
.queue-details ul { margin: 8px 0 0; padding-left: 18px; color: var(--muted); }
.queue-actions {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px;
}
.queue-actions button:disabled { opacity: 0.45; cursor: not-allowed; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; gap: 12px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { margin-top: 0; width: 100%; display: flex; justify-content: space-between; }
  .stat-grid, .grid-2, .grid-2-inner, .grid-3-inner { grid-template-columns: 1fr; }
  .main { padding: 16px; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 10px; }
}
@media (max-width: 720px) {
  .image-gallery__item,
  .image-gallery__item img {
    width: 80px !important; height: 80px !important;
    max-width: 80px; max-height: 80px;
  }
}
