/* 黑底白字主题 | 中文微软雅黑 | 英文 Calibri */
:root {
  --bg: #0d0d0d;
  --bg-card: #1a1a1a;
  --bg-hover: #252525;
  --border: #333;
  --text: #e8e8e8;
  --text-muted: #999;
  --accent: #3b82f6;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --orange: #f97316;
  --market-open: #22c55e;
  --market-closed: #666;
}

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

html {
  overflow-x: hidden;
  max-width: 100%;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "微软雅黑", "Calibri", "Segoe UI", sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  max-width: 100vw;
}
img, canvas, iframe, table {
  max-width: 100%;
}
.container {
  width: 100%;
  max-width: 1280px;
  box-sizing: border-box;
}
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}
.grid-holdings {
  display: grid;
  grid-template-columns: 1.6fr 0.9fr;
  gap: 1.25rem;
}
@media (max-width: 900px) {
  .grid-holdings { grid-template-columns: 1fr; }
}
/* 行情弹窗 */
.tv-modal-mask {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
}
.tv-modal-mask.show { display: flex; }
.tv-modal {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 12px;
  width: min(960px, 96vw);
  max-height: 92vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.tv-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #333;
}
.tv-modal-body { height: min(560px, 70vh); }
.tv-modal-close {
  background: #333;
  border: none;
  color: #eee;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.2rem;
}

/* 交易新增/修改弹窗 */
.tx-form-modal {
  width: min(640px, 96vw);
  max-height: 92vh;
}
.tx-form-modal .tx-form-body {
  height: auto;
  max-height: min(75vh, 720px);
  overflow-y: auto;
}
.tx-confirm-modal {
  width: min(420px, 96vw);
  max-height: 92vh;
}
.tx-confirm-modal .tx-confirm-body {
  height: auto;
  padding: 1rem 1.1rem 1.25rem;
  overflow-y: auto;
}
.tx-summary-card {
  margin: 0 0 1rem;
  padding: 0.75rem 0 0.25rem;
  border-top: 1px solid var(--border);
}
.tx-summary-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.tx-summary-head h2 {
  margin: 0;
  font-size: 1.05rem;
}
.tx-summary-count {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* 筛选透视表 */
.pivot-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.pivot-table th,
.pivot-table td {
  border: 1px solid #333;
  padding: 0.4rem 0.55rem;
  white-space: nowrap;
}
.pivot-table thead th {
  background: #141414;
  font-weight: 600;
  text-align: center;
}
.pivot-table .pivot-corner {
  text-align: left;
  vertical-align: bottom;
  min-width: 72px;
}
.pivot-table .pivot-market.us {
  color: #93c5fd;
  background: #121820;
}
.pivot-table .pivot-market.cn {
  color: #fde68a;
  background: #1a1810;
}
.pivot-table .pivot-row-label {
  font-weight: 600;
  background: #141414;
}
.pivot-table tbody tr:hover td {
  background: #1f1f1f;
}
.pivot-table tbody tr:hover .pivot-row-label {
  background: #222;
}
.pivot-table .pivot-total td {
  background: #1c1c1c;
  font-weight: 700;
  border-top: 2px solid #555;
}
.pivot-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.symbol-link {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.symbol-link:hover { color: #60a5fa; }


/* 英文数字用 Calibri */
.en, .num, code, .symbol {
  font-family: "Calibri", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* 导航 */
.navbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar .brand {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}
.navbar .nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}
.navbar .nav-links a {
  color: var(--text-muted);
  padding: 0.35rem 0.6rem;
  border-radius: 4px;
  font-size: 0.95rem;
}
.navbar .nav-links a:hover,
.navbar .nav-links a.active {
  color: var(--text);
  background: var(--bg-hover);
  text-decoration: none;
}
.nav-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.nav-toggle {
  display: none;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-hover);
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  padding: 0;
  flex-shrink: 0;
}
.nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: #eee;
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
}
.nav-toggle.open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.nav-toggle.open span:nth-child(2) {
  opacity: 0;
}
.nav-toggle.open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* 时间与市场状态 — 原版样式，字号约 2 倍并加粗 */
.time-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  align-items: center;
  justify-content: center;
  padding: 1rem 1.5rem;
  background: linear-gradient(180deg, #141414 0%, #0f0f0f 100%);
  border-bottom: 1px solid var(--border);
}
.time-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  min-width: 180px;
}
.time-item .label {
  color: var(--text-muted);
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.time-item .time-value {
  font-family: "Calibri", "Segoe UI", sans-serif;
  font-size: 2.0rem;
  font-weight: 700;
  color: #f0f0f0;
  letter-spacing: 0.02em;
  line-height: 1.2;
}
.time-item .time-value.cn {
  color: #93c5fd;
}
.time-item .time-value.us {
  color: #86efac;
}
.market-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  font-size: 1.1rem;
  font-weight: 700;
}
.market-badge.open {
  background: rgba(34, 197, 94, 0.18);
  color: var(--market-open);
  border: 1px solid var(--market-open);
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.25);
}
.market-badge.closed {
  background: rgba(102, 102, 102, 0.2);
  color: var(--market-closed);
  border: 1px solid var(--market-closed);
}
.market-badge .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
@media (max-width: 600px) {
  .time-item .time-value { font-size: 1.45rem; }
  .time-bar { gap: 1rem; padding: 0.85rem 1rem; }
}

/* 趋势图周期按钮 */
.period-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.6rem;
}
.period-btns .btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.period-btns input[type="date"] {
  padding: 0.3rem 0.45rem;
  background: #111;
  border: 1px solid #333;
  border-radius: 4px;
  color: #eee;
  font-size: 0.85rem;
}

/* 布局 */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.25rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
@media (max-width: 900px) {
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }
}

/* 卡片 */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.card h2, .card h3 {
  margin-bottom: 0.85rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

/* 资金概览数字 */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.85rem;
}
.stat-item {
  background: #111;
  border-radius: 8px;
  padding: 0.75rem;
  text-align: center;
}
.stat-item .label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}
.stat-item .value {
  font-size: 1.15rem;
  font-weight: 600;
  font-family: "Calibri", sans-serif;
}
.stat-item .value.green { color: var(--green); }
.stat-item .value.red { color: var(--red); }
.stat-item .value.yellow { color: var(--yellow); }

/* 表格 */
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
th, td {
  padding: 0.55rem 0.7rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th {
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  background: #111;
  position: sticky;
  top: 0;
}
tr:hover td {
  background: var(--bg-hover);
}
td.num, th.num {
  text-align: right;
  font-family: "Calibri", sans-serif;
}
.symbol {
  font-weight: 600;
  color: var(--accent);
}
.name-cn {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-left: 0.3rem;
}
.pnl-pos { color: var(--green); }
.pnl-neg { color: var(--red); }

/* 按钮 */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-hover);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  transition: background 0.15s;
}
.btn:hover {
  background: #333;
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: #2563eb;
}
.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.8rem;
}
.btn-danger {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

/* 表单 */
.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  background: #111;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 600px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* 登录页 */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
}
.login-card h1 {
  text-align: center;
  margin-bottom: 0.5rem;
  font-size: 1.4rem;
}
.login-card .domain {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}
.error-msg {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--red);
  color: var(--red);
  padding: 0.6rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

/* 图表容器 */
.chart-container {
  position: relative;
  height: 320px;
  width: 100%;
}
.chart-container.tall {
  height: 400px;
}

/* 分页 */
.pagination {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}
.pagination a, .pagination span {
  padding: 0.35rem 0.7rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.pagination a:hover {
  background: var(--bg-hover);
  text-decoration: none;
}
.pagination .current {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* 工具条 */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}
.toolbar form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* 页脚 */
.footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

/* 空状态 */
.empty {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

/* 股票管理输入 */
.stock-input {
  padding: 0.3rem;
  background: #111;
  border: 1px solid #333;
  border-radius: 4px;
  color: #eee;
  max-width: 100%;
}
.stock-actions {
  white-space: nowrap;
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  align-items: center;
}
.owner-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  justify-content: space-between;
}
.owner-edit {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  flex: 1;
  min-width: 240px;
}
.owner-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

/* ========== 手机端自适应 ========== */
@media (max-width: 768px) {
  .navbar {
    padding: 0.65rem 0.85rem;
    flex-direction: column;
    align-items: stretch;
  }
  .nav-top {
    width: 100%;
  }
  .nav-toggle {
    display: inline-flex;
  }
  .navbar .nav-links {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    width: 100%;
    padding-top: 0.5rem;
  }
  .navbar .nav-links.open {
    display: flex;
  }
  .navbar .nav-links a {
    padding: 0.7rem 0.85rem;
    font-size: 1rem;
    border-radius: 8px;
  }

  .time-bar {
    gap: 0.65rem 1rem;
    padding: 0.7rem 0.75rem;
    justify-content: space-around;
  }
  .time-item {
    min-width: 0;
    flex: 1 1 40%;
  }
  .time-item .label {
    font-size: 0.7rem;
  }
  .time-item .time-value {
    font-size: 1.05rem;
    word-break: break-all;
  }
  .market-badge {
    font-size: 0.8rem;
    padding: 0.35rem 0.65rem;
  }
  .market-badge .dot {
    width: 7px;
    height: 7px;
  }

  .container {
    padding: 0.85rem 0.7rem;
  }
  .card {
    padding: 0.9rem;
    border-radius: 8px;
    margin-bottom: 0.9rem;
  }
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
  }
  .stat-item {
    padding: 0.6rem 0.45rem;
  }
  .stat-item .value {
    font-size: 1rem;
    word-break: break-all;
  }

  .table-wrap {
    margin: 0 -0.15rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  table {
    font-size: 0.8rem;
    min-width: 640px;
  }
  th, td {
    padding: 0.45rem 0.5rem;
  }
  .stocks-table {
    min-width: 720px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
  .toolbar {
    gap: 0.5rem;
  }
  .toolbar form {
    width: 100%;
  }
  .toolbar select,
  .toolbar input[type="text"] {
    flex: 1 1 auto;
    min-width: 0;
  }

  .chart-container {
    height: 240px;
  }
  .chart-container.tall {
    height: 280px;
  }
  .tv-modal {
    width: 100%;
    max-height: 95vh;
    border-radius: 10px;
  }
  .tv-modal-body {
    height: min(420px, 60vh);
  }
  .tx-form-modal .tx-form-body {
    max-height: min(80vh, 640px);
  }
  .footer {
    padding: 1rem 0.75rem;
    font-size: 0.75rem;
  }
}

@media (max-width: 400px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }
  .time-item .time-value {
    font-size: 0.95rem;
  }
}

