/* ==========================================================================
   持仓记录系统 · 样式表
   设计令牌（颜色 / 圆角 / 阴影）集中在 :root，组件一律引用变量，不再散落硬编码色值。
   ========================================================================== */

/* ========== 全局重置 ========== */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

:root {
  /* 灰阶 */
  --gray-50:  #f8f9fa;
  --gray-100: #f1f3f5;
  --gray-200: #e9ecef;
  --gray-300: #dee2e6;
  --gray-400: #ced4da;
  --gray-500: #adb5bd;
  --gray-600: #868e96;
  --gray-700: #495057;
  --gray-800: #343a40;
  --gray-900: #212529;

  /* 表面与文字 */
  --surface: #ffffff;
  --surface-soft: var(--gray-50);
  --surface-hover: var(--gray-100);
  --border: var(--gray-300);
  --border-soft: var(--gray-200);
  --text: var(--gray-800);
  --text-muted: var(--gray-700);
  --text-subtle: var(--gray-600);
  --text-faint: var(--gray-500);

  /* 主色（#4c6ef5 对白底 4.6:1，达到 WCAG AA） */
  --primary: #4c6ef5;
  --primary-hover: #4263eb;
  --primary-active: #3b5bdb;
  --primary-disabled: #a5b8f5;
  --primary-soft: #edf2ff;
  --primary-border: #bac8f3;
  --on-primary: #ffffff;
  --ring: rgba(76, 110, 245, .35);

  /* 语义色 */
  --danger: #d6336c;
  --danger-strong: #c92a2a;
  --danger-soft: #fff0f3;
  --success: #2b8a3e;
  --success-soft: #ebfbee;
  --warn-text: #8a6100;
  --warn-soft: #fff9db;

  /* 圆角：仅 6 / 8 / 12 三档 */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;

  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(33, 37, 41, .06);
  --shadow: 0 2px 8px rgba(33, 37, 41, .08);
  --shadow-lg: 0 12px 32px rgba(33, 37, 41, .16);

  /* 版面宽度与 sticky 头部高度（由 JS 实测写入） */
  --page-max: 1400px;
  --header-h: 84px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}

body {
  /* 渐变只放在 body 一层，避免与 sticky 头部各算各的造成色带断层 */
  background: linear-gradient(180deg, #f4f6fb 0%, #e9edf5 100%) no-repeat;
  color: var(--text);
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ========== 通用工具类 ========== */
.u-hidden,
[hidden] { display: none !important; }
.row-inline { display: flex; align-items: center; gap: 8px; }
.input-flex { flex: 1; min-width: 0; }

/* 键盘可达性：统一 focus ring */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ========== 头部（两行：标题+搜索 / 栏目+工具栏） ========== */
.header-container {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border-soft);
}
.header-inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.header-row {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  flex-wrap: wrap;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.title {
  font-size: 1.15rem;
  font-weight: 650;
  color: var(--gray-900);
  letter-spacing: .2px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.title::before {
  content: "";
  width: 4px;
  height: 18px;
  border-radius: 2px;
  background: var(--primary);
}

/* ========== 搜索框（内嵌清空按钮 + 结果计数） ========== */
.search-wrap { position: relative; display: flex; align-items: center; }
.search-box {
  width: 280px;
  max-width: 100%;
  padding: 8px 32px 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.search-box:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
  outline: none;
}
.search-box::placeholder { color: var(--text-faint); }
.search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: var(--gray-200);
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.search-clear:hover { background: var(--gray-300); }
.count-chip {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-soft);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}

/* ========== 按钮体系（1 主 + 次级描边 + 幽灵） ========== */
.btn {
  padding: 8px 14px;
  min-height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  line-height: 1.2;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  background: var(--surface-soft);
  color: var(--text);
  white-space: nowrap;
}
.btn:hover { background: var(--surface-hover); }
.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { background: var(--primary-active); }
.btn-primary:disabled { background: var(--primary-disabled); }
.btn-outline {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-muted);
}
.btn-outline:hover {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary-active);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn-sm {
  padding: 4px 10px;
  min-height: 28px;
  font-size: 13px;
}
.btn-danger {
  background: var(--surface);
  border-color: var(--danger);
  color: var(--danger-strong);
}
.btn-danger:hover { background: var(--danger-soft); }

/* ========== 栏目 tabs ========== */
.category-tabs {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}
.category-tabs .btn {
  padding: 6px 14px;
  min-height: 32px;
  font-size: 13px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: grab;
  user-select: none;
  transition: all .15s;
}
.category-tabs .btn:hover {
  border-color: var(--primary-border);
  background: var(--primary-soft);
  color: var(--primary-active);
}
.category-tabs .btn.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}
.category-tabs .btn.is-dragging {
  opacity: .45;
  border-style: dashed;
}
.category-tabs .btn.drop-target {
  box-shadow: inset 2px 0 0 var(--primary);
}
.category-tabs .btn:active { cursor: grabbing; }

/* 工具栏：第二行右对齐 */
.toolbar {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
}

/* ========== 批量操作下拉菜单 ========== */
.batch-menu {
  position: relative;
  display: inline-flex;
}
.batch-menu-btn .caret {
  margin-left: 6px;
  font-size: 11px;
  color: var(--text-faint);
  display: inline-block;
  transition: transform .15s;
}
.batch-menu.is-open .batch-menu-btn {
  border-color: var(--primary-border);
  background: var(--primary-soft);
  color: var(--primary-active);
}
.batch-menu.is-open .caret { transform: rotate(180deg); }
.batch-menu-list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 200;
  min-width: 132px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.batch-menu-item {
  padding: 8px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 14px;
  line-height: 1.2;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.batch-menu-item:hover { background: var(--primary-soft); color: var(--primary-active); }
.batch-menu-item.is-disabled { color: var(--text-faint); }
.batch-menu-item.is-disabled:hover { background: var(--surface-soft); color: var(--text-faint); }

/* ========== 主体布局 ========== */
.content-wrapper {
  display: flex;
  gap: 20px;
  padding: 20px;
  max-width: var(--page-max);
  margin: 0 auto;
  flex: 1;
  width: 100%;
  min-height: 0;
  align-items: stretch;
}
/* 整页固定：列表在 .table-container 内单独滚动，页脚不再被表格压住 */
.main-content {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.side-cal {
  width: 240px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  align-self: flex-start;
  position: sticky;
  top: calc(var(--header-h) + 20px);
}
.side-cal h3 {
  font-size: 14px;
  margin: 0 0 8px;
  color: var(--text-muted);
}
.side-cal .search-box {
  width: 100%;
  padding: 7px 10px;
  margin-bottom: 8px;
}
.side-cal .mini-cal { max-width: 100%; }

/* ========== 表头工具条（全选 / 反选 / 计数） ========== */
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 13px;
  color: var(--text-muted);
}
.table-toolbar label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}
.table-toolbar { flex: 0 0 auto; }
.table-toolbar .spacer { flex: 1; }
.selection-info { color: var(--primary-active); font-weight: 500; }

/* ========== 表格 ========== */
.table-container {
  /* 列表自身的滚动窗口：表头在窗口内吸顶，页脚保持可见 */
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  border-radius: 0 0 var(--radius) var(--radius);
  overscroll-behavior: contain;
}
.table-container::-webkit-scrollbar { width: 10px; }
.table-container::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border: 2px solid var(--surface);
  border-radius: 6px;
}
.table-container::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }
.table-container::-webkit-scrollbar-track { background: transparent; }
#stockTable {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  table-layout: fixed;
  margin: 0;
  background: var(--surface);
  border-radius: 0 0 var(--radius) var(--radius);
}
thead th {
  padding: 10px 12px;
  text-align: center;
  color: var(--text-muted);
  font-weight: 600;
  /* 粘性表头：贴在滚动窗口顶部 */
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--border);
  user-select: none;
  overflow-wrap: anywhere;
}
th.sortable { cursor: pointer; padding-right: 28px; }
th.sortable:hover { color: var(--primary-active); }
th.col-check { width: 44px; padding-right: 12px; cursor: default; }
th.col-ops { width: 124px; cursor: default; }

td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-soft);
  text-align: center;
  color: var(--text);
  vertical-align: middle;
}
td small { color: var(--text-faint); font-size: 11px; }
.cell { display: block; overflow-wrap: anywhere; }
td.col-check { width: 44px; }
td.col-ops { width: 124px; padding-left: 6px; padding-right: 6px; }

/* 斑马纹 + hover 主色左描边 */
tbody tr:nth-child(even) { background: var(--surface-soft); }
tbody tr:hover {
  background: var(--primary-soft);
  box-shadow: inset 3px 0 0 var(--primary);
}
tbody tr.selected { background: var(--primary-soft); }
tbody tr.selected:hover { box-shadow: inset 3px 0 0 var(--primary-active); }
tbody tr:last-child td { border-bottom: none; }

/* 主表整行可点击跳转同花顺个股行情页：只有主表生效，不影响批量预览等其它表格 */
#stockTable tbody tr { cursor: pointer; }
#stockTable tbody td.col-check,
#stockTable tbody td.col-ops { cursor: default; }

.profit-positive { color: var(--danger-strong); font-weight: 600; }
.profit-negative { color: var(--success); font-weight: 600; }

/* 排序指示器：未排序 ⇅（灰色），排序后单侧箭头，右侧预留空间不压文字 */
th.sortable::after {
  content: "⇅";
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  line-height: 1;
  color: var(--gray-400);
}
th.sortable.asc::after { content: "▲"; color: var(--primary); }
th.sortable.desc::after { content: "▼"; color: var(--primary); }

/* 行内操作按钮（触控高度 ≥32px） */
.op-btn {
  margin: 0 2px;
  padding: 4px 8px;
  min-height: 32px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
}
.op-btn:hover {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary-active);
}
.op-btn.del { border-color: var(--danger); color: var(--danger-strong); }
.op-btn.del:hover { background: var(--danger-soft); }

/* 持仓表操作列：只显示图标，靠 title/aria-label 说明用途 */
td.col-ops { white-space: nowrap; }
td.col-ops .op-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  width: 32px;
  padding: 0;
  font-size: 15px;
  line-height: 1;
}

/* ========== 空态 ========== */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-subtle);
}
.empty-icon { font-size: 34px; line-height: 1; margin-bottom: 12px; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-desc { font-size: 13px; color: var(--text-subtle); margin-bottom: 16px; }
.empty-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.empty-state + .empty-state { margin-top: 8px; }

/* ========== 弹窗 ========== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(33, 37, 41, .45);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal.is-open { display: flex; }
.modal-content {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 22px 24px;
  box-shadow: var(--shadow-lg);
  animation: modal-in .18s ease-out;
}
.modal--sm { max-width: 380px; }
.modal--md { max-width: 440px; }
.modal--lg { max-width: 640px; }
.modal--center { text-align: center; }
.modal-header {
  font-size: 1.1rem;
  margin-bottom: 15px;
  padding-right: 28px;
  font-weight: 650;
  color: var(--gray-900);
}
.modal-close {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-subtle);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { background: var(--surface-hover); color: var(--text); }
.modal-buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 16px;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ========== 表单 ========== */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 24px;
  align-items: start;
}
.form-grid--1 { grid-template-columns: 1fr; }
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}
.form-group input,
.form-group select,
.form-group textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
  outline: none;
}
.form-group input[readonly] {
  background: var(--surface-soft);
  color: var(--text-subtle);
}
.form-group textarea {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
}
.tip-error {
  color: var(--danger-strong);
  font-size: 12px;
  margin-top: 8px;
}
.tip-error--block { margin: 8px 0; }

/* ========== 批量添加：解析预览 ========== */
.batch-parse-bar { flex-wrap: wrap; gap: 10px; }
.batch-parse-tip { font-size: 12px; color: var(--text-subtle); }
.batch-preview {
  margin-top: 4px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface-soft);
  max-height: 300px;
  overflow-y: auto;
}
.bp-head,
.bp-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  font-size: 13px;
}
.bp-head {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--gray-100);
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-muted);
  font-weight: 600;
}
.bp-row {
  background: var(--surface);
  border-bottom: 1px solid var(--border-soft);
}
.bp-row:last-child { border-bottom: none; }
.bp-check { flex: 0 0 20px; display: flex; justify-content: center; }
.bp-code { flex: 0 0 68px; font-variant-numeric: tabular-nums; }
.bp-name { flex: 1 1 84px; min-width: 0; overflow-wrap: anywhere; }
.bp-io { flex: 0 0 96px; min-width: 0; display: flex; align-items: center; gap: 6px; }
.bp-io input { width: 100%; min-width: 0; padding: 5px 7px; font-size: 13px; }
.bp-io-tag { display: none; flex: 0 0 auto; font-size: 12px; color: var(--text-subtle); }
.bp-note { flex: 2 1 128px; min-width: 0; color: var(--text-subtle); overflow-wrap: anywhere; }
.bp-row.is-warn { background: var(--warn-soft); }
.bp-row.is-warn .bp-note { color: var(--warn-text); }
.bp-row.is-bad { background: var(--danger-soft); }
.bp-row.is-bad .bp-note { color: var(--danger-strong); }
.bp-row.is-off { opacity: .6; }

@media (max-width: 768px) {
  .batch-preview { max-height: 260px; }
  .bp-head { display: none; }
  .bp-row { flex-wrap: wrap; gap: 6px 8px; padding: 9px 10px; }
  .bp-code { flex: 0 0 auto; font-weight: 600; }
  .bp-name { flex: 1 1 auto; }
  .bp-io { flex: 1 1 calc(50% - 8px); }
  .bp-io-tag { display: inline; }
  .bp-note { flex: 1 1 100%; font-size: 12px; }
}
.auth-links { text-align: center; margin-top: 8px; }
.link {
  font-size: 12px;
  color: var(--primary);
  text-decoration: none;
}
.link:hover { text-decoration: underline; }
.link-sep { margin: 0 6px; color: var(--gray-300); }
.auth-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  margin: 0 auto 16px;
}
.callout {
  margin: 12px 0;
  padding: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  word-break: break-all;
  text-align: left;
}
.callout-title { font-size: 12px; color: var(--text-faint); margin-bottom: 4px; }
.callout-link { font-size: 13px; color: var(--primary); word-break: break-all; }
.section-card {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 12px;
}
.section-card > .section-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-muted);
}
.user-id { margin: 8px 0; font-weight: 600; color: var(--text); text-align: center; }
.user-mail { margin: 4px 0 12px; font-size: 13px; color: var(--text-subtle); text-align: center; }
.progress-wrap { margin-bottom: 15px; }
.progress-label { font-size: 13px; color: var(--text-subtle); margin-bottom: 6px; }
.progress-track {
  width: 100%;
  height: 8px;
  background: var(--gray-200);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width .3s ease;
}
.modal-actions-center { margin-top: 15px; text-align: center; }
.modal-actions-right { margin-top: 8px; text-align: right; }
.hint { font-size: 12px; color: var(--text-subtle); margin-top: 4px; }
.stack-sm > * + * { margin-top: 8px; }

/* ========== 栏目管理列表 ========== */
#categoryList {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 24px;
  align-items: start;
}
#categoryList > div {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
#categoryList input {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--surface);
}
#categoryList input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
  outline: none;
}
#categoryList .op-btn.del { margin: 0; }

/* ========== 迷你日历 ========== */
#miniCal {
  display: grid;
  grid-template-columns: repeat(7, 26px);
  gap: 3px;
  justify-content: center;
  margin-top: 8px;
}
#miniCal > .cal-nav {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
#miniCal > .cal-nav button {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
#miniCal > .cal-nav button:hover { background: var(--primary-soft); }
#miniCal > .cal-title {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
  flex: 1;
}
#miniCal > .cal-weekday {
  width: 26px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  font-size: 11px;
  color: var(--text-subtle);
}
#miniCal > button {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
#miniCal > button:hover { border-color: var(--primary-border); background: var(--primary-soft); }
#miniCal > button.has {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
}
/* 已选日期 / 区间内日期 */
#miniCal > button.sel {
  background: var(--primary-active);
  border-color: var(--primary-active);
  color: var(--on-primary);
  font-weight: 700;
}
#miniCal > button.in-range {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary-active);
}

/* ========== 小眼睛密码框 ========== */
.pwd-box {
  position: relative;
  display: flex;
  align-items: center;
}
.pwd-box input {
  flex: 1;
  min-width: 0;
  padding-right: 36px;
}
.pwd-box .eye {
  position: absolute;
  right: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 18px;
  line-height: 1;
}

/* 屏蔽浏览器自动填充小眼睛/钥匙 */
input[type="password"]::-webkit-credentials-auto-fill-button,
input[type="password"]::-webkit-reveal,
input[type="password"]::-webkit-internal-reveal {
  visibility: hidden !important;
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

/* ========== 加载状态 ========== */
.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, .7);
  z-index: 2000;
  justify-content: center;
  align-items: center;
}
.loading-overlay.active { display: flex; }
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--gray-200);
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ========== 页脚 ========== */
.site-footer {
  text-align: center;
  padding: 12px 0 16px;
  font-size: 12px;
  color: var(--text-faint);
}

/* 版权信息中的作者链接：默认与文字同色，悬停时高亮并显示下划线 */
.footer-author {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.footer-author:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* ========== 响应式：1024 / 768 / 500 ========== */
@media (max-width: 1024px) {
  .content-wrapper { padding: 16px; gap: 16px; }
  .search-box { width: 220px; }
  .side-cal { width: 220px; }
}

@media (max-width: 768px) {
  :root { --header-h: 108px; }
  body { height: auto; min-height: 100vh; overflow: visible; }
  .main-content { display: block; overflow: visible; }
  .table-container { flex: none; overflow: visible; }
  .side-cal { align-self: auto; }
  .header-inner { padding: 8px 12px; gap: 6px; }
  .header-row { gap: 8px; }
  .title { font-size: 1.05rem; }
  .search-box { width: 100%; }
  .search-wrap { flex: 1; min-width: 140px; }
  .header-right { flex: 1 1 100%; }
  .toolbar { justify-content: flex-start; gap: 6px; }
  .btn { padding: 6px 10px; font-size: 13px; min-height: 32px; }
  .content-wrapper {
    flex-direction: column;
    padding: 12px;
    gap: 12px;
  }
  .side-cal { width: 100%; position: static; }

  /* 卡片化：取消多列表格，避免横向滚动 */
  #stockTable { display: block !important; table-layout: auto; }
  #stockTable.u-hidden { display: none !important; }
  #stockTable thead { display: none; }
  #stockTable tbody { display: block; padding: 10px 12px; }
  #stockTable tbody tr {
    display: block;
    position: relative;
    border: 1px solid var(--border-soft);
    border-left: 3px solid var(--primary-border);
    border-radius: var(--radius);
    background: var(--surface) !important;
    box-shadow: var(--shadow-sm);
    padding: 12px 12px 10px 36px;
    margin-bottom: 10px;
  }
  #stockTable tbody tr:last-child { margin-bottom: 0; }
  #stockTable tbody tr.selected {
    border-left-color: var(--primary);
    background: var(--primary-soft) !important;
  }
  #stockTable td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 3px 0;
    border-bottom: none;
    text-align: right;
    font-size: 13px;
  }
  #stockTable td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    text-align: left;
    font-size: 12px;
    color: var(--text-subtle);
  }
  #stockTable td .cell { text-align: right; }
  #stockTable td.col-check {
    position: absolute;
    left: 12px;
    top: 12px;
    display: block;
    width: auto;
    padding: 0;
  }
  #stockTable td.col-ops {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
    width: auto;
    margin-top: 8px;
    padding: 8px 0 0;
    border-top: 1px dashed var(--border-soft);
  }
  .op-btn { padding: 6px 10px; }
  #stockTable td.col-ops .op-btn { width: 36px; min-width: 36px; height: 36px; }
  .table-toolbar { padding: 8px 12px; }
  #categoryList { grid-template-columns: 1fr; }
  .user-profile-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 500px) {
  .form-grid { grid-template-columns: 1fr; }
  .modal-content { padding: 18px; }
  .count-chip { display: none; }
  .user-profile-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .modal-content,
  .loading-spinner,
  .progress-bar { animation: none !important; transition: none !important; }
}

/* ========== 用户画像模块 ========== */
.user-profile-card {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 15px;
  margin-bottom: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.user-profile-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.user-profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  font-size: 13px;
}
.user-profile-grid div {
  padding: 6px 8px;
  background: var(--surface-soft);
  border-radius: var(--radius-sm);
}
.recognition-5 { color: #e8590c; }
.recognition-4 { color: var(--success); }
.recognition-3 { color: var(--primary); }
.recognition-2 { color: #d9480f; }
.recognition-1 { color: var(--danger-strong); }
.visit-record-item {
  border-left: 3px solid var(--primary);
  padding: 10px;
  margin-bottom: 10px;
  background: var(--surface-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
#userProfileList, #visitRecordList {
  max-height: 400px;
  overflow-y: auto;
}
#profileSearch, #visitRecordContent { width: 70%; }
#visitRecordContent { margin-right: 8px; }
