:root {
  --brand: #2563eb;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e2e5eb;
  --danger: #dc2626;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

a { color: var(--brand); }

/* ---------- pagine auth ---------- */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
}

.auth-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 32px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
}

.auth-logo {
  font-size: 22px;
  font-weight: 700;
  color: var(--brand);
  margin: 0 0 8px;
}

.auth-card h2 { margin: 0 0 16px; font-size: 18px; }
.auth-hint { color: var(--muted); font-size: 14px; margin-top: -8px; }

.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.auth-card input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
}
.auth-card button {
  margin-top: 4px;
  padding: 11px;
  border: none;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.auth-card button:hover { filter: brightness(1.08); }

.form-error { color: var(--danger); font-size: 13px; margin: 0; }
.auth-alt { margin-top: 18px; font-size: 14px; text-align: center; color: var(--muted); }
.lang-switch { margin-top: 10px; font-size: 13px; text-align: center; }

/* ---------- shell app ---------- */

.app-shell { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.topbar .brand { font-weight: 700; color: var(--brand); display: flex; align-items: center; gap: 8px; }
.topbar .brand img { height: 24px; }

.layer-tabs { display: flex; gap: 6px; }
.layer-tab {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 13px;
}
.layer-tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.view-switch { margin-left: auto; display: flex; gap: 4px; }
.view-switch button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  border-radius: 6px;
  font-size: 13px;
}
.view-switch button.active { background: var(--text); color: #fff; }

.logout-link { font-size: 13px; color: var(--muted); text-decoration: none; margin-left: 12px; cursor: pointer; }

.app-body { flex: 1; display: flex; min-height: 0; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  overflow-y: auto;
}
.sidebar h3 { font-size: 12px; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.athlete-row { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.athlete-row:hover { background: var(--bg); }
.athlete-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.pending-badge {
  margin-top: 16px;
  padding: 8px 10px;
  background: #fff7ed;
  border: 1px solid #fdba74;
  border-radius: 8px;
  font-size: 13px;
  color: #9a3412;
}

.calendar-area { flex: 1; overflow: auto; padding: 16px; position: relative; }

.fab {
  position: fixed;
  right: 28px;
  bottom: 28px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  border: none;
  font-size: 28px;
  line-height: 56px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .2);
}

/* ---------- vista mese ---------- */

.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.month-head { font-size: 12px; color: var(--muted); text-transform: uppercase; text-align: center; padding-bottom: 4px; }
.month-cell {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 96px;
  padding: 6px;
  font-size: 12px;
  cursor: pointer;
}
.month-cell.other-month { opacity: .45; }
.month-cell .day-num { font-weight: 600; margin-bottom: 4px; }
.month-cell.drop-target { outline: 2px dashed var(--brand); }

.chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 999px;
  color: #fff;
  font-size: 11px;
  margin-bottom: 3px;
  cursor: grab;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip img { width: 14px; height: 14px; border-radius: 50%; }

/* ---------- vista settimana swimlane ---------- */

.week-grid { display: grid; grid-template-columns: 160px repeat(7, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.week-cell { background: var(--card); min-height: 70px; padding: 4px; }
.week-head { background: #fafbfc; font-size: 12px; text-align: center; padding: 6px 2px; font-weight: 600; }
.week-athlete-label { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 8px; background: #fafbfc; }
.week-athlete-label img { width: 22px; height: 22px; border-radius: 50%; }
.week-cell.drop-target { outline: 2px dashed var(--brand); outline-offset: -2px; }

/* ---------- pannello creazione/modifica ---------- */

.panel-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .35);
  display: flex; justify-content: flex-end; z-index: 50;
}
.panel {
  width: min(420px, 100%);
  background: var(--card);
  height: 100%;
  overflow-y: auto;
  padding: 20px;
}
.panel h2 { margin-top: 0; }
.panel-close { float: right; border: none; background: none; font-size: 20px; cursor: pointer; color: var(--muted); }
.panel form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.panel label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.panel input, .panel select, .panel textarea {
  padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
}
.panel textarea { min-height: 80px; }
.panel .row { display: flex; gap: 10px; }
.panel .row > * { flex: 1; }
.panel button.primary {
  padding: 10px; border: none; border-radius: 8px; background: var(--brand); color: #fff; font-weight: 600; cursor: pointer;
}
.panel button.secondary {
  padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; cursor: pointer;
}
.type-choice { display: flex; gap: 12px; }
.type-choice button {
  flex: 1; padding: 24px 12px; border: 2px solid var(--border); border-radius: 10px; background: #fff;
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.type-choice button:hover { border-color: var(--brand); }

.status-badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; background: var(--bg); }
.media-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; margin-right: 6px; }
.media-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

.menu-more { position: relative; }
.menu-more-list {
  position: absolute; right: 0; top: 100%; background: #fff; border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 4px 12px rgba(0, 0, 0, .12); z-index: 10; min-width: 160px;
}
.menu-more-list button {
  display: block; width: 100%; text-align: left; padding: 8px 12px; border: none; background: none; cursor: pointer; font-size: 13px;
}
.menu-more-list button:hover { background: var(--bg); }

/* ---------- vista atleta mobile ---------- */

.mobile-shell { max-width: 480px; margin: 0 auto; padding: 12px 12px 90px; }
.mobile-header { display: flex; justify-content: space-between; align-items: center; padding: 8px 4px 16px; }
.mobile-section-title { font-size: 13px; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; }
.mobile-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 10px;
}
.mobile-card img.cover { width: 100%; border-radius: 8px; margin-bottom: 8px; max-height: 180px; object-fit: cover; }
.mobile-card .title { font-weight: 600; margin-bottom: 4px; }
.mobile-card .meta { font-size: 13px; color: var(--muted); }
.mobile-actions { display: flex; gap: 8px; margin-top: 10px; }
.mobile-actions button { flex: 1; padding: 9px; border-radius: 8px; border: 1px solid var(--border); background: #fff; cursor: pointer; }
.mobile-actions button.approve { background: #16a34a; color: #fff; border-color: #16a34a; }

@media (max-width: 720px) {
  .sidebar { display: none; }
  .layer-tabs { display: none; }
}
