:root {
    color-scheme: dark;
    /* Force dark system controls (dates, selects) */
    text-align: center;

    --primary: #FFD700;
    /* Gold */
    --primary-dim: #cca700;
    --background: #0f172a;
    /* Deep Navy */
    --surface: rgba(30, 41, 59, 0.7);
    /* Glassy Navy */
    --surface-light: rgba(51, 65, 85, 0.8);
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --danger: #ef4444;
    --success: #22c55e;

    --font-main: 'Outfit', sans-serif;

    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);

    --radius-md: 12px;
    --radius-lg: 20px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-main);
    background-color: var(--background);
    background-image:
        radial-gradient(circle at 10% 20%, rgba(255, 215, 0, 0.05) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(255, 215, 0, 0.05) 0%, transparent 20%);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
    /* Prevent scrolling body, scroll main instead */
}

/* Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 600px;
    margin: 0 auto;
    position: relative;
    background: rgba(0, 0, 0, 0.2);
}

.app-header {
    padding: 8px 12px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    z-index: 10;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.logo-area h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 1px;
    background: linear-gradient(45deg, #fff, var(--primary));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 0.75rem;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.cloud-indicator {
    font-size: 1.5rem;
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.cloud-indicator.synced {
    color: var(--success);
}

.cloud-indicator.error {
    color: var(--danger);
}

.cloud-indicator.syncing {
    animation: pulse 1.5s infinite;
    color: var(--primary);
}

@keyframes pulse {
    0% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.5;
    }
}

main {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* Initial Fade In */
.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

.data-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 0.95rem;
    color: #ddd;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Components */
.card {
    background: var(--surface);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    border: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

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

.btn-primary:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-nav {
    background: var(--surface-light);
    color: var(--text);
    justify-content: flex-start;
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-nav i {
    font-size: 1.5rem;
    color: var(--primary);
}

.btn-nav:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-icon-only {
    padding: 8px;
    width: auto;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

input,
select,
textarea {
    width: 100%;
    padding: 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    color: var(--text);
    font-family: var(--font-main);
    font-size: 1rem;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
}

/* Custom Checkbox */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-wrapper input {
    width: auto;
}

/* Quote */
.quote-widget {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    border-top: 1px solid rgba(255, 215, 0, 0.2);
    border-bottom: 1px solid rgba(255, 215, 0, 0.2);
}

.quote-text {
    font-style: italic;
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.quote-author {
    font-size: 0.8rem;
    color: var(--primary);
}

/* Utilities */
.text-center {
    text-align: center;
}

.input-centered {
    text-align: center;
    font-weight: bold;
    font-size: 1.1rem;
    max-width: 200px;
    margin: 0 auto;
    display: block;
}

.mt-4 {
    margin-top: 1rem;
}

.text-gold {
    color: var(--primary);
}

.hidden {
    display: none !important;
}

/* Toast */
#toast-container {
    position: fixed;
    top: 100px;
    left: 0;
    right: 0;
    margin: auto;
    z-index: 2147483647;
    width: auto;
    max-width: 360px;
}

.toast {
    background: rgba(20, 20, 20, 0.95);
    color: #fff;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary);
    animation: slideUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Badges */
.badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-sede {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-trasferta {
    background: rgba(234, 179, 8, 0.15);
    color: #facc15;
    border: 1px solid rgba(234, 179, 8, 0.3);
}

.badge-assenza {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-smart {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Contact Person Highlight */
.contact-highlight {
    color: var(--primary);
    font-weight: 700;
    font-size: 1rem;
    margin-top: 4px;
    align-items: center;
    gap: 6px;
}

/* Dashboard Components */
.dashboard-header {
    text-align: center;
    margin-bottom: 20px;
}

.dashboard-date {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
    text-transform: capitalize;
}

.dashboard-greeting {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-card {
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.9));
    border: 1px solid rgba(255, 215, 0, 0.1);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 5px;
}

/* Alert Box */
.alert-box {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-md);
    padding: 15px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: pulse-red 2s infinite;
}

.alert-content {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #f87171;
    font-weight: 600;
    font-size: 0.95rem;
}

.alert-action {
    background: #ef4444;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

@keyframes pulse-red {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* Missing Days Section in Alert Box */
.missing-days-section {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed rgba(239, 68, 68, 0.35);
    width: 100%;
}

.missing-days-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #fca5a5;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.missing-days-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.missing-day-pill {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.45);
    color: #fff;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: inherit;
}

.missing-day-pill:hover,
.missing-day-pill:active {
    background: #ef4444;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
}

/* Modal Overlay & Card */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

.modal-card {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-lg, 16px);
    padding: 22px;
    max-width: 440px;
    width: 100%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

/* Footer Signature */
.app-footer {
    text-align: center;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.2);
    padding: 10px;
    margin-top: auto;
    /* Push to bottom if using flex column */
    letter-spacing: 1px;
    font-weight: 300;
    text-transform: uppercase;
}


/* --- Fixed Bottom Navigation Bar --- */
.bottom-nav-bar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 600px;
    height: 64px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 -4px 25px rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-main);
    font-size: 0.75rem;
    font-weight: 600;
    gap: 4px;
    cursor: pointer;
    padding: 8px 0;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item i {
    font-size: 1.5rem;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s;
}

.bottom-nav-item:hover {
    color: var(--text);
}

.bottom-nav-item.active {
    color: var(--primary);
}

.bottom-nav-item.active i {
    transform: translateY(-2px);
    color: var(--primary);
    filter: drop-shadow(0 2px 8px rgba(255, 215, 0, 0.45));
}

/* User Profile Badge in Header */
.user-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 4px 8px;
    border-radius: 16px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
    transition: all 0.2s ease;
    user-select: none;
    max-width: 95px;
    flex-shrink: 1;
    min-width: 0;
    cursor: pointer;
}

#user-header-name {
    display: inline-block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 62px;
}

.user-badge:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--primary);
    transform: translateY(-1px);
}

.user-badge i {
    font-size: 1.15rem;
    color: var(--primary);
}

/* --- Login & Register Styles --- */
.auth-wrapper {
    max-width: 420px;
    margin: 20px auto 40px auto;
    width: 100%;
}

.auth-card {
    background: var(--surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
    text-align: left;
}

.auth-header {
    text-align: center;
    margin-bottom: 24px;
}

.auth-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}

.auth-header p {
    font-size: 0.88rem;
    color: var(--text-muted);
}

.btn-faceid {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.85), rgba(59, 130, 246, 0.95));
    border: 1px solid rgba(96, 165, 250, 0.5);
    color: white;
    padding: 14px 20px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.35);
    transition: all 0.2s ease;
    margin-bottom: 20px;
    width: 100%;
    cursor: pointer;
}

.btn-faceid:hover, .btn-faceid:active {
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}

.btn-faceid i {
    font-size: 1.4rem;
}

.auth-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 18px 0;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.auth-divider:not(:empty)::before {
    margin-right: .75em;
}

.auth-divider:not(:empty)::after {
    margin-left: .75em;
}

.input-password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-password-wrapper input {
    padding-right: 44px;
}

.btn-toggle-pwd {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
}

.btn-toggle-pwd:hover {
    color: var(--text);
}

.fast-access-section {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px dashed rgba(255, 255, 255, 0.12);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fast-access-btn {
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.35);
    color: var(--primary);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.2s ease;
}

.fast-access-btn:hover {
    background: rgba(255, 215, 0, 0.2);
    transform: translateY(-1px);
}


/* --- AI Assistant Styles --- */
.ai-header-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.25), rgba(255, 215, 0, 0.25));
    border: 1px solid rgba(255, 215, 0, 0.5);
    color: var(--primary);
    padding: 5px 11px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.2);
}

.ai-header-btn:hover, .ai-header-btn:active {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.45), rgba(255, 215, 0, 0.45));
    transform: translateY(-1px);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
}

.ai-header-btn i {
    font-size: 1.05rem;
    color: var(--primary);
}

.ai-banner-card {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.85), rgba(20, 28, 48, 0.95));
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: var(--radius-lg);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    transition: all 0.2s ease;
}

.ai-banner-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(255, 215, 0, 0.15);
}

.ai-icon-pulse {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #a855f7, #f59e0b);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.35rem;
    flex-shrink: 0;
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.4);
    animation: pulseAI 2.5s infinite;
}

@keyframes pulseAI {
    0% { transform: scale(1); box-shadow: 0 0 10px rgba(245, 158, 11, 0.4); }
    50% { transform: scale(1.05); box-shadow: 0 0 20px rgba(168, 85, 247, 0.6); }
    100% { transform: scale(1); box-shadow: 0 0 10px rgba(245, 158, 11, 0.4); }
}

.ai-modal-card {
    max-width: 480px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.ai-chips-scroll::-webkit-scrollbar {
    display: none;
}

.ai-chip {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #e2e8f0;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.15s ease;
}

.ai-chip:hover {
    background: rgba(255, 215, 0, 0.2);
    border-color: var(--primary);
    color: var(--primary);
}

.ai-bubble {
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 0.88rem;
    line-height: 1.5;
    max-width: 88%;
    word-break: break-word;
}

.ai-bubble-user {
    align-self: flex-end;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.ai-bubble-bot {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #f1f5f9;
    border-bottom-left-radius: 4px;
    text-align: left;
}


/* --- Google Sign-In & Onboarding Styles --- */
.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    background: #ffffff;
    color: #1f2937;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.btn-google:hover {
    background: #f8fafc;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transform: translateY(-1px);
}

.google-account-pill {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 215, 0, 0.35);
    border-radius: 12px;
    padding: 10px 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    margin-bottom: 8px;
}

.google-account-pill:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--primary);
    transform: translateY(-1px);
}

.google-avatar-circle {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #a855f7, #eab308);
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Header Responsive tweaks for ultra-narrow mobile screens */
@media (max-width: 480px) {
    .app-header {
        padding: 6px 8px;
    }
    .logo-area h1 {
        font-size: 1.05rem !important;
        letter-spacing: 0.5px !important;
    }
    .subtitle {
        font-size: 0.58rem !important;
        letter-spacing: 1px !important;
    }
    .header-actions {
        gap: 4px !important;
    }
    .ai-header-btn {
        padding: 3px 6px !important;
        font-size: 0.72rem !important;
    }
    .user-badge {
        padding: 3px 6px !important;
        font-size: 0.74rem !important;
        max-width: 82px !important;
    }
    #user-header-name {
        max-width: 50px !important;
    }
    #weather-header {
        font-size: 0.74rem !important;
    }
}


/* --- iPhone & iOS Safari Specific Optimizations --- */
:root {
    --sat: env(safe-area-inset-top, 0px);
    --sab: env(safe-area-inset-bottom, 0px);
    --sal: env(safe-area-inset-left, 0px);
    --sar: env(safe-area-inset-right, 0px);
}

html, body {
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-text-size-adjust: 100%;
}

.app-container {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
}

.app-header {
    padding-top: max(8px, env(safe-area-inset-top, 8px));
    padding-left: max(10px, env(safe-area-inset-left, 10px));
    padding-right: max(10px, env(safe-area-inset-right, 10px));
    padding-bottom: 8px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
}

.bottom-nav-bar {
    padding-bottom: max(8px, env(safe-area-inset-bottom, 8px));
    height: calc(56px + env(safe-area-inset-bottom, 0px));
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
}

/* Evita lo zoom automatico su iPhone (Safari) per input < 16px */
@media screen and (max-width: 768px) {
    input, select, textarea {
        font-size: 16px !important;
    }
}

/* Modal overlay con supporto safe area e scroll touch morbido */
.modal-overlay {
    padding: max(16px, env(safe-area-inset-top, 16px)) max(12px, env(safe-area-inset-right, 12px)) max(16px, env(safe-area-inset-bottom, 16px)) max(12px, env(safe-area-inset-left, 12px));
    -webkit-overflow-scrolling: touch;
}

.modal-card {
    max-height: calc(90vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
