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

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --border: #2a2a2a;
  --text: #e8e8e8;
  --muted: #888;
  --green: #3fb950;
  --red: #f85149;
  --yellow: #d29922;
  --blue: #58a6ff;
  --btn-bg: #2a2a2a;
  --btn-hover: #333;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", monospace;
  font-size: 13px;
  min-height: 100vh;
  padding: 32px 24px;
}

header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 32px;
}

h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

#refresh-info {
  color: var(--muted);
  font-size: 11px;
}

#hosts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 24px;
}

.host-section {
  min-width: 0;
}

.host-section h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent, var(--muted));
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.port-link {
  color: var(--accent, var(--blue));
  text-decoration: none;
  font-family: inherit;
  font-size: 12px;
}
.port-link:hover { text-decoration: underline; }

.host-error {
  color: var(--red);
  font-size: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

thead tr {
  background: var(--surface);
}

th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface); }

td {
  padding: 12px 14px;
  vertical-align: middle;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
  flex-shrink: 0;
}

.dot-up    { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot-down  { background: var(--red);   box-shadow: 0 0 6px var(--red); }
.dot-check { background: var(--yellow); animation: pulse 1s infinite; }

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

.service-name {
  display: flex;
  align-items: center;
}

.svc-type {
  color: var(--muted);
  font-size: 11px;
  margin-left: 4px;
}

.status-text-up   { color: var(--green); }
.status-text-down { color: var(--red); }

.actions {
  display: flex;
  gap: 6px;
}

button {
  background: var(--btn-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 10px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.1s, opacity 0.1s;
}

button:hover:not(:disabled) { background: var(--btn-hover); }
button:disabled { opacity: 0.35; cursor: not-allowed; }

button.danger { color: var(--red); border-color: #3a1a1a; }
button.danger:hover:not(:disabled) { background: #2a1010; }

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 12px;
  max-width: 320px;
  animation: slide-in 0.2s ease;
}

.toast.ok  { border-left: 3px solid var(--green); }
.toast.err { border-left: 3px solid var(--red); }

@keyframes slide-in {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);   opacity: 1; }
}

/* ── admin panel ─────────────────────────── */
.backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 40;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.backdrop.visible { opacity: 1; pointer-events: all; }

.admin-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 400px;
  background: #111;
  border-left: 1px solid var(--border);
  z-index: 50;
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.22s ease;
}
.admin-panel.open { transform: translateX(0); }

.panel-header {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.panel-header h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--panel-accent, var(--muted));
  flex: 1; display: flex; align-items: center; gap: 7px;
}
.panel-close {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 20px; line-height: 1; padding: 2px 4px;
}
.panel-close:hover { color: var(--text); }

.panel-body { flex: 1; overflow-y: auto; padding: 20px; }

.svc-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }

.svc-list-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
}
.svc-list-info { flex: 1; min-width: 0; }
.svc-list-name { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.svc-list-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.svc-list-btns { display: flex; gap: 6px; flex-shrink: 0; }
.svc-list-btn {
  background: none; border: 1px solid var(--border); border-radius: 4px;
  color: var(--muted); cursor: pointer; padding: 4px 8px; font-size: 11px;
  font-family: inherit; transition: all 0.1s;
}
.svc-list-btn:hover { background: var(--btn-bg); color: var(--text); }
.svc-list-btn.del:hover { border-color: #3a1a1a; color: var(--red); }

.add-svc-btn {
  width: 100%; background: none; border: 1px dashed var(--border);
  border-radius: 6px; color: var(--muted); cursor: pointer;
  padding: 10px; font-family: inherit; font-size: 12px; text-align: center;
  transition: all 0.15s;
}
.add-svc-btn:hover {
  border-color: var(--panel-accent, var(--blue));
  color: var(--panel-accent, var(--blue));
}

.svc-form {
  margin-top: 16px; padding: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
.svc-form-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--muted); margin-bottom: 14px;
}
.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.form-row .opt { color: #555; font-size: 10px; }
.form-row input, .form-row select {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text); font-family: inherit; font-size: 12px;
  padding: 7px 10px; outline: none; transition: border-color 0.1s;
}
.form-row input:focus, .form-row select:focus {
  border-color: var(--panel-accent, var(--blue));
}
.form-row select option { background: var(--surface); }
.form-row .hint { font-size: 10px; color: #555; margin-top: 3px; }
.form-row .field-error { font-size: 10px; color: var(--red); margin-top: 3px; display:none; }
.form-row input.invalid { border-color: var(--red); }
.form-actions { display: flex; gap: 8px; margin-top: 16px; }
.form-save {
  flex: 1; background: var(--panel-accent, var(--blue)); color: #000;
  border: none; border-radius: 4px; padding: 8px;
  font-family: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
  transition: opacity 0.1s;
}
.form-save:hover:not(:disabled) { opacity: 0.85; }
.form-save:disabled { opacity: 0.4; cursor: not-allowed; }
.form-cancel {
  background: var(--btn-bg); color: var(--muted); border: 1px solid var(--border);
  border-radius: 4px; padding: 8px 14px;
  font-family: inherit; font-size: 12px; cursor: pointer;
}
.form-cancel:hover { background: var(--btn-hover); color: var(--text); }

.gear-btn {
  background: none; border: none; color: currentColor; cursor: pointer;
  opacity: 0.35; padding: 1px; line-height: 0; margin-left: auto;
  transition: opacity 0.15s; flex-shrink: 0;
}
.gear-btn:hover { opacity: 1; }
