:root {
  --bg: #f3f7f5;
  --surface: #ffffff;
  --text: #14241f;
  --muted: #5a6f67;
  --border: #d5e3dc;
  --accent: #0f7a5c;
  --accent-hover: #0b634b;
  --danger: #c43c1a;
  --ok-bg: #e8f7ef;
  --ok-text: #1f7a45;
  --err-bg: #fff1ed;
  --err-text: #b42318;
  --radius: 12px;
  --font: "Manrope", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --shadow: 0 18px 50px rgba(15, 61, 46, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: linear-gradient(180deg, #e7f1ec 0%, var(--bg) 220px);
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
  color: var(--text);
}

.brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: block;
  flex-shrink: 0;
}

.nav {
  display: flex;
  gap: 1rem;
}

.nav a {
  color: var(--muted);
  font-size: 0.95rem;
}

.nav a:hover {
  color: var(--accent);
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.5rem;
}

h1 {
  margin: 0 0 0.35rem;
  font-size: 1.6rem;
}

.subtitle {
  margin: 0 0 1.25rem;
  color: var(--muted);
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: 0.92rem;
}

.flash.ok {
  background: var(--ok-bg);
  color: var(--ok-text);
}

.flash.err {
  background: var(--err-bg);
  color: var(--err-text);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.card h2 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
}

.form-grid {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.form-grid input,
.form-grid select {
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-grid input:focus,
.form-grid select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 122, 92, 0.15);
}

.form-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font: inherit;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.btn:hover {
  background: var(--accent-hover);
  text-decoration: none;
}

.btn.secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}

.btn.secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn.danger {
  background: #fff;
  color: var(--danger);
  border-color: #ffc2b0;
}

.btn.danger:hover {
  background: #fff4f0;
}

.btn.small {
  padding: 0.3rem 0.65rem;
  font-size: 0.85rem;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  text-align: left;
  padding: 0.7rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.host-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.mono {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.88rem;
}

.empty {
  color: var(--muted);
  padding: 1rem 0;
}

.filter-bar {
  display: flex;
  gap: 0.6rem;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.filter-bar label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.filter-bar input {
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  min-width: 200px;
  outline: none;
}

.filter-bar input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 122, 92, 0.15);
}

.domain-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.domain-list li {
  border-bottom: 1px solid var(--border);
}

.domain-list li:last-child {
  border-bottom: none;
}

.domain-list a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 0.2rem;
  color: var(--text);
  text-decoration: none;
}

.domain-list a:hover {
  color: var(--accent);
}

.badge {
  color: var(--muted);
  font-size: 0.85rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  background: #14241f;
  color: #fff;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  z-index: 50;
  box-shadow: var(--shadow);
}

.login-page {
  background: #e8f2ed;
  overflow-x: hidden;
}

.login-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 70% 55% at 15% 20%, rgba(15, 122, 92, 0.18), transparent 60%),
    radial-gradient(ellipse 55% 50% at 88% 15%, rgba(227, 107, 85, 0.16), transparent 55%),
    radial-gradient(ellipse 60% 45% at 70% 90%, rgba(120, 190, 90, 0.14), transparent 50%),
    linear-gradient(160deg, #eef7f3 0%, #f7f4f1 48%, #e9f1ec 100%);
}

.login-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(15, 61, 46, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 61, 46, 0.04) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(circle at center, black 35%, transparent 80%);
}

.login-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-panel {
  width: min(420px, 100%);
  padding: 2rem 1.75rem 1.75rem;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(213, 227, 220, 0.95);
  border-radius: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  animation: login-rise 420ms ease both;
}

.login-hero {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-logo {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  display: block;
  margin: 0 auto 1rem;
  box-shadow: 0 10px 24px rgba(15, 61, 46, 0.12);
}

.login-title {
  margin: 0;
  font-size: clamp(1.55rem, 4vw, 1.85rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--text);
}

.login-desc {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
}

.login-field input {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font: inherit;
  font-weight: 500;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.login-field input::placeholder {
  color: #93a59d;
  font-weight: 400;
}

.login-field input:hover {
  border-color: #b9cfc4;
}

.login-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(15, 122, 92, 0.14);
  background: #fcfffe;
}

.login-submit {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.9rem 1rem;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #12936d 0%, var(--accent) 55%, #0b634b 100%);
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.18s ease, filter 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 10px 22px rgba(15, 122, 92, 0.28);
}

.login-submit:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.login-submit:active {
  transform: translateY(0);
  filter: brightness(0.98);
}

.login-submit:focus-visible {
  outline: 3px solid rgba(227, 107, 85, 0.55);
  outline-offset: 2px;
}

@keyframes login-rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .login-panel {
    animation: none;
  }

  .login-submit,
  .login-field input,
  .btn {
    transition: none;
  }
}

.modal[hidden] {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 36, 31, 0.45);
}

.modal-panel {
  position: relative;
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.modal-panel h2 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}

.modal-message {
  margin: 0 0 1.1rem;
  color: var(--muted);
  line-height: 1.5;
  word-break: break-all;
}

.modal-actions {
  margin-top: 0;
  justify-content: flex-end;
}
