/* =============================================================================
   Rotaract Milano Duomo – Design system di base
   Token, reset, tipografia e componenti condivisi da tutte le pagine
   (sito pubblico, gestionale desktop, gestionale mobile, vista backup).
   ============================================================================= */

:root {
  color-scheme: light;
  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

  /* Brand (rosa Rotaract) */
  --brand-50: #fff1f6;
  --brand-100: #ffe1ec;
  --brand-200: #ffc3d8;
  --brand-300: #ff94ba;
  --brand-400: #f2578f;
  --brand-500: #d81b60;
  --brand-600: #bd1553;
  --brand-700: #9c1145;
  --brand-800: #7a0e37;

  /* Neutri */
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  /* Accenti semantici */
  --teal-50: #f0fdfa;
  --teal-100: #ccfbf1;
  --teal-600: #0d9488;
  --teal-700: #0f766e;
  --green-50: #f0fdf4;
  --green-100: #dcfce7;
  --green-600: #16a34a;
  --green-700: #15803d;
  --amber-50: #fffbeb;
  --amber-100: #fef3c7;
  --amber-600: #d97706;
  --amber-700: #b45309;
  --red-50: #fef2f2;
  --red-100: #fee2e2;
  --red-600: #dc2626;
  --red-700: #b91c1c;
  --indigo-50: #eef2ff;
  --indigo-100: #e0e7ff;
  --indigo-600: #4f46e5;
  --indigo-700: #4338ca;
  --sky-50: #f0f9ff;
  --sky-100: #e0f2fe;
  --sky-700: #0369a1;

  /* Superfici e testo */
  --bg: #f4f5f9;
  --bg-accent: radial-gradient(1200px 600px at 10% -10%, rgba(216, 27, 96, 0.08), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(13, 148, 136, 0.07), transparent 60%);
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --border: #e6e9f0;
  --border-strong: #d3d8e2;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #64748b;
  --muted: #64748b;

  /* Alias legacy usati dal codice esistente */
  --primary: var(--brand-500);
  --secondary: #0d6efd;
  --card-bg: var(--surface);

  /* Geometria */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-pill: 999px;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 6px 16px -12px rgba(15, 23, 42, 0.18);
  --shadow: 0 2px 6px -2px rgba(15, 23, 42, 0.06), 0 18px 40px -24px rgba(15, 23, 42, 0.25);
  --shadow-lg: 0 10px 25px -10px rgba(15, 23, 42, 0.2), 0 30px 70px -30px rgba(15, 23, 42, 0.35);
  --ring: 0 0 0 3px rgba(216, 27, 96, 0.16);
  --ring-teal: 0 0 0 3px rgba(13, 148, 136, 0.18);

  --control-h: 2.7rem;
  --control-h-sm: 2.2rem;
  --transition: 160ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  background-image: var(--bg-accent);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding: 2rem;
}

h1,
h2,
h3,
h4,
h5 {
  margin: 0 0 0.35rem;
  color: var(--text);
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

h1 {
  font-size: clamp(1.6rem, 2.4vw, 2rem);
}

h2 {
  font-size: clamp(1.3rem, 2vw, 1.55rem);
}

h3 {
  font-size: 1.15rem;
}

h4 {
  font-size: 1rem;
}

p {
  margin: 0 0 0.75rem;
}

a {
  color: var(--brand-600);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-xs);
  background: var(--slate-100);
  color: var(--slate-700);
}

main {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

::selection {
  background: var(--brand-100);
  color: var(--brand-800);
}

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

/* -----------------------------------------------------------------------------
   Utilità
   ----------------------------------------------------------------------------- */

.hidden {
  display: none !important;
}

.muted {
  color: var(--text-3);
}

.text-sm {
  font-size: 0.86rem;
}

.text-xs {
  font-size: 0.78rem;
}

.text-strong {
  font-weight: 700;
  color: var(--text);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.cluster-between {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.eyebrow,
.badge-subtitle {
  margin: 0;
  color: var(--brand-600);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.badge-title {
  margin: 0;
  font-weight: 800;
  color: var(--text);
}

/* -----------------------------------------------------------------------------
   Card / pannelli
   ----------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

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

.card-header h2,
.card-header h3 {
  margin-bottom: 0.15rem;
}

.card-header p {
  margin: 0;
  color: var(--text-3);
}

.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.section-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
}

.section-card-header h3,
.section-card-header h4 {
  margin: 0;
}

.section-card-header p {
  margin: 0.15rem 0 0;
  color: var(--text-3);
  font-size: 0.9rem;
}

.section-card-body {
  padding: 1.25rem;
}

/* Statistiche */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.9rem;
}

.stat-card {
  --tone: var(--brand-500);
  --tone-soft: var(--brand-50);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 1rem 1.1rem 1rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  min-width: 0;
}

.stat-card::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--tone);
}

.stat-card > span,
.stat-card .stat-label {
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}

.stat-card > strong,
.stat-card .stat-value {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.15;
}

.stat-card > small,
.stat-card .stat-hint {
  color: var(--text-3);
  font-size: 0.82rem;
}

.stat-card[data-tone='teal'] {
  --tone: var(--teal-600);
  --tone-soft: var(--teal-50);
}

.stat-card[data-tone='green'] {
  --tone: var(--green-600);
  --tone-soft: var(--green-50);
}

.stat-card[data-tone='amber'] {
  --tone: var(--amber-600);
  --tone-soft: var(--amber-50);
}

.stat-card[data-tone='red'] {
  --tone: var(--red-600);
  --tone-soft: var(--red-50);
}

.stat-card[data-tone='indigo'] {
  --tone: var(--indigo-600);
  --tone-soft: var(--indigo-50);
}

.stat-card[data-tone='slate'] {
  --tone: var(--slate-600);
  --tone-soft: var(--slate-100);
}

.stat-card[data-tone='sky'] {
  --tone: var(--sky-700);
  --tone-soft: var(--sky-50);
}

/* -----------------------------------------------------------------------------
   Badge, pill, avatar
   ----------------------------------------------------------------------------- */

.badge,
.pill,
.status-pill {
  --tone-bg: var(--slate-100);
  --tone-fg: var(--slate-700);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.65rem;
  border-radius: var(--radius-pill);
  background: var(--tone-bg);
  color: var(--tone-fg);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.4;
  white-space: nowrap;
}

.badge[data-tone='brand'],
.badge[data-tone='primary'] {
  --tone-bg: var(--brand-50);
  --tone-fg: var(--brand-700);
}

.badge[data-tone='teal'],
.badge[data-tone='success'],
.status-pill[data-variant='success'] {
  --tone-bg: var(--green-100);
  --tone-fg: var(--green-700);
}

.badge[data-tone='amber'],
.badge[data-tone='warning'],
.status-pill[data-variant='warning'] {
  --tone-bg: var(--amber-100);
  --tone-fg: var(--amber-700);
}

.badge[data-tone='red'],
.badge[data-tone='danger'],
.status-pill[data-variant='danger'] {
  --tone-bg: var(--red-100);
  --tone-fg: var(--red-700);
}

.badge[data-tone='indigo'],
.badge[data-tone='info'] {
  --tone-bg: var(--indigo-100);
  --tone-fg: var(--indigo-700);
}

.badge[data-tone='sky'] {
  --tone-bg: var(--sky-100);
  --tone-fg: var(--sky-700);
}

.badge[data-tone='teal-soft'] {
  --tone-bg: var(--teal-100);
  --tone-fg: var(--teal-700);
}

.badge-dot::before {
  content: '';
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}

.count-pill {
  min-width: 2.1rem;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-pill);
  background: var(--slate-100);
  color: var(--slate-700);
  font-weight: 800;
  text-align: center;
  font-size: 0.85rem;
}

.avatar {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--brand-100), var(--brand-200));
  color: var(--brand-700);
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

/* -----------------------------------------------------------------------------
   Bottoni
   ----------------------------------------------------------------------------- */

button,
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: var(--control-h);
  padding: 0.55rem 1.15rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--brand-500);
  color: #fff;
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08), 0 8px 18px -12px rgba(216, 27, 96, 0.55);
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition),
    border-color var(--transition), color var(--transition), opacity var(--transition);
}

button:hover,
.btn:hover {
  background: var(--brand-600);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.08), 0 12px 22px -12px rgba(216, 27, 96, 0.6);
  text-decoration: none;
}

button:active,
.btn:active {
  transform: translateY(0);
}

button:disabled,
.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

button.secondary,
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}

button.secondary:hover,
.btn-secondary:hover {
  background: var(--surface-2);
  border-color: var(--slate-400);
  box-shadow: var(--shadow-sm);
}

button.ghost,
.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: transparent;
  box-shadow: none;
}

button.ghost:hover,
.btn-ghost:hover {
  background: var(--slate-100);
  color: var(--text);
  box-shadow: none;
}

button.danger,
.btn-danger {
  background: var(--red-600);
  color: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08), 0 8px 18px -12px rgba(220, 38, 38, 0.6);
}

button.danger:hover,
.btn-danger:hover {
  background: var(--red-700);
}

button.danger.ghost,
.btn-danger-ghost {
  background: transparent;
  color: var(--red-600);
  border-color: transparent;
  box-shadow: none;
}

button.danger.ghost:hover,
.btn-danger-ghost:hover {
  background: var(--red-50);
  color: var(--red-700);
  box-shadow: none;
}

button.success,
.btn-success {
  background: var(--teal-600);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08), 0 8px 18px -12px rgba(13, 148, 136, 0.6);
}

button.success:hover,
.btn-success:hover {
  background: var(--teal-700);
}

.btn-dark {
  background: var(--slate-800);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08), 0 8px 18px -12px rgba(15, 23, 42, 0.6);
}

.btn-dark:hover {
  background: var(--slate-900);
}

.btn-soft {
  background: var(--brand-50);
  color: var(--brand-700);
  box-shadow: none;
}

.btn-soft:hover {
  background: var(--brand-100);
  color: var(--brand-800);
  box-shadow: none;
}

.btn-sm,
button.btn-sm {
  min-height: var(--control-h-sm);
  padding: 0.35rem 0.8rem;
  font-size: 0.86rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  min-height: 3rem;
  padding: 0.7rem 1.5rem;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  width: var(--control-h);
  min-width: var(--control-h);
  padding: 0;
  border-radius: var(--radius);
}

.btn-icon.btn-sm {
  width: var(--control-h-sm);
  min-width: var(--control-h-sm);
}

.btn-pill {
  border-radius: var(--radius-pill);
}

.btn svg,
button svg,
.icon-text-button svg {
  width: 1.05em;
  height: 1.05em;
  flex-shrink: 0;
}

.btn-icon-badge {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.22);
  font-size: 1.05rem;
  line-height: 1;
}

/* Bottoni legacy (usati nel markup esistente) */
.admin-top-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: var(--control-h);
  padding: 0.5rem 1rem 0.5rem 0.65rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  line-height: 1.2;
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}

.admin-top-button:hover {
  transform: translateY(-1px);
  background: var(--surface-2);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}

.admin-top-icon {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--slate-100);
  color: var(--slate-700);
  font-size: 0.95rem;
  line-height: 1;
}

.admin-public-button .admin-top-icon {
  background: var(--teal-100);
  color: var(--teal-700);
}

.admin-site-settings-button .admin-top-icon {
  background: var(--indigo-100);
  color: var(--indigo-700);
}

.admin-logout-button {
  color: var(--red-700);
}

.admin-logout-button .admin-top-icon {
  background: var(--red-50);
  color: var(--red-700);
}

.add-member-button {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 1.05rem 0.5rem 0.6rem;
  white-space: nowrap;
}

.add-member-icon {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.22);
  font-size: 1.25rem;
  line-height: 1;
}

.add-finance-button {
  background: var(--teal-600);
}

.add-finance-button:hover {
  background: var(--teal-700);
}

.add-settings-button {
  background: var(--slate-800);
}

.add-settings-button:hover {
  background: var(--slate-900);
}

.icon-text-button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: var(--control-h-sm);
  padding: 0.35rem 0.7rem;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

.icon-text-button.save-button {
  background: var(--surface);
  color: var(--teal-700);
  border-color: var(--teal-100);
  box-shadow: none;
}

.icon-text-button.save-button:hover {
  background: var(--teal-50);
  border-color: var(--teal-600);
  box-shadow: none;
}

.print-button,
.export-attendees-button {
  background: var(--surface);
  color: var(--text-2);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}

.print-button:hover,
.export-attendees-button:hover {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.print-row {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
}

/* -----------------------------------------------------------------------------
   Form
   ----------------------------------------------------------------------------- */

label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-2);
  min-width: 0;
}

label small,
.field-hint {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-3);
}

input,
select,
textarea {
  font: inherit;
  color: var(--text);
  width: 100%;
  min-height: var(--control-h);
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

input::placeholder,
textarea::placeholder {
  color: var(--slate-400);
  font-weight: 500;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--slate-400);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand-400);
  box-shadow: var(--ring);
}

input:disabled,
select:disabled,
textarea:disabled,
input[readonly] {
  background: var(--surface-3);
  color: var(--text-3);
  cursor: not-allowed;
  box-shadow: none;
}

textarea {
  min-height: 5.5rem;
  resize: vertical;
  line-height: 1.5;
}

select {
  appearance: none;
  padding-right: 2.4rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='4 6 8 10 12 6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  cursor: pointer;
}

input[type='checkbox'],
input[type='radio'] {
  width: 1.1rem;
  height: 1.1rem;
  min-height: 0;
  padding: 0;
  margin: 0;
  box-shadow: none;
  accent-color: var(--brand-500);
  cursor: pointer;
  flex-shrink: 0;
}

input[type='file'] {
  padding: 0.45rem 0.6rem;
  font-size: 0.86rem;
  cursor: pointer;
}

input[type='file']::file-selector-button {
  font: inherit;
  font-weight: 700;
  font-size: 0.82rem;
  margin-right: 0.75rem;
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
}

input[type='color'] {
  padding: 0.25rem;
  width: 3.5rem;
  cursor: pointer;
}

input[type='number'] {
  font-variant-numeric: tabular-nums;
}

.form-grid,
.admin-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1rem;
}

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

.form-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.span-2 {
  grid-column: span 2;
}

.span-all {
  grid-column: 1 / -1;
}

.field-group {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.field-group > input {
  flex: 1;
}

/* Checkbox in riga stile "opzione" */
.checkbox-field,
.status-toggle,
.quote-toggle,
.event-inline-toggle,
.interclub-toggle,
.member-board-toggle,
.club-selector {
  flex-direction: row;
  align-items: center;
  gap: 0.6rem;
  min-height: var(--control-h);
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-2);
  font-weight: 700;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.checkbox-field:hover,
.status-toggle:hover,
.quote-toggle:hover,
.event-inline-toggle:hover,
.interclub-toggle:hover,
.member-board-toggle:hover,
.club-selector:hover {
  border-color: var(--border-strong);
  background: var(--surface);
}

.checkbox-field:has(input:checked),
.event-inline-toggle:has(input:checked),
.interclub-toggle:has(input:checked),
.member-board-toggle:has(input:checked) {
  border-color: var(--brand-200);
  background: var(--brand-50);
  color: var(--brand-800);
}

/* Interruttore (switch) */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  cursor: pointer;
  font-weight: 700;
  color: var(--text-2);
  flex-direction: row;
  min-width: 0;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-track {
  position: relative;
  width: 2.6rem;
  height: 1.5rem;
  border-radius: var(--radius-pill);
  background: var(--slate-300);
  transition: background var(--transition);
  flex-shrink: 0;
}

.switch-track::after {
  content: '';
  position: absolute;
  top: 0.15rem;
  left: 0.15rem;
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.3);
  transition: transform var(--transition);
}

.switch input:checked + .switch-track {
  background: var(--brand-500);
}

.switch input:checked + .switch-track::after {
  transform: translateX(1.1rem);
}

.switch input:focus-visible + .switch-track {
  box-shadow: var(--ring);
}

.switch-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.switch-text small {
  font-weight: 500;
  color: var(--text-3);
}

/* Controllo segmentato (radio a bottoni) */
.segmented {
  display: inline-flex;
  padding: 0.25rem;
  gap: 0.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-3);
}

.segmented label {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.15rem;
  padding: 0.3rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
}

.segmented label:has(input:checked) {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

.segmented input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

/* Sezioni di form */
.form-section {
  display: grid;
  gap: 1rem;
  padding: 1.15rem 1.25rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.form-section-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.form-section-title h4 {
  margin: 0;
  font-size: 0.98rem;
}

.form-section-title p {
  margin: 0.1rem 0 0;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-3);
}

.form-section-index {
  width: 1.9rem;
  height: 1.9rem;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-50);
  color: var(--brand-700);
  font-size: 0.82rem;
  font-weight: 800;
  flex-shrink: 0;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* -----------------------------------------------------------------------------
   Chip (tag) e dropdown
   ----------------------------------------------------------------------------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  max-width: 100%;
  min-height: 2.1rem;
  padding: 0.25rem 0.5rem 0.25rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 700;
  box-shadow: var(--shadow-xs);
}

.chip[data-tone='ok'] {
  border-color: var(--green-100);
  background: var(--green-50);
  color: var(--green-700);
}

.chip[data-tone='warn'] {
  border-color: var(--amber-100);
  background: var(--amber-50);
  color: var(--amber-700);
}

.chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.chip button {
  min-height: 0;
  width: 1.45rem;
  height: 1.45rem;
  padding: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: inherit;
  box-shadow: none;
  font-size: 0.85rem;
  line-height: 1;
  opacity: 0.7;
}

.chip button:hover {
  background: rgba(15, 23, 42, 0.08);
  opacity: 1;
  transform: none;
  box-shadow: none;
}

.chip-input {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  min-height: var(--control-h);
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  cursor: text;
}

.chip-input:focus-within {
  border-color: var(--brand-400);
  box-shadow: var(--ring);
}

.chip-input input {
  flex: 1 1 140px;
  min-width: 120px;
  min-height: 1.8rem;
  padding: 0.2rem 0.4rem;
  border: none;
  box-shadow: none;
  background: transparent;
}

.chip-input input:focus {
  box-shadow: none;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  z-index: 30;
  max-height: 260px;
  overflow-y: auto;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  width: 100%;
  min-height: 2.4rem;
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  box-shadow: none;
  border: none;
}

.dropdown-item:hover,
.dropdown-item:focus-visible,
.dropdown-item.is-active {
  background: var(--brand-50);
  color: var(--brand-800);
  transform: none;
  box-shadow: none;
}

.dropdown-item small {
  font-weight: 600;
  color: var(--text-3);
}

.dropdown-item[data-action='add'] {
  justify-content: flex-start;
  color: var(--brand-600);
  border-top: 1px solid var(--border);
  border-radius: 0;
  margin-top: 0.25rem;
  padding-top: 0.6rem;
}

.dropdown-item[data-action='add'] svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.dropdown-empty {
  padding: 0.6rem 0.7rem;
  color: var(--text-3);
  font-size: 0.86rem;
}

/* -----------------------------------------------------------------------------
   Tabelle
   ----------------------------------------------------------------------------- */

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr {
  transition: background var(--transition);
}

.data-table tbody tr:hover {
  background: var(--surface-2);
}

.data-table textarea {
  width: 100%;
  min-height: 3.2rem;
  padding: 0.45rem 0.6rem;
  font-size: 0.86rem;
}

.data-table input:not([type='checkbox']),
.data-table select {
  min-height: var(--control-h-sm);
  padding: 0.35rem 0.6rem;
  font-size: 0.88rem;
}

.data-table .empty-row,
.finance-empty-row,
.members-empty-row,
.attendees-empty-row {
  padding: 2rem 1rem !important;
  text-align: center !important;
  color: var(--text-3);
}

.amount {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.amount[data-type='income'],
.amount[data-tone='positive'] {
  color: var(--green-700);
}

.amount[data-type='expense'],
.amount[data-tone='negative'] {
  color: var(--red-700);
}

/* -----------------------------------------------------------------------------
   Modali
   ----------------------------------------------------------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  animation: overlay-in 160ms ease-out;
}

@keyframes overlay-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 540px;
  max-height: calc(100vh - 3rem);
  padding: 1.6rem;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  overflow: auto;
  animation: modal-in 200ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.modal-card.modal-md {
  max-width: 720px;
}

.modal-card.modal-lg {
  max-width: 960px;
}

.modal-card.modal-xl {
  max-width: min(1200px, 96vw);
}

.modal-close {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  z-index: 2;
  width: 2.25rem;
  height: 2.25rem;
  min-height: 0;
  padding: 0;
  border-radius: var(--radius-pill);
  background: var(--slate-100);
  color: var(--slate-600);
  font-size: 1.25rem;
  line-height: 1;
  box-shadow: none;
}

.modal-close:hover {
  background: var(--slate-200);
  color: var(--text);
  transform: none;
  box-shadow: none;
}

.modal-header {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 1rem;
  padding-right: 2.5rem;
}

.modal-header h2,
.modal-header h3 {
  margin: 0.1rem 0 0.15rem;
  font-size: 1.35rem;
}

.modal-icon {
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius-lg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-50);
  color: var(--brand-600);
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1;
  flex-shrink: 0;
}

.modal-icon[data-tone='teal'] {
  background: var(--teal-50);
  color: var(--teal-700);
}

.modal-icon[data-tone='indigo'] {
  background: var(--indigo-50);
  color: var(--indigo-700);
}

.modal-icon[data-tone='slate'] {
  background: var(--slate-100);
  color: var(--slate-700);
}

.modal-icon[data-tone='amber'] {
  background: var(--amber-50);
  color: var(--amber-700);
}

.modal-icon[data-tone='red'],
.modal-icon[data-tone='danger'] {
  background: var(--red-50);
  color: var(--red-700);
}

.modal-icon[data-tone='green'],
.modal-icon[data-tone='success'] {
  background: var(--green-50);
  color: var(--green-700);
}

.modal-icon svg {
  width: 1.4rem;
  height: 1.4rem;
}

.modal-pill,
.member-fee-pill,
.event-modal-pill,
.registration-modal-pill,
.settings-modal-pill,
.finance-modal-pill,
.quotes-modal-pill {
  display: inline-flex;
  width: fit-content;
  margin: 0.35rem 0 0;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-pill);
  background: var(--sky-100);
  color: var(--sky-700);
  font-size: 0.78rem;
  font-weight: 700;
}

.modal-body {
  display: grid;
  gap: 1rem;
}

.modal-footer,
.modal-actions,
.member-modal-actions,
.settings-modal-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

.modal-footer-start {
  margin-right: auto;
}

/* -----------------------------------------------------------------------------
   Avvisi, toast, stati vuoti
   ----------------------------------------------------------------------------- */

.alert {
  --tone-bg: var(--sky-50);
  --tone-fg: var(--sky-700);
  --tone-border: var(--sky-100);
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.85rem 1rem;
  border: 1px solid var(--tone-border);
  border-radius: var(--radius);
  background: var(--tone-bg);
  color: var(--tone-fg);
  font-size: 0.9rem;
}

.alert p {
  margin: 0;
}

.alert > svg {
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
  margin-top: 0.15rem;
}

.alert strong {
  font-weight: 800;
}

.alert[data-tone='success'] {
  --tone-bg: var(--green-50);
  --tone-fg: var(--green-700);
  --tone-border: var(--green-100);
}

.alert[data-tone='warning'] {
  --tone-bg: var(--amber-50);
  --tone-fg: var(--amber-700);
  --tone-border: var(--amber-100);
}

.alert[data-tone='danger'] {
  --tone-bg: var(--red-50);
  --tone-fg: var(--red-700);
  --tone-border: var(--red-100);
}

.alert[data-tone='brand'] {
  --tone-bg: var(--brand-50);
  --tone-fg: var(--brand-800);
  --tone-border: var(--brand-100);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  z-index: 100;
  transform: translateX(-50%);
  max-width: min(92vw, 520px);
  padding: 0.8rem 1.15rem;
  border-radius: var(--radius);
  background: var(--slate-900);
  color: #fff;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toast-in 220ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.toast[data-type='error'] {
  background: var(--red-700);
}

.toast[data-type='success'] {
  background: var(--green-700);
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 0.4rem;
  padding: 2.25rem 1.5rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  color: var(--text-3);
  text-align: center;
}

.empty-state strong {
  color: var(--text-2);
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 0.5rem 0;
}

/* Skeleton / caricamento */
.skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--slate-100) 25%, var(--slate-200) 37%, var(--slate-100) 63%);
  background-size: 400% 100%;
  animation: skeleton 1.4s ease infinite;
}

@keyframes skeleton {
  0% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0 50%;
  }
}

/* -----------------------------------------------------------------------------
   Responsive di base
   ----------------------------------------------------------------------------- */

@media (max-width: 900px) {
  body {
    padding: 1.25rem;
  }

  .form-grid-2,
  .form-grid-3 {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  body {
    padding: 0.85rem;
  }

  .card {
    padding: 1.1rem;
    border-radius: var(--radius-lg);
  }

  .modal-overlay {
    padding: 0.75rem;
    align-items: flex-end;
  }

  .modal-card {
    max-height: calc(100vh - 1.5rem);
    padding: 1.25rem;
    border-radius: var(--radius-lg);
  }

  .modal-header {
    grid-template-columns: 1fr;
  }

  .modal-footer,
  .modal-actions,
  .member-modal-actions,
  .settings-modal-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .modal-footer button,
  .modal-actions button,
  .member-modal-actions button,
  .settings-modal-actions button,
  .modal-footer .btn,
  .modal-actions .btn {
    width: 100%;
  }

  .modal-footer-start {
    margin-right: 0;
  }
}

@media print {
  body {
    padding: 0;
    background: #fff;
  }

  button,
  .btn,
  .print-row,
  .toast,
  .modal-overlay {
    display: none !important;
  }

  .card,
  .section-card {
    box-shadow: none;
    border-color: #ddd;
  }
}
