:root {
  --bg: #f5f2eb;
  --panel: #fffdf8;
  --panel-strong: #ffffff;
  --ink: #17231d;
  --muted: #738079;
  --green: #143d34;
  --green-soft: #e8f0eb;
  --gold: #c9964b;
  --gold-soft: #f4eadb;
  --line: #e5ded3;
  --danger: #a43e38;
  --shadow: 0 18px 48px rgba(31, 45, 38, 0.09);
}

* {
  box-sizing: border-box;
}

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

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

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

.top-actions,
.action-row,
.inline-actions,
.row-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: 30px;
}

h2 {
  margin-bottom: 14px;
  font-size: 24px;
}

h3 {
  margin-bottom: 12px;
  font-size: 18px;
}

h4 {
  margin-bottom: 8px;
  font-size: 15px;
}

.top-subtitle,
.hint,
.muted,
.status,
#sectionSubtitle {
  color: var(--muted);
  line-height: 1.6;
}

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

.login-panel {
  max-width: 430px;
  padding: 26px;
}

label {
  display: block;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  margin-top: 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  outline-color: var(--green);
}

textarea {
  min-height: 108px;
  resize: vertical;
  line-height: 1.55;
}

.json-editor {
  min-height: 560px;
  font-family: Consolas, Monaco, monospace;
  font-size: 13px;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 0;
  border-radius: 7px;
  padding: 0 14px;
  background: var(--green);
  color: #fff;
  cursor: pointer;
  font-weight: 850;
  text-decoration: none;
}

button:hover,
.button:hover {
  filter: brightness(1.04);
}

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

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

.small {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.hidden {
  display: none !important;
}

.admin-grid {
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
  gap: 18px;
}

.side {
  position: sticky;
  top: 18px;
  align-self: start;
  padding: 10px;
}

.tab {
  width: 100%;
  justify-content: flex-start;
  margin: 4px 0;
  background: transparent;
  color: var(--ink);
}

.tab.active {
  background: var(--green);
  color: #fff;
}

.workspace {
  min-height: 760px;
  overflow: hidden;
}

.sticky-actions {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.96);
  padding: 18px 20px;
  backdrop-filter: blur(10px);
}

#sectionTitle {
  display: block;
  font-size: 18px;
}

#sectionSubtitle {
  margin: 4px 0 0;
  font-size: 13px;
}

.status {
  min-height: 24px;
  padding: 12px 20px 0;
  font-size: 13px;
}

#view {
  padding: 18px 20px 28px;
}

.dirty-badge,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--gold-soft);
  color: #8a5d20;
  font-size: 12px;
  font-weight: 850;
}

.cards,
.stat-grid,
.asset-grid {
  display: grid;
  gap: 14px;
}

.stat-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-card,
.card,
.form-section,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.stat-card {
  padding: 18px;
}

.stat-number {
  margin-bottom: 4px;
  font-size: 30px;
  font-weight: 900;
  color: var(--green);
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.quick-card {
  align-items: flex-start;
  justify-content: flex-start;
  min-height: 110px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.editor-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
}

.item-list {
  align-self: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 12px;
}

.item-card {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  min-height: 74px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.item-card:last-child {
  border-bottom: 0;
}

.item-card.active {
  background: var(--green-soft);
}

.item-thumb,
.image-preview {
  width: 56px;
  height: 56px;
  border: 1px solid var(--line);
  border-radius: 6px;
  object-fit: cover;
  background: #f4f1eb;
}

.item-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 900;
}

.item-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.form-section {
  margin-bottom: 16px;
  padding: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}

.form-grid .wide,
.wide {
  grid-column: 1 / -1;
}

.repeat-list {
  display: grid;
  gap: 10px;
}

.repeat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfaf6;
}

.repeat-row.three {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) auto;
}

.repeat-row.single {
  grid-template-columns: minmax(0, 1fr) auto;
}

.repeat-row.image {
  grid-template-columns: 86px minmax(0, 1fr) auto;
  align-items: center;
}

.image-picker {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfaf6;
}

.image-picker .image-preview {
  width: 88px;
  height: 68px;
}

.asset-grid {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

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

.asset-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #f4f1eb;
}

.asset-body {
  padding: 10px;
}

.asset-url {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 980px) {
  .admin-grid,
  .editor-layout,
  .form-grid,
  .stat-grid,
  .quick-grid {
    grid-template-columns: 1fr;
  }

  .side {
    position: static;
  }

  .sticky-actions,
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }
}
