* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0f2f5;
    color: #1a1a2e;
    min-height: 100vh;
}

/* Login Page */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

.login-logo {
    display: block;
    margin: 0 auto 16px;
    height: 80px;
    width: auto;
}

.login-card h1 {
    text-align: center;
    margin-bottom: 8px;
    font-size: 1.5rem;
}

.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 24px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #333;
}

.form-group input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: #4a90d9;
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.1);
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: #4a90d9;
    color: white;
    width: 100%;
    padding: 12px;
    font-size: 1rem;
}

.btn-primary:hover {
    background: #357abd;
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
    background: #eee;
    color: #333;
}

.btn-small:hover {
    background: #ddd;
}

.error-msg {
    color: #e74c3c;
    text-align: center;
    margin-top: 12px;
    font-size: 0.9rem;
}

.hidden {
    display: none !important;
}

/* Main App */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    margin-bottom: 20px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-logo {
    height: 40px;
    width: auto;
}

header h1 {
    font-size: 1.3rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

#userDisplay {
    color: #666;
    font-size: 0.9rem;
}

/* Search */
.search-section {
    background: white;
    padding: 20px 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    margin-bottom: 20px;
}

.search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.search-bar input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
}

.search-bar input:focus {
    outline: none;
    border-color: #4a90d9;
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.1);
}

.search-bar select {
    padding: 10px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.9rem;
    background: white;
}

.search-bar .btn-primary {
    width: auto;
    padding: 10px 24px;
}

.search-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #666;
    font-size: 0.9rem;
}

/* Results */
.results-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.placeholder-text {
    text-align: center;
    color: #999;
    padding: 60px 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.email-card {
    background: white;
    padding: 16px 20px;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.email-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.email-checkbox {
    margin-top: 4px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.email-content {
    flex: 1;
    min-width: 0;
}

.email-subject {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-meta {
    display: flex;
    gap: 16px;
    font-size: 0.8rem;
    color: #666;
}

.email-preview {
    font-size: 0.85rem;
    color: #888;
    margin-top: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-folder {
    background: #e8f0fe;
    color: #4a90d9;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 20px;
    padding: 16px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px 24px;
    border-bottom: 1px solid #eee;
}

.modal-header h2 {
    font-size: 1.2rem;
    margin-right: 16px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: #999;
    line-height: 1;
}

.modal-close:hover {
    color: #333;
}

.modal-meta {
    padding: 16px 24px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    font-size: 0.9rem;
}

.modal-meta p {
    margin-bottom: 4px;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    white-space: pre-wrap;
    font-size: 0.9rem;
    line-height: 1.6;
}

.modal-actions {
    padding: 16px 24px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
}

/* Admin Panel */
.admin-panel {
    background: white;
    padding: 20px 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    margin-top: 20px;
}

.admin-panel h3 {
    margin-bottom: 16px;
}

.admin-panel h4 {
    margin-bottom: 6px;
    font-size: 0.95rem;
}

.import-section {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #eee;
}

.import-section:last-of-type {
    border-bottom: none;
}

.import-hint {
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 8px;
}

.import-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.import-path-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.9rem;
}

.import-path-input:focus {
    outline: none;
    border-color: #4a90d9;
}

.import-row .btn-primary {
    width: auto;
    white-space: nowrap;
}

.import-progress {
    margin-top: 16px;
}

.progress-bar-container {
    width: 100%;
    height: 24px;
    background: #e9ecef;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #4a90d9, #357abd);
    border-radius: 12px;
    transition: width 0.5s ease;
    width: 0%;
}

#importStatus {
    font-size: 0.9rem;
    color: #333;
    margin: 0;
}

.import-elapsed {
    font-size: 0.8rem;
    color: #888;
    margin-top: 4px;
}

/* Responsive */
@media (max-width: 768px) {
    .search-bar {
        flex-direction: column;
    }

    .email-meta {
        flex-direction: column;
        gap: 4px;
    }

    header {
        flex-direction: column;
        gap: 12px;
    }
}
