:root {
  --primary: #e31e24;
  --sidebar: #1e293b;
  --sidebar-text: #cbd5e1;
  --bg: #f1f5f9;
  --border: #e2e8f0;
  --danger: #ef4444;
  --success: #22c55e;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body.admin-body {
  font-family: 'Peyda', system-ui, sans-serif;
  background: var(--bg);
  display: flex;
  flex-direction: row-reverse;
  min-height: 100vh;
}

.admin-sidebar {
  width: 240px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 1.25rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: white;
  border-bottom: 1px solid #334155;
}

.admin-sidebar nav { padding: 1rem 0; }
.admin-sidebar a {
  display: block;
  padding: .75rem 1.25rem;
  color: var(--sidebar-text);
  text-decoration: none;
}
.admin-sidebar a:hover { background: #334155; color: white; }

.admin-content { flex: 1; display: flex; flex-direction: column; }
.admin-topbar {
  background: white;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
}
.admin-main { padding: 1.5rem; flex: 1; }
.admin-main h1 { margin-bottom: 1.5rem; }

.btn {
  display: inline-flex;
  align-items: center;
  padding: .6rem 1.2rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: .875rem;
  border: none;
  cursor: pointer;
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: white; }
.btn-outline { background: white; border: 1px solid var(--border); color: #334155; }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-block { width: 100%; }

.alert {
  padding: .75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: white;
  padding: 1.25rem;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.stat-card span { display: block; font-size: .85rem; color: #64748b; }
.stat-card strong { font-size: 1.75rem; }

.admin-section {
  background: white;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 1.5rem;
}
.section-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td {
  padding: .75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
}
.admin-table th { background: #f8fafc; font-weight: 600; }
.table-thumb { width: 60px; height: 45px; object-fit: cover; border-radius: 4px; }
.status {
  display: inline-block;
  padding: .2rem .5rem;
  border-radius: 4px;
  font-size: .75rem;
  font-weight: 600;
  margin-right: .25rem;
}
.status.published { background: #dcfce7; color: #166534; }
.status.draft { background: #f1f5f9; color: #64748b; }
.status.featured { background: #fef3c7; color: #92400e; }
.actions { display: flex; gap: .5rem; }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}
.login-card {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,.1);
  width: 100%;
  max-width: 400px;
}
.login-card h1 { margin-bottom: 1.5rem; text-align: center; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: .35rem; font-weight: 500; font-size: .9rem; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: .6rem .75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .9rem;
  font-family: inherit;
}
.field-with-add-row {
  display: flex;
  gap: .5rem;
  align-items: stretch;
}
.field-with-add-row select,
.field-with-add-row .select2-container {
  flex: 1;
  min-width: 0;
}
.field-with-add-row .select2-container { width: 100% !important; }
.lookup-add-btn {
  flex-shrink: 0;
  width: 2.5rem;
  padding: 0;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.form-checkboxes { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; }
.form-checkboxes label { display: flex; align-items: center; gap: .35rem; }

.admin-form { max-width: 900px; }
.form-group-full { margin-top: 0.5rem; }
.admin-form-section-title { font-size: 1.1rem; margin: 0 0 0.5rem; }
.section-divider { margin: 2rem 0; border: none; border-top: 1px solid var(--border); }

.spec-input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
  margin-bottom: .5rem;
}

.lookup-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.lookup-modal[hidden] { display: none; }
.lookup-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .45);
}
.lookup-modal-dialog {
  position: relative;
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .15);
}
.lookup-modal-dialog--wide { max-width: 520px; }
.lookup-modal-dialog h2 {
  margin-bottom: 1rem;
  font-size: 1.15rem;
}
.lookup-modal-hint {
  font-size: .85rem;
  color: #64748b;
  margin-bottom: .75rem;
}
.lookup-modal-actions {
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

.lookup-color-row {
  display: flex;
  gap: .75rem;
  align-items: center;
}
.lookup-color-row input[type="color"] {
  width: 3rem;
  height: 2.5rem;
  padding: .15rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  background: white;
}
.lookup-color-row input[type="text"] {
  flex: 1;
  font-family: ui-monospace, monospace;
}

.color-option {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
}
.color-swatch {
  width: 1rem;
  height: 1rem;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, .15);
  flex-shrink: 0;
}

.lookup-logo-upload {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .75rem;
}
.lookup-logo-upload-btn { cursor: pointer; margin: 0; }
.lookup-logo-file-name { font-size: .8rem; color: #64748b; }
.lookup-logo-or {
  font-size: .8rem;
  color: #64748b;
  margin: .5rem 0;
}
.lookup-logo-search {
  width: 100%;
  padding: .5rem .65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: .5rem;
  font-family: inherit;
}
.lookup-logo-library {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: .4rem;
  max-height: 180px;
  overflow-y: auto;
  padding: .25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
}
.lookup-logo-pick {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: .35rem;
  border: 2px solid transparent;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  min-height: 44px;
}
.lookup-logo-pick:hover { border-color: #cbd5e1; }
.lookup-logo-pick.is-selected { border-color: var(--primary); background: #fef2f2; }
.lookup-logo-pick img {
  max-width: 100%;
  max-height: 32px;
  object-fit: contain;
}
.lookup-logo-preview {
  margin-top: .75rem;
  padding: .75rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
  text-align: center;
  background: #fff;
}
.lookup-logo-preview img {
  max-height: 56px;
  max-width: 120px;
  object-fit: contain;
}

.hero-settings-section { margin-bottom: 1.5rem; }
.hero-settings-section h2 { font-size: 1.1rem; margin: 0; }
.hero-settings-hint {
  font-size: .85rem;
  color: #64748b;
  margin: .5rem 0 1rem;
}

.hero-color-input-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 280px;
}

.hero-color-input-row input[type="color"] {
  width: 48px;
  height: 40px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  background: #fff;
}

.hero-color-input-row .hero-color-hex {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, monospace;
}

.hero-preview-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
}
.hero-preview-card { display: flex; flex-direction: column; gap: .5rem; }
.hero-preview-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.hero-preview-label { font-size: .8rem; font-weight: 600; color: #475569; }
.hero-upload-scope-hint { margin: 0 0 1rem; color: #64748b; font-size: .85rem; }
.hero-preview-frame {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #0f0c29;
}
.hero-preview-frame--desktop { aspect-ratio: 21 / 9; }
.hero-preview-frame--mobile { aspect-ratio: 9 / 16; max-width: 200px; }
.hero-preview-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.hero-upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.hero-upload-tip {
  font-size: .75rem;
  color: #64748b;
  margin: .25rem 0 .5rem;
}
.hero-upload-pick { cursor: pointer; margin-bottom: .35rem; }
.hero-upload-name { font-size: .8rem; color: #64748b; display: block; }
.hero-upload-preview {
  margin-top: .5rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: .5rem;
  background: #f8fafc;
  max-height: 120px;
  overflow: hidden;
}
.hero-upload-preview img {
  width: 100%;
  max-height: 100px;
  object-fit: contain;
}

@media (max-width: 768px) {
  .hero-preview-grid,
  .hero-upload-grid {
    grid-template-columns: 1fr;
  }
}

.image-grid-admin {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.image-admin-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.image-admin-card.primary { border-color: var(--primary); border-width: 2px; }
.image-admin-card img { width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.image-admin-actions { padding: .5rem; display: flex; flex-direction: column; gap: .25rem; }
.primary-label { font-size: .75rem; color: var(--primary); font-weight: 600; text-align: center; }
.delete-form { margin-top: 2rem; }
.upload-form { margin-bottom: 1rem; }

.admin-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}
.admin-loading-overlay[hidden] { display: none !important; }
.admin-loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem 2rem;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  min-width: 200px;
}
.admin-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e2e8f0;
  border-top-color: var(--primary, #2563eb);
  border-radius: 50%;
  animation: admin-spin 0.75s linear infinite;
}
.admin-loading-text {
  margin: 0;
  font-size: 0.9rem;
  color: #334155;
  font-weight: 500;
}
@keyframes admin-spin {
  to { transform: rotate(360deg); }
}

.admin-section-lead {
  margin-top: 0.35rem;
  color: #64748b;
  font-size: 0.9rem;
}

.featured-pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.85rem;
}

.featured-pick-card {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.75rem;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.featured-pick-card.is-selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(227, 30, 36, 0.12);
}

.featured-pick-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.featured-pick-card__media {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16 / 10;
  border-radius: 8px;
  overflow: hidden;
  background: #f1f5f9;
}

.featured-pick-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.featured-pick-card__body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.featured-pick-card__body small {
  color: #64748b;
  font-size: 0.8rem;
  line-height: 1.4;
}

.featured-pick-hint {
  margin-top: 0.85rem;
  font-size: 0.88rem;
  color: var(--success);
}

@media (max-width: 768px) {
  body.admin-body { flex-direction: column; }
  .admin-sidebar { width: 100%; }
}
