.admin-body {
  background: #eef1ef;
}

.admin-brand {
  color: inherit;
  text-decoration: none;
}

.admin-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-link {
  min-height: 36px;
  padding: 8px 10px;
  color: var(--green-dark);
  background: transparent;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.header-link:hover {
  background: var(--green-soft);
}

.header-button {
  border: 0;
}

.admin-main {
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: 28px 20px 64px;
}

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

.auth-panel {
  width: min(480px, 100%);
  margin: 36px auto 0;
  padding: 28px;
}

.panel-kicker {
  margin-bottom: 5px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.panel-intro {
  margin-top: 9px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.auth-form {
  display: grid;
  gap: 15px;
  margin-top: 24px;
}

.auth-form .primary-button {
  width: 100%;
}

.admin-workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  align-items: start;
  gap: 18px;
}

.template-sidebar {
  position: sticky;
  top: 78px;
  overflow: hidden;
}

.sidebar-heading,
.editor-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.sidebar-heading h1 {
  font-size: 20px;
}

.editor-heading h2 {
  font-size: 20px;
}

.square-button {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  place-items: center;
  color: #fff;
  background: var(--green);
  border-radius: 6px;
  font-size: 24px;
  line-height: 1;
}

.square-button:hover {
  background: var(--green-dark);
}

.admin-template-list {
  display: grid;
  max-height: calc(100vh - 180px);
  overflow-y: auto;
  padding: 8px;
}

.admin-template-item {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 66px;
  padding: 8px;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  text-align: left;
}

.admin-template-item:hover {
  background: #f6f8f7;
}

.admin-template-item.is-active {
  border-color: #9eb9ac;
  background: var(--green-soft);
}

.admin-template-thumb {
  display: block;
  width: 50px;
  height: 50px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: #f1f2f1;
}

.admin-template-copy {
  min-width: 0;
}

.admin-template-copy strong,
.admin-template-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-template-copy strong {
  font-size: 13px;
}

.admin-template-copy small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.template-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #a8afab;
}

.template-status.is-enabled {
  background: var(--green);
}

.editor-panel {
  min-width: 0;
  overflow: hidden;
}

.save-state {
  min-width: 80px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.form-section {
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

.form-section h3 {
  margin: 0 0 15px;
  font-size: 15px;
}

.field-grid {
  display: grid;
  gap: 14px;
}

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

label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: #414a45;
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cbd2ce;
  border-radius: 5px;
  outline: 0;
}

input:focus,
select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(23, 107, 77, 0.1);
}

input[type="file"] {
  padding: 7px;
  font-size: 12px;
}

input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  accent-color: var(--green);
}

.toggle-field {
  display: flex;
  align-items: center;
  align-self: end;
  flex-direction: row;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #f8faf9;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(260px, 0.8fr);
  align-items: start;
  gap: 24px;
}

.canvas-column {
  min-width: 0;
}

.template-canvas {
  position: relative;
  width: 100%;
  max-height: 560px;
  overflow: hidden;
  border: 1px solid #bfc8c3;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #edf0ee 25%, transparent 25%),
    linear-gradient(-45deg, #edf0ee 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #edf0ee 75%),
    linear-gradient(-45deg, transparent 75%, #edf0ee 75%);
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
  touch-action: none;
  user-select: none;
}

.canvas-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.canvas-overlay {
  z-index: 3;
}

.product-box {
  position: absolute;
  z-index: 2;
  display: grid;
  min-width: 18px;
  min-height: 18px;
  place-items: center;
  border: 2px solid var(--amber);
  background: rgba(185, 121, 25, 0.22);
  cursor: move;
}

.product-box span {
  padding: 4px 6px;
  color: #70470b;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 3px;
  font-size: 11px;
  font-weight: 800;
  pointer-events: none;
}

.resize-handle {
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: 16px;
  height: 16px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--amber);
  cursor: nwse-resize;
}

.canvas-help {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.canvas-controls {
  display: grid;
  gap: 15px;
}

.compact-grid {
  gap: 10px;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.asset-field {
  align-content: start;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafbfa;
}

.asset-current {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.remove-asset {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 2px;
  color: var(--danger);
  font-size: 11px;
  font-weight: 400;
}

.editor-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 18px 24px;
}

.danger-button {
  min-height: 44px;
  margin-right: auto;
  padding: 8px 16px;
  color: var(--danger);
  background: #f9ecea;
  border-radius: 6px;
  font-weight: 700;
}

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

.empty-list {
  padding: 24px 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

.admin-dialog {
  width: min(440px, calc(100vw - 28px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: 0 20px 60px rgba(20, 32, 26, 0.24);
}

.admin-dialog::backdrop {
  background: rgba(17, 25, 21, 0.5);
}

.admin-dialog .auth-form {
  margin: 0;
  padding: 22px;
}

.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-heading h2 {
  font-size: 18px;
}

.dialog-close {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border-radius: 5px;
  font-size: 24px;
}

.dialog-close:hover {
  color: var(--ink);
  background: #f0f2f1;
}

@media (max-width: 980px) {
  .admin-workspace {
    grid-template-columns: 1fr;
  }

  .template-sidebar {
    position: static;
  }

  .admin-template-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: none;
  }

  .editor-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .admin-main {
    padding: 14px 10px 40px;
  }

  .admin-header-actions .header-link:first-child {
    display: none;
  }

  .auth-panel {
    margin-top: 12px;
    padding: 20px;
  }

  .admin-template-list,
  .field-grid-2,
  .asset-grid {
    grid-template-columns: 1fr;
  }

  .form-section {
    padding: 18px 14px;
  }

  .editor-actions {
    align-items: stretch;
    flex-direction: column-reverse;
    padding: 14px;
  }

  .editor-actions .primary-button,
  .danger-button {
    width: 100%;
    margin: 0;
  }
}
