:root {
    --primary: #CC0000;
    --secondary: #e0e0e0;
    --text: #333;
    --bg: #f4f6f8;
    --white: #ffffff;
    --success: #28a745;
    --error: #dc3545;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

/* Header */
.app-header {
    background-color: var(--primary);
    color: var(--white);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.logo {
    font-weight: bold;
    font-size: 1.2rem;
}

.status-badge {
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.2);
}

.status-badge.online {
    background: var(--success);
}

.status-badge.offline {
    background: var(--error);
}

/* Main */
main {
    padding: 1rem;
    max-width: 800px;
    margin: 0 auto;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

h2,
h3 {
    margin-top: 0;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s;
    width: 100%;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-secondary {
    background: var(--secondary);
    color: var(--text);
}

.btn-text {
    background: transparent;
    color: var(--text);
}

.btn-large {
    padding: 1rem;
    font-size: 1.1rem;
    font-weight: bold;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Form */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
}

/* Views */
.hidden {
    display: none !important;
}

/* PDF Preview Container - iOS Fixes */
.pdf-preview-container {
    height: 400px;
    /* Default height */
    border: 1px solid #ccc;
    margin-bottom: 1rem;
    overflow-y: auto;
    /* Enable scrolling */
    -webkit-overflow-scrolling: touch;
    /* Momentum scrolling for iOS */
}

/* Force iframe to not expand infinitely on iOS */
.pdf-preview-container iframe {
    width: 100%;
    min-width: 100%;
    height: 100%;
    display: block;
    border: none;
}

.signature-wrapper {
    border: 2px dashed #ccc;
    background: #fff;
    border-radius: 4px;
    position: relative;
    height: 300px;
    width: 100%;
    margin: 1rem 0;
}

canvas {
    width: 100%;
    height: 100%;
    touch-action: none;
}

.signature-actions {
    text-align: right;
    font-size: 0.9rem;
}

/* Checklist */
.checklist label {
    display: block;
    padding: 0.75rem;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}

.checklist label:last-child {
    border-bottom: none;
}

.checklist input {
    width: auto;
    margin-right: 0.5rem;
}

@media (min-width: 600px) {
    .btn {
        width: auto;
    }

    .actions {
        justify-content: flex-end;
    }
}

/* LOGIN SCREEN STYLES */
#login-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: var(--white);
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.logo-img {
    max-width: 180px;
    height: auto;
    margin: 0 auto 24px;
    display: block;
}

/* Hide app container by default until logged in */
#app-container.auth-locked {
    display: none;
}

/* FORCE EXACT LOGIN STYLING (MATCHING MAINTENANCE REPORT) */
#login-screen h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 16px 0;
    color: #0a0a0a;
    display: flex;
    align-items: center;
    gap: 8px;
    /* Inline style in HIV handles key justification */
}

#login-screen h2::before {
    content: '';
    display: block;
    width: 4px;
    height: 1.1em;
    background: #CC0000;
    border-radius: 2px;
}

#login-screen .btn {
    display: block;
    width: 100%;
    padding: 16px;
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
    border: none;
    border-radius: 99px;
    /* Pill shape */
    background: #CC0000;
    color: white;
    box-shadow: 0 4px 12px rgba(204, 0, 0, 0.3);
    cursor: pointer;
    transition: transform 0.1s;
}

#login-screen .btn:active {
    transform: scale(0.98);
}

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

#loading-overlay.hidden {
    display: none;
}

.loading-card {
    text-align: center;
    padding: 40px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    max-width: 90%;
    width: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

#loading-message {
    color: var(--text-dark);
    font-size: 1.1rem;
    font-weight: 500;
    margin: 0;
}