:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #1e293b;
    --light: #f8fafc;
    --gray: #64748b;
    --border: #e2e8f0;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* App Container */
.app-container {
    display: flex;
    min-height: 100vh;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: white;
    padding: 2rem 1rem;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
    padding: 0 1rem;
}

.logo i {
    font-size: 2rem;
    color: var(--primary);
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1rem;
    color: var(--gray);
    text-decoration: none;
    border-radius: 10px;
    transition: all 0.3s;
}

.nav-item i {
    width: 20px;
}

.nav-item:hover {
    background: var(--light);
    color: var(--primary);
}

.nav-item.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.header h2 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--dark);
    font-size: 1.8rem;
}

.header h2 i {
    color: var(--primary);
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: white;
    border-radius: 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Card */
.screen {
    display: none;
}

.screen.active {
    display: block;
}

.hero-card {
    border: 1px solid rgba(99, 102, 241, 0.18);
}

.hero-copy {
    color: var(--gray);
    margin-bottom: 1.25rem;
}

.server-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--light);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--gray);
}

.server-status .dot {
    background: var(--gray);
}

.server-status.online .dot {
    background: var(--success);
}

.server-status.offline .dot {
    background: var(--danger);
    animation: none;
}

.quick-link-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
}

.quick-link-card {
    display: block;
    padding: 1.5rem;
    background: white;
    border-radius: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    text-decoration: none;
    color: inherit;
    transition: all 0.3s;
    border: 1px solid transparent;
}

.quick-link-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.25);
}

.quick-link-card i {
    font-size: 1.75rem;
    color: var(--primary);
    margin-bottom: 0.85rem;
}

.quick-link-card h4 {
    color: var(--dark);
    font-size: 1.05rem;
    margin-bottom: 0.4rem;
}

.quick-link-card p {
    color: var(--gray);
    font-size: 0.85rem;
    line-height: 1.5;
}

.card {
    background: white;
    border-radius: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    margin-bottom: 2rem;
}

.card-body {
    padding: 2rem;
}

/* Form */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    color: var(--dark);
    font-weight: 500;
}

.form-group label i {
    color: var(--primary);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.875rem;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 0.95rem;
    transition: all 0.3s;
    font-family: inherit;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.hint {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--gray);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Examples */
.examples {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--light);
    border-radius: 12px;
    flex-wrap: wrap;
}

.example-label {
    color: var(--gray);
    font-size: 0.9rem;
}

.example-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    background: white;
    border-radius: 8px;
    color: var(--gray);
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.example-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
}

/* Filters Row */
.filters-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.btn-primary, .btn-secondary {
    padding: 1rem 2rem;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    transition: all 0.3s;
    flex: 1;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-secondary {
    background: white;
    color: var(--gray);
    border: 2px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-icon {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 10px;
    color: var(--gray);
    cursor: pointer;
    transition: all 0.3s;
}

.btn-icon:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    color: var(--dark);
}

.section-title i {
    color: var(--primary);
    font-size: 1.25rem;
}

.section-title h3 {
    font-size: 1.25rem;
}

.spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
}

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

/* Results Section */
.results-section {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    animation: slideUp 0.3s ease;
}

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

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.results-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.results-title i {
    font-size: 1.5rem;
    color: var(--primary);
}

.results-title h3 {
    color: var(--dark);
}

.results-title span {
    background: var(--light);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.9rem;
    color: var(--primary);
    margin-left: 0.5rem;
}

.results-actions {
    display: flex;
    gap: 0.5rem;
}

/* Email Table */
.email-table {
    border: 2px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: white;
}

.table-header {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    font-weight: 600;
}

.table-row {
    display: flex;
    border-bottom: 1px solid var(--border);
    transition: all 0.2s;
    cursor: pointer;
}

.table-row:hover {
    background: var(--light);
}

.table-row.has-code {
    background: rgba(245, 158, 11, 0.05);
}

.table-row.has-code:hover {
    background: rgba(245, 158, 11, 0.1);
}

.table-cell {
    padding: 1rem;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sender Info */
.sender-info {
    display: flex;
    flex-direction: column;
}

.sender-info small {
    color: var(--gray);
    font-size: 0.8rem;
}

/* Subject Preview */
.subject-preview {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.subject-preview .preview-text {
    font-size: 0.8rem;
    color: var(--gray);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Code Badge */
.code-badge {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    padding: 0.5rem 0.75rem;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--warning);
    cursor: pointer;
    transition: all 0.2s;
}

.code-badge:hover {
    background: var(--warning);
    color: white;
    transform: scale(1.05);
    box-shadow: 0 2px 10px rgba(245, 158, 11, 0.3);
}

.no-code {
    color: var(--gray);
    font-style: italic;
}

/* Folder Badge */
.folder-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.folder-badge.inbox {
    background: var(--light);
    color: var(--primary);
    border: 1px solid var(--primary);
}

.folder-badge.spam {
    background: #fee2e2;
    color: var(--danger);
    border: 1px solid var(--danger);
}

/* Batch Refresh Status */
.batch-status {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: 600;
}

.batch-status.ok {
    background: #d1fae5;
    color: var(--success);
    border: 1px solid var(--success);
}

.batch-status.error {
    background: #fee2e2;
    color: var(--danger);
    border: 1px solid var(--danger);
}

.batch-note {
    font-family: 'Courier New', monospace;
    font-size: 0.82rem;
    color: var(--gray);
    word-break: break-all;
}

.x-status {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
}

.x-status.live {
    background: #d1fae5;
    color: var(--success);
}

.x-status.sus {
    background: #ffedd5;
    color: #f97316;
}

.x-status.die {
    background: #fee2e2;
    color: var(--danger);
}

.x-status.warning {
    background: #fef3c7;
    color: var(--warning);
}

.x-status.pending {
    background: var(--light);
    color: var(--gray);
}

/* Stats Section */
.stats-section {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    margin-top: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    display: none;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: linear-gradient(135deg, var(--light), white);
    padding: 1.5rem;
    border-radius: 16px;
    text-align: center;
    border: 1px solid var(--border);
    transition: all 0.3s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.stat-label {
    color: var(--gray);
    font-size: 0.9rem;
}

/* 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;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 2px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border-radius: 20px 20px 0 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
}

.modal-body {
    padding: 2rem;
}

.email-info {
    background: var(--light);
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
}

.email-info p {
    margin: 0.5rem 0;
}

.email-content-full {
    background: var(--light);
    padding: 1.5rem;
    border-radius: 12px;
    font-family: 'Courier New', monospace;
    white-space: pre-wrap;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

/* Code Box */
.code-box {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    padding: 1.5rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 2px dashed var(--warning);
    flex-wrap: wrap;
    gap: 1rem;
}

.code-value {
    font-family: 'Courier New', monospace;
    font-size: 2rem;
    font-weight: bold;
    color: var(--warning);
    letter-spacing: 2px;
}

.copy-btn {
    padding: 0.75rem 1.5rem;
    background: white;
    border: none;
    border-radius: 10px;
    color: var(--warning);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s;
    font-weight: 500;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.copy-btn:hover {
    background: var(--warning);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}

/* Guide */
.guide-steps {
    padding-left: 1.25rem;
    color: var(--dark);
    line-height: 1.7;
}

.guide-steps li {
    margin-bottom: 0.6rem;
}

.guide-steps code {
    background: var(--light);
    padding: 0.15rem 0.4rem;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 0.88rem;
    color: var(--primary-dark);
}

.guide-steps a {
    color: var(--primary);
}

.faq-item {
    padding: 1rem 1.25rem;
    background: var(--light);
    border-left: 4px solid var(--warning);
    border-radius: 10px;
    margin-bottom: 1rem;
}

.faq-item:last-child {
    margin-bottom: 0;
}

.faq-item h4 {
    color: var(--dark);
    font-size: 0.95rem;
    margin-bottom: 0.4rem;
}

.faq-item p {
    color: var(--gray);
    font-size: 0.9rem;
    line-height: 1.5;
}

.code-block {
    background: var(--dark);
    color: #e2e8f0;
    padding: 1rem 1.25rem;
    border-radius: 12px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre;
    margin: 0.5rem 0 1rem;
}

/* No Results */
.no-results {
    text-align: center;
    padding: 3rem;
    color: var(--gray);
}

.no-results i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: white;
    padding: 1rem 2rem;
    border-radius: 50px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 1rem;
    transform: translateX(400px);
    transition: transform 0.3s;
    z-index: 1000;
    border-left: 4px solid var(--success);
}

.toast.show {
    transform: translateX(0);
}

.toast i {
    font-size: 1.2rem;
    color: var(--success);
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .main-content {
        padding: 1rem;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        margin-bottom: 1rem;
    }

    .header h2 {
        font-size: 1.35rem;
    }

    .sidebar {
        width: 100%;
        padding: 1rem;
    }

    .logo {
        margin-bottom: 1rem;
    }

    .nav-menu {
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: 0.25rem;
    }

    .nav-item {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .card-body,
    .results-section,
    .stats-section {
        padding: 1rem;
    }

    .filters-row {
        flex-direction: column;
    }

    .action-buttons {
        flex-direction: column;
    }

    .toast {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
        padding: 0.9rem 1rem;
        border-radius: 18px;
        transform: translateY(140px);
    }

    .toast.show {
        transform: translateY(0);
    }

    .table-header {
        display: none;
    }
    
    .table-row {
        flex-direction: column;
        padding: 1rem;
    }
    
    .table-cell {
        padding: 0.5rem 0;
    }
    
    .code-badge {
        width: fit-content;
    }
    
    .code-box {
        flex-direction: column;
        text-align: center;
    }
    
    .code-value {
        font-size: 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .modal-content {
        width: 95%;
        margin: 1rem;
    }
}