:root {
  --cream: #fbf3e3;
  --sand: #f3e4c8;
  --sand-2: #e9d5b0;
  --bordeaux: #6b1a1a;
  --bordeaux-2: #431010;
  --brick: #a6321c;
  --gold: #e5a32b;
  --ink: #2b1a12;
  --ink-soft: #5c4335;
  --white: #fffdf8;
  --radius: 18px;
  --font-head: "Montserrat", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
}

.admin-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .8rem clamp(1rem, 4vw, 2.5rem);
  background: var(--white);
  border-bottom: 1px solid rgba(67, 16, 16, .12);
}

.admin-header__brand img { display: block; height: 34px; width: auto; }

.admin-header__actions { display: flex; align-items: center; gap: .8rem; }

.link {
  font-size: .9rem;
  font-weight: 600;
  color: var(--brick);
  text-decoration: none;
}
.link:hover { text-decoration: underline; }

.admin-main {
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 2.5rem) clamp(1rem, 4vw, 2rem) 4rem;
}

h1 {
  margin: 0 0 .35rem;
  font-family: var(--font-head);
  font-size: 1.5rem;
  color: var(--bordeaux);
}

.login {
  max-width: 420px;
  margin: 8vh auto;
  padding: 2rem;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 22px 48px -30px rgba(67, 16, 16, .55);
}

.login p { margin: 0 0 1.2rem; color: var(--ink-soft); font-size: .95rem; }

.login__form { display: grid; gap: .5rem; }

label {
  display: grid;
  gap: .3rem;
  font-size: .8rem;
  font-weight: 600;
  color: var(--ink-soft);
}

input:not([type=file]),
textarea {
  width: 100%;
  padding: .6rem .7rem;
  font: inherit;
  font-size: .95rem;
  color: var(--ink);
  background: var(--white);
  border: 1px solid rgba(67, 16, 16, .22);
  border-radius: 10px;
}

input:not([type=file]):focus,
textarea:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
  border-color: transparent;
}

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

button {
  padding: .55rem 1.1rem;
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
}

.btn-primary { background: var(--bordeaux); color: #fff6e6; }
.btn-primary:hover { background: var(--bordeaux-2); }

.btn-ghost { background: transparent; border-color: rgba(67, 16, 16, .25); color: var(--bordeaux); }

.btn-danger { background: transparent; border-color: rgba(166, 50, 28, .45); color: var(--brick); }
.btn-danger:hover { background: rgba(166, 50, 28, .08); }

.btn-icon { padding: .35rem .7rem; background: var(--sand); color: var(--bordeaux); font-size: 1rem; }
.btn-icon:hover { background: var(--sand-2); }

button:disabled { opacity: .55; cursor: progress; }

.editor-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.editor-head p { max-width: 56ch; margin: 0; color: var(--ink-soft); font-size: .92rem; }
.editor-head div > p { margin-top: .2rem; }

.feedback { min-height: 1.2em; margin: .2rem 0; font-size: .9rem; color: var(--ink-soft); }
.feedback.is-error { color: #a1291a; }
.feedback.is-ok { color: #1f7a45; }

.items { display: grid; gap: 1.2rem; margin-top: 1rem; }

.item {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 1.2rem;
  padding: 1.1rem;
  background: var(--white);
  border: 1px solid rgba(67, 16, 16, .1);
  border-radius: var(--radius);
  box-shadow: 0 18px 40px -34px rgba(67, 16, 16, .6);
}

.item__media img {
  width: 100%;
  height: 170px;
  object-fit: cover;
  border-radius: 12px;
  background: var(--sand);
}

.upload {
  display: block;
  margin-top: .6rem;
  padding: .45rem .9rem;
  font-size: .82rem;
  font-weight: 700;
  text-align: center;
  color: var(--bordeaux);
  background: var(--sand);
  border-radius: 999px;
  cursor: pointer;
}
.upload:hover { background: var(--sand-2); }
.upload.is-busy { opacity: .6; pointer-events: none; }

.upload-hint { margin: .35rem 0 0; font-size: .72rem; color: var(--ink-soft); }

.item__fields { display: grid; gap: .65rem; align-content: start; }

.item__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  margin-top: .2rem;
}

.item__status { font-size: .8rem; color: var(--ink-soft); }
.item__status.is-ok { color: #1f7a45; }
.item__status.is-error { color: #a1291a; }

.empty { color: var(--ink-soft); font-size: .95rem; }

@media (max-width: 720px) {
  .admin-header__brand img { height: 26px; }
  .item { grid-template-columns: 1fr; }
  .item__media img { height: 200px; }
  .admin-main { padding-bottom: 3rem; }
}

/* ---------- ritaglio foto ---------- */
dialog.crop {
  width: min(620px, 94vw);
  max-height: 92vh;
  padding: 0;
  color: var(--ink);
  background: var(--white);
  border: none;
  border-radius: 18px;
  box-shadow: 0 40px 80px -30px rgba(43, 26, 18, .65);
  overflow: hidden;
}

dialog.crop::backdrop { background: rgba(43, 26, 18, .6); }

dialog.crop[open] { display: flex; flex-direction: column; }

.crop__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem 1.2rem;
  background: var(--bordeaux);
  color: #fff6e6;
}

.crop__head h2 { margin: 0; font-family: var(--font-head); font-size: 1.05rem; color: #fff6e6; }

.crop__close {
  padding: .3rem;
  font-size: 1rem;
  line-height: 1;
  color: #fff6e6;
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
}
.crop__close:hover { background: rgba(255, 255, 255, .14); }

.crop__body { padding: 1rem 1.2rem; overflow-y: auto; }

.crop__frame {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--sand);
  border-radius: 12px;
  overflow: hidden;
  touch-action: none;
}

.crop__frame canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}
.crop__frame canvas:active { cursor: grabbing; }

.crop__zoom {
  display: grid;
  gap: .3rem;
  margin-top: .9rem;
  font-size: .8rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.crop__zoom input[type="range"] { width: 100%; accent-color: var(--bordeaux); }

.crop__hint { margin: .5rem 0 0; font-size: .78rem; color: var(--ink-soft); }

.crop__foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .6rem;
  padding: .9rem 1.2rem;
  background: var(--sand);
  border-top: 1px solid rgba(67, 16, 16, .12);
}

.crop__zoom-row {
  display: flex;
  align-items: center;
  gap: .7rem;
}

.crop__zoom input[type="range"] { flex: 1; min-width: 0; }

.crop__zoom output {
  min-width: 3.2rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--bordeaux);
}

.crop__frame canvas {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

/* ---------- orari di apertura ---------- */
.hours-panel {
  margin-bottom: 2rem;
  padding: 1.1rem;
  background: var(--white);
  border: 1px solid rgba(67, 16, 16, .1);
  border-radius: var(--radius);
  box-shadow: 0 18px 40px -34px rgba(67, 16, 16, .6);
}

.hours-panel h2 {
  margin: 0 0 .2rem;
  font-family: var(--font-head);
  font-size: 1.15rem;
  color: var(--bordeaux);
}

.hours-rows { display: grid; gap: .2rem; margin-top: .4rem; }

.hours-row {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr) auto;
  gap: .6rem;
  align-items: center;
  padding: .5rem .2rem;
  border-bottom: 1px dashed rgba(67, 16, 16, .15);
}

.hours-row:last-child { border-bottom: none; }

.hours-row__day {
  font-size: .9rem;
  font-weight: 700;
  color: var(--bordeaux);
}

.hours-row__slots {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .3rem;
  font-size: .85rem;
  color: var(--ink-soft);
}

.hours-row__slots input[type="time"] {
  width: auto;
  padding: .3rem .4rem;
  font-size: .88rem;
  border-radius: 8px;
}

.hours-row__closed {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
  color: var(--ink-soft);
}

.hours-row__closed input {
  width: auto;
  margin: 0;
  accent-color: var(--bordeaux);
}

.hours-row.is-closed .hours-row__slots { opacity: .4; }

@media (max-width: 720px) {
  .hours-row { grid-template-columns: minmax(0, 1fr) auto; }
  .hours-row__slots { grid-column: 1 / -1; order: 3; }
}
