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

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

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: #161b22;
  border-bottom: 1px solid #21262d;
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 { font-size: 20px; color: #58a6ff; }

.header-right { display: flex; align-items: center; gap: 12px; }

#last-checked { font-size: 12px; color: #8b949e; }

.nav-link {
  color: #58a6ff;
  text-decoration: none;
  font-size: 13px;
  padding: 8px 14px;
  border: 1px solid #30363d;
  border-radius: 6px;
}
.nav-link:hover { background: #21262d; }

.server-actions { margin-top: 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.server-actions .svc-label {
  font-size: 11px;
  text-transform: uppercase;
  color: #8b949e;
  margin-right: 4px;
}
.run-btn { background: #8957e5; }
.run-btn:hover { background: #a371f7; }

button {
  background: #238636;
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
button:hover { background: #2ea043; }
button:disabled { background: #555; cursor: wait; }

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

.servers {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 20px;
}

.empty { grid-column: 1 / -1; text-align: center; color: #8b949e; padding: 40px; }

.server-card {
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 10px;
  padding: 18px;
}

.server-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.server-name { font-size: 16px; font-weight: 600; }
.server-host { font-size: 12px; color: #8b949e; margin-top: 2px; }

.pill {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
}
.pill.ok { background: #1f6f2b22; color: #3fb950; border: 1px solid #3fb95055; }
.pill.bad { background: #da363322; color: #f85149; border: 1px solid #f8514955; }

.health-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.health-item {
  background: #0d1117;
  border: 1px solid #21262d;
  border-radius: 8px;
  padding: 10px;
}

.health-item .label { font-size: 11px; color: #8b949e; text-transform: uppercase; }
.health-item .value {
  font-size: 13px;
  margin-top: 4px;
  color: #e6edf3;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.services h3 {
  font-size: 12px;
  text-transform: uppercase;
  color: #8b949e;
  margin-bottom: 8px;
}

.service-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: #0d1117;
  border: 1px solid #21262d;
  border-radius: 6px;
  margin-bottom: 6px;
}

.service-left { display: flex; align-items: center; gap: 10px; min-width: 0; }

.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot.ok { background: #3fb950; }
.dot.bad { background: #f85149; }
.dot.unknown { background: #8b949e; }

.service-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.service-status { font-size: 12px; color: #8b949e; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.log-btn {
  background: #1f6feb;
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 5px;
  white-space: nowrap;
}
.log-btn:hover { background: #388bfd; }

.card-error {
  margin-top: 10px;
  padding: 8px 10px;
  background: #da363322;
  border: 1px solid #f8514955;
  color: #f85149;
  border-radius: 6px;
  font-size: 12px;
  word-break: break-word;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.hidden { display: none; }

.modal-box {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 10px;
  width: min(1000px, 92vw);
  height: 75vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #21262d;
}
.modal-head h2 { font-size: 15px; }
.modal-head button { background: transparent; color: #8b949e; font-size: 16px; }
.modal-head button:hover { color: #fff; }

.log-source-picker {
  background: #0d1117;
  color: #e6edf3;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 13px;
  margin-left: auto;
}

.log-filters {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid #21262d;
  align-items: center;
}
.log-filters input {
  flex: 1;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #e6edf3;
  padding: 8px 10px;
  font-size: 13px;
}
.log-filters .secondary { background: #21262d; }
.log-filters .secondary:hover { background: #30363d; }
.log-filters .analyze-btn { background: #8957e5; margin-left: auto; }
.log-filters .analyze-btn:hover { background: #a371f7; }
.log-filters .analyze-btn:disabled { background: #555; cursor: wait; }

.log-analysis {
  background: #1c1333;
  border-bottom: 1px solid #30363d;
  max-height: 45%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.log-analysis.hidden { display: none; }
.log-analysis-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid #30363d;
}
.log-analysis-head h3 { font-size: 13px; color: #a371f7; }
.log-analysis-head button { background: transparent; color: #8b949e; font-size: 15px; }
.log-analysis-head button:hover { color: #fff; }
#log-analysis-content {
  flex: 1;
  overflow: auto;
  padding: 12px 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  color: #d0c7f0;
}

.log-count {
  font-size: 12px;
  color: #8b949e;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  min-width: 90px;
}

#log-content {
  flex: 1;
  overflow: auto;
  padding: 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  color: #c9d1d9;
}
