:root {
  --ink: #10241c;
  --ink-soft: #3d564a;
  --paper: #f7f3ea;
  --paper-2: #fffdf8;
  --brand: #0b3d2e;
  --brand-2: #146049;
  --line: rgba(16, 36, 28, 0.12);
  --whatsapp: #1faa59;
  --whatsapp-ink: #06361c;
  --email: #2a6fdb;
  --email-ink: #0c2d66;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(11, 61, 46, 0.12);
  --radius: 18px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Manrope", sans-serif;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(20, 96, 73, 0.18), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(201, 162, 39, 0.16), transparent 50%),
    linear-gradient(180deg, #eef5f0 0%, var(--paper) 42%, #ebe4d6 100%);
  line-height: 1.45;
}

.bg-wash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(11, 61, 46, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(11, 61, 46, 0.035) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent 75%);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  backdrop-filter: blur(14px);
  background: rgba(247, 243, 234, 0.82);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.brand-mark {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 0.85rem;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--brand), var(--brand-2));
  color: #f4efe4;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  flex-shrink: 0;
}

.brand-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand-sub {
  margin: 0.1rem 0 0;
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.top-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.shell {
  width: min(1480px, calc(100% - 1.5rem));
  margin: 1rem auto 2rem;
}

.hero-panel,
.list-panel {
  background: color-mix(in srgb, var(--paper-2) 92%, white);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 1.35rem 1.5rem 1.4rem;
  animation: rise 0.45s ease both;
}

@media (min-width: 1100px) {
  .list-panel {
    padding: 1.5rem 1.85rem 1.6rem;
  }
}

@media (max-width: 600px) {
  .shell {
    width: calc(100% - 0.85rem);
    margin: 0.65rem auto 1.5rem;
  }

  .list-panel {
    padding: 1rem 0.85rem 1.1rem;
    border-radius: 16px;
  }

  .list-head h2 {
    font-size: 1.25rem;
  }

  .topbar {
    padding: 0.75rem 0.85rem;
  }

  .top-actions .btn.ghost {
    padding: 0.5rem 0.7rem;
    font-size: 0.85rem;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.hero-panel h1,
.list-head h2,
.sheet-head h2 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.65rem;
}

.hero-panel h1 {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  max-width: 16ch;
  line-height: 1.15;
}

.hero-panel > p {
  margin: 0 0 1.2rem;
  color: var(--ink-soft);
  max-width: 42ch;
}

.steps {
  margin: 0 0 1.4rem;
  padding-left: 1.15rem;
  color: var(--ink-soft);
}

.steps li + li {
  margin-top: 0.35rem;
}

.list-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.settings input,
.settings textarea,
.settings select,
#create-form input,
#create-form textarea {
  font: inherit;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.65rem 0.8rem;
  background: #fff;
}

.meta-toggle-card {
  margin-bottom: 0.35rem;
}

/* —— Layout: eventi (sx) | calendario (dx) —— */
.cal-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.7fr);
  gap: 1.25rem 1.75rem;
  align-items: start;
}

.cal-layout.is-cal-collapsed {
  grid-template-columns: 1fr;
}

.cal-day-pane,
.cal-month-pane {
  min-width: 0;
}

.day-pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.day-pane-head .day-title {
  margin: 0;
}

.cal-pane-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.cal-pane-toolbar .cal-nav {
  flex: 1;
  margin: 0;
  min-width: 0;
}

.btn-cal-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
  flex-shrink: 0;
  padding: 0.45rem 0.75rem;
  font-size: 0.85rem;
}

.cal-layout.is-cal-collapsed .cal-month-pane {
  display: none;
}

.cal-layout:not(.is-cal-collapsed) #btn-show-cal {
  display: none !important;
}

.cal-layout.is-cal-collapsed #btn-show-cal {
  display: inline-flex !important;
}

@media (max-width: 900px) {
  .cal-layout:not(.is-cal-collapsed) {
    grid-template-columns: 1fr;
  }

  .cal-layout:not(.is-cal-collapsed) .cal-month-pane {
    order: -1;
    position: sticky;
    top: 4.5rem;
    z-index: 5;
    padding: 0.75rem;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: color-mix(in srgb, var(--paper-2) 96%, white);
    box-shadow: 0 10px 28px rgba(11, 61, 46, 0.08);
  }

  .btn-cal-label {
    display: none;
  }

  #btn-hide-cal {
    width: 2.4rem;
    height: 2.4rem;
    padding: 0;
    justify-content: center;
    border-radius: 12px;
  }

  #btn-hide-cal svg {
    transform: rotate(-90deg);
  }
}

/* —— Calendario mese —— */
.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
}

.cal-nav-center {
  display: grid;
  justify-items: center;
  gap: 0.25rem;
  min-width: 0;
}

.cal-nav-center h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.cal-nav-btn {
  width: 2.6rem;
  height: 2.6rem;
  padding: 0;
  font-size: 1.55rem;
  line-height: 1;
  border-radius: 14px;
}

.cal-today-btn {
  padding: 0.25rem 0.7rem;
  font-size: 0.78rem;
  border-radius: 999px;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.3rem;
  margin-bottom: 0.35rem;
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.35rem;
  margin-bottom: 1.15rem;
}

.cal-cell {
  appearance: none;
  border: 1px solid transparent;
  background: rgba(255, 253, 248, 0.7);
  border-radius: 12px;
  min-height: 3.15rem;
  padding: 0.35rem 0.2rem 0.4rem;
  font: inherit;
  color: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.15rem;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.cal-cell.cal-empty {
  pointer-events: none;
  background: transparent;
  min-height: 3.15rem;
}

.cal-cell:hover:not(.cal-empty),
.cal-cell:focus-visible {
  border-color: color-mix(in srgb, var(--brand) 30%, var(--line));
  background: #fff;
  outline: none;
  transform: translateY(-1px);
}

.cal-cell.is-today .cal-day-num {
  background: var(--brand);
  color: #f6f1e5;
  border-radius: 999px;
  width: 1.65rem;
  height: 1.65rem;
  display: grid;
  place-items: center;
}

.cal-cell.is-selected {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 12%, #fffefb);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 25%, transparent);
}

.cal-dots {
  display: flex;
  gap: 0.18rem;
  justify-content: center;
  min-height: 0.4rem;
}

.cal-dot {
  width: 0.38rem;
  height: 0.38rem;
  border-radius: 50%;
  background: var(--brand-2);
}

.cal-day-num {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.65rem;
}

.day-title {
  margin: 0 0 0.45rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.empty-hint {
  display: inline-block;
  margin-top: 0.35rem;
  font-size: 0.85rem;
}

@media (max-width: 420px) {
  .cal-cell {
    min-height: 2.75rem;
    border-radius: 10px;
  }
}

.status-line {
  min-height: 1.4rem;
  margin-bottom: 0.75rem;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.events {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.7rem;
}

.events {
  gap: 0.4rem;
}

.event-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.3rem;
  align-items: stretch;
}

.event-card {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #fffefb, #f6f1e6);
  border-radius: 12px;
  padding: 0.55rem 0.7rem;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  font: inherit;
  color: inherit;
  min-width: 0;
}

.event-card--compact {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: center;
  border-left: 4px solid var(--evt-color, var(--brand-2));
  background: var(--evt-bg, #fffefb);
  min-height: 3rem;
  padding: 0.55rem 0.65rem 0.55rem 0.75rem;
  cursor: default;
}

.event-card--compact .evt-open {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0.1rem 0;
  margin: 0;
  display: grid;
  grid-template-columns: 4rem minmax(0, 1fr);
  gap: 0.65rem;
  align-items: center;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  min-width: 0;
}

.event-card--compact .evt-time {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--evt-color, var(--brand-2));
  font-variant-numeric: tabular-nums;
}

.event-card--compact .evt-main {
  display: grid;
  gap: 0.12rem;
  min-width: 0;
}

.event-card--compact .name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.event-card--compact .evt-meta {
  font-size: 0.8rem;
  color: var(--ink-soft);
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.evt-msg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}

.msg-btn {
  appearance: none;
  border: 0;
  border-radius: 10px;
  min-height: 2.35rem;
  padding: 0.4rem 0.7rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  white-space: nowrap;
}

.msg-btn.whatsapp {
  background: var(--whatsapp);
}

.msg-btn.email {
  background: var(--email);
}

.msg-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.msg-btn:hover:not(:disabled),
.msg-btn:focus-visible:not(:disabled) {
  filter: brightness(1.05);
  outline: none;
}

.cal-layout.is-cal-collapsed .event-card--compact {
  padding: 0.7rem 0.85rem;
  min-height: 3.25rem;
}

.cal-layout.is-cal-collapsed .event-card--compact .name {
  font-size: 1.12rem;
}

@media (max-width: 700px) {
  .event-card--compact {
    grid-template-columns: 1fr;
    gap: 0.5rem;
    align-items: stretch;
  }

  .event-card--compact .evt-open {
    grid-template-columns: 3.5rem minmax(0, 1fr);
  }

  .evt-msg-actions {
    justify-content: stretch;
  }

  .msg-btn {
    flex: 1;
    min-height: 2.55rem;
  }

  .msg-btn span {
    display: inline;
  }
}

@media (min-width: 701px) and (max-width: 1100px) {
  .msg-btn span {
    display: none;
  }

  .msg-btn {
    width: 2.45rem;
    padding: 0;
  }
}

.missing-inline {
  color: var(--danger);
  font-weight: 500;
}

.event-actions {
  display: flex;
  flex-direction: row;
  gap: 0.25rem;
  align-items: center;
}

.icon-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fffefb;
  color: var(--brand);
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 10px;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  border-color: color-mix(in srgb, var(--brand) 35%, var(--line));
  background: #fff;
  outline: none;
}

.icon-btn.delete {
  color: var(--danger);
}

.icon-btn.delete:hover,
.icon-btn.delete:focus-visible {
  border-color: color-mix(in srgb, var(--danger) 40%, var(--line));
  background: rgba(180, 35, 24, 0.06);
}

.event-card:hover {
  border-color: color-mix(in srgb, var(--brand) 28%, var(--line));
  box-shadow: 0 8px 18px rgba(11, 61, 46, 0.08);
}

.evt-open:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--brand) 55%, transparent);
  outline-offset: 2px;
  border-radius: 8px;
}

.color-field {
  border: 0;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.color-field legend {
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0;
  margin-bottom: 0.15rem;
}

.color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.color-swatch {
  appearance: none;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 999px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.color-swatch.is-selected {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--ink);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: rgba(11, 61, 46, 0.07);
}

.chip.missing {
  background: rgba(180, 35, 24, 0.08);
  color: var(--danger);
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.65rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  transition: transform 0.15s ease, filter 0.15s ease, background 0.15s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--brand);
  color: #f6f1e5;
}

.btn.primary.lg {
  padding: 0.9rem 1.35rem;
  font-size: 1.02rem;
}

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

.btn.whatsapp {
  background: var(--whatsapp);
  color: #fff;
  flex: 1;
  min-height: 3.1rem;
  border-radius: 14px;
}

.btn.email {
  background: var(--email);
  color: #fff;
  flex: 1;
  min-height: 3.1rem;
  border-radius: 14px;
}

.hint {
  margin: 1rem 0 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.sheet {
  border: 0;
  padding: 0;
  width: min(560px, 100%);
  max-height: min(92vh, 860px);
  border-radius: 24px 24px 0 0;
  margin: auto auto 0;
  background: var(--paper-2);
  box-shadow: var(--shadow);
}

.sheet::backdrop {
  background: rgba(10, 28, 20, 0.45);
  backdrop-filter: blur(4px);
}

.sheet-inner {
  display: flex;
  flex-direction: column;
  max-height: min(92vh, 860px);
}

.sheet-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1rem 0.7rem;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--paper-2);
}

.sheet-head h2 {
  font-size: 1.15rem;
  margin: 0;
}

.sheet-body {
  padding: 1.1rem 1.15rem 1.5rem;
  overflow: auto;
}

.client-name {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
  margin: 0 0 1rem;
  line-height: 1.15;
}

.meta {
  margin: 0 0 1.1rem;
  display: grid;
  gap: 0.85rem;
}

.meta dt {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

.meta dd {
  margin: 0.15rem 0 0;
  font-weight: 600;
}

.preview {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.7rem 0.85rem;
  margin-bottom: 1.1rem;
  background: #f3eee3;
}

.preview summary {
  cursor: pointer;
  font-weight: 600;
}

.preview pre {
  white-space: pre-wrap;
  margin: 0.7rem 0 0;
  font-family: var(--font-body);
  font-size: 0.92rem;
  color: var(--ink-soft);
}

.cta-row {
  display: flex;
  gap: 0.7rem;
}

.settings {
  display: grid;
  gap: 1rem;
}

.settings label {
  display: grid;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.92rem;
}

.field-hint {
  font-weight: 400;
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.settings textarea {
  resize: vertical;
  min-height: 7rem;
}

.empty {
  padding: 1.4rem 0.4rem;
  color: var(--ink-soft);
  text-align: center;
}

@media (min-width: 720px) {
  .sheet {
    border-radius: 24px;
    margin: auto;
  }

  .topbar {
    padding-inline: 1.75rem;
  }
}

/* —— Landing —— */
.landing {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1.75rem;
  padding: 2rem 1.25rem 3rem;
  position: relative;
  z-index: 1;
  animation: rise 0.5s ease both;
}

.logo-hit {
  border: 0;
  background: transparent;
  /* Non deve sembrare cliccabile (accesso supervisor nascosto) */
  cursor: default;
  display: grid;
  justify-items: center;
  gap: 0.55rem;
  padding: 0.5rem;
  color: inherit;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.logo-svg {
  filter: drop-shadow(0 16px 28px rgba(11, 61, 46, 0.28));
  animation: logo-in 0.7s ease both;
}

@keyframes logo-in {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.logo-title {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.logo-sub {
  color: var(--ink-soft);
  font-size: 0.95rem;
  margin-top: -0.25rem;
}

.landing-actions {
  width: min(320px, 100%);
  display: grid;
  gap: 0.85rem;
}

.landing-foot {
  min-height: 1.25rem;
  color: var(--ink-soft);
  font-size: 0.88rem;
  text-align: center;
  margin: 0;
}

.suspended-msg {
  margin: 0;
  padding: 1rem 1.1rem;
  border-radius: 14px;
  background: rgba(180, 35, 24, 0.1);
  border: 1px solid rgba(180, 35, 24, 0.35);
  color: var(--danger);
  text-align: center;
  font-weight: 600;
  line-height: 1.4;
}

.suspend-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #f3eee3;
}

.btn.danger {
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  white-space: nowrap;
}

.btn.ok {
  background: var(--brand-2);
  color: #fff;
  border-radius: 999px;
  white-space: nowrap;
}

#screen-app[hidden],
#screen-landing[hidden],
[hidden] {
  display: none !important;
}

.list-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.65rem;
  justify-content: flex-end;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 520px) {
  .list-head {
    flex-direction: column;
    align-items: stretch;
  }

  .list-tools {
    justify-content: stretch;
  }

  .list-tools .btn.primary {
    width: 100%;
  }

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

.import-hint {
  margin: 0;
  padding: 0.85rem 0.95rem;
  border-radius: 12px;
  background: #f3eee3;
  border: 1px solid var(--line);
  white-space: pre-wrap;
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--ink-soft);
  line-height: 1.45;
}

.settings-section {
  margin: 0.6rem 0 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
}
