:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-2: #243044;
  --border: #2f3f56;
  --text: #e8edf4;
  --muted: #8fa3bc;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.subtitle {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.header-stats {
  color: var(--muted);
  font-size: 0.875rem;
  text-align: right;
}

.mode-tabs {
  display: flex;
  gap: 0.35rem;
}

.mode-tab {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 8px;
  padding: 0.45rem 0.85rem;
  font: inherit;
  cursor: pointer;
}

.mode-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.hidden {
  display: none !important;
}

.aside-label {
  margin: 0.75rem 0.75rem 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

#batch-list {
  list-style: none;
  margin: 0;
  padding: 0 0.5rem 1rem;
  overflow-y: auto;
  flex: 1;
}

#batch-list li button {
  width: 100%;
  text-align: left;
  padding: 0.6rem 0.65rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.15rem 0.5rem;
  align-items: center;
}

#batch-list li button:hover {
  background: var(--surface-2);
}

#batch-list li button.active {
  background: var(--accent);
  color: #fff;
}

.batch-label {
  font-weight: 600;
}

.batch-range {
  font-size: 0.8rem;
  color: var(--muted);
  grid-column: 1;
}

#batch-list li button.active .batch-range {
  color: rgba(255, 255, 255, 0.75);
}

.batch-progress {
  grid-column: 2;
  grid-row: 1 / span 2;
  font-size: 0.8rem;
  color: var(--warning);
  font-weight: 600;
}

.batch-progress.done {
  color: var(--success);
}

#batch-list li button.active .batch-progress {
  color: #fff;
}

.layout-bulk aside {
  border-right: 1px solid var(--border);
}

.bulk-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.batch-product-grid {
  list-style: none;
  margin: 0 0 1.25rem;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.5rem;
}

.batch-product-grid li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.85rem;
}

.batch-product-grid li.published {
  border-color: rgba(34, 197, 94, 0.4);
}

.batch-product-grid li.pending {
  border-color: rgba(245, 158, 11, 0.35);
}

.batch-product-status {
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

.batch-product-grid li.published .batch-product-status {
  color: var(--success);
}

.bulk-prompt-panel textarea {
  min-height: 360px;
}

.bulk-paste-panel textarea {
  min-height: 320px;
  font-size: 0.9rem;
}

.bulk-all-done {
  background: var(--surface);
  border: 1px solid var(--success);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.bulk-results {
  background: var(--surface);
  border: 1px solid var(--success);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-top: 1rem;
}

.bulk-results h3 {
  margin: 0 0 0.5rem;
  color: var(--success);
  font-size: 1rem;
}

.bulk-results ul {
  margin: 0;
  padding-left: 1.25rem;
}

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: calc(100vh - 72px);
}

aside {
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#search {
  margin: 0.75rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

#search:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

#product-list {
  list-style: none;
  margin: 0;
  padding: 0 0.5rem 1rem;
  overflow-y: auto;
  flex: 1;
}

#product-list li button {
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.65rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

#product-list li button:hover {
  background: var(--surface-2);
}

#product-list li button.active {
  background: var(--accent);
  color: #fff;
}

.product-num {
  color: var(--muted);
  font-size: 0.8rem;
}

#product-list li button.active .product-num {
  color: rgba(255, 255, 255, 0.75);
}

.badges {
  display: flex;
  gap: 0.25rem;
}

.badge {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
}

.badge.ok {
  background: var(--success);
}

main {
  overflow-y: auto;
  padding: 1.25rem 1.5rem 2rem;
}

.empty-state {
  color: var(--muted);
  padding: 3rem 1rem;
  text-align: center;
}

.product-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.product-header h2 {
  margin: 0;
  font-size: 1.4rem;
}

.nav-buttons {
  display: flex;
  gap: 0.5rem;
}

button.primary,
button.secondary,
button.success {
  border: none;
  border-radius: 8px;
  padding: 0.55rem 0.9rem;
  font: inherit;
  cursor: pointer;
  font-weight: 500;
}

button.primary {
  background: var(--accent);
  color: #fff;
}

button.primary:hover {
  background: var(--accent-hover);
}

button.secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

button.secondary:hover {
  background: var(--border);
}

button.secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button.success {
  background: var(--success);
  color: #fff;
}

button.success:hover {
  filter: brightness(0.95);
}

.photos {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.photos img {
  width: 100px;
  height: 100px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.section {
  margin-bottom: 1.25rem;
}

.section h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.file-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.875rem;
  line-height: 1.5;
  max-height: 220px;
  overflow-y: auto;
}

.file-block.missing {
  color: var(--muted);
  font-style: italic;
}

.publish-panel {
  background: linear-gradient(135deg, #1e3a5f 0%, var(--surface) 100%);
  border: 2px solid var(--success);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.publish-panel.empty {
  border-color: var(--border);
  background: var(--surface);
}

.publish-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.publish-panel h3 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--success);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.publish-panel.empty h3 {
  color: var(--muted);
}

.publish-copy-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.publish-display {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.publish-title {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.3;
  color: #fff;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.publish-title.missing {
  font-size: 1rem;
  font-weight: 500;
  color: var(--warning);
}

.publish-description {
  font-size: 1.2rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  min-height: 120px;
}

.publish-description.missing {
  font-size: 1rem;
  color: var(--warning);
}

.publish-empty {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

.prompt-panel {
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.25rem;
}

.prompt-panel textarea {
  width: 100%;
  min-height: 280px;
  margin-top: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  line-height: 1.45;
  resize: vertical;
}

.prompt-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.paste-panel textarea {
  width: 100%;
  min-height: 200px;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  line-height: 1.5;
  resize: vertical;
}

.paste-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
  align-items: center;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--success);
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.contact-note {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

.layout-marketplace {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: calc(100vh - 72px);
}

#mp-product-list {
  list-style: none;
  margin: 0;
  padding: 0 0.5rem 1rem;
  overflow-y: auto;
}

#mp-product-list li button {
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.65rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  display: grid;
  gap: 0.15rem;
}

#mp-product-list li button:hover {
  background: var(--surface-2);
}

#mp-product-list li button.active {
  background: var(--accent);
  color: #fff;
}

.mp-meta {
  font-size: 0.75rem;
  color: var(--muted);
}

#mp-product-list li button.active .mp-meta {
  color: rgba(255, 255, 255, 0.75);
}

.mp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0;
}

.mp-open-fb {
  display: inline-block;
  text-decoration: none;
  text-align: center;
}

.mp-setup {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.setup-steps {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.setup-steps a {
  color: var(--accent);
}

.mp-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.mp-field label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.warn-text {
  color: var(--warning) !important;
}

@media (max-width: 800px) {
  .layout {
    grid-template-columns: 1fr;
  }

  aside {
    max-height: 240px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}
