:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --border: #e3e8ef;
  --border-strong: #d3dae5;
  --text: #171a1f;
  --muted: #5f6b7a;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #e8f0ff;
  --success: #15803d;
  --success-soft: #e8f7ee;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --warn: #b45309;
  --warn-soft: #fff6e5;
  --shadow: 0 12px 32px rgba(23, 26, 31, 0.06);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 10% -10%, #e9f0ff 0%, rgba(233, 240, 255, 0) 60%),
    radial-gradient(900px 500px at 110% 0%, #fff1e8 0%, rgba(255, 241, 232, 0) 55%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.muted {
  color: var(--muted);
  margin: 0;
}

.small {
  font-size: 12.5px;
}

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

h1 {
  font-size: 26px;
}

h2 {
  font-size: 16px;
}

h3 {
  font-size: 17px;
  margin-bottom: 12px;
}

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

.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 32px 20px;
}

.login-card {
  width: min(380px, 100%);
  padding: 36px 32px 28px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: center;
}

.brand-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  display: block;
}

.brand-logo.small {
  width: 38px;
  height: 38px;
  margin: 0;
}

.subtitle {
  margin: 4px 0 26px;
  color: var(--muted);
  font-size: 14px;
}

.login-foot {
  margin: 0;
  color: #8b95a3;
  font-size: 12.5px;
}

/* ---------- 基础组件 ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.card-head h2 {
  margin-bottom: 2px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  text-align: left;
}

.field span {
  font-size: 13px;
  color: var(--muted);
}

input,
select {
  width: 100%;
  height: 42px;
  padding: 0 13px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #fbfcfe;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input:focus,
select:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.13);
}

input[readonly] {
  background: #f7f9fc;
  color: #3c4653;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 15px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 550;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.06s ease, color 0.15s ease;
}

.btn:hover:not(:disabled) {
  background: #f7f9fc;
  border-color: #c4cedb;
}

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

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.primary:hover:not(:disabled) {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

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

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

.btn.small {
  height: 30px;
  padding: 0 10px;
  font-size: 12.5px;
  border-radius: 8px;
}

.btn.block {
  width: 100%;
  height: 44px;
  font-size: 14.5px;
}

.danger-text {
  color: var(--danger);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.btn-row.end {
  justify-content: flex-end;
  margin-top: 20px;
}

.form-error {
  min-height: 18px;
  margin: 4px 0 0;
  color: var(--danger);
  font-size: 12.5px;
  text-align: left;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge.ok {
  background: var(--success-soft);
  color: var(--success);
}

.badge.bad {
  background: var(--danger-soft);
  color: var(--danger);
}

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

.badge.quiet {
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 550;
}

.note {
  margin: 16px 0 0;
  padding: 11px 14px;
  border-radius: 10px;
  background: var(--warn-soft);
  border: 1px solid #f6e2b8;
  color: var(--warn);
  font-size: 12.5px;
}

/* ---------- 主界面 ---------- */

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(227, 232, 239, 0.9);
}

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

.brand-name {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

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

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

.layout {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 24px 24px 8px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.wide {
  grid-column: 1 / -1;
}

.info-list {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.info-list > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 9px;
  border-bottom: 1px dashed var(--border);
}

.info-list > div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.info-list dt {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.info-list dd {
  margin: 0;
  font-size: 13.5px;
  font-weight: 550;
  text-align: right;
  overflow-wrap: anywhere;
}

.link-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-top: 10px;
}

.link-label {
  display: flex;
  flex-direction: column;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

.link-label small {
  font-size: 10.5px;
  font-weight: 400;
  color: #98a2b0;
}

.add-row {
  display: flex;
  gap: 10px;
  margin: 4px 0 6px;
}

.add-row input {
  max-width: 320px;
}

.table-wrap {
  margin-top: 10px;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  font-size: 13.5px;
}

th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 13px 12px;
  border-bottom: 1px solid #eef1f5;
  vertical-align: middle;
}

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

tbody tr.disabled-row {
  opacity: 0.58;
}

th.right,
td.right {
  text-align: right;
}

.user-name {
  font-weight: 600;
  font-size: 14px;
}

.user-meta {
  color: #8b95a3;
  font-size: 11.5px;
  margin-top: 2px;
}

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

.secret {
  letter-spacing: 0.08em;
  color: #3c4653;
}

.share-cell,
.actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.actions {
  justify-content: flex-end;
}

.empty {
  margin: 18px 0 4px;
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  background: #f8fafc;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
}

.foot {
  margin-top: auto;
  padding: 22px;
  text-align: center;
  color: #98a2b0;
  font-size: 12px;
}

/* ---------- 对话框与提示 ---------- */

.dialog {
  border: 0;
  border-radius: 16px;
  padding: 0;
  width: min(420px, calc(100vw - 32px));
  box-shadow: 0 30px 80px rgba(23, 26, 31, 0.22);
  background: var(--card);
  color: var(--text);
}

.dialog::backdrop {
  background: rgba(23, 26, 31, 0.38);
  backdrop-filter: blur(2px);
}

.dialog-inner {
  padding: 26px 26px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dialog p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.6;
}

.dialog .field:first-of-type {
  margin-top: 10px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 100;
  max-width: min(560px, calc(100vw - 40px));
  padding: 11px 18px;
  border-radius: 12px;
  background: #1f2937;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 14px 36px rgba(23, 26, 31, 0.24);
  opacity: 0;
  transform: translate(-50%, 10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error {
  background: #b91c1c;
}

.toast.warn {
  background: #b45309;
}

.clipboard-helper {
  position: fixed;
  top: -1000px;
  left: -1000px;
  opacity: 0;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    padding: 18px 16px 4px;
  }

  .topbar {
    padding: 12px 16px;
  }

  .brand-sub {
    display: none;
  }

  .top-actions .btn {
    padding: 0 10px;
  }

  .wide {
    grid-column: auto;
  }

  .link-row {
    grid-template-columns: 1fr auto;
  }

  .link-label {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: baseline;
    gap: 8px;
  }

  .add-row {
    flex-direction: column;
  }

  .add-row input {
    max-width: none;
  }

  .card {
    padding: 18px;
  }
}

@media (max-width: 560px) {
  .top-actions #btn-password {
    display: none;
  }

  table {
    font-size: 12.5px;
  }

  th,
  td {
    padding: 10px 8px;
  }

  .share-cell {
    flex-direction: column;
    align-items: flex-start;
  }
}
