/* ============================================================
   准抓 · 13F 站点样式
   基于 header.php 参考设计系统（stone 中性色 + 单一蓝色强调），
   保留原有版面结构（.content 左右分栏、.table、.charts、图例）。
   ============================================================ */

:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --bg-subtle: #f5f5f4;
  --border: #e7e5e4;
  --border-strong: #d6d3d1;
  --text: #1c1917;
  --text-2: #57534e;
  --text-3: #a8a29e;
  --primary: #2563eb;
  --primary-light: #eff6ff;
  --primary-hover: #1d4ed8;
  --green: #16a34a;
  --green-light: #f0fdf4;
  --red: #dc2626;
  --red-light: #fef2f2;
  --amber: #d97706;
  --amber-light: #fffbeb;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --yellow-highlight: #fffab7;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

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

/* ---------- 导航 ---------- */
.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  height: 56px;
  position: sticky; top: 0; z-index: 100;
}
.nav-brand {
  font-weight: 700;
  font-size: 1rem;
  margin-right: 2rem;
  color: var(--text);
  letter-spacing: -0.02em;
  text-decoration: none;
}
.nav-brand:hover { text-decoration: none; }
.nav-brand-13f {
  font-weight: 700;
  font-size: 1rem;
  margin-right: 2rem;
  color: var(--primary);
  letter-spacing: -0.02em;
  text-decoration: none;
}
.nav-brand-13f:hover { text-decoration: underline; }
.nav-sep { font-weight: 700; font-size: 1rem; color: var(--text-3); margin-right: 0.25rem; }
.nav-links { display: flex; gap: 0.25rem; flex: 1; }
.nav-links a {
  color: var(--text-2);
  text-decoration: none;
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s;
}
.nav-links a:hover { color: var(--text); background: var(--bg-subtle); text-decoration: none; }
.nav-links a.active { color: var(--text); background: var(--primary-light); }
.nav-user { font-size: 0.8125rem; color: var(--text-3); display: flex; align-items: center; gap: 0.625rem; }
.nav-user a { color: var(--text-2); text-decoration: none; }
.nav-user a:hover { color: var(--red); }
.nav-user .nav-name { color: var(--text-2); }
.nav-user .nav-name:hover { color: var(--primary); }
.nav-add { font-size: 0.8125rem; color: var(--text-2); text-decoration: none; }
.nav-add:hover { color: var(--primary); text-decoration: none; }
.nav-login {
  font-size: 0.8125rem;
  color: var(--text-2);
  text-decoration: none;
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}
.nav-login:hover { color: var(--primary); border-color: var(--primary); text-decoration: none; }

/* ---------- 设置页 Tabs ---------- */
.setting-tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; flex-wrap: wrap; }
.setting-tabs a {
  color: var(--text-2); text-decoration: none; font-size: 0.875rem; font-weight: 500;
  padding: 0.625rem 1rem; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.setting-tabs a:hover { color: var(--text); }
.setting-tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- 表单（设置页） ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.form-field label { display: block; font-size: 0.8125rem; color: var(--text-2); margin-bottom: 0.375rem; font-weight: 500; }
.form-field .req { color: var(--red); margin-left: 2px; }
.form-field input[type=text], .form-field input[type=file] {
  width: 100%; box-sizing: border-box; padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-size: 0.875rem;
  font-family: inherit;
}
.form-field input:focus { outline: none; border-color: var(--primary); }
.form-hint { font-size: 0.75rem; color: var(--text-3); line-height: 1.7; margin-top: 0.375rem; }
.form-hint a { color: var(--primary); }
.form-actions { margin-top: 1.25rem; display: flex; gap: 0.625rem; align-items: center; }

/* ---------- 弹窗（cusip 编辑） ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); display: none; align-items: center; justify-content: center; z-index: 100; }
.modal-mask.open { display: flex; }
.modal-box { background: #fff; border-radius: var(--radius); box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25); width: min(480px, 92vw); padding: 1.5rem; }
.modal-box h3 { margin: 0 0 1rem; font-size: 1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.625rem; margin-top: 1.25rem; }

/* ---------- 同步日志块（getcusip） ---------- */
.sync-step { background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.75rem 1rem; margin: 0.5rem 0; font-size: 0.8125rem; line-height: 1.8; }

@media (max-width: 640px) {
  .nav { padding: 0 0.75rem; flex-wrap: wrap; height: auto; min-height: 56px; padding-top: 0.375rem; padding-bottom: 0.375rem; }
  .nav-brand { margin-right: 0.75rem; line-height: 2; }
  .nav-links { flex-wrap: wrap; }
  .nav-links a { padding: 0.375rem 0.5rem; }
}

/* ---------- 布局 ---------- */
.container { max-width: 98%; margin: 0 auto; padding: 1.5rem 2rem 3rem; }

@media (max-width: 640px) {
  .container { padding: 1rem 0.75rem 2rem; }
}

/* 页面标题区 */
#summary { margin-bottom: 1rem; }
#summary h1 { font-size: 1.5rem; }
#summary h2 { font-size: 1rem; font-weight: 500; color: var(--text-2); }
#summary h5 { font-size: 0.85rem; font-weight: 400; color: var(--text-3); line-height: 1.8; }
#summary img { max-width: 180px; height: auto; }

/* 内容区：左侧表格 + 右侧图表（保留原有分栏结构） */
.content {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1.5rem;
  width: 100%;
}

/* 表格容器：横向滚动代替列挤压，从根本上避免长公司名遮挡相邻列 */
.table {
  flex: 4;
  min-width: 0;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.charts {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 300px;
}

/* ---------- 表格 ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}
th, td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
  overflow-wrap: break-word;
}
th {
  background: var(--bg-subtle);
  font-weight: 600;
  color: var(--text-2);
  font-size: 0.8125rem;
  white-space: nowrap;
}
tbody tr:last-child td, table tr:last-child td { border-bottom: none; }
tbody tr:hover td, table tr:hover td { background: var(--bg); }
td a, th a { color: var(--primary); }

/* 数字列右对齐（配合页面内 nth-child 规则使用） */
.num, .num td { text-align: right; }

/* ---------- 标题 ---------- */
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 0.75rem; }
h2 {
  font-size: 1.0625rem; font-weight: 600;
  margin-top: 0; margin-bottom: 0.75rem;
  padding-bottom: 0.5rem; border-bottom: 1px solid var(--border);
}
h3 { font-size: 1rem; font-weight: 600; }
h5 { font-size: 0.85rem; font-weight: 400; color: var(--text-3); }

/* ---------- 链接 / 图片 / 标记 ---------- */
a { color: var(--primary); }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }

mark {
  background-color: var(--yellow-highlight);
  color: var(--text);
  padding: 1px 5px;
  border-radius: 4px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* ---------- 按钮（兼容页面里 <a><button>… 的既有写法） ---------- */
button, .btn {
  display: inline-block;
  padding: 0.5rem 1.25rem;
  background: var(--surface);
  color: var(--text-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  line-height: 1.5;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}
button:hover, .btn:hover {
  color: var(--primary);
  border-color: var(--primary);
  text-decoration: none;
}
button:focus-visible, .btn:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.35);
  outline-offset: 1px;
}
.btn-primary, .btn-primary button, button.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover, .btn-primary button:hover, button.btn-primary:hover {
  color: #fff;
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}
a.btn-primary { color: #fff; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

/* ---------- 徽标（加仓 / 减仓 / 新进 / 清仓 等） ---------- */
.badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 3px;
  font-size: 0.6875rem;
  font-weight: 500;
  background: var(--bg-subtle);
  color: var(--text-2);
  white-space: nowrap;
}
.badge-blue  { background: var(--primary-light); color: var(--primary); }
.badge-green { background: var(--green-light); color: var(--green); }
.badge-red   { background: var(--red-light); color: var(--red); }
.badge-amber { background: var(--amber-light); color: var(--amber); }

/* ---------- 提示消息 ---------- */
.msg { padding: 0.625rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: 0.8125rem; }
.msg-ok   { background: var(--green-light); color: var(--green); border: 1px solid #bbf7d0; }
.msg-err  { background: var(--red-light); color: var(--red); border: 1px solid #fecaca; }
.msg-info { background: var(--primary-light); color: var(--primary); border: 1px solid #bfdbfe; }

/* ---------- 工具类 ---------- */
.muted { color: var(--text-3); }
.text-sm { font-size: 0.8125rem; }

/* ---------- 图表区（qr.php 右栏） ---------- */
.chart-container { width: 100%; }
.charts .chart-container { margin-bottom: 1.5rem; }
.text-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
  padding-bottom: 10px;
}
.text-container h3 { margin: 0; font-size: 0.9375rem; }

.piechart { margin-top: 5px; width: 100%; }
.piechart svg { display: block; width: 100%; height: auto; }
.piechart path { transition: opacity 0.15s ease; }
.piechart path:hover { opacity: 0.85; }

/* 图例：横向并排排列，超出面板宽度自动折行；单项内部不折行 */
#category_legend { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.legend-block { display: flex; align-items: center; white-space: nowrap; }
.legend-color {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 2px;
  margin-right: 6px;
  flex: none;
}
.legend-text { font-variant-numeric: tabular-nums; font-size: 0.8125rem; color: var(--text-2); white-space: nowrap; }

/* ---------- 首页 ---------- */
.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 1000px) {
  .home-grid { grid-template-columns: 1fr; }
}

.fund-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1rem;
}

.fund-card {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem 1rem;
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.fund-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}
.fund-logo {
  height: 44px;
  display: flex;
  align-items: center;
}
.fund-logo img { max-height: 44px; width: auto; max-width: 100%; }
/* 底部公司信息区（无边框版，manager.php 用） */
.fund-intro-plain { padding: 0.25rem 0 0; }
.fund-intro-plain img { max-height: 44px; width: auto; }
.fund-intro-plain p { font-size: 0.875rem; color: var(--text-2); line-height: 1.8; }
.fund-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.fund-star {
  font-size: 0.8125rem;
  color: var(--text-2);
}
.fund-star .star-label { color: var(--text-3); }
.fund-meta {
  margin-top: auto;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--text-2);
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  font-variant-numeric: tabular-nums;
}
.fund-meta .muted { color: var(--text-3); }

/* 右栏模块 */
.side-module {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem 1.25rem;
  margin-bottom: 1.5rem;
}
.side-module h2 { margin-bottom: 0.75rem; }
.side-module .sub { font-size: 0.75rem; color: var(--text-3); font-weight: 400; }

.module-list { list-style: none; }
.module-list li {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.375rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}
.module-list li:last-child { border-bottom: none; }
.module-list a { color: var(--text); flex: 1; min-width: 0; }
.module-list a:hover { color: var(--primary); }
.module-list .rank {
  color: var(--text-3);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  width: 1.25rem;
  flex: none;
}
.module-list .count {
  color: var(--text-2);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.module-list .count b { color: var(--primary); font-weight: 600; }

/* ---------- 股票详情页（cusip.php） ---------- */
/* 信息区不满宽，保持阅读舒适 */
.stock-profile { max-width: 44rem; margin-bottom: 2rem; }
.stock-title-row {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.stock-title-row h1 { margin: 0; }
.symbol-badge {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  padding: 0.125rem 0.625rem;
  border-radius: 4px;
}
.stock-price-box {
  margin-left: auto;
  font-size: 0.875rem;
  color: var(--text-2);
  white-space: nowrap;
}
.stock-price-box b { color: var(--text); font-variant-numeric: tabular-nums; }

/* 字段表：dt「中文名：」 dd「苹果」，行间发丝线分隔 */
.stock-facts {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  margin: 0 0 1.25rem;
}
.stock-facts dt {
  color: var(--text-3);
  font-size: 0.8125rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}
.stock-facts dt::after { content: "："; }
.stock-facts dd {
  margin: 0;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9375rem;
}

.holders-bar { margin-bottom: 0.5rem; }
.holders-bar .label { display: block; font-size: 0.8125rem; color: var(--text-3); margin-bottom: 0.5rem; }
.holders-bar .links { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.holders-bar .links a {
  color: var(--text-2);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.875rem;
  font-size: 0.8125rem;
  text-decoration: none;
}
.holders-bar .links a:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-light); }

.holding-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
  align-items: start;
}
.holding-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}
.holding-card h3 {
  font-size: 0.9375rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.holding-card h3 .latest {
  margin-left: auto;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-3);
}

/* ---------- 分页（shares.php 等） ---------- */
.pagination {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.25rem 0;
}
.pagination .page-info { font-size: 0.8125rem; color: var(--text-3); }
.pagination .page-links { display: flex; align-items: center; gap: 0.375rem; flex-wrap: wrap; }
.page-btn {
  display: inline-block;
  min-width: 2rem;
  padding: 0.25rem 0.625rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}
a.page-btn:hover { color: var(--primary); border-color: var(--primary); }
.page-btn.current {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
  font-weight: 600;
}
.page-gap { color: var(--text-3); padding: 0 0.125rem; }

/* ---------- 登录 ---------- */
.login-wrap { max-width: 24rem; margin: 3rem auto 0; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 2rem;
}
.login-card h1 { font-size: 1.25rem; margin-bottom: 0.25rem; }
.login-sub { color: var(--text-2); font-size: 0.875rem; margin-bottom: 1.5rem; }
.login-error { color: var(--red); font-size: 0.8125rem; margin-bottom: 0.75rem; }
.login-foot { margin-top: 1rem; text-align: center; font-size: 0.8125rem; color: var(--text-3); }

/* ---------- 表单 ---------- */
.field { margin-bottom: 1.1rem; }
.field label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-2);
}
.field input[type="text"],
.field input[type="password"],
.field select,
.field input[type="file"] {
  width: 100%;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.field input:focus,
.field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.875rem;
  color: var(--text-2);
  cursor: pointer;
}
.check input { accent-color: var(--primary); }

/* ---------- 响应式 ---------- */
@media (max-width: 800px) {
  .content { flex-direction: column; }
  .content > * { width: 100%; }
  .table { flex: none; width: 100%; }
  .charts { min-width: 0; }
}
