/* Pod Monitor — Tokyo Night dark + pastel */
:root {
    --bg-page:       #1a1b26;
    --bg-card:       #24283b;
    --bg-header:     #1f2335;
    --bg-row-alt:    #1f2231;
    --bg-row-hover:  #2a2e44;
    --bg-deep:       #16161e;
    --border:        #414868;
    --border-light:  #2a2e44;

    --text:          #c0caf5;
    --text-muted:    #9aa5ce;
    --text-dim:      #6b7394;

    --pastel-cyan:   #7dcfff;
    --pastel-mint:   #9ece6a;
    --pastel-peach:  #e0af68;
    --pastel-red:    #f7768e;
    --pastel-lilac:  #bb9af7;
    --pastel-blue:   #a9b1d6;

    --shadow:        0 4px 24px rgba(0,0,0,0.45);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
    background: var(--bg-page);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.45;
}
.muted { color: var(--text-muted); font-weight: normal; }
.dim   { color: var(--text-dim); }
.num   { text-align: right; font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.hidden { display: none !important; }
.mono   { font-family: 'JetBrains Mono', Menlo, Consolas, monospace; }

/* ---------- topbar ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--pastel-cyan);
    display: flex;
    align-items: center;
    gap: 10px;
}
.topbar h1 .version {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: normal;
}
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
}
.title-email-icon {
    width: 22px;
    height: 22px;
    cursor: pointer;
    display: inline-block;
    transition: transform 0.15s;
}
.title-email-icon:hover { transform: scale(1.15); }
.title-email-icon.status-critical { animation: emailPulse 1.2s ease-in-out infinite; }
@keyframes emailPulse {
    0%,100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.12); }
}
.last-update {
    color: var(--text-muted);
    font-size: 12.5px;
}
.autorefresh {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 12.5px;
}
.autorefresh-select,
.limit-select {
    background: var(--bg-header);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12.5px;
    font-family: inherit;
}
.autorefresh-select:focus,
.limit-select:focus {
    outline: none;
    border-color: var(--pastel-cyan);
}

/* ---------- main + layout ---------- */
main {
    padding: 16px 20px 30px;
    max-width: 1900px;
    margin: 0 auto;
}
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 14px;
    box-shadow: var(--shadow);
}
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    gap: 12px;
    flex-wrap: wrap;
}
.section-header h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

/* ---------- buttons ---------- */
.btn {
    background: var(--bg-header);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: all 0.12s;
    user-select: none;
}
.btn:hover { background: var(--bg-row-hover); border-color: var(--text-dim); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary {
    background: var(--pastel-cyan);
    color: var(--bg-page);
    border-color: var(--pastel-cyan);
    font-weight: 600;
}
.btn.primary:hover { background: var(--pastel-lilac); border-color: var(--pastel-lilac); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--pastel-red); border-color: var(--pastel-red); }
.btn.danger:hover { background: var(--pastel-red); color: var(--bg-page); }
.btn.warn {
    background: var(--pastel-peach);
    color: var(--bg-page);
    border-color: var(--pastel-peach);
    font-weight: 600;
}
.btn.warn:hover { background: var(--pastel-red); border-color: var(--pastel-red); color: var(--bg-page); }
.btn.mint {
    background: var(--pastel-mint);
    color: var(--bg-page);
    border-color: var(--pastel-mint);
    font-weight: 600;
}
.btn.block { display: block; width: 100%; }

/* ---------- node grid (cards) ---------- */
.node-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
}
.node-card {
    background: var(--bg-header);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.node-card.stress-running {
    border-color: var(--pastel-peach);
    box-shadow: 0 0 12px rgba(224,175,104,0.25);
}
.node-card .node-name {
    color: var(--pastel-cyan);
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.node-card .ip-info {
    font-size: 12.5px;
    color: var(--text-muted);
}
.node-card .ip-info .v {
    color: var(--text);
    font-family: 'JetBrains Mono', Menlo, Consolas, monospace;
}
.node-card .ip-info .v.mint { color: var(--pastel-mint); }
.node-card .ip-info .v.peach { color: var(--pastel-peach); }
.node-card .ip-info .v.red { color: var(--pastel-red); }
.node-card .stress-status {
    color: var(--pastel-peach);
    font-size: 11.5px;
    margin-top: 4px;
    text-align: center;
    min-height: 1em;
}
.node-card button.stress-button {
    margin-top: 8px;
    width: 100%;
}

/* ---------- stress progress bar ---------- */
.stress-progress {
    margin-top: 8px;
}
.stress-progress-bar {
    background: var(--bg-deep);
    border: 1px solid var(--pastel-peach);
    border-radius: 10px;
    height: 22px;
    overflow: hidden;
    position: relative;
}
.stress-progress-fill {
    background: linear-gradient(90deg, var(--pastel-cyan), var(--pastel-peach));
    height: 100%;
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bg-page);
    font-weight: 700;
    font-size: 11.5px;
}
.stress-progress-info {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 4px;
}

/* ---------- connectivity matrix (table) ---------- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}
.data-table thead th {
    background: var(--bg-header);
    color: var(--text-muted);
    text-transform: capitalize;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.4px;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1;
    text-align: center;
}
.data-table tbody th {
    color: var(--pastel-cyan);
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    text-align: left;
    text-transform: lowercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-light);
}
/* Cluster-leader jelzés a sor-fejlécben — kis zöld világító pötty */
.leader-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #9ece6a;
    margin-left: 6px;
    vertical-align: middle;
    box-shadow: 0 0 6px rgba(158, 206, 106, 0.7);
    cursor: help;
    animation: leader-pulse 2.4s ease-in-out infinite;
}
@keyframes leader-pulse {
    0%, 100% { box-shadow: 0 0 4px rgba(158, 206, 106, 0.55); opacity: 1; }
    50%      { box-shadow: 0 0 10px rgba(158, 206, 106, 0.95); opacity: 0.85; }
}
.data-table tbody td {
    padding: 4px 6px;
    border-bottom: 1px solid var(--border-light);
    text-align: center;
}
.data-table tbody tr:nth-child(even) th,
.data-table tbody tr:nth-child(even) td { background: var(--bg-row-alt); }
.data-table tbody tr:hover th,
.data-table tbody tr:hover td { background: var(--bg-row-hover); }

.status-cell {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.status-ok      { color: var(--pastel-mint); }
.status-fail    { color: var(--pastel-red); }
.status-pending { color: var(--pastel-peach); }

.table-scroll {
    overflow-x: auto;
    border: 1px solid var(--border-light);
    border-radius: 6px;
}
.table-scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.table-scroll::-webkit-scrollbar-track { background: var(--bg-deep); }
.table-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; border: 2px solid var(--bg-deep); }
.table-scroll::-webkit-scrollbar-thumb:hover { background: var(--pastel-blue); }

/* ---------- modal ---------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(10,10,20,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    backdrop-filter: blur(2px);
}
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}
.modal.small { max-width: 420px; }
.modal-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h3 { margin: 0; font-size: 15px; color: var(--pastel-cyan); }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-footer {
    padding: 12px 18px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field > label > span.label-name { color: var(--text-muted); font-size: 12.5px; margin-right: 8px; }
.field > label > span.label-value { color: var(--pastel-cyan); font-weight: 600; font-variant-numeric: tabular-nums; }
.field input[type="range"] {
    width: 100%;
    accent-color: var(--pastel-cyan);
}
.field select {
    background: var(--bg-deep);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    font-family: inherit;
    font-size: 14px;
}
.field select:focus { outline: none; border-color: var(--pastel-cyan); }

/* Email modal-stat grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin: 14px 0;
}
.stat-item {
    background: var(--bg-deep);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 10px;
    text-align: center;
    transition: transform 0.15s, border-color 0.15s;
}
.stat-item.clickable { cursor: pointer; }
.stat-item.clickable:hover {
    border-color: var(--pastel-cyan);
    transform: translateY(-1px);
}
.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--pastel-cyan);
    font-variant-numeric: tabular-nums;
}
.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}
.error-section, .warning-section {
    background: var(--bg-deep);
    border-left: 3px solid var(--pastel-red);
    border-radius: 4px;
    padding: 10px 14px;
    margin: 10px 0;
}
.warning-section { border-left-color: var(--pastel-peach); }
.error-section h4, .warning-section h4 {
    margin: 0 0 6px;
    color: var(--pastel-red);
    font-size: 13px;
}
.warning-section h4 { color: var(--pastel-peach); }
.error-section h4.config { color: var(--pastel-cyan); }
.error-list {
    margin: 0;
    padding-left: 0;
    list-style: none;
    font-size: 12.5px;
    color: var(--text);
}
.error-list li { padding: 2px 0; }

/* ---------- debug log panel ---------- */
.debug-log {
    position: fixed;
    top: 70px;
    right: 16px;
    width: 360px;
    max-height: 280px;
    overflow-y: auto;
    z-index: 60;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    font-family: 'JetBrains Mono', Menlo, Consolas, monospace;
    font-size: 11px;
    color: var(--text-muted);
    box-shadow: var(--shadow);
}
.debug-log .debug-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: -apple-system, sans-serif;
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-light);
}
.debug-log .debug-line {
    line-height: 1.45;
    color: var(--text-muted);
    word-break: break-all;
}
.debug-log .debug-line .ts { color: var(--text-dim); margin-right: 6px; }
.debug-log::-webkit-scrollbar { width: 6px; }
.debug-log::-webkit-scrollbar-track { background: var(--bg-deep); }
.debug-log::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ---------- loading state ---------- */
.loading {
    color: var(--text-muted);
    padding: 20px;
    text-align: center;
    font-style: italic;
}

@media (max-width: 900px) {
    .node-grid { grid-template-columns: 1fr; }
    .debug-log { width: calc(100vw - 32px); right: 16px; }
}
