:root {
  color-scheme: dark;
  --bg: #050607;
  --surface: #111217;
  --surface-alt: #16181e;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --accent: #22c55e;
  --danger: #f87171;
  --border: rgba(255, 255, 255, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: radial-gradient(circle at top, rgba(34, 197, 94, 0.08), transparent 55%), var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

/* Floating Customize Theme button (login page) */
#themeButton.floating-theme-button {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 28px -12px rgba(0,0,0,0.5);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  z-index: 1100;
}

#themeButton.floating-theme-button::before {
  content: '⚙';
  font-size: 22px;
}

button {
  border: none;
  border-radius: 999px;
  padding: 0.65rem 1.4rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

button:hover:not(:disabled) {
  opacity: 0.9;
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

button.danger {
  background: var(--danger);
  color: #fff;
}

.admin-shell {
  width: min(1100px, 100%);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}

.auth-panel,
.dashboard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1.5rem;
  padding: 2rem;
  box-shadow: 0 30px 70px -40px rgba(0, 0, 0, 0.7);
}

.auth-panel h1 {
  margin: 0;
  font-size: 2rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.75rem;
  width: fit-content;
  padding: 0.4rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  transition: border 0.2s ease, color 0.2s ease;
}

.back-link:hover {
  color: var(--accent);
  border-color: rgba(34, 197, 94, 0.6);
}

.auth-panel form,
#productForm {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.5rem;
}

label span {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--muted);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"] {
  width: 100%;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  padding: 0.8rem 1rem;
}

.auth-panel button,
#productForm button,
.dashboard-actions button {
  background: var(--accent);
  color: #00110a;
  font-weight: 700;
}

.dashboard {
  grid-column: span 2;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 0.75rem;
  margin: 0 0 0.3rem;
  color: var(--muted);
}

.status-pill {
  background: rgba(34, 197, 94, 0.2);
  color: var(--accent);
  padding: 0.3rem 0.9rem;
  border-radius: 999px;
  font-size: 0.85rem;
}

.card {
  background: var(--surface-alt);
  border-radius: 1.25rem;
  padding: 1.5rem;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.limited-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toggle input {
  width: auto;
}

.limited-qty {
  flex: 1;
}

.product-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.product-row {
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.02);
}

.product-summary h4 {
  margin: 0 0 0.2rem;
}

.product-summary p {
  margin: 0.1rem 0;
  color: var(--muted);
}

.product-limited {
  color: var(--accent);
  font-weight: 600;
}

.row-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.error-text {
  color: var(--danger);
  min-height: 1.25rem;
}

.muted {
  color: var(--muted);
}

/* Theme controls (login page uses injected markup) */
.theme-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 7, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1200;
  padding: 1.5rem;
  backdrop-filter: blur(6px);
}

.theme-overlay.visible {
  display: flex;
}

.theme-panel {
  width: min(420px, 100%);
  background: var(--surface);
  border-radius: 1.75rem;
  border: 1px solid var(--border);
  padding: 1.75rem;
  box-shadow: 0 30px 60px -28px rgba(0, 0, 0, 0.85);
  transform: scale(0.6) rotate(-120deg);
  opacity: 0;
}

.theme-panel.open {
  animation: spinIn 0.65s ease forwards;
}

@keyframes spinIn {
  0% {
    transform: scale(0.55) rotate(-160deg);
    opacity: 0;
  }
  55% {
    transform: scale(1.05) rotate(12deg);
    opacity: 1;
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

.theme-panel h3 {
  margin: 0 0 1rem;
  font-size: 1.3rem;
}

.theme-section {
  margin-bottom: 1.5rem;
}

.theme-section:last-of-type {
  margin-bottom: 0;
}

.theme-section label {
  font-weight: 600;
  display: block;
  margin-bottom: 0.5rem;
}

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(48px, 1fr));
  gap: 0.6rem;
}

.accent-swatch {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.2s ease, border 0.2s ease;
}

.accent-swatch.selected {
  border-color: var(--text);
  transform: translateY(-2px);
}

.color-picker {
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.45rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
}

.mode-toggle {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.mode-toggle button {
  flex: 1;
}

.close-panel {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-weight: 600;
  box-shadow: none;
}

@media (max-width: 768px) {
  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .product-row {
    flex-direction: column;
  }

  .row-actions {
    justify-content: flex-start;
  }
}
