/* ==========================================================================
   Windows Core Server 控制台 —— 深色主题
   全部为本地样式，无外部字体 / 图片 / CDN 依赖。
   ========================================================================== */

/* ------------------------------- 变量 ------------------------------- */

:root {
  --bg: #0f1115;
  --bg-grad: radial-gradient(1100px 520px at 50% -260px, #182033 0%, rgba(15, 17, 21, 0) 70%);
  --bg-elev: #151922;
  --bg-elev-2: #1a1f2b;
  --bg-hover: #1e2532;
  --bg-input: #10141b;
  --border: #252c39;
  --border-strong: #333c4d;
  --text: #e6eaf2;
  --text-dim: #9aa4b5;
  --text-mute: #6b7688;
  --accent: #4f8cff;
  --accent-strong: #2f74f5;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --green: #22c55e;
  --green-soft: rgba(34, 197, 94, 0.14);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.13);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.14);
  --radius: 10px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC",
    "Hiragino Sans GB", "Source Han Sans SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, "Liberation Mono", "Courier New", monospace;
}

/* ------------------------------- 基础 ------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background-color: var(--bg);
  background-image: var(--bg-grad);
  background-repeat: no-repeat;
  -webkit-font-smoothing: antialiased;
}

body.modal-open,
body.detail-open {
  overflow: hidden;
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.01em;
}

p {
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}

button:disabled {
  cursor: not-allowed;
}

a {
  color: var(--accent);
}

code,
.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
}

.muted {
  color: var(--text-mute);
}

.small {
  font-size: 12px;
}

.icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  display: block;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

::selection {
  background: rgba(79, 140, 255, 0.35);
}

* {
  scrollbar-width: thin;
  scrollbar-color: #333c4d transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: #2c3444;
  border-radius: 99px;
  border: 2px solid var(--bg);
}

::-webkit-scrollbar-thumb:hover {
  background: #3a4559;
}

/* ------------------------------- 顶栏 ------------------------------- */

.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(15, 17, 21, 0.82);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px) saturate(140%);
}

.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

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

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: #dce6ff;
  background: linear-gradient(150deg, #2f74f5, #1b3f8f);
  border: 1px solid rgba(120, 165, 255, 0.35);
  box-shadow: 0 6px 18px rgba(47, 116, 245, 0.28);
  flex: 0 0 auto;
}

.brand-mark .icon {
  width: 20px;
  height: 20px;
}

.brand-mark-lg {
  width: 46px;
  height: 46px;
  border-radius: 13px;
}

.brand-mark-lg .icon {
  width: 24px;
  height: 24px;
}

.brand-text {
  min-width: 0;
}

.brand-title {
  font-size: 15.5px;
  font-weight: 650;
  letter-spacing: 0.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  font-size: 11.5px;
  color: var(--text-mute);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-dim);
  font-size: 12.5px;
  white-space: nowrap;
}

.stat-pill .dot {
  background: var(--text-mute);
}

.stat-pill.is-online {
  border-color: rgba(34, 197, 94, 0.32);
  color: #cdeedd;
}

.stat-pill.is-online .dot {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.14);
}

.stat-text {
  font-variant-numeric: tabular-nums;
}

/* ------------------------------- 按钮 ------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elev-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.12s ease, color 0.16s ease;
}

.btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: #414d61;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
}

.btn-sm {
  height: 32px;
  padding: 0 11px;
  font-size: 12.5px;
  gap: 6px;
}

.btn-sm .icon {
  width: 15px;
  height: 15px;
}

.btn-primary {
  background: linear-gradient(180deg, #5a93ff, var(--accent-strong));
  border-color: #3d7cf3;
  color: #fff;
  box-shadow: 0 4px 14px rgba(47, 116, 245, 0.28);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #6b9dff, #3a7bf8);
  border-color: #5a93ff;
}

.btn-ghost {
  background: var(--bg-elev);
  border-color: var(--border);
  color: var(--text-dim);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
}

.btn-danger {
  background: linear-gradient(180deg, #f05252, #d92c2c);
  border-color: #c92b2b;
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: linear-gradient(180deg, #f66565, #e23a3a);
}

.btn-danger-ghost {
  background: var(--bg-elev);
  border-color: var(--border);
  color: #e98a8a;
}

.btn-danger-ghost:hover:not(:disabled) {
  background: var(--red-soft);
  border-color: rgba(239, 68, 68, 0.45);
  color: #ff9b9b;
}

.btn-block {
  width: 100%;
}

.icon-btn {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius-xs);
  border: 1px solid transparent;
  color: var(--text-dim);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover:not(:disabled) {
  background: var(--bg-elev-2);
  border-color: var(--border);
  color: var(--text);
}

.icon-btn.tiny {
  width: 26px;
  height: 26px;
}

.icon-btn.tiny .icon {
  width: 14px;
  height: 14px;
}

.icon-btn.is-danger:hover:not(:disabled) {
  background: var(--red-soft);
  border-color: rgba(239, 68, 68, 0.4);
  color: #ff9b9b;
}

.icon-btn.is-ok:hover:not(:disabled) {
  background: var(--green-soft);
  border-color: rgba(34, 197, 94, 0.4);
  color: #7ee2a4;
}

.btn.is-busy {
  pointer-events: none;
}

/* ------------------------------- 加载 ------------------------------- */

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-top-color: currentColor;
  animation: spin 0.75s linear infinite;
  flex: 0 0 auto;
  display: inline-block;
}

.spinner-sm {
  width: 13px;
  height: 13px;
  border-width: 2px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.list-skeleton {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
}

.skeleton-row {
  display: grid;
  grid-template-columns: 90px 1fr 120px 120px 100px;
  align-items: center;
  gap: 18px;
  padding: 14px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
}

.sk {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, #1d2431 25%, #232c3c 37%, #1d2431 63%);
  background-size: 400% 100%;
  animation: shimmer 1.5s ease infinite;
}

.sk-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.sk-sm {
  width: 80%;
}

.sk-btn {
  height: 24px;
  border-radius: 7px;
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}

/* ------------------------------- 布局 ------------------------------- */

.container {
  flex: 1;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.018), rgba(255, 255, 255, 0));
}

.panel-title {
  font-size: 15px;
}

.panel-sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-mute);
}

.app-foot {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 0 24px 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  color: var(--text-mute);
  font-size: 11.5px;
}

/* ------------------------------- 状态点 ------------------------------- */

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-dim);
  white-space: nowrap;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-mute);
  flex: 0 0 auto;
}

.status.is-online .dot {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

.status.is-online {
  color: #a9e6c3;
}

.status.is-offline .dot {
  background: #4b5566;
}

.status.is-offline {
  color: var(--text-mute);
}

.status-ago {
  color: var(--text-mute);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.status-ago::before {
  content: "· ";
}

/* ------------------------------- 表格 ------------------------------- */

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 14px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--text-mute);
  background: #12161e;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(37, 44, 57, 0.7);
  vertical-align: middle;
}

.data-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.016);
}

.data-table tbody tr:hover {
  background: var(--accent-soft);
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.device-row {
  cursor: pointer;
  transition: background 0.14s ease;
}

.device-row.is-offline .device-name {
  color: var(--text-dim);
}

.cell-name {
  min-width: 150px;
}

.name-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
}

.device-name {
  font-weight: 550;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

.device-name.is-empty {
  color: var(--text-mute);
  font-weight: 400;
}

.cell-sub {
  display: block;
  font-size: 11px;
  color: var(--text-mute);
  margin-top: 2px;
}

.name-editor {
  display: flex;
  align-items: center;
  gap: 4px;
}

.name-input {
  height: 30px;
  width: 170px;
  padding: 0 9px;
  font-size: 13px;
}

.link {
  border: 0;
  padding: 0;
  background: none;
  color: #9fc0ff;
  font-size: 12.5px;
  border-bottom: 1px dashed rgba(159, 192, 255, 0.35);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.link:hover {
  color: #c7dbff;
  border-bottom-color: rgba(199, 219, 255, 0.7);
}

.region-text {
  color: var(--text-dim);
  white-space: nowrap;
}

.version-cell,
.os-cell {
  color: var(--text-dim);
}

.os-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.os-text {
  display: inline-block;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.counts {
  color: var(--text-dim);
}

.cell-actions {
  text-align: right;
}

.device-list {
  min-height: 160px;
}

.tunnel-table .device-name {
  max-width: 140px;
}

.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}

/* 徽章 / chip */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text-dim);
  font-size: 11.5px;
  line-height: 1.7;
  white-space: nowrap;
}

.badge.mono {
  font-size: 11px;
}

.badge.tiny {
  padding: 1px 6px;
  font-size: 10.5px;
}

.badge.is-ok {
  background: var(--green-soft);
  border-color: rgba(34, 197, 94, 0.32);
  color: #86e3ab;
}

.badge.is-warn {
  background: var(--amber-soft);
  border-color: rgba(245, 158, 11, 0.32);
  color: #f2c078;
}

.badge.is-bad {
  background: var(--red-soft);
  border-color: rgba(239, 68, 68, 0.34);
  color: #ff9d9d;
}

.badge.mode {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 10.5px;
  color: #b9c6dd;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: #12161e;
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.7;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip.tiny {
  font-size: 10.5px;
}

.chip.is-ok {
  border-color: rgba(34, 197, 94, 0.3);
  color: #86e3ab;
}

/* 空态 / 错误 / 提示 */

.state-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 42px 24px;
  text-align: center;
  color: var(--text-dim);
}

.state-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--accent);
}

.state-icon .icon {
  width: 20px;
  height: 20px;
}

.state-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.state-text {
  max-width: 520px;
  font-size: 12.5px;
  color: var(--text-mute);
  line-height: 1.7;
}

.state-card.is-error {
  color: #ffb4b4;
}

.state-card.is-error .state-icon {
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.3);
  background: var(--red-soft);
}

.state-card.is-loading .state-text {
  color: var(--text-dim);
}

.banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(245, 158, 11, 0.32);
  background: var(--amber-soft);
  color: #f0c987;
  font-size: 12.5px;
}

.banner .icon {
  margin-top: 2px;
  color: var(--amber);
}

.banner strong {
  display: block;
  color: #ffd9a1;
  font-size: 13px;
}

.banner span {
  color: #dcb887;
}

/* ------------------------------- 登录 ------------------------------- */

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}

.auth-card {
  width: 100%;
  max-width: 384px;
  padding: 30px 28px 26px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #161b25, #141821);
  box-shadow: var(--shadow);
  animation: rise 0.28s ease both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.auth-title {
  font-size: 17px;
  letter-spacing: 0.01em;
}

.auth-sub {
  font-size: 12px;
  color: var(--text-mute);
  margin-top: 2px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-note {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--text-mute);
  line-height: 1.6;
}

.auth-error,
.form-error {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(239, 68, 68, 0.34);
  background: var(--red-soft);
  color: #ffb0b0;
  font-size: 12.5px;
}

/* ------------------------------- 表单控件 ------------------------------- */

.input,
.select {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text);
  font-size: 13px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input::placeholder {
  color: #5c6678;
}

.input:hover:not(:disabled),
.select:hover:not(:disabled) {
  border-color: #3d485a;
}

.input:focus,
.select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.16);
}

.input:disabled,
.select:disabled {
  opacity: 0.55;
  background: #0d1117;
}

.input.mono,
.select.mono {
  font-family: var(--mono);
  font-size: 12.5px;
}

.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #7c8798 50%),
    linear-gradient(135deg, #7c8798 50%, transparent 50%);
  background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field + .field {
  margin-top: 2px;
}

.field-label {
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.01em;
}

.field-hint {
  font-size: 11.5px;
  color: var(--text-mute);
  line-height: 1.6;
}

.field.is-disabled {
  opacity: 0.6;
}

.field-static {
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border-strong);
  background: #12161e;
  color: var(--text-dim);
  font-size: 12px;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-row .input {
  flex: 1;
  min-width: 0;
}

/* 开关 */

.switch-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  color: var(--text-dim);
  font-size: 12.5px;
  position: relative;
}

.switch-field input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  margin: 0;
}

.switch-track {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: #1b212c;
  position: relative;
  transition: background 0.18s ease, border-color 0.18s ease;
  flex: 0 0 auto;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #7d8899;
  transition: transform 0.18s ease, background 0.18s ease;
}

.switch-field input:checked + .switch-track {
  background: rgba(34, 197, 94, 0.85);
  border-color: rgba(34, 197, 94, 0.8);
}

.switch-field input:checked + .switch-track::after {
  transform: translateX(16px);
  background: #fff;
}

.switch-field input:focus-visible + .switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.switch-field input:disabled + .switch-track {
  opacity: 0.5;
}

.switch-label {
  white-space: nowrap;
}

/* ------------------------------- Toast ------------------------------- */

.toast-root {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  max-width: min(360px, calc(100vw - 36px));
  padding: 10px 13px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: #1a202b;
  color: var(--text);
  font-size: 12.5px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  animation: toast-in 0.2s ease both;
  word-break: break-word;
  cursor: pointer;
}

.toast.is-leaving {
  animation: toast-out 0.2s ease both;
}

.toast-icon .icon {
  width: 15px;
  height: 15px;
  margin-top: 2px;
}

.toast-msg {
  min-width: 0;
  line-height: 1.55;
}

.toast-success {
  border-color: rgba(34, 197, 94, 0.4);
}

.toast-success .toast-icon {
  color: var(--green);
}

.toast-error {
  border-color: rgba(239, 68, 68, 0.42);
}

.toast-error .toast-icon {
  color: #ff8b8b;
}

.toast-info .toast-icon {
  color: var(--accent);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ------------------------------- 弹窗 ------------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: rgba(6, 8, 12, 0.66);
  backdrop-filter: blur(3px);
  animation: fade-in 0.16s ease both;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal {
  width: 100%;
  max-width: 520px;
  max-height: min(88vh, 760px);
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: #151a23;
  box-shadow: var(--shadow);
  animation: pop 0.18s ease both;
  outline: none;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--border);
}

.modal-heading {
  min-width: 0;
}

.modal-title {
  font-size: 15px;
}

.modal-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-mute);
}

.modal-close {
  margin: -4px -4px 0 0;
}

.modal-body {
  padding: 16px 18px 18px;
  overflow-y: auto;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.confirm-msg {
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text);
  word-break: break-word;
}

.confirm-detail {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-mute);
  word-break: break-all;
}

.confirm .modal-foot {
  margin-top: 18px;
}

.confirm-modal .modal-body {
  padding-top: 18px;
}

/* ------------------------------- 设备详情抽屉 ------------------------------- */

.detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(6, 8, 12, 0.6);
  animation: fade-in 0.16s ease both;
}

.detail-panel {
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  background-image: var(--bg-grad);
  animation: slide-in 0.22s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes slide-in {
  from {
    transform: translateX(28px);
    opacity: 0.4;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.detail-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(18, 22, 30, 0.9);
  flex-wrap: wrap;
}

.back-btn {
  flex: 0 0 auto;
}

.detail-id {
  flex: 1;
  min-width: 220px;
}

.detail-name {
  font-size: 17px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-badges {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.detail-heartbeat {
  font-size: 11.5px;
  color: var(--text-mute);
  font-variant-numeric: tabular-nums;
}

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

.detail-tabs {
  display: flex;
  gap: 4px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(18, 22, 30, 0.6);
  overflow-x: auto;
}

.tab {
  position: relative;
  height: 44px;
  padding: 0 16px;
  color: var(--text-mute);
  font-size: 13px;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

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

.tab.is-active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 22px 24px 40px;
}

.detail-body > .tab-pane {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 卡片 */

.card {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  overflow: hidden;
}

.card-head {
  padding: 14px 16px 10px;
  border-bottom: 1px solid rgba(37, 44, 57, 0.7);
}

.card-title {
  font-size: 13.5px;
}

.card-sub {
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--text-mute);
}

.card-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 8px 24px;
}

.kv {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 7px 0;
  border-bottom: 1px dashed rgba(37, 44, 57, 0.6);
  min-width: 0;
}

.kv:last-child {
  border-bottom: 0;
}

.kv-key {
  font-size: 12px;
  color: var(--text-mute);
  white-space: nowrap;
}

.kv-val {
  font-size: 12.5px;
  color: var(--text);
  text-align: right;
  word-break: break-all;
}

.kv-val.masked {
  letter-spacing: 0.08em;
  color: #b9c6dd;
}

.reserved {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

/* 联通检测 */

.ping {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ping-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.ping-result {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #12161e;
  font-size: 12.5px;
}

.ping-result.is-ok {
  border-color: rgba(34, 197, 94, 0.34);
  background: var(--green-soft);
}

.ping-result.is-bad {
  border-color: rgba(239, 68, 68, 0.34);
  background: var(--red-soft);
}

.ping-flag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.ping-result.is-ok .ping-flag {
  color: #8ce8b0;
}

.ping-result.is-bad .ping-flag {
  color: #ff9d9d;
}

.ping-meta {
  color: var(--text-dim);
}

.ping-err {
  color: #ff9d9d;
  word-break: break-word;
}

/* 工具条 */

.toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.toolbar-info {
  flex: 1 1 280px;
  min-width: 0;
}

.pane-title {
  font-size: 15px;
}

.pane-sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-mute);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.address-cell,
.traffic {
  white-space: nowrap;
  color: var(--text-dim);
}

/* 代理卡片 */

.proxy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}

.proxy-card {
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 15px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.proxy-card:hover {
  border-color: var(--border-strong);
  background: #171c26;
}

.proxy-card.is-on {
  border-color: rgba(34, 197, 94, 0.3);
  box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.06);
}

.proxy-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.proxy-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.proxy-title {
  font-size: 14px;
}

.proxy-desc {
  font-size: 11.5px;
  color: var(--text-mute);
  line-height: 1.6;
  min-height: 36px;
}

.proxy-addr {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #10141b;
  min-width: 0;
}

.proxy-addr-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #9fc0ff;
  font-size: 12px;
}

.proxy-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--text-mute);
}

.proxy-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px dashed rgba(37, 44, 57, 0.8);
  margin-top: 1px;
}

/* ------------------------------- 命令 ------------------------------- */

.cmd-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 15px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elev);
}

.cmd-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.cmd-field-main {
  flex: 1 1 320px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.cmd-field-timeout {
  width: 150px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cmd-row .btn {
  height: 36px;
}

.cmd-status-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  min-height: 18px;
}

.cmd-status {
  font-size: 12px;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}

.cmd-output {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #0c0f15;
  overflow: hidden;
}

.cmd-output.is-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 32px 20px;
  border-style: dashed;
  background: rgba(12, 15, 21, 0.6);
}

.cmd-empty-icon {
  color: var(--text-mute);
}

.cmd-empty-icon .icon {
  width: 22px;
  height: 22px;
}

.cmd-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  background: #12161e;
}

.cmd-echo {
  font-family: var(--mono);
  font-size: 12px;
  color: #b9c6dd;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 52%;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  background: #0c0f15;
  border: 1px solid var(--border);
}

.cmd-copy {
  margin-left: auto;
}

.cmd-body {
  max-height: 340px;
  overflow: auto;
}

.cmd-pre {
  margin: 0;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  color: #cfd8e6;
  white-space: pre-wrap;
  word-break: break-word;
}

.cmd-pre + .cmd-pre {
  border-top: 1px dashed rgba(37, 44, 57, 0.9);
}

.cmd-pre.is-stderr {
  color: #ff9d9d;
  background: rgba(239, 68, 68, 0.06);
}

.cmd-history-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cmd-history-title {
  font-size: 12.5px;
  color: var(--text-dim);
  font-weight: 500;
}

.cmd-history {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cmd-history-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  color: var(--text-dim);
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.cmd-history-item:hover {
  background: var(--bg-elev-2);
  border-color: var(--border);
}

.cmd-history-item.is-active {
  background: var(--accent-soft);
  border-color: rgba(79, 140, 255, 0.4);
  color: var(--text);
}

.cmd-history-time {
  color: var(--text-mute);
  font-size: 11.5px;
  flex: 0 0 auto;
}

.cmd-history-cmd {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

/* 隐藏的复制中转站 */

.copy-shim {
  position: fixed;
  left: -9999px;
  top: 0;
  opacity: 0;
  pointer-events: none;
}

.noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  z-index: 200;
}

/* ------------------------------- 响应式 ------------------------------- */

@media (max-width: 1080px) {
  .device-table th:nth-child(5),
  .device-table td:nth-child(5) {
    display: none;
  }
}

@media (max-width: 900px) {
  .container {
    padding: 16px 14px;
  }

  .topbar-inner {
    padding: 12px 14px;
    gap: 12px;
  }

  .brand-title {
    font-size: 14px;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .panel-head {
    padding: 14px;
  }

  .detail-head {
    padding: 12px 14px;
    gap: 10px;
  }

  .detail-body {
    padding: 16px 14px 32px;
  }

  .detail-tabs {
    padding: 0 8px;
  }

  /* 表格 → 卡片 */
  .data-table thead {
    display: none;
  }

  .data-table,
  .data-table tbody,
  .data-table tr,
  .data-table td {
    display: block;
    width: 100%;
  }

  .data-table tr {
    margin: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-elev);
    overflow: hidden;
  }

  .data-table tr:nth-child(even) {
    background: var(--bg-elev);
  }

  .data-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 9px 12px;
    border-bottom: 1px solid rgba(37, 44, 57, 0.6);
    text-align: right;
  }

  .data-table td:last-child {
    border-bottom: 0;
  }

  .data-table td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    font-size: 11.5px;
    color: var(--text-mute);
    text-align: left;
    letter-spacing: 0.02em;
  }

  .data-table td.cell-actions {
    justify-content: flex-end;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .data-table td.cell-actions::before {
    content: none;
  }

  .cell-name,
  .cell-actions {
    min-width: 0;
  }

  .cell-sub {
    display: none;
  }

  .os-cell {
    justify-content: flex-end;
  }

  .os-text {
    max-width: 150px;
  }

  .device-name {
    max-width: 60vw;
  }

  .name-input {
    width: 100%;
    min-width: 120px;
  }

  .data-table tbody tr:hover {
    background: var(--bg-elev);
  }

  .sk-name {
    width: 60%;
  }

  .skeleton-row {
    grid-template-columns: 16px 1fr 60px;
  }

  .skeleton-row .sk:nth-child(3),
  .skeleton-row .sk:nth-child(4) {
    display: none;
  }

  .proxy-grid {
    grid-template-columns: 1fr;
  }

  .cmd-field-timeout {
    width: 120px;
  }

  .cmd-echo {
    max-width: 100%;
  }

  .cmd-copy {
    margin-left: 0;
  }

  .toast-root {
    left: 12px;
    right: 12px;
    bottom: 12px;
    align-items: stretch;
  }

  .toast {
    max-width: none;
  }
}

@media (max-width: 560px) {
  .brand-sub {
    display: none;
  }

  .stat-pill {
    padding: 5px 10px;
    font-size: 12px;
  }

  .topbar-actions {
    gap: 8px;
  }

  .detail-name {
    font-size: 15.5px;
  }

  .detail-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .modal-overlay {
    padding: 12px;
    align-items: flex-end;
  }

  .modal {
    max-height: 92vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ------------------------- 危险操作（停止 / 卸载） ------------------------- */

.danger-zone {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.danger-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 14px;
  border: 1px solid rgba(239, 68, 68, 0.26);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.07), rgba(239, 68, 68, 0.02));
}

.danger-row .danger-text strong {
  display: block;
  font-size: 13px;
  margin-bottom: 3px;
  color: var(--text);
}

.danger-row .danger-text .field-hint {
  margin: 0;
}

.danger-row .btn {
  flex: none;
}

.danger-modal .modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.danger-flow {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.danger-intro {
  margin: 0;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-dim);
}

.danger-list {
  margin: 0;
  padding-left: 20px;
  color: #ffb0b0;
  font-size: 12.5px;
  line-height: 1.8;
}

.danger-list li::marker {
  color: var(--red);
}

.danger-check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-dim);
  cursor: pointer;
}

.danger-check input {
  margin-top: 2px;
  accent-color: var(--red);
  width: 15px;
  height: 15px;
  flex: none;
}

.danger-phrase {
  margin: 0;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(239, 68, 68, 0.45);
  background: var(--red-soft);
  color: #ffd0d0;
  font-family: var(--mono);
  font-size: 13px;
  word-break: break-all;
}

.danger-input {
  width: 100%;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
}

.danger-input:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18);
}

.danger-final {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  font-size: 12.5px;
}

.step-dots {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.step-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--text-mute);
  font-family: var(--mono);
  font-size: 11px;
}

.step-dot.is-on {
  border-color: rgba(239, 68, 68, 0.7);
  background: var(--red-soft);
  color: #ffb0b0;
}
/* ------------------------- 直连 8964 ------------------------- */

.direct {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.direct .input-row {
  gap: 8px;
}

.direct .direct-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 22px;
}

.direct .field-hint a,
.direct a.link {
  color: var(--accent);
  text-decoration: none;
}

.direct a.link:hover {
  text-decoration: underline;
}