/* 客户凭据管理后台 —— 简洁卡片风，移动端可用 */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f2f4f7;
  --card: #ffffff;
  --border: #e2e6ec;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --warning-bg: #fff7ed;
  --warning-border: #f59e0b;
}

body {
  font-family: "Microsoft YaHei", "PingFang SC", -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  min-height: 100vh;
}

code { background: #eef1f5; padding: 1px 5px; border-radius: 3px; font-size: 13px; }

/* ---------- 布局 ---------- */
.view-center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.card-narrow { width: 100%; max-width: 380px; }
.card h1 { font-size: 20px; margin-bottom: 6px; }

.layout { display: flex; min-height: calc(100vh - 52px); }

.sidebar {
  width: 180px;
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 12px 8px;
  flex-shrink: 0;
}
.nav-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: none;
  background: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
}
.nav-item:hover { background: #eef2f7; }
.nav-item.active { background: var(--primary); color: #fff; }

.content { flex: 1; padding: 20px; min-width: 0; }
.tab-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 8px; }
.tab-head h2 { font-size: 18px; }

/* ---------- 顶栏 ---------- */
.topbar {
  height: 52px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}
.brand { font-weight: 600; font-size: 16px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

/* ---------- 表单 ---------- */
form label { display: block; margin: 12px 0 4px; font-size: 13px; color: var(--muted); }
form input[type="text"], form input[type="password"], form textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}
form input:focus, form textarea:focus { outline: none; border-color: var(--primary); }

.form-error {
  margin-top: 10px;
  padding: 8px 10px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
  border-radius: 6px;
  font-size: 13px;
}

/* ---------- 按钮 ---------- */
.btn {
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: none; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: #f3f4f6; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-block { width: 100%; margin-top: 16px; }
.btn-mini { padding: 3px 8px; font-size: 12px; margin: 0 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 表格 ---------- */
.table-wrap { background: var(--card); border: 1px solid var(--border); border-radius: 10px; overflow: auto; }
.tbl { width: 100%; border-collapse: collapse; min-width: 720px; }
.tbl th, .tbl td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td.wrap { white-space: normal; word-break: break-all; }
.tbl th { background: #f8fafc; font-size: 13px; color: var(--muted); font-weight: 600; }
.tbl tbody tr:hover { background: #f8fafc; }
.tbl .secret { font-family: monospace; letter-spacing: 1px; }
.tbl .empty-row td { text-align: center; color: var(--muted); padding: 24px; }

/* ---------- 开关 ---------- */
.guard-card { margin-bottom: 14px; }
.switch-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; color: var(--text); margin: 0; }
.switch-label input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }
.small { font-size: 12px; margin-top: 8px; }
.muted { color: var(--muted); }

/* ---------- 横幅 ---------- */
.banner {
  padding: 10px 16px;
  font-size: 13px;
  line-height: 1.6;
}
.banner-warning { background: var(--warning-bg); border-bottom: 1px solid var(--warning-border); color: #92400e; }

/* ---------- hidden 属性全局保护 ----------
   .modal/.view-center 等设置了 display:flex，会覆盖 HTML hidden 属性的
   UA 样式（display:none），导致所有弹窗常驻显示、遮罩拦截全部点击。
   此规则保证任何带 hidden 的元素一律不显示。 */
[hidden] { display: none !important; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  z-index: 100;
}
.modal-card {
  background: var(--card);
  border-radius: 10px;
  padding: 22px;
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow: auto;
}
.modal-card h3 { margin-bottom: 8px; font-size: 17px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---------- 轻提示 ---------- */
.toast {
  position: fixed;
  bottom: 28px; left: 50%;
  transform: translateX(-50%);
  background: #111827; color: #fff;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 200;
}

/* ---------- 移动端 ---------- */
@media (max-width: 640px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; display: flex; border-right: none; border-bottom: 1px solid var(--border); padding: 6px; }
  .nav-item { width: auto; flex: 1; text-align: center; }
  .tbl { min-width: 640px; }
  .topbar { padding: 0 12px; }
  .content { padding: 12px; }
}
