:root {
  color-scheme: light;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;

  --background: #f3f6fb;
  --surface: #ffffff;
  --surface-muted: #eef3fb;
  --primary: #172554;
  --primary-light: #1e3a8a;
  --accent: #f59e0b;
  --text: #172033;
  --muted: #64748b;
  --border: #dbe4f0;
  --danger: #b91c1c;
  --success: #047857;
  --shadow: 0 15px 35px rgb(15 23 42 / 10%);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--background);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--background);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.login-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding:
    max(24px, env(safe-area-inset-top))
    18px
    max(24px, env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at top right, #dbeafe 0, transparent 35%),
    linear-gradient(145deg, #eff6ff, #f8fafc);
}

.login-shell {
  width: min(100%, 440px);
}

.login-card,
.content-card,
.welcome-panel {
  border: 1px solid rgb(219 228 240 / 85%);
  border-radius: 24px;
  background: rgb(255 255 255 / 96%);
  box-shadow: var(--shadow);
}

.login-card {
  padding: 28px;
}

.app-logo {
  display: grid;
  width: 68px;
  height: 68px;
  margin-bottom: 20px;
  place-items: center;
  border-radius: 22px;
  color: white;
  background:
    linear-gradient(145deg, var(--primary-light), var(--primary));
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -1px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(28px, 7vw, 38px);
  letter-spacing: -1px;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
}

.subtitle {
  margin-bottom: 24px;
  color: var(--muted);
  line-height: 1.6;
}

label,
legend {
  font-weight: 700;
}

label {
  display: block;
  margin: 18px 0 8px;
}

input[type="text"],
input[type="password"],
select,
textarea {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  outline: none;
  background: white;
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 4px rgb(30 58 138 / 10%);
}

fieldset {
  margin: 22px 0 0;
  padding: 0;
  border: 0;
}

.actor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.actor-option {
  margin: 0;
}

.actor-option input {
  position: absolute;
  opacity: 0;
}

.actor-option span {
  display: grid;
  min-height: 52px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-muted);
  cursor: pointer;
}

.actor-option input:checked + span {
  border-color: var(--primary);
  color: white;
  background: var(--primary);
}

.primary-button,
.text-button {
  border: 0;
  cursor: pointer;
}

.primary-button {
  display: grid;
  width: 100%;
  min-height: 52px;
  margin-top: 24px;
  place-items: center;
  border-radius: 15px;
  color: white;
  background: var(--primary);
  font-weight: 800;
  text-decoration: none;
}

.primary-button:active {
  transform: translateY(1px);
}

.button-link {
  padding: 10px 14px;
}

.text-button {
  padding: 10px 12px;
  color: white;
  background: transparent;
  font-weight: 700;
}

.alert {
  margin-bottom: 18px;
  padding: 13px 15px;
  border-radius: 13px;
  line-height: 1.45;
}

.alert-error {
  color: #7f1d1d;
  background: #fee2e2;
}

.alert-success {
  color: #065f46;
  background: #d1fae5;
}

.topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  min-height: 66px;
  align-items: center;
  justify-content: space-between;
  padding:
    max(10px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    10px
    max(16px, env(safe-area-inset-left));
  color: white;
  background: var(--primary);
  box-shadow: 0 8px 20px rgb(15 23 42 / 18%);
}

.topbar strong {
  display: block;
  font-size: 18px;
}

.current-user {
  display: block;
  margin-top: 3px;
  color: #dbeafe;
  font-size: 12px;
}

.topbar form {
  margin: 0;
}

.page-shell {
  width: min(100%, 1100px);
  margin: 0 auto;
  padding:
    22px
    max(16px, env(safe-area-inset-right))
    max(34px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}

.welcome-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px;
}

.welcome-panel p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--primary-light);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.status-badge {
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--success);
  background: #d1fae5;
  font-size: 13px;
  font-weight: 800;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 18px 0;
}

.summary-card {
  min-height: 116px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 14px;
}

.summary-card strong {
  display: block;
  margin-top: 10px;
  color: var(--primary);
  font-size: 32px;
}

.content-card {
  padding: 22px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.empty-state {
  padding: 32px 18px;
  border: 1px dashed var(--border);
  border-radius: 18px;
  text-align: center;
  background: var(--surface-muted);
}

.empty-state p {
  max-width: 520px;
  margin: 8px auto 0;
  color: var(--muted);
  line-height: 1.6;
}

.event-list {
  display: grid;
  gap: 10px;
}

.event-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 15px;
}

.event-row p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.event-meta {
  display: grid;
  flex: 0 0 auto;
  justify-items: end;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.priority {
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.priority-normale {
  color: #1e3a8a;
  background: #dbeafe;
}

.priority-importante {
  color: #92400e;
  background: #fef3c7;
}

.priority-urgente {
  color: #991b1b;
  background: #fee2e2;
}

@media (max-width: 700px) {
  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .welcome-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .event-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .event-meta {
    width: 100%;
    justify-items: start;
  }
}

@media (max-width: 420px) {
  .login-card {
    padding: 22px 18px;
  }

  .summary-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .summary-card {
    min-height: 105px;
    padding: 14px;
  }

  .summary-card strong {
    font-size: 27px;
  }

  .content-card,
  .welcome-panel {
    padding: 18px;
  }
}
/* === Funzioni eventi - Fase 5 === */
.topbar-actions,
.badge-row,
.filter-actions,
.action-grid,
.inline-fields,
.recipient-grid {
  display: flex;
  align-items: center;
  gap: 10px;
}

.text-link {
  color: white;
  font-weight: 800;
  text-decoration: none;
}

.compact-button {
  width: auto;
  min-width: 150px;
  margin-top: 0;
  padding: 0 18px;
}

.secondary-button,
.ghost-button,
.success-button,
.danger-button,
.whatsapp-button {
  display: inline-grid;
  min-height: 46px;
  place-items: center;
  padding: 10px 16px;
  border: 0;
  border-radius: 13px;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
}

.secondary-button {
  color: var(--primary);
  background: #dbeafe;
}

.ghost-button {
  border: 1px solid var(--border);
  color: var(--text);
  background: white;
}

.success-button {
  color: #065f46;
  background: #d1fae5;
}

.danger-button {
  color: white;
  background: #b91c1c;
}

.whatsapp-button {
  color: #064e3b;
  background: #bbf7d0;
}

.inline-button {
  margin-top: 12px;
}

.form-page,
.detail-page {
  padding-bottom: 110px;
}

.stack-form {
  display: grid;
  gap: 16px;
}

.form-grid,
.filter-grid,
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.filter-grid {
  grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(140px, 1fr));
  align-items: end;
  margin-top: 20px;
}

.field {
  min-width: 0;
}

.field label {
  margin-top: 0;
}

.wide-field {
  grid-column: 1 / -1;
}

textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  outline: none;
  color: var(--text);
  background: white;
  resize: vertical;
}

input[type="search"],
input[type="datetime-local"],
input[type="date"],
input[type="number"],
input[type="tel"] {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  outline: none;
  color: var(--text);
  background: white;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.category-option,
.recipient-option {
  margin: 0;
}

.category-option input,
.recipient-option input {
  position: absolute;
  opacity: 0;
}

.category-option span,
.recipient-option span {
  display: grid;
  min-height: 54px;
  place-items: center;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  background: var(--surface-muted);
  text-align: center;
  cursor: pointer;
}

.category-option input:checked + span,
.recipient-option input:checked + span {
  border-color: var(--primary);
  color: white;
  background: var(--primary);
}

.recipient-grid {
  align-items: stretch;
  margin-top: 14px;
}

.recipient-option {
  flex: 1;
}

.field-help,
.muted-text {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.checkbox-field {
  display: flex;
  align-items: end;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  margin: 0;
}

.hidden {
  display: none !important;
}

.reminders-list {
  display: grid;
  gap: 12px;
}

.reminder-row {
  display: grid;
  grid-template-columns: 1fr 1.3fr 1.5fr auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-muted);
}

.inline-fields {
  align-items: stretch;
}

.inline-fields input {
  width: 35%;
}

.inline-fields select {
  width: 65%;
}

.danger-text {
  min-height: 42px;
  padding: 8px;
  border: 0;
  color: #b91c1c;
  background: transparent;
  font-weight: 800;
  cursor: pointer;
}

.sticky-submit {
  position: sticky;
  z-index: 8;
  bottom: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgb(255 255 255 / 94%);
  box-shadow: 0 15px 35px rgb(15 23 42 / 15%);
  backdrop-filter: blur(12px);
}

.list-card {
  margin-top: 16px;
}

.event-row-link {
  color: inherit;
  text-decoration: none;
  transition: transform .15s ease, border-color .15s ease;
}

.event-row-link:hover {
  border-color: #93c5fd;
  transform: translateY(-1px);
}

.status,
.neutral-badge {
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status-da-fare {
  color: #1e3a8a;
  background: #dbeafe;
}

.status-preso-in-carico {
  color: #5b21b6;
  background: #ede9fe;
}

.status-completato {
  color: #065f46;
  background: #d1fae5;
}

.status-rimandato {
  color: #92400e;
  background: #fef3c7;
}

.status-annullato {
  color: #991b1b;
  background: #fee2e2;
}

.neutral-badge {
  color: #334155;
  background: #e2e8f0;
}

.event-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 16px 0;
}

.action-grid form {
  margin: 0;
}

.action-button {
  width: 100%;
  margin: 0;
}

.detail-grid {
  margin: 18px 0 0;
}

.detail-grid div {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-muted);
}

.detail-grid dt {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-grid dd {
  margin: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.prose-block {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.prose-block p {
  margin-bottom: 0;
  white-space: pre-wrap;
  line-height: 1.65;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.tag-list span {
  padding: 6px 10px;
  border-radius: 999px;
  color: #1e3a8a;
  background: #dbeafe;
  font-size: 13px;
  font-weight: 800;
}

.checklist-view {
  display: grid;
  gap: 8px;
  margin: 18px 0 0;
  padding-left: 22px;
}

.reminder-summary-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.reminder-summary {
  display: grid;
  gap: 4px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-muted);
}

.reminder-summary span {
  color: var(--muted);
  font-size: 13px;
}

.postpone-form,
.whatsapp-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
  margin-top: 18px;
}

.whatsapp-form .wide-field {
  grid-column: 1 / -1;
}

.history-block {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.history-block p {
  margin: 7px 0;
  color: var(--muted);
  font-size: 14px;
}

.danger-zone {
  border-color: #fecaca;
}

@media (max-width: 850px) {
  .category-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-grid,
  .action-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 600px) {
  .form-grid,
  .filter-grid,
  .detail-grid,
  .action-grid,
  .postpone-form,
  .whatsapp-form {
    grid-template-columns: 1fr;
  }

  .wide-field {
    grid-column: auto;
  }

  .category-grid {
    grid-template-columns: 1fr 1fr;
  }

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

  .event-hero,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .compact-button {
    width: 100%;
  }

  .sticky-submit {
    bottom: 8px;
  }

  .sticky-submit > * {
    flex: 1;
  }
}
