/* 1. GLOBAL FIX */
* {
    box-sizing: border-box;
}

body {
    font-family: sans-serif;
    display: flex;
    justify-content: center;
    /* Top align ensures we don't cut off the top if it overflows */
    align-items: flex-start; 
    margin: 0;
    background-color: #f4f4f4;
    min-height: 100vh;
    overflow-y: auto; /* Allow scrolling if absolutely needed */
    padding: 10px 0;
}

.form-container {
    background: white;
    /* FIX: Very tight padding to save vertical space */
    padding: 15px 20px; 
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    
    width: 100%;
    max-width: 320px;
    
    /* Remove rigid height, let it shrink to fit content */
    min-height: auto; 
    margin: 5px auto; 
}

/* FIX: Drastically reduced spacing between fields */
.form-group {
    margin-bottom: 8px; 
}

label {
    display: block;
    margin-bottom: 2px; /* Tighter labels */
    font-weight: bold;
    font-size: 0.85em; /* Slightly smaller text */
}

input {
    width: 100%;
    /* FIX: Compact inputs */
    padding: 8px; 
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

button {
    width: 100%;
    padding: 10px; /* Smaller button */
    border: none;
    background: #0000AF;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 15px;
    margin-top: 5px;
}

button:hover {
    background: #000080; 
}

.form-group-inline {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    margin-top: 5px;
}
.form-group-inline label {
    font-weight: normal;
    margin: 0 0 0 5px;
    font-size: 0.85em;
}
.form-group-inline input {
    width: auto; 
}

.message {
    margin-top: 5px;
    border-radius: 4px;
    padding: 0;
    font-size: 0.85em;
}
.message:not(:empty) {
    padding: 8px;
}
.success { color: #155724; background-color: #d4edda; }
.error { color: #721c24; background-color: #f8d7da; }

a {
    color: #007bff;
    text-decoration: none;
    display: block;
    text-align: center;
    margin-top: 10px;
    font-size: 0.85em;
}

/* --- MOBILE OPTIMIZATIONS (iPhone SE) --- */
@media screen and (max-width: 480px) {
    body {
        width: 100% !important;
        margin: 0 auto !important;
        
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        
        /* Mobile padding adjustment */
        padding: 10px; 
        padding-bottom: 40px; 
    }

    .form-container {
        box-shadow: none;
        padding: 10px; /* Even tighter on mobile */
    }

    button, .btn, input:not([type="checkbox"]) {
        width: 100% !important;
        /* Mobile touch targets need to be slightly larger than desktop, 
           but we keep them compact here to fit the screen */
        padding: 10px !important; 
        margin-bottom: 8px;
    }
}