* { margin: 0; padding: 0; box-sizing: border-box; }
body { 
    font-family: 'Open Sans', Arial, sans-serif; 
    background-color: #f5f5f5;
    color: #333;
}
.top-bar {
    background-color: #0d7c8c;
    color: white;
    padding: 15px 0;
    text-align: center;
    font-size: 14px;
}
.nav-bar {
    background-color: white;
    padding: 20px 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.nav-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.logo {
    display: flex;
    align-items: center;
    gap: 15px;
    font-weight: 700;
    color: #333;
}
.logo-text {
    font-size: 18px;
    line-height: 1.3;
}
.container { 
    max-width: 1200px; 
    margin: 0 auto; 
    padding: 40px 20px;
}
.hero-section {
    background: linear-gradient(135deg, #0d7c8c 0%, #0a5f6c 100%);
    color: white;
    padding: 60px 20px;
    text-align: center;
    margin-bottom: 40px;
    border-radius: 8px;
}
.hero-section h1 {
    font-size: 3em;
    font-weight: 700;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}
.hero-section p {
    font-size: 1.2em;
    margin-bottom: 30px;
    line-height: 1.6;
}
.content-card {
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}
.header { text-align: center; margin-bottom: 30px; }
.login-section { text-align: center; margin: 30px 0; }
.google-btn { 
    background-color: #4285F4;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    margin: 10px;
    transition: background-color 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.google-btn:hover { background-color: #357ae8; }

.microsoft-btn {
    background-color: #2F2F2F;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    margin: 10px;
    transition: background-color 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.microsoft-btn:hover { background-color: #000000; }

.auth-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
}
@media (min-width: 600px) {
    .auth-buttons {
        flex-direction: row;
        justify-content: center;
    }
}
.dashboard { display: none; }
.user-info { 
    background-color: #e8f4f5;
    padding: 20px;
    border-radius: 5px;
    margin-bottom: 30px;
    border-left: 4px solid #0d7c8c;
}
.stats-grid { 
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin: 30px 0;
}
.stat-card { 
    background: linear-gradient(135deg, #0d7c8c 0%, #0a5f6c 100%);
    color: white;
    padding: 30px 20px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    transition: transform 0.3s ease;
}
.stat-card:hover {
    transform: translateY(-5px);
}
.stat-number { 
    font-size: 2.5em;
    font-weight: 700;
    margin-bottom: 10px;
}
.stat-label {
    font-size: 0.95em;
    opacity: 0.95;
}
.hidden { display: none; }
.checkin-section { 
    margin-top: 30px;
    padding: 30px;
    background-color: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}
.checkin-section h3 {
    color: #0d7c8c;
    margin-bottom: 15px;
    font-size: 1.5em;
}
.search-box {
    width: 100%;
    padding: 15px;
    margin: 20px 0;
    border: 2px solid #0d7c8c;
    border-radius: 5px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}
.search-box:focus {
    outline: none;
    border-color: #0a5f6c;
    box-shadow: 0 0 5px rgba(13, 124, 140, 0.3);
}
.user-list { 
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: white;
}
.user-item { 
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s ease;
    font-size: 14px;
}
.user-item:hover {
    background-color: #f5f5f5;
}
.checkin-btn { 
    background-color: #0d7c8c;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.3s ease;
}
.checkin-btn:hover {
    background-color: #0a5f6c;
}
.checked-in { 
    background-color: #d4edda;
    border-left: 4px solid #28a745;
}
.btn-secondary {
    background-color: #6c757d;
}
.btn-secondary:hover {
    background-color: #5a6268;
}
.btn-danger {
    background-color: #dc3545;
}
.btn-danger:hover {
    background-color: #c82333;
}
.button-group {
    text-align: center;
    margin-top: 30px;
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

/* Admin utility styles */
.no-underline { text-decoration: none; }
.muted { color: #666; }
.muted-2 { color: #555; }
.text-brand { color: #0d7c8c; }
.text-center { text-align: center; }
.mt-10 { margin-top: 10px; }
.mt-15 { margin-top: 15px; }
.mb-15 { margin-bottom: 15px; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.block { display: block; }
.flex-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.w-320 { max-width: 320px; }
.w-200 { max-width: 200px; }
.panel-box { overflow: auto; max-height: 250px; border: 1px solid #eee; border-radius: 6px; padding: 10px; background: #fff; }
.panel-tall { max-height: 70vh; }
.align-center { align-items: center; }
.align-end { align-items: flex-end; }
.container-inner { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.w-160 { max-width: 160px; }
.control-sm { padding: 6px 10px; font-size: 14px; height: 36px; }
.control-xs { padding: 4px 8px; font-size: 13px; height: 30px; }
.gap-sm { gap: 8px; }
.w-140 { max-width: 140px; }
.w-120 { max-width: 120px; }

/* Table helpers */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; border-bottom: 1px solid #eee; padding: 6px 8px; background: #fff; }
.data-table td { padding: 6px 8px; border-bottom: 1px solid #f5f5f5; }
.table-sticky thead th { position: sticky; top: 0; z-index: 1; }
.qr-region { width: 320px; max-width: 100%; }

/* Modal overlay */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.modal-content { background: #fff; border-radius: 8px; width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; padding: 16px 16px 20px; box-shadow: 0 10px 30px rgba(0,0,0,0.2); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.modal-close { background: transparent; border: none; font-size: 18px; cursor: pointer; color: #555; }
.modal-close:hover { color: #111; }
.scanner-region-full { width: 100%; max-width: 480px; margin: 10px auto; }

/* Ensure hidden actually hides modals (specificity override) */
.modal.hidden { display: none !important; }

/* Typeahead dropdown */
.typeahead { border: 1px solid #eee; border-radius: 6px; background: #fff; box-shadow: 0 6px 16px rgba(0,0,0,0.08); max-width: 320px; max-height: 240px; overflow: auto; margin-top: 6px; }
.typeahead-item { padding: 8px 10px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.typeahead-item:hover { background: #f5f5f5; }
.typeahead-primary { font-weight: 600; color: #0d7c8c; }
.typeahead-secondary { font-size: 12px; color: #555; }

/* Global nav links */
.nav-links {
    display: flex;
    gap: 12px;
}
.nav-links a {
    color: #0d7c8c;
    font-weight: 600;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 6px;
}
.nav-links a:hover {
    background: #e8f4f5;
}

.nav-right { display: flex; align-items: center; gap: 12px; }
.auth-controls { display: flex; align-items: center; }
.nav-btn { color: #0d7c8c; font-weight: 600; background: transparent; border: none; padding: 8px 12px; border-radius: 6px; cursor: pointer; }
.nav-btn:hover { background: #e8f4f5; }

/* Admin/labels helpers */
.label-strong { font-weight: 600; margin-bottom: 6px; }

/* QR Labels layout (4 per US Letter page) */
.labels-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.labels-grid {
    width: 8.5in; /* match paper width for accurate print layout */
    margin: 0 auto;
    display: grid;
    grid-template-columns: 3.75in 3.75in; /* two columns */
    grid-column-gap: 0.5in; /* gutter */
    grid-row-gap: 0.5in; /* gutter */
    padding: 0.25in; /* small inner padding */
    background: transparent;
}
.label-card {
    width: 3.75in;
    height: 5in; /* two rows -> 5in each with 0.5in gutter and 0.5in margins */
    border: 1px dashed #cfd8dc;
    border-radius: 6px;
    background: #fff;
    padding: 0.25in;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    page-break-inside: avoid;
}
.label-name {
    font-size: 18pt;
    font-weight: 700;
    text-align: center;
}
.label-qr {
    width: 2.6in; /* visual size on paper */
    height: 2.6in;
    display: flex;
    align-items: center;
    justify-content: center;
}
.label-org {
    font-size: 12pt;
    text-align: center;
    color: #37474f;
}

/* Print tuning for exact Letter pages */
@media print {
    @page { size: Letter; margin: 0.5in; }
    body { background: #fff; }
    .top-bar, .nav-bar, .labels-actions { display: none !important; }
    .content-card { box-shadow: none; padding: 0; }
}

/* Screen fallback: allow horizontal scroll if wider than viewport */
.labels-scroll { overflow-x: auto; }

/* Progress bar */
.progress { position: relative; height: 18px; background: #e9ecef; border-radius: 9px; overflow: hidden; }
.progress-bar { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, #0d7c8c, #0a5f6c); width: 0%; transition: width 0.4s ease; }
.progress-marker { position: absolute; top: -6px; bottom: -6px; width: 2px; background: #d9534f; left: 51%; }
.progress-legend { display: flex; justify-content: space-between; font-size: 12px; color: #555; margin-top: 6px; }
.progress-complete { background: linear-gradient(90deg, #2e7d32, #1b5e20) !important; }

/* Compact list for stats */
.mini-list { border: 1px solid #eee; border-radius: 6px; overflow: auto; background: #fff; max-height: 420px; }
.mini-item { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border-bottom: 1px solid #f3f3f3; }
.mini-item:last-child { border-bottom: 0; }
.badge { font-size: 12px; background: #e8f4f5; color: #0d7c8c; border-radius: 4px; padding: 2px 6px; }

/* Charts layout helpers */
.chart-col { flex: 1; min-width: 300px; }
.full-width { min-width: 100%; }

/* Auth Modal */
.auth-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(2px);
    animation: fadeIn 0.2s ease-out;
}

.auth-modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    position: relative;
    max-width: 90%;
    width: 360px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    animation: slideUp 0.3s ease-out;
}

.auth-modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    border: none;
    background: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    transition: color 0.2s;
}
.auth-modal-close:hover { color: #333; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    margin: 0;
}
.search-box-sm {
    padding: 6px;
    font-size: 13px;
    height: auto;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .nav-content {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }
    
    .logo {
        margin-bottom: 5px;
    }

    .nav-right {
        width: 100%;
        flex-direction: column;
        gap: 15px;
    }

    .nav-links {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 8px;
    }

    .nav-links a {
        font-size: 14px;
        padding: 8px 12px;
        background: #f8f9fa;
        border-radius: 20px;
        border: 1px solid #e9ecef;
        text-align: center;
        flex-grow: 1; /* Make buttons fill available space */
        max-width: 150px; /* But not too wide */
    }

    .nav-links a:hover, .nav-links a.active {
        background: #e8f4f5;
        border-color: #0d7c8c;
    }
    
    .auth-controls {
        width: 100%;
        justify-content: center;
    }

    .container {
        padding: 20px 15px;
    }

    .hero-section {
        padding: 40px 15px;
        border-radius: 0;
        margin-left: -15px;
        margin-right: -15px;
        width: calc(100% + 30px);
    }

    .hero-section h1 {
        font-size: 2em;
    }
    
    .hero-section p {
        font-size: 1.1em;
    }

    .content-card {
        padding: 20px;
    }
    
    .search-box {
        font-size: 16px; /* prevent zoom on input focus for iOS */
        padding: 12px;
    }
    
    .user-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 15px;
    }
    
    .user-item .checkin-btn {
        width: 100%;
        margin-top: 5px;
        padding: 12px;
    }
    
    /* Stats and tables adjustments */
    .stats-grid {
        grid-template-columns: 1fr; /* Single column stats */
    }
    
    .mini-item {
        flex-direction: column;
        gap: 6px;
        padding: 12px;
    }
    
    .chart-col {
        min-width: 100%;
    }
    
    .flex-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .w-320, .w-200, .w-160, .w-140, .w-120 {
        max-width: 100%;
        width: 100%;
    }
    
    .control-sm, .control-xs {
        height: 44px; /* Larger touch targets */
        font-size: 16px;
    }
    
    /* Modal adjustments */
    .modal {
        padding: 0;
        align-items: flex-end; /* Sheet-like behavior on mobile */
    }
    
    .modal-content {
        max-height: 95vh;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        width: 100%;
        max-width: 100%;
    }
    
    /* QR Scanner camera view */
    #scanner-container video {
        max-width: 100% !important;
        height: auto !important;
    }
    
    /* Admin tables overrides */
    .panel-box {
        max-height: none; /* Let it expand */
        overflow-x: auto;
    }
}
