/* 财务流水归集系统 - 样式（深色主题，PC/手机自适应） */
:root {
  --bg: #0f1115;
  --bg-card: #171a21;
  --bg-input: #1f232d;
  --border: #2a2f3a;
  --text: #e8eaef;
  --text-dim: #9aa1ad;
  --primary: #4f8cff;
  --primary-dark: #3a6fd8;
  --green: #ef5350;      /* 涨红跌绿？此处为记账软件：收入=红系不合理，改用中国记账习惯：收入=红/暖，支出=绿 */
  --income: #e05a4e;
  --expense: #3fae7a;
  --danger: #e05a4e;
  --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: radial-gradient(1200px 600px at 50% -10%, #1c2536 0%, var(--bg) 60%);
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 28px;
  text-align: center;
}
.login-logo { font-size: 44px; }
.login-card h1 { font-size: 20px; margin: 10px 0 4px; }
.login-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 24px; }
.login-error { color: var(--danger); font-size: 13px; margin-top: 12px; }

/* ---------- 顶栏 & 页签 ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 18px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.app-title { font-weight: 700; font-size: 16px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-badge {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 12px; font-size: 13px; color: var(--text-dim);
}
.tabs {
  display: flex;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 49px; z-index: 19;
  overflow-x: auto;
}
.tab {
  flex: 1; min-width: 64px;
  padding: 12px 6px;
  background: none; border: none; color: var(--text-dim);
  font-size: 14px; cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.main { max-width: 960px; margin: 0 auto; padding: 16px; }
.view { display: flex; flex-direction: column; gap: 16px; }

/* ---------- 卡片 / 表单 ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.card-title { font-size: 16px; margin-bottom: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.field label em { color: var(--danger); font-style: normal; }
.field-hint { font-size: 12px; color: var(--text-dim); margin-top: 6px; line-height: 1.5; }
input, select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 15px;
  outline: none;
  font-family: inherit;
}
input:focus, select:focus { border-color: var(--primary); }
input[type="date"], input[type="month"] { min-height: 42px; }
select { min-height: 42px; }
input::placeholder { color: #5a616e; }
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator { filter: invert(0.8); }

.seg { display: flex; background: var(--bg-input); border-radius: 8px; border: 1px solid var(--border); overflow: hidden; min-height: 42px; }
.seg-item {
  flex: 1; border: none; background: none; color: var(--text-dim);
  font-size: 15px; cursor: pointer; font-family: inherit;
}
.seg-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }

/* ---------- 按钮 ---------- */
.btn {
  border: none; border-radius: 8px; cursor: pointer;
  font-size: 15px; padding: 10px 18px;
  font-family: inherit; transition: opacity .15s;
  min-height: 42px;
}
.btn:active { opacity: .8; }
.btn-primary { background: var(--primary); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: var(--bg-input); color: var(--text); border: 1px solid var(--border); }
.btn-sm { padding: 6px 12px; min-height: 34px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-danger-text { color: var(--danger); }

/* ---------- 筛选 ---------- */
.filter-bar, .stats-filter {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px;
}
.filter-bar input, .filter-bar select, .stats-filter input, .stats-filter select {
  width: auto; flex: 1; min-width: 120px;
}
.filter-bar .btn, .stats-filter .btn { flex: 0 0 auto; }
.stats-filter { margin-bottom: 0; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; padding: 8px 10px;
  color: var(--text-dim); font-weight: 500; font-size: 12px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td {
  padding: 9px 10px; border-bottom: 1px solid #1f232d;
  white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis;
}
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 12px;
}
.tag-income { background: rgba(224, 90, 78, .15); color: var(--income); }
.tag-expense { background: rgba(63, 174, 122, .15); color: var(--expense); }
.amount-in { color: var(--income); font-weight: 600; }
.amount-out { color: var(--expense); font-weight: 600; }
.row-actions { display: flex; gap: 8px; }
.link-btn { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 13px; font-family: inherit; }
.empty-tip { color: var(--text-dim); text-align: center; padding: 24px 0; font-size: 14px; }
.tip { color: var(--text-dim); font-size: 13px; margin-bottom: 14px; line-height: 1.6; }

/* ---------- 统计 ---------- */
.stat-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 6px;
}
.stat-label { font-size: 13px; color: var(--text-dim); }
.stat-value { font-size: 22px; font-weight: 700; }
.stat-card.income .stat-value { color: var(--income); }
.stat-card.expense .stat-value { color: var(--expense); }
.stat-card.net .stat-value { color: var(--primary); }
.stat-card.commission .stat-value { color: #d9a441; }

/* ---------- 设置 ---------- */
.settings-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.settings-head .card-title { margin-bottom: 0; }
.cfg-list { list-style: none; }
.cfg-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 4px; border-bottom: 1px solid #1f232d; font-size: 14px;
}
.cfg-list li:last-child { border-bottom: none; }
.cfg-list .cfg-tag { font-size: 12px; color: var(--text-dim); margin-left: 8px; }
.cfg-list .cfg-off { color: #6b7280; text-decoration: line-through; }
.cfg-list .cfg-empty { color: var(--text-dim); justify-content: center; padding: 16px 4px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, .6);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  width: 100%; max-width: 480px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; padding: 22px;
  max-height: 80vh; overflow-y: auto;
}
.modal h3 { font-size: 16px; margin-bottom: 12px; }
.modal p { font-size: 14px; color: var(--text-dim); line-height: 1.6; margin-bottom: 8px; }
.modal .dup-table { width: 100%; font-size: 13px; margin: 10px 0; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 60px; transform: translateX(-50%);
  background: #2b303c; color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 20px; border-radius: 10px;
  font-size: 14px; z-index: 200;
  box-shadow: 0 6px 24px rgba(0,0,0,.4);
}

/* ---------- 移动端适配 ---------- */
@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; }
  .stat-cards { grid-template-columns: 1fr; }
  .stat-value { font-size: 26px; }
  .main { padding: 12px; }
  .card { padding: 14px; }
  .table { font-size: 13px; }
  .tab { font-size: 13px; padding: 11px 4px; }
  /* 手机上流水表格隐藏次要列（12列：时间/方向/公司/账户/客户/项目/金额/销售/提成/备注/录入人/操作） */
  .table th:nth-child(4), .table td:nth-child(4),   /* 账户 */
  .table th:nth-child(9), .table td:nth-child(9),   /* 提成 */
  .table th:nth-child(10), .table td:nth-child(10), /* 备注 */
  .table th:nth-child(11), .table td:nth-child(11) { display: none; } /* 录入人 */
}

/* ===== 合同管理模块 ===== */
.cti-row {
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: var(--bg-soft, #f9fafb);
}
.cti-main { display: flex; gap: 8px; flex-wrap: wrap; }
.cti-main input { flex: 1 1 110px; min-width: 90px; }
.cti-attrs { margin-top: 6px; }
.cti-attr-list { display: flex; flex-direction: column; gap: 4px; }
.cti-attr { display: flex; gap: 6px; align-items: center; }
.cti-attr input { flex: 1 1 120px; padding: 5px 8px; font-size: 13px; }
.cti-attr .btn-sm { padding: 3px 8px; }
.ct-status { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; white-space: nowrap; }
.st-unpaid { background: #fee2e2; color: #b91c1c; }
.st-part { background: #fef3c7; color: #92400e; }
.st-paid { background: #dcfce7; color: #15803d; }
.cfg-user { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.perm-check { margin-left: 10px; font-size: 13px; white-space: nowrap; cursor: pointer; }
.perm-check input { width: auto; margin-right: 3px; }
@media (max-width: 640px) {
  .cti-main input { flex: 1 1 45%; }
  .perm-check { margin-left: 6px; }
}

/* ---------- 次卡台账 ---------- */
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.9); }
.card-prog { display: flex; align-items: center; gap: 8px; min-width: 150px; }
.card-prog-bar { flex: 1; height: 8px; min-width: 60px; background: var(--bg-input); border-radius: 6px; overflow: hidden; }
.card-prog-bar span { display: block; height: 100%; background: var(--primary); border-radius: 6px; transition: width .3s; }
.card-prog-bar span.low { background: var(--danger); }
.card-prog-num { font-size: 13px; white-space: nowrap; color: var(--text); }
.card-prog-num.low { color: var(--danger); font-weight: 600; }
.row-muted { opacity: .55; }
.note-cell { max-width: 260px; font-size: 13px; color: var(--text-dim); }
.muted { color: var(--text-dim); font-size: 12px; }
.ops { display: flex; gap: 6px; flex-wrap: wrap; }
.ops .btn-sm { min-height: 30px; padding: 4px 10px; }
@media (max-width: 640px) {
  .note-cell { max-width: 160px; }
  .card-prog { min-width: 120px; }
}

/* ---------- 体检结算模式 ---------- */
.ct-settle { margin-top: 10px; padding: 10px 12px; background: var(--bg-input); border-radius: 8px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.settle-grid { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; }
.settle-grid b { margin-left: 2px; }
.cti-main-tier input, .cti-main-tier .cti-amount { flex: 1 1 90px; min-width: 76px; }
.cti-main-tier .cti-name { flex: 1.4 1 110px; }
.cti-main-tier .cti-amount { flex: 0 0 96px; background: var(--bg-panel, rgba(0,0,0,.04)); }
@media (max-width: 640px) {
  .cti-main-tier input { flex: 1 1 45%; min-width: 0; }
  .settle-grid { gap: 4px 12px; }
}
