* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #f5f5f5;
}

/* Login Page */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 400px;
}

.login-container h1 {
    text-align: center;
    margin-bottom: 10px;
    color: #333;
    font-size: 28px;
}

.subtitle {
    text-align: center;
    color: #666;
    font-size: 14px;
    margin-bottom: 25px;
}

.login-container input {
    width: 100%;
    padding: 12px;
    margin-bottom: 20px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.login-container input:focus {
    outline: none;
    border-color: #667eea;
}

.login-container button {
    width: 100%;
    padding: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s;
}

.login-container button:hover:not(:disabled) {
    background: #5568d3;
}

.login-container button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.error-message {
    color: #dc3545;
    text-align: center;
    margin-top: 15px;
    font-size: 14px;
}

/* Manager Page */
.top-bar {
    background: #0078D7;
    color: white;
    padding: 12px 20px;
    padding-right: 130px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-bar-section {
    display: flex;
    align-items: center;
    gap: 8px;
}

.date-section {
    gap: 8px;
}

.filters-section {
    display: flex;
    gap: 15px;
    flex: 1;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.actions-section {
    margin-left: auto;
    gap: 12px;
}

.actions-top {
    display: flex;
    justify-content: flex-end;
}

.actions-bottom {
    display: flex;
    align-items: center;
    gap: 12px;
}

.site-label {
    font-size: 16px;
    white-space: nowrap;
}

.site-label strong {
    font-weight: bold;
}

.filter-label {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.device-select {
    padding: 6px 10px;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    background: white;
    color: #333;
    cursor: pointer;
    min-width: 120px;
}

/* Date selector styles */
.date-input {
    padding: 6px 10px;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    background: white;
    color: #333;
    cursor: pointer;
}

.date-separator {
    font-size: 13px;
    font-weight: normal;
    padding: 0 4px;
}

.load-date-btn {
    background: #FFA500;
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s;
    white-space: nowrap;
}

.load-date-btn:hover {
    background: #FF8C00;
}

.date-range-label {
    font-size: 12px;
    font-style: italic;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 10px;
    border-radius: 4px;
    white-space: nowrap;
}

.changes-label {
    font-size: 13px;
    white-space: nowrap;
}

.save-btn {
    background: #28A745;
    color: white;
    border: none;
    padding: 7px 18px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s;
    white-space: nowrap;
}

.save-btn:hover:not(:disabled) {
    background: #218838;
}

.save-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Main Container */
.main-container {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.loading {
    text-align: center;
    font-size: 18px;
    color: #666;
    padding: 50px;
}

/* Faces Grid */
.faces-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    padding: 10px;
}

.face-card {
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.face-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.card-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 10px;
}

.header-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.device-name {
    font-size: 11px;
    font-weight: bold;
    color: #0078D7;
    background: #E3F2FD;
    padding: 4px 10px;
    border-radius: 12px;
    text-align: right;
}

.timestamp-label {
    font-size: 10px;
    color: #666;
    background: #f5f5f5;
    padding: 3px 8px;
    border-radius: 10px;
    text-align: right;
}

.image-container {
    position: relative;
    margin-bottom: 15px;
}

.face-image {
    width: 112px;
    height: 112px;
    margin: 0 0 0 0;
    display: block;
    border-radius: 4px;
    object-fit: cover;
    background: #f0f0f0;
}

.face-image.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 12px;
}

.swap-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 30px;
    height: 30px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.swap-btn:hover {
    background: white;
    transform: scale(1.1);
}

.face-id {
    font-size: 11px;
    color: #666;
    text-align: left;
    margin-bottom: 10px;
    word-break: break-all;
}

.confidence-container {
    margin-bottom: 15px;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 4px;
}

.confidence-value {
    font-size: 16px;
    font-weight: bold;
    margin-top: 3px;
}

.confidence-high {
    color: #28A745;
}

.confidence-medium {
    color: #FFC107;
}

.confidence-low {
    color: #DC3545;
}

.card-section {
    margin-bottom: 15px;
}

.card-label {
    font-size: 12px;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.current-assignment {
    font-size: 14px;
    color: #0078D7;
    margin-bottom: 15px;
    text-align: left;
    min-height: 20px;
}

.card-select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s;
}

.card-select:focus {
    outline: none;
    border-color: #0078D7;
}

/* Responsive */
@media (max-width: 1400px) {
    .top-bar {
        gap: 15px;
    }

    .filters-section {
        gap: 12px;
    }

    .device-select {
        min-width: 100px;
        font-size: 12px;
    }

    .filter-label {
        font-size: 12px;
    }
}

@media (max-width: 1200px) {
    .top-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .top-bar-section {
        justify-content: flex-start;
    }

    .filters-section {
        flex-wrap: wrap;
    }

    .actions-section {
        margin-left: 0;
        justify-content: space-between;
    }
}

@media (max-width: 768px) {
    .filters-section {
        flex-direction: column;
        gap: 10px;
    }

    .filter-group {
        width: 100%;
    }

    .device-select {
        flex: 1;
    }

    .faces-grid {
        grid-template-columns: 1fr;
    }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
    z-index: 1001;
}

.modal-close:hover,
.modal-close:focus {
    color: #bbb;
}

.modal-content-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 60px 20px 20px;
}

.modal-content {
    max-width: 90%;
    max-height: 80%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.modal-controls {
    margin-top: 20px;
    display: flex;
    gap: 15px;
}

.modal-toggle-btn {
    background: #0078D7;
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

.modal-toggle-btn:hover {
    background: #005a9e;
}
.success-message {
    color: #28A745;
    text-align: center;
    margin-top: 15px;
    font-size: 14px;
}

.auth-link {
    text-align: center;
    margin-top: 15px;
    font-size: 14px;
    color: #666;
}

.auth-link a {
    color: #667eea;
    text-decoration: none;
    font-weight: bold;
}

.auth-link a:hover {
    text-decoration: underline;
}

.top-bar-link {
    color: rgba(255, 255, 255, 0.85);
    font-size: 13px;
    text-decoration: none;
    white-space: nowrap;
}

.top-bar-link:hover {
    color: white;
    text-decoration: underline;
}

/* Account Menu */
.account-menu-wrapper {
    position: absolute;
    top: 10px;
    right: 16px;
}

.account-btn {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 6px 14px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}

.account-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.account-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    min-width: 200px;
    z-index: 500;
    overflow: hidden;
}

.account-dropdown.hidden {
    display: none;
}

.account-dropdown-header {
    padding: 12px 16px;
    font-size: 13px;
    color: #555;
    background: #f8f9fa;
}

.account-divider {
    border: none;
    border-top: 1px solid #eee;
    margin: 0;
}

.account-option {
    display: block;
    width: 100%;
    padding: 11px 16px;
    text-align: left;
    background: none;
    border: none;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    transition: background 0.15s;
}

.account-option:hover {
    background: #f0f4ff;
    color: #0078D7;
}

/* Account Modals */
.account-modal-overlay {
    position: fixed;
    z-index: 1000;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.account-modal-overlay.hidden {
    display: none;
}

.account-modal {
    background: white;
    border-radius: 10px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow: hidden;
}

.account-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    background: #0078D7;
    color: white;
}

.account-modal-header h2 {
    font-size: 17px;
    font-weight: 600;
    margin: 0;
}

.account-modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.account-modal-close:hover {
    opacity: 1;
}

.account-modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.account-modal-body input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.account-modal-body input:focus {
    outline: none;
    border-color: #0078D7;
}

.account-modal-submit {
    width: 100%;
    padding: 10px;
    background: #0078D7;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 4px;
}

.account-modal-submit:hover:not(:disabled) {
    background: #005a9e;
}

.account-modal-submit:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.account-modal-error {
    color: #dc3545;
    font-size: 13px;
    min-height: 16px;
}

.account-modal-success {
    color: #28a745;
    font-size: 13px;
    min-height: 16px;
}

/* Save Progress Bar */
.save-progress-bar-bg {
    width: 100%;
    background: #e9ecef;
    border-radius: 6px;
    height: 12px;
    overflow: hidden;
    margin-top: 8px;
}

.save-progress-bar {
    height: 100%;
    background: #0078D7;
    border-radius: 6px;
    width: 0%;
    transition: width 0.1s ease;
}