/* ============================================================
   GESTIONE SOCI - MATTI PER LA CUCINA
   Main Stylesheet
   ============================================================ */

/* Footer styles are at the bottom of this file */

:root {
    --primary: #c0392b;
    --primary-dark: #96281b;
    --primary-light: #e74c3c;
    --secondary: #2c3e50;
    --secondary-light: #34495e;
    --accent: #e67e22;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --info: #3498db;
    --bg: #f8f5f2;
    --bg-card: #ffffff;
    --text: #2c3e50;
    --text-light: #7f8c8d;
    --text-muted: #95a5a6;
    --border: #ddd;
    --border-light: #eee;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ============================================================
   LAYOUT PUBLIC
   ============================================================ */
.public-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem 1rem;
}

.public-header {
    text-align: center;
    margin-bottom: 2rem;
}

.public-header .logo-text {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.5px;
}

.public-header .subtitle {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    width: 100%;
    max-width: 520px;
}

.card-lg {
    max-width: 780px;
}

.card-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--secondary);
    margin-bottom: 0.5rem;
}

.card-desc {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

/* ============================================================
   STEPPER
   ============================================================ */
.stepper {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
    width: 100%;
    max-width: 520px;
}

.stepper .step {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    padding: 0.5rem 0.8rem;
    border-radius: 20px;
    background: #eee;
    white-space: nowrap;
}

.stepper .step.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}

.stepper .step.done {
    background: var(--success);
    color: #fff;
}

.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255,255,255,0.25);
    font-size: 0.72rem;
    font-weight: 700;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-group {
    margin-bottom: 1.25rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-row-3 {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 1rem;
}

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--secondary);
    margin-bottom: 0.35rem;
}

label .required {
    color: var(--danger);
    margin-left: 2px;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="number"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    transition: var(--transition);
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.12);
}

input.error,
select.error {
    border-color: var(--danger);
}

.form-help {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.form-error {
    font-size: 0.78rem;
    color: var(--danger);
    margin-top: 0.25rem;
}

/* OTP Input */
.otp-wrapper {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin: 1.5rem 0;
}

.otp-input {
    width: 52px;
    height: 60px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.otp-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.12);
}

/* Phone input */
.phone-input-group {
    display: flex;
    gap: 0;
}

.phone-prefix {
    padding: 0.7rem 0.8rem;
    border: 2px solid var(--border);
    border-right: none;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    background: #f5f5f5;
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
}

.phone-input-group input {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Channel selector */
.channel-selector {
    display: flex;
    gap: 0.75rem;
    margin: 1rem 0;
}

.channel-btn {
    flex: 1;
    padding: 0.9rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    cursor: pointer;
    text-align: center;
    transition: var(--transition);
    font-family: inherit;
}

.channel-btn:hover {
    border-color: var(--primary-light);
}

.channel-btn.active {
    border-color: var(--primary);
    background: rgba(192, 57, 43, 0.04);
}

.channel-btn .icon {
    font-size: 1.8rem;
    display: block;
    margin-bottom: 0.3rem;
}

.channel-btn .label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1.4;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(192, 57, 43, 0.3);
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: var(--secondary);
    color: #fff;
}

.btn-secondary:hover {
    background: var(--secondary-light);
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: #fff;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 0.4rem 0.9rem;
    font-size: 0.82rem;
}

.btn-lg {
    padding: 0.9rem 2rem;
    font-size: 1.05rem;
}

/* Loading spinner */
.btn .spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.btn.loading .spinner {
    display: block;
}

.btn.loading .btn-text {
    opacity: 0.5;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    padding: 0.9rem 1.2rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* ============================================================
   PRIVACY / CONTRACT DOCUMENT VIEW
   ============================================================ */
.document-view {
    background: #fafafa;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1.5rem;
    max-height: 350px;
    overflow-y: auto;
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
    line-height: 1.7;
}

.document-view h4 {
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.consent-group {
    padding: 1rem;
    background: #fffbf0;
    border: 1px solid #ffc107;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
}

.consent-group label {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    cursor: pointer;
    font-weight: 400;
}

.consent-group input[type="radio"],
.consent-group input[type="checkbox"] {
    width: auto;
    margin-top: 3px;
}

/* ============================================================
   TIMER / RESEND
   ============================================================ */
.timer-text {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 1rem;
}

.resend-link {
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    background: none;
    border: none;
    font-family: inherit;
    font-size: inherit;
}

.resend-link:disabled {
    color: var(--text-muted);
    cursor: not-allowed;
    text-decoration: none;
}

/* ============================================================
   SUCCESS PAGE
   ============================================================ */
.success-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--success);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    font-size: 2.5rem;
    color: #fff;
}

/* ============================================================
   ADMIN LAYOUT
   ============================================================ */
.admin-wrapper {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 260px;
    background: var(--secondary);
    color: #fff;
    padding: 1.5rem 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
}

.admin-sidebar .brand {
    padding: 0 1.5rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 1rem;
}

.admin-sidebar .brand h3 {
    font-size: 1rem;
    font-weight: 700;
}

.admin-sidebar .brand small {
    font-size: 0.75rem;
    opacity: 0.6;
}

.admin-nav a {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.75rem 1.5rem;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.9rem;
    transition: var(--transition);
}

.admin-nav a:hover,
.admin-nav a.active {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

.admin-nav a .badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 700;
}

.admin-main {
    margin-left: 260px;
    flex: 1;
    padding: 2rem;
    background: var(--bg);
}

.admin-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.admin-topbar h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--secondary);
}

/* ============================================================
   ADMIN STATS
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

/* Dashboard 2-col grids (grafici, tabelle) */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--secondary);
    margin-top: 0.25rem;
}

.stat-card .stat-detail {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

.stat-card.primary { border-left: 4px solid var(--primary); }
.stat-card.success { border-left: 4px solid var(--success); }
.stat-card.warning { border-left: 4px solid var(--warning); }
.stat-card.info { border-left: 4px solid var(--info); }

/* ============================================================
   TABLE
   ============================================================ */
.table-wrapper {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
}

.table-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.table-filter {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.table-filter input,
.table-filter select {
    padding: 0.45rem 0.75rem;
    font-size: 0.85rem;
    width: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    padding: 0.85rem 1rem;
    text-align: left;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #fafafa;
    border-bottom: 2px solid var(--border-light);
}

tbody td {
    padding: 0.85rem 1rem;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

tbody tr:hover {
    background: #f8f9fa;
}

/* Status badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-pending { background: #fff3cd; color: #856404; }
.badge-approved { background: #d4edda; color: #155724; }
.badge-rejected { background: #f8d7da; color: #721c24; }
.badge-suspended { background: #e2e3e5; color: #383d41; }
.badge-paid { background: #d4edda; color: #155724; }
.badge-unpaid { background: #f8d7da; color: #721c24; }

/* ============================================================
   MODAL
   ============================================================ */
/* Le "modali" sono rese come VERE PAGINE a tutto schermo (niente popup flottante) */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 260px;               /* lascia visibile la sidebar fissa: la "pagina" sta nell'area contenuti */
    background: #f4f5fb;        /* sfondo pagina opaco, non un overlay scuro */
    z-index: 1200;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-overlay.show {
    display: block;
}

/* Barra superiore con tasto Indietro, iniettata via JS su ogni pagina */
.modal-pagebar {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #fff;
    border-bottom: 1px solid #e6e8f0;
    padding: .7rem 1rem;
    display: flex;
    align-items: center;
    gap: .8rem;
    box-shadow: 0 2px 8px rgba(30,36,53,.04);
}
.modal-back {
    background: #eef0fe;
    border: 1px solid #c7cafe;
    color: #4338ca;
    border-radius: 9px;
    padding: .45rem .9rem;
    font-weight: 600;
    font-size: .9rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}
.modal-back:hover { background: #e0e3fd; }

.modal {
    background: #fff;
    border-radius: 16px;
    padding: 1.6rem 1.8rem;
    width: 100%;
    max-width: 860px;
    margin: 1.4rem auto;
    box-shadow: 0 6px 30px rgba(30,36,53,.07);
    border: 1px solid #e6e8f0;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 1.1rem;
    padding-bottom: .8rem;
    border-bottom: 2px solid #eef0f4;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
    position: sticky;
    bottom: 0;
    background: #fff;
    padding-top: 1rem;
    border-top: 1px solid #eef0f4;
}

/* ============================================================
   MEMBER DETAIL
   ============================================================ */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.detail-section {
    background: #fff;
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.detail-section h4 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-light);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.88rem;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    color: var(--text-muted);
    font-weight: 500;
}

.detail-value {
    font-weight: 600;
    text-align: right;
}

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.3rem;
    padding: 1.25rem;
}

.pagination a,
.pagination span {
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    text-decoration: none;
    color: var(--text);
    border: 1px solid var(--border);
}

.pagination a:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.pagination .active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ============================================================
   TOUCH & MOBILE UTILITIES
   ============================================================ */
/* Scroll momentum per iOS */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Tap highlight per mobile */
a, button, .btn, input[type="submit"] {
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
}

/* Prevent text resize on orientation change */
html {
    -webkit-text-size-adjust: 100%;
}

/* Smooth scroll */
html { scroll-behavior: smooth; }

/* Better select on mobile */
select {
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

/* ============================================================
   RESPONSIVE — MOBILE FIRST
   ============================================================ */
@media (max-width: 768px) {
    /* === FORMS === */
    .form-row,
    .form-row-3 {
        grid-template-columns: 1fr;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px !important; /* Previene zoom su iOS */
        padding: 0.65rem 0.75rem;
        min-height: 44px; /* Touch target minimo */
    }

    .form-group label {
        font-size: 0.85rem;
    }

    /* === BUTTONS — touch-friendly === */
    .btn, button[type="submit"] {
        min-height: 44px;
        padding: 0.65rem 1rem;
        font-size: 0.9rem;
    }

    .btn-block {
        width: 100%;
    }

    /* === STEPPER === */
    .stepper {
        flex-wrap: wrap;
    }

    .stepper .step {
        font-size: 0.7rem;
        padding: 0.4rem 0.6rem;
    }

    /* === CARDS === */
    .card {
        padding: 1rem;
        border-radius: var(--radius-sm);
        margin-bottom: 0.75rem;
    }

    /* === TABLES — card layout su mobile === */
    .table-responsive {
        overflow-x: visible;
        margin: 0;
        padding: 0;
    }

    .table-cards-mobile {
        min-width: 0 !important;
    }

    .table-cards-mobile thead {
        display: none;
    }

    .table-cards-mobile tbody tr {
        display: block;
        background: #fff;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        margin-bottom: 0.5rem;
        padding: 0.5rem 0.75rem;
        box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    }

    .table-cards-mobile tbody tr:hover {
        box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    }

    .table-cards-mobile tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.35rem 0;
        border: none;
        border-bottom: 1px solid #f0f0f0;
        font-size: 0.85rem;
        white-space: normal;
        text-align: right;
    }

    .table-cards-mobile tbody td:last-child {
        border-bottom: none;
    }

    .table-cards-mobile tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.7rem;
        color: var(--text-muted);
        text-transform: uppercase;
        text-align: left;
        flex-shrink: 0;
        margin-right: 0.75rem;
        max-width: 40%;
        word-break: break-word;
        line-height: 1.2;
    }

    .table-cards-mobile tbody td:empty {
        display: none;
    }

    /* Prima td (solitamente nome/id) evidenziata */
    .table-cards-mobile tbody td:first-child {
        font-weight: 700;
        font-size: 0.9rem;
        color: var(--primary);
        border-bottom: 2px solid var(--primary-light, #eee);
        padding-bottom: 0.4rem;
        margin-bottom: 0.1rem;
    }

    /* === TABLE HEADER & FILTERS === */
    .table-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        padding: 1rem;
    }

    .table-header h3 {
        font-size: 1rem;
    }

    .table-filter {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .table-filter input,
    .table-filter select {
        flex: 1;
        min-width: 120px;
        min-height: 40px;
    }

    /* === ADMIN LAYOUT === */
    .admin-sidebar {
        /* Gestito da layout-header inline styles */
    }

    .admin-main {
        margin-left: 0;
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
        max-width: 100vw;
        overflow-x: hidden;
    }

    /* Previeni overflow orizzontale globale */
    body, html {
        overflow-x: hidden;
    }

    .admin-topbar {
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.5rem;
        padding: 0.75rem 0;
    }

    .admin-topbar h1 {
        font-size: 1.1rem;
    }

    .admin-topbar .btn,
    .admin-topbar a.btn {
        width: 100%;
        text-align: center;
        justify-content: center;
    }

    /* === STATS GRID — 1 COLONNA su mobile === */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 0.5rem;
    }

    /* === DASHBOARD GRIDS (grafici + tabelle) === */
    .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    /* === OVERRIDE: tutti i grid inline a 1 colonna su mobile === */
    [style*="grid-template-columns:1fr 1fr"],
    [style*="grid-template-columns: 1fr 1fr"],
    [style*="grid-template-columns:1fr 280px"],
    [style*="grid-template-columns: 1fr 280px"],
    [style*="grid-template-columns:1fr 350px"],
    [style*="grid-template-columns: 1fr 350px"],
    [style*="grid-template-columns:300px auto"],
    [style*="grid-template-columns: 300px auto"],
    [style*="grid-template-columns:1fr 1fr 80px"],
    [style*="grid-template-columns: 1fr 1fr 80px"] {
        grid-template-columns: 1fr !important;
    }

    /* Override anche repeat(auto-fit, minmax(200px, 1fr)) su schermi piccoli */
    [style*="grid-template-columns:repeat"] {
        grid-template-columns: 1fr !important;
    }

    .stat-card {
        padding: 0.75rem;
    }

    .stat-value {
        font-size: 1.3rem;
    }

    .stat-label {
        font-size: 0.7rem;
    }

    /* === DETAIL GRIDS === */
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .detail-section {
        padding: 1rem;
    }

    /* === MODALS (pagine) — mobile === */
    .modal-overlay {
        left: 0;               /* su mobile la sidebar è off-canvas: la pagina occupa tutto */
    }
    .modal {
        width: 100%;
        max-width: none !important;
        margin: 1rem auto;
        padding: 1.1rem 1rem;
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-header {
        padding: 0.75rem 1rem;
        position: sticky;
        top: 0;
        background: #fff;
        z-index: 5;
    }

    .modal-footer {
        padding: 0.75rem 1rem;
        position: sticky;
        bottom: 0;
        background: #fff;
        z-index: 5;
    }

    /* === OTP INPUTS === */
    .otp-input {
        width: 44px;
        height: 52px;
        font-size: 1.2rem;
    }

    /* === BADGES & PILLS === */
    .badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
    }

    /* === ALERTS === */
    .alert {
        padding: 0.75rem;
        font-size: 0.85rem;
        border-radius: var(--radius-sm);
    }

    /* === TABS === */
    .nav-tabs,
    .tabs {
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .nav-tabs a,
    .tabs a,
    .nav-tabs button,
    .tabs button {
        flex: 1;
        min-width: calc(50% - 0.25rem);
        text-align: center;
        padding: 0.6rem 0.5rem;
        font-size: 0.8rem;
    }

    /* === ACTION BUTTONS ROW === */
    .action-buttons,
    .btn-group {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .action-buttons .btn,
    .btn-group .btn {
        flex: 1;
        min-width: calc(50% - 0.5rem);
        text-align: center;
    }

    /* === PAGINATION === */
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.25rem;
    }

    .pagination a,
    .pagination span {
        min-width: 36px;
        min-height: 36px;
        padding: 0.4rem;
        font-size: 0.8rem;
    }

    /* === GENERAL SPACING === */
    h1 { font-size: 1.3rem; }
    h2 { font-size: 1.15rem; }
    h3 { font-size: 1rem; }
    body { font-size: 0.9rem; }

    /* === FLEX HELPERS mobile === */
    .d-flex-mobile-col {
        flex-direction: column !important;
    }

    /* === PRINT hide mobile elements === */
    .admin-mobile-bar,
    .sidebar-overlay { }
}

/* === EXTRA SMALL — telefoni piccoli === */
@media (max-width: 400px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .admin-topbar h1 {
        font-size: 1rem;
    }

    .card {
        padding: 0.75rem;
    }

    table th,
    table td {
        padding: 0.4rem;
        font-size: 0.72rem;
    }

    .nav-tabs a,
    .tabs a {
        min-width: 100%;
    }
}

/* ============================================================
   FOOTER - PUBLIC
   ============================================================ */
.public-footer {
    width: 100%;
    max-width: 520px;
    margin: 3rem auto 0 auto;
    padding: 1.5rem 1rem;
    border-top: 1px solid var(--border-light);
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.7;
    align-self: center;
}
.public-footer .footer-name {
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.82rem;
}
.public-footer .footer-links {
    margin-top: 0.5rem;
}
.public-footer .footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    margin: 0 0.5rem;
    transition: color var(--transition);
}
.public-footer .footer-links a:hover {
    color: var(--primary);
}

/* ============================================================
   FOOTER - ADMIN
   ============================================================ */
.admin-footer {
    padding: 1.25rem 1.5rem;
    margin-top: 2rem;
    border-top: 1px solid var(--border-light);
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.admin-footer a {
    color: var(--text-muted);
    text-decoration: none;
}
.admin-footer a:hover {
    color: var(--primary);
}
@media (max-width: 600px) {
    .admin-footer {
        flex-direction: column;
        text-align: center;
    }
}

/* === MODERN BUTTONS === */
.btn .bi, button .bi {
    margin-right: 0.3rem;
    font-size: 0.9em;
    vertical-align: -0.05em;
}
.btn-sm .bi {
    font-size: 0.85em;
}
