:root {
  --primary: #1f5fd6;
  --primary-dark: #164aad;
  --primary-soft: #e8f0ff;
  --sidebar: #0f1b2f;
  --sidebar-2: #16263f;
  --bg: #f2f4f8;
  --panel: #ffffff;
  --text: #1d2939;
  --muted: #667085;
  --line: #e4e9f1;
  --line-2: #eef2f8;
  --green: #0f9d58;
  --green-soft: #e7f7ee;
  --red: #d92d20;
  --red-soft: #feeceb;
  --orange: #f79009;
  --orange-soft: #fff4e5;
  --radius: 8px;
  --shadow: 0 8px 24px rgba(16, 24, 40, 0.08);
  --font: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 13px; color: var(--text);
  background: var(--bg); -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }
button { font-family: inherit; }

/* ============ 登录 ============ */
.login-screen {
  min-height: 100vh; display: grid; grid-template-columns: 480px 1fr;
  background: linear-gradient(120deg, #0c1830 0%, #173b78 55%, #1f5fd6 100%);
}
.login-panel {
  background: #fff; padding: 56px 54px; display: flex; flex-direction: column; justify-content: center;
}
.login-brand { display: flex; gap: 14px; align-items: center; margin-bottom: 38px; }
.brand-mark {
  width: 46px; height: 46px; border-radius: 12px; background: linear-gradient(135deg, #2f7bf0, #164aad);
  color: #fff; font-weight: 700; letter-spacing: 1px; display: grid; place-items: center; font-size: 17px;
  box-shadow: 0 8px 18px rgba(31, 95, 214, 0.35);
}
.brand-mark.small { width: 34px; height: 34px; border-radius: 9px; font-size: 13px; }
.login-brand h1 { font-size: 24px; letter-spacing: 2px; }
.login-brand p { color: var(--muted); font-size: 12px; margin-top: 4px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-form label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.login-form .input { height: 42px; font-size: 14px; }
.btn-block { width: 100%; height: 42px; font-size: 15px; letter-spacing: 4px; }
.login-hint { font-size: 11px; color: #98a2b3; line-height: 1.7; margin-top: 6px; }
.login-foot { margin-top: 40px; font-size: 11px; color: #98a2b3; }
.login-aside { display: flex; align-items: center; padding: 0 8vw; color: #fff; }
.aside-inner h2 { font-size: 30px; line-height: 1.45; font-weight: 600; letter-spacing: 1px; }
.aside-inner ul { margin: 28px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 14px; }
.aside-inner li { font-size: 14px; color: rgba(255, 255, 255, 0.82); padding-left: 22px; position: relative; }
.aside-inner li::before {
  content: ""; position: absolute; left: 0; top: 7px; width: 7px; height: 7px;
  border-radius: 50%; background: #6fa8ff; box-shadow: 0 0 0 4px rgba(111, 168, 255, 0.16);
}

/* ============ 应用框架 ============ */
.app { display: grid; grid-template-columns: 218px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, #0f1b2f, #142440); color: #cbd5e1;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { display: flex; gap: 10px; align-items: center; padding: 18px 18px 16px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { color: #fff; font-size: 15px; letter-spacing: 1px; }
.brand-text span { font-size: 10px; color: #7c8ba4; letter-spacing: 1px; text-transform: uppercase; }
.nav { flex: 1; overflow-y: auto; padding: 10px 10px 20px; }
.nav-group { margin-top: 12px; }
.nav-group-title { font-size: 10px; color: #6b7c96; letter-spacing: 2px; padding: 8px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 7px;
  color: #b9c6d9; cursor: pointer; font-size: 13px; margin-bottom: 2px; border: 1px solid transparent;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav-item.active { background: linear-gradient(90deg, rgba(47, 123, 240, 0.28), rgba(47, 123, 240, 0.08)); color: #fff; border-color: rgba(94, 154, 255, 0.25); }
.nav-item svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.7; flex: none; }
.nav-badge { margin-left: auto; background: var(--red); color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 9px; }
.sidebar-foot {
  padding: 12px 18px; border-top: 1px solid rgba(255,255,255,0.06); font-size: 11px; color: #7c8ba4;
  display: flex; align-items: center; gap: 8px;
}
.sidebar-foot .dot { width: 3px; height: 3px; border-radius: 50%; background: #4b5c76; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 58px; background: #fff; border-bottom: 1px solid var(--line); display: flex;
  align-items: center; justify-content: space-between; padding: 0 22px; position: sticky; top: 0; z-index: 20;
}
.topbar-left { display: flex; align-items: baseline; gap: 14px; min-width: 0; }
.topbar-left h2 { font-size: 17px; font-weight: 600; letter-spacing: .5px; }
.page-desc { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 8px; padding-left: 6px; }
.user-chip .avatar {
  width: 30px; height: 30px; border-radius: 50%; background: #e8f0ff; color: var(--primary);
  display: grid; place-items: center; font-weight: 600;
}
.user-chip strong { display: block; font-size: 12px; }
.user-chip small { display: block; font-size: 10px; color: var(--muted); }
.view { padding: 18px 22px 40px; min-width: 0; }

/* ============ 通用组件 ============ */
.input, .select, textarea.input {
  height: 30px; border: 1px solid #d5dce8; border-radius: 6px; padding: 0 10px;
  font-size: 12px; color: var(--text); background: #fff; outline: none; font-family: inherit;
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31, 95, 214, 0.1); }
textarea.input { height: auto; padding: 8px 10px; resize: vertical; }
.select-sm { height: 28px; font-size: 12px; }
.input:disabled { background: #f7f8fa; color: #98a2b3; }
.btn {
  height: 30px; padding: 0 14px; border-radius: 6px; border: 1px solid #d5dce8; background: #fff;
  color: #344054; font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap; transition: all .15s;
}
.btn:hover { border-color: #b7c3d6; background: #fafbfc; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.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: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #b42318; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: #f2f4f8; color: var(--text); }
.btn-sm { height: 26px; padding: 0 9px; font-size: 11px; }
.btn-link { border: none; background: none; color: var(--primary); cursor: pointer; font-size: 12px; padding: 0 5px; }
.btn-link.danger { color: var(--red); }
.btn-link:disabled { color: #b7c3d6; cursor: not-allowed; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(16,24,40,.03); }
.card-pad { padding: 16px 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid var(--line-2); }
.card-head h3 { font-size: 13px; font-weight: 600; }
.card-body { padding: 14px 16px; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }
.toolbar .input { height: 30px; }
.toolbar-label { font-size: 12px; color: var(--muted); }

.grid { display: grid; gap: 12px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }

.kpi { padding: 16px 18px; position: relative; overflow: hidden; }
.kpi .kpi-label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi .kpi-value { font-size: 24px; font-weight: 600; margin-top: 8px; letter-spacing: .3px; font-variant-numeric: tabular-nums; }
.kpi .kpi-foot { margin-top: 6px; font-size: 11px; color: var(--muted); }
.kpi .kpi-icon {
  position: absolute; right: 14px; top: 14px; width: 34px; height: 34px; border-radius: 9px;
  background: var(--primary-soft); color: var(--primary); display: grid; place-items: center;
}
.kpi .kpi-icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.kpi.green .kpi-icon { background: var(--green-soft); color: var(--green); }
.kpi.orange .kpi-icon { background: var(--orange-soft); color: var(--orange); }

/* 表格 */
.table-wrap { overflow: auto; border-radius: var(--radius); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 12px; background: #fff; }
table.tbl th, table.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line-2); text-align: left; white-space: nowrap; }
table.tbl th {
  background: #f7f9fc; color: #475467; font-weight: 600; font-size: 11px; position: sticky; top: 0; z-index: 1;
  border-bottom: 1px solid var(--line);
}
table.tbl tbody tr:hover { background: #f8faff; }
table.tbl tr.selected { background: #edf4ff; }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl td.center, table.tbl th.center { text-align: center; }
table.tbl tfoot td { background: #f7f9fc; font-weight: 600; border-top: 1px solid var(--line); }
table.tbl .indent-1 { padding-left: 26px; }
table.tbl .indent-2 { padding-left: 44px; }
table.tbl .indent-3 { padding-left: 62px; }
table.tbl .muted { color: var(--muted); }
.empty-state { padding: 44px 20px; text-align: center; color: #98a2b3; font-size: 12px; }
.empty-state strong { display: block; color: #667085; font-size: 13px; margin-bottom: 6px; font-weight: 500; }

.badge {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 4px;
  font-size: 11px; line-height: 1; white-space: nowrap;
}
.badge.gray { background: #f2f4f7; color: #475467; }
.badge.blue { background: #e8f0ff; color: #1f5fd6; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.orange { background: var(--orange-soft); color: #b54708; }
.badge.red { background: var(--red-soft); color: var(--red); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tab {
  padding: 9px 16px; font-size: 12px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px; background: none; border-top: none; border-left: none; border-right: none;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 5vh 20px; overflow-y: auto;
}
.modal {
  background: #fff; border-radius: 10px; width: 560px; max-width: 100%; box-shadow: 0 20px 50px rgba(0,0,0,.25);
  animation: pop .16s ease-out;
}
.modal.wide { width: 960px; }
.modal.xwide { width: 1180px; }
@keyframes pop { from { transform: translateY(-8px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 15px; font-weight: 600; }
.modal-close { border: none; background: none; font-size: 20px; color: #98a2b3; cursor: pointer; line-height: 1; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 11px; color: var(--muted); }
.form-field .input, .form-field .select { width: 100%; height: 32px; }
.form-field textarea.input { height: 64px; }
.form-field .hint { font-size: 10px; color: #98a2b3; }

/* 凭证录入 */
.voucher-head { display: grid; grid-template-columns: 90px 130px 150px 1fr; gap: 10px; margin-bottom: 12px; align-items: end; }
.voucher-head .form-field .input { height: 30px; }
.voucher-grid { width: 100%; border-collapse: collapse; font-size: 12px; }
.voucher-grid th {
  background: #f7f9fc; font-size: 11px; color: #475467; padding: 7px 6px; border: 1px solid var(--line);
  font-weight: 600; text-align: left;
}
.voucher-grid td { border: 1px solid var(--line-2); padding: 0; vertical-align: middle; }
.voucher-grid td input, .voucher-grid td select {
  width: 100%; height: 30px; border: none; outline: none; padding: 0 7px; font-size: 12px;
  background: transparent; font-family: inherit;
}
.voucher-grid td input:focus, .voucher-grid td select:focus { background: #f5f9ff; box-shadow: inset 0 0 0 1px var(--primary); }
.voucher-grid td.num input { text-align: right; font-variant-numeric: tabular-nums; }
.voucher-grid tfoot td { background: #f7f9fc; padding: 6px 8px; font-weight: 600; }
.voucher-grid tfoot .amount { text-align: right; font-variant-numeric: tabular-nums; }
.balance-tip { font-size: 12px; margin-top: 8px; display: flex; gap: 18px; align-items: center; }
.balance-tip .ok { color: var(--green); }
.balance-tip .bad { color: var(--red); }
.entry-actions { display: flex; gap: 8px; margin-top: 10px; }

.voucher-view-line { display: flex; justify-content: space-between; padding: 6px 0; font-size: 12px; border-bottom: 1px dashed var(--line-2); }
.voucher-view-line span:first-child { color: var(--muted); }

/* 报表 */
.report-table td.label { min-width: 260px; }
.report-table tr.bold td { font-weight: 600; background: #fafcff; }
.report-table tr.section td { background: #f2f5fa; font-weight: 600; }
.report-summary { display: flex; gap: 26px; padding: 10px 0 14px; font-size: 12px; color: var(--muted); }
.report-summary strong { color: var(--text); font-size: 15px; margin-left: 4px; }

/* 其它 */
.pill-status { display: inline-flex; align-items: center; gap: 5px; }
.pill-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.muted { color: var(--muted); }
.text-right { text-align: right; }
.text-danger { color: var(--red); }
.text-green { color: var(--green); }
.mono { font-family: Consolas, "Courier New", monospace; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt20 { margin-top: 20px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; } .mb16 { margin-bottom: 16px; }
.flex { display: flex; align-items: center; } .gap8 { gap: 8px; } .gap12 { gap: 12px; } .wrap { flex-wrap: wrap; }
.w100 { width: 100%; }
.page-section { margin-bottom: 16px; }
.section-title { font-size: 13px; font-weight: 600; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.section-title::before { content: ""; width: 3px; height: 13px; background: var(--primary); border-radius: 2px; }
.check-list { display: flex; flex-direction: column; gap: 8px; font-size: 12px; }
.check-item { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 6px; background: #fbfcfe; }
.check-item .ok { color: var(--green); font-weight: 600; }
.check-item .warn { color: var(--orange); font-weight: 600; }
.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.quick-card {
  border: 1px solid var(--line); border-radius: 8px; padding: 14px; display: flex; gap: 10px; align-items: center;
  cursor: pointer; background: #fff; transition: .15s;
}
.quick-card:hover { border-color: #b9cdf2; background: #fbfdff; box-shadow: 0 4px 14px rgba(31,95,214,.08); }
.quick-card .q-icon { width: 34px; height: 34px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }
.quick-card strong { display: block; font-size: 12px; }
.quick-card small { display: block; color: var(--muted); font-size: 10px; margin-top: 2px; }
.chart-bars { display: flex; align-items: flex-end; gap: 18px; height: 150px; padding: 10px 6px 0; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.chart-bar-group { display: flex; gap: 4px; align-items: flex-end; height: 100%; }
.chart-bar { width: 14px; border-radius: 3px 3px 0 0; background: #bcd3ff; min-height: 2px; transition: height .3s; }
.chart-bar.profit { background: #2f7bf0; }
.chart-label { font-size: 10px; color: var(--muted); }
.chart-legend { display: flex; gap: 16px; font-size: 11px; color: var(--muted); padding-left: 6px; }
.chart-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; }

/* Toast */
.toast-host { position: fixed; top: 18px; right: 18px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--primary); border-radius: 7px;
  box-shadow: var(--shadow); padding: 11px 16px; font-size: 12px; min-width: 220px; max-width: 420px;
  animation: slidein .18s ease-out;
}
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
.toast.warn { border-left-color: var(--orange); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* 打印 */
@media print {
  .sidebar, .topbar, .toolbar, .no-print { display: none !important; }
  .app { display: block; }
  .view { padding: 0; }
  .card { border: none; box-shadow: none; }
  body { background: #fff; }
  table.tbl th { background: #fff; }
}
