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

:root {
    /* addendum #8: brand + shape tokens now come from design-tokens.css
       (loaded before this file). Only PWA-dark surface tokens stay local;
       the brand reds resolve to the canonical #B91C1C via token aliases. */
    --success: #28A745;
}

body {
    font-family: var(--font);
    background-color: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

#app {
    min-height: 100vh;
    position: relative;
}

.screen {
    min-height: 100vh;
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.screen.active {
    display: block;
}

.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.container {
    padding: 20px;
    max-width: 600px;
    margin: 0 auto;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h1 {
    font-size: 1.2rem;
    font-weight: 600;
}

.header-logo {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-btn);
    object-fit: cover;
}

.logo {
    width: 120px;
    height: 120px;
    border-radius: 20px;
    object-fit: contain;
    margin: 40px auto 20px;
    display: block;
    box-shadow: 0 4px 12px color-mix(in srgb, var(--brand-red) 30%, transparent);
}

.logo-small {
    width: 80px;
    height: 80px;
    border-radius: 16px;
    object-fit: cover;
    margin: 20px auto;
    display: block;
}

h1 {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 8px;
}

h2 {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 30px;
    font-size: 0.95rem;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

input, select {
    font-family: var(--font);
    width: 100%;
    padding: 14px 16px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-btn);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.2s;
}

input:focus, select:focus {
    outline: 2px solid var(--brand-red);
    outline-offset: 1px;
    border-color: var(--brand-red);
    box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.25);
}

input::placeholder {
    color: var(--text-secondary);
}

#otp {
    text-align: center;
    font-size: 1.5rem;
    letter-spacing: 8px;
    font-weight: 600;
}

.btn {
    font-family: var(--font);
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: var(--radius-btn);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 10px;
}

.btn-primary {
    background-color: var(--brand-red);
    color: white;
}

.btn-primary:hover {
    background-color: var(--brand-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--brand-red) 30%, transparent);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background-color: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--bg-card-hover);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-btn);
    transition: background-color 0.2s;
}

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

.facility-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

.facility-header {
    margin-bottom: 16px;
}

.facility-name {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.facility-address {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.gate-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.gate-button {
    width: 100%;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--brand-red) 0%, var(--brand-dark) 100%);
    color: white;
    border: none;
    border-radius: var(--radius-btn);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.gate-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px color-mix(in srgb, var(--brand-red) 40%, transparent);
}

.gate-button:active {
    transform: translateY(0);
}

.gate-button svg {
    width: 24px;
    height: 24px;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.profile-info {
    background-color: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    margin-top: 20px;
}

.info-item {
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
}

.info-item:last-child {
    border-bottom: none;
}

.info-item label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.info-item div {
    color: var(--text-primary);
    font-size: 1rem;
}

.error-message {
    color: var(--error);
    background-color: rgba(220, 53, 69, 0.1);
    border: 1px solid var(--error);
    border-radius: var(--radius-btn);
    padding: 12px 16px;
    margin-top: 16px;
    font-size: 0.9rem;
    display: none;
}

.error-message.show {
    display: block;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(26, 26, 46, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--brand-red);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--bg-card);
    color: var(--text-primary);
    padding: 16px 24px;
    border-radius: var(--radius-btn);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    z-index: 1001;
    animation: slideUp 0.3s ease-out;
    max-width: 90%;
}

.toast.success {
    background-color: var(--success);
}

.toast.error {
    background-color: var(--error);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@media (max-width: 480px) {
    .container {
        padding: 16px;
    }
    
    h1 {
        font-size: 1.75rem;
    }
    
    .logo {
        width: 100px;
        height: 100px;
    }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    .screen {
        min-height: -webkit-fill-available;
    }
}
