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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}

.login-box h1 {
    font-size: 24px;
    margin-bottom: 8px;
    color: #2563eb;
}

.subtitle {
    color: #6b7280;
    margin-bottom: 30px;
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #374151;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
}

.form-group input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.error-message {
    color: #dc2626;
    font-size: 14px;
    margin-bottom: 15px;
    min-height: 20px;
}

.footer-text {
    text-align: center;
    margin-top: 20px;
    font-size: 12px;
    color: #9ca3af;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-success, .btn-danger, .btn-warning {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: #2563eb;
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-success {
    background: #16a34a;
    color: white;
}

.btn-success:hover {
    background: #15803d;
}

.btn-danger {
    background: #dc2626;
    color: white;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-warning {
    background: #ea580c;
    color: white;
}

.btn-warning:hover {
    background: #c2410c;
}

.btn-small {
    padding: 8px 16px;
    font-size: 12px;
}

/* Dashboard */
.dashboard {
    min-height: 100vh;
}

header {
    background: white;
    padding: 20px 40px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 24px;
    color: #2563eb;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

#username-display {
    color: #6b7280;
    font-size: 14px;
}

main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 30px;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.card {
    background: white;
    padding: 24px;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.card h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: #374151;
}

.stat-large {
    font-size: 48px;
    font-weight: bold;
    color: #2563eb;
}

.loading {
    color: #6b7280;
    font-style: italic;
}

.control-panel {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.pm2-status {
    background: #f9fafb;
    padding: 15px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: #374151;
}

.logs-container {
    position: relative;
}

#logs {
    background: #1f2937;
    color: #f9fafb;
    padding: 15px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    max-height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

#refreshLogsBtn {
    margin-bottom: 10px;
}

.info-list {
    list-style: none;
}

.info-list li {
    padding: 8px 0;
    border-bottom: 1px solid #e5e7eb;
}

.info-list li:last-child {
    border-bottom: none;
}

.status-running {
    color: #16a34a;
    font-weight: bold;
}

.status-stopped {
    color: #dc2626;
    font-weight: bold;
}

.status-complete {
    color: #2563eb;
    font-weight: bold;
}

.history-table {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th {
    background: #f9fafb;
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #e5e7eb;
}

table td {
    padding: 12px;
    border-bottom: 1px solid #e5e7eb;
}

.table-controls {
    margin-bottom: 15px;
}

.emails-info {
    margin-bottom: 10px;
    padding: 10px;
    background: #f9fafb;
    border-radius: 4px;
}

.emails-info p {
    margin: 0;
    color: #6b7280;
    font-size: 14px;
}

/* Campaign Stages */
.stages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.stage-item {
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 15px;
    background: #f9fafb;
    transition: all 0.2s;
}

.stage-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.stage-completed {
    border-color: #16a34a;
    background: #dcfce7;
}

.stage-in-progress {
    border-color: #2563eb;
    background: #dbeafe;
    animation: pulse 2s ease-in-out infinite;
}

.stage-pending {
    border-color: #9ca3af;
    background: #f3f4f6;
    opacity: 0.7;
}

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

.stage-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.stage-icon {
    font-size: 20px;
    font-weight: bold;
}

.stage-completed .stage-icon {
    color: #16a34a;
}

.stage-in-progress .stage-icon {
    color: #2563eb;
}

.stage-pending .stage-icon {
    color: #9ca3af;
}

.stage-day {
    font-weight: bold;
    font-size: 16px;
    color: #374151;
}

.stage-body {
    font-size: 13px;
}

.stage-desc {
    color: #6b7280;
    margin-bottom: 8px;
    font-weight: 500;
}

.stage-info {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 12px;
    color: #6b7280;
}

.stage-results {
    font-size: 12px;
    color: #16a34a;
    font-weight: 500;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(0,0,0,0.1);
}

.stage-date {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 4px;
}

/* System Status Overview */
.system-overview {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.system-overview h3 {
    color: white;
    margin-bottom: 20px;
}

.system-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.status-section {
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 8px;
    backdrop-filter: blur(10px);
}

.status-section.full-width {
    grid-column: 1 / -1;
}

.status-section h4 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: rgba(255, 255, 255, 0.95);
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 8px;
}

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

.metric {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.metric-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 16px;
    font-weight: bold;
    color: white;
}

.text-success {
    color: #86efac !important;
}

.text-warning {
    color: #fbbf24 !important;
}

.text-danger {
    color: #fca5a5 !important;
}

.text-complete {
    color: #a5f3fc !important;
}

.text-muted {
    color: rgba(255, 255, 255, 0.5) !important;
}

/* Progress Bar */
.progress-bar-container {
    position: relative;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    height: 40px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #16a34a 0%, #22c55e 100%);
    transition: width 0.5s ease;
    border-radius: 10px;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    font-size: 14px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 15px;
    }

    .control-panel {
        flex-direction: column;
    }

    .control-panel button {
        width: 100%;
    }
}
