/* CZDS Pipeline Monitor — Dashboard Styles V3 */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0f172a;
    color: #e2e8f0;
    min-height: 100vh;
}

/* Header */
.header {
    background: #1e293b;
    border-bottom: 1px solid #334155;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.logo-icon {
    width: 38px;
    height: 34px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: white;
}
.header h1 {
    font-size: 14px;
    font-weight: 600;
    color: #f1f5f9;
}
.header-right {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 13px;
}
.user-badge {
    background: #334155;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    color: #94a3b8;
}
.nav-link {
    color: #94a3b8;
    text-decoration: none;
    font-size: 13px;
    padding: 4px 10px;
    border-radius: 6px;
    transition: all 0.2s;
}
.nav-link:hover { color: #e2e8f0; background: #334155; }
.nav-link.active { color: #f1f5f9; background: #334155; }
.btn-logout {
    color: #94a3b8;
    text-decoration: none;
    font-size: 13px;
}
.btn-logout:hover { color: #f87171; }

/* Main */
.main {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px;
}

/* ===== Zone Bar (V3) ===== */
.zone-bar {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 14px 20px;
    margin-bottom: 16px;
}
.zone-bar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.zone-bar-title {
    font-size: 13px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.zone-items {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.zone-divider {
    height: 1px;
    background: #334155;
    margin: 4px 0;
}
.zone-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 8px;
    border-radius: 8px;
    transition: background 0.2s;
}
.zone-item:hover { background: #1a2744; }
.zone-item.disabled { opacity: 0.5; }
.zone-item.disabled .zone-item-name { color: #64748b; }
.zone-item-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 100px;
}
.zone-item-name {
    font-size: 14px;
    font-weight: 600;
    color: #e2e8f0;
    font-family: 'SF Mono', 'Fira Code', monospace;
}
.zone-item-progress {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}
.zone-progress-bar {
    flex: 1;
    height: 6px;
    background: #0f172a;
    border-radius: 3px;
    overflow: hidden;
    max-width: 200px;
}
.zone-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    border-radius: 3px;
    transition: width 0.5s ease;
}
.zone-progress-text {
    font-size: 12px;
    font-weight: 600;
    color: #94a3b8;
    min-width: 35px;
}
.zone-stage-label {
    font-size: 11px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.zone-item-status {
    min-width: 80px;
    text-align: right;
}
.zone-status-text {
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
}
.zone-status-text.off { color: #475569; }
.zone-status-text.idle { color: #64748b; }
.zone-status-text.running { color: #4ade80; }
.zone-status-text.paused { color: #fbbf24; background: #422006; }
.zone-status-text.completed { color: #3b82f6; }
.zone-status-text.failed { color: #f87171; }
.zone-status-text.superseded { color: #94a3b8; }
.zone-item-actions {
    min-width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.zone-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: #334155;
    color: #e2e8f0;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.zone-action-btn:hover { background: #475569; }
.zone-action-btn.pause { color: #fbbf24; }
.zone-action-btn.resume { color: #4ade80; }

/* Zone toggle (mini slider) */
.zone-toggle-wrap {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 18px;
    cursor: pointer;
}
.zone-toggle-input { display: none; }
.zone-toggle-slider {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #475569;
    border-radius: 9px;
    transition: background 0.3s;
}
.zone-toggle-slider::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    background: #94a3b8;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: all 0.3s;
}
.zone-toggle-input:checked + .zone-toggle-slider { background: #22c55e; }
.zone-toggle-input:checked + .zone-toggle-slider::after { left: 16px; background: white; }
.zone-empty {
    font-size: 13px;
    color: #64748b;
}

/* Per-zone download-only toggle */
.zone-dl-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 8px;
}
.zone-dl-switch.zone-toggle-wrap {
    width: 28px;
    height: 16px;
}
.zone-dl-slider.zone-toggle-slider::after {
    width: 12px;
    height: 12px;
}
.zone-dl-input:checked + .zone-dl-slider {
    background: #f59e0b;
}
.zone-dl-input:checked + .zone-dl-slider::after {
    left: 14px;
    background: white;
}
.zone-dl-label {
    font-size: 11px;
    color: #64748b;
    white-space: nowrap;
    transition: color 0.2s;
}
.zone-dl-input:checked ~ .zone-dl-label,
.zone-dl-wrap:has(.zone-dl-input:checked) .zone-dl-label {
    color: #fbbf24;
}

/* Buttons */
.btn {
    padding: 8px 18px;
    border: none;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-primary { background: #3b82f6; color: white; }
.btn-primary:hover { background: #2563eb; }
.btn-danger { background: #dc2626; color: white; }
.btn-danger:hover { background: #b91c1c; }

/* Status Dot */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}
.status-dot.idle { background: #64748b; }
.status-dot.running { background: #22c55e; animation: pulse 1.5s infinite; }
.status-dot.failed { background: #ef4444; }
.status-dot.completed { background: #3b82f6; }

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

/* ===== Server Monitor ===== */
.monitor-section {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 18px 20px;
    margin-bottom: 16px;
}
.monitor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.monitor-title {
    font-size: 13px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.monitor-meta {
    font-size: 12px;
    color: #64748b;
}
.monitor-gauges {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 14px;
}
.gauge-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.gauge-label {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.gauge-ring-wrap {
    position: relative;
    width: 80px;
    height: 80px;
}
.gauge-ring {
    width: 80px;
    height: 80px;
    transform: rotate(-90deg);
}
.gauge-bg {
    fill: none;
    stroke: #1e293b;
    stroke-width: 6;
}
.gauge-fill {
    fill: none;
    stroke-width: 6;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.8s ease;
}
.gauge-fill-cpu { stroke: #3b82f6; }
.gauge-fill-ram { stroke: #8b5cf6; }
.gauge-fill-disk { stroke: #06b6d4; }
.gauge-fill-load { stroke: #f59e0b; }

.gauge-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 16px;
    font-weight: 700;
    color: #f1f5f9;
}
.gauge-sub {
    font-size: 11px;
    color: #64748b;
}

/* Network stats bar */
.monitor-net {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-top: 12px;
    border-top: 1px solid #334155;
    font-size: 12px;
    color: #94a3b8;
}
.net-item {
    display: flex;
    align-items: center;
    gap: 4px;
}
.net-arrow {
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
}
.net-arrow.down { border-top: 6px solid #4ade80; }
.net-arrow.up { border-bottom: 6px solid #f87171; }
.net-divider {
    width: 1px;
    height: 14px;
    background: #334155;
}
.net-total {
    color: #64748b;
    font-size: 11px;
}

/* ===== Stage Cards ===== */
.stages {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.stage-card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 18px 20px;
    transition: border-color 0.3s;
}
.stage-card.active {
    border-color: #3b82f6;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.1);
}
.stage-card.paused {
    border-color: #f59e0b;
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.08);
}
.stage-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.stage-title {
    display: flex;
    align-items: center;
    gap: 10px;
}
.stage-number {
    width: 26px;
    height: 26px;
    background: #334155;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: #94a3b8;
}
.stage-name {
    font-size: 15px;
    font-weight: 600;
}
.stage-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Stage pause button */
.stage-pause-btn {
    width: 28px;
    height: 28px;
    border: 1px solid #334155;
    border-radius: 6px;
    background: transparent;
    color: #94a3b8;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.stage-pause-btn:hover { background: #334155; color: #e2e8f0; }
.stage-pause-btn.paused { border-color: #f59e0b; color: #fbbf24; background: #422006; }
.stage-pause-btn.paused:hover { background: #713f12; }

/* Paused banner */
.stage-paused-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 12px;
    background: #422006;
    border: 1px solid #92400e;
    border-radius: 8px;
    font-size: 13px;
    color: #fbbf24;
}
.paused-icon { font-size: 15px; }
.paused-text { flex: 1; }

/* Badges */
.badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-pending { background: #334155; color: #94a3b8; }
.badge-running { background: #14532d; color: #4ade80; }
.badge-success { background: #052e16; color: #22c55e; }
.badge-danger { background: #450a0a; color: #f87171; }
.badge-paused { background: #422006; color: #fbbf24; }

/* Progress Bar */
.progress-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.progress-bar {
    flex: 1;
    height: 8px;
    background: #0f172a;
    border-radius: 4px;
    overflow: hidden;
}
.progress-bar.small { height: 5px; }
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    border-radius: 4px;
    transition: width 0.5s ease;
    min-width: 0;
}
.progress-text {
    font-size: 13px;
    font-weight: 600;
    color: #94a3b8;
    min-width: 40px;
    text-align: right;
}

/* Stage Stats */
.stage-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}
.stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.stat-label {
    font-size: 11px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.stat-value {
    font-size: 16px;
    font-weight: 700;
    color: #e2e8f0;
}
.stat-pass { color: #4ade80; }
.stat-filter { color: #f87171; }

/* ===== Zone Diff Rows ===== */
.zone-diff-rows {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #334155;
}
.zone-diff-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
    font-size: 13px;
}
.zone-diff-name {
    font-weight: 600;
    color: #e2e8f0;
    min-width: 50px;
    font-family: 'SF Mono', 'Fira Code', monospace;
}
.zone-diff-bar {
    flex: 1;
}
.zone-diff-stats {
    font-size: 12px;
    color: #94a3b8;
    min-width: 200px;
    text-align: right;
}
.zone-diff-status {
    font-size: 11px;
    color: #64748b;
    min-width: 80px;
    text-align: right;
}

/* ===== Filter Details ===== */
.filter-details {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #334155;
}
.filter-detail-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 3px 0;
    font-size: 13px;
}
.filter-detail-label { color: #94a3b8; }
.filter-detail-value {
    font-weight: 600;
    color: #f87171;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

/* ===== Workers ===== */
.workers-container {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #334155;
}
.workers-title {
    font-size: 12px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}
.workers-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 20px;
}
.worker-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 3px 0;
}
.worker-row.stalled .worker-name { color: #f87171; }
.worker-row.stalled .progress-fill { background: linear-gradient(90deg, #ef4444, #dc2626); }
.worker-row.done .worker-name { color: #4ade80; }
.worker-row.done .progress-fill { background: linear-gradient(90deg, #22c55e, #16a34a); }
.worker-name {
    font-size: 12px;
    color: #94a3b8;
    min-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.worker-progress { flex: 1; }
.worker-stats {
    font-size: 12px;
    color: #64748b;
    min-width: 80px;
    text-align: right;
    white-space: nowrap;
}
.worker-badge-stalled {
    font-size: 10px;
    font-weight: 600;
    color: #f87171;
    background: #450a0a;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 4px;
}

/* ===== Zone Bar Controls ===== */
.zone-bar-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-left: auto;
}
.zone-retention-setting {
    display: flex;
    align-items: center;
    gap: 6px;
}
.retention-label {
    font-size: 12px;
    color: #64748b;
    white-space: nowrap;
}
.retention-input {
    width: 52px;
    background: #0f172a;
    border: 1px solid #334155;
    color: #e2e8f0;
    padding: 3px 6px;
    border-radius: 5px;
    font-size: 12px;
    text-align: center;
    outline: none;
}
.retention-input:focus { border-color: #3b82f6; }

/* ===== CZDS Settings Row ===== */
.czds-settings-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}
.czds-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 140px;
}
.czds-field-label {
    font-size: 11px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.czds-field-input {
    background: #0f172a;
    border: 1px solid #334155;
    color: #e2e8f0;
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    width: 100%;
}
.czds-field-input:focus { border-color: #3b82f6; }
.czds-save-btn {
    padding: 7px 18px;
    white-space: nowrap;
    align-self: flex-end;
}
.czds-field-sm { min-width: 80px; flex: 0 1 auto; }
.czds-field-sm .czds-field-input { width: 80px; text-align: center; }
.czds-settings-divider {
    height: 1px;
    background: #334155;
    margin: 14px 0;
}

/* ===== History Table (gd-table) ===== */
.gd-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.gd-table thead { position: sticky; top: 0; z-index: 5; background: #0f172a; }
.gd-table th {
    padding: 8px 10px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #334155;
    white-space: nowrap;
}
.gd-table td {
    padding: 7px 10px;
    border-bottom: 1px solid #1e293b;
    color: #cbd5e1;
    white-space: nowrap;
}
.gd-table tbody tr:hover { background: #1a2744; }
.empty-state { text-align: center; color: #475569; padding: 24px !important; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .monitor-gauges { grid-template-columns: repeat(2, 1fr); }
    .workers-grid { grid-template-columns: 1fr; }
    .stage-stats { grid-template-columns: repeat(2, 1fr); }
    .header { flex-direction: column; gap: 10px; }
    .header-right { flex-wrap: wrap; justify-content: center; }
    .zone-item { flex-wrap: wrap; }
}
