/* ============================================================
   XHS · DATA TERMINAL
   HUD · Grid · Cyan · Amber
   ============================================================ */

:root {
  /* 底色 - 冷白系 */
  --bg-0: #FFFFFF;
  --bg-1: #F7FAFC;
  --bg-2: #FFFFFF;
  --bg-3: #F1F5F9;
  --bg-4: #E5EAF3;

  /* 主色 - 深蓝 */
  --cyan: #2563EB;
  --cyan-dim: #1D4ED8;
  --cyan-bright: #60A5FA;
  --cyan-soft: rgba(37, 99, 235, .09);
  --cyan-ghost: rgba(37, 99, 235, .045);

  /* 强调色 */
  --amber: #F59E0B;
  --amber-dim: #D97706;
  --magenta: #EF4444;
  --magenta-dim: #DC2626;
  --lime: #10B981;
  --lime-soft: rgba(16, 185, 129, .12);

  /* 文本 */
  --text: #0F172A;
  --text-mid: #334155;
  --text-dim: #64748B;
  --text-ghost: #94A3B8;

  /* 边线 */
  --line: rgba(37, 99, 235, .18);
  --line-dim: #E2E8F0;
  --line-strong: rgba(37, 99, 235, .32);
  --line-dotted: #CBD5E1;

  /* 字体 */
  --font-display: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Noto Sans SC", sans-serif;
  --font-hud: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Noto Sans SC", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --font-cn: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Noto Sans SC", sans-serif;

  /* 效果 */
  --glow-cyan: 0 14px 32px rgba(37,99,235,.18);
  --glow-cyan-soft: 0 8px 22px rgba(37,99,235,.10);
  --glow-amber: 0 8px 18px rgba(245,158,11,.14);
  --glow-magenta: 0 8px 20px rgba(239,68,68,.16);
  --shadow-sm: 0 1px 2px rgba(15,23,42,.05);
  --shadow-md: 0 14px 36px rgba(15,23,42,.08);

  /* 渐变 */
  --grad-primary: linear-gradient(135deg, #1D4ED8 0%, #2563EB 48%, #3B82F6 100%);
  --grad-primary-soft: linear-gradient(135deg, rgba(37,99,235,.09), rgba(14,165,233,.05));
  --grad-sidebar: linear-gradient(180deg, #FFFFFF 0%, #F8FAFC 100%);
}

/* ============ 基础 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; border-radius: 0 !important; }
html {
  font-size: 15.5px;
  height: 100%;
  overflow: hidden;
}
body {
  font-family: var(--font-cn);
  background: var(--bg-1);
  color: var(--text);
  line-height: 1.55;
  height: 100%;
  position: relative;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1, "ss01" 1;
}

::selection { background: var(--cyan); color: var(--bg-0); }

em, i, .title-it { font-style: normal !important; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
button, input, textarea, select { font-family: inherit; color: var(--text); }
*:focus { outline: none; }
*:focus-visible { outline: 1px solid var(--cyan); outline-offset: 2px; box-shadow: var(--glow-cyan-soft); }

#sidebarLogoutBtn:hover { color: var(--magenta) !important; border-color: var(--magenta) !important; }

.toast-stack {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast-item {
  max-width: min(460px, calc(100vw - 32px));
  padding: 9px 16px;
  background: rgba(17, 24, 39, .9);
  color: #F8FAFC;
  border: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 8px 24px rgba(15,23,42,.22);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  text-align: center;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  animation: toastIn .2s cubic-bezier(.2,.8,.3,1);
}
.toast-item .toast-ico { flex-shrink: 0; display: block; }
.toast-item.toast-success .toast-ico { color: #34D399; }
.toast-item.hide { animation: toastOut .18s ease-in forwards; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-8px); }
}

.app-dialog-mask {
  position: fixed;
  inset: 0;
  z-index: 5200;
  background: rgba(15,23,42,.28);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.app-dialog-mask.show { display: flex; }
.app-dialog {
  width: min(360px, 100%);
  background: #FFFFFF;
  border: 1px solid var(--line-dim);
  box-shadow: 0 18px 48px rgba(15,23,42,.18);
  padding: 18px;
  border-radius: 14px !important;
}
.app-dialog-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
}
.app-dialog-message {
  color: var(--text-mid);
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 14px;
}
.app-dialog-input {
  margin-bottom: 14px;
  border-radius: 10px !important;
}
.app-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.app-dialog .btn {
  border-radius: 10px !important;
}

/* ============ 文档页 ============ */
.docs-toc-item {
  display: block;
  padding: 8px 12px;
  border-left: 2px solid transparent;
  color: var(--text-mid);
  text-decoration: none;
  transition: all .15s;
  font-weight: 500;
  font-family: var(--font-cn);
  font-size: 13px;
  border-radius: 0 6px 6px 0;
}
.docs-toc-item:hover { background: var(--cyan-ghost); border-left-color: var(--cyan); color: var(--cyan-dim); }
.docs-toc-item.active { background: var(--cyan-soft); border-left-color: var(--cyan); color: var(--cyan-dim); font-weight: 600; }
.docs-content section { margin-bottom: 28px; scroll-margin-top: 24px; }
.docs-content section:last-child { margin-bottom: 0; }
.doc-h {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  padding-bottom: 8px;
  margin-bottom: 12px;
  border-bottom: 2px solid var(--cyan);
  display: inline-block;
}
.doc-h3 {
  font-family: var(--font-cn);
  font-size: 15px;
  font-weight: 600;
  color: var(--cyan-dim);
  margin: 14px 0 8px;
}
.docs-content p { margin-bottom: 10px; color: var(--text-mid); font-family: var(--font-cn); }
.docs-content ul, .docs-content ol { padding-left: 22px; margin-bottom: 10px; }
.docs-content li { margin-bottom: 5px; color: var(--text-mid); }
.docs-content code { font-family: var(--font-mono); background: var(--bg-3); padding: 1px 6px; border-radius: 4px; font-size: 12.5px; color: var(--cyan-dim); }
.docs-content strong { color: var(--text); font-weight: 700; }
.doc-table-wrap { overflow-x: auto; margin: 8px 0 10px; }
.doc-table { width: 100%; border-collapse: collapse; font-size: 13px; border: 1px solid var(--line-dim); border-radius: 8px; overflow: hidden; }
.doc-table th { padding: 8px 12px; background: var(--bg-3); text-align: left; font-family: var(--font-cn); font-weight: 600; color: var(--text-mid); border-bottom: 1px solid var(--line-dim); font-size: 12px; }
.doc-table td { padding: 7px 12px; border-bottom: 1px solid var(--line-dim); color: var(--text-mid); }
.doc-callout { display:flex; gap:10px; align-items:flex-start; padding:12px 14px; border-radius:8px; margin:12px 0; font-size:13px; line-height:1.7; }
.doc-callout-icon { flex-shrink:0; margin-top:1px; font-size:15px; }
.doc-callout.info { background:rgba(37,99,235,.06); border-left:3px solid var(--cyan); color:var(--text-mid); }
.doc-callout.tip { background:rgba(16,185,129,.07); border-left:3px solid var(--lime); color:var(--text-mid); }
.doc-callout.warn { background:rgba(245,158,11,.08); border-left:3px solid var(--amber); color:var(--text-mid); }
.doc-step-list { counter-reset:step; list-style:none; padding:0; margin:0; }
.doc-step-list li { counter-increment:step; display:flex; gap:14px; align-items:flex-start; padding:12px 0; border-bottom:1px solid var(--line-dim); }
.doc-step-list li:last-child { border-bottom:0; }
.doc-step-num { flex-shrink:0; width:26px; height:26px; border-radius:50%; background:var(--cyan); color:#fff; font-size:12px; font-weight:700; display:flex; align-items:center; justify-content:center; margin-top:1px; }
.doc-step-body { flex:1; }
.doc-step-body strong { display:block; font-size:14px; color:var(--text); margin-bottom:3px; }
.doc-step-body p { margin:0; font-size:13px; color:var(--text-dim); }
.doc-tag { display:inline-block; padding:1px 7px; border-radius:4px; font-size:11px; font-weight:600; margin-right:4px; }
.doc-tag.xhs { background:rgba(255,45,85,.10); color:#FF2D55; }
.doc-tag.dy { background:rgba(37,99,235,.10); color:var(--cyan-dim); }
.doc-tag.common { background:var(--bg-3); color:var(--text-dim); }
.doc-field-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:6px; margin:8px 0; }
.doc-field-chip { background:var(--bg-3); border:1px solid var(--line-dim); border-radius:6px; padding:5px 10px; font-size:12px; color:var(--text-mid); }
.doc-dl dt { font-family: var(--font-cn); font-weight: 600; color: var(--text); margin-top: 12px; margin-bottom: 4px; }
.doc-dl dt::before { content: ""; }
.doc-dl dd { margin-left: 0; padding-left: 14px; color: var(--text-mid); border-left: 2px solid var(--line-dim); }

/* 文档页：两列等高，整体撑满视口（扣除顶部 padding/标题/副标题约 180px） */
#page-docs.active { display: flex; flex-direction: column; }
#page-docs .two-col {
  align-items: stretch;
  height: calc(100vh - 180px);
  min-height: 420px;
}
#page-docs .two-col > .card {
  max-height: none !important;
  height: 100%;
  position: static !important;
  top: auto !important;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
#page-docs .two-col > .card > #docsToc { overflow-y: auto; }

/* ============ 全局触感增强（Micro-interactions） ============ */
/* 让可交互元素都有默认过渡 */
button, a, label, .nav-item, .card, .stat, .file-item, .task-card,
input, textarea, select, .tag, .tab-row .btn, .form-input, .form-textarea,
.auth-tab, .file-icon, .checkbox-wrap, .u-dropdown-item,
table tr, table td, th {
  transition-property: background-color, border-color, color, box-shadow, transform, filter, opacity;
  transition-duration: .18s;
  transition-timing-function: cubic-bezier(.3,.7,.3,1);
}

/* 卡片 hover */
.card { will-change: transform; }
.card:hover {
  border-color: rgba(37,99,235,.2);
  box-shadow: 0 4px 16px rgba(0,0,0,.06);
  transform: translateY(-1px);
}
.two-col .card:hover { transform: translateY(-1px); }

/* 统计块 hover */
.stat { cursor: default; }
.stat:hover {
  background: var(--bg-0);
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
  transform: translateY(-1px);
}

/* 数据中心任务卡片 hover */
.card[onclick]:hover { border-color: var(--cyan); box-shadow: 0 2px 12px rgba(8,145,178,.15); }

/* 表格行 hover */
.table tbody tr { position: relative; }
.table tbody tr:hover td {
  background: var(--cyan-ghost) !important;
}

/* 文件项 hover */
.file-item:hover {
  background: var(--cyan-ghost);
  transform: translateX(2px);
}
.file-item:hover .file-icon { border-color: var(--cyan); color: var(--cyan); }
.file-item:hover .file-name { color: var(--cyan-dim); }

/* 任务卡 hover */
.task-card { will-change: transform; }
.task-card:hover {
  transform: translateY(-1px);
  border-color: rgba(37,99,235,.25);
  box-shadow: 0 4px 12px rgba(0,0,0,.06);
}

/* button hover */
button:not(:disabled):hover { filter: brightness(1.01); }
.btn:not(:disabled):hover { transform: translateY(-1px); }
.btn:not(:disabled):active { transform: translateY(0); filter: brightness(.97); }

/* 输入框 hover */
.form-input:hover:not(:focus), .form-textarea:hover:not(:focus), select.form-input:hover:not(:focus) {
  border-color: var(--cyan);
}

/* 链接 hover */
a:hover { color: var(--cyan-dim); }

/* Tag hover */
.tag { transition: transform .15s, filter .15s; }
.tag:hover { transform: scale(1.03); }

/* 导航项 hover */
.nav-item { will-change: background-color, color; }
.nav-item:hover:not(.active) {
  background: var(--cyan-ghost);
  color: var(--cyan-dim);
}

/* Auth tab hover */
.auth-tab:hover:not(--active) { color: var(--cyan-dim); }

/* Checkbox hover */
.checkbox-wrap:hover { color: var(--cyan-dim); }
.checkbox-wrap:hover label { cursor: pointer; }

/* 表头 hover */
.table th:hover { background: var(--bg-4); cursor: default; }

/* 预览缩略图 hover */
.preview-thumb:hover { box-shadow: 0 4px 12px rgba(0,0,0,.15); }

/* 光标提示 */
.nav-item, .auth-tab, .btn:not(:disabled), .tab-row .btn, .modal-close,
.file-item, .task-card, .card-header button, .nav-item *,
.tag { cursor: pointer; }
.nav-item.active, .stat, .card { cursor: default; }

/* 卡片 header 按钮 hover */
.card-header button:hover { color: var(--cyan); }

/* input hover */
input:hover:not(:disabled):not(:focus),
textarea:hover:not(:disabled):not(:focus),
select:hover:not(:disabled):not(:focus) {
  background-color: var(--bg-0);
}

/* 关闭按钮 hover */
.modal-close:hover, #sidebarLogoutBtn:hover,
.banner-close:hover { transform: rotate(90deg); }

/* 尊重用户无障碍偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; }
}

/* ============ 预览弹窗增强 ============ */
.preview-table {
  font-size: 13px;
  background: var(--bg-0);
}
.preview-table thead th {
  background: var(--bg-3);
  color: var(--text-mid);
  font-size: 12px;
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-dim);
  white-space: nowrap;
}
.preview-table thead th.row-idx {
  width: 60px;
  text-align: center;
}
.preview-table tbody tr:nth-child(even) td { background: rgba(0,0,0,.015); }
.preview-table tbody tr:hover td { background: var(--cyan-ghost); }
.preview-table tbody td {
  padding: 9px 12px;
  max-width: 300px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
  border-bottom: 1px solid var(--line-dim);
  cursor: default;
}
.preview-table tbody td.row-idx {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  text-align: center;
  background: var(--bg-3);
  width: 60px;
}
.preview-table tbody td.expanded { white-space: normal; word-break: break-all; max-width: 600px; }
.preview-table tbody td.col-url { color: var(--cyan-dim); cursor: pointer; }
.preview-table tbody td.col-url:hover { color: var(--cyan); }
/* 展开链接：保持和折叠时同一列宽（不放大、不缩小），仅换行增高 */
.preview-table tbody td.col-url.expanded {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
  min-width: 300px;
  max-width: 300px;
}
/* 图片列：完整展示所有缩略图，允许换行 */
.preview-table tbody td.img-cell {
  white-space: normal;
  max-width: 480px;
  padding: 6px 8px;
  line-height: 0;
}
.preview-table tbody td.img-cell .preview-thumb { margin: 2px 4px 2px 0; }
/* 笔记正文列：完整显示，多行换行 */
.preview-table tbody td.content-cell {
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 780px;
  min-width: 420px;
  line-height: 1.65;
  padding: 10px 14px;
  cursor: text;
}
/* 预览界面里隐藏的列（如笔记ID）：完全不占位 */
.preview-table th.col-hidden,
.preview-table td.col-hidden { display: none !important; }
.preview-thumb {
  display: inline-block;
  width: 40px; height: 40px;
  object-fit: cover;
  border: 1px solid var(--line-dim);
  border-radius: 6px;
  vertical-align: middle;
  margin-right: 4px;
  cursor: zoom-in;
  transition: transform .15s, border-color .15s;
}
.preview-thumb:hover { transform: scale(1.08); border-color: var(--cyan); }
/* Lightbox 容器：默认隐藏，show 时铺满 */
#imgLightbox {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.86);
  z-index: 3000;
  justify-content: center; align-items: center;
  cursor: zoom-out;
}
#imgLightbox.show { display: flex !important; }
#imgLightboxImg {
  max-width: 90vw; max-height: 84vh;
  box-shadow: 0 10px 40px rgba(0,0,0,.6);
  cursor: default;
  border-radius: 4px;
}
.lb-arrow {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  color: #fff;
  width: 44px; height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .15s;
}
.lb-arrow:hover { background: rgba(255,255,255,.22); transform: translateY(-50%) scale(1.06); }
.lb-prev { left: 24px; }
.lb-next { right: 24px; }
.lb-toolbar {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px;
  background: rgba(20,20,20,.7);
  backdrop-filter: blur(6px);
  padding: 8px 14px;
  border-radius: 28px;
  cursor: default;
}
#lbCounter {
  color: rgba(255,255,255,.85);
  font-family: var(--font-mono, ui-monospace);
  font-size: 12px;
  letter-spacing: .04em;
  padding: 0 6px;
}
.lb-btn {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  color: #fff;
  padding: 5px 12px;
  font-size: 12px;
  border-radius: 16px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
  text-decoration: none;
  transition: background .15s;
}
.lb-btn:hover { background: rgba(255,255,255,.24); }
#csvSearchInput:focus { outline: none; border-color: var(--cyan); background: var(--bg-0); box-shadow: 0 0 0 3px var(--cyan-soft); }
.preview-highlight { background: rgba(255,181,71,.35); }

/* ============ 余额横幅 ============ */
.balance-banner {
  position: fixed;
  top: -100px; left: 0; right: 0;
  z-index: 2500;
  background: linear-gradient(90deg, #FFF1F2 0%, #FEE2E2 50%, #FFF1F2 100%);
  color: var(--text);
  padding: 12px 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-family: var(--font-hud);
  font-size: 13px;
  letter-spacing: .04em;
  border-bottom: 2px solid var(--magenta);
  box-shadow: 0 4px 20px rgba(239,68,68,.15);
  transition: top .5s cubic-bezier(.2,.8,.2,1);
}
.balance-banner.show { top: 0; }
.balance-banner::before {
  content: "⚠ ALERT";
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .3em;
  color: var(--magenta);
  margin-right: 6px;
  padding-right: 14px;
  border-right: 1px solid rgba(239,68,68,.3);
  animation: blink 1.5s infinite;
  font-weight: 600;
}
@keyframes blink { 50% { opacity: .45; } }
.balance-banner svg { width: 16px; height: 16px; color: var(--magenta); flex-shrink: 0; }
.balance-banner strong {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--magenta);
  padding: 0 4px;
}
.balance-banner .banner-close {
  position: absolute; right: 20px;
  width: 24px; height: 24px;
  border: 1px solid var(--magenta);
  background: #FFFFFF;
  color: var(--magenta);
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s;
}
.balance-banner .banner-close:hover {
  background: var(--magenta); color: #FFFFFF;
  box-shadow: var(--glow-magenta);
}

