:root {
  --gm-primary: #1a1a2e;
  --gm-accent: #e94560;

  /* Sidebar */
  --sb-width: 240px;
  --sb-mini: 68px;
  --sb-bg: #ffa000;
  --sb-border: rgba(0, 0, 0, .12);
  --sb-text: rgba(255, 255, 255, .85);
  --sb-hover-bg: rgba(0, 0, 0, .10);
  --sb-active-bg: rgba(0, 0, 0, .20);
  --sb-accent: #fff;
  --topbar-h: 52px;
}

.fs-5 {
    font-size: 0.95rem !important;
}

a,
a:hover,
a:focus,
a:active {
  text-decoration: none !important;
}

body {
  background-color: #f4f6f9;
  font-size: 0.92rem;
  overflow-x: hidden;
}

/* page-content is the flex column that fills the viewport */
#page-content {
  margin-left: var(--sb-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left .22s ease;
}

#page-content>.container-fluid {
  flex: 1;
}

/* =========================================
   SIDEBAR
   ========================================= */
#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sb-width);
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: width .22s ease;
  overflow: hidden;
}

/* -- Brand row -- */
.sb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 0 16px;
  flex-shrink: 0;
}

.sb-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: #fff;
  font-weight: 800;
  font-size: .92rem;
  letter-spacing: .3px;
  white-space: nowrap;
  overflow: hidden;
  min-width: 0;
}

.sb-brand-logo {
  height: 30px;
  width: auto;
  margin-right: 8px;
  flex-shrink: 0;
  object-fit: contain;
}

body.sb-collapsed .sb-brand-logo {
  height: 26px;
  margin-right: 0;
}

.sb-brand i {
  color: var(--sb-accent);
  font-size: 1.3rem;
  flex-shrink: 0;
}

.sb-brand span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-collapse-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, .4);
  font-size: 1rem;
  cursor: pointer;
  padding: 6px 7px;
  border-radius: 6px;
  line-height: 1;
  flex-shrink: 0;
  transition: color .15s, background .15s;
}

.sb-collapse-btn:hover {
  color: #fff;
  background: rgba(0, 0, 0, .12);
}

/* -- Logo motoclub -- */
.sb-logo-wrap {
  display: flex;
  justify-content: center;
  padding: 0px 0 0px;
  flex-shrink: 0;
}

.sb-logo-img {
  width: 100px;
  height: auto;
  border-radius: 50%;
  object-fit: cover;
  transition: width .22s ease, height .22s ease;
}

body.sb-collapsed .sb-logo-img {
  width: 38px;
  height: 38px;
}

/* -- Nav list -- */
.sb-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0;
}

.sb-nav::-webkit-scrollbar {
  width: 4px;
}

.sb-nav:hover::-webkit-scrollbar {
  width: 10px;
}

.sb-nav::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, .2);
  border-radius: 4px;
  transition: background .2s;
}

.sb-nav:hover::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, .4);
}

.sb-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* Section separator */
.sb-sep {
  padding: 16px 16px 5px;
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.sb-sep hr {
  border-color: var(--sb-border);
  margin: 0;
}

.sb-sep span {
  white-space: nowrap;
}

/* Inner divider (no label) */
.sb-divider {
  padding: 4px 16px;
}

.sb-divider hr {
  border-color: var(--sb-border);
  margin: 0;
}

/* Nav links */
.sb-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 16px;
  color: var(--sb-text);
  font-size: .875rem;
  font-weight: 500;
  white-space: nowrap;
  position: relative;
  transition: color .15s, background .15s;
}

.sb-link:hover {
  color: #fff;
  background: var(--sb-hover-bg);
}

.sb-link.active {
  color: var(--sb-accent);
  background: var(--sb-active-bg);
  border-right: 3px solid #ff0000;
  font-weight: 600;
}

.sb-link i {
  font-size: 1.05rem;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
}

.sb-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

@keyframes sb-bounce-left {
  0%, 100% { transform: translateX(0); opacity: 1; }
  50%       { transform: translateX(-5px); opacity: .6; }
}
.sb-ev-arrow {
  margin-left: auto;
  font-size: .8rem !important;
  width: auto !important;
  flex-shrink: 0;
  color: #fff;
  animation: sb-bounce-left 1.1s ease-in-out infinite;
}
body.sb-collapsed .sb-ev-arrow { display: none !important; }

/* -- User footer -- */
.sb-footer {
  border-top: 1px solid var(--sb-border);
  padding: 10px;
  flex-shrink: 0;
}

.sb-user-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: none;
  border: none;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s;
  min-width: 0;
}

.sb-user-btn:hover {
  background: rgba(0, 0, 0, .10);
}

.sb-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--sb-accent);
  flex-shrink: 0;
}

.sb-avatar-ph {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #333;
  border: 2px solid var(--sb-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sb-avatar-ph i {
  color: #aaa;
  font-size: .9rem;
}

.sb-user-meta {
  min-width: 0;
  text-align: left;
  flex: 1;
  overflow: hidden;
}

.sb-user-name {
  font-size: .8rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}

.sb-user-role {
  margin-top: 2px;
}

.sb-footer .dropdown-menu {
  background-color: #b87608;
}

.sb-footer .dropdown-menu .dropdown-item {
  color: #fff;
}

.sb-footer .dropdown-menu .dropdown-item:hover,
.sb-footer .dropdown-menu .dropdown-item:focus {
  background-color: rgba(0, 0, 0, .15);
  color: #fff;
}

.sb-footer .dropdown-menu .dropdown-divider {
  border-color: rgba(255, 255, 255, .2);
}

/* ---- COLLAPSED state ---- */
body.sb-collapsed #sidebar {
  width: var(--sb-mini);
}

body.sb-collapsed #page-content {
  margin-left: var(--sb-mini);
}

body.sb-collapsed .sb-label {
  display: none;
}

body.sb-collapsed .sb-sep span {
  display: none;
}

body.sb-collapsed .sb-sep {
  padding: 8px 8px 4px;
}

body.sb-collapsed .sb-sep hr {
  display: block;
}

body.sb-collapsed .sb-link {
  justify-content: center;
  padding: 10px 0;
}

body.sb-collapsed .sb-link i {
  width: auto;
}

body.sb-collapsed .sb-brand span {
  display: none;
}

body.sb-collapsed .sb-header {
  justify-content: center;
  padding: 0;
}

body.sb-collapsed .sb-collapse-btn {
  display: none;
}

body.sb-collapsed .sb-footer {
  padding: 10px 4px;
}

body.sb-collapsed .sb-user-btn {
  justify-content: center;
  padding: 6px 0;
}

body.sb-collapsed .sb-user-meta {
  display: none;
}

/* Show collapse-reopen button inside brand area when collapsed */
body.sb-collapsed .sb-expand-btn {
  display: flex;
}

.sb-expand-btn {
  display: none;
  background: none;
  border: none;
  color: rgba(255, 255, 255, .4);
  font-size: 1rem;
  cursor: pointer;
  padding: 6px 7px;
  border-radius: 6px;
  line-height: 1;
  align-items: center;
  justify-content: center;
  transition: color .15s, background .15s;
}

.sb-expand-btn:hover {
  color: #fff;
  background: rgba(0, 0, 0, .12);
}


/* ---- MOBILE overlay ---- */
#sb-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 1039;
}

body.sb-open #sb-overlay {
  display: block;
}

/* ---- TOPBAR (mobile) ---- */
#topbar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  height: var(--topbar-h);
  background: var(--sb-bg);
  position: sticky;
  top: 0;
  z-index: 1030;
  flex-shrink: 0;
}

.topbar-toggle {
  background: none;
  border: none;
  color: rgba(255, 255, 255, .8);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  flex-shrink: 0;
}

.topbar-title {
  font-weight: 700;
  color: #fff;
  font-size: .9rem;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =========================================
   RESPONSIVE — SIDEBAR
   ========================================= */
@media (min-width: 992px) {
  #topbar {
    display: none !important;
  }

  #sb-overlay {
    display: none !important;
  }
}

@media (max-width: 991.98px) {
  #sidebar {
    width: var(--sb-width) !important;
    transform: translateX(-100%);
    transition: transform .22s ease, width 0s;
    z-index: 1050;
  }

  body.sb-open #sidebar {
    transform: translateX(0);
  }

  #page-content {
    margin-left: 0 !important;
    padding-top: var(--topbar-h);
  }

  #topbar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
  }
}

.navbar-brand {
  letter-spacing: 0.5px;
  font-size: 1.1rem;
}

.card {
  border: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .10);
  border-radius: .6rem;
}

.card-header {
  background: #fff;
  border-bottom: 2px solid #f0f0f0;
  font-weight: 600;
}

.table thead th {
  background: #f8f9fa;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.stat-card {
  border-left: 4px solid var(--gm-accent);
}

.stat-card .stat-number {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}

.badge {
  font-size: 0.75rem;
}

.btn-action {
  padding: .2rem .5rem;
  font-size: .82rem;
}

a {
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 1.2rem;
}

/* =========================================
   LISTA EVENTI MARSHAL
   ========================================= */
.eventi-list {

}

.evento-item {
  cursor: pointer;
  padding: 10px 4px;
  user-select: none;
}

.evento-item:hover .evento-nome {
  color: #FFA000;
}

.evento-nome {
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #222;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.evento-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.data-box {
  background: #FFA000;
  color: white;
  width: 180px;
  min-height: 130px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.35;
  flex-shrink: 0;
}

.data-box .data-giorno {
  font-size: 1.5rem;
}

.data-box .data-num {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
}

.data-box .data-mese {
  font-size: 1.5rem;
}

.data-box .data-tipo {
  font-size: .6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  opacity: .85;
  margin-top: 4px;
}

.evento-spacer {
  flex: 1;
}

.evento-divider {
  margin: 10px 0 0;
  border-color: #e0e0e0;
}

/* Semaphore */
.semaforo {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Anello esterno + pallino interno: il colore lo dà `color`, ereditato sia dal
   bordo (border senza colore = currentColor) sia dal pallino in ::before. */
.dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-block;
  position: relative;
  flex-shrink: 0;
  background: transparent;
  border: 2px solid;
  color: #9e9e9e;
}

.dot::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 76%;
  height: 76%;
  border-radius: 50%;
  background: currentColor;
}

.dot-rosso {
  color: #e53935;
}

.dot-giallo {
  color: #f9a825;
}

.dot-arancione {
  color: #fb8c00;
}

.dot-verde {
  color: #43a047;
}

.dot-spento {
  color: #9e9e9e;
}

/* =========================================
   MODAL EVENTO
   ========================================= */
.modal-evento .modal-content {
  background: #FFA000;
  border: none;
  border-radius: 18px;
  overflow: hidden;
}

.modal-evento .modal-body {
  padding: 14px;
}

.evento-card {
  background: white;
  border-radius: 14px;
  padding: 22px 18px 18px;
}

.evento-card-title {
  font-weight: 800;
  font-size: 1.25rem;
  text-align: center;
  margin-bottom: 18px;
  letter-spacing: .02em;
}

.info-row {
  background: #fff;
  border: 1px solid #ebebeb;
  border-radius: 10px;
  padding: 11px 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.9rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
}

.info-icon-wrap {
  background: #FFA000;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.info-icon-wrap.sq {
  border-radius: 8px;
}

.btn-evento-action {
  background: #FFA000;
  color: white;
  border: none;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 1.5px;
  padding: 14px;
  border-radius: 10px;
  cursor: pointer;
  width: 100%;
  margin-top: 14px;
  transition: background .2s;
}

.btn-evento-action:hover {
  background: #e65100;
}

/* =========================================
   RESPONSIVE
   ========================================= */

/* Tablet e mobile (< 992px) */
@media (max-width: 991.98px) {

  /* Admin: form sopra, tabella sotto */
  .row>[class*="col-md-4"],
  .row>[class*="col-md-8"] {
    flex: 0 0 100%;
    max-width: 100%;
  }

  /* Card header con azioni: stack */
  .card-header.d-flex {
    flex-wrap: wrap;
    gap: .4rem;
  }
}

/* Mobile (< 768px) */
@media (max-width: 767.98px) {

  /* Titoli */
  .page-title {
    font-size: 1.1rem;
    margin-bottom: .8rem;
  }

  /* Container padding ridotto */
  .container-fluid.py-4 {
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
  }

  /* Card body */
  .card-body {
    padding: .75rem;
  }

  .card-header {
    padding: .6rem .75rem;
    font-size: .88rem;
  }

  /* Stat cards */
  .stat-card .stat-number {
    font-size: 1.6rem;
  }

  /* Tabelle: font più piccolo */
  .table {
    font-size: .7rem;
  }

  .table th,
  .table td {
    padding: .4rem .5rem;
  }

  /* Bottoni azione: touch target adeguato */
  .btn-action {
    padding: .4rem .55rem;
    font-size: .8rem;
  }

  /* Badge */
  .badge {
    font-size: .7rem;
  }

  /* Profilo: stack colonne interne */
  .row.g-3>.col {
    flex: 0 0 100%;
    max-width: 100%;
  }

  /* Index: stat cards 2 colonne (già col-6) OK */

  /* Admin presenze: input time compatti */
  input[type="time"] {
    min-width: 90px;
  }

  /* Footer */
  footer {
    font-size: .78rem;
    padding: .6rem !important;
  }
}

/* Mobile piccolo (< 576px) */
@media (max-width: 575.98px) {

  /* Lista eventi marshal */
  .eventi-list {
    max-width: 100%;
  }

  .data-box {
    width: 180px;
    min-height: 130px;
  }

  .data-box .data-num {
    font-size: 2rem;
  }

  .data-box .data-giorno,
  .data-box .data-mese {
    font-size: 1.5rem;
  }

  .dot {
    width: 30px;
    height: 30px;
  }

  .semaforo {
    gap: 14px;
    padding-right: 14px;
  }

  .evento-nome {
    font-size: 1rem;
  }

  /* Modal evento: quasi full-screen */
  .modal-evento .modal-dialog {
    margin: .4rem;
    max-width: calc(100vw - .8rem);
  }

  .modal-evento .modal-body {
    padding: 10px;
  }

  .evento-card {
    padding: 16px 12px 14px;
  }

  .evento-card-title {
    font-size: 1.05rem;
  }

  .info-row {
    padding: 9px 12px;
    font-size: .82rem;
    gap: 10px;
  }

  .info-icon-wrap {
    width: 30px;
    height: 30px;
    font-size: .85rem;
  }

  .btn-evento-action {
    padding: 12px;
    font-size: .88rem;
  }

  /* Tabelle admin: nascondi colonne secondarie su xs */
  .d-none-xs {
    display: none !important;
  }

  /* Form row g-2: stack su xs */
  .row.g-2>.col {
    flex: 0 0 100%;
    max-width: 100%;
  }

  /* Bottoni inline nelle tabelle: più spazio */
  .btn-action {
    padding: .45rem .6rem;
  }

  /* Navbar badge ruolo: nascondi su xs */
  .navbar .badge {
    display: none;
  }
}

/* ── Custom circuit select (csc) ─────────────────────────────────────────── */
.csc-wrap { position: relative; }
.csc-toggle {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 10px; border: 1px solid #ced4da; border-radius: .375rem;
  background: #fff; font-size: .875rem; min-height: 31px;
  cursor: pointer; user-select: none;
}
.csc-wrap:focus-within .csc-toggle { box-shadow: 0 0 0 .25rem rgba(13,110,253,.25); }
.csc-wrap:focus-within .csc-toggle,
.csc-wrap.open .csc-toggle { border-color: #86b7fe; }
.csc-icon { width: 22px; height: 22px; object-fit: contain; border-radius: 3px; flex-shrink: 0; }
.csc-icon-ph {
  width: 22px; height: 22px; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; color: #aaa; font-size: .9rem;
}
.csc-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.csc-arrow { font-size: .7rem; color: #666; transition: transform .15s; margin-left: auto; flex-shrink: 0; }
.csc-wrap.open .csc-arrow { transform: rotate(180deg); }
.csc-menu {
  display: none; position: absolute; top: calc(100% + 2px); left: 0; right: 0;
  z-index: 1050; background: #fff; border: 1px solid #ced4da; border-radius: .375rem;
  box-shadow: 0 4px 14px rgba(0,0,0,.12); max-height: 240px; overflow-y: auto;
}
.csc-wrap.open .csc-menu { display: block; }
.csc-opt {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; font-size: .875rem; cursor: pointer; transition: background .1s;
}
.csc-opt:hover { background: #f5f5f5; }
.csc-opt.active { background: #fff3e0; font-weight: 600; }