:root {
  --primary: #1e3a8a;
  --primary-light: #3b82f6;
  --accent: #f97316;
  --accent-dark: #ea580c;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.15);
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); overflow: hidden; }
.hidden { display: none !important; }

.view { height: 100vh; width: 100%; max-width: 600px; margin: 0 auto; background: var(--bg); display: flex; flex-direction: column; }

/* AUTH */
.auth-container { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 24px; max-width: 400px; margin: 0 auto; width: 100%; }
.auth-header { text-align: center; margin-bottom: 32px; }
.auth-icon { font-size: 64px; margin-bottom: 16px; }
.auth-header h1 { font-size: 24px; color: var(--primary); margin-bottom: 8px; }
.auth-header p { color: var(--text-muted); font-size: 14px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.error-msg { background: #fef2f2; color: var(--danger); padding: 12px; border-radius: var(--radius-sm); font-size: 14px; text-align: center; margin-top: 16px; border: 1px solid #fecaca; }

.teams-list { display: flex; flex-direction: column; gap: 12px; }
.team-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; cursor: pointer; transition: all 0.2s; text-align: left; }
.team-card:hover { border-color: var(--primary-light); transform: translateY(-2px); box-shadow: var(--shadow); }
.team-card h3 { font-size: 16px; color: var(--primary); margin-bottom: 4px; }
.team-card p { font-size: 13px; color: var(--text-muted); }
.team-role { display: inline-block; font-size: 11px; padding: 2px 8px; background: var(--bg); border-radius: 10px; margin-top: 8px; font-weight: 600; }

/* HEADER MODERNO */
.app-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  padding: 16px 20px;
  box-shadow: var(--shadow);
  z-index: 10;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
}

.app-header h1 {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.5px;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  color: white;
  backdrop-filter: blur(10px);
}

.header-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.header-btn:active {
  transform: translateY(0);
  background: rgba(255, 255, 255, 0.2);
}

.header-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.header-btn-text {
  font-size: 13px;
  font-weight: 600;
  padding: 0 12px;
  height: 36px;
  display: flex;
  align-items: center;
}

/* Super Admin Header */
#super-admin-view .app-header {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
}

/* Player Header */
#player-main-view .app-header {
  background: linear-gradient(135deg, #f97316, #ea580c);
}

.main-content { flex: 1; overflow-y: auto; padding: 16px; padding-bottom: 90px; -webkit-overflow-scrolling: touch; }

/* BOTTOM NAV */
.bottom-nav { position: absolute; bottom: 0; left: 0; right: 0; background: var(--surface); display: flex; justify-content: space-around; padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); box-shadow: 0 -2px 10px rgba(0,0,0,0.05); z-index: 10; max-width: 600px; margin: 0 auto; }
.nav-btn { flex: 1; background: none; border: none; padding: 8px 4px; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--text-muted); cursor: pointer; font-size: 11px; font-weight: 500; }
.nav-btn.active { color: var(--primary); }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 12px 20px; border: none; border-radius: var(--radius-sm); font-size: 15px; font-weight: 600; cursor: pointer; transition: all 0.2s; font-family: inherit; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: white; }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-block { width: 100%; }

/* FORMS */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-input, .form-select { width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 15px; font-family: inherit; background: var(--surface); color: var(--text); }
.form-input:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); }

/* FAB */
.fab { position: fixed; bottom: 90px; right: calc(50% - 280px); width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: white; border: none; font-size: 28px; box-shadow: var(--shadow-lg); cursor: pointer; z-index: 5; }
@media (max-width: 600px) { .fab { right: 20px; } }

/* ITEMS */
.player-item, .event-item { background: var(--surface); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.event-item.match { border-left: 4px solid var(--accent); }
.event-item.training { border-left: 4px solid var(--primary); }
.player-info, .event-info { flex: 1; min-width: 0; }
.player-name, .event-title { font-weight: 600; font-size: 15px; }
.player-role, .event-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.code-badge { background: var(--primary); color: white; padding: 4px 8px; border-radius: 6px; font-family: monospace; font-size: 13px; font-weight: 700; letter-spacing: 1px; }
.player-number { background: var(--text); color: white; width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; margin-right: 8px; flex-shrink: 0; }

/* TOAST & EMPTY */
.toast { position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%); background: var(--text); color: white; padding: 12px 20px; border-radius: 24px; font-size: 14px; font-weight: 500; z-index: 200; box-shadow: var(--shadow); animation: toastIn 0.3s; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 20px); } to { opacity: 1; transform: translate(-50%, 0); } }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state-icon { font-size: 56px; margin-bottom: 12px; }

/* MODAL */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 100; display: flex; align-items: flex-end; animation: fadeIn 0.2s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--surface); width: 100%; max-width: 600px; margin: 0 auto; border-radius: 20px 20px 0 0; max-height: 92vh; display: flex; flex-direction: column; animation: slideUp 0.3s; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-header { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 24px; color: var(--text-muted); cursor: pointer; padding: 4px 8px; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; flex-shrink: 0; }

/* CONVOCAZIONI */
.convocation-row { display: flex; align-items: center; justify-content: space-between; padding: 12px; background: var(--bg); border-radius: var(--radius-sm); margin-bottom: 8px; border: 1px solid var(--border); }
.convocation-info { flex: 1; }
.convocation-actions { display: flex; gap: 6px; }
.toggle-convoca { background: var(--border); color: var(--text-muted); border: none; padding: 6px 12px; border-radius: 20px; font-size: 12px; font-weight: 600; cursor: pointer; }
.toggle-convoca.active { background: var(--primary); color: white; }
.toggle-convoca:disabled { background: #ccc; cursor: not-allowed; }

.response-btn { border: none; padding: 6px 10px; border-radius: 6px; font-size: 12px; font-weight: 700; cursor: pointer; opacity: 0.5; transition: all 0.2s; }
.response-btn.active { opacity: 1; transform: scale(1.05); }
.response-btn.yes { background: #d1fae5; color: #065f46; }
.response-btn.yes.active { background: var(--success); color: white; }
.response-btn.no { background: #fee2e2; color: #991b1b; }
.response-btn.no.active { background: var(--danger); color: white; }
.response-btn.maybe { background: #fef3c7; color: #92400e; }
.response-btn.maybe.active { background: var(--warning); color: white; }

.summary-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.summary-chip { padding: 6px 12px; border-radius: 20px; font-size: 13px; font-weight: 600; color: white; }
.chip-yes { background: var(--success); }
.chip-no { background: var(--danger); }
.chip-maybe { background: var(--warning); }
.chip-pending { background: var(--text-muted); }

/* STAFF & ADMIN */
.staff-item { display: flex; align-items: center; justify-content: space-between; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; }
.sa-user-item, .sa-team-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.sa-user-info h4 { font-size: 15px; margin-bottom: 2px; }
.sa-user-info p { font-size: 12px; color: var(--text-muted); }
.role-badge { font-size: 10px; padding: 2px 6px; border-radius: 10px; font-weight: 700; text-transform: uppercase; }
.role-super { background: #7c3aed; color: white; }
.role-admin { background: var(--primary); color: white; }
.role-vice { background: var(--accent); color: white; }

.card { background: var(--surface); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.tabs { display: flex; background: var(--surface); border-radius: var(--radius); padding: 4px; margin-bottom: 14px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.tab { flex: 1; padding: 10px; background: none; border: none; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; color: var(--text-muted); cursor: pointer; transition: all 0.2s; }
.tab.active { background: var(--primary); color: white; }

/* INDISPONIBILITÀ */
.unavail-item { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; background: var(--bg); border-radius: 6px; margin-bottom: 4px; font-size: 13px; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }