:root {
  --primary: #1e3a8a;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --accent: #0284c7;
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #16a34a;
  --radius: 8px;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

/* Header */
header.app-header {
  background: #0f172a;
  color: white;
  padding: 14px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  background: var(--accent);
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.brand-text h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.brand-text span {
  font-size: 12px;
  color: #94a3b8;
}

/* Navigation Tabs */
.nav-tabs {
  display: flex;
  gap: 8px;
}

.nav-tab {
  background: #1e293b;
  border: 1px solid #334155;
  color: #94a3b8;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-tab:hover {
  background: #334155;
  color: white;
}

.nav-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 600;
}

/* Container */
.container {
  max-width: 1200px;
  margin: 28px auto;
  padding: 0 20px;
}

/* Actions Bar */
.action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 280px;
  max-width: 480px;
}

.search-input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 14px;
  background: white;
  outline: none;
  transition: all 0.2s;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
}

.stats-counter {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

/* Info Box */
.info-hint {
  font-size: 13px;
  color: var(--text-muted);
  background: #f1f5f9;
  border-left: 3px solid var(--accent);
  padding: 8px 12px;
  border-radius: 0 6px 6px 0;
  margin-bottom: 16px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-outline {
  background: white;
  border-color: var(--border);
  color: #334155;
}
.btn-outline:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.btn-danger {
  background: white;
  border-color: #fecaca;
  color: var(--danger);
}
.btn-danger:hover {
  background: #fee2e2;
  border-color: #f87171;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

/* Order Move Buttons */
.btn-move {
  background: white;
  border: 1px solid var(--border);
  color: #475569;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-move:hover:not(:disabled) {
  background: var(--primary-light);
  border-color: #93c5fd;
  color: var(--primary);
}

.btn-move:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  border-color: var(--border);
}

/* Card & Table */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-responsive {
  overflow-x: auto;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

table.data-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
  padding: 14px 18px;
  border-bottom: 2px solid var(--border);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

table.data-table td {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.data-table tr:hover td {
  background: #f8fafc;
}

.badge-sigla {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  display: inline-block;
  font-size: 13px;
  letter-spacing: 0.5px;
}

.badge-order {
  background: #f1f5f9;
  color: #475569;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  border: 1px solid #cbd5e1;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  color: #94a3b8;
}

.empty-title {
  font-size: 18px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 8px;
}

.empty-desc {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 440px;
  margin: 0 auto 20px;
  line-height: 1.5;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 580px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-15px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
}

.btn-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 24px;
}

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full {
  grid-column: span 2;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

.form-group label .required {
  color: var(--danger);
}

.form-control {
  padding: 9px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: #f8fafc;
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  display: none;
  align-items: center;
  gap: 10px;
  z-index: 1000;
}

.toast.show {
  display: flex;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Sub-Navigation Tabs */
.sub-nav-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 22px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 12px;
  flex-wrap: wrap;
}

.sub-nav-tab {
  background: white;
  border: 1px solid var(--border);
  color: #475569;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sub-nav-tab:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: var(--primary);
}

.sub-nav-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* Checkbox Groups */
.checkboxes-row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  padding: 12px 16px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #334155;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Entity Badges */
.badge-tag {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
  display: inline-block;
  white-space: nowrap;
}

.badge-tag-gdf { background: #dcfce7; color: #166534; }
.badge-tag-sagf { background: #fef3c7; color: #92400e; }
.badge-tag-aria { background: #e0f2fe; color: #075985; }
.badge-tag-congedo { background: #fee2e2; color: #991b1b; }
.badge-tag-electric { background: #dbeafe; color: #1e40af; }
.badge-tag-thermal { background: #ffedd5; color: #9a3412; }
.badge-tag-hybrid { background: #f3e8ff; color: #6b21a8; }

/* Status & Course Badges */
.badge-status {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.badge-status-open {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}
.badge-status-closed {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}

.badge-esito {
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  display: inline-block;
}
.badge-esito-in-corso { background: #f1f5f9; color: #64748b; }
.badge-esito-idoneo { background: #dcfce7; color: #166534; font-weight: 700; }
.badge-esito-non-idoneo { background: #fee2e2; color: #991b1b; }
.badge-esito-assente { background: #fef3c7; color: #92400e; }
.badge-esito-escluso { background: #ede9fe; color: #5b21b6; }

.badge-locked {
  background: #e0e7ff;
  color: #3730a3;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.badge-manual {
  background: #f1f5f9;
  color: #475569;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-cert-sigla {
  background: #1e3a8a;
  color: #ffffff;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  display: inline-block;
}

.badge-prereq-ok {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-prereq-missing {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-exp-valid {
  background: #dcfce7;
  color: #15803d;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  display: inline-block;
}

.badge-exp-warning {
  background: #fef3c7;
  color: #b45309;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  display: inline-block;
}

.badge-exp-expired {
  background: #fee2e2;
  color: #b91c1c;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  display: inline-block;
}

/* Timeline & Course Details */
.course-banner {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.course-banner-info h4 {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}
.course-banner-info span {
  font-size: 13px;
  color: var(--text-muted);
}

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

/* ============================================== */
/* LOGIN SCREEN                                   */
/* ============================================== */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top right, #1e3a8a 0%, #0f172a 75%);
  padding: 24px;
}

.login-card {
  background: white;
  border-radius: 14px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.45);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-header {
  background: #0f172a;
  color: white;
  padding: 32px 24px 24px;
  text-align: center;
  border-bottom: 1px solid #1e293b;
}

.login-logo {
  width: 54px;
  height: 54px;
  background: #0284c7;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  margin-bottom: 12px;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.4);
}

.login-header h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.3px;
  margin-bottom: 4px;
}

.login-header p {
  font-size: 13px;
  color: #94a3b8;
}

.login-body {
  padding: 28px 24px 32px;
}

.login-alert {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.4;
}

/* Header User Section */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1e293b;
  border: 1px solid #334155;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  color: #f1f5f9;
}

.user-badge .role-tag {
  background: #0284c7;
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.user-badge .role-tag.admin {
  background: #e11d48;
}

.btn-header {
  background: #1e293b;
  border: 1px solid #334155;
  color: #cbd5e1;
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-header:hover {
  background: #334155;
  color: white;
  border-color: #475569;
}

.btn-header-danger {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.btn-header-danger:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #ffffff;
  border-color: rgba(239, 68, 68, 0.5);
}

.badge-attivo {
  background: #dcfce7;
  color: #166534;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.badge-disattivo {
  background: #fee2e2;
  color: #991b1b;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

/* ============================================== */
/* LIVE SEARCH ALLIEVI AUTOCOMPLETE               */
/* ============================================== */
.search-allievo-container {
  position: relative;
  flex: 1;
  z-index: 100;
}

.search-allievo-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 12px 28px -4px rgba(0, 0, 0, 0.25), 0 8px 10px -6px rgba(0, 0, 0, 0.15);
  max-height: 290px;
  overflow-y: auto;
  z-index: 9999;
}

.search-allievo-header-hint {
  padding: 8px 14px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.search-allievo-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  transition: all 0.15s;
}

.search-allievo-item:last-child {
  border-bottom: none;
}

.search-allievo-item:hover,
.search-allievo-item.highlighted {
  background-color: #f0f7ff;
}

.search-allievo-item-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.search-allievo-name {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 6px;
}

.search-allievo-details {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-search-add {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-search-add:hover {
  background: var(--primary-hover);
}

.search-allievo-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ============================================== */
/* BOTTONI & BANNER CHIUSURA/RIAPERTURA CORSO      */
/* ============================================== */
.btn-success {
  background: #16a34a;
  border: 1px solid #16a34a;
  color: white;
}
.btn-success:hover {
  background: #15803d;
  border-color: #15803d;
}

.btn-outline-warning {
  background: white;
  border: 1px solid #f59e0b;
  color: #b45309;
}
.btn-outline-warning:hover {
  background: #fef3c7;
  border-color: #d97706;
}

.btn-outline-success {
  background: white;
  border: 1px solid #16a34a;
  color: #166534;
}
.btn-outline-success:hover {
  background: #dcfce7;
  border-color: #15803d;
}

.course-edit-status-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  gap: 12px;
}

.course-edit-status-banner.closed {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.course-edit-status-banner.open {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}





