:root {
  --bg: #0b0f1a;
  --bg-2: #0e1424;
  --panel: #121a2c;
  --panel-2: #0f1729;
  --border: #1f2a44;
  --border-2: #2a3a5c;
  --text: #e6ecff;
  --muted: #8a93ad;
  --primary: #5b8cff;
  --primary-2: #7aa3ff;
  --success: #2dd06b;
  --danger: #ef4444;
  --warning: #f5a524;
  --shadow: 0 12px 32px rgba(2, 8, 23, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", system-ui,
    -apple-system, sans-serif;
  font-size: 14px;
}

a {
  color: var(--primary-2);
  text-decoration: none;
}

button {
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}

input,
select,
textarea {
  font-family: inherit;
  font-size: 14px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.18);
}

textarea {
  resize: vertical;
  min-height: 60px;
}

/* Buttons */
.btn-primary,
.btn-ghost,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: transform 0.05s, background 0.15s, border-color 0.15s;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.btn-primary {
  background: linear-gradient(180deg, #5b8cff, #4070ee);
  color: #fff;
  box-shadow: 0 6px 18px rgba(64, 112, 238, 0.32);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #6ea0ff, #4f7ef2);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-2);
}

.btn-ghost:hover {
  border-color: #38507a;
  background: rgba(91, 140, 255, 0.08);
}

.btn-danger {
  background: linear-gradient(180deg, #ef4444, #c93636);
  color: #fff;
  box-shadow: 0 6px 18px rgba(201, 54, 54, 0.32);
}

.btn-danger:hover {
  filter: brightness(1.05);
}

.btn-link {
  background: transparent;
  border: 0;
  color: var(--primary-2);
  padding: 4px 6px;
  border-radius: 6px;
}

.btn-link:hover {
  background: rgba(91, 140, 255, 0.1);
}

.btn-link.danger {
  color: #ff8e8e;
}

.btn-link.danger:hover {
  background: rgba(239, 68, 68, 0.12);
}

/* ============ 登录 ============ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(800px 380px at 20% 10%, rgba(91, 140, 255, 0.18), transparent 65%),
    radial-gradient(700px 320px at 80% 90%, rgba(43, 209, 194, 0.12), transparent 70%),
    var(--bg);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px 26px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-head {
  text-align: center;
  margin-bottom: 6px;
}

.login-logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #5b8cff, #4070ee);
  color: #fff;
  margin-bottom: 12px;
  box-shadow: 0 10px 24px rgba(64, 112, 238, 0.36);
}

.login-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 4px;
}

.login-sub {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.login-err {
  color: #ff8e8e;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.4);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
}

#loginBtn {
  margin-top: 6px;
  height: 40px;
  width: 100%;
}

/* ============ 工作台 ============ */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #5b8cff, #4070ee);
  color: #fff;
  flex-shrink: 0;
}

.brand-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.3px;
}

.brand-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.tabs {
  display: flex;
  gap: 4px;
  background: var(--panel-2);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.tab {
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 7px;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.3px;
  transition: background 0.15s, color 0.15s;
}

.tab:hover {
  color: var(--text);
}

.tab.is-active {
  background: rgba(91, 140, 255, 0.18);
  color: #ecf1fb;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.tab-panel {
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-title {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.page-sub {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.form-card {
  padding: 22px;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
}

.field strong {
  color: var(--text);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.form-msg {
  color: var(--success);
  font-size: 12.5px;
}

.form-msg.is-error {
  color: #ff8e8e;
}

.form-err {
  color: #ff8e8e;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12.5px;
}

/* ============ 代理表 ============ */
.agent-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.agent-table thead th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  padding: 12px 16px;
  background: rgba(91, 140, 255, 0.05);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.agent-table tbody td {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}

.agent-table tbody tr:first-child td {
  border-top: 0;
}

.agent-table tbody tr:hover td {
  background: rgba(91, 140, 255, 0.04);
}

.agent-table .empty {
  text-align: center;
  color: var(--muted);
  padding: 32px 16px;
}

.agent-table .col-action {
  text-align: right;
  width: 220px;
}

.agent-table .col-action .actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

.host-cell {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  color: #cfd8ee;
}

.host-link {
  color: var(--primary-2);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.host-link:hover {
  text-decoration: underline;
}

.skin-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(91, 140, 255, 0.14);
  color: #cfd8ee;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid rgba(91, 140, 255, 0.3);
}

.skin-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--primary-2);
}

.login-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}
.login-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
}
.login-pill.on {
  background: rgba(34, 197, 94, 0.16);
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.32);
}
.login-pill.on::before {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}
.login-pill.off {
  background: rgba(148, 163, 184, 0.14);
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.28);
}
.login-pill.off::before {
  background: #94a3b8;
}

/* ===== 接入状态 pill（DNS / HTTPS）===== */
.status-cell { white-space: nowrap; }
.status-stack {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
}
.st-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
  letter-spacing: .2px;
}
.st-pill.ok {
  background: rgba(45, 208, 107, 0.14);
  color: #86efac;
  border-color: rgba(45, 208, 107, 0.32);
}
.st-pill.warn {
  background: rgba(245, 165, 36, 0.14);
  color: #fcd34d;
  border-color: rgba(245, 165, 36, 0.32);
}
.st-pill.off {
  background: rgba(148, 163, 184, 0.10);
  color: #94a3b8;
  border-color: rgba(148, 163, 184, 0.20);
}
.st-pill.err {
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.32);
  cursor: help;
}
.st-pill.loading {
  background: rgba(91, 140, 255, 0.10);
  color: #7aa3ff;
  border-color: rgba(91, 140, 255, 0.22);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .55; } }

/* ===== CNAME 接入指引卡 ===== */
.cname-hint {
  margin: 8px 0 4px;
}
.cname-card {
  background: rgba(91, 140, 255, 0.06);
  border: 1px solid rgba(91, 140, 255, 0.22);
  border-radius: 10px;
  padding: 12px 14px;
}
.cname-title {
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 13px;
}
.cname-grid { display: grid; gap: 6px; }
.cname-row {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  align-items: center;
  font-size: 12.5px;
}
.cname-k { color: var(--muted); font-size: 12px; }
.cname-v { color: var(--text); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cname-v code {
  background: rgba(15, 23, 41, 0.6);
  padding: 2px 8px;
  border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: #c5d2ff;
}
.cname-actions { margin-top: 10px; display: flex; gap: 8px; }
.btn-link.tiny { padding: 1px 4px; font-size: 11.5px; }
.btn-ghost.tiny {
  padding: 4px 9px;
  font-size: 12px;
  border-radius: 6px;
}

/* ===== 一键开通 HTTPS 弹窗（终端样日志）===== */
.modal-wide .modal-card,
.modal-card.modal-wide {
  max-width: 720px;
  width: 92vw;
}
.ssl-log {
  margin: 12px 0 16px;
  padding: 12px 14px;
  background: #04070f;
  border: 1px solid #1f2a44;
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.6;
  color: #cbd5e1;
  height: 360px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.field-hint {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}
.field-hint a {
  color: var(--primary-2);
  text-decoration: none;
}
.field-hint a:hover { text-decoration: underline; }
.field-hint b { color: var(--text); font-weight: 600; }

.login-card-info {
  margin-top: 8px;
  padding: 12px 14px;
  background: rgba(91, 140, 255, 0.06);
  border: 1px solid rgba(91, 140, 255, 0.18);
  border-radius: 10px;
  display: grid;
  gap: 8px;
  font-size: 13px;
}
.login-card-info .lci-row {
  display: grid;
  grid-template-columns: 80px 1fr;
  align-items: center;
  gap: 12px;
}
.login-card-info .lci-k {
  color: var(--muted);
  font-size: 12px;
}
.login-card-info .lci-v {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.login-card-info code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12.5px;
  color: var(--text);
  word-break: break-all;
  overflow-wrap: anywhere;
  flex: 1;
  min-width: 0;
}
.login-card-info .btn-link {
  flex: 0 0 auto;
  background: rgba(91, 140, 255, 0.16);
  color: #cfd8ee;
  border: 1px solid rgba(91, 140, 255, 0.32);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.login-card-info .btn-link:hover {
  background: rgba(91, 140, 255, 0.28);
}
.login-card-info .lci-tip {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.muted-cell {
  color: var(--muted);
}

.contact-cell {
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 12.5px;
  color: var(--text);
  max-width: 240px;
}

.time-cell {
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

/* ============ 皮肤库 ============ */
.skin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.skin-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, transform 0.1s;
}

.skin-card:hover {
  border-color: rgba(91, 140, 255, 0.5);
}

.skin-thumb {
  position: relative;
  aspect-ratio: 16 / 10;
  background: linear-gradient(135deg, #1a2540, #0f1729);
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}

.skin-iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 1280px;
  height: 800px;
  border: 0;
  transform-origin: 0 0;
  transform: scale(0.32);
  pointer-events: none;
  background: #0b0f1a;
}

.skin-thumb-mask {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(11, 15, 26, 0) 60%,
    rgba(11, 15, 26, 0.5) 100%
  );
  pointer-events: none;
}

.skin-thumb-label {
  position: absolute;
  left: 12px;
  bottom: 10px;
  background: rgba(11, 15, 26, 0.6);
  color: #ecf1fb;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(4px);
}

.skin-meta {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.skin-name {
  font-weight: 700;
  font-size: 14px;
}

.skin-actions {
  display: flex;
  gap: 8px;
}

/* ============ 弹窗 ============ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 修复：HTML hidden 属性必须能压过下面的 display:flex / display:grid，
   否则登录页和工作台会同时显示。 */
[hidden] { display: none !important; }

.modal[hidden] {
  display: none;
}

.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(2, 8, 23, 0.65);
  backdrop-filter: blur(2px);
}

.modal-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px 22px 20px;
  width: min(460px, calc(100vw - 24px));
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-narrow {
  width: min(380px, calc(100vw - 24px));
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 20px;
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.modal-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.modal-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.modal-sub {
  margin: -6px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* ============ Toast ============ */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 10px;
  background: rgba(45, 208, 107, 0.18);
  border: 1px solid rgba(45, 208, 107, 0.5);
  color: #c6f5d8;
  font-size: 13px;
  z-index: 200;
  box-shadow: var(--shadow);
}

.toast.is-error {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.5);
  color: #ffc6c6;
}

/* ============ 移动端 ============ */
@media (max-width: 760px) {
  .topbar {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 14px;
  }
  .topbar-right {
    margin-left: 0;
    width: 100%;
    justify-content: flex-end;
  }
  .tabs {
    width: 100%;
    overflow-x: auto;
  }
  .tab-panel {
    padding: 16px 12px;
  }
  .agent-table thead {
    display: none;
  }
  .agent-table,
  .agent-table tbody,
  .agent-table tr,
  .agent-table td {
    display: block;
    width: 100%;
  }
  .agent-table tbody tr {
    border-top: 1px solid var(--border);
    padding: 10px 6px;
  }
  .agent-table tbody td {
    border-top: 0;
    padding: 6px 12px;
  }
  .agent-table tbody td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 2px;
  }
  .agent-table .col-action {
    text-align: left;
    width: auto;
  }
  .agent-table .col-action .actions {
    justify-content: flex-start;
  }
}
