:root {
  --bg: #f6f4f1;
  --panel: #ffffff;
  --ink: #22201d;
  --muted: #706a63;
  --line: #ded8d0;
  --accent: #8b3f35;
  --accent-dark: #5f2923;
  --green: #2f7a4f;
  --pink: #ffe0ea;
  --pink-strong: #f5a9c1;
  --warning: #b26700;
  --shadow: 0 16px 40px rgba(42, 35, 27, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.locked .topbar,
body.locked .app-shell {
  display: none;
}

.login-screen {
  min-height: 100vh;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

body.locked .login-screen {
  display: flex;
}

.login-box {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.login-box h1 {
  margin: 0;
}

.login-error {
  margin: 0;
  color: #9c2d2d;
  font-weight: 800;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.file-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
  cursor: pointer;
}

button:hover,
.file-button:hover {
  border-color: var(--accent);
}

.danger {
  border-color: #d9a5a5;
  background: #fff4f4;
  color: #9c2d2d;
}

.danger:hover {
  border-color: #b42323;
}

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

.primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.ghost {
  background: transparent;
}

.file-button {
  display: inline-flex;
  align-items: center;
  position: relative;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.topbar {
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1,
.workspace h2,
.editor h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 24px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.app-shell {
  min-height: calc(100vh - 85px);
  display: grid;
  grid-template-columns: 280px minmax(520px, 1fr) 360px;
  gap: 18px;
  padding: 18px;
}

.filters,
.workspace,
.editor {
  min-width: 0;
}

.filters,
.editor {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
  align-self: start;
  position: sticky;
  top: 104px;
}

.filters {
  display: grid;
  gap: 16px;
}

.status-card {
  padding: 10px 12px;
  border-radius: 6px;
  background: #f1ebe4;
  color: var(--muted);
  font-size: 13px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 63, 53, 0.13);
}

.check-row {
  grid-template-columns: 18px 1fr;
  align-items: center;
  color: var(--ink);
  font-weight: 600;
}

.check-row input {
  width: 18px;
  height: 18px;
}

.stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.stats div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.stats strong {
  font-size: 24px;
}

.stats span {
  color: var(--muted);
  font-size: 12px;
}

.workspace {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.table-toolbar p {
  margin: 4px 0 0;
  color: var(--muted);
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 178px);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #faf8f5;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: #f7eee8;
}

tbody tr.inactive {
  background: var(--pink);
}

tbody tr.inactive.selected,
tbody tr.inactive:hover {
  background: #ffd2df;
}

.product-name {
  display: grid;
  gap: 3px;
}

.product-name strong {
  font-size: 15px;
}

.product-name span,
.mini {
  color: var(--muted);
  font-size: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-width: 84px;
  border-radius: 999px;
  padding: 4px 8px;
  color: #fff;
  background: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.pill.off {
  background: var(--pink-strong);
  color: #5f1f31;
}

.issue {
  color: var(--warning);
  font-size: 12px;
  font-weight: 800;
}

.table-thumb {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #efe8df;
  object-fit: cover;
  display: block;
}

.table-thumb.missing {
  display: grid;
  place-items: center;
  color: var(--warning);
  font-size: 11px;
  font-weight: 800;
}

.editor-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.switch {
  display: block;
  width: 48px;
  height: 28px;
  position: relative;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--pink-strong);
  transition: 0.18s ease;
}

.switch span::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  top: 3px;
  left: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
  transition: 0.18s ease;
}

.switch input:checked + span {
  background: var(--green);
}

.switch input:checked + span::after {
  transform: translateX(20px);
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

.product-form {
  display: grid;
  gap: 12px;
}

.image-preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.image-preview-grid span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.small-preview {
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #efe8df;
  background-position: center;
  background-size: cover;
}

.small-preview.no-image {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.preview-card {
  margin-top: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.preview-media {
  height: 150px;
  background: #efe8df;
  background-position: center;
  background-size: cover;
}

.preview-media.no-image {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

.preview-body {
  padding: 14px;
}

.preview-body span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.preview-body h3 {
  margin: 4px 0 4px;
}

.preview-body p {
  margin: 0 0 10px;
  color: var(--muted);
}

.preview-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 260px minmax(420px, 1fr);
  }

  .editor {
    grid-column: 1 / -1;
    position: static;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    justify-content: stretch;
  }

  .top-actions > * {
    flex: 1 1 140px;
    justify-content: center;
  }

  .app-shell {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .filters {
    position: static;
  }

  .table-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-actions {
    justify-content: stretch;
  }

  .toolbar-actions button {
    flex: 1;
  }
}
