:root {
  --lime: #7ac143;
  --lime-deep: #5a9e2e;
  --forest: #1f4d2e;
  --forest-2: #163821;
  --sun: #f5a623;
  --sun-soft: #ffe8b8;
  --cream: #f7faf4;
  --paper: #ffffff;
  --ink: #1a2e22;
  --muted: #5c7264;
  --line: rgba(31, 77, 46, 0.12);
  --ok: #5a9e2e;
  --warn: #c45c12;
  --shadow: 0 16px 48px rgba(22, 56, 33, 0.1);
  --radius: 16px;
  --font-display: "Nunito", system-ui, sans-serif;
  --font-body: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(900px 480px at 0% 0%, rgba(122, 193, 67, 0.18), transparent 55%),
    radial-gradient(700px 420px at 100% 8%, rgba(245, 166, 35, 0.12), transparent 50%),
    linear-gradient(180deg, #f4f8f0 0%, var(--cream) 40%, #eef5ea 100%);
}

#app { min-height: 100vh; display: flex; flex-direction: column; }

/* Header */
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.85rem 1.5rem; gap: 1rem; flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 40;
}
.brand { cursor: pointer; display: flex; flex-direction: column; gap: 0.15rem; }
.logo-mark { display: flex; align-items: baseline; gap: 0.35rem; line-height: 1; }
.logo-up {
  font-family: var(--font-display); font-weight: 800; font-size: 1.75rem;
  color: var(--lime); letter-spacing: -0.03em;
  text-shadow: 0 1px 0 #fff;
}
.logo-station {
  font-family: var(--font-display); font-weight: 800; font-size: 1.15rem;
  color: var(--forest); letter-spacing: 0.04em;
}
.brand-tag { font-size: 0.78rem; color: var(--muted); }

.nav { display: flex; gap: 0.35rem; flex-wrap: wrap; align-items: center; }
.nav a, .nav button {
  font: inherit; border: 0; background: transparent; color: var(--ink);
  padding: 0.5rem 0.9rem; border-radius: 999px; cursor: pointer; text-decoration: none;
  font-weight: 500; font-size: 0.95rem;
}
.nav a:hover, .nav button:hover { background: rgba(122, 193, 67, 0.14); }
.nav a.active { background: var(--forest); color: #fff; }
.nav .nav-cta {
  background: var(--lime); color: #fff; font-weight: 700;
  box-shadow: 0 6px 18px rgba(122, 193, 67, 0.35);
}
.nav .nav-cta:hover { background: var(--lime-deep); color: #fff; }

.main { flex: 1; width: 100%; }
.main-pad { width: min(1120px, 100%); margin: 0 auto; padding: 1.25rem 1.5rem 2.5rem; }
.main-pad-wide { width: min(1560px, 100%); padding-left: 1.25rem; padding-right: 1.25rem; }

/* Landing */
.landing { width: 100%; }
.hero-band {
  position: relative;
  min-height: min(78vh, 640px);
  display: flex; align-items: flex-end;
  color: #fff;
  background:
    linear-gradient(115deg, rgba(22, 56, 33, 0.92) 0%, rgba(31, 77, 46, 0.72) 45%, rgba(122, 193, 67, 0.35) 100%),
    url("/assets/flyer-ref.png") center 20% / cover no-repeat;
}
.hero-band::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(22, 56, 33, 0.75), transparent 55%);
  pointer-events: none;
}
.hero-inner {
  position: relative; z-index: 1;
  width: min(1120px, 100%); margin: 0 auto;
  padding: 3.5rem 1.5rem 3rem;
}
.hero-kicker {
  display: inline-block; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--sun-soft); margin-bottom: 0.75rem;
}
.hero-inner h1 {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(2.4rem, 6vw, 4rem); margin: 0 0 0.5rem;
  letter-spacing: -0.03em; line-height: 1.05;
}
.hero-inner h1 .lime { color: var(--lime); }
.hero-inner .lede {
  margin: 0 0 1.5rem; max-width: 38ch; font-size: 1.15rem;
  color: rgba(255, 255, 255, 0.9); line-height: 1.45;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }

.section {
  width: min(1120px, 100%); margin: 0 auto; padding: 2.75rem 1.5rem;
}
.section-head { margin-bottom: 1.5rem; max-width: 40rem; }
.section-head h2 {
  font-family: var(--font-display); font-weight: 800; font-size: clamp(1.6rem, 3vw, 2.1rem);
  color: var(--forest); margin: 0 0 0.4rem; letter-spacing: -0.02em;
}
.section-head p { margin: 0; color: var(--muted); font-size: 1.05rem; }

.cards { display: grid; gap: 1rem; }
@media (min-width: 720px) {
  .cards-2 { grid-template-columns: 1fr 1fr; }
  .cards-3 { grid-template-columns: repeat(3, 1fr); }
}
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.35rem 1.4rem; box-shadow: var(--shadow);
}
.card h3 {
  font-family: var(--font-display); font-weight: 800; font-size: 1.15rem;
  color: var(--forest); margin: 0 0 0.5rem;
}
.card .time {
  display: inline-block; font-weight: 700; color: var(--lime-deep);
  background: rgba(122, 193, 67, 0.14); padding: 0.25rem 0.65rem;
  border-radius: 999px; font-size: 0.85rem; margin-bottom: 0.75rem;
}
.card ul { margin: 0; padding-left: 1.1rem; color: var(--muted); }
.card li { margin: 0.35rem 0; }

.pill-row { display: flex; flex-wrap: wrap; gap: 0.55rem; margin-top: 0.5rem; }
.pill {
  background: rgba(31, 77, 46, 0.06); border: 1px solid var(--line);
  color: var(--forest); padding: 0.55rem 0.9rem; border-radius: 999px;
  font-weight: 600; font-size: 0.9rem;
}

.cta-band {
  margin: 1rem 1.5rem 2.5rem; border-radius: 22px; overflow: hidden;
  background: linear-gradient(120deg, var(--forest-2), var(--forest) 50%, var(--lime-deep));
  color: #fff; padding: 2rem 1.75rem;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem;
  width: min(1120px, calc(100% - 3rem)); margin-left: auto; margin-right: auto;
}
.cta-band h2 { font-family: var(--font-display); margin: 0 0 0.35rem; font-size: 1.6rem; }
.cta-band p { margin: 0; opacity: 0.9; max-width: 36ch; }

.foot {
  background: var(--forest-2); color: rgba(255, 255, 255, 0.85);
  margin-top: auto;
}
.foot-inner {
  width: min(1120px, 100%); margin: 0 auto; padding: 1.75rem 1.5rem 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem 1.75rem;
}
.foot-block { min-width: 0; }
.foot-brand { color: var(--lime); font-family: var(--font-display); font-size: 1.1rem; }
.foot-brand-alt { font-size: 1.02rem; }
.foot-role { margin: 0.15rem 0 0 !important; font-size: 0.82rem !important; opacity: 0.7 !important; }
.foot p { margin: 0.35rem 0 0; font-size: 0.9rem; opacity: 0.85; line-height: 1.45; }
.foot a { color: #fff; text-decoration: underline; text-underline-offset: 2px; }
.foot a:hover { color: var(--lime); }
.foot-social { margin-top: 0.55rem !important; }
.foot-credit {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 0 1.5rem 1.15rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.65);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 0.85rem;
}
.foot-credit .foot-credit-link,
.foot-credit .dc-credit-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: rgba(255, 255, 255, 0.65);
  text-decoration: none;
}
.foot-credit .foot-credit-link:hover,
.foot-credit .dc-credit-link:hover {
  color: var(--lime);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.foot-credit .dc-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 4px;
  flex-shrink: 0;
}
.remember-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.25rem 0 1rem;
  color: var(--muted);
  font-size: 0.92rem;
  user-select: none;
}
.remember-row input[type="checkbox"] {
  width: auto;
  margin: 0;
  accent-color: var(--lime-deep);
}

/* App panels */
.panel {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.25rem 1.35rem; margin: 1rem 0;
}
.panel h2 {
  font-family: var(--font-display); font-weight: 800; margin: 0 0 1rem;
  font-size: 1.35rem; color: var(--forest);
}
.panel-head {
  display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between;
  gap: 0.75rem 1.25rem; margin-bottom: 0.75rem;
}
.panel-head h2 { margin-bottom: 0.35rem; }
.panel-head .muted { margin: 0; }
.search-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem;
  margin: 0;
}
.search-bar input[type="search"] {
  width: min(260px, 70vw); margin: 0; padding: 0.55rem 0.75rem;
}

.grid { display: grid; gap: 1rem; }
@media (min-width: 800px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .cal-layout { grid-template-columns: 1.35fr 0.9fr; align-items: start; }
}

label { display: block; font-size: 0.88rem; color: var(--muted); margin-bottom: 0.3rem; font-weight: 500; }
input, select, textarea {
  width: 100%; padding: 0.7rem 0.8rem; border-radius: 12px;
  border: 1px solid var(--line); background: #fff; font: inherit; margin-bottom: 0.85rem;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(122, 193, 67, 0.45); border-color: var(--lime);
}

button.btn, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  border: 0; border-radius: 12px; padding: 0.72rem 1.15rem; cursor: pointer;
  font: inherit; font-weight: 700; background: var(--lime); color: #fff;
  text-decoration: none;
}
button.btn:hover, .btn:hover { background: var(--lime-deep); }
button.btn.secondary, .btn.secondary {
  background: transparent; color: var(--forest); border: 1px solid rgba(31, 77, 46, 0.25);
}
button.btn.secondary:hover, .btn.secondary:hover { background: rgba(122, 193, 67, 0.1); }
button.btn.btn-sm, .btn.btn-sm {
  padding: 0.38rem 0.72rem;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 10px;
  line-height: 1.2;
  white-space: nowrap;
}

/* Wrapper tabella (senza scroll orizzontale forzato) */
.table-wrap {
  width: 100%;
  margin: 0.35rem 0 0.15rem;
}

/* Gruppo pulsanti: flex sicuro dentro span, non sul td */
.btn-group {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
}
td.td-actions {
  white-space: normal;
  vertical-align: middle;
  text-align: right;
  width: 1%;
  min-width: 11rem;
  padding-left: 0.75rem;
}
th.th-actions {
  text-align: right;
  width: 1%;
  min-width: 11rem;
}

/* Toolbar dettaglio (PDF, stato, ecc.) */
.detail-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
  margin-top: 1.15rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.detail-toolbar .btn-group {
  justify-content: flex-start;
}
.status-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: min(220px, 100%);
  margin: 0;
}
.status-field label {
  margin: 0;
}
.status-field select {
  margin: 0;
  width: auto;
  min-width: 10.5rem;
  padding: 0.45rem 0.65rem;
}
.detail-meta {
  display: grid;
  gap: 0.35rem 1.25rem;
  margin: 0.75rem 0 1rem;
}
@media (min-width: 640px) {
  .detail-meta {
    grid-template-columns: 1fr 1fr;
  }
}
.detail-meta p {
  margin: 0;
}
.detail-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin: 0 0 0.35rem;
}
.detail-title-row h2 {
  margin: 0;
  flex: 1 1 auto;
}
.detail-title-row .badge {
  flex: 0 0 auto;
}

/* Blocco azioni legacy fuori tabella */
div.td-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.day-actions {
  margin-top: 0.55rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
button.btn.ghost { background: rgba(255,255,255,0.15); color: #fff; border: 1px solid rgba(255,255,255,0.35); }
/* Ghost su sfondo chiaro (ricerca in pannello) */
.panel .btn.ghost,
.search-bar .btn.ghost {
  background: transparent;
  color: var(--forest);
  border: 1px solid rgba(31, 77, 46, 0.25);
}
.panel .btn.ghost:hover,
.search-bar .btn.ghost:hover {
  background: rgba(122, 193, 67, 0.1);
  color: var(--forest);
}
button.btn.warn { background: var(--sun); color: var(--forest-2); }
button.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  font-size: 0.95rem;
}
.table th, .table td {
  text-align: left;
  padding: 0.85rem 0.55rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table tbody tr:last-child th,
.table tbody tr:last-child td {
  border-bottom: none;
}
.table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid rgba(31, 77, 46, 0.18);
}
.badge {
  display: inline-block; padding: 0.18rem 0.55rem; border-radius: 999px;
  font-size: 0.76rem; font-weight: 700; background: rgba(122, 193, 67, 0.16); color: var(--lime-deep);
}
.badge.bozza { background: rgba(92, 114, 100, 0.15); color: var(--muted); }
.badge.assegnata { background: rgba(122, 193, 67, 0.18); color: var(--ok); }
.badge.completata { background: rgba(26, 46, 34, 0.12); color: var(--ink); }
.badge.annullata { background: #ffe8e2; color: #8a2a18; }
.badge.in_approvazione { background: rgba(245, 166, 35, 0.22); color: var(--warn); }
.badge.accettato { background: rgba(122, 193, 67, 0.18); color: var(--ok); }
.badge.chiuso { background: rgba(26, 46, 34, 0.1); color: var(--ink); }

.msg { padding: 0.75rem 1rem; border-radius: 12px; margin: 0.5rem 0; }
.msg.err { background: #ffe8e2; color: #8a2a18; }
.msg.ok { background: #e7f6dc; color: #2f6a1a; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 1rem 0; }

.table tbody tr.notif-pending { background: #fff7e0; }
.table tbody tr.notif-unread { background: #f2f8ec; }

/* Calendar */
.cal-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap;
  margin-bottom: 1rem;
}
.cal-toolbar h2 { margin: 0; }
.cal-nav { display: flex; align-items: center; gap: 0.4rem; }
.cal-month-label {
  font-family: var(--font-display); font-weight: 800; color: var(--forest);
  min-width: 11rem; text-align: center; font-size: 1.15rem;
}

.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.4rem;
}
.cal-dow {
  text-align: center; font-size: 0.75rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em; padding: 0.35rem 0;
}
.cal-cell {
  min-height: 72px; border: 1px solid var(--line); border-radius: 12px;
  background: #fff; padding: 0.4rem; cursor: pointer; text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
  display: flex; flex-direction: column; gap: 0.2rem;
}
.cal-cell:hover { border-color: var(--lime); box-shadow: 0 6px 18px rgba(122, 193, 67, 0.15); }
.cal-cell.out { opacity: 0.38; background: #f3f6f1; cursor: default; }
.cal-cell.out:hover { border-color: var(--line); box-shadow: none; }
.cal-cell.today { outline: 2px solid var(--sun); outline-offset: -1px; }
.cal-cell.selected { border-color: var(--forest); background: rgba(122, 193, 67, 0.1); }
.cal-cell.has-items { border-color: rgba(122, 193, 67, 0.45); }
.cal-daynum { font-weight: 700; font-size: 0.95rem; color: var(--forest); }
.cal-dots { display: flex; flex-wrap: wrap; gap: 3px; margin-top: auto; }
.cal-dot {
  width: 7px; height: 7px; border-radius: 50%;
}
.cal-dot.ev { background: var(--lime); }
.cal-dot.bk { background: var(--sun); }
.cal-dot.qt { background: var(--forest); }
.cal-dot.sc { background: #c0392b; }

.day-panel h3 {
  font-family: var(--font-display); font-weight: 800; color: var(--forest);
  margin: 0 0 0.75rem; font-size: 1.15rem;
}
.day-item {
  border-top: 1px solid var(--line); padding: 0.7rem 0; font-size: 0.92rem;
}
.day-item:first-of-type {
  border-top: none;
  padding-top: 0;
}
.day-item .kind {
  display: inline-block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; margin-bottom: 0.25rem;
  color: var(--lime-deep);
}
.day-item .kind.bk { color: var(--warn); }
.day-item .kind.qt { color: var(--forest); }
.day-item .kind.sc { color: #c0392b; }

.legend {
  display: flex; flex-wrap: wrap; gap: 0.85rem; margin-top: 0.85rem;
  font-size: 0.82rem; color: var(--muted);
}
.legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.legend i {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block;
}
.legend .ev { background: var(--lime); }
.legend .bk { background: var(--sun); }
.legend .qt { background: var(--forest); }

/* Vetrina promo landing */
.promo-feed {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
  width: min(920px, 100%);
  margin: 0 auto;
}
.promo-item {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.promo-img {
  width: 100%;
  height: auto;
  max-height: none;
  object-fit: contain;
  display: block;
  border-radius: 4px;
  box-shadow: 0 12px 36px rgba(22, 56, 33, 0.12);
  background: rgba(31, 77, 46, 0.04);
}
.promo-copy h3 {
  font-family: var(--font-display);
  font-size: 1.45rem;
  color: var(--forest);
  margin: 0 0 0.4rem;
}
.promo-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  white-space: normal;
  font-size: 1.02rem;
}

/* Modal */
.modal {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(22, 56, 33, 0.45); }
.modal-card {
  position: relative; z-index: 1; width: min(520px, 100%);
  background: #fff; border-radius: 18px; padding: 1.5rem 1.35rem 1.35rem;
  box-shadow: var(--shadow); max-height: 85vh; overflow: auto;
}
.modal-close {
  position: absolute; top: 0.55rem; right: 0.7rem; border: 0; background: transparent;
  font-size: 1.5rem; cursor: pointer; color: var(--muted); line-height: 1;
}

@media (max-width: 700px) {
  .cal-cell { min-height: 54px; padding: 0.3rem; }
  .cal-daynum { font-size: 0.85rem; }
  .hero-band { min-height: 70vh; }
}
