:root {
  --bg: #0f1419;
  --panel: #171d24;
  --panel2: #1e2630;
  --border: #2a3441;
  --text: #dbe4ee;
  --sub: #7d8b9c;
  --accent: #22b573;
  --accent2: #1a9660;
  --danger: #e05c5c;
  --warn: #e0b95c;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
.sub { color: var(--sub); font-size: 0.85rem; }
.error { color: var(--danger); min-height: 1em; }

header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.5rem; border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: baseline; gap: 0.75rem; }
h1 { margin: 0; font-size: 1.25rem; letter-spacing: 0.02em; }
h1::before { content: "🔀 "; }

.status { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--sub); display: inline-block; }
.dot.up { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.dot.down { background: var(--danger); box-shadow: 0 0 6px var(--danger); }

nav { display: flex; gap: 0.25rem; padding: 0.5rem 1.5rem 0; border-bottom: 1px solid var(--border); }
.tab {
  background: none; border: none; color: var(--sub); padding: 0.6rem 1rem;
  cursor: pointer; font-size: 0.95rem; border-bottom: 2px solid transparent;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab:hover { color: var(--text); }

main { padding: 1.25rem 1.5rem; max-width: 900px; margin: 0 auto; }
.toolbar { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 1rem; }

button {
  background: var(--panel2); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 0.5rem 0.9rem; cursor: pointer; font-size: 0.9rem;
}
button:hover { border-color: var(--sub); }
button.primary { background: var(--accent2); border-color: var(--accent2); font-weight: 600; }
button.primary:hover { background: var(--accent); }
button.danger { color: var(--danger); }
button.danger:hover { border-color: var(--danger); }
button.linkish { background: none; border: none; color: var(--sub); padding: 0.25rem 0; }
button.linkish:hover { color: var(--text); }
button:disabled { opacity: 0.5; cursor: wait; }

.site-list { display: flex; flex-direction: column; gap: 0.6rem; }
.site-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 0.9rem 1.1rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem;
}
.site-card .addr { font-weight: 600; font-size: 1rem; }
.site-card .addr a { color: var(--text); text-decoration: none; }
.site-card .addr a:hover { color: var(--accent); }
.site-card .target { color: var(--sub); font-size: 0.85rem; font-family: ui-monospace, monospace; margin-top: 0.2rem; white-space: pre-wrap; }
.site-card .actions { display: flex; gap: 0.4rem; flex-shrink: 0; }
.badge {
  font-size: 0.7rem; padding: 0.1rem 0.45rem; border-radius: 10px;
  background: var(--panel2); border: 1px solid var(--border); color: var(--warn); margin-left: 0.5rem;
}

textarea, input {
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 0.55rem 0.7rem; font-size: 0.9rem; width: 100%;
}
textarea { font-family: ui-monospace, "SF Mono", Menlo, monospace; resize: vertical; }
#editor { min-height: 420px; line-height: 1.5; tab-size: 4; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); }

.output {
  background: var(--panel); border: 1px solid var(--border); border-radius: 6px;
  padding: 0.8rem 1rem; font-size: 0.8rem; white-space: pre-wrap; word-break: break-all;
  font-family: ui-monospace, monospace; margin-top: 0.75rem; max-height: 50vh; overflow: auto;
}
.output.bad { border-color: var(--danger); }
.output.good { border-color: var(--accent2); }

.backup-list { display: flex; flex-direction: column; gap: 0.4rem; }
.backup-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 0.5rem 0.9rem;
  font-family: ui-monospace, monospace; font-size: 0.85rem;
}
.backup-row .actions { display: flex; gap: 0.4rem; }

dialog {
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 1.5rem; width: min(520px, 92vw);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog h2 { margin: 0 0 1rem; font-size: 1.1rem; }
dialog label { display: block; margin-bottom: 0.8rem; font-size: 0.85rem; color: var(--sub); }
.radio-row { display: flex; gap: 1.25rem; margin-bottom: 0.8rem; }
.radio-row label { display: flex; align-items: center; gap: 0.4rem; margin: 0; cursor: pointer; }
.radio-row input { width: auto; }
.check-row { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; margin-bottom: 0.5rem !important; }
.check-row input { width: auto; }
#option-fields { border-top: 1px solid var(--border); margin-top: 1rem; padding-top: 0.9rem; }
#auth-fields { margin-left: 1.4rem; }
.badge.lan { color: var(--accent); }
.badge.auth { color: #6aa6e8; }
#folder-hint { margin: 0.3rem 0 0; font-family: ui-monospace, monospace; font-size: 0.75rem; }
dialog input, dialog textarea { margin-top: 0.3rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.25rem; }

.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: var(--panel2); border: 1px solid var(--border); border-radius: 8px;
  padding: 0.7rem 1.2rem; font-size: 0.9rem; max-width: 80vw; white-space: pre-wrap;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5); z-index: 50;
}
.toast.good { border-color: var(--accent2); }
.toast.bad { border-color: var(--danger); }

.login { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
.login-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 2rem; width: 320px; display: flex; flex-direction: column; gap: 0.8rem;
}
.login-card h1 { text-align: center; margin-bottom: 0.5rem; }
