/* ============================================================
   SquadraFacile — modern UI theme on top of Bootstrap 5
   ============================================================ */

:root {
    --sg-bg:           #f4f6fb;
    --sg-panel:        #ffffff;
    --sg-border:       #e3e7ef;
    --sg-text:         #1d2330;
    --sg-text-soft:    #5a6478;
    --sg-muted:        #8a93a8;

    --sg-primary:      #2f54eb;
    --sg-primary-50:   #eaf0ff;
    --sg-primary-700:  #1f3aa6;

    --sg-success:      #10b981;
    --sg-danger:       #ef4444;
    --sg-warning:      #f59e0b;

    --sg-shadow:       0 1px 2px rgba(16,24,40,.06), 0 4px 14px rgba(16,24,40,.05);
    --sg-radius:       14px;
    --sg-radius-sm:    10px;

    --sg-sidebar-w:    272px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }
body.sg-body {
    margin: 0;
    background: var(--sg-bg);
    color: var(--sg-text);
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
    font-size: 14.5px;
    line-height: 1.5;
}

/* ---------------------------------- Layout shell --------- */
.sg-shell {
    display: flex;
    min-height: 100vh;
}

.sg-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin-left: var(--sg-sidebar-w);
}

.sg-content {
    flex: 1;
    width: 100%;
    max-width: 100%;
    /* Responsive horizontal padding: shrinks on small screens, caps at
       56px on large ones. Tables and grids stretch to full available width. */
    padding: 24px clamp(16px, 2.5vw, 56px) 40px;
}

/* ---------------------------------- Sidebar -------------- */
.sg-sidebar {
    width: var(--sg-sidebar-w);
    position: fixed;
    inset: 0 auto 0 0;
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    color: #cbd5e1;
    padding: 22px 14px 20px;
    overflow-y: auto;
    box-shadow: 4px 0 20px rgba(15, 23, 42, .08);
}

.sg-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    padding: 6px 8px 18px;
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.sg-brand__logo {
    width: 92px; height: 92px;
    border-radius: 20px;
    object-fit: contain;
    background: #fff;
    padding: 6px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, .25),
                inset 0 0 0 1px rgba(255, 255, 255, .08);
}
.sg-brand__placeholder {
    width: 92px; height: 92px; border-radius: 20px;
    background: linear-gradient(135deg, #2f54eb, #6f7bff);
    color: #fff; display: grid; place-items: center; font-size: 38px;
    box-shadow: 0 8px 20px rgba(47, 84, 235, .35);
}
.sg-brand__text {
    min-width: 0;
    width: 100%;
}
.sg-brand__name {
    font-weight: 600;
    color: #f8fafc;
    font-size: 15px;
    line-height: 1.25;
    /* Allow long club names to break over up to 3 lines, then ellipsis */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
    hyphens: auto;
}
.sg-brand__sub {
    font-size: 11.5px;
    color: #94a3b8;
    margin-top: 2px;
    letter-spacing: .02em;
    text-transform: uppercase;
}

/* Chip ruolo sotto il nome società (sidebar scura). Un colore per ruolo
   come segnale d'identità rapido; tinte translucide coordinate al tema. */
.sg-role-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 9px;
    padding: 3px 11px 3px 9px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    line-height: 1;
    border: 1px solid transparent;
    white-space: nowrap;
}
.sg-role-chip__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex: none;
}
.sg-role-chip--club-admin {
    color: #c2d2ff;
    background: rgba(47, 84, 235, .18);
    border-color: rgba(47, 84, 235, .38);
}
.sg-role-chip--club-admin .sg-role-chip__dot {
    background: #6b8bff;
    box-shadow: 0 0 0 3px rgba(47, 84, 235, .25);
}
.sg-role-chip--secretary {
    color: #9bedcb;
    background: rgba(16, 185, 129, .16);
    border-color: rgba(16, 185, 129, .34);
}
.sg-role-chip--secretary .sg-role-chip__dot {
    background: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, .22);
}
.sg-role-chip--accountant {
    color: #fcd9a1;
    background: rgba(245, 158, 11, .16);
    border-color: rgba(245, 158, 11, .34);
}
.sg-role-chip--accountant .sg-role-chip__dot {
    background: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, .22);
}
.sg-role-chip--sponsor {
    color: #cdbcff;
    background: rgba(139, 92, 246, .18);
    border-color: rgba(139, 92, 246, .38);
}
.sg-role-chip--sponsor .sg-role-chip__dot {
    background: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, .25);
}

.sg-nav { display: flex; flex-direction: column; gap: 2px; }
.sg-nav__section {
    text-transform: uppercase;
    font-size: 10.5px;
    letter-spacing: .08em;
    color: #64748b;
    margin: 18px 12px 6px;
}
.sg-nav__item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    color: #cbd5e1;
    text-decoration: none;
    transition: background .15s, color .15s;
    font-size: 14px;
}
.sg-nav__item i { font-size: 17px; opacity: .85; }
.sg-nav__item:hover { background: rgba(255,255,255,.06); color: #f8fafc; }
.sg-nav__item.is-active {
    background: rgba(47,84,235,.18);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--sg-primary);
}

/* ---------------------------------- Topbar --------------- */
.sg-topbar {
    background: var(--sg-panel);
    border-bottom: 1px solid var(--sg-border);
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
}
.sg-topbar__title {
    font-size: 18px;
    font-weight: 600;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Hamburger: hidden on desktop, shown ≤992px (see Responsive section). */
.sg-navtoggle {
    display: none;
    flex: 0 0 auto;
    width: 42px; height: 42px;
    align-items: center; justify-content: center;
    background: transparent;
    border: 1px solid var(--sg-border);
    border-radius: var(--sg-radius-sm);
    color: var(--sg-text);
    font-size: 20px;
    margin-right: 4px;
}
.sg-navtoggle:hover { background: var(--sg-primary-50); color: var(--sg-primary); }
.sg-navtoggle:active { transform: scale(.96); }
/* Dim backdrop behind the off-canvas drawer (mobile only). */
.sg-backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, .5);
    opacity: 0; visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
    z-index: 40;
}
.sg-backdrop.is-visible { opacity: 1; visibility: visible; }
.sg-userbtn {
    display: flex; align-items: center; gap: 10px;
    background: transparent;
    border: 1px solid var(--sg-border);
    border-radius: 999px;
    padding: 4px 12px 4px 4px;
    color: var(--sg-text);
}
.sg-userbtn:hover { background: var(--sg-primary-50); }
.sg-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: linear-gradient(135deg, var(--sg-primary), #6f7bff);
    color: #fff; display: grid; place-items: center; font-weight: 600;
}
.sg-avatar--img { object-fit: cover; overflow: hidden; padding: 0; }
.sg-userbtn__info { text-align: left; line-height: 1.1; }
.sg-userbtn__name { font-size: 13.5px; font-weight: 600; }
.sg-userbtn__role { font-size: 11.5px; color: var(--sg-muted); }

/* ---------------------------------- Cards ---------------- */
.sg-page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin: 0 0 22px;
    flex-wrap: wrap; gap: 12px;
}
.sg-page-header h1 {
    font-size: 22px; font-weight: 700; margin: 0;
}
.sg-page-header .breadcrumb { margin-bottom: 0; }

.sg-card {
    background: var(--sg-panel);
    border: 1px solid var(--sg-border);
    border-radius: var(--sg-radius);
    box-shadow: var(--sg-shadow);
    padding: 20px 22px;
    margin-bottom: 20px;
}
.sg-card__header {
    display: flex; align-items: center; justify-content: space-between;
    margin: -4px 0 14px;
}
.sg-card__title { font-size: 15px; font-weight: 600; margin: 0; }

/* ---------------------------------- Hero (dashboard) ------ */
.sg-hero {
    background:
        linear-gradient(120deg, rgba(47,84,235,.10) 0%, rgba(111,123,255,.08) 50%, rgba(16,185,129,.08) 100%),
        var(--sg-panel);
    border: 1px solid var(--sg-border);
    border-radius: var(--sg-radius);
    padding: 22px 24px;
    margin-bottom: 22px;
    display: flex; flex-wrap: wrap;
    align-items: center; justify-content: space-between;
    gap: 18px;
    box-shadow: var(--sg-shadow);
}
.sg-hero__title {
    font-size: 24px; font-weight: 700; margin: 0;
    background: linear-gradient(120deg, #2f54eb, #6f7bff 60%, #10b981);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.sg-hero__sub { color: var(--sg-text-soft); font-size: 13.5px; margin-top: 4px; }
.sg-hero__quick {
    display: flex; flex-wrap: wrap; gap: 10px;
}
.sg-quick {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 14px;
    background: #fff;
    border: 1px solid var(--sg-border);
    border-radius: var(--sg-radius-sm);
    color: var(--sg-text);
    text-decoration: none;
    font-size: 13.5px; font-weight: 500;
    transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease, color .12s ease;
    box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.sg-quick i { font-size: 16px; color: var(--sg-primary); }
.sg-quick:hover {
    transform: translateY(-2px);
    border-color: var(--sg-primary);
    box-shadow: 0 6px 16px rgba(47,84,235,.18);
    color: var(--sg-primary);
}

/* ---------------------------------- KPI cards ------------ */
.sg-kpi-grid {
    display: grid;
    /* auto-fit collapses empty columns so the items always stretch to
       fill the full row, no matter how wide the viewport gets. */
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.sg-kpi {
    background: var(--sg-panel);
    border: 1px solid var(--sg-border);
    border-radius: var(--sg-radius);
    padding: 18px 18px 16px;
    box-shadow: var(--sg-shadow);
    display: flex; flex-direction: column;
    gap: 4px;
    position: relative;
    overflow: hidden;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.sg-kpi::after {
    /* subtle accent strip on the left edge */
    content: '';
    position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
    background: var(--sg-primary);
    opacity: 0;
    transition: opacity .2s ease;
}
.sg-kpi:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(15,23,42,.08), 0 2px 6px rgba(15,23,42,.05);
    border-color: var(--sg-primary-50);
}
.sg-kpi:hover::after { opacity: 1; }

.sg-kpi__label { font-size: 12.5px; color: var(--sg-muted); text-transform: uppercase; letter-spacing: .04em; }
.sg-kpi__value { font-size: 28px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.sg-kpi__hint  { font-size: 12.5px; color: var(--sg-text-soft); }
.sg-kpi__icon {
    position: absolute; right: 14px; top: 14px;
    width: 38px; height: 38px;
    background: var(--sg-primary-50);
    color: var(--sg-primary);
    border-radius: 12px;
    display: grid; place-items: center;
    font-size: 18px;
}
.sg-kpi.is-success .sg-kpi__icon  { background: #ecfdf5; color: #047857; }
.sg-kpi.is-success::after         { background: #10b981; }
.sg-kpi.is-danger  .sg-kpi__icon  { background: #fef2f2; color: #b91c1c; }
.sg-kpi.is-danger::after          { background: #ef4444; }
.sg-kpi.is-warning .sg-kpi__icon  { background: #fffbeb; color: #b45309; }
.sg-kpi.is-warning::after         { background: #f59e0b; }
.sg-kpi.is-success .sg-kpi__value { color: #047857; }
.sg-kpi.is-danger  .sg-kpi__value { color: #b91c1c; }

/* ---------------------------------- Activity timeline ----- */
.sg-activity .sg-card__header { margin-bottom: 12px; }
.sg-timeline { list-style: none; padding: 0; margin: 0; }
.sg-timeline__item {
    position: relative;
    padding: 10px 0 10px 22px;
    border-left: 2px solid var(--sg-border);
    margin-left: 6px;
}
.sg-timeline__item:last-child { padding-bottom: 0; }
.sg-timeline__dot {
    position: absolute; left: -7px; top: 14px;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--sg-primary);
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px var(--sg-border);
}
.sg-timeline__dot.is-success { background: var(--sg-success); }
.sg-timeline__dot.is-danger  { background: var(--sg-danger); }
.sg-timeline__title { font-weight: 600; font-size: 13.5px; color: var(--sg-text); }
.sg-timeline__text  { color: var(--sg-text-soft); font-size: 13px; margin-top: 2px; }
.sg-timeline__meta  { color: var(--sg-muted); font-size: 11.5px; margin-top: 4px; }

/* ---------------------------------- Enrollment list (member detail) */
.sg-enroll-list { list-style: none; padding: 0; margin: 0 0 6px; }
.sg-enroll-list__item {
    padding: 10px 0;
    border-bottom: 1px dashed var(--sg-border);
}
.sg-enroll-list__item:last-child { border-bottom: 0; }
.sg-enroll-list--past .sg-enroll-list__item { color: var(--sg-text-soft); }
.sg-enroll-list--past .sg-enroll-list__item i { color: var(--sg-muted); }

/* ---------------------------------- Unpaid fees widget ---- */
.sg-unpaid { list-style: none; padding: 0; margin: 0; max-height: 360px; overflow-y: auto; }
.sg-unpaid__item {
    padding: 12px 0;
    border-bottom: 1px dashed var(--sg-border);
}
.sg-unpaid__item:last-child { border-bottom: 0; }
.sg-unpaid__head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; margin-bottom: 6px;
}
.sg-unpaid__name {
    font-weight: 600; color: var(--sg-text);
    text-decoration: none;
}
.sg-unpaid__name:hover { color: var(--sg-primary); }
.sg-unpaid__months {
    display: flex; flex-wrap: wrap; gap: 6px;
}
.sg-unpaid__chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 9px;
    background: #fef2f2;
    color: #b91c1c;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid #fecaca;
}
.sg-unpaid__chip i { font-size: 11px; }

/* ---------------------------------- Tables --------------- */
.sg-table-wrap {
    background: var(--sg-panel);
    border: 1px solid var(--sg-border);
    border-radius: var(--sg-radius);
    overflow: hidden;
    box-shadow: var(--sg-shadow);
}

/* ---------------------------------- DataTables integration --
   We use DataTables v2.x with the bootstrap5 styling adapter. The
   adapter generates `.dt-container` + Bootstrap row/col classes for
   search/length/info/paging. Below we make those blocks visually
   coherent with the SquadraFacile sg-table look. */
.sg-table-wrap .dt-container {
    padding: 14px 16px 4px;
    background: var(--sg-panel);
}
.sg-table-wrap .dt-container .dt-search,
.sg-table-wrap .dt-container .dt-length {
    margin-bottom: 12px;
    color: var(--sg-text-soft);
    font-size: 13.5px;
}
.sg-table-wrap .dt-container .dt-search input,
.sg-table-wrap .dt-container .dt-length select {
    border-radius: var(--sg-radius-sm);
    border: 1px solid var(--sg-border);
    padding: 5px 10px;
    font-size: 13.5px;
    background: #fff;
    margin-left: 6px;
}
.sg-table-wrap .dt-container .dt-search input:focus,
.sg-table-wrap .dt-container .dt-length select:focus {
    outline: none;
    border-color: var(--sg-primary);
    box-shadow: 0 0 0 .15rem rgba(47,84,235,.15);
}
.sg-table-wrap .dt-container .dt-info {
    color: var(--sg-muted);
    font-size: 12.5px;
    padding: 10px 0 14px;
}
.sg-table-wrap .dt-container .dt-paging .pagination {
    margin: 8px 0 14px;
    gap: 4px;
}
.sg-table-wrap .dt-container .pagination .page-link {
    color: var(--sg-text);
    border: 1px solid var(--sg-border);
    border-radius: var(--sg-radius-sm) !important;
    padding: 5px 10px;
    font-size: 13px;
}
.sg-table-wrap .dt-container .pagination .page-item.active .page-link {
    background: var(--sg-primary);
    border-color: var(--sg-primary);
    color: #fff;
}
.sg-table-wrap .dt-container .pagination .page-item.disabled .page-link {
    color: var(--sg-muted);
    background: transparent;
}
/* Override sg-table thead UPPERCASE+small for DT (already styled the same,
   but DT may inject `dt-orderable-asc/dsc` icons that we want to align). */
.sg-table-wrap table.sg-table thead th {
    position: relative;
    cursor: pointer;
    user-select: none;
}
.sg-table-wrap table.sg-table thead th:not(.dt-orderable-none):after {
    /* leave room for the DataTables sort caret rendered by the adapter */
    content: '';
}
.sg-table-wrap table.dataTable.no-footer { border-bottom: 0; }
.sg-table-wrap table.dataTable > thead > tr > th.dt-orderable-asc,
.sg-table-wrap table.dataTable > thead > tr > th.dt-orderable-desc { padding-right: 30px; }
.sg-table-wrap div.dt-scroll-body { overflow-x: hidden; }
/* Tame "—" empty cells / muted rows */
.sg-table-wrap table.sg-table tbody tr.text-muted td { color: var(--sg-muted); }
.sg-table { width: 100%; border-collapse: collapse; }
.sg-table thead th {
    background: #f7f9fd;
    color: var(--sg-text-soft);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .05em;
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--sg-border);
}
.sg-table tbody td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--sg-border);
    font-size: 14px;
    vertical-align: middle;
}
.sg-table tbody tr:last-child td { border-bottom: 0; }
.sg-table tbody tr:hover { background: #fafbff; }
/* Seasonal-fee sub-line in fee cells: compact + muted on desktop
   (the mobile card layout promotes it to a full label/value row — see
   Responsive). */
.sg-fee-extra { font-size: .82em; color: var(--sg-muted); }
.sg-fee-extra__lbl::after { content: ": "; }
.sg-table .text-end { text-align: right; }
.sg-table .num { font-variant-numeric: tabular-nums; }
.sg-empty { padding: 28px; text-align: center; color: var(--sg-muted); }

/* ---------------------------------- Badges --------------- */
.sg-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    background: #eef1f6;
    color: var(--sg-text-soft);
}
.sg-badge.is-success { background: #dcfce7; color: #047857; }
.sg-badge.is-danger  { background: #fee2e2; color: #b91c1c; }
.sg-badge.is-warning { background: #fef3c7; color: #b45309; }
.sg-badge.is-primary { background: var(--sg-primary-50); color: var(--sg-primary-700); }

/* ---------------------------------- Buttons -------------- */
.btn { border-radius: var(--sg-radius-sm); font-weight: 500; }
.btn-primary { background-color: var(--sg-primary); border-color: var(--sg-primary); }
.btn-primary:hover { background-color: var(--sg-primary-700); border-color: var(--sg-primary-700); }
.btn-outline-secondary { color: var(--sg-text-soft); border-color: var(--sg-border); }
.btn-outline-secondary:hover { background: #f7f9fd; color: var(--sg-text); }

.sg-toolbar {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
    margin-bottom: 16px;
    background: var(--sg-panel);
    border: 1px solid var(--sg-border);
    border-radius: var(--sg-radius);
    padding: 12px 16px;
    box-shadow: var(--sg-shadow);
}
.sg-toolbar .form-control,
.sg-toolbar .form-select { border-radius: var(--sg-radius-sm); }

/* ---------------------------------- Forms ---------------- */
.form-label { font-weight: 500; font-size: 13.5px; color: var(--sg-text-soft); }
.form-control, .form-select {
    border-radius: var(--sg-radius-sm);
    border-color: var(--sg-border);
    padding: 8px 12px;
}
.form-control:focus, .form-select:focus {
    border-color: var(--sg-primary);
    box-shadow: 0 0 0 .15rem rgba(47, 84, 235, .15);
}

/* ------------------------------ Financial filter --------- */
.sg-fin-filter {
    display: flex; flex-wrap: wrap; gap: 16px 20px; align-items: flex-end;
}
.sg-fin-filter__field { display: flex; flex-direction: column; gap: 6px; }
.sg-fin-filter__field > .form-label { margin: 0; }
.sg-fin-filter .sg-fin-mode-panel { display: flex; flex-wrap: wrap; gap: 16px 20px; align-items: flex-end; }
.sg-fin-filter .sg-fin-mode-panel[hidden] { display: none; }
.sg-fin-filter .sg-fin-actions { margin-left: auto; align-self: flex-end; }

/* Segmented toggle (season vs range) */
.sg-segmented {
    display: inline-flex; padding: 3px; gap: 2px;
    background: var(--sg-bg); border: 1px solid var(--sg-border);
    border-radius: var(--sg-radius-sm);
}
.sg-segmented input { position: absolute; opacity: 0; pointer-events: none; }
.sg-segmented label {
    display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
    padding: 7px 16px; border-radius: 8px; font-size: 13.5px; font-weight: 600;
    color: var(--sg-text-soft); white-space: nowrap; user-select: none;
    transition: background .12s ease, color .12s ease, box-shadow .12s ease;
}
.sg-segmented input:checked + label {
    background: var(--sg-panel); color: var(--sg-primary);
    box-shadow: var(--sg-shadow);
}
.sg-segmented label:hover { color: var(--sg-primary); }
.sg-segmented input:focus-visible + label {
    outline: 2px solid var(--sg-primary); outline-offset: 1px;
}
.sg-fin-range-to { display: inline-flex; align-items: center; gap: 8px; }
.sg-fin-range-to::before {
    content: "→"; color: var(--sg-text-soft); font-weight: 600; align-self: center;
    margin-bottom: 8px;
}
@media (max-width: 640px) {
    .sg-fin-filter .sg-fin-actions { margin-left: 0; width: 100%; }
    .sg-fin-filter .sg-fin-actions .btn { width: 100%; }
}

/* ---------------------------------- Guest / Login -------- */
body.sg-guest-body {
    margin: 0;
    min-height: 100vh;
    color: var(--sg-text);
    font-family: "Inter", "Segoe UI", system-ui, sans-serif;
    /* Multi-layer gradient: 2 soft color blobs + base off-white,
       with a subtle dot grid to add depth. */
    background:
        radial-gradient(800px 520px at 12% 8%,   rgba(47, 84, 235, .22), transparent 65%),
        radial-gradient(720px 480px at 88% 102%, rgba(111, 123, 255, .22), transparent 65%),
        radial-gradient(600px 460px at 100% 0%,  rgba(16, 185, 129, .14), transparent 65%),
        #eef2ff;
    display: grid; place-items: center;
    padding: 24px 16px;
    position: relative;
    overflow-x: hidden;
}
body.sg-guest-body::before {
    content: '';
    position: fixed; inset: 0;
    background-image: radial-gradient(rgba(15,23,42,.06) 1px, transparent 1px);
    background-size: 26px 26px;
    pointer-events: none;
    z-index: 0;
}

.sg-guest-wrap {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 460px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    align-items: stretch;
    animation: sg-login-rise .55s cubic-bezier(.2, .8, .2, 1);
}
@keyframes sg-login-rise {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Hero with the platform logo on top of the card */
.sg-login-hero {
    text-align: center;
    padding: 8px 0 4px;
}
.sg-login-hero__logo {
    width: 184px;
    height: 184px;
    object-fit: contain;
    background: #fff;
    border-radius: 34px;
    padding: 18px;
    box-shadow:
        0 26px 60px rgba(47, 84, 235, .28),
        0 8px 18px rgba(15, 23, 42, .10);
    margin-bottom: 22px;
    transition: transform .25s ease;
}
.sg-login-hero__logo:hover { transform: translateY(-2px) rotate(-1deg); }
.sg-login-hero__title {
    font-size: 26px;
    font-weight: 700;
    margin: 0;
    background: linear-gradient(120deg, #2f54eb, #6f7bff 60%, #10b981);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.sg-login-hero__subtitle {
    color: var(--sg-text-soft);
    font-size: 14px;
    margin: 6px 0 0;
}

/* Glassmorphism card around the form */
.sg-login-card {
    background: rgba(255, 255, 255, .85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, .6);
    border-radius: 20px;
    box-shadow:
        0 30px 80px rgba(15, 23, 42, .12),
        0 2px 4px rgba(15, 23, 42, .04);
    padding: 30px 28px;
}
.sg-login-card .form-label {
    font-weight: 500;
    font-size: 13px;
    color: var(--sg-text-soft);
    margin-bottom: 6px;
}
.sg-login-card .input-group-text {
    background: #fff;
    border-right: 0;
    color: var(--sg-muted);
}
.sg-login-card .form-control {
    border-left: 0;
    padding: 10px 12px;
}
.sg-login-card .input-group {
    border-radius: var(--sg-radius-sm);
    transition: box-shadow .15s ease, border-color .15s ease;
}
.sg-login-card .input-group:focus-within {
    box-shadow: 0 0 0 .18rem rgba(47, 84, 235, .15);
}
.sg-login-card .input-group:focus-within .input-group-text,
.sg-login-card .input-group:focus-within .form-control {
    border-color: var(--sg-primary);
}
.sg-login-card .input-group:focus-within .input-group-text {
    color: var(--sg-primary);
}
.sg-login-card .form-control:focus {
    box-shadow: none;
    outline: 0;
}

/* Gradient primary login button */
.sg-login-btn {
    background: linear-gradient(120deg, #2f54eb, #6f7bff);
    border: 0;
    padding: 11px 16px;
    font-weight: 600;
    letter-spacing: .01em;
    box-shadow: 0 10px 24px rgba(47, 84, 235, .35);
    transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
.sg-login-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 30px rgba(47, 84, 235, .45);
    filter: brightness(1.05);
}
.sg-login-btn:active { transform: translateY(0); }

.sg-login-foot {
    text-align: center;
    color: var(--sg-muted);
    font-size: 12.5px;
    margin-top: 8px;
}
.sg-login-foot__author {
    text-decoration: none;
    font-weight: 600;
    background: linear-gradient(120deg, var(--sg-primary), #6f7bff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.sg-login-foot__author:hover { filter: brightness(1.15); }

@media (max-width: 480px) {
    .sg-login-hero__logo { width: 132px; height: 132px; padding: 14px; border-radius: 28px; }
    .sg-login-hero__title { font-size: 22px; }
    .sg-login-card { padding: 22px 18px; }
}

/* Legacy class still used by sidebar for the in-app logo fallback */
.sg-brand__logo--app {
    background: #fff;
    padding: 4px;
    object-fit: contain;
}

/* ---------------------------------- Misc ----------------- */
.sg-section-title {
    font-size: 16px; font-weight: 600; margin: 30px 0 12px;
}
/* Modal title with a subject (e.g. a person's name): the subject sits on
   its own line, smaller and lighter, so long names never wrap mid-word.
   Force the title to span the header and stay left-aligned (in a flex
   header the h5 otherwise shrinks to content and the second line looks
   off-centre). */
.modal-header .modal-title { flex: 1 1 auto; min-width: 0; text-align: left; }
.sg-modal-subject {
    display: block;
    font-size: .82em;
    font-weight: 500;
    color: var(--sg-text-soft);
    margin-top: 2px;
    text-align: left;
}

/* Detail cards (e.g. member detail): on phones the label/value dl stacks
   and long unbreakable values (email, fiscal code) wrap instead of
   overflowing the card. */
@media (max-width: 640px) {
    .sg-card dl.row > dt,
    .sg-card dl.row > dd {
        flex: 0 0 100%; max-width: 100%;
    }
    .sg-card dl.row > dt { margin-bottom: 1px; }
    .sg-card dl.row > dd { margin-bottom: 10px; overflow-wrap: anywhere; }
    /* Guardian block (plain divs) also breaks long values. */
    .sg-card .row > [class*="col-"] > div { overflow-wrap: anywhere; }
}

/* ---------------------------------- Profile -------------- */
.sg-profile-avatar {
    width: 104px; height: 104px; border-radius: 50%;
    background: linear-gradient(135deg, var(--sg-primary), #6f7bff);
    color: #fff; font-size: 42px; font-weight: 600;
    display: grid; place-items: center; overflow: hidden;
    box-shadow: 0 8px 22px rgba(47, 84, 235, .30);
}
.sg-profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sg-profile-avatar--sm { width: 64px; height: 64px; font-size: 26px; box-shadow: none; flex: 0 0 auto; }

/* Branded hero header */
.sg-profile-hero { padding: 0; overflow: hidden; }
.sg-profile-hero__cover {
    height: 104px;
    /* Same dark navy as the sidebar, for a cohesive shell. */
    background:
        radial-gradient(120% 160% at 0% 0%, rgba(255,255,255,.08), transparent 60%),
        linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}
.sg-profile-hero__body {
    display: flex; align-items: flex-end; flex-wrap: wrap; gap: 6px 20px;
    /* Sits BELOW the cover (on white); only the avatar pokes up into it. */
    padding: 16px 24px 20px;
}
.sg-profile-avatar--hero {
    width: 96px; height: 96px; font-size: 38px; flex: 0 0 auto;
    margin-top: -68px;            /* overlaps the cover band */
    border: 4px solid var(--sg-panel);
    box-shadow: 0 10px 24px rgba(15, 23, 42, .18);
}
.sg-profile-hero__id { flex: 1 1 auto; min-width: 0; padding-bottom: 4px; }
.sg-profile-name { font-size: 22px; font-weight: 700; margin: 0 0 8px; line-height: 1.2; }
.sg-profile-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sg-profile-hero__meta {
    display: flex; flex-wrap: wrap; gap: 8px 28px; padding-bottom: 6px;
}
.sg-profile-meta__item { display: flex; flex-direction: column; gap: 3px; }
.sg-profile-meta__lbl {
    font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
    color: var(--sg-muted); font-weight: 600;
}
.sg-profile-meta__val { font-weight: 600; color: var(--sg-text); overflow-wrap: anywhere; }

.sg-profile-uploader { display: flex; align-items: center; gap: 16px; }
/* Avatar crop modal */
.sg-crop-wrap { max-height: 60vh; }
.sg-crop-wrap > img { display: block; max-width: 100%; }
@media (max-width: 640px) {
    /* Hero stacks and centers on phones. */
    .sg-profile-hero__body { flex-direction: column; align-items: center; text-align: center; }
    .sg-profile-hero__meta { justify-content: center; gap: 10px 24px; margin-top: 6px; }
    .sg-profile-meta__item { align-items: center; }
    .sg-profile-chips { justify-content: center; }
}
@media (max-width: 480px) {
    .sg-profile-uploader { flex-direction: column; align-items: flex-start; }
}

/* Minor (under-18) marker: icon-only on desktop (hover tooltip), icon +
   "Minorenne" word on phones where tap tooltips don't fire. */
.sg-minor-badge__txt { display: none; }
@media (max-width: 640px) {
    .sg-minor-badge__txt { display: inline; margin-left: 4px; }
}

/* Training-session detail header meta. Desktop: items in a spaced wrapping
   row. Mobile: one item per line, with the status chips below. */
.sg-ts-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; margin-top: 4px; }
.sg-ts-meta__item { display: inline-flex; align-items: center; gap: 6px; }
.sg-ts-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
@media (max-width: 640px) {
    .sg-ts-meta { flex-direction: column; align-items: flex-start; gap: 9px; }
    .sg-ts-meta__item { width: 100%; }
}
.sg-empty-illustration {
    text-align: center; padding: 40px 20px; color: var(--sg-muted);
}
.sg-empty-illustration i { font-size: 40px; opacity: .6; }
.text-money { font-variant-numeric: tabular-nums; }
.text-money.positive { color: #047857; }
.text-money.negative { color: #b91c1c; }

/* ---------------------------------- Footer -------------- */
.sg-footer {
    padding: 18px clamp(16px, 2.5vw, 56px);
    border-top: 1px solid var(--sg-border);
    background: var(--sg-panel);
    color: var(--sg-text-soft);
    font-size: 13px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    justify-content: center;
}
.sg-footer__sep { opacity: .5; }
.sg-footer__author {
    text-decoration: none;
    font-weight: 600;
    background: linear-gradient(120deg, var(--sg-primary), #6f7bff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.sg-footer__author:hover { filter: brightness(1.1); }
.sg-heart {
    display: inline-block;
    color: #ef4444;
    transform: translateY(1px);
    animation: sg-heartbeat 1.5s ease-in-out infinite;
}
@keyframes sg-heartbeat {
    0%, 100% { transform: translateY(1px) scale(1); }
    25%      { transform: translateY(1px) scale(1.18); }
    50%      { transform: translateY(1px) scale(.95); }
    75%      { transform: translateY(1px) scale(1.1); }
}

/* ---------------------------------- Club context switcher -- */
.sg-ctxbtn {
    background: var(--sg-panel);
    border: 1px solid var(--sg-border);
    border-radius: 10px;
    padding: 6px 12px;
    color: var(--sg-text);
    font-size: 13px;
    display: inline-flex;
    align-items: center;
}
.sg-ctxbtn:hover { background: var(--sg-primary-50); border-color: var(--sg-primary); }
.sg-ctx-dropdown { min-width: 260px; max-height: 420px; overflow-y: auto; }

/* ---------------------------------- Locked / readonly fields */
.form-control[readonly],
.form-select[readonly] {
    background-color: #eef1f6;
    color: var(--sg-text-soft);
    cursor: not-allowed;
    border-color: var(--sg-border);
    box-shadow: none;
}
.form-control[readonly]:focus,
.form-select[readonly]:focus {
    outline: none;
    border-color: var(--sg-border);
    box-shadow: none;
}
.input-group:has(> .form-control[readonly]) .input-group-text {
    background-color: #e6eaf2;
    color: var(--sg-muted);
    border-color: var(--sg-border);
}
.sg-locked-hint {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--sg-muted);
    font-size: 12px;
    margin-top: 4px;
}
.sg-locked-hint .bi-lock-fill { color: var(--sg-warning); }

/* ---------------------------------- Payment history modal -- */
.sg-history-popup { padding: 1.25rem 1.5rem !important; }
.sg-history-popup .swal2-title { padding: 0 0 .5rem; }
.sg-history-popup .swal2-html-container { margin: 0; max-width: 100%; overflow-x: hidden; }
.sg-history-wrap { max-height: 60vh; overflow-y: auto; overflow-x: hidden; }
.sg-history-wrap .sg-table { table-layout: auto; }
.sg-history-wrap .sg-table th,
.sg-history-wrap .sg-table td { white-space: normal; word-break: break-word; }
.sg-history-wrap .dataTables_wrapper { overflow-x: hidden; }
/* DataTables inner scroll: remove the X scrollbar from the body */
.sg-history-wrap div.dt-scroll-body { overflow-x: hidden !important; }

/* History popup title: subject (person) on its own line, smaller. */
.sg-swal-subject {
    display: block;
    font-size: .58em;
    font-weight: 500;
    color: var(--sg-text-soft);
    margin-top: 6px;
}
@media (max-width: 640px) {
    .sg-history-popup { padding: 1rem 1rem !important; }
    .sg-history-popup .swal2-title { font-size: 1.25rem; }
    /* The length menu ("Mostra 25 righe") is noise on a phone — drop it,
       keep search + paging. */
    .sg-history-popup .dt-length { display: none; }
    .sg-history-popup .dt-search { margin: 0 0 6px; }
}

/* ---------------------------------- Notifications -------- */
.sg-bell {
    border: 1px solid var(--sg-border);
    border-radius: 999px;
    padding: 5px 10px;
    color: var(--sg-text-soft);
    background: transparent;
}
.sg-bell:hover { background: var(--sg-primary-50); color: var(--sg-primary); }
.sg-bell .badge { font-size: 10px; padding: 3px 5px; }
.sg-bell-dropdown { min-width: 340px; max-width: 380px; max-height: 480px; overflow-y: auto; padding: 0; }
.sg-notif-item { white-space: normal; padding: 10px 14px; }
.sg-notif-item:hover { background: var(--sg-primary-50); }

/* ---------------------------------- Responsive ----------- */
/* Prevent any accidental page-level horizontal scroll on small screens;
   wide content (tables) scrolls inside its own container instead. */
html, body { max-width: 100%; }

@media (max-width: 992px) {
    /* Off-canvas drawer navigation. The sidebar slides in over the
       content; a hamburger in the topbar opens it, a backdrop closes it. */
    .sg-sidebar {
        transform: translateX(-100%);
        transition: transform .25s ease;
        z-index: 50;
        width: min(86vw, 320px);
    }
    .sg-sidebar.is-open { transform: translateX(0); }
    .sg-main { margin-left: 0; }
    .sg-navtoggle { display: inline-flex; }
    /* Lock background scroll while the drawer is open. */
    body.sg-nav-open { overflow: hidden; }
    .sg-content { overflow-x: hidden; }

    /* Topbar condenses: title shrinks, secondary controls stay compact. */
    .sg-topbar { padding: 10px 14px; gap: 8px; }
    .sg-topbar__title { font-size: 16px; flex: 1 1 auto; }
    .sg-topbar__right { gap: 6px !important; }
    .sg-ctxbtn { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    /* Wide tables scroll horizontally inside the card instead of being
       clipped or pushing the page wider. */
    .sg-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* Dashboard quick actions: full set on desktop, essential set on phones. */
.sg-hero__quick--mobile { display: none; }
@media (max-width: 640px) {
    .sg-hero__quick--desktop { display: none; }
    .sg-hero__quick--mobile  { display: flex; }
}

@media (max-width: 640px) {
    /* Topbar: drop the name/role text, keep the avatar tappable. */
    .sg-userbtn { padding: 4px; border-radius: 999px; }
    .sg-userbtn__info { display: none; }
    .sg-userbtn > .bi-chevron-down { display: none; }
    .sg-content { padding: 16px 14px 32px; }
    .sg-page-header h1 { font-size: 19px; }
    /* Primary page action goes full width so it's easy to tap. */
    .sg-page-header > .d-flex { width: 100%; }
    .sg-page-header .btn { flex: 1 1 auto; justify-content: center; }

    /* Financial period filter stacks; every control goes full width. */
    .sg-fin-filter { flex-direction: column; align-items: stretch; }
    .sg-fin-filter__field,
    .sg-fin-filter .sg-fin-mode-panel,
    .sg-fin-filter .sg-fin-actions { width: 100%; margin: 0; align-self: stretch; }
    .sg-fin-filter .sg-fin-mode-panel { flex-direction: column; align-items: stretch; }
    .sg-fin-filter .sg-segmented { width: 100%; box-sizing: border-box; }
    .sg-fin-filter .sg-segmented label { flex: 1 1 0; min-width: 0; justify-content: center; padding: 8px 8px; }
    .sg-fin-filter .form-select,
    .sg-fin-filter .form-control,
    .sg-fin-filter .sg-fin-actions .btn { width: 100%; box-sizing: border-box; }
    .sg-fin-range-to { width: 100%; }
    .sg-fin-range-to::before { display: none; }

    /* Touch targets: comfortable minimum on phones. */
    .sg-table .btn, .btn-sm { min-height: 38px; }
}

/* Pending-dues table → stacked cards on phones (label/value rows). */
@media (max-width: 640px) {
    .sg-dues-table thead { display: none; }
    .sg-dues-table, .sg-dues-table tbody, .sg-dues-table tr, .sg-dues-table td { display: block; width: 100%; }
    .sg-dues-table tr {
        border: 1px solid var(--sg-border);
        border-radius: var(--sg-radius-sm);
        padding: 10px 12px;
        margin-bottom: 10px;
        background: var(--sg-panel);
    }
    .sg-dues-table td {
        display: flex; align-items: center; justify-content: space-between;
        gap: 12px; padding: 4px 0; border: 0; text-align: right;
    }
    .sg-dues-table td::before {
        content: attr(data-label);
        font-size: 12px; font-weight: 600; color: var(--sg-text-soft);
        text-align: left; flex: 0 0 auto;
    }
    .sg-dues-table td:last-child { justify-content: stretch; padding-top: 8px; }
    .sg-dues-table td:last-child::before { display: none; }
    .sg-dues-table td:last-child .btn { width: 100%; justify-content: center; }
}

/* Generic DataTable → card layout on phones (opt-in via .sg-dt-cards).
   DataTables keeps the DOM <td>s, so per-cell data-label drives the
   label/value rows; the title and actions cells get special treatment. */
@media (max-width: 640px) {
    /* When the wrapper only holds stacked cards, drop its own frame so the
       cards don't look boxed-in-a-box (double border). */
    .sg-table-wrap:has(.sg-dt-cards) {
        border: 0; box-shadow: none; background: transparent;
        border-radius: 0; overflow: visible;
    }
    .sg-dt-cards thead { display: none; }
    .sg-dt-cards, .sg-dt-cards tbody, .sg-dt-cards tr { display: block; width: 100%; }
    .sg-dt-cards tr {
        border: 1px solid var(--sg-border);
        border-radius: var(--sg-radius-sm);
        padding: 14px 16px;
        margin-bottom: 12px;
        background: var(--sg-panel);
        box-shadow: var(--sg-shadow);
    }
    .sg-dt-cards tbody td {
        display: flex; align-items: center; justify-content: space-between;
        gap: 8px 14px; padding: 6px 0; border: 0; text-align: right;
        white-space: normal; flex-wrap: wrap;
    }
    /* Seasonal fee: on mobile it becomes a full label/value row that
       mirrors the data-label rows exactly (bold label left, value right). */
    .sg-dt-cards tbody td .sg-fee-extra {
        flex: 1 0 100%; display: flex; align-items: center;
        justify-content: space-between; gap: 14px; margin-top: 6px;
        font-size: 14px; color: inherit;
    }
    .sg-dt-cards tbody td .sg-fee-extra__lbl {
        font-size: 12px; font-weight: 600; color: var(--sg-text-soft);
    }
    .sg-dt-cards tbody td .sg-fee-extra__lbl::after { content: none; }

    /* Any other secondary `.small` detail in a cell (e.g. seasonal paid /
       residual under a status badge) drops to its own full-width line. */
    .sg-dt-cards tbody td .small { flex: 1 0 100%; text-align: right; margin-top: 2px; }

    /* Coach matrix: months with no payment show only Month + Status (+ the
       record action). Hide the empty date/amount/method rows. */
    .sg-dt-cards tr.sg-cp-nopay td:nth-child(3),
    .sg-dt-cards tr.sg-cp-nopay td:nth-child(4),
    .sg-dt-cards tr.sg-cp-nopay td:nth-child(5) { display: none; }
    .sg-dt-cards td::before {
        content: attr(data-label);
        font-size: 12px; font-weight: 600; color: var(--sg-text-soft);
        text-align: left; flex: 0 0 auto;
    }
    /* Hide value-less cells (e.g. an empty period) to keep cards tight. */
    .sg-dt-cards td:empty { display: none; }

    /* Title row: the record name, full width, no label, prominent. */
    .sg-dt-cards td.sg-dt-title {
        display: block; text-align: left;
        padding: 0 0 10px; margin-bottom: 8px;
        border-bottom: 1px solid var(--sg-border);
    }
    .sg-dt-cards td.sg-dt-title::before { display: none; }
    .sg-dt-cards td.sg-dt-title a,
    .sg-dt-cards td.sg-dt-title { font-size: 16px; font-weight: 700; }

    /* Actions row: full-width button bar at the bottom of the card. */
    .sg-dt-cards td.sg-dt-actions {
        display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 8px;
        padding-top: 12px; margin-top: 8px; border-top: 1px solid var(--sg-border);
    }
    .sg-dt-cards td.sg-dt-actions::before { display: none; }
    .sg-dt-cards td.sg-dt-actions .btn { flex: 1 1 auto; min-height: 40px; justify-content: center; }
    .sg-dt-cards td.sg-dt-actions form { flex: 1 1 auto; display: flex; }
    .sg-dt-cards td.sg-dt-actions form .btn { width: 100%; }

    /* Tappable variant: hide the action bar, make the whole card open the
       record. Tighter cards → more rows per screen. */
    .sg-dt-cards--tap td.sg-dt-actions { display: none; }
    .sg-dt-cards--tap tbody tr {
        cursor: pointer; padding: 11px 14px; margin-bottom: 8px;
        -webkit-tap-highlight-color: transparent;
        position: relative; padding-right: 30px;
    }
    .sg-dt-cards--tap tbody tr:active { background: var(--sg-primary-50); }
    /* Chevron hint that the card is tappable. */
    .sg-dt-cards--tap tbody tr::after {
        content: "\F285"; font-family: "bootstrap-icons";
        position: absolute; top: 12px; right: 10px;
        color: var(--sg-text-soft); font-size: 16px;
    }
    .sg-dt-cards--tap td.sg-dt-title { padding-bottom: 8px; margin-bottom: 6px; }
}

/* ============================================================
   Language switcher — topbar (compact pill) + guest (floating top-right)
   ============================================================ */
.sg-lang { display: inline-flex; }

.sg-lang__btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: #fff;
    border: 1px solid #e4e8ee;
    border-radius: 999px;
    color: #2c3e50;
    transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, transform .05s ease;
    cursor: pointer;
    line-height: 1;
}
.sg-lang__btn:hover {
    background: #f5f7fb;
    border-color: #d3d9e3;
}
.sg-lang__btn:active { transform: translateY(1px); }
.sg-lang__btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(47, 84, 235, .25);
    border-color: #2f54eb;
}

.sg-lang__flag {
    display: inline-block;
    border-radius: 3px;
    object-fit: cover;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .05);
    vertical-align: middle;
}

.sg-lang__caret {
    font-size: 0.72rem;
    color: #6b7888;
}

.sg-lang__menu {
    min-width: 200px;
    padding: 6px;
    border-radius: 12px;
    border: 1px solid #e4e8ee;
}

.sg-lang__item {
    display: flex;
    align-items: center;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.92rem;
}
.sg-lang__item:hover { background: #f5f7fb; }
.sg-lang__item.is-active {
    background: rgba(47, 84, 235, .08);
    color: #2f54eb;
    font-weight: 600;
}

/* Guest variant: floating top-right on login screen */
.sg-guest-langbar {
    position: absolute;
    top: 18px;
    right: 22px;
    z-index: 10;
}
.sg-lang--guest .sg-lang__btn {
    background: rgba(255, 255, 255, .9);
    backdrop-filter: blur(6px);
}

/* ============================================================
   Dashboard widget — Scadenziario (prossime 30gg)
   ============================================================ */
.sg-deadlines-widget { padding-bottom: 4px; }

.sg-deadlines-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 340px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #cdd5e0 transparent;
}
.sg-deadlines-list::-webkit-scrollbar { width: 8px; }
.sg-deadlines-list::-webkit-scrollbar-track { background: transparent; }
.sg-deadlines-list::-webkit-scrollbar-thumb { background-color: #cdd5e0; border-radius: 4px; }

.sg-deadlines-list__item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 6px;
    border-bottom: 1px solid #eef1f6;
    transition: background-color .12s ease;
}
.sg-deadlines-list__item:last-child { border-bottom: 0; }
.sg-deadlines-list__item:hover { background: #f8fafd; }

.sg-deadlines-list__date {
    min-width: 56px;
    text-align: center;
    background: #eef3ff;
    color: #2f54eb;
    border-radius: 10px;
    padding: 6px 8px;
    line-height: 1;
}
.sg-deadlines-list__day {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #1a2849;
}
.sg-deadlines-list__mon {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #2f54eb;
    margin-top: 2px;
}
.sg-deadlines-list__main { flex: 1 1 auto; min-width: 0; }
.sg-deadlines-list__title {
    color: #1a2849;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.96rem;
}
.sg-deadlines-list__title:hover { color: #2f54eb; text-decoration: underline; }

/* ============================================================
   Deadline form — channel cards (radio-as-card pattern)
   ============================================================ */
.sg-channels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}
.sg-channel-card {
    position: relative;
    display: flex;
    gap: 12px;
    padding: 14px;
    border: 2px solid #e4e8ee;
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    transition: border-color .15s ease, box-shadow .15s ease, transform .05s ease;
    margin: 0;
}
.sg-channel-card:hover { border-color: #c5cee8; }
.sg-channel-card input[type=radio] {
    position: absolute;
    top: 12px;
    right: 12px;
    accent-color: #2f54eb;
}
.sg-channel-card.is-active {
    border-color: #2f54eb;
    background: linear-gradient(180deg, #f4f7ff 0%, #ffffff 100%);
    box-shadow: 0 2px 6px rgba(47, 84, 235, .12);
}
.sg-channel-card__body { padding-right: 24px; flex: 1; }
.sg-channel-card__title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: #1a2849;
    margin-bottom: 4px;
}
.sg-channel-card__title i { color: #2f54eb; }
.sg-channel-card__desc {
    font-size: 0.85rem;
    color: #6b7888;
    line-height: 1.35;
}

/* ============================================================
   Deadline form — anteprima prossime occorrenze
   ============================================================ */
.sg-rec-preview {
    margin-top: 8px;
    border: 1px dashed #c5cee8;
    border-radius: 12px;
    padding: 14px 16px;
    background: linear-gradient(180deg, #f6f9ff 0%, #ffffff 100%);
}
.sg-rec-preview__head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    color: #2f54eb;
}
.sg-rec-preview__head i { font-size: 1.05rem; }
.sg-rec-preview__list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.sg-rec-preview__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    color: #4a5568;
    border-bottom: 1px dashed #eef1f6;
    font-variant-numeric: tabular-nums;
}
.sg-rec-preview__item:last-child { border-bottom: 0; }
.sg-rec-preview__item.is-next {
    color: #1a2849;
    font-weight: 600;
}

/* ============================================================
   Codice Fiscale — modal autocomplete comune
   ============================================================ */
.sg-cf-autocomplete {
    display: none;
    position: absolute;
    left: 12px; right: 12px;
    z-index: 5;
    background: #fff;
    border: 1px solid #d3d9e3;
    border-radius: 8px;
    margin-top: 4px;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 6px 18px rgba(0,0,0,.08);
}
.sg-cf-ac-item {
    padding: 6px 10px;
    cursor: pointer;
    font-size: 0.9rem;
}
.sg-cf-ac-item:hover { background: #f5f7fb; }

/* ============================================================
   Sex segmented toggle — Member form
   ============================================================ */
.sg-sex-toggle {
    display: flex;
    gap: 10px;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 12px;
}
.sg-sex-toggle__opt {
    position: relative;
    flex: 1 1 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0;
    padding: 9px 10px;
    border-radius: 10px;
    background: #ffffff;
    color: #2c3e50;
    cursor: pointer;
    user-select: none;
    transition: background-color .15s ease, color .15s ease, box-shadow .15s ease, transform .05s ease, border-color .15s ease;
    font-weight: 600;
    font-size: 0.92rem;
    border: 2px solid #cdd5e0;
}
.sg-sex-toggle__opt input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    inset: 0;
}
.sg-sex-toggle__icon { font-size: 1.1rem; line-height: 1; color: #6b7888; }
.sg-sex-toggle__label { line-height: 1; }

/* Default (no selection): show both options with hover affordance */
.sg-sex-toggle__opt--m:hover {
    background: #f4f7ff;
    border-color: #2f54eb;
    color: #1d4ed8;
}
.sg-sex-toggle__opt--m:hover .sg-sex-toggle__icon { color: #1d4ed8; }

.sg-sex-toggle__opt--f:hover {
    background: #fff4f8;
    border-color: #ec4899;
    color: #be1862;
}
.sg-sex-toggle__opt--f:hover .sg-sex-toggle__icon { color: #be1862; }

.sg-sex-toggle__opt:active { transform: translateY(1px); }
.sg-sex-toggle__opt:focus-within {
    box-shadow: 0 0 0 3px rgba(47, 84, 235, .22);
}

/* Active selection */
.sg-sex-toggle__opt--m.is-active {
    background: linear-gradient(180deg, #e9f1ff 0%, #ffffff 100%);
    color: #1d4ed8;
    border-color: #2f54eb;
    box-shadow: 0 2px 8px rgba(29, 78, 216, .18);
}
.sg-sex-toggle__opt--m.is-active .sg-sex-toggle__icon { color: #1d4ed8; }

.sg-sex-toggle__opt--f.is-active {
    background: linear-gradient(180deg, #fdeaf3 0%, #ffffff 100%);
    color: #be1862;
    border-color: #ec4899;
    box-shadow: 0 2px 8px rgba(190, 24, 98, .18);
}
.sg-sex-toggle__opt--f.is-active .sg-sex-toggle__icon { color: #be1862; }

/* Recent activities widget — show 4 items, scroll vertically up to 10. */
.sg-timeline--scroll {
    max-height: 320px;          /* ~ 4 timeline items */
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 6px;
    scrollbar-width: thin;
    scrollbar-color: #cdd5e0 transparent;
}
.sg-timeline--scroll::-webkit-scrollbar { width: 8px; }
.sg-timeline--scroll::-webkit-scrollbar-track { background: transparent; }
.sg-timeline--scroll::-webkit-scrollbar-thumb { background-color: #cdd5e0; border-radius: 4px; }

/* ============================================================
   Gestione Turni — capienza palestra + board settimanale
   ============================================================ */
.sg-subtle { color: var(--sg-text-soft); font-size: 13px; margin-top: 2px; }

/* --- Card capienza --- */
.sg-gym-capacity {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
}
.sg-gym-capacity__main { display: flex; align-items: center; gap: 18px; }
.sg-gym-capacity__icon {
    width: 56px; height: 56px;
    display: grid; place-items: center;
    border-radius: var(--sg-radius-sm);
    background: var(--sg-primary-50);
    color: var(--sg-primary);
    font-size: 26px;
}
.sg-gym-capacity__label {
    font-size: 12px; font-weight: 600; letter-spacing: .04em;
    text-transform: uppercase; color: var(--sg-muted);
}
.sg-gym-capacity__value { font-size: 30px; font-weight: 700; line-height: 1.1; color: var(--sg-text); }
.sg-gym-capacity__value span { font-size: 14px; font-weight: 500; color: var(--sg-text-soft); }
.sg-gym-capacity__value.is-muted { font-size: 18px; color: var(--sg-warning); }
.sg-gym-capacity__form { min-width: 240px; max-width: 320px; flex: 1 1 240px; }
.sg-gym-capacity.is-unset { border-left: 4px solid var(--sg-warning); }
.sg-gym-capacity.is-unset .sg-gym-capacity__icon { background: #fffbeb; color: var(--sg-warning); }

/* --- Board --- */
.sg-gym-board {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 12px;
    align-items: start;
}
@media (max-width: 1200px) { .sg-gym-board { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 768px)  { .sg-gym-board { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px)  { .sg-gym-board { grid-template-columns: 1fr; } }

.sg-gym-day {
    background: var(--sg-panel);
    border: 1px solid var(--sg-border);
    border-radius: var(--sg-radius);
    box-shadow: var(--sg-shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.sg-gym-day.is-over { border-color: var(--sg-danger); box-shadow: 0 0 0 1px var(--sg-danger) inset; }
.sg-gym-day__head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--sg-border);
    background: #fafbfe;
}
.sg-gym-day__name { font-weight: 700; font-size: 13px; letter-spacing: .03em; text-transform: uppercase; color: var(--sg-text); }
.sg-gym-day__peak {
    font-size: 11.5px; font-weight: 600; color: var(--sg-text-soft);
    background: var(--sg-primary-50); color: var(--sg-primary-700);
    padding: 2px 8px; border-radius: 999px; white-space: nowrap;
}
.sg-gym-day__peak.is-danger { background: #fef2f2; color: #b91c1c; }
.sg-gym-day__body { padding: 10px; display: flex; flex-direction: column; gap: 10px; min-height: 60px; }
.sg-gym-day__empty { color: var(--sg-muted); font-size: 12.5px; text-align: center; padding: 16px 4px; }

/* --- Slot turno --- */
.sg-gym-slot {
    display: block; text-decoration: none; color: inherit;
    border: 1px solid var(--sg-border);
    border-left: 3px solid var(--sg-muted);
    border-radius: var(--sg-radius-sm);
    padding: 9px 10px;
    transition: transform .12s ease, box-shadow .12s ease;
}
.sg-gym-slot:hover { transform: translateY(-1px); box-shadow: var(--sg-shadow); }
.sg-gym-slot.is-free  { border-left-color: var(--sg-primary); }
.sg-gym-slot.is-coach { border-left-color: var(--sg-success); }
.sg-gym-slot.is-full  { border-left-color: var(--sg-danger); background: #fef6f6; }
.sg-gym-slot__top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.sg-gym-slot__time { font-weight: 700; font-size: 13px; color: var(--sg-text); }
.sg-gym-slot__tag { font-size: 10.5px; font-weight: 600; color: var(--sg-text-soft); white-space: nowrap; }
.sg-gym-slot.is-coach .sg-gym-slot__tag { color: #047857; }
.sg-gym-slot.is-free  .sg-gym-slot__tag { color: var(--sg-primary-700); }
.sg-gym-slot__name { font-size: 12.5px; color: var(--sg-text-soft); margin: 3px 0 7px; line-height: 1.3; }
.sg-gym-slot__meter { height: 6px; border-radius: 999px; background: #eef1f7; overflow: hidden; }
.sg-gym-slot__bar { height: 100%; border-radius: 999px; background: var(--sg-primary); transition: width .3s ease; }
.sg-gym-slot.is-coach .sg-gym-slot__bar { background: var(--sg-success); }
.sg-gym-slot.is-full  .sg-gym-slot__bar { background: var(--sg-danger); }
.sg-gym-slot__count { font-size: 11px; font-weight: 600; color: var(--sg-text-soft); margin-top: 5px; }
.sg-gym-slot__count span { font-weight: 500; color: var(--sg-muted); }

/* ============================================================
   Bilancio · Quote attese vs incassate
   ============================================================ */
.sg-expected-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 4px;
}
.sg-expected-kpi {
    border: 1px solid var(--sg-border);
    border-radius: var(--sg-radius-sm);
    padding: 12px 14px;
    background: var(--sg-panel);
}
.sg-expected-kpi__label {
    font-size: 11px; font-weight: 600; letter-spacing: .04em;
    text-transform: uppercase; color: var(--sg-muted);
}
.sg-expected-kpi__value { font-size: 22px; font-weight: 700; line-height: 1.1; margin-top: 4px; }
.sg-expected-kpi__hint  { font-size: 11.5px; color: var(--sg-text-soft); margin-top: 6px; line-height: 1.4; }
.sg-expected-kpi.is-expected { border-left: 3px solid var(--sg-primary); }
.sg-expected-kpi.is-expected .sg-expected-kpi__value { color: var(--sg-primary-700); }
.sg-expected-kpi.is-received { border-left: 3px solid var(--sg-success); }
.sg-expected-kpi.is-received .sg-expected-kpi__value { color: #047857; }
.sg-expected-kpi.is-gap      { border-left: 3px solid var(--sg-warning); }
.sg-expected-kpi.is-gap      .sg-expected-kpi__value { color: #b45309; }
.sg-expected-kpi.is-coverage { border-left: 3px solid #6366f1; }
.sg-expected-kpi.is-coverage .sg-expected-kpi__value { color: #4338ca; }
.sg-expected-bar {
    margin-top: 14px;
    height: 10px;
    border-radius: 999px;
    background: #eef1f7;
    overflow: hidden;
    position: relative;
}
.sg-expected-bar__fill {
    height: 100%;
    background: linear-gradient(90deg, var(--sg-success), #34d399);
    transition: width .4s ease;
}

/* --- Day-picker (form turno) --- */
.sg-day-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.sg-day-picker input { position: absolute; opacity: 0; pointer-events: none; }
.sg-day-picker label {
    cursor: pointer; user-select: none;
    min-width: 46px; text-align: center;
    padding: 8px 10px; font-size: 13px; font-weight: 600;
    border: 1px solid var(--sg-border); border-radius: var(--sg-radius-sm);
    color: var(--sg-text-soft); background: var(--sg-panel);
    transition: all .12s ease;
}
.sg-day-picker label:hover { border-color: var(--sg-primary); color: var(--sg-primary); }
.sg-day-picker input:checked + label {
    background: var(--sg-primary); border-color: var(--sg-primary); color: #fff;
    box-shadow: 0 2px 6px rgba(47,84,235,.25);
}

/* ---- Enrollment wizard (2 step: atleta → quota) ----------------------- */
.sg-wiz { text-align: left; }

/* Stepper: due segmenti che fanno anche da breadcrumb */
.sg-wiz-steps {
    display: flex; gap: 10px; list-style: none; margin: 0 0 18px; padding: 0;
}
.sg-wiz-step {
    display: flex; align-items: center; gap: 8px;
    flex: 1; padding: 8px 12px;
    border: 1px solid var(--sg-border); border-radius: var(--sg-radius-sm);
    color: var(--sg-muted); font-size: .9rem; font-weight: 600;
    background: var(--sg-panel); transition: all .15s ease;
}
.sg-wiz-dot {
    width: 24px; height: 24px; flex: none;
    display: grid; place-items: center; border-radius: 50%;
    background: var(--sg-bg); color: var(--sg-muted);
    font-size: .8rem; font-weight: 700;
    border: 1px solid var(--sg-border); transition: all .15s ease;
}
.sg-wiz-step.is-active { color: var(--sg-primary); border-color: var(--sg-primary); background: var(--sg-primary-50); }
.sg-wiz-step.is-active .sg-wiz-dot { background: var(--sg-primary); color: #fff; border-color: var(--sg-primary); }
.sg-wiz-step.is-done { color: var(--sg-success); border-color: var(--sg-success); }
.sg-wiz-step.is-done .sg-wiz-dot { background: var(--sg-success); color: #fff; border-color: var(--sg-success); }

/* Viewport + slide tra i pannelli */
.sg-wiz-viewport { position: relative; overflow: hidden; }
.sg-wiz-pane { display: none; }
.sg-wiz-pane.is-active {
    display: block;
    animation: sgWizIn .22s ease both;
}
@keyframes sgWizIn {
    from { opacity: 0; transform: translateX(12px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* Chip atleta selezionato (step 2) */
.sg-wiz-athlete {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 14px; margin-bottom: 16px;
    border: 1px solid var(--sg-border); border-left: 3px solid var(--sg-primary);
    border-radius: var(--sg-radius-sm); background: var(--sg-bg);
}
.sg-wiz-athlete__label { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--sg-muted); }
.sg-wiz-athlete__name  { font-weight: 700; color: var(--sg-text); margin: 2px 0 4px; }
.sg-wiz-h3 { font-size: 1.02rem; font-weight: 700; margin: 0 0 2px; color: var(--sg-text); }

/* Toggle segmentato Paga / Esente */
.sg-seg {
    display: inline-flex; padding: 3px; gap: 3px;
    background: var(--sg-bg); border: 1px solid var(--sg-border);
    border-radius: 999px;
}
.sg-seg__btn {
    border: 0; background: transparent; cursor: pointer;
    padding: 6px 18px; border-radius: 999px;
    font-size: .9rem; font-weight: 600; color: var(--sg-text-soft);
    transition: all .15s ease;
}
.sg-seg__btn:hover { color: var(--sg-text); }
.sg-seg__btn.is-active { background: var(--sg-primary); color: #fff; box-shadow: 0 2px 6px rgba(47,84,235,.25); }

.sg-wiz-feewrap { display: grid; gap: 12px; }

/* Anteprima live di quanto pagherà */
.sg-wiz-preview {
    margin-top: 16px; padding: 12px 14px; border-radius: var(--sg-radius-sm);
    font-size: .95rem;
}
.sg-wiz-preview.is-fee    { background: var(--sg-primary-50); color: var(--sg-primary-700); }
.sg-wiz-preview.is-exempt { background: #fff7ed; color: #b45309; }

/* Footer azioni */
.sg-wiz-actions {
    display: flex; justify-content: flex-end; gap: 8px;
    margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--sg-border);
}

@media (prefers-reduced-motion: reduce) {
    .sg-wiz-pane.is-active { animation: none; }
}

/* Enrollment picker on phones: result rows become tidy cards — the name
   and CF on their own line, the medical-cert badge and the "Select" button
   on a second line — so nothing wraps mid-word. */
@media (max-width: 640px) {
    .sg-wiz-popup.swal2-popup { padding: 1rem 1rem 1.25rem !important; }
    .sg-wiz-popup .swal2-title { font-size: 1.4rem; }

    tbody.sg-picker-rows tr {
        display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
        padding: 11px 2px; border-bottom: 1px solid var(--sg-border);
    }
    tbody.sg-picker-rows td { padding: 0; border: 0; }
    tbody.sg-picker-rows td:first-child { flex: 1 1 100%; }       /* name + CF */
    tbody.sg-picker-rows td:nth-child(2) { flex: 0 0 auto; text-align: left; }
    tbody.sg-picker-rows td:last-child { margin-left: auto; }     /* button to the right */
    tbody.sg-picker-rows .sg-badge { white-space: nowrap; }
    .sg-picker-choose { white-space: nowrap; min-height: 38px; }

    /* Footer actions stack full-width and stay tappable. */
    .sg-wiz-actions { flex-wrap: wrap; }
    .sg-wiz-actions .btn { flex: 1 1 auto; min-height: 40px; }
    /* Athlete recap (step 2) wraps instead of squeezing. */
    .sg-wiz-athlete { flex-wrap: wrap; }
}
