:root {
  --bg0: #f2f5f8;
  --bg1: #e8eef4;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #ffffff;
  --ink: #15202b;
  --muted: #5d6b78;
  --line: rgba(21, 32, 43, 0.08);
  --line-strong: rgba(21, 32, 43, 0.14);
  --accent: #0f6e6a;
  --accent-2: #1a4d6d;
  --accent-soft: #e4f3f2;
  --ok: #0f7a4f;
  --ok-bg: #e5f6ee;
  --warn: #9a5b00;
  --warn-bg: #fff3dd;
  --err: #b42318;
  --err-bg: #fdecea;
  --radius: 14px;
  --shadow: 0 1px 0 rgba(255,255,255,0.7) inset, 0 10px 30px -18px rgba(21, 32, 43, 0.28);
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "DM Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(1200px 600px at 8% -10%, rgba(15, 110, 106, 0.14), transparent 55%),
    radial-gradient(900px 500px at 92% 0%, rgba(26, 77, 109, 0.12), transparent 50%),
    linear-gradient(180deg, var(--bg0), var(--bg1) 40%, #eef2f5);
  background-attachment: fixed;
}

#app { min-height: 100vh; }

/* —— Login —— */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}
.login::before {
  content: "";
  position: absolute;
  inset: -20% auto auto -10%;
  width: 48vmin;
  height: 48vmin;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(15, 110, 106, 0.22), transparent 70%);
  animation: drift 14s ease-in-out infinite alternate;
  pointer-events: none;
}
.login::after {
  content: "";
  position: absolute;
  inset: auto -8% -15% auto;
  width: 42vmin;
  height: 42vmin;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(26, 77, 109, 0.18), transparent 70%);
  animation: drift 18s ease-in-out infinite alternate-reverse;
  pointer-events: none;
}
@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(4%, 6%) scale(1.08); }
}
.login-card {
  position: relative;
  z-index: 1;
  width: min(400px, 100%);
  background: var(--surface);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 1.85rem 1.6rem 1.5rem;
  box-shadow: var(--shadow);
  animation: rise 0.45s ease-out;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.login-mark {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.85rem;
}
.login-mark i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.login-card h1 {
  margin: 0 0 0.25rem;
  font-size: 1.55rem;
  letter-spacing: -0.035em;
  font-weight: 700;
}
.login-card p {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.login-card label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.login-card input {
  width: 100%;
  font: inherit;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  margin-bottom: 0.95rem;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.login-card input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.err-msg { color: var(--err); font-size: 0.82rem; margin: -0.45rem 0 0.75rem; }

/* —— Topbar —— */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(21, 32, 43, 0.92);
  backdrop-filter: blur(12px);
  color: #eef3f6;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0.75rem 1.15rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  min-width: 0;
}
.brand-name {
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: 0.98rem;
}
.brand-sub {
  font-size: 0.72rem;
  color: #9aadb8;
  font-family: var(--mono);
}
.topbar .grow { flex: 1; }
.live {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: #c5d0d8;
  font-variant-numeric: tabular-nums;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
}
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6b7280;
  flex-shrink: 0;
}
.dot.ok {
  background: #34d399;
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.55);
  animation: pulse 2s ease-out infinite;
}
.dot.bad { background: #f87171; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}
.topbar button {
  background: transparent;
  border-color: rgba(255,255,255,0.16);
  color: #e8eef2;
}
.topbar button:hover { background: rgba(255,255,255,0.08); }
.topbar button.ghost-danger {
  border-color: rgba(248, 113, 113, 0.35);
  color: #fecaca;
}
.topbar button.ghost-danger:hover { background: rgba(248, 113, 113, 0.12); }

.main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.25rem 1.1rem 3rem;
  animation: rise 0.4s ease-out;
}

/* —— Status hero —— */
.status-hero {
  background: var(--surface);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  padding: 1.1rem 1.15rem 1rem;
  box-shadow: var(--shadow);
  margin-bottom: 0.9rem;
  transition: border-color 0.25s;
}
.status-hero.ok { border-color: rgba(15, 122, 79, 0.28); }
.status-hero.err { border-color: rgba(180, 35, 24, 0.35); }
.status-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.status-title {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.status-host {
  margin-top: 0.2rem;
  font-size: 0.8rem;
  color: var(--muted);
  font-family: var(--mono);
}
.tag {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  vertical-align: middle;
}
.tag.reality { background: var(--ok-bg); color: var(--ok); }
.status-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}
.kpi-cell {
  padding: 0.7rem 0.8rem;
  border-radius: 12px;
  background: linear-gradient(180deg, #fafcfd, #f3f7f9);
  border: 1px solid var(--line);
}
.kpi-cell .lbl {
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}
.kpi-cell .val {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-top: 0.2rem;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}
.kpi-cell .sub {
  font-size: 0.74rem;
  color: var(--muted);
  margin-top: 0.15rem;
}
.status-foot {
  margin-top: 0.85rem;
  font-size: 0.76rem;
  color: var(--muted);
  font-family: var(--mono);
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
}
.pill {
  font-size: 0.72rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid transparent;
}
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--err-bg); color: var(--err); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }

/* —— Sections —— */
.section {
  background: var(--surface);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.05rem;
  box-shadow: var(--shadow);
  min-width: 0;
}
.section + .section { margin-top: 0.85rem; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.section h2 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.section-head .hint {
  font-size: 0.74rem;
  color: var(--muted);
}

.layout-split {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 0.85rem;
  margin-top: 0.85rem;
  align-items: stretch;
}
.layout-split > .section {
  display: flex;
  flex-direction: column;
  margin-top: 0;
  height: 440px;
  min-height: 440px;
  max-height: 440px;
}
.layout-split .section-head { flex: 0 0 auto; }
.dest-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-right: 0.15rem;
}
.dest-scroll .meta { margin-bottom: 0.45rem; }

.chart-wrap {
  position: relative;
}
.chart-svg {
  width: 100%;
  height: auto;
  display: block;
}
.chart-svg .grid {
  stroke: rgba(21, 32, 43, 0.08);
  stroke-width: 1;
}
.chart-svg .axis {
  fill: var(--muted);
  font-size: 11px;
  font-family: var(--sans);
}
.chart-svg .dot-pt {
  fill: #fff;
  stroke: #0f6e6a;
  stroke-width: 2;
}
.chart-svg .dot-pt.on {
  fill: #0f6e6a;
  r: 5;
}
.chart-svg .hover-x {
  stroke: rgba(15, 110, 106, 0.35);
  stroke-dasharray: 3 3;
}
.chart-tip {
  position: absolute;
  top: 8px;
  background: #15202b;
  color: #fff;
  font-size: 0.75rem;
  line-height: 1.45;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  pointer-events: none;
  min-width: 140px;
  box-shadow: 0 10px 24px -12px rgba(0,0,0,0.5);
}
.chart-legend {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.55rem;
  font-size: 0.76rem;
  color: var(--muted);
}
.chart-legend .lg {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: #0f6e6a;
  margin-right: 0.35rem;
  vertical-align: -1px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
th, td {
  text-align: left;
  padding: 0.55rem 0.35rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom-color: var(--line-strong);
}
tbody tr {
  transition: background 0.15s;
}
tbody tr:hover { background: rgba(15, 110, 106, 0.04); }
tbody tr:last-child td { border-bottom: none; }
td.host {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--muted);
  word-break: break-all;
}
td.num {
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-family: var(--mono);
  font-size: 0.78rem;
}
td.actions-cell {
  text-align: right;
  white-space: nowrap;
}
.bar {
  height: 4px;
  background: var(--accent-soft);
  border-radius: 2px;
  margin-top: 0.28rem;
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 2px;
  transition: width 0.35s ease;
}

.logs {
  font-family: var(--mono);
  font-size: 0.7rem;
  line-height: 1.5;
  background: #12181f;
  color: #c9d4dc;
  border-radius: 12px;
  padding: 0.75rem 0.8rem;
  flex: 1;
  min-height: 0;
  height: auto;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  border: 1px solid rgba(255,255,255,0.04);
}
.logs .err { color: #ff8a80; }
.logs .warn { color: #ffcc80; }
.logs .info { color: #8fa0ab; }

.meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 0.7rem;
}
.meta b { color: var(--ink); font-weight: 600; }

button, .btn {
  font: inherit;
  font-size: 0.84rem;
  font-weight: 550;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  padding: 0.45rem 0.8rem;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}
button:hover { background: #f4f7f9; }
button:active { transform: translateY(1px); }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button.primary:hover { filter: brightness(1.06); }
button.danger {
  background: #fff;
  border-color: #f0c2be;
  color: var(--err);
}
button.danger:hover { background: var(--err-bg); }
button.quiet {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent);
}
button.quiet:hover { background: #d5ebe9; }
button:disabled { opacity: 0.55; cursor: default; }

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  background: #15202b;
  color: #fff;
  padding: 0.6rem 0.9rem;
  border-radius: 10px;
  font-size: 0.84rem;
  z-index: 20;
  box-shadow: 0 12px 28px -12px rgba(0,0,0,0.45);
  animation: rise 0.25s ease-out;
}

.add-row {
  display: flex;
  gap: 0.5rem;
  margin: 0 0 0.9rem;
  flex-wrap: wrap;
}
.add-row input {
  flex: 1;
  min-width: 180px;
  font: inherit;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.add-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.empty {
  color: var(--muted);
  font-size: 0.88rem;
  padding: 1.2rem 0.2rem;
  text-align: center;
}
.op-msg {
  font-size: 0.78rem;
  color: var(--muted);
  min-height: 1.1em;
}

@media (max-width: 1100px) {
  .status-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .status-kpis { grid-template-columns: 1fr; }
  .layout-split { grid-template-columns: 1fr; }
  .layout-split > .section {
    height: 360px;
    min-height: 360px;
    max-height: 360px;
  }
  .brand-sub { display: none; }
}
