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

:root {
  --bg: #0f1115;
  --surface: #181b22;
  --border: #2a2f3a;
  --text: #e8eaed;
  --muted: #9aa3b2;
  --accent: #5b8def;
  --accent-hover: #7aa2f7;
  --danger: #f87171;
  --success: #4ade80;
  --header-h: 64px;
}

body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.5rem;
  background: rgba(15, 17, 21, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.brand {
  font-weight: 700;
  color: var(--text);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-chip {
  color: var(--muted);
  font-size: 0.875rem;
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem;
}

h1 {
  font-size: 1.5rem;
  margin-bottom: 0.35rem;
}

h2 {
  font-size: 1.125rem;
  margin-bottom: 0.75rem;
}

.lead {
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

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

.card a.card-link {
  display: block;
  color: inherit;
}

.card a.card-link:hover {
  border-color: var(--accent);
}

.muted {
  color: var(--muted);
  font-size: 0.875rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--muted);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.4);
}

.form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field label {
  font-size: 0.8rem;
  color: var(--muted);
}

.field input,
.field select,
.field textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  width: 100%;
}

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

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.hours-grid {
  display: grid;
  gap: 0.85rem;
}

.hours-day {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem;
  background: var(--surface);
}

.hours-day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.hours-closed {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.hours-times {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.hours-times label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.hours-apply {
  margin-top: 0.75rem;
}

.hours-apply summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 0.9rem;
}

.hours-apply-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.85rem;
  margin: 0.65rem 0;
  font-size: 0.875rem;
}

.field-hint {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.field-error {
  margin: 0.35rem 0 0;
  color: #f85149;
  font-size: 0.85rem;
  min-height: 1.1em;
}

.accordion-title {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  min-width: 0;
}

.section-status {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

.section-status.success {
  color: #3fb950;
}

.section-status.error {
  color: #f85149;
}

.product-images-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.65rem;
  align-items: stretch;
  overflow-x: auto;
  padding: 0.25rem 0;
}

.product-image-chip {
  position: relative;
  flex: 0 0 auto;
  width: 112px;
  cursor: grab;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  padding: 0.35rem;
  user-select: none;
}

.product-image-chip:active {
  cursor: grabbing;
}

.product-image-chip.dragging {
  opacity: 0.55;
}

.product-image-chip.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.product-image-chip .preview-img {
  width: 100%;
  height: 88px;
  margin: 0;
  pointer-events: none;
}

.product-image-badge {
  position: absolute;
  left: 0.45rem;
  top: 0.45rem;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 0.7rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.product-image-remove {
  position: absolute;
  right: 0.35rem;
  top: 0.35rem;
  width: 1.35rem;
  height: 1.35rem;
  border: none;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  cursor: pointer;
  font: inherit;
  line-height: 1;
}

.product-images,
.product-image-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.product-image-row {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.status {
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.status.error {
  color: var(--danger);
}

.status.success {
  color: var(--success);
}

.login-wrap {
  min-height: calc(100vh - var(--header-h));
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 420px;
}

.item-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  background: var(--bg);
}

.preview-img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #111;
  display: block;
  margin-bottom: 0.5rem;
}

.preview-img.wide {
  width: 100%;
  max-width: 280px;
  height: auto;
  aspect-ratio: 4 / 3;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table th,
.table td {
  text-align: left;
  padding: 0.6rem 0.4rem;
  border-bottom: 1px solid var(--border);
}

.table th {
  color: var(--muted);
  font-weight: 600;
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}

.badge.admin {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.4);
}

.badge.deluxe {
  color: #a78bfa;
  border-color: rgba(167, 139, 250, 0.4);
}

.badge.basic {
  color: #67e8f9;
  border-color: rgba(103, 232, 249, 0.4);
}

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

.accordion-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.accordion-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: transparent;
  border: none;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.accordion-trigger:hover {
  background: rgba(255, 255, 255, 0.03);
}

.accordion-trigger .chevron {
  color: var(--muted);
  transition: transform 0.2s ease;
}

.accordion-item.open .accordion-trigger .chevron {
  transform: rotate(180deg);
}

.accordion-panel {
  display: none;
  padding: 0 1.25rem 1.25rem;
  border-top: 1px solid var(--border);
}

.accordion-item.open .accordion-panel {
  display: block;
  padding-top: 1rem;
}

.section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.top-actions .btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.panel[hidden] {
  display: none;
}

.ms {
  position: relative;
  min-width: 12rem;
}

.ms-control {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  padding: 0.35rem 0.5rem;
  cursor: text;
}

.ms-add-mode .ms-control {
  cursor: default;
  border: none;
  background: transparent;
  padding: 0;
  min-height: 0;
}

.ms-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.ms-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(91, 141, 239, 0.15);
  border: 1px solid rgba(91, 141, 239, 0.35);
  color: var(--text);
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  font-size: 0.8rem;
}

.ms-chip button {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  line-height: 1;
  padding: 0;
}

.ms-add-btn {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}

.ms-add-btn:hover,
.ms.open .ms-add-btn {
  border-color: var(--accent);
  color: var(--accent);
}

.ms-input {
  flex: 1;
  min-width: 8rem;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  padding: 0.25rem;
}

.ms-dropdown {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 260px;
  overflow: hidden;
  display: none;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  min-width: 16rem;
}

.ms.open .ms-dropdown {
  display: flex;
}

.ms-dropdown-search-wrap {
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  padding: 0.4rem 0.5rem;
  background: var(--surface);
}

.ms-dropdown-search {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  padding: 0.4rem 0.55rem;
}

.ms-dropdown-list {
  overflow: auto;
  max-height: 200px;
}

.ms-option {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
}

.ms-option:hover,
.ms-option.active {
  background: rgba(91, 141, 239, 0.12);
}

.ms-option[disabled] {
  opacity: 0.45;
  cursor: default;
}

.ms-empty {
  padding: 0.75rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.template-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.template-card {
  display: grid;
  gap: 0.65rem;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  padding: 0.65rem;
  font: inherit;
}

.template-card:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
}

.template-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.template-card-select {
  display: grid;
  gap: 0.65rem;
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.template-card-preview {
  display: block;
  height: 72px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.template-card-preview.theme-forge {
  background:
    linear-gradient(135deg, #1a1714 0%, #2a2218 45%, #141210 100%),
    radial-gradient(circle at 20% 20%, rgba(232,165,75,0.35), transparent 40%);
}

.template-card-preview.theme-grove {
  background:
    linear-gradient(160deg, #d7e8dc 0%, #eef5ef 50%, #e8f0e9 100%),
    radial-gradient(ellipse at 10% 0%, rgba(47,107,79,0.25), transparent 45%);
}

.template-card-preview.theme-coast {
  background:
    linear-gradient(120deg, #d9e8f8 0%, #f3f7fb 55%, #e7f1fa 100%),
    radial-gradient(circle at 85% 15%, rgba(31,111,235,0.28), transparent 42%);
}

.template-card-body {
  display: grid;
  gap: 0.25rem;
}

.template-card-body strong {
  font-size: 0.95rem;
}

.template-card-body .muted {
  font-size: 0.8rem;
  line-height: 1.35;
}

.template-preview-btn {
  width: 100%;
}

body.modal-open {
  overflow: hidden;
}

.layout-preview-modal[hidden] {
  display: none !important;
}

.layout-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.layout-preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 10, 14, 0.72);
}

.layout-preview-dialog {
  position: relative;
  z-index: 1;
  width: min(1100px, 100%);
  height: min(860px, calc(100vh - 2rem));
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.4);
}

.layout-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}

.layout-preview-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

@media (max-width: 900px) {
  .template-picker {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .site-header {
    padding: 0 1rem;
  }

  main {
    padding: 1rem;
  }
}
