/* 桓晨财税 · 代账系统 样式
   全部颜色走 CSS 变量，改主色只改 :root 一处 */

:root {
  --bg: #f5f7f7;
  --panel: #ffffff;
  --panel-2: #fbfcfc;
  --line: #e3e8e8;
  --line-2: #eef1f1;
  --text: #1b2321;
  --text-2: #5b6866;
  --text-3: #8c9a97;
  --brand: #17604f;
  --brand-2: #114a3d;
  --brand-soft: #e8f2ee;
  --brand-line: #cfe4dc;
  --ok: #2c7a5a;
  --ok-soft: #e8f4ee;
  --warn: #9a6b1f;
  --warn-soft: #fbf1e0;
  --danger: #a83f39;
  --danger-soft: #fbeceb;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(27, 35, 33, .04), 0 8px 24px rgba(27, 35, 33, .05);
  --shadow-lg: 0 12px 40px rgba(27, 35, 33, .16);
  --mono: "SF Mono", "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ========== 图标 ========== */
.ico { width: 18px; height: 18px; display: inline-block; vertical-align: -3px; fill: none;
       stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ico.sm { width: 16px; height: 16px; }
.ico.lg { width: 22px; height: 22px; }

/* ========== 登录 ========== */
.login-wrap {
  min-height: 100%; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 420px at 50% -10%, var(--brand-soft), transparent 70%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 380px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px;
  padding: 34px 30px 26px; box-shadow: var(--shadow);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.login-brand h1 { font-size: 20px; letter-spacing: .5px; }
.login-brand p { margin: 3px 0 0; font-size: 12px; color: var(--text-3); }
.mark {
  width: 38px; height: 38px; border-radius: 10px; flex: none;
  background: var(--brand); color: var(--panel);
  display: flex; align-items: center; justify-content: center;
}
.mark svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--panel-2); color: var(--text);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand); background: var(--panel);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.login-error { min-height: 18px; color: var(--danger); font-size: 12.5px; margin-bottom: 6px; }
.login-hint { font-size: 11.5px; color: var(--text-3); text-align: center; margin: 14px 0 0; line-height: 1.6; }
.login-hint b { color: var(--text-2); font-weight: 600; }

/* ========== 主框架 ========== */
.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 216px; flex: none; background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
}
.side-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px 16px; border-bottom: 1px solid var(--line-2);
}
.side-brand .mark { width: 32px; height: 32px; border-radius: 9px; }
.side-brand-text strong { display: block; font-size: 14.5px; letter-spacing: .4px; }
.side-brand-text small { display: block; font-size: 11px; color: var(--text-3); margin-top: 1px; }

.nav { flex: 1; overflow-y: auto; padding: 10px 8px; }
.nav-group { font-size: 11px; color: var(--text-3); padding: 12px 10px 6px; letter-spacing: .6px; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer;
  color: var(--text-2); font-size: 13.5px; margin-bottom: 1px;
  border: none; background: none; width: 100%; text-align: left;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-item.active .ico { stroke-width: 1.9; }
.nav-badge { margin-left: auto; font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.nav-item.active .nav-badge { color: var(--brand); }

.side-foot { padding: 12px 16px 14px; border-top: 1px solid var(--line-2); }
.side-foot-row { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-2); }
.side-foot-sub { font-size: 11px; color: var(--text-3); margin-top: 4px; }
.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.dot.ok { background: var(--ok); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 58px; flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; background: var(--panel); border-bottom: 1px solid var(--line); gap: 16px;
}
.topbar-left { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.topbar-left h2 { font-size: 16px; white-space: nowrap; }
.page-sub { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 14px; }

.client-pick { display: flex; align-items: center; gap: 7px; }
.client-pick-label { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.client-pick select {
  padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel-2); color: var(--text); outline: none; max-width: 230px;
}
.client-pick select:focus { border-color: var(--brand); }

.user-chip { display: flex; align-items: center; gap: 8px; padding-left: 14px; border-left: 1px solid var(--line); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--brand-soft); color: var(--brand);
  display: flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 600;
}
.user-meta strong { display: block; font-size: 13px; }
.user-meta small { display: block; font-size: 11px; color: var(--text-3); }
.icon-btn {
  border: 1px solid transparent; background: none; color: var(--text-3); cursor: pointer;
  width: 28px; height: 28px; border-radius: 6px; display: inline-flex;
  align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); border-color: var(--line); }

.view { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 16px 20px 28px; }

/* ========== 通用组件 ========== */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px; border-bottom: 1px solid var(--line-2); gap: 12px;
}
.card-head h3 { font-size: 14px; }
.card-body { padding: 16px; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--panel); color: var(--text); cursor: pointer; font-size: 13px;
  transition: background .12s, border-color .12s, color .12s;
  white-space: nowrap;
}
.btn:hover { background: var(--panel-2); border-color: var(--line); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--panel); }
.btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: var(--line); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger-soft); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn.block { width: 100%; justify-content: center; padding: 10px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.input, .select {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--text); outline: none; font-size: 13px;
}
.input:focus, .select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.search-box { position: relative; }
.search-box .ico { position: absolute; left: 9px; top: 8px; color: var(--text-3); }
.search-box .input { padding-left: 31px; width: 210px; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th, table.grid td {
  padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line-2);
  white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis;
}
table.grid th {
  background: var(--panel-2); font-weight: 600; color: var(--text-2);
  font-size: 12.5px; position: sticky; top: 0; z-index: 1;
}
table.grid tbody tr { cursor: pointer; }
table.grid tbody tr:hover { background: var(--panel-2); }
table.grid tbody tr.selected { background: var(--brand-soft); }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12.5px; }
table.grid tfoot td { font-weight: 600; background: var(--panel-2); }

/* 标签 */
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11.5px; line-height: 1.6; white-space: nowrap;
  background: var(--panel-2); color: var(--text-2); border: 1px solid var(--line-2);
}
.tag.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.tag.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.tag.brand { background: var(--brand-soft); color: var(--brand); border-color: transparent; }

/* 统计卡 */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.stats.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1280px) { .stats.five { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 16px; box-shadow: var(--shadow);
}
.stat-label { font-size: 12.5px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 26px; font-weight: 600; margin-top: 6px; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 13px; font-weight: 400; color: var(--text-3); margin-left: 4px; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20, 28, 26, .38);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 48px 20px; z-index: 100; overflow-y: auto;
}
.modal {
  background: var(--panel); border-radius: 12px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 720px; border: 1px solid var(--line);
  animation: pop .16s ease-out;
}
.modal.wide { max-width: 940px; }
.modal.narrow { max-width: 460px; }
@keyframes pop { from { transform: translateY(-8px); opacity: 0 } to { transform: none; opacity: 1 } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 18px; border-bottom: 1px solid var(--line-2);
}
.modal-head h3 { font-size: 15px; }
.modal-body { padding: 18px; max-height: 66vh; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 9px;
  padding: 13px 18px; border-top: 1px solid var(--line-2); background: var(--panel-2);
  border-radius: 0 0 12px 12px;
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid label.ff { display: block; }
.form-grid label.ff > span { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 5px; }
.form-grid label.ff > span .req { color: var(--danger); margin-left: 2px; }
.form-grid input, .form-grid select, .form-grid textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--panel-2); color: var(--text); outline: none;
}
.form-grid textarea { min-height: 64px; resize: vertical; }
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus {
  border-color: var(--brand); background: var(--panel); box-shadow: 0 0 0 3px var(--brand-soft);
}

/* 标签页 */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tab {
  padding: 9px 14px; border: none; background: none; cursor: pointer;
  font-size: 13.5px; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* 空状态 */
.empty { padding: 48px 20px; text-align: center; color: var(--text-3); font-size: 13px; }
.empty .ico { width: 34px; height: 34px; stroke-width: 1.2; margin-bottom: 8px; color: var(--line); }

/* 金额着色 */
.amt-dr { color: var(--text); }
.amt-cr { color: var(--text-2); }
.pos { color: var(--ok); }
.neg { color: var(--danger); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 20px);
  background: var(--text); color: var(--panel); padding: 10px 18px; border-radius: 8px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 200;
  max-width: 70vw; box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger); }

/* 凭证分录编辑 */
.entry-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.entry-table th {
  font-size: 12px; color: var(--text-3); font-weight: 500; text-align: left;
  padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.entry-table td { padding: 4px 6px; }
.entry-table input, .entry-table select {
  width: 100%; padding: 6px 8px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--panel-2); outline: none; font-size: 13px;
}
.entry-table input:focus, .entry-table select:focus { border-color: var(--brand); background: var(--panel); }
.entry-table td.num input { text-align: right; font-family: var(--mono); }
.entry-foot { display: flex; align-items: center; gap: 18px; padding: 12px 8px 0; border-top: 1px solid var(--line-2); margin-top: 6px; }
.entry-foot .sum { font-size: 13px; color: var(--text-2); }
.entry-foot .sum b { font-family: var(--mono); color: var(--text); margin-left: 4px; }
.entry-foot .balance { margin-left: auto; font-size: 13px; }
.balance-tag { padding: 3px 10px; border-radius: 20px; font-size: 12px; }
.balance-tag.ok { background: var(--ok-soft); color: var(--ok); }
.balance-tag.bad { background: var(--danger-soft); color: var(--danger); }

/* 报表 */
.report-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 12px; flex-wrap: wrap; }
.report-title { font-size: 15px; font-weight: 600; }
.report-sub { font-size: 12px; color: var(--text-3); }
table.report { width: 100%; border-collapse: collapse; font-size: 13px; }
table.report th, table.report td { padding: 8px 12px; border-bottom: 1px solid var(--line-2); }
table.report th { background: var(--panel-2); font-size: 12.5px; font-weight: 600; color: var(--text-2); text-align: right; }
table.report th:first-child, table.report th:nth-child(2) { text-align: left; }
table.report td.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 12.5px; }
table.report tr.bold td { font-weight: 600; }
table.report tr.sub td { background: var(--panel-2); font-weight: 600; }
.bs-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) {
  .bs-cols { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* 明细账、余额表容器 */
.scroll-y { max-height: calc(100vh - 300px); overflow-y: auto; }

/* 进度条 */
.bar { height: 5px; border-radius: 3px; background: var(--line-2); overflow: hidden; width: 100%; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 3px; }

@media (max-width: 1100px) {
  .client-pick-label { display: none; }
  .user-meta { display: none; }
}
