:root {
  --primary: #2b6cf6;
  --primary-dark: #1d55d0;
  --primary-light: #eaf1ff;
  --navy: #10284f;
  --navy-2: #0d213f;
  --text: #1f2d3d;
  --text-2: #5a6b80;
  --text-3: #93a1b3;
  --border: #e4e9f0;
  --bg: #f4f6fa;
  --card: #ffffff;
  --success: #15a06b;
  --success-light: #e7f7f0;
  --warning: #e8a317;
  --warning-light: #fff5e2;
  --danger: #e05050;
  --danger-light: #fdecec;
  --shadow: 0 2px 12px rgba(19, 42, 76, .06);
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button, input, select, textarea { font-family: inherit; }
a { cursor: pointer; text-decoration: none; color: inherit; }

/* ---------- 登录 ---------- */
.login-page {
  display: flex;
  min-height: 100vh;
  background: #fff;
}
.login-brand {
  width: 46%;
  min-width: 420px;
  padding: 90px 70px;
  color: #fff;
  background: linear-gradient(155deg, #1b4fa8 0%, #12336d 55%, #0d254f 100%);
  position: relative;
  overflow: hidden;
}
.login-brand::after {
  content: "";
  position: absolute;
  width: 520px; height: 520px;
  right: -220px; bottom: -220px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 0 0 60px rgba(255,255,255,.03), 0 0 0 120px rgba(255,255,255,.02);
}
.brand-logo {
  width: 56px; height: 56px; border-radius: 15px;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 700; margin-bottom: 28px;
}
.login-brand h1 { margin: 0; font-size: 40px; letter-spacing: 2px; font-weight: 600; }
.login-brand p { margin: 12px 0 42px; font-size: 16px; color: rgba(255,255,255,.72); }
.brand-points { list-style: none; padding: 0; margin: 0; }
.brand-points li { margin: 16px 0; padding-left: 26px; position: relative; color: rgba(255,255,255,.85); }
.brand-points li::before {
  content: "✓"; position: absolute; left: 0; top: 1px;
  width: 17px; height: 17px; border-radius: 50%;
  background: rgba(255,255,255,.18); font-size: 11px;
  display: flex; align-items: center; justify-content: center;
}
.brand-foot { position: absolute; bottom: 42px; color: rgba(255,255,255,.45); font-size: 13px; }
.login-panel { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px; }
.login-box { width: 100%; max-width: 380px; }
.login-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 30px; }
.login-tab {
  flex: 1; padding: 12px 0; border: 0; background: none;
  color: var(--text-2); font-size: 16px; cursor: pointer; position: relative;
}
.login-tab.active { color: var(--primary); font-weight: 600; }
.login-tab.active::after {
  content: ""; position: absolute; left: 20%; right: 20%; bottom: -1px;
  height: 3px; background: var(--primary); border-radius: 3px;
}
.auth-form label { display: block; margin: 16px 0 8px; font-weight: 600; color: var(--text-2); }
.auth-form input {
  width: 100%; height: 44px; border: 1px solid var(--border);
  border-radius: 8px; padding: 0 14px; outline: none; transition: .2s;
}
.auth-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 8px; }
.btn-block { width: 100%; height: 46px; margin-top: 8px; font-size: 15px; }
.demo-tip { margin-top: 20px; padding: 12px; background: var(--primary-light); color: #3759a8; border-radius: 8px; text-align: center; font-size: 13px; }
.login-note { margin-top: 26px; color: var(--text-3); font-size: 12px; }

/* ---------- 布局 ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 224px; flex: 0 0 224px; background: var(--navy);
  color: #d7e2f2; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-logo {
  height: 68px; display: flex; align-items: center; gap: 10px;
  padding: 0 20px; border-bottom: 1px solid rgba(255,255,255,.07);
}
.logo-mark {
  width: 34px; height: 34px; border-radius: 9px; background: var(--primary);
  display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff;
}
.logo-text { font-size: 17px; font-weight: 600; color: #fff; line-height: 1.15; }
.logo-text small { display: block; font-size: 10px; font-weight: 400; color: #8ea5c6; letter-spacing: .5px; }
.side-nav { flex: 1; padding: 12px 10px; }
.nav-group-title { font-size: 11px; color: #6f88ad; padding: 14px 12px 6px; letter-spacing: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  height: 40px; padding: 0 12px; margin: 2px 0;
  border-radius: 7px; color: #c5d3e8; position: relative; transition: .15s;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.nav-badge { margin-left: auto; background: var(--danger); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; font-style: normal; }
.sidebar-bottom { padding: 14px; border-top: 1px solid rgba(255,255,255,.07); }
.side-user { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #315b9c; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; }
.side-user-info b { display: block; color: #fff; font-size: 13px; }
.side-user-info small { color: #7f97ba; font-size: 11px; }

.main-wrap { flex: 1; min-width: 0; }
.topbar {
  height: 68px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px; position: sticky; top: 0; z-index: 20;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; }
.top-select {
  height: 36px; border: 1px solid var(--border); border-radius: 7px;
  padding: 0 30px 0 12px; background: #fff; color: var(--text);
  font-size: 14px; outline: none; cursor: pointer;
}
.period-select { background: var(--primary-light); border-color: #d3e2ff; color: var(--primary-dark); }
.company-label { font-size: 14px; color: var(--text-2); font-weight: 600; padding-left: 6px; border-left: 1px solid var(--border); margin-left: 6px; }
.icon-btn {
  height: 34px; padding: 0 12px; border: 1px solid var(--border);
  background: #fff; border-radius: 7px; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }
.main-content { padding: 24px 26px 40px; max-width: 1500px; margin: 0 auto; }

/* ---------- 通用组件 ---------- */
.btn {
  height: 36px; padding: 0 16px; border: 1px solid var(--border);
  background: #fff; color: var(--text); border-radius: 7px;
  cursor: pointer; font-size: 14px; display: inline-flex;
  align-items: center; justify-content: center; gap: 6px; transition: .15s;
}
.btn:hover { border-color: #bfcde0; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { background: #fff; color: var(--danger); border-color: #f3c6c6; }
.btn-danger:hover { background: var(--danger-light); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; gap: 16px; }
.page-title { margin: 0; font-size: 22px; font-weight: 600; }
.page-sub { margin: 6px 0 0; color: var(--text-2); font-size: 13px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 16px; font-weight: 600; }
.card-body { padding: 20px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.stat-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--primary); }
.stat-card.green::before { background: var(--success); }
.stat-card.orange::before { background: var(--warning); }
.stat-card.purple::before { background: #8b6ce8; }
.stat-label { color: var(--text-2); font-size: 13px; }
.stat-value { font-size: 26px; font-weight: 600; margin-top: 8px; letter-spacing: -.5px; }
.stat-foot { font-size: 12px; color: var(--text-3); margin-top: 6px; }

.dashboard-grid { display: grid; grid-template-columns: 1.45fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 1000px) { .dashboard-grid { grid-template-columns: 1fr; } }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.toolbar input, .toolbar select {
  height: 34px; border: 1px solid var(--border); border-radius: 7px;
  padding: 0 10px; outline: none; background: #fff;
}
.toolbar input:focus, .toolbar select:focus { border-color: var(--primary); }
.toolbar .grow { flex: 1; }

table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; padding: 12px 14px; background: #f8fafc;
  color: var(--text-2); font-weight: 600; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table td { padding: 11px 14px; border-bottom: 1px solid #eef1f5; }
.data-table tr:hover td { background: #f9fbff; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .center { text-align: center; }
.data-table .total-row td { background: #f5f8ff; font-weight: 600; border-top: 2px solid var(--primary-light); }
.table-wrap { overflow-x: auto; }
.empty { padding: 50px 20px; text-align: center; color: var(--text-3); }
.empty b { display: block; color: var(--text-2); margin-bottom: 6px; font-size: 15px; }

.tag { display: inline-block; padding: 2px 9px; border-radius: 12px; font-size: 12px; }
.tag-blue { background: var(--primary-light); color: var(--primary-dark); }
.tag-green { background: var(--success-light); color: var(--success); }
.tag-orange { background: var(--warning-light); color: #a46f00; }
.tag-gray { background: #f0f2f5; color: var(--text-2); }
.tag-red { background: var(--danger-light); color: var(--danger); }

.link-btn { color: var(--primary); cursor: pointer; background: none; border: 0; padding: 2px 5px; font-size: 13px; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }
.text-muted { color: var(--text-3); }
.text-right { text-align: right; }
.money-in { color: var(--danger); }
.money-out { color: var(--success); }

.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 20px; color: var(--text-2); font-size: 13px; }
.pagination button { height: 28px; min-width: 28px; border: 1px solid var(--border); background: #fff; border-radius: 5px; cursor: pointer; }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- 弹窗 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(10, 24, 45, .5); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 620px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal.wide { max-width: 940px; }
.modal.narrow { max-width: 440px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-close { border: 0; background: none; font-size: 22px; color: var(--text-3); cursor: pointer; line-height: 1; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; margin-bottom: 6px; color: var(--text-2); font-size: 13px; }
.field input, .field select, .field textarea {
  width: 100%; height: 38px; border: 1px solid var(--border); border-radius: 7px;
  padding: 0 11px; outline: none;
}
.field textarea { height: 70px; padding: 9px 11px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

/* 凭证录入 */
.voucher-meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.entry-table { width: 100%; border-collapse: collapse; }
.entry-table th { background: #f8fafc; padding: 10px; font-size: 13px; color: var(--text-2); border: 1px solid var(--border); }
.entry-table td { padding: 6px; border: 1px solid var(--border); }
.entry-table input, .entry-table select { width: 100%; height: 34px; border: 1px solid var(--border); border-radius: 6px; padding: 0 8px; outline: none; }
.entry-table input:focus, .entry-table select:focus { border-color: var(--primary); }
.entry-table .row-index { width: 42px; text-align: center; color: var(--text-3); }
.entry-table .row-op { width: 54px; text-align: center; }
.entry-table .amt { text-align: right; }
.voucher-total { display: flex; align-items: center; justify-content: space-between; padding: 14px 4px 4px; font-size: 14px; }
.voucher-total b { font-size: 17px; }
.balance-ok { color: var(--success); }
.balance-bad { color: var(--danger); }

/* 报表 */
.report-paper { background: #fff; padding: 30px 36px; }
.report-title { text-align: center; font-size: 22px; font-weight: 600; letter-spacing: 3px; margin-bottom: 6px; }
.report-meta { text-align: center; color: var(--text-2); font-size: 13px; margin-bottom: 22px; }
.report-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.report-table th, .report-table td { border: 1px solid #cfd8e3; padding: 8px 10px; }
.report-table th { background: #f3f6fa; font-weight: 600; text-align: center; }
.report-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.report-table tr.section td { background: #f8fafc; font-weight: 600; }
.report-table tr.subtotal td { font-weight: 600; background: #fbfcfe; }
.report-table tr.grand td { font-weight: 700; background: #eef4ff; }
.report-actions { display: flex; gap: 8px; }

/* 余额表 / 账簿 */
.ledger-head { display: flex; justify-content: space-between; align-items: baseline; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.ledger-head h3 { margin: 0; font-size: 16px; }
.indent-1 { padding-left: 22px !important; color: var(--text-2); }
.indent-2 { padding-left: 40px !important; color: var(--text-3); }

/* 图表 */
.chart-box { width: 100%; height: 230px; }
.chart-legend { display: flex; justify-content: center; gap: 22px; font-size: 12px; color: var(--text-2); margin-top: 6px; }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }

.setting-section { margin-bottom: 18px; }
.setting-section h3 { margin: 0 0 14px; font-size: 16px; }
.tip-box { background: var(--warning-light); border: 1px solid #ffe1a8; color: #8a6100; padding: 12px 14px; border-radius: 8px; font-size: 13px; line-height: 1.6; }

.toast-root { position: fixed; top: 84px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: #fff; border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: 8px; padding: 12px 16px; box-shadow: 0 6px 24px rgba(0,0,0,.12);
  min-width: 230px; animation: slideIn .2s ease;
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

.ico { display: inline-block; width: 18px; text-align: center; font-style: normal; font-size: 14px; opacity: .9; }
.ico-home::before { content: "⌂"; }
.ico-voucher::before { content: "▤"; }
.ico-account::before { content: "☰"; }
.ico-opening::before { content: "◫"; }
.ico-book::before { content: "▥"; }
.ico-balance::before { content: "⚖"; }
.ico-report::before { content: "▦"; }
.ico-setting::before { content: "⚙"; }

@media print {
  .sidebar, .topbar, .page-actions, .report-actions, .toolbar, .toast-root { display: none !important; }
  .main-content { padding: 0; max-width: none; }
  .card { border: 0; box-shadow: none; }
  .report-paper { padding: 0; }
  body { background: #fff; }
}
@media (max-width: 760px) {
  .sidebar { width: 64px; flex-basis: 64px; }
  .logo-text, .nav-item span, .nav-group-title, .side-user-info { display: none; }
  .nav-item { justify-content: center; }
  .login-brand { display: none; }
  .voucher-meta { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
