:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #d9e0ea;
  --brand: #1769aa;
  --brand-dark: #0f4f83;
  --warn: #b54708;
  --danger: #b42318;
  --ok: #067647;
  --shadow: 0 16px 40px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(180deg, #eef4fb 0, var(--bg) 360px);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
}

.app-shell {
  width: min(1380px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar,
.summary-grid {
  margin-bottom: 18px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.08;
}

h2 {
  font-size: 18px;
}

.account-chip {
  min-width: 128px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

.primary-button {
  height: 42px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.ghost-button {
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.ghost-button:hover {
  color: var(--danger);
  border-color: #f3b7b2;
  background: #fff7f6;
}

/* 顶栏右侧按钮组（日志查看 + 退出登录） */
.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* 非危险动作的 ghost 按钮（日志查看/返回仪表盘/刷新）：hover 走品牌蓝而非退出红 */
.ghost-button.logs-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.ghost-button.logs-link:hover {
  color: var(--brand-dark);
  border-color: var(--brand);
  background: #eef4ff;
}

/* ── 运行日志页（logs.php） ── */
.logs-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.logstatus-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.logstatus-card {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}

.logstatus-card h2 {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 6px;
}

.logstatus-card[data-state="ok"] {
  border-left-color: #12b76a;
}
.logstatus-card[data-state="warn"] {
  border-left-color: #f79009;
}
.logstatus-card[data-state="error"] {
  border-left-color: var(--danger);
}

.logstatus-line {
  font-size: 14px;
  font-weight: 800;
}

.logstatus-card[data-state="ok"] .logstatus-line {
  color: #067647;
}
.logstatus-card[data-state="warn"] .logstatus-line {
  color: var(--warn);
}
.logstatus-card[data-state="error"] .logstatus-line {
  color: var(--danger);
}

.logstatus-detail {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
}

.log-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.log-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.log-tabs {
  display: flex;
  gap: 8px;
}

.log-tab {
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.log-tab.active {
  background: linear-gradient(0deg, var(--brand) 0%, var(--brand-dark) 100%);
  border-color: var(--brand-dark);
  color: #fff;
}

.log-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}

.log-meta .ghost-button {
  height: 34px;
}

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

.log-table th {
  text-align: left;
  padding: 8px 14px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  border-bottom: 1px solid var(--line);
}

.log-table td {
  padding: 7px 14px;
  border-bottom: 1px solid #eef1f5;
  vertical-align: top;
  text-align: left; /* 覆盖旧版全局 th,td 数字右对齐 */
  white-space: normal; /* 覆盖旧版全局 nowrap，长消息允许换行 */
}

.log-table .col-time {
  width: 158px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.log-table .col-level {
  width: 84px;
}

.log-table .col-msg {
  word-break: break-all;
}

.lv-chip {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.lv-chip-ok {
  background: #dcfae6;
  color: #067647;
}
.lv-chip-done {
  background: #e0f2fe;
  color: #026aa2;
}
.lv-chip-info {
  background: #f2f4f7;
  color: #475467;
}
.lv-chip-warn {
  background: #fef0c7;
  color: #b54708;
}
.lv-chip-error {
  background: #fee4e2;
  color: #b42318;
}

tr.lv-error .col-msg {
  color: #b42318;
  font-weight: 600;
}
tr.lv-warn .col-msg {
  color: #b54708;
}

/* td.log-empty 提高优先级：压过 .log-table td 的 text-align:left（否则"加载中…"贴左边缘） */
.log-table td.log-empty {
  text-align: center;
  color: var(--muted);
  padding: 28px 0;
}

@media (max-width: 860px) {
  .logstatus-grid {
    grid-template-columns: 1fr;
  }
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-header span {
  color: var(--muted);
  font-size: 13px;
}

.metric-body {
  padding: 16px 18px;
}

.metric-body strong {
  display: block;
  font-size: clamp(20px, 3vw, 30px);
}

.mini-chart {
  margin-top: 16px;
}

.mini-pie-wrap {
  display: grid;
  grid-template-columns: 132px 1fr;
  align-items: center;
  gap: 18px;
}

.mini-pie {
  position: relative;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  box-shadow: 0 1px 5px rgba(23, 32, 51, 0.12);
}

.mini-pie-label {
  position: absolute;
  transform: translate(-50%, -50%);
  min-width: 38px;
  padding: 2px 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #172033;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  box-shadow: 0 1px 5px rgba(23, 32, 51, 0.16);
}

.mini-legend {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.mini-legend-row {
  display: grid;
  grid-template-columns: 10px minmax(48px, auto) 1fr 48px;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.mini-legend-row i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.mini-legend-row b {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-legend-row span {
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 负债行（如保证金借款导致的负现金）：金额带负号 + 红色，不进饼图扇区。
   曾经用 Math.abs 取绝对值展示，-1,803.31 显示成 $1,803.31，看着像账上真有这笔钱。 */
.mini-legend-row.negative b,
.mini-legend-row.negative span,
.mini-legend-row.negative em {
  color: var(--danger);
}

.mini-legend-row em {
  color: var(--brand-dark);
  font-style: normal;
  font-weight: 800;
  text-align: right;
}

.mini-empty {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.panel {
  margin-bottom: 18px;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1260px;
}

.compact table {
  min-width: 900px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid #edf1f6;
  font-size: 14px;
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: #475467;
  background: #f8fafc;
  font-size: 12px;
  font-weight: 800;
}

.sort-button {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  width: 100%;
  min-height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: inherit;
  cursor: pointer;
}

th:first-child .sort-button {
  justify-content: flex-start;
}

.sort-button::after {
  content: "-";
  color: #98a2b3;
  font-size: 11px;
}

.sort-button.active {
  color: var(--brand-dark);
}

.sort-button.active[data-direction="asc"]::after {
  content: "^";
  color: var(--brand-dark);
}

.sort-button.active[data-direction="desc"]::after {
  content: "v";
  color: var(--brand-dark);
}

td.negative {
  color: var(--danger);
  font-weight: 700;
}

td.positive {
  color: var(--ok);
  font-weight: 700;
}

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

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 8px;
  background: #eef2f6;
  color: #344054;
  font-size: 12px;
  font-weight: 800;
}

.tag.warn {
  background: #fff4e5;
  color: var(--warn);
}

.tag.danger {
  background: #fee4e2;
  color: var(--danger);
}

.tag.spread {
  background: #e6f0fa;
  color: #1769aa;
}

/* 组合持仓行：父行可点开，明细腿默认折叠（对齐 IBKR 持仓列表） */
.spread-row {
  cursor: pointer;
}

.spread-row:hover td {
  background: #f2f7fc;
}

.spread-row td:first-child {
  font-weight: 800;
}

/* 展开箭头：固定宽度，展开/收起时不抖动 */
.spread-arrow {
  display: inline-block;
  width: 12px;
  color: var(--muted);
  font-size: 11px;
}

/* 父行下方的合约摘要（IBKR 的 "SPY Oct 740/680 Bull Put" 那行小字） */
.spread-sub {
  display: block;
  margin-top: 2px;
  padding-left: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

/* 明细腿：缩进 + 无粗体，弱于父行 */
.spread-leg td {
  background: #fbfdff;
  font-size: 13px;
}

.spread-leg .leg-name {
  padding-left: 26px;
}

.spread-leg td.num {
  color: var(--muted);
}

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

.assignment-card strong {
  font-size: clamp(18px, 2.4vw, 26px);
}

.assignment-list {
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.total-row td {
  position: sticky;
  bottom: 0;
  border-top: 2px solid var(--line);
  background: #f8fafc;
  font-weight: 800;
}

/* ── NAV meta row (date + change + TWR) ── */
.nav-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.nav-change,
.nav-twr {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.nav-change {
  cursor: pointer;
  transition:
    transform 120ms ease,
    box-shadow 120ms ease;
}

.nav-change:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(23, 32, 51, 0.15);
}

.nav-change.positive,
.nav-twr.positive {
  background: #e6f9f0;
  color: var(--ok);
}

.nav-change.negative,
.nav-twr.negative {
  background: #fee4e2;
  color: var(--danger);
}

/* ── Income panel (dividend / loan) ── */
.income-panel {
  display: flex;
  gap: 18px;
  margin-bottom: 18px;
}

.income-col {
  flex: 1;
  min-width: 0;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.income-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.income-big {
  font-size: clamp(22px, 3vw, 32px);
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 10px;
}

.income-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.income-sub-label {
  font-size: 13px;
  color: var(--muted);
}

.income-sub-val {
  font-size: 13px;
  font-weight: 700;
  margin-left: auto;
}

.income-sub-val.positive {
  color: var(--ok);
}

.income-sub-val.negative {
  color: var(--danger);
}

.income-link-btn {
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition:
    background 120ms ease,
    border-color 120ms ease;
}

.income-link-btn:hover {
  background: #deeeff;
  border-color: #9bbfe0;
}

.income-link-btn.tax {
  color: var(--danger);
}

.income-link-btn.tax:hover {
  background: #fee4e2;
  border-color: #f3b7b2;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(23, 32, 51, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 10px;
}

.modal-card {
  width: min(90vw, 1400px);
  max-height: 92vh;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(23, 32, 51, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.modal-header h3 {
  font-size: 15px;
  margin: 0;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: #f1f5f9;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  line-height: 1;
  transition: background 120ms ease;
}

.modal-close:hover {
  background: #fee4e2;
  color: var(--danger);
}

.modal-body {
  overflow: auto;
  padding: 12px 16px;
  flex: 1;
  min-width: 0;
}

.modal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  table-layout: auto;
}

.modal-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #edf1f6;
  text-align: left;
  white-space: normal;
}

.modal-table th {
  padding: 7px 10px;
  border-bottom: 1px solid #edf1f6;
  text-align: left;
  background: #f8fafc;
  font-size: 11px;
  font-weight: 800;
  color: #475467;
}

.modal-table td.num {
  text-align: right;
  font-weight: 700;
  white-space: nowrap;
}

.modal-table th.num {
  text-align: right;
}

.modal-table td.desc-cell {
  white-space: normal;
  max-width: 420px;
  color: var(--muted);
  font-size: 11px;
}

.modal-table tr.symbol-subtotal td {
  background: #f0f7ff;
  font-weight: 800;
  border-top: 1px solid var(--line);
}

.modal-table tr.grand-total td {
  background: #172033;
  color: #fff;
  font-weight: 800;
  border-top: 2px solid var(--brand);
}

/* Sortable header links in modals */
.modal-sort {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.modal-sort:hover {
  color: var(--brand);
}

.div-type {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 800;
  background: #e6f9f0;
  color: var(--ok);
}

.div-type.tax {
  background: #fee4e2;
  color: var(--danger);
}

/* ── 净资产卡片标题行右侧（账号 chip + 报告日期） ── */
.nav-header-side {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-header-side .account-chip {
  min-width: 0;
  padding: 4px 10px;
  font-size: 12px;
}

/* ── 侧边浮动：年/月/日期三级筛选 + 数据源说明 ── */
.date-fab {
  position: fixed;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 30px rgba(23, 32, 51, 0.18);
  width: 168px;
}

.fab-select {
  width: 100%;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

/* 日期列表（size=6 滚动列表） */
.date-fab select[size] {
  height: auto;
  max-height: 148px;
  overflow-y: auto;
  padding: 4px;
}

.date-fab select[size] option {
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.date-fab select[size] option:checked {
  background: linear-gradient(0deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff;
  font-weight: 800;
}

.info-link {
  align-self: center;
  margin-top: 2px;
  padding: 3px 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition:
    background 120ms ease,
    color 120ms ease;
}

.info-link:hover {
  background: #eef4ff;
}

/* FIFO 未就绪等异常警示：提示链接转橙色 */
.info-link.warn {
  color: var(--warn);
}

.info-link.warn:hover {
  background: #fffaeb;
}

/* ── 数据源与提示说明弹窗 ── */
.info-card {
  width: min(92vw, 560px);
}

.info-block {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.info-block + .info-block {
  margin-top: 12px;
}

.info-block h4 {
  margin: 0 0 6px;
  font-size: 13px;
}

.info-block p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.info-block.warning {
  border-color: #f79009;
  background: #fffaeb;
}

.info-block.warning h4 {
  color: #b54708;
}

.logout-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.logout-link:hover {
  color: var(--danger);
}

/* ── 登录页 ── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(
      ellipse 80% 60% at 50% -10%,
      rgba(23, 105, 170, 0.13) 0%,
      transparent 60%
    ),
    linear-gradient(180deg, #eef4fb 0%, var(--bg) 400px);
}

.login-card {
  width: min(400px, 100%);
  padding: 44px 36px 36px;
  border-radius: 16px;
  background: var(--panel);
  box-shadow:
    0 24px 64px rgba(23, 32, 51, 0.12),
    0 2px 8px rgba(23, 32, 51, 0.06);
  text-align: center;
}

.login-icon {
  display: grid;
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #e8f2fc 0%, #d4e8f9 100%);
  color: var(--brand);
}

.login-title {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.login-subtitle {
  margin: 0 0 18px;
  font-size: 14px;
  color: var(--muted);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0;
}

.login-input-wrap {
  position: relative;
}

.login-input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  opacity: 0.55;
}

.login-input-wrap input {
  width: 100%;
  height: 48px;
  padding: 0 16px 0 44px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  color: var(--ink);
  background: #fafbfe;
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.login-input-wrap input:focus {
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(23, 105, 170, 0.12);
}

.login-input-wrap input::placeholder {
  color: #aab3c5;
}

.login-btn {
  width: 100%;
  height: 48px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition:
    opacity 140ms ease,
    transform 100ms ease,
    box-shadow 140ms ease;
  box-shadow: 0 4px 14px rgba(23, 105, 170, 0.28);
}

.login-btn:hover {
  opacity: 0.92;
  box-shadow: 0 6px 20px rgba(23, 105, 170, 0.36);
}

.login-btn:active {
  transform: scale(0.985);
}

.login-error {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--danger);
}

.login-card.has-error {
  animation: login-shake 0.38s ease;
}

@keyframes login-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-8px);
  }
  40% {
    transform: translateX(7px);
  }
  60% {
    transform: translateX(-5px);
  }
  80% {
    transform: translateX(4px);
  }
}

/* ── 日期面板浮动开关：桌面端默认隐藏（面板收起后显示），手机端常显 ── */
.fab-toggle {
  display: none;
  position: fixed;
  right: 12px;
  bottom: 16px;
  z-index: 950;
  align-items: center;
  gap: 6px;
  height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(0deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(15, 79, 131, 0.45);
  cursor: pointer;
}

/* 桌面端手动收起日期面板（笔记本小屏遮挡正文，2026-08-09 用户反馈） */
.date-fab.collapsed {
  display: none;
}

.fab-toggle.visible {
  display: inline-flex;
}

/* 面板顶部"收起"按钮 */
.fab-collapse {
  align-self: flex-end;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
}

.fab-collapse:hover {
  color: var(--ink);
}

@media (max-width: 900px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  /* income-panel 是 flex 容器：必须改 flex-direction（原 grid-template-columns 是死规则） */
  .income-panel {
    flex-direction: column;
  }

  /* 日期面板改底部弹出：默认收起，点右下角浮动按钮展开，不再遮挡正文 */
  .date-fab {
    top: auto;
    right: 12px;
    bottom: 72px;
    transform: none;
    display: none;
    width: 196px;
    max-height: min(60vh, 420px);
    overflow-y: auto;
    padding: 10px;
  }

  .date-fab.open {
    display: flex;
  }

  /* 手机端开关按钮常显（样式已上移到基础规则） */
  .fab-toggle {
    display: inline-flex;
  }

  .app-shell {
    width: calc(100% - 20px);
    padding: 16px 0 32px;
  }

  .table-wrap {
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 480px) {
  /* 饼图+图例小屏纵向堆叠，避免图例被压扁 */
  .mini-pie-wrap {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .mini-legend {
    width: 100%;
  }

  .panel-header,
  .metric-body {
    padding: 12px 14px;
  }
}
