/* Metrics Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    backdrop-filter: blur(15px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 22px;
    display: flex;
    align-items: center;
    gap: 18px;
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--border-highlight), transparent);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-icon.blue { background: var(--primary-light); color: #818cf8; }
.stat-icon.cyan { background: var(--accent-light); color: var(--accent); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.amber { background: var(--warning-light); color: var(--warning); }

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.7rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    font-family: var(--font-mono);
}

.stat-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Server Cards Grid */
.servers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 22px;
}

.server-card {
    background: var(--bg-card);
    backdrop-filter: blur(15px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
    transition: var(--transition);
}

.server-card:hover {
    border-color: var(--border-highlight);
    transform: translateY(-2px);
    box-shadow: 0 12px 30px -10px rgba(0,0,0,0.6);
}

.server-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.server-provider-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1rem;
}

.server-provider-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.06);
}

.server-meta-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.84rem;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.2);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.server-meta-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.server-meta-item span:first-child {
    color: var(--text-dim);
}

.server-meta-item span:last-child {
    font-family: var(--font-mono);
    color: var(--text-main);
    word-break: break-all;
}

.server-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border-subtle);
}

/* Mailbox Explorer Split View */
.explorer-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
    height: calc(100vh - 170px);
    min-height: 600px;
}

.folder-panel {
    background: var(--bg-card);
    backdrop-filter: blur(15px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
}

.folder-tree {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.folder-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}

.folder-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-main);
}

.folder-item.active {
    background: var(--primary-light);
    color: #ffffff;
    border-color: var(--border-highlight);
    font-weight: 600;
}

.folder-label {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 0.88rem;
}

.folder-counts {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.76rem;
    font-family: var(--font-mono);
}

.unread-pill {
    background: var(--primary);
    color: #ffffff;
    padding: 2px 7px;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 700;
}

.messages-panel {
    background: var(--bg-card);
    backdrop-filter: blur(15px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.messages-toolbar {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.messages-table-wrap {
    flex: 1;
    overflow-y: auto;
}

.messages-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.messages-table th {
    background: rgba(0, 0, 0, 0.3);
    padding: 12px 18px;
    text-align: left;
    color: var(--text-dim);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid var(--border-subtle);
}

.messages-table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}

.message-row {
    cursor: pointer;
    transition: var(--transition);
}

.message-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.message-row.unread {
    font-weight: 700;
    color: #ffffff;
}

.message-row.unread td:first-child {
    border-left: 3px solid var(--accent);
}

.message-sender {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-subject {
    max-width: 360px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-date {
    font-family: var(--font-mono);
    color: var(--text-dim);
    font-size: 0.8rem;
    white-space: nowrap;
}

.messages-pagination {
    padding: 12px 20px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.84rem;
    color: var(--text-muted);
}

/* Transfer Wizard & Studio */
.wizard-steps {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
    position: relative;
}

.wizard-steps::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 40px;
    right: 40px;
    height: 2px;
    background: var(--border-subtle);
    z-index: 1;
}

.wizard-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
    z-index: 2;
}

.wizard-step-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-surface);
    border: 2px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-dim);
    transition: var(--transition);
}

.wizard-step.active .wizard-step-circle {
    background: var(--primary);
    border-color: #818cf8;
    color: #ffffff;
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.5);
}

.wizard-step.done .wizard-step-circle {
    background: var(--success);
    border-color: #34d399;
    color: #ffffff;
}

.wizard-step-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-dim);
}

.wizard-step.active .wizard-step-title {
    color: var(--text-main);
}

/* Account Pipeline Cards */
.pipeline-container {
    display: grid;
    grid-template-columns: 1fr 60px 1fr;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
}

.pipeline-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid var(--border-highlight);
    margin: 0 auto;
}

.pipeline-card {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px;
}

/* Folder Mapping Table */
.mapping-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 14px;
}

.mapping-table th {
    padding: 10px 14px;
    text-align: left;
    color: var(--text-dim);
    font-size: 0.78rem;
    border-bottom: 1px solid var(--border-subtle);
}

.mapping-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.88rem;
}

/* Live Migration Runner */
.runner-card {
    background: var(--bg-card);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-xl);
    padding: 32px;
    box-shadow: 0 0 40px -10px rgba(99, 102, 241, 0.2);
}

.progress-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.progress-bar-container {
    height: 12px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 24px;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 99px;
    transition: width 0.3s ease;
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.6);
}

.terminal-window {
    background: #060910;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    padding: 16px;
    height: 280px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.terminal-line {
    display: flex;
    gap: 12px;
}

.terminal-time {
    color: var(--text-dim);
    user-select: none;
}

.terminal-tag {
    font-weight: 700;
}

.terminal-tag.info { color: var(--accent); }
.terminal-tag.success { color: var(--success); }
.terminal-tag.warning { color: var(--warning); }
.terminal-tag.error { color: var(--danger); }

.terminal-msg {
    color: var(--text-main);
    word-break: break-all;
}

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: #0f172a;
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 680px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-glow);
    transform: scale(0.95);
    transition: transform 0.2s ease;
    overflow: hidden;
}

.modal-backdrop.open .modal-card {
    transform: scale(1);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

/* Toast System */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 2000;
}

.toast {
    background: #1e293b;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    color: #ffffff;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    min-width: 280px;
    max-width: 420px;
    animation: toastSlide 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.success { border-color: rgba(16, 185, 129, 0.4); background: #064e3b; }
.toast.error { border-color: rgba(239, 68, 68, 0.4); background: #7f1d1d; }
.toast.info { border-color: rgba(6, 182, 212, 0.4); background: #0e7490; }

@keyframes toastSlide {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
