* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
    display: grid;
    grid-template-columns: 1fr 2fr;
    grid-template-rows: auto auto 1fr;
    gap: 0;
    height: calc(100vh - 40px);
}

header {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    padding: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
}

.stats {
    font-size: 1.2rem;
    display: flex;
    gap: 20px;
    align-items: center;
}

.badge {
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
}

.badge.unread {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.badge.read {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.controls {
    grid-column: 1;
    background: #f8fafc;
    padding: 20px;
    border-right: 1px solid #e2e8f0;
}

.filter {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#status-filter, #search-input {
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s;
}

#status-filter:focus, #search-input:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

#refresh-btn {
    padding: 12px 24px;
    background: #4f46e5;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

#refresh-btn:hover {
    background: #4338ca;
    transform: translateY(-2px);
}

.mail-list {
    grid-column: 1;
    grid-row: 3;
    overflow-y: auto;
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
}

.mail-item {
    padding: 20px;
    border-bottom: 1px solid #e2e8f0;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.mail-item:hover {
    background: #f1f5f9;
}

.mail-item.unread {
    background: #fef2f2;
    border-left: 4px solid #ef4444;
}

.mail-item.selected {
    background: #e0e7ff;
}

.mail-item .sender {
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mail-item .time {
    font-size: 0.9rem;
    color: #64748b;
    margin-bottom: 8px;
}

.mail-item .title {
    font-weight: 500;
    color: #334155;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.mail-item .preview {
    font-size: 0.9rem;
    color: #64748b;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.mail-item .status {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 12px;
}

.status.unread {
    background: #fee2e2;
    color: #dc2626;
}

.status.read {
    background: #dcfce7;
    color: #16a34a;
}

.status.archived {
    background: #f3f4f6;
    color: #6b7280;
}

.mail-detail {
    grid-column: 2;
    grid-row: 2 / 4;
    display: flex;
    flex-direction: column;
    background: white;
}

.detail-header {
    padding: 30px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.detail-header h2 {
    font-size: 1.8rem;
    color: #1e293b;
    margin: 0;
}

.detail-actions {
    display: flex;
    gap: 12px;
}

.btn-primary, .btn-secondary, .btn-danger {
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: #4f46e5;
    color: white;
}

.btn-primary:hover {
    background: #4338ca;
}

.btn-secondary {
    background: #f1f5f9;
    color: #475569;
}

.btn-secondary:hover {
    background: #e2e8f0;
}

.btn-danger {
    background: #fee2e2;
    color: #dc2626;
}

.btn-danger:hover {
    background: #fecaca;
}

.detail-content {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
}

.mail-info {
    background: #f8fafc;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 30px;
}

.mail-info p {
    margin-bottom: 12px;
    font-size: 1.1rem;
}

.mail-info strong {
    color: #475569;
    min-width: 80px;
    display: inline-block;
}

.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

.mail-body {
    line-height: 1.8;
    color: #334155;
    font-size: 1.1rem;
}

.mail-body pre {
    background: #f8fafc;
    padding: 20px;
    border-radius: 12px;
    overflow-x: auto;
    margin: 20px 0;
}

.mail-body code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #64748b;
    font-size: 1.2rem;
}

@media (max-width: 1024px) {
    .container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr 1fr;
    }
    
    .mail-list {
        grid-column: 1;
        grid-row: 3;
    }
    
    .mail-detail {
        grid-column: 1;
        grid-row: 4;
    }
}
