:root {
  --ink: #342d27;
  --muted: #7b6f66;
  --line: #e8d9ca;
  --paper: #fbf4ec;
  --soft: #f3e6d8;
  --brand: #a87956;
  --brand-dark: #4b372c;
  --honey: #c59a43;
  --white: #fff;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(197,154,67,.14), transparent 28rem),
    radial-gradient(circle at bottom right, rgba(168,121,86,.16), transparent 32rem),
    linear-gradient(135deg, #fbf4ec, #efe1d2);
  font-family: "Manrope", "Segoe UI", Arial, sans-serif;
  line-height: 1.5;
}

.admin-shell {
  max-width: 1540px;
  margin: 0 auto;
  padding: 30px 28px 116px;
}

.admin-shell.is-login {
  display: grid;
  max-width: 1080px;
  min-height: 100vh;
  place-items: center;
}

.admin-shell.is-login .admin-header {
  display: none;
}

.admin-header {
  display: grid;
  grid-template-columns: 160px minmax(260px, 1fr);
  gap: 18px 24px;
  align-items: center;
  margin-bottom: 24px;
  padding: 18px 20px;
  background: rgba(255,250,244,.86);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(75, 55, 44, .1);
  backdrop-filter: blur(12px);
}

.admin-header > div {
  min-width: 0;
}

.admin-header .eyebrow {
  margin-bottom: 5px;
  font-size: 12px;
}

.admin-header p:not(.eyebrow) {
  margin-bottom: 0;
}

.admin-logo,
.login-mark img {
  display: block;
  width: 100%;
  height: auto;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: 13px;
}

h1 {
  margin: 0;
  font-family: "Marcellus", Georgia, serif;
  font-weight: 400;
  font-size: clamp(32px, 5vw, 50px);
  line-height: 1;
}

h2 {
  margin: 0 0 10px;
  font-family: "Marcellus", Georgia, serif;
  font-weight: 400;
  font-size: 26px;
  line-height: 1.1;
}

p {
  margin-top: 0;
  color: var(--muted);
}

.admin-actions {
  display: flex;
  grid-column: 1 / -1;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}

.admin-language {
  display: inline-flex;
  gap: 4px;
  grid-column: 1 / -1;
  justify-self: end;
  padding: 4px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.admin-language a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  min-height: 34px;
  color: var(--brand-dark);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
}

.admin-language .flag {
  display: inline-block;
  width: 18px;
  height: 12px;
  margin-right: 6px;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(75, 55, 44, .18);
}

.flag-de {
  background: linear-gradient(to bottom, #111 0 33.33%, #dd0000 33.33% 66.66%, #ffce00 66.66%);
}

.flag-it {
  background: linear-gradient(to right, #009246 0 33.33%, #fff 33.33% 66.66%, #ce2b37 66.66%);
}

.flag-en {
  background:
    linear-gradient(45deg, transparent 42%, #cf142b 42% 58%, transparent 58%),
    linear-gradient(-45deg, transparent 42%, #cf142b 42% 58%, transparent 58%),
    linear-gradient(to bottom, transparent 38%, #fff 38% 44%, #cf142b 44% 56%, #fff 56% 62%, transparent 62%),
    linear-gradient(to right, transparent 38%, #fff 38% 44%, #cf142b 44% 56%, #fff 56% 62%, transparent 62%),
    #00247d;
}

.admin-language a.active {
  color: var(--white);
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
}

.compact-language {
  align-self: center;
  margin-left: 4px;
}

.admin-shell.is-admin .header-language {
  display: none;
}

.login-language {
  margin: 0 0 20px;
}

.admin-actions a,
.sticky-save a,
.section-title a,
.list-picker a,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  color: var(--white);
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  border: 0;
  border-radius: 999px;
  font-weight: 800;
  letter-spacing: 0;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(75, 55, 44, .16);
}

.admin-actions a {
  min-height: 38px;
  padding: 0 15px;
  font-size: 14px;
  box-shadow: none;
}

.admin-actions .ghost {
  color: var(--brand-dark);
  background: var(--white);
  border: 1px solid var(--line);
  box-shadow: none;
}

.login-card,
.help-card,
.edit-card,
.notice {
  background: rgba(255,250,244,.92);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(75, 55, 44, .12);
}

.login-card {
  width: min(100%, 480px);
  padding: 34px;
  text-align: left;
  border-color: #dcc9b6;
}

.login-mark {
  max-width: 340px;
  margin: 0 auto 30px;
}

.login-intro {
  margin-bottom: 26px;
}

.login-card label {
  margin-bottom: 14px;
}

.login-card input {
  min-height: 58px;
  font-size: 18px;
}

.login-card button {
  min-width: 128px;
  margin-top: 2px;
  min-height: 54px;
  padding-inline: 30px;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.admin-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.admin-tabs a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 62px;
  padding: 0 18px;
  color: var(--brand-dark);
  background: rgba(255,250,244,.86);
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 18px;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 12px 28px rgba(75, 55, 44, .08);
}

.admin-tabs a.active {
  color: var(--white);
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
}

.section-title,
.custom-manager {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
  padding: 20px;
  background: rgba(255,250,244,.9);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 12px 28px rgba(75, 55, 44, .08);
}

.section-title h2 {
  margin: 0;
}

.create-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
}

.list-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: end;
}

.list-picker a {
  min-height: 42px;
  color: var(--brand-dark);
  background: var(--white);
  border: 1px solid var(--line);
  box-shadow: none;
}

.list-picker a.active {
  color: var(--white);
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
}

.custom-head-card {
  margin-bottom: 4px;
}

.delete-list {
  margin: 22px 0 0;
}

.delete-list button {
  color: #8a2534;
  background: #fff;
  border: 1px solid #ddc7b3;
  box-shadow: none;
}

.help-card {
  padding: 20px;
}

.help-card span {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-bottom: 16px;
  color: var(--white);
  background: linear-gradient(135deg, var(--brand), var(--honey));
  border-radius: 50%;
  font-weight: 900;
}

.edit-card {
  margin-top: 18px;
  overflow: hidden;
}

.edit-card-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 20px 22px;
  background: linear-gradient(135deg, var(--soft), #fffaf4);
  border-bottom: 1px solid var(--line);
}

.card-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

.edit-card-head span,
.category-print,
.delete-category {
  flex: 0 0 auto;
  padding: 8px 12px;
  color: var(--brand-dark);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.delete-category {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  color: #8a2534;
  border-color: #ddc7b3;
  cursor: pointer;
}

.delete-category input {
  width: auto;
  padding: 0;
  box-shadow: none;
}

.new-category-card {
  border-style: dashed;
  border-color: var(--brand);
}

.new-category-card .edit-card-head {
  background: linear-gradient(135deg, #fff, var(--soft));
}

.notice {
  margin: 0 0 16px;
  padding: 16px 18px;
  font-weight: 800;
}

.success { border-left: 5px solid #3d9a5f; }
.error { border-left: 5px solid #c94747; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 22px;
}

.language-edit-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  overflow-x: visible;
}

.language-panel {
  min-width: 0;
  border-right: 1px solid var(--line);
  border-bottom: 0;
}

.language-panel:last-child {
  border-right: 0;
}

.language-panel-head {
  display: flex;
  gap: 9px;
  align-items: center;
  padding: 15px 22px;
  color: var(--brand-dark);
  background: #fffaf4;
  border-bottom: 1px solid var(--line);
  font-weight: 900;
}

.language-panel-head small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.language-panel .field-grid {
  grid-template-columns: 1fr;
}

.items-editor {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.items-editor-head,
.items-editor-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px 36px;
  gap: 8px;
  align-items: center;
}

.items-editor.readonly-items .items-editor-head,
.items-editor.readonly-items .items-editor-row {
  grid-template-columns: minmax(0, 1fr) 118px;
}

.items-editor-list {
  display: grid;
  gap: 8px;
}

.items-editor-head {
  position: sticky;
  top: -10px;
  z-index: 1;
  padding: 4px 0 8px;
  color: var(--muted);
  background: #fff;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.items-editor-row input {
  min-height: 40px;
  padding: 9px 10px;
  font-size: 14px;
}

.items-editor-row input:nth-child(2) {
  text-align: right;
}

.master-price-preview {
  color: var(--muted);
  background: #f8efe6;
  cursor: default;
}

.row-remove {
  width: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  color: #8a2534;
  background: #fff7f5;
  border: 1px solid #e6c7bd;
  border-radius: 50%;
  box-shadow: none;
  font-size: 22px;
  line-height: 1;
}

.add-row {
  justify-self: start;
  min-height: 38px;
  margin-top: 2px;
  padding: 0 13px;
  color: var(--brand-dark);
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: none;
  font-size: 13px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--brand-dark);
  font-weight: 800;
}

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

input,
textarea {
  width: 100%;
  padding: 15px 16px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: 500 16px/1.5 "Manrope", "Segoe UI", Arial, sans-serif;
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(185, 100, 125, .14);
}

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

code {
  padding: 2px 6px;
  color: var(--brand-dark);
  background: var(--soft);
  border-radius: 5px;
}

.sticky-save {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  gap: 10px;
  padding: 12px;
  background: rgba(255,255,255,.94);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 14px 36px rgba(75, 55, 44, .18);
  backdrop-filter: blur(10px);
}

@media (max-width: 860px) {
  .admin-header,
  .help-grid,
  .section-title,
  .custom-manager,
  .create-list,
  .field-grid {
    grid-template-columns: 1fr;
  }

  .language-edit-grid {
    grid-template-columns: repeat(3, minmax(340px, 1fr));
    overflow-x: auto;
  }

  .language-panel {
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }

  .language-panel:last-child {
    border-right: 0;
  }

  .items-editor-head,
  .items-editor-row {
    grid-template-columns: minmax(210px, 1fr) 104px 36px;
  }

  .items-editor.readonly-items .items-editor-head,
  .items-editor.readonly-items .items-editor-row {
    grid-template-columns: minmax(210px, 1fr) 104px;
  }

  .admin-language {
    justify-self: start;
  }

  .admin-logo {
    max-width: 260px;
  }

  .list-picker {
    justify-content: start;
  }
}

@media (max-width: 620px) {
  .admin-shell {
    padding-inline: 12px;
  }

  .login-card {
    padding: 22px;
  }

  .admin-actions,
  .admin-tabs,
  .sticky-save {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-actions a,
  .compact-language {
    width: 100%;
  }

  .compact-language {
    justify-content: center;
    margin-left: 0;
  }

  .sticky-save {
    right: 12px;
    left: 12px;
    border-radius: 14px;
  }

  .edit-card-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .card-tools {
    justify-content: flex-start;
  }
}
