:root {
  --bg: #f4f1ea;
  --panel: #fffdf8;
  --ink: #1e2629;
  --muted: #66706d;
  --line: #d8d1c5;
  --accent: #0f6b78;
  --accent-dark: #0b4d57;
  --danger: #9f2d20;
  --shadow: 0 18px 45px rgba(30, 38, 41, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

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

.app-header {
  align-items: center;
  background: #172023;
  color: white;
  display: flex;
  justify-content: space-between;
  min-height: 96px;
  padding: 22px 32px;
}

.app-header h1,
.section-head h2,
.panel-head h3 {
  letter-spacing: 0;
  margin: 0;
}

.eyebrow {
  color: #87c9cf;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

.role-badge {
  align-items: center;
  display: flex;
  background: #334346;
  border: 1px solid #526365;
  border-radius: 6px;
  color: white;
  font-weight: 700;
  min-height: 40px;
  padding: 9px 12px;
}

.toolbar input,
.toolbar select,
label input,
label select,
label textarea {
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  min-height: 40px;
  padding: 9px 10px;
  width: 100%;
}

.app-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: calc(100vh - 96px);
}

.sidebar {
  background: #243033;
  padding: 18px;
}

.nav-button {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: #dbe5e4;
  cursor: pointer;
  display: block;
  margin-bottom: 8px;
  min-height: 42px;
  padding: 10px 12px;
  text-align: left;
  width: 100%;
}

.nav-button.active,
.nav-button:hover {
  background: #334346;
  color: white;
}

.content {
  padding: 28px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.catalog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.section-head p {
  color: var(--muted);
  margin: 6px 0 0;
}

.primary-button,
.secondary-button,
.danger-button {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  min-height: 40px;
  padding: 10px 14px;
}

.primary-button {
  background: var(--accent);
  color: white;
}

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

.secondary-button {
  background: #e6ded0;
  color: var(--ink);
}

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

.stats-grid,
.role-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.stat-card,
.role-grid article,
.export-panel,
.editor-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 18px;
}

.stat-card strong {
  display: block;
  font-size: 30px;
  line-height: 1;
  margin-bottom: 8px;
}

.stat-card span,
.role-grid p {
  color: var(--muted);
}

.toolbar {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(220px, 1fr) 220px 220px;
  margin-bottom: 16px;
}

.catalog-layout {
  align-items: start;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 60fr) minmax(360px, 40fr);
  height: calc(100vh - 260px);
  min-height: 520px;
}

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  height: 100%;
  overflow: auto;
}

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

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

th {
  background: #eee7db;
  font-size: 12px;
  position: sticky;
  top: 0;
  text-transform: uppercase;
  z-index: 1;
}

tbody tr {
  cursor: pointer;
}

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

tbody tr.not-selected-for-production {
  background: #f1f1ee;
  color: #858b89;
}

tbody tr.not-selected-for-production td {
  opacity: 0.55;
}

tbody tr.not-selected-for-production:hover,
tbody tr.not-selected-for-production.selected {
  background: #e8eeee;
}

tbody tr.selected-for-production {
  box-shadow: inset 4px 0 0 var(--accent);
}

.editor-panel {
  height: 100%;
  overflow: auto;
  padding: 18px;
  position: sticky;
  top: 18px;
}

.panel-head {
  align-items: flex-start;
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
}

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

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

.full {
  grid-column: 1 / -1;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 16px 0 0;
  padding: 14px;
}

legend {
  color: var(--ink);
  font-weight: 700;
  padding: 0 6px;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

.preview-box {
  align-items: flex-start;
  background: transparent;
  border: 0;
  border-radius: 0;
  display: flex;
  justify-content: flex-start;
  margin: 8px 0 14px;
  min-height: 180px;
  overflow: hidden;
  padding: 10px 0 0 10px;
}

.preview-box img {
  display: none;
  max-height: 299px;
  max-width: 100%;
  object-fit: contain;
}

#previewEmpty {
  color: var(--muted);
}

.form-actions,
.export-panel {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.table-image-cell {
  align-items: start;
  display: grid;
  gap: 7px;
  justify-items: start;
  min-width: 96px;
}

.production-choice {
  align-items: center;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  font-size: 12px;
  font-weight: 700;
  gap: 6px;
  min-height: 20px;
}

.production-choice input {
  height: 16px;
  min-height: 0;
  padding: 0;
  width: 16px;
}

.image-column-cell {
  padding: 10px 0 0 10px;
  vertical-align: top;
}

.table-image-cell img,
.table-image-empty {
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  height: 83px !important;
  object-fit: cover;
  width: 76px !important;
}

.table-image-cell strong {
  font-size: 12px;
}

.readonly-field {
  background: #ece7df !important;
  color: #59615f !important;
}

.text-editor-block {
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 14px;
}

.text-editor-block:first-of-type {
  border-top: 0;
  margin-top: 0;
  padding-top: 0;
}

.text-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  margin-top: 8px;
}

.text-status-field {
  max-width: 20%;
  min-width: 150px;
  margin-bottom: 10px;
}

.export-panel,
.role-grid article {
  padding: 18px;
}

.audit-layout {
  display: grid;
  gap: 18px;
}

.audit-panel h3 {
  margin: 0 0 10px;
}

.audit-panel table {
  min-width: 980px;
}

.is-hidden {
  display: none !important;
}

@media (max-width: 1050px) {
  .app-shell,
  .catalog-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: flex;
    gap: 8px;
    overflow: auto;
  }

  .nav-button {
    margin: 0;
    min-width: 150px;
  }

  .editor-panel {
    height: auto;
    overflow: visible;
    position: static;
  }

  .catalog-layout {
    height: auto;
    min-height: 0;
  }

  .table-wrap {
    max-height: 560px;
  }
}

@media (max-width: 720px) {
  .app-header,
  .section-head {
    display: block;
  }

  .role-badge {
    margin-top: 16px;
  }

  .content {
    padding: 18px;
  }

  .toolbar,
  .form-grid {
    grid-template-columns: 1fr;
  }
}
