:root {
  --bg: #f2f2f7;
  --bg-elevated: #ffffff;
  --fill: rgba(120, 120, 128, 0.12);
  --fill-strong: rgba(120, 120, 128, 0.2);
  --sep: rgba(60, 60, 67, 0.12);
  --label: #1c1c1e;
  --secondary: #8e8e93;
  --tertiary: #aeaeb2;
  --blue: #007aff;
  --blue-press: #0066d6;
  --green: #34c759;
  --orange: #ff9500;
  --red: #ff3b30;
  --radius: 12px;
  --radius-sm: 8px;
  --side-w: 220px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --shadow-sheet: 0 10px 40px rgba(0, 0, 0, 0.18);
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; min-height: 100%;
  font: 13px/1.4 var(--font);
  color: var(--label);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input { font: inherit; color: inherit; }
button {
  appearance: none; border: 0; cursor: pointer;
  background: var(--blue); color: #fff;
  border-radius: var(--radius-sm);
  padding: 0.42rem 0.9rem;
  font-weight: 510;
  letter-spacing: -0.01em;
  transition: transform 100ms ease-out, background 120ms ease-out, opacity 120ms ease-out;
}
button:hover { background: var(--blue-press); }
button:active { transform: scale(0.97); }
button.secondary { background: var(--fill); color: var(--label); }
button.secondary:hover { background: var(--fill-strong); }
button.ghost {
  background: transparent; color: var(--blue);
  padding: 0.15rem 0.3rem; font-weight: 500; font-size: 0.92em;
}
button.ghost:hover { background: transparent; opacity: 0.75; }
button.danger { background: var(--red); }
button.danger:hover { filter: brightness(0.95); }
button:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
input {
  width: 100%;
  background: var(--bg);
  border: 0;
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.7rem;
  color: var(--label);
}
input:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.28);
  background: #fff;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(1200px 600px at 50% -10%, #ffffff 0%, transparent 55%),
    linear-gradient(180deg, #ececf1 0%, var(--bg) 45%, #e8e8ed 100%);
}
.login-card {
  width: min(360px, 100%);
  text-align: center;
}
.login-card .brand {
  margin: 0 0 0.15rem;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1.1;
}
.login-card .sub {
  margin: 0 0 1.1rem;
  color: var(--secondary);
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  background: var(--fill);
  padding: 2px;
  border-radius: 9px;
  margin-bottom: 0.95rem;
}
.seg button {
  background: transparent;
  color: var(--label);
  border-radius: 7px;
  padding: 0.38rem 0.5rem;
  font-weight: 510;
}
.seg button.active {
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 1px rgba(0, 0, 0, 0.04);
}
.seg button:hover { background: transparent; }
.seg button.active:hover { background: #fff; }
.login-card .group {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  overflow: hidden;
  text-align: left;
  margin-bottom: 0.85rem;
}
.login-card .field {
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.85rem;
  margin: 0;
  border-bottom: 0.5px solid var(--sep);
}
.login-card .field:last-of-type { border-bottom: 0; }
.login-card .field label { color: var(--label); font-size: 0.95rem; }
.login-card .field input {
  background: transparent; border: 0; border-radius: 0;
  padding: 0.35rem 0; box-shadow: none;
  text-align: right;
  -webkit-appearance: none; appearance: none;
}
.login-card .field input:focus { box-shadow: none; background: transparent; }
.login-card .field input::placeholder { color: var(--tertiary); text-align: right; }
.login-card .field input:-webkit-autofill,
.login-card .field input:-webkit-autofill:hover,
.login-card .field input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--label);
  -webkit-box-shadow: 0 0 0 1000px #fff inset;
  box-shadow: 0 0 0 1000px #fff inset;
  transition: background-color 99999s ease-out;
  caret-color: var(--label);
}
.login-card .error {
  color: var(--red); min-height: 1.1rem; font-size: 0.85rem;
  margin: 0 0 0.65rem; text-align: left;
}
.login-card .submit {
  width: 100%; padding: 0.65rem 1rem; font-size: 1rem; border-radius: var(--radius);
}

.shell {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  min-height: 100vh;
}
.side {
  position: sticky; top: 0; height: 100vh;
  padding: 0.85rem 0.65rem;
  display: flex; flex-direction: column;
  background: rgba(246, 246, 248, 0.92);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-right: 0.5px solid var(--sep);
}
.side .logo {
  font-weight: 700; font-size: 1.15rem; letter-spacing: -0.035em;
  padding: 0.35rem 0.7rem 0.55rem;
}
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-sec {
  margin: 0.65rem 0.7rem 0.2rem;
  font-size: 0.68rem; font-weight: 600; color: var(--tertiary);
  letter-spacing: 0.02em; text-transform: uppercase;
}
.nav-sec:first-child { margin-top: 0.15rem; }
.nav button {
  width: 100%; text-align: left; background: transparent; color: var(--label);
  border-radius: 8px; padding: 0.48rem 0.7rem;
  font-size: 0.92rem; font-weight: 500; letter-spacing: -0.01em;
}
.nav button:hover { background: var(--fill); }
.nav button.active {
  background: rgba(0, 122, 255, 0.12); color: var(--blue); font-weight: 600;
}
.nav button.active:hover { background: rgba(0, 122, 255, 0.16); }
.side-foot {
  margin-top: auto; padding: 0.55rem 0.7rem 0.2rem;
  font-size: 0.75rem; color: var(--secondary); word-break: break-all; line-height: 1.35;
}
.side .logout {
  width: 100%; margin-top: 0.35rem; background: transparent;
  color: var(--secondary); font-weight: 500; text-align: left; padding: 0.4rem 0.7rem;
}
.side .logout:hover { background: var(--fill); color: var(--label); }

.main {
  padding: 1.35rem 1.6rem 2rem;
  width: 100%; max-width: 960px;
  animation: rise 280ms var(--ease) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .main { animation: none; }
  button:active { transform: none; }
}

.topbar {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 0.75rem; margin-bottom: 1.1rem; flex-wrap: wrap;
}
.topbar h1 {
  margin: 0; font-size: 1.75rem; font-weight: 700;
  letter-spacing: -0.04em; line-height: 1.15;
}
.topbar p {
  margin: 0.2rem 0 0; color: var(--secondary);
  font-size: 0.88rem; letter-spacing: -0.01em;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--bg-elevated);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  overflow: hidden;
}
.metric {
  padding: 0.95rem 1rem;
  border-right: 0.5px solid var(--sep);
}
.metric:last-child { border-right: 0; }
.metric .k { color: var(--secondary); font-size: 0.78rem; font-weight: 500; }
.metric .v {
  margin-top: 0.2rem; font-size: 1.45rem; font-weight: 650;
  letter-spacing: -0.045em; font-variant-numeric: tabular-nums;
}
.metric .s { color: var(--tertiary); font-size: 0.82rem; font-weight: 500; }

.panel {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  overflow: auto;
  width: 100%;
  margin-bottom: 0.85rem;
}
.panel-h {
  display: flex; justify-content: space-between; align-items: center;
  gap: 0.5rem; flex-wrap: wrap; padding: 0.7rem 1rem 0.55rem;
}
.panel-h h2 {
  margin: 0; font-size: 0.8rem; font-weight: 600; color: var(--secondary);
  letter-spacing: -0.01em;
}
.panel-b { padding: 0.85rem 1rem 1rem; }

table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left; padding: 0.62rem 1rem;
  border-bottom: 0.5px solid var(--sep);
  font-size: 0.9rem; vertical-align: middle;
}
th {
  color: var(--secondary); font-weight: 500; white-space: nowrap;
  font-size: 0.75rem; padding-top: 0.35rem; padding-bottom: 0.4rem;
}
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 120ms ease-out; }
tbody tr:hover td { background: rgba(0, 0, 0, 0.02); }
td code, .mono {
  font-family: var(--mono); font-size: 0.82rem;
  letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
}

.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: 0.78rem; font-weight: 510; color: var(--secondary);
}
.badge::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--tertiary);
}
.badge.online { color: #248a3d; }
.badge.online::before { background: var(--green); }

.hint {
  color: var(--secondary);
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.85rem;
  font-size: 0.88rem;
  letter-spacing: -0.01em;
}
.hint.warn { color: #9a6700; background: rgba(255, 149, 0, 0.12); }
.hint.ok { color: #248a3d; background: rgba(52, 199, 89, 0.12); }
.hint.tip { cursor: pointer; }
.hint.tip:hover { opacity: 0.92; }

.toolbar {
  display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap;
  margin-bottom: 0.85rem;
}
.search {
  flex: 1; min-width: 160px; max-width: 280px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
}
.search:focus { background: #fff; }

.loading {
  display: grid; place-items: center; min-height: 12rem;
  color: var(--secondary); font-size: 0.9rem; gap: 0.65rem;
}
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--fill-strong);
  border-top-color: var(--blue);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  padding: 2.2rem 1.2rem; color: var(--secondary); text-align: center; font-size: 0.9rem;
}
.empty .empty-t {
  margin: 0 0 0.25rem; color: var(--label); font-size: 1rem;
  font-weight: 600; letter-spacing: -0.02em;
}
.empty .empty-d { margin: 0 0 0.85rem; color: var(--secondary); font-size: 0.85rem; }
.empty .actions { justify-content: center; }

.modal-bg {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, 0.32);
  display: grid; place-items: center; padding: 1rem;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  animation: fade 160ms ease-out both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(400px, 100%);
  background: rgba(255, 255, 255, 0.96);
  border-radius: 14px;
  padding: 1.1rem 1.15rem 1rem;
  box-shadow: var(--shadow-sheet);
  animation: sheet 280ms var(--ease) both;
}
@keyframes sheet {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: none; }
}
.modal h3 {
  margin: 0 0 0.35rem; font-size: 1.05rem; font-weight: 650;
  letter-spacing: -0.025em; text-align: center;
}
.modal .modal-sub {
  margin: 0 0 0.85rem; text-align: center;
  color: var(--secondary); font-size: 0.85rem;
}
.modal .row { margin-bottom: 0.6rem; }
.modal .row label {
  display: block; font-size: 0.78rem; color: var(--secondary); margin-bottom: 0.25rem;
}
.modal .btns {
  display: flex; gap: 0.5rem; margin-top: 1rem;
}
.modal .btns button { flex: 1; padding: 0.55rem; border-radius: 10px; }

.inset {
  background: var(--bg-elevated); border-radius: var(--radius); overflow: hidden;
}
.inset .field {
  display: grid; grid-template-columns: 5.5rem 1fr; align-items: center;
  gap: 0.4rem; padding: 0.55rem 0.85rem; margin: 0;
  border-bottom: 0.5px solid var(--sep);
}
.inset .field:last-child { border-bottom: 0; }
.inset .field label { color: var(--label); font-size: 0.92rem; margin: 0; }
.inset .field input {
  background: transparent; border: 0; border-radius: 0;
  padding: 0.3rem 0; text-align: right; box-shadow: none;
}
.inset .field input:focus { box-shadow: none; background: transparent; }

.wizard {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  overflow: hidden;
}
.wizard-step {
  display: grid;
  grid-template-columns: 1.75rem 1fr;
  gap: 0.65rem;
  padding: 0.85rem 1rem;
  border-bottom: 0.5px solid var(--sep);
  align-items: start;
}
.wizard-step:last-child { border-bottom: 0; }
.wizard-step .n {
  width: 1.5rem; height: 1.5rem; border-radius: 50%;
  background: var(--fill); color: var(--secondary);
  display: inline-grid; place-items: center;
  font-size: 0.75rem; font-weight: 650;
  margin-top: 0.05rem;
}
.wizard-step.done .n { background: rgba(52, 199, 89, 0.18); color: #248a3d; }
.wizard-step h3 {
  margin: 0 0 0.15rem; font-size: 0.95rem; font-weight: 600; letter-spacing: -0.02em;
}
.wizard-step p { margin: 0; color: var(--secondary); font-size: 0.85rem; }
.wizard-step .step-act { margin-top: 0.4rem; }

.field { display: grid; gap: 0.25rem; margin-bottom: 0.65rem; }
.field label { color: var(--secondary); font-size: 0.8rem; }
.error { color: var(--red); min-height: 1rem; font-size: 0.85rem; }
.muted { color: var(--secondary); font-size: 0.85rem; }
.actions { display: flex; gap: 0.35rem; flex-wrap: wrap; align-items: center; }
.pwd-box { max-width: 400px; }
.dl-row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.dl-row a {
  display: inline-flex; align-items: center;
  padding: 0.5rem 0.95rem; border-radius: var(--radius-sm);
  background: var(--blue); color: #fff; text-decoration: none; font-weight: 510;
  transition: transform 100ms ease-out, background 120ms ease-out;
}
.dl-row a:hover { background: var(--blue-press); }
.dl-row a:active { transform: scale(0.97); }
.dl-row a.secondary { background: var(--fill); color: var(--label); }
.dl-row a.secondary:hover { background: var(--fill-strong); }

.quick {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.quick button {
  width: 100%;
  padding: 0.7rem 0.75rem;
  border-radius: var(--radius);
  text-align: left;
  font-weight: 600;
  letter-spacing: -0.02em;
  background: var(--bg-elevated);
  color: var(--label);
}
.quick button:hover { background: #fff; }
.quick button.primary {
  background: var(--blue); color: #fff;
}
.quick button.primary:hover { background: var(--blue-press); }
.quick button:disabled { opacity: 0.4; }
.split {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 0.85rem;
  margin-bottom: 0.85rem;
}
.prog { margin-bottom: 0.75rem; }
.prog-h {
  display: flex; justify-content: space-between;
  font-size: 0.8rem; color: var(--secondary); margin-bottom: 0.3rem;
}
.prog-bar {
  height: 6px; border-radius: 980px; background: var(--fill); overflow: hidden;
}
.prog-bar i {
  display: block; height: 100%; width: 0;
  background: var(--blue); border-radius: 980px;
  transition: width 320ms var(--ease);
}
.prog-bar.hot i { background: var(--orange); }
.prog-bar.full i { background: var(--red); }
.dns-row { display: flex; gap: 0.5rem; }
.dns-row input { flex: 1; background: var(--bg); }

.toast {
  position: fixed; left: 50%; bottom: 1.4rem; transform: translateX(-50%);
  background: rgba(30, 30, 32, 0.88); color: #fff;
  padding: 0.55rem 0.95rem; border-radius: 980px; z-index: 99;
  font-size: 0.82rem; font-weight: 500;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  animation: toast-in 220ms var(--ease) both;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(6px); }
  to { opacity: 1; transform: translateX(-50%); }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: relative; height: auto;
    border-right: 0; border-bottom: 0.5px solid var(--sep);
  }
  .nav { flex-direction: row; flex-wrap: wrap; gap: 2px; }
  .nav button { width: auto; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric { border-bottom: 0.5px solid var(--sep); }
  .quick { grid-template-columns: 1fr 1fr; }
  .split { grid-template-columns: 1fr; }
  .main { padding: 1rem 1rem 1.5rem; max-width: none; }
}
