:root {
  color-scheme: light;
  --bg: #eef2f4;
  --surface: #ffffff;
  --surface-strong: #f8fafb;
  --text: #172126;
  --muted: #667780;
  --line: #d7e0e5;
  --primary: #087f8c;
  --primary-dark: #06606a;
  --accent: #c9831a;
  --danger: #b42318;
  --success: #18825f;
  --shadow: 0 18px 50px rgba(23, 33, 38, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px;
  background: #18262b;
  color: #f6fbfc;
}

.brand {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: #087f8c;
  color: #ffffff;
  font-weight: 800;
}

.brand strong,
.brand span,
.session-box strong,
.session-box span {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.brand strong {
  font-size: 16px;
}

.brand span,
.session-box span {
  color: #b9c9cf;
  font-size: 12px;
  margin-top: 3px;
}

.tabs {
  display: grid;
  gap: 8px;
}

.tab,
.ghost-button,
.icon-button,
.primary-button,
.copy-button {
  border: 0;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.tab {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 8px;
  background: transparent;
  color: #d4e1e5;
  text-align: left;
}

.tab:hover,
.tab.is-active {
  background: rgba(255, 255, 255, 0.11);
  color: #ffffff;
}

.tab span {
  overflow-wrap: anywhere;
}

.bind-link {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #d4e1e5;
  text-decoration: none;
  transition: background 0.16s;
}
.bind-link:hover {
  background: rgba(255,255,255,0.11);
  color: #fff;
}

.session-box {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) 36px;
  gap: 10px;
  align-items: center;
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #8798a0;
}

.status-dot.is-online {
  background: var(--success);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  text-decoration: none;
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.workspace {
  min-width: 0;
  padding: 28px;
}

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

.workspace-head h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: 0;
}

.workspace-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.ghost-button,
.primary-button,
.copy-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border-radius: 8px;
  white-space: nowrap;
}

.ghost-button {
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.ghost-button:hover {
  border-color: #b9c8cf;
  background: var(--surface-strong);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(320px, 520px) minmax(320px, 1fr);
  gap: 18px;
  align-items: start;
}

.panel-stack,
.result-panel {
  min-width: 0;
}

.panel,
.result-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  display: none;
}

.panel.is-active {
  display: block;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 58px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e8f4f5;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 700;
}

.badge-muted {
  background: #eef1f3;
  color: var(--muted);
}

.badge-error {
  background: #fff0ed;
  color: var(--danger);
}

.badge-success {
  background: #e9f6f1;
  color: var(--success);
}

.form {
  display: grid;
  gap: 10px;
  padding: 18px;
}

label {
  color: #34454d;
  font-size: 13px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  outline: none;
}

input {
  height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 180px;
  max-height: 360px;
  resize: vertical;
  padding: 12px;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
}

input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(8, 127, 140, 0.14);
}

.primary-button {
  margin-top: 6px;
  padding: 0 16px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
}

.primary-button:hover {
  background: var(--primary-dark);
}

.primary-button:disabled,
.ghost-button:disabled,
.copy-button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.result-panel {
  overflow: hidden;
}

.result-empty {
  display: grid;
  place-items: center;
  min-height: 300px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.result-card {
  padding: 18px;
}

.endpoint-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 14px;
  border: 1px solid #cfe6e8;
  border-radius: 8px;
  background: #f3fbfb;
}

.endpoint {
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 20px;
  font-weight: 800;
  color: var(--primary-dark);
}

.copy-button {
  min-width: 42px;
  padding: 0 12px;
  background: #f5e9d8;
  color: #81520d;
}

.copy-button:hover {
  background: #efd8b6;
}

.meta-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.meta-item {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.meta-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.meta-value {
  display: block;
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 700;
}

.toast {
  margin: 18px;
  padding: 12px;
  border-radius: 8px;
  background: #fff7ea;
  color: #80520f;
}

.toast.error {
  background: #fff0ed;
  color: var(--danger);
}

/* ── IPLock 测压 ── */

.iplock-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
}

.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  margin-top: 6px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: var(--danger);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.16s ease, opacity 0.16s ease;
}

.danger-button:hover {
  background: #911a12;
}

.danger-button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.iplock-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  margin-bottom: 14px;
}

.iplock-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #8798a0;
  flex-shrink: 0;
}

.iplock-dot.is-active {
  background: var(--success);
  animation: pulse-dot 1.2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── 控制台日志 ── */

.iplock-console {
  margin-top: 14px;
  max-height: 260px;
  overflow-y: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #18262b;
  color: #8ee5b9;
  font-family: "Cascadia Mono", Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
}

.console-line {
  display: block;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tab {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .session-box {
    margin-top: 0;
  }

  .workspace {
    padding: 18px;
  }

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

@media (max-width: 520px) {
  .workspace-head {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace-head h1 {
    font-size: 22px;
  }

  .ghost-button,
  .primary-button {
    width: 100%;
  }

  .meta-list,
  .endpoint-row {
    grid-template-columns: 1fr;
  }
}
