:root {
  --cms-ink: #142018;
  --cms-paper: #fffdf7;
  --cms-green: #b9e7a8;
  --cms-gold: #f4c765;
  --cms-danger: #ff8e7d;
}

.cms-toolbar,
.cms-panel,
.cms-toast,
.cms-card-controls,
.cms-menu-editor {
  font-family: Manrope, system-ui, sans-serif;
}

.cms-toolbar {
  position: fixed;
  z-index: 100000;
  right: 18px;
  bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px;
  border: 1px solid rgb(255 255 255 / 16%);
  border-radius: 18px;
  color: var(--cms-paper);
  background: rgb(20 32 24 / 94%);
  box-shadow: 0 22px 70px rgb(13 20 15 / 28%);
  backdrop-filter: blur(18px);
}

.cms-toolbar strong {
  padding: 0 8px;
  font-size: 12px;
  white-space: nowrap;
}

.cms-toolbar button,
.cms-panel button,
.cms-card-controls button,
.cms-menu-editor button {
  min-height: 38px;
  padding: 8px 12px;
  border: 0;
  border-radius: 11px;
  color: var(--cms-paper);
  background: rgb(255 255 255 / 10%);
  font: 700 12px/1 Manrope, system-ui, sans-serif;
  cursor: pointer;
}

.cms-toolbar button:hover,
.cms-panel button:hover,
.cms-card-controls button:hover,
.cms-menu-editor button:hover {
  background: rgb(255 255 255 / 18%);
}

.cms-toolbar .cms-save,
.cms-panel .cms-apply,
.cms-menu-editor .cms-menu-save {
  color: var(--cms-ink);
  background: var(--cms-green);
}

.cms-toolbar button:disabled,
.cms-menu-editor button:disabled {
  opacity: .48;
  cursor: not-allowed;
}

.cms-panel {
  position: fixed;
  z-index: 100001;
  top: 16px;
  right: 16px;
  width: min(370px, calc(100vw - 32px));
  max-height: calc(100dvh - 110px);
  overflow: auto;
  padding: 18px;
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 20px;
  color: var(--cms-paper);
  background: rgb(20 32 24 / 96%);
  box-shadow: 0 24px 90px rgb(13 20 15 / 34%);
  backdrop-filter: blur(20px);
}

.cms-panel[hidden] { display: none; }
.cms-panel [hidden] { display: none !important; }

.cms-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 5px;
}

.cms-panel h2 {
  margin: 0;
  font: 700 17px/1.2 Manrope, system-ui, sans-serif;
}

.cms-panel .cms-panel__close {
  display: grid;
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
}

.cms-panel > p {
  margin: 0 0 14px;
  color: rgb(255 253 247 / 66%);
  font-size: 12px;
  line-height: 1.5;
}

.cms-fields { display: grid; gap: 10px; }

.cms-fields label {
  display: grid;
  gap: 6px;
  color: rgb(255 253 247 / 72%);
  font-size: 12px;
  font-weight: 700;
}

.cms-fields input,
.cms-fields textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 12px;
  border: 1px solid rgb(255 255 255 / 16%);
  border-radius: 12px;
  outline: none;
  color: var(--cms-paper);
  background: rgb(255 255 255 / 8%);
  font: 500 13px/1.5 Manrope, system-ui, sans-serif;
}

.cms-fields textarea {
  min-height: 112px;
  resize: vertical;
}

.cms-fields input:focus,
.cms-fields textarea:focus { border-color: var(--cms-gold); }

.cms-panel-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.cms-history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgb(255 255 255 / 12%);
  border-radius: 14px;
  background: rgb(255 255 255 / 6%);
}

.cms-history-item strong,
.cms-history-item small { display: block; }
.cms-history-item small { margin-top: 4px; color: rgb(255 253 247 / 55%); }

.cms-history-item__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.cms-panel .cms-danger,
.cms-menu-editor .cms-danger {
  color: #ffd8d1;
  background: rgb(255 142 125 / 13%);
}

.cms-panel .cms-danger:hover,
.cms-menu-editor .cms-danger:hover {
  background: rgb(255 142 125 / 24%);
}

#full-menu-dialog.cms-menu-editor-active {
  overflow: hidden;
  background: var(--cms-ink);
}

#full-menu-dialog.cms-menu-editor-active .full-menu-dialog__surface {
  height: 100%;
  min-height: 0;
  background: var(--cms-ink);
}

#full-menu-dialog.cms-menu-editor-active .full-menu-dialog__surface > .full-menu-dialog__header,
#full-menu-dialog.cms-menu-editor-active .full-menu-dialog__surface > .full-menu-dialog__body {
  display: none;
}

.cms-menu-editor {
  display: grid;
  height: 100%;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  color: var(--cms-paper);
  background: var(--cms-ink);
}

.cms-menu-editor[hidden],
.cms-menu-editor [hidden] {
  display: none !important;
}

.cms-menu-editor__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 16px;
  border-bottom: 1px solid rgb(255 255 255 / 12%);
  background: rgb(20 32 24 / 98%);
}

.cms-menu-editor__header h2,
.cms-menu-product-head h3,
.cms-menu-history h3,
.cms-menu-editor__empty h3 {
  margin: 0;
  font: 700 18px/1.2 Manrope, system-ui, sans-serif;
  letter-spacing: 0;
}

.cms-menu-editor__status {
  margin: 4px 0 0;
  color: rgb(255 253 247 / 58%);
  font-size: 11px;
  line-height: 1.35;
}

.cms-menu-editor__status[data-dirty="true"] {
  color: var(--cms-gold);
}

.cms-menu-editor__header-actions,
.cms-menu-product-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.cms-menu-editor .cms-menu-close,
.cms-menu-editor .cms-danger {
  color: var(--cms-ink);
  background: var(--cms-danger);
}

.cms-menu-editor__content,
.cms-menu-editor__main {
  min-height: 0;
  overflow: hidden;
}

.cms-menu-editor.is-saving .cms-menu-editor__content {
  opacity: .58;
}

.cms-menu-editor__main {
  display: grid;
  height: 100%;
  grid-template-columns: minmax(250px, 300px) minmax(0, 1fr);
}

.cms-menu-editor__list-pane {
  display: grid;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border-right: 1px solid rgb(255 255 255 / 12%);
  background: rgb(255 255 255 / 3%);
}

.cms-menu-editor__list-head {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid rgb(255 255 255 / 10%);
  font-size: 12px;
}

.cms-menu-list-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.cms-menu-list-actions button {
  min-width: 0;
  padding-inline: 7px;
  font-size: 10px;
}

.cms-menu-editor__list {
  min-height: 0;
  overflow: auto;
  padding: 8px;
  scrollbar-color: rgb(255 255 255 / 22%) transparent;
  scrollbar-width: thin;
}

.cms-menu-list-group + .cms-menu-list-group {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgb(255 255 255 / 9%);
}

.cms-menu-list-group__heading {
  padding: 0 0 4px;
  color: rgb(255 253 247 / 68%);
  font-size: 10px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.cms-menu-editor .cms-menu-category-link {
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: inherit;
  background: transparent;
  text-align: left;
  text-transform: inherit;
}

.cms-menu-category-link strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cms-menu-category-link span {
  min-width: 22px;
  padding: 3px 6px;
  border-radius: 999px;
  background: rgb(255 255 255 / 8%);
  text-align: center;
}

.cms-menu-editor .cms-menu-category-link:hover {
  border-color: rgb(255 255 255 / 14%);
  background: rgb(255 255 255 / 6%);
}

.cms-menu-editor .cms-menu-category-link.is-selected {
  border-color: rgb(244 199 101 / 46%);
  color: var(--cms-gold);
  background: rgb(244 199 101 / 9%);
}

.cms-menu-editor .cms-menu-category-link.is-hidden:not(.is-selected) {
  opacity: .5;
}

.cms-menu-editor .cms-menu-product-link {
  display: grid;
  width: 100%;
  min-height: 0;
  gap: 3px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  text-align: left;
}

.cms-menu-editor .cms-menu-product-link + .cms-menu-product-link {
  margin-top: 3px;
}

.cms-menu-product-link span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cms-menu-product-link small {
  color: rgb(255 253 247 / 48%);
  font-size: 9px;
  font-weight: 600;
}

.cms-menu-editor .cms-menu-product-link:hover {
  border-color: rgb(255 255 255 / 14%);
  background: rgb(255 255 255 / 7%);
}

.cms-menu-editor .cms-menu-product-link.is-selected {
  border-color: var(--cms-green);
  color: var(--cms-ink);
  background: var(--cms-green);
}

.cms-menu-product-link.is-selected small {
  color: rgb(20 32 24 / 64%);
}

.cms-menu-product-link.is-hidden:not(.is-selected) {
  opacity: .48;
}

.cms-menu-editor__details {
  min-height: 0;
  overflow: auto;
  padding: 16px;
  scrollbar-color: rgb(255 255 255 / 22%) transparent;
  scrollbar-width: thin;
}

.cms-menu-product-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.cms-menu-product-head > div:first-child {
  min-width: 0;
}

.cms-menu-product-head > div:first-child > span {
  display: block;
  margin-bottom: 4px;
  overflow: hidden;
  color: rgb(255 253 247 / 48%);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cms-menu-product-head h3 {
  overflow-wrap: anywhere;
}

.cms-menu-category-summary {
  margin: 5px 0 0;
  color: rgb(255 253 247 / 56%);
  font-size: 11px;
  line-height: 1.4;
}

.cms-menu-product-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(110px, .35fr);
  gap: 10px;
  padding: 14px;
  border: 1px solid rgb(255 255 255 / 11%);
  border-radius: 16px;
  background: rgb(255 255 255 / 4%);
}

.cms-menu-field {
  display: grid;
  align-content: start;
  gap: 6px;
  color: rgb(255 253 247 / 68%);
  font-size: 10px;
  font-weight: 700;
}

.cms-menu-field--wide {
  grid-column: 1 / -1;
}

.cms-menu-category-form {
  grid-template-columns: minmax(0, 1fr) minmax(120px, .25fr);
}

.cms-menu-editor input,
.cms-menu-editor textarea,
.cms-menu-editor select {
  width: 100%;
  box-sizing: border-box;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid rgb(255 255 255 / 15%);
  border-radius: 10px;
  outline: 0;
  color: var(--cms-paper);
  background: rgb(255 255 255 / 7%);
  font: 500 12px/1.4 Manrope, system-ui, sans-serif;
}

.cms-menu-editor select option {
  color: var(--cms-ink);
  background: var(--cms-paper);
}

.cms-menu-editor textarea {
  min-height: 78px;
  resize: vertical;
}

.cms-menu-editor input:focus,
.cms-menu-editor textarea:focus,
.cms-menu-editor select:focus {
  border-color: var(--cms-gold);
  box-shadow: 0 0 0 2px rgb(244 199 101 / 14%);
}

.cms-menu-editor [aria-invalid="true"] {
  border-color: var(--cms-danger);
  box-shadow: 0 0 0 2px rgb(255 142 125 / 16%);
}

.cms-menu-visibility {
  display: flex;
  grid-column: 1 / -1;
  width: fit-content;
  align-items: center;
  gap: 8px;
  color: rgb(255 253 247 / 76%);
  font-size: 11px;
  font-weight: 700;
}

.cms-menu-visibility input {
  width: 17px;
  min-height: 17px;
  margin: 0;
  accent-color: var(--cms-green);
}

.cms-menu-media-editor,
.cms-menu-variants {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid rgb(255 255 255 / 11%);
  border-radius: 16px;
  background: rgb(255 255 255 / 4%);
}

.cms-menu-media-editor {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.cms-menu-media-editor h4,
.cms-menu-variants h4 {
  margin: 0;
  font-size: 12px;
  line-height: 1.25;
}

.cms-menu-media-editor p,
.cms-menu-variants p,
.cms-menu-history p,
.cms-menu-editor__empty p {
  margin: 4px 0 0;
  color: rgb(255 253 247 / 55%);
  font-size: 10px;
  line-height: 1.4;
}

.cms-menu-media-editor__preview {
  display: grid;
  width: 72px;
  height: 72px;
  overflow: hidden;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 12%);
  border-radius: 12px;
  color: rgb(255 253 247 / 46%);
  background: rgb(255 255 255 / 6%);
  font-size: 9px;
}

.cms-menu-media-editor__preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cms-menu-media-editor__preview.is-broken img {
  display: none;
}

.cms-menu-variants__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cms-menu-variants__list {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.cms-menu-variant-row {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(82px, .35fr) auto auto;
  align-items: center;
  gap: 7px;
}

.cms-menu-variant-row > span {
  color: rgb(255 253 247 / 62%);
  font-size: 11px;
  font-weight: 700;
}

.cms-menu-history {
  height: 100%;
  overflow: auto;
  padding: 16px;
}

.cms-menu-history__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgb(255 255 255 / 11%);
}

.cms-menu-history__list {
  display: grid;
  gap: 8px;
  max-width: 820px;
  margin-top: 14px;
}

.cms-menu-history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgb(255 255 255 / 11%);
  border-radius: 13px;
  background: rgb(255 255 255 / 4%);
}

.cms-menu-history-item strong,
.cms-menu-history-item small {
  display: block;
}

.cms-menu-history-item small {
  margin-top: 4px;
  color: rgb(255 253 247 / 52%);
  font-size: 10px;
}

.cms-menu-editor__message,
.cms-menu-editor__empty {
  padding: 24px;
  color: rgb(255 253 247 / 68%);
  font-size: 12px;
}

.cms-menu-editor__empty {
  display: grid;
  min-height: 300px;
  place-content: center;
  justify-items: center;
  text-align: center;
}

.cms-menu-editor__empty button {
  margin-top: 14px;
}

.cms-toast {
  position: fixed;
  z-index: 100002;
  top: 18px;
  left: 50%;
  max-width: calc(100vw - 32px);
  padding: 11px 15px;
  border-radius: 999px;
  color: var(--cms-paper);
  background: var(--cms-ink);
  box-shadow: 0 15px 55px rgb(13 20 15 / 24%);
  font-size: 12px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -8px);
  transition: opacity .2s ease, transform .2s ease;
}

.cms-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.cms-toast[data-kind="error"] { color: var(--cms-ink); background: var(--cms-danger); }

body.cms-editing [data-cms-text-key],
body.cms-editing [data-cms-image-key],
body.cms-editing [data-cms-link-key] {
  outline: 1px dashed rgb(65 121 66 / 55%);
  outline-offset: 3px;
}

body.cms-editing [data-cms-text-key]:hover,
body.cms-editing [data-cms-image-key]:hover,
body.cms-editing [data-cms-link-key]:hover,
body.cms-editing .cms-selected {
  outline: 3px solid #4c9a50 !important;
  outline-offset: 4px;
}

body.cms-editing [contenteditable] { cursor: text; }
body.cms-editing [data-cms-image-key] { cursor: copy; }
body.cms-editing a[href] { cursor: not-allowed; }
body.cms-editing a[data-cms-link-key] { cursor: pointer; }
body.cms-editing a[href] [contenteditable] { cursor: text; }

.cms-card-controls {
  position: absolute;
  z-index: 8;
  top: 8px;
  left: 8px;
  display: none;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: rgb(20 32 24 / 92%);
  box-shadow: 0 8px 30px rgb(13 20 15 / 22%);
}

body.cms-editing [data-cms-card-key] { position: relative; }
body.cms-editing [data-cms-card-key]:hover > .cms-card-controls,
body.cms-editing [data-cms-card-key]:focus-within > .cms-card-controls { display: flex; }
.cms-card-controls button { min-width: 34px; min-height: 32px; padding: 6px 8px; }

body.cms-editing .cms-card-hidden {
  display: block !important;
  opacity: 1;
  filter: none;
}

body.cms-editing .cms-card-hidden > .media-slot,
body.cms-editing .cms-card-hidden > .product-card__copy {
  opacity: .42;
  filter: grayscale(.7);
}

body.cms-editing .team-profile.cms-card-hidden {
  display: flex !important;
}

body.cms-editing .team-profiles {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-flow: row;
  grid-auto-columns: auto;
  grid-template-rows: none;
  margin: 0;
  padding: 0;
  overflow: visible;
  gap: 18px;
}

body.cms-editing .team-carousel__controls {
  display: none !important;
}

body.cms-editing .team-profile.cms-card-hidden > .team-profile__media,
body.cms-editing .team-profile.cms-card-hidden > .team-profile__copy,
body.cms-editing .team-section.cms-card-hidden > .team-section__grid {
  opacity: .42;
  filter: grayscale(.7);
}

body.cms-editing .cms-card-hidden::after {
  content: none;
}

body.cms-load-error::before {
  content: "CMS не смогла загрузить контент. Обновите страницу; сохранение заблокировано.";
  position: fixed;
  z-index: 100003;
  inset: auto 16px 88px;
  padding: 14px;
  border-radius: 14px;
  color: var(--cms-ink);
  background: var(--cms-danger);
  text-align: center;
  font: 700 13px/1.4 Manrope, system-ui, sans-serif;
}

@media (max-width: 980px) {
  body.cms-editing .team-profiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cms-menu-editor__main {
    grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
  }

  .cms-menu-product-head {
    align-items: stretch;
    flex-direction: column;
  }

  .cms-menu-product-actions {
    flex-wrap: wrap;
  }
}

@media (max-width: 720px) {
  body.cms-editing .team-profiles {
    grid-template-columns: minmax(0, 1fr);
  }

  .cms-toolbar {
    right: 8px;
    bottom: 8px;
    left: 8px;
    justify-content: center;
    flex-wrap: wrap;
    border-radius: 16px;
  }

  .cms-toolbar strong { width: 100%; text-align: center; }
  .cms-toolbar button { flex: 1 1 auto; padding-inline: 8px; }

  .cms-panel {
    top: 8px;
    right: 8px;
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 112px);
  }

  .cms-menu-editor__header {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
  }

  .cms-menu-editor__header-actions {
    width: 100%;
  }

  .cms-menu-editor__header-actions button {
    flex: 1 1 auto;
    padding-inline: 7px;
  }

  .cms-menu-editor__main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(170px, 30dvh) minmax(0, 1fr);
  }

  .cms-menu-editor__list-pane {
    border-right: 0;
    border-bottom: 1px solid rgb(255 255 255 / 12%);
  }

  .cms-menu-editor__details,
  .cms-menu-history {
    padding: 11px;
  }

  .cms-menu-product-form {
    grid-template-columns: minmax(0, 1fr);
    padding: 11px;
  }

  .cms-menu-field--wide,
  .cms-menu-visibility {
    grid-column: auto;
  }

  .cms-menu-media-editor,
  .cms-menu-variants {
    padding: 11px;
  }

  .cms-menu-media-editor {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .cms-menu-media-editor__preview {
    width: 64px;
    height: 64px;
  }

  .cms-menu-media-editor > button {
    grid-column: 1 / -1;
  }

  .cms-menu-variant-row {
    grid-template-columns: minmax(0, 1fr) 88px auto;
  }

  .cms-menu-variant-row > button {
    grid-column: 1 / -1;
  }

  .cms-menu-history__head {
    align-items: flex-start;
    flex-direction: column;
  }

  body.cms-editing [data-cms-card-key] > .cms-card-controls { display: flex; }

  body.cms-editing .team-profile.cms-card-hidden {
    display: flex !important;
  }
}

@media (max-width: 430px) {
  .cms-menu-editor__header-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .cms-menu-editor__header-actions .cms-menu-close {
    grid-column: 1 / -1;
  }

  .cms-menu-product-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .cms-menu-variants__head {
    align-items: stretch;
    flex-direction: column;
  }

  .cms-menu-history-item {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cms-toast { transition: none; }
}
