/* SynUnit Pipeline Dashboard — evefall.se inspired */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Open Sans', sans-serif; background: #f5f5f5; color: #333; font-size: 15px; line-height: 1.6; }
.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }

/* Header */
header { background: #fff; border-bottom: 1px solid #e0e0e0; padding: 28px 0 20px; }
.header-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
h1 { font-size: 28px; font-weight: 700; color: #000; letter-spacing: -0.5px; }
h1 .light { font-weight: 400; color: #606060; }
.subtitle { color: #999; font-size: 14px; margin-top: 2px; }
.badge { display: inline-block; padding: 4px 14px; border-radius: 20px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.badge-ok { background: #e8f5e9; color: #2e7d32; }
.badge-error { background: #fce4ec; color: #c62828; }

/* Main */
main { padding: 32px 0 64px; }

/* Pipeline flow */
.pipeline-flow {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
    background: #fff; border-radius: 10px; padding: 16px 20px; margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.pipe-stage {
    text-align: center; padding: 10px 14px; border-radius: 8px;
    background: #f0f4ff; border: 2px solid #c5cae9; min-width: 80px;
    transition: all 0.3s;
}
.pipe-stage .pipe-count { font-size: 24px; font-weight: 700; color: #1a237e; line-height: 1.1; }
.pipe-stage .pipe-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: #5c6bc0; margin-top: 2px; }
.pipe-done { background: #e8f5e9; border-color: #a5d6a7; }
.pipe-done .pipe-count { color: #2e7d32; }
.pipe-done .pipe-label { color: #4caf50; }
.pipe-fail { background: #fce4ec; border-color: #ef9a9a; }
.pipe-fail .pipe-count { color: #c62828; }
.pipe-fail .pipe-label { color: #e57373; }
.pipe-arrow { color: #bbb; font-size: 14px; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 24px; }
.card { background: #fff; border-radius: 10px; padding: 24px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); transition: box-shadow 0.2s; }
.card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.12); }
.card-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; color: #999; margin-bottom: 8px; }
.card-value { font-size: 36px; font-weight: 700; color: #000; line-height: 1.1; }
.card-sub { font-size: 13px; color: #999; margin-top: 4px; }
.disk-bar { height: 6px; background: #eee; border-radius: 3px; margin-top: 12px; overflow: hidden; }
.disk-bar-fill { height: 100%; background: #4caf50; border-radius: 3px; transition: width 0.5s ease; }
.disk-bar-fill.disk-warn { background: #ff9800; }
.disk-bar-fill.disk-critical { background: #f44336; }

/* Worker cards */
.workers-section { margin-bottom: 24px; }
.workers-section h2 { font-size: 16px; font-weight: 600; color: #000; margin-bottom: 12px; }
.workers-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.worker-card {
    background: #fff; border-radius: 10px; padding: 16px 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08); border-left: 4px solid #e0e0e0;
    transition: border-color 0.3s;
}
.worker-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.worker-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; transition: all 0.3s; }
.dot-active { background: #4caf50; box-shadow: 0 0 8px rgba(76,175,80,0.5); animation: pulse 1.5s infinite; }
.dot-idle { background: #90caf9; }
.dot-error { background: #f44336; box-shadow: 0 0 8px rgba(244,67,54,0.4); }
.dot-starting { background: #bdbdbd; }
.worker-name { font-weight: 600; font-size: 14px; color: #333; }
.worker-status { margin-left: auto; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: #999; font-weight: 600; }
.worker-detail { font-size: 12px; color: #666; font-family: 'Courier New', monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.worker-progress { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.worker-progress-bar { flex: 1; height: 6px; background: #e0e0e0; border-radius: 3px; overflow: hidden; }
.worker-progress-fill { height: 100%; background: linear-gradient(90deg, #4caf50, #2e7d32); border-radius: 3px; transition: width 0.5s ease; }
.worker-progress-text { font-size: 12px; font-weight: 700; color: #2e7d32; min-width: 32px; text-align: right; }
.worker-speed { font-size: 13px; font-weight: 600; color: #1b5e20; margin-top: 4px; }
.worker-meta { font-size: 11px; color: #888; font-family: 'Courier New', monospace; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@keyframes pulse { 0%,100% { opacity:1; transform:scale(1); } 50% { opacity:0.5; transform:scale(1.3); } }

/* Master section */
.master-section { background: #fff; border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); padding: 20px; margin-bottom: 24px; }
.master-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.master-header h2 { font-size: 16px; font-weight: 600; color: #000; }
.master-host { font-weight: 400; font-size: 13px; color: #999; margin-left: 8px; }
.master-summary { display: flex; gap: 32px; margin-bottom: 20px; }
.master-stat-value { font-size: 28px; font-weight: 700; color: #000; line-height: 1.1; }
.master-stat-label { font-size: 12px; color: #999; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }
.master-bar-wrap { margin-bottom: 16px; }
.master-bar-label { display: flex; justify-content: space-between; font-size: 12px; color: #666; margin-bottom: 6px; }
.master-bar { height: 10px; background: #eee; border-radius: 5px; overflow: hidden; }
.master-bar-fill { height: 100%; background: linear-gradient(90deg, #66bb6a, #2e7d32); border-radius: 5px; transition: width 0.8s ease; }
.master-days { display: flex; flex-direction: column; gap: 6px; }
.master-day { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.master-day-name { min-width: 70px; font-family: 'Courier New', monospace; color: #555; font-size: 12px; }
.master-day-bar-wrap { flex: 1; height: 8px; background: #f0f0f0; border-radius: 4px; overflow: hidden; display: flex; }
.master-day-bar-synced { height: 100%; background: #4caf50; transition: width 0.5s ease; }
.master-day-bar-remain { height: 100%; background: #42a5f5; transition: width 0.5s ease; }
.master-day-size { min-width: 80px; text-align: right; font-family: 'Courier New', monospace; font-size: 12px; color: #666; }
.size-synced { color: #2e7d32; font-weight: 600; }

/* Sync rate */
.sync-rate-panel { margin-top: 20px; padding: 16px 20px; border-radius: 8px; border: 1px solid #eee; transition: background 0.3s; }
.rate-good { background: #e8f5e9; border-color: #c8e6c9; }
.rate-bad { background: #fce4ec; border-color: #f8bbd0; }
.rate-neutral { background: #f5f5f5; border-color: #e0e0e0; }
.rate-indicator { display: flex; align-items: center; gap: 14px; }
.rate-arrow { font-size: 28px; line-height: 1; flex-shrink: 0; width: 36px; text-align: center; }
.rate-good .rate-arrow { color: #2e7d32; }
.rate-bad .rate-arrow { color: #c62828; }
.rate-neutral .rate-arrow { color: #757575; }
.rate-info { flex: 1; min-width: 0; }
.rate-main { font-size: 14px; font-weight: 600; color: #333; }
.rate-detail { font-size: 11px; font-family: 'Courier New', monospace; color: #888; margin-top: 3px; }
.rate-eta { font-size: 20px; font-weight: 700; color: #2e7d32; white-space: nowrap; flex-shrink: 0; }
.rate-eta-warn { color: #c62828; font-size: 14px; }

/* Settings */
.settings-section { background: #fff; border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); margin-bottom: 24px; overflow: hidden; }
.settings-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; cursor: pointer; user-select: none; }
.settings-header:hover { background: #fafafa; }
.settings-header h2 { font-size: 16px; font-weight: 600; color: #000; }
.settings-toggle { font-size: 12px; color: #999; }
.settings-body { padding: 0 20px 20px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 16px; }
.setting-item label { display: block; font-size: 13px; font-weight: 600; color: #333; margin-bottom: 4px; }
.setting-desc { font-size: 11px; color: #999; margin-bottom: 6px; }
.setting-item input { width: 100%; padding: 8px 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; font-family: 'Courier New', monospace; background: #fafafa; transition: border-color 0.2s; }
.setting-item input:focus { outline: none; border-color: #1976d2; background: #fff; }
.settings-actions { display: flex; align-items: center; gap: 16px; }
.settings-status { font-size: 13px; color: #666; }
.settings-ok { color: #2e7d32; font-weight: 600; }
.settings-err { color: #c62828; font-weight: 600; }

/* Tailscale */
.tailscale-section { background: #fff; border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); padding: 20px; margin-bottom: 24px; }
.tailscale-section h2 { font-size: 16px; font-weight: 600; color: #000; margin-bottom: 16px; }
.ts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.ts-node { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 8px; background: #fafafa; border: 1px solid #eee; }
.ts-online { border-left: 3px solid #4caf50; }
.ts-offline { border-left: 3px solid #bdbdbd; opacity: 0.7; }
.ts-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.ts-dot-on { background: #4caf50; box-shadow: 0 0 6px rgba(76,175,80,0.4); }
.ts-dot-off { background: #bdbdbd; }
.ts-name { font-weight: 600; font-size: 14px; color: #333; }
.ts-ip { font-family: 'Courier New', monospace; font-size: 12px; color: #666; }
.ts-traffic { font-size: 11px; color: #999; margin-top: 2px; }
.ts-loading { color: #999; font-style: italic; padding: 8px; }

/* Log */
.log-section { background: #fff; border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); overflow: hidden; margin-bottom: 24px; }
.log-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid #eee; }
.log-header h2 { font-size: 16px; font-weight: 600; color: #000; }
.log-controls { display: flex; gap: 8px; }
.btn { background: #424242; color: #fff; border: none; padding: 8px 16px; border-radius: 6px; font-size: 13px; font-family: 'Open Sans', sans-serif; cursor: pointer; transition: background 0.2s; }
.btn:hover { background: #616161; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn.active { background: #1976d2; }
.log-viewer { height: 400px; overflow-y: auto; padding: 12px 20px; background: #fafafa; font-family: 'Courier New', monospace; font-size: 12px; line-height: 1.7; }
.log-line { white-space: pre-wrap; word-break: break-all; padding: 1px 0; }
.log-error { color: #c62828; font-weight: 600; }
.log-warn { color: #e65100; }
.log-info { color: #1565c0; }
.log-loading { color: #999; font-style: italic; }

/* Info row */
.info-row { display: flex; gap: 32px; flex-wrap: wrap; }
.info-item { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.info-label { color: #999; }
.info-value { color: #333; font-weight: 600; }

/* Footer */
footer { padding: 24px 0; text-align: center; color: #999; font-size: 13px; border-top: 1px solid #e0e0e0; }

/* Utility */
.hidden { display: none !important; }

/* Responsive */
@media (max-width: 768px) {
    .cards { grid-template-columns: repeat(2, 1fr); }
    .workers-grid { grid-template-columns: 1fr 1fr; }
    .pipeline-flow { gap: 4px; }
    .pipe-stage { min-width: 60px; padding: 8px 10px; }
    .pipe-stage .pipe-count { font-size: 18px; }
    h1 { font-size: 22px; }
    .card-value { font-size: 28px; }
    .log-viewer { height: 300px; }
}
@media (max-width: 480px) {
    .cards { grid-template-columns: 1fr; }
    .workers-grid { grid-template-columns: 1fr; }
    .pipeline-flow { flex-wrap: wrap; justify-content: center; }
    .pipe-arrow { display: none; }
}
