/* 曼昆财务中台 · 月度经营看板（本地候选 v0.2）
   交互与 VI 参考飞书：浅色明亮、飞书蓝主色、圆角卡片、细边框、状态标签 */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #f5f6f7;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --line: #e5e6eb;
  --line-strong: #d0d3d9;
  --ink: #1f2329;
  --ink-2: #4e5969;
  --muted: #86909c;
  --faint: #c9cdd4;
  --blue: #3370ff;
  --blue-soft: #eaf2ff;
  --green: #00b365;
  --green-soft: #e8f7ef;
  --red: #f5475c;
  --red-soft: #ffecef;
  --orange: #ff7d00;
  --orange-soft: #fff4e8;
  --purple: #722ed1;
  --purple-soft: #f5eeff;
  --teal: #13c2c2;
  --teal-soft: #e6ffff;
  --amber: #ffb400;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(31, 35, 41, 0.05);
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
i { display: inline-block; vertical-align: middle; }

.app { max-width: 1440px; margin: 0 auto; padding: 0 28px 28px; }

/* ===== 顶栏 ===== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 4px 14px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 9px;
  background: linear-gradient(135deg, #ff9a3d, #ff6a00);
  color: #fff; font-size: 17px; font-weight: 800;
  display: grid; place-items: center;
  box-shadow: 0 3px 10px rgba(255, 106, 0, 0.28);
}
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: 0.2px; display: flex; align-items: center; gap: 8px; }
.version-badge {
  font-size: 10.5px; font-weight: 600; color: var(--blue); background: var(--blue-soft);
  border: 1px solid rgba(51, 112, 255, 0.25); border-radius: 6px; padding: 1px 7px;
  letter-spacing: 0.3px;
}
.brand-sub { font-size: 11px; color: var(--muted); margin-top: 2px; letter-spacing: 1px; }
.top-right { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.refresh-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); color: var(--ink-2); border: 1px solid var(--line-strong);
  border-radius: 8px; padding: 7px 14px; font-size: 13px; cursor: pointer;
  box-shadow: var(--shadow);
}
.refresh-btn:hover { color: var(--blue); border-color: var(--blue); }

/* ===== 月份切换（segmented，飞书风格） ===== */
.month-bar {
  display: flex; gap: 2px; flex-wrap: wrap;
  background: #eceef1; border-radius: 9px; padding: 4px;
  margin-bottom: 18px;
}
.month-btn {
  background: transparent; color: var(--ink-2); border: none;
  border-radius: 7px; padding: 7px 15px; font-size: 13px; cursor: pointer;
  transition: all 0.15s;
}
.month-btn:hover { color: var(--ink); }
.month-btn.active {
  background: var(--surface); color: var(--blue); font-weight: 600;
  box-shadow: 0 1px 3px rgba(31, 35, 41, 0.12);
}
.month-btn.year { margin-left: auto; }
.year-btn { color: var(--blue); font-weight: 600; }
.year-btn.active { background: var(--blue); color: #fff; }
.year-sep::before { content: '年份'; font-size: 11px; color: #86909c; margin-right: 2px; }
.year-sep { display: inline-flex; align-items: center; margin-right: 4px; }
.month-sep { width: 1px; background: #d7dae0; margin: 6px 8px; display: inline-block; }
.month-btn.year.active { background: var(--blue); color: #fff; }

/* ===== KPI（飞书卡片） ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 12px; margin-bottom: 18px; }
.kpi-card {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 14px; box-shadow: var(--shadow);
}
.kpi-ico {
  width: 36px; height: 36px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center;
}
.kpi-ico i { width: 18px; height: 18px; }
.ico-green { background: var(--green-soft); color: var(--green); }
.ico-blue { background: var(--blue-soft); color: var(--blue); }
.ico-red { background: var(--red-soft); color: var(--red); }
.ico-orange { background: var(--orange-soft); color: var(--orange); }
.ico-purple { background: var(--purple-soft); color: var(--purple); }
.ico-teal { background: var(--teal-soft); color: var(--teal); }
.kpi-body { min-width: 0; }
.kpi-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.kpi-value { font-size: 22px; font-weight: 700; letter-spacing: -0.2px; font-variant-numeric: tabular-nums; color: var(--ink); }
.kpi-value.pos { color: var(--green); }
.kpi-value.neg { color: var(--red); }
.kpi-sub { font-size: 11px; color: var(--muted); margin-top: 5px; }

/* ===== 区块 ===== */
.section { margin-bottom: 18px; }
.section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.section-head h2 { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 7px; }
.section-head h2 i { color: var(--blue); }
.section-note { font-size: 12px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 3px 9px; }
.section-hint { font-size: 11.5px; color: var(--faint); }

/* ===== 城市卡片（可点击） ===== */
.city-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.city-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
  cursor: pointer; transition: all 0.15s;
}
.city-card:hover { border-color: var(--blue); box-shadow: 0 4px 14px rgba(51, 112, 255, 0.14); transform: translateY(-1px); }
.city-name { font-size: 13px; font-weight: 700; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.city-name .city-link { display: inline-flex; align-items: center; gap: 4px; color: var(--blue); }
.city-name .city-link i { width: 13px; height: 13px; }
.city-name .tag { font-size: 11px; color: var(--blue); font-weight: 600; background: var(--blue-soft); border-radius: 5px; padding: 2px 7px; }
.city-rows { display: flex; flex-direction: column; gap: 6px; }
.city-row { display: flex; justify-content: space-between; font-size: 12.5px; }
.city-row .k { color: var(--muted); }
.city-row .v { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink-2); }
.city-row .v.pos { color: var(--green); }
.city-row .v.neg { color: var(--red); }

/* ===== 图表卡 ===== */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.card.wide { grid-column: 1 / -1; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card-title { font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.card-title i { width: 15px; height: 15px; color: var(--blue); }
.chart { height: 270px; }

/* ===== 明细表 ===== */
.tabs { display: flex; gap: 2px; background: #eceef1; border-radius: 8px; padding: 3px; }
.tab {
  background: transparent; color: var(--muted); border: none;
  border-radius: 6px; padding: 5px 14px; font-size: 12.5px; cursor: pointer;
}
.tab.active { background: var(--surface); color: var(--blue); font-weight: 600; box-shadow: 0 1px 2px rgba(31,35,41,0.1); }
.search-box {
  margin-left: auto; display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; padding: 6px 10px;
}
.search-box i { color: var(--faint); }
.search { border: none; outline: none; font-size: 12.5px; width: 220px; background: transparent; color: var(--ink); }
.search::placeholder { color: var(--faint); }

.table-wrap { overflow: auto; max-height: 480px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.detail-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.detail-table th {
  position: sticky; top: 0; background: var(--surface-2); color: var(--ink-2);
  text-align: left; padding: 10px 12px; font-weight: 600; white-space: nowrap;
  border-bottom: 1px solid var(--line); z-index: 1;
}
.detail-table th, .detail-table td { padding: 9px 12px; border-bottom: 1px solid #f0f1f3; color: var(--ink-2); white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.detail-table td.col-narrow { max-width: 150px; }
.detail-table td.col-client { max-width: 180px; }
.detail-table td.col-entity { max-width: 190px; }
.detail-table td.col-name { max-width: 120px; }
.detail-table td.col-flow { max-width: 150px; }
.detail-table td.col-cat { max-width: 160px; }
.detail-table td.col-payee { max-width: 150px; }
.detail-table tbody tr:hover { background: var(--surface-2); }
.detail-table .amt { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
.detail-table .amt.pos { color: var(--green); }
.detail-table .amt.neg { color: var(--red); }

/* 状态标签（飞书 pill） */
.status {
  display: inline-block; padding: 2px 9px; border-radius: 6px; font-size: 11.5px; font-weight: 500;
}
.status.green { background: var(--green-soft); color: var(--green); }
.status.blue { background: var(--blue-soft); color: var(--blue); }
.status.gray { background: #f2f3f5; color: var(--muted); }
.status.red { background: var(--red-soft); color: var(--red); }

/* 账户余额矩阵：统计卡 + 币种符号 + 城市标签 */
.acct-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.acct-stat { background: #fff; border: 1px solid #e5e6eb; border-radius: 12px; padding: 12px 14px; box-shadow: 0 1px 2px rgba(31,35,41,.04); }
.acct-stat-k { font-size: 11.5px; color: #86909c; margin-bottom: 5px; }
.acct-stat-v { font-size: 19px; font-weight: 700; color: #1d2129; font-variant-numeric: tabular-nums; letter-spacing: 0.2px; }
.acct-stat-v.blue { color: var(--blue); }
.acct-stat-v.amber { color: #ff7d00; }
.acct-stat-v.purple { color: #722ed1; }
.acct-stat-sub { font-size: 11px; color: #c9cdd4; margin-top: 3px; }
.detail-table th.th-cur { text-align: right; color: #4e5969; }
.detail-table th.th-cny { text-align: right; }
.acct-name { font-weight: 600; color: #1d2129; }
.city-pill { display: inline-block; background: #f2f3f5; color: #4e5969; border-radius: 5px; padding: 1px 8px; font-size: 11.5px; }
.detail-table .amt { text-align: right; }
.detail-table .amt-empty { color: #c9cdd4; }
.detail-table .amt.acct-cny { color: var(--blue); font-weight: 700; }
.acct-total td { background: #eef4ff; font-weight: 600; color: #1d2129; }
.acct-total td.acct-cny { color: var(--blue); font-size: 13px; }
/* 账户页操作按钮（飞书风格） */
.acct-actions { display: flex; gap: 10px; align-items: center; margin-left: 0; }
.btn-accent, .btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 8px; padding: 8px 18px; font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all 0.15s;
}
.btn-accent { background: var(--blue); border: 1px solid var(--blue); color: #fff; box-shadow: 0 2px 8px rgba(51,112,255,0.25); }
.btn-accent:hover { background: #2762e8; border-color: #2762e8; box-shadow: 0 3px 10px rgba(51,112,255,0.32); }
.btn-accent i, .btn-ghost i { width: 14px; height: 14px; }
.btn-ghost { background: #fff; border: 1px solid #d7dae0; color: #4e5969; }
.btn-ghost:hover { border-color: var(--blue); color: var(--blue); background: #f7faff; }

/* 账户余额修改面板 */
.acct-modal-mask { position: fixed; inset: 0; background: rgba(31,35,41,.45); z-index: 60; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(2px); }
.acct-modal { background: #fff; border-radius: 16px; padding: 24px 26px; width: 500px; max-width: 92vw; box-shadow: 0 16px 48px rgba(0,0,0,.24); }
.acct-modal-title { font-size: 16px; font-weight: 700; color: #1d2129; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.acct-modal-title::before { content: ''; width: 4px; height: 16px; background: var(--blue); border-radius: 2px; }
.acct-modal .field label { font-weight: 500; }
.acct-modal select:focus, .acct-modal input[type=number]:focus, .acct-modal textarea:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(51,112,255,.12);
}
.acct-modal .am-actions .btn { border-radius: 8px; padding: 8px 18px; font-size: 13px; }
.acct-modal .am-actions .btn.primary { box-shadow: 0 2px 8px rgba(51,112,255,.25); }
.acct-modal .field { margin-bottom: 12px; }
.acct-modal .field label { display: block; font-size: 12px; color: #4e5969; margin-bottom: 5px; }
.acct-modal .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.acct-modal select, .acct-modal input[type=number], .acct-modal textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; padding: 8px 10px; box-sizing: border-box; font-family: inherit; background: #fff;
}
.acct-modal textarea { min-height: 56px; }

@media (max-width: 900px) { .acct-stats { grid-template-columns: repeat(2, 1fr); } .records-head { flex-wrap: wrap; } .acct-actions { margin-left: 0; } }
.foot { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--muted); }


@media (max-width: 1320px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .city-grid { grid-template-columns: repeat(3, 1fr); }
  .chart-grid { grid-template-columns: 1fr 1fr; }
  .card.wide { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .city-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
  .search-box { width: 100%; margin-left: 0; }
  .search { width: 100%; }
  .month-btn.year { margin-left: 0; }
  .month-sep { margin: 6px 4px; }
}

/* ===== 城市二级详情页 ===== */
.kpi-card[data-kpi] { cursor: pointer; }
.kpi-card[data-kpi]:hover { border-color: var(--blue); box-shadow: 0 4px 14px rgba(51, 112, 255, 0.14); transform: translateY(-1px); }
.city-detail { margin-bottom: 18px; }
.crumb { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 13px; }
.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); color: var(--ink-2); border: 1px solid var(--line-strong);
  border-radius: 8px; padding: 6px 12px; font-size: 12.5px; cursor: pointer; box-shadow: var(--shadow);
}
.back-btn:hover { color: var(--blue); border-color: var(--blue); }
.crumb-sep { color: var(--faint); }
.crumb-city { font-size: 16px; font-weight: 700; }
.crumb-month { font-size: 12px; color: var(--muted); background: var(--blue-soft); color: var(--blue); border-radius: 6px; padding: 3px 9px; font-weight: 600; }
.detail-head { margin-top: 20px; }

/* ===== 审批链接 / KPI 可点击 ===== */
.appr-link {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--blue); text-decoration: none; font-weight: 600; white-space: nowrap;
}
.appr-link:hover { text-decoration: underline; }
.appr-link i { width: 12px; height: 12px; }
.kpi-card.clickable { cursor: pointer; transition: all 0.15s; }
.kpi-card.clickable:hover { border-color: var(--blue); box-shadow: 0 4px 14px rgba(51, 112, 255, 0.14); transform: translateY(-1px); }
.kpi-card.clickable .kpi-label::after { content: " ↗"; color: var(--blue); font-size: 11px; }

/* 记录页头部 */
.records-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.records-title { font-size: 17px; font-weight: 700; }
.records-summary { font-size: 12.5px; color: var(--blue); background: var(--blue-soft); border-radius: 6px; padding: 4px 10px; font-weight: 600; }
.crumb-type { font-size: 13px; color: var(--ink-2); font-weight: 600; }
