:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafd;
  --line: #dde5ef;
  --line-soft: #edf1f6;
  --text: #0f172a;
  --muted: #66758a;
  --blue: #2563eb;
  --blue-soft: #eaf1ff;
  --green: #12a150;
  --green-soft: #e8f8ef;
  --amber: #d97706;
  --amber-soft: #fff4d9;
  --red: #dc2626;
  --red-soft: #fee9e9;
  --nav: #111827;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 0%, rgba(37, 99, 235, .06), transparent 28%),
    linear-gradient(180deg, #f8fbff 0%, var(--bg) 42%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}
button, input, select, textarea { font: inherit; }
button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .92);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, transform .16s ease, box-shadow .16s ease;
}
button:hover {
  border-color: #b8c5d8;
  background: #fff;
  box-shadow: 0 8px 20px rgba(15, 23, 42, .06);
}
button:active { transform: translateY(1px); }
button.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  box-shadow: 0 10px 22px rgba(37, 99, 235, .2);
}
button.primary:hover { background: #1d4ed8; border-color: #1d4ed8; }
button.danger { color: var(--red); border-color: #fecaca; background: #fff7f7; }
button.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.icon-btn { min-width: 72px; }
.full { width: 100%; }
.hidden { display: none !important; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(430px, 100%);
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(221, 229, 239, .9);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 34px;
  backdrop-filter: blur(16px);
}
.brand-mark, .logo span {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: linear-gradient(180deg, #3b82f6 0%, #1d4ed8 100%);
  color: #fff;
  font-weight: 800;
}
.login-card h1 { margin: 20px 0 6px; font-size: 28px; }
.login-card p { margin: 0 0 24px; color: var(--muted); }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 11px 12px;
  outline: none;
}
textarea { min-height: 86px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.login-card label { margin-bottom: 14px; }
.form-error { min-height: 20px; color: var(--red); margin-top: 12px; }

.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: linear-gradient(180deg, #111827 0%, #0b1220 100%);
  color: #dbe4f0;
  padding: 24px 18px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 10px 28px;
  font-size: 22px;
}
.logo strong { color: #fff; }
.sidebar nav { display: grid; gap: 8px; }
.sidebar nav button {
  text-align: left;
  color: #d6deea;
  border-color: transparent;
  background: transparent;
  border-radius: 8px;
  padding: 13px 16px;
  font-size: 17px;
}
.sidebar nav button.active, .sidebar nav button:hover {
  background: rgba(255,255,255,.11);
  color: #fff;
  box-shadow: none;
}
.main {
  min-width: 0;
  padding: 32px 40px 56px;
  overflow: auto;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}
.topbar h2 { margin: 0; font-size: 32px; line-height: 1.15; }
.topbar p { margin: 7px 0 0; color: var(--muted); font-size: 17px; }
.top-actions { display: flex; gap: 10px; align-items: center; }
.refresh-status {
  color: var(--muted);
  font-size: 13px;
  padding: 0 4px;
}

.hero-panel, .overview-shell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: linear-gradient(135deg, #ffffff 0%, #f7fbff 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 16px;
}
.hero-panel h3, .overview-shell h3 { margin: 8px 0 7px; font-size: 24px; }
.hero-panel p, .overview-shell p { margin: 0; color: var(--muted); }
.overview-copy { min-width: 0; }
.overview-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.eyebrow {
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
}

.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.summary-row { margin-bottom: 18px; }
.dashboard-grid {
  grid-template-columns: minmax(0, 1fr) 420px;
  align-items: start;
}
.band-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr);
  gap: 16px;
  align-items: stretch;
}
.panel, .metric, .status-card {
  background: rgba(255,255,255,.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.045);
}
.panel { padding: 18px; overflow: hidden; }
.metric {
  padding: 18px;
  min-height: 118px;
}
.metric span {
  color: var(--muted);
  font-size: 14px;
}
.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 31px;
  line-height: 1;
}
.metric em {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
}
.metric.live-metric {
  border-color: rgba(37, 99, 235, .22);
  background: linear-gradient(180deg, #ffffff 0%, #f4f8ff 100%);
}
.metric.live-metric strong {
  color: var(--blue);
}
.metric.live-metric::after {
  content: "";
  display: block;
  width: 42px;
  height: 3px;
  margin-top: 13px;
  border-radius: 999px;
  background: linear-gradient(90deg, #60a5fa, #2563eb);
}
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 24px 0 12px;
}
.section-title h3 { margin: 0; font-size: 20px; }
.section-title.flush { margin: 0 0 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }

.live-panel, .quick-panel { min-height: 156px; }
.live-traffic {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.live-traffic div {
  padding: 14px;
  border-radius: 8px;
  background: var(--panel-soft);
  border: 1px solid var(--line-soft);
}
.live-traffic span {
  color: var(--muted);
  font-size: 13px;
}
.live-traffic strong {
  display: block;
  margin-top: 9px;
  font-size: 22px;
}
.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.quick-actions button {
  min-height: 52px;
  text-align: left;
}

.status-card {
  padding: 18px;
  min-width: 0;
}
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.card-head strong { display: block; font-size: 17px; }
.card-head span { display: block; color: var(--muted); font-size: 13px; margin-top: 4px; }
.server-url {
  margin: 14px 0 15px;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.bar-row { display: grid; gap: 6px; margin-top: 12px; }
.bar-row > div:first-child {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}
.bar-row strong { color: var(--text); }
.bar-row small { color: var(--muted); }
.bar {
  height: 7px;
  border-radius: 999px;
  background: #edf2f7;
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #60a5fa, #2563eb);
}
.mini-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.mini-grid span {
  display: grid;
  gap: 3px;
  padding: 10px;
  border-radius: 8px;
  background: var(--panel-soft);
  min-width: 0;
}
.mini-grid b {
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mini-grid small {
  color: var(--muted);
  font-size: 12px;
}
.server-cards { margin-bottom: 18px; }
.server-status-list {
  display: grid;
  gap: 14px;
}
.server-wide-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 460px);
  gap: 18px;
  background: rgba(255,255,255,.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.045);
  padding: 18px;
}
.server-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.server-title strong {
  display: block;
  font-size: 18px;
}
.server-title span {
  display: block;
  max-width: 760px;
  margin-top: 5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.resource-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.server-side {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  align-content: stretch;
}
.server-side div {
  display: grid;
  align-content: center;
  gap: 6px;
  min-height: 86px;
  padding: 12px;
  border-radius: 8px;
  background: var(--panel-soft);
  border: 1px solid var(--line-soft);
}
.server-side span {
  color: var(--muted);
  font-size: 12px;
}
.server-side strong {
  min-width: 0;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
  table-layout: auto;
}
th, td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
}
th {
  color: var(--muted);
  font-weight: 700;
  background: var(--panel-soft);
}
th:first-child { border-top-left-radius: 8px; }
th:last-child { border-top-right-radius: 8px; }
tr:last-child td { border-bottom: 0; }
td strong { font-weight: 750; }
.url-cell, .sub-link {
  max-width: 440px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--muted);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 650;
  background: var(--blue-soft);
  color: #1e40af;
  white-space: nowrap;
}
.chip.green { background: var(--green-soft); color: #166534; }
.chip.red { background: var(--red-soft); color: #991b1b; }
.chip.amber { background: var(--amber-soft); color: #92400e; }
.muted { color: var(--muted); }
.empty {
  border: 1px dashed #c4cfdd;
  border-radius: 8px;
  padding: 32px;
  text-align: center;
  color: var(--muted);
  background: rgba(255,255,255,.72);
}
.group-card h4 {
  margin: 18px 0 8px;
  font-size: 15px;
}
.group-stats { margin-bottom: 14px; }
.compact-panel { max-height: 432px; overflow: auto; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.form-grid .wide { grid-column: 1 / -1; }
dialog {
  width: min(780px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0;
}
dialog::backdrop { background: rgba(15, 23, 42, .38); backdrop-filter: blur(4px); }
#modalForm { padding: 20px; }
.modal-head, .modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.modal-head { margin-bottom: 18px; }
.modal-head h3 { margin: 0; }
.modal-actions { margin-top: 18px; justify-content: flex-end; }
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: #111827;
  color: #fff;
  border-radius: 8px;
  padding: 13px 15px;
  box-shadow: var(--shadow);
  max-width: 430px;
  z-index: 20;
}
.sub-link {
  display: block;
  color: var(--blue);
}
.code {
  background: #0f172a;
  color: #dbeafe;
  border-radius: 8px;
  padding: 14px;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
}

@media (max-width: 1200px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .band-grid { grid-template-columns: 1fr; }
  .server-wide-card { grid-template-columns: 1fr; }
  .server-side { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
  }
  .sidebar nav { grid-template-columns: repeat(3, 1fr); }
  .sidebar nav button { font-size: 14px; text-align: center; }
  .main { padding: 20px; }
  .topbar, .hero-panel, .overview-shell { align-items: flex-start; flex-direction: column; }
  .live-traffic, .resource-grid, .server-side { grid-template-columns: 1fr; }
  .grid.cols-4, .grid.cols-3, .grid.cols-2, .form-grid { grid-template-columns: 1fr; }
  .url-cell, .sub-link { max-width: 240px; }
}
