:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-subtle: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --green-bg: #ecfdf5;
  --green-fg: #047857;
  --amber-bg: #fffbeb;
  --amber-fg: #b45309;
  --red-bg: #fef2f2;
  --red-fg: #b91c1c;
  --blue-bg: #eff6ff;
  --blue-fg: #1d4ed8;
  --gray-bg: #f1f5f9;
  --gray-fg: #475569;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans Devanagari", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

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

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

/* 顶部导航栏 */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 16px;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  display: inline-block;
  flex-shrink: 0;
}

.role-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--blue-bg);
  color: var(--blue-fg);
}

.role-badge.role-admin {
  background: #ede9fe;
  color: #6d28d9;
}

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

/* 图1样式胶囊语言切换器 */
.lang-switch {
  display: inline-flex;
  background: #f1f5f9;
  padding: 3px;
  border-radius: 10px;
  gap: 2px;
}

.lang-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.lang-btn:hover {
  color: var(--text);
}

.lang-btn.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
}

/* 主容器与布局 */
.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 20px 56px;
}

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

.stack-lg {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

/* 登录视图 */
.login-wrap {
  max-width: 420px;
  margin: 64px auto 0;
}

.login-card {
  padding: 30px;
}

.login-heading {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 700;
}

.login-sub {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 13px;
}

/* 提示条 */
.notice-banner {
  background: var(--blue-bg);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  color: #1e40af;
}

.notice-icon {
  font-size: 18px;
  line-height: 1.2;
}

.notice-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 2px;
}

.notice-desc {
  font-size: 12.5px;
  color: #1d4ed8;
}

/* 统计卡片 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stats-grid.stats-two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stats-grid.stats-five {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
}

.stat-amber { color: var(--amber-fg); }
.stat-green { color: var(--green-fg); }
.stat-red { color: var(--red-fg); }
.stat-blue { color: var(--primary); }

/* 导航页签 */
.nav-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-tab {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-tab:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.nav-tab.active {
  background: var(--text);
  color: #ffffff;
  border-color: var(--text);
}

/* 表单 */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

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

.field-full {
  grid-column: 1 / -1;
}

.field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.field .req {
  color: var(--danger);
  margin-left: 2px;
}

input[type="text"],
input[type="password"],
input[type="url"],
input[type="search"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

/* 多图上传拖拽区 */
.upload-dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: 10px;
  background: var(--surface-subtle);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.upload-dropzone:hover,
.upload-dropzone.drag-over {
  border-color: var(--primary);
  background: var(--blue-bg);
}

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

.upload-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.preview-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.preview-item {
  position: relative;
  width: 88px;
  height: 88px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #f8fafc;
}

.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.preview-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 0;
  background: rgba(15, 23, 42, 0.78);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-remove:hover {
  background: var(--danger);
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

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

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-ghost:hover:not(:disabled) {
  background: #f8fafc;
  border-color: #94a3b8;
}

.btn-danger {
  background: var(--red-bg);
  color: var(--red-fg);
  border-color: #fecaca;
}

.btn-danger:hover:not(:disabled) {
  background: #fee2e2;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 6px;
}

.btn-xs {
  padding: 2px 7px;
  font-size: 11.5px;
  border-radius: 5px;
}

.btn-block {
  width: 100%;
}

/* 警告与提示 */
.alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  border: 1px solid transparent;
}

.alert-error {
  background: var(--red-bg);
  color: var(--red-fg);
  border-color: #fecaca;
}

.alert-ok {
  background: var(--green-bg);
  color: var(--green-fg);
  border-color: #a7f3d0;
}

.alert-warn {
  background: var(--amber-bg);
  color: var(--amber-fg);
  border-color: #fde68a;
}

/* 工具条与筛选 */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

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

.pill-tabs {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pill-tab {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.pill-tab.active {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

.search-input {
  width: 240px !important;
}

.filter-select {
  width: auto !important;
  min-width: 140px;
}

/* 表格 */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

.data-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
  white-space: nowrap;
}

.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.data-table tbody tr:hover {
  background: #fafcff;
}

.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--muted);
}

/* 敏感信息单元 */
.secret-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 170px;
}

.secret-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.secret-label {
  font-size: 11px;
  color: var(--muted);
  min-width: 34px;
}

.secret-val {
  word-break: break-all;
}

.url-link {
  color: var(--primary);
  text-decoration: none;
  word-break: break-all;
  font-size: 12.5px;
  display: inline-block;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

.url-link:hover {
  text-decoration: underline;
}

/* 表格缩略图 */
.thumb-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 100px;
  max-width: 180px;
}

.thumb-btn {
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 44px;
  height: 44px;
  overflow: hidden;
  cursor: zoom-in;
  background: #f8fafc;
}

.thumb-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* 状态徽章 */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-pending { background: var(--amber-bg); color: var(--amber-fg); }
.badge-syncing { background: var(--blue-bg); color: var(--blue-fg); }
.badge-synced { background: var(--green-bg); color: var(--green-fg); }
.badge-failed { background: var(--red-bg); color: var(--red-fg); }
.badge-cancelled { background: var(--gray-bg); color: var(--gray-fg); }
.badge-locked { background: var(--gray-bg); color: var(--gray-fg); }

.action-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* 分页 */
.pagination {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* 弹窗 & 灯箱 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 86vh;
  overflow: auto;
  padding: 22px;
  box-shadow: var(--shadow-lg);
}

.modal-lg {
  max-width: 780px;
}

.lightbox-wrap {
  position: relative;
  max-width: 92vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.lightbox-img {
  max-width: 88vw;
  max-height: 78vh;
  border-radius: 10px;
  background: #0f172a;
  box-shadow: var(--shadow-lg);
}

.lightbox-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #ffffff;
  font-size: 13px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 80;
}

.emp-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.code-inline {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  font-weight: 600;
}

@media (max-width: 900px) {
  .stats-grid,
  .stats-grid.stats-five {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .form-grid,
  .emp-form {
    grid-template-columns: 1fr;
  }
  .search-input {
    width: 100% !important;
  }
}
