/* 全部样式本地提供,不引用任何外部 CDN 与在线字体 */
:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --border: #e3e8ef;
  --text: #1c2536;
  --muted: #6b7787;
  --primary: #2aabee;
  --primary-dark: #1d90cd;
  --danger: #e0524b;
  --success: #2f9e68;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 33, 61, 0.06), 0 8px 24px rgba(20, 33, 61, 0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Source Han Sans SC",
    system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 17px; }
h2 { font-size: 15px; }
h3 { font-size: 14px; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); margin: 6px 0 0; font-size: 13px; }

/* 登录页 */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(160deg, #eaf4fb 0%, #f4f6f9 60%);
}

.login-card {
  width: 360px;
  max-width: calc(100vw - 32px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 28px 26px 26px;
}

.login-brand { text-align: center; margin-bottom: 20px; }
.login-brand h1 { margin: 12px 0 2px; font-size: 18px; }
.login-brand p { margin: 0; font-size: 12px; }

.login-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.login-logo.small { width: 30px; height: 30px; border-radius: 9px; font-size: 12px; }

/* 表单元素 */
.field { display: block; margin-bottom: 14px; }
.field > span, .field-label { display: block; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

input[type="text"], input[type="password"], input[type="url"], input[type="number"], textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; line-height: 1.55; }

input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(42, 171, 238, 0.14);
}

.check { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 13px; }
.check input { width: 15px; height: 15px; margin: 0; accent-color: var(--primary); }
.radio-row { display: flex; flex-wrap: wrap; gap: 16px; }
.radio { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.radio input { margin: 0; accent-color: var(--primary); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: #eef4f8; color: #17607f; }
.btn-secondary:hover:not(:disabled) { background: #e2edf4; }
.btn-ghost { border-color: var(--border); color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: #f7f9fb; color: var(--text); }
.btn-danger { color: var(--danger); border-color: #f2cfcd; }
.btn-danger:hover:not(:disabled) { background: #fdf3f2; }
.btn-block { width: 100%; padding: 10px; margin-top: 6px; }
.btn-mini { padding: 4px 9px; font-size: 12px; }

/* 顶栏与导航 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 22px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; }

.badge {
  padding: 2px 9px;
  border-radius: 20px;
  background: #eaf6fd;
  color: #17607f;
  font-size: 12px;
}

.tabs { display: flex; gap: 4px; padding: 12px 22px 0; }
.tab {
  padding: 7px 16px;
  border: 1px solid transparent;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}
.tab.active { background: #fff; border-color: var(--border); border-bottom-color: #fff; color: var(--text); font-weight: 600; }

.layout { padding: 12px 22px 32px; }
.panel-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; align-items: start; }

@media (max-width: 1080px) {
  .panel-grid { grid-template-columns: minmax(0, 1fr); }
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px 18px;
}
.card-narrow { max-width: 640px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-actions { display: flex; gap: 8px; }

.divider { height: 1px; background: var(--border); margin: 16px 0 12px; }

/* 表格 */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left;
  padding: 8px 10px;
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td { padding: 9px 10px; border-bottom: 1px solid #f0f3f7; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.col-ops { text-align: right; }
.cell-ops { text-align: right; white-space: nowrap; }
.cell-ops .btn { margin-left: 4px; }
.cell-action { max-width: 320px; word-break: break-all; color: var(--muted); }
.cell-title { font-weight: 600; }
.pos-cell { white-space: nowrap; color: var(--muted); }

.tag { display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 12px; }
.tag-link { background: #eaf6fd; color: #17607f; }
.tag-content { background: #eef7f0; color: #24704a; }
.tag-off { background: #f3f4f6; color: #7c8592; }

.switch { position: relative; display: inline-block; width: 38px; height: 21px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute;
  inset: 0;
  background: #d3dae3;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.15s;
}
.switch-track::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 15px;
  height: 15px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s;
}
.switch input:checked + .switch-track { background: var(--success); }
.switch input:checked + .switch-track::before { transform: translateX(17px); }

.empty { padding: 26px 0; text-align: center; color: var(--muted); }

/* 键盘预览 */
.keyboard-preview {
  background: #eef2f6;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kb-row { display: flex; gap: 6px; }
.kb-btn {
  flex: 1;
  padding: 9px 6px;
  background: #fff;
  border: 1px solid #dfe5ec;
  border-radius: 7px;
  text-align: center;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kb-btn.webapp { border-color: #bfe3f6; color: #17607f; }
.kb-empty { color: var(--muted); font-size: 12px; text-align: center; padding: 14px 0; }

.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; }

/* 弹窗 */
.dialog {
  width: 560px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 60px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(20, 33, 61, 0.22);
  color: var(--text);
  background: var(--card);
}
.dialog::backdrop { background: rgba(20, 33, 61, 0.42); }
.dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 60px); }
.dialog h2 { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.dialog-body { padding: 16px 20px; overflow-y: auto; }
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: #fbfcfd;
  border-radius: 0 0 14px 14px;
}

.upload-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.upload-row input[type="file"] { font-size: 12px; }
.image-preview { margin-top: 10px; }
.image-preview img { max-width: 100%; max-height: 220px; border-radius: 8px; border: 1px solid var(--border); }

.form-actions { margin-top: 8px; }

/* 轻提示 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 8px;
  background: #1c2536;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(20, 33, 61, 0.25);
  z-index: 100;
}
.toast.error-toast { background: var(--danger); }
