:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e4e7ec;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --income: #059669;
  --expense: #dc2626;
  --danger: #dc2626;
  --sidebar: #111827;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

/* ---- 布局 ---- */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 220px;
  background: var(--sidebar);
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}
.brand { font-size: 18px; font-weight: 700; padding: 6px 10px 20px; color: #fff; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a {
  color: #cbd5e1; text-decoration: none; padding: 10px 12px;
  border-radius: 8px; font-size: 15px;
}
.sidebar nav a:hover { background: #1f2937; color: #fff; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar-footer { margin-top: auto; font-size: 13px; color: #9ca3af; padding: 0 10px; }
.sidebar-footer .who { margin-bottom: 8px; }
.sidebar-footer .logout { color: #9ca3af; text-decoration: none; }
.sidebar-footer .logout:hover { color: #fff; }

.content { margin-left: 220px; padding: 28px 32px; max-width: 1100px; }

h2 { margin: 0 0 20px; font-size: 22px; }
h3 { margin: 26px 0 10px; font-size: 16px; color: #374151; }

/* ---- 卡片 ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 8px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.card .label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.card .value { font-size: 24px; font-weight: 700; }
.value.income { color: var(--income); }
.value.expense { color: var(--expense); }
.value.neg { color: var(--expense); }

/* ---- 表格 ---- */
table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
th { background: #f9fafb; color: #4b5563; font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.income { color: var(--income); font-weight: 600; }
td.expense { color: var(--expense); font-weight: 600; }
td.neg { color: var(--expense); }
td.empty, .empty { color: var(--muted); text-align: center; padding: 22px; }

/* ---- 按钮 / 表单 ---- */
.btn {
  display: inline-block; padding: 8px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; color: var(--text); font-size: 14px; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: #cbd5e1; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; margin-top: 8px; padding: 10px; }

.filter { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filter select, .filter input, .form select, .form input, .form textarea, .inline-form input, .inline-form select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; background: #fff;
}
.filter input[type="text"] { min-width: 160px; }

.summary-line { font-size: 14px; color: var(--muted); margin-bottom: 12px; }
.summary-line b { color: var(--text); }

.form { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; max-width: 720px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: #4b5563; }
.grid label.full { grid-column: 1 / -1; }
.form-actions { margin-top: 18px; display: flex; gap: 10px; }
.hint { font-size: 13px; color: var(--muted); }

/* ---- 设置 ---- */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.panel h3 { margin: 0 0 12px; }
.inline-form { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.inline-form input, .inline-form select { flex: 1; min-width: 80px; }
.panel ul { list-style: none; margin: 0; padding: 0; }
.panel li { display: flex; align-items: center; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.panel li:last-child { border-bottom: none; }
.panel li form { margin: 0; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 10px; }
.tag.expense { background: #fef2f2; color: var(--expense); }
.tag.income { background: #ecfdf5; color: var(--income); }
.dim { color: var(--muted); font-size: 13px; }

.link { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 13px; padding: 0; }
.link.danger { color: var(--danger); }
td.actions { white-space: nowrap; display: flex; gap: 10px; align-items: center; border-bottom: none; }
td.actions form { display: inline; }

/* ---- 登录页 ---- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #1e3a8a, #2563eb); }
.login-box { background: #fff; padding: 36px 32px; border-radius: 14px; width: 360px; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.login-box h1 { margin: 0 0 4px; font-size: 20px; }
.login-box .sub { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.login-box label { display: block; font-size: 13px; color: #4b5563; margin-bottom: 12px; }
.login-box input { width: 100%; padding: 10px; margin-top: 5px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }

.alert { padding: 10px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 12px; }
.alert.error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }

/* ---- 报销状态标签 ---- */
.status { font-size: 12px; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.status.pending { background: #f3f4f6; color: #6b7280; }
.status.submitted { background: #fef3c7; color: #b45309; }
.status.reimbursed { background: #dbeafe; color: #1d4ed8; }
.status.settled { background: #d1fae5; color: #047857; }
.status-cell { display: flex; align-items: center; gap: 6px; }
.status-cell form { display: inline; margin: 0; }
.advance-btn { background: #eef2ff; border: 1px solid #c7d2fe; color: #4338ca; border-radius: 6px; cursor: pointer; font-size: 13px; padding: 1px 8px; }
.advance-btn:hover { background: #e0e7ff; }

/* ---- 统计报表 / 图表 ---- */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.toolbar .inline-form label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #4b5563; }
.chart-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-top: 16px; }
.chart-card h3 { margin: 0 0 8px; }
.chart { margin-top: 6px; }
.chart svg { display: block; max-width: 100%; height: auto; }
.legend { display: flex; gap: 16px; margin-bottom: 8px; font-size: 13px; color: #4b5563; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-item i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.mt { margin-top: 16px; }

/* ---- 票据预览灯箱 ---- */
.lightbox { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.lightbox[hidden] { display: none; }
.lightbox-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .72); }
.lightbox-box { position: relative; background: #fff; border-radius: 12px; width: min(860px, 92vw); height: min(640px, 86vh); padding: 12px; display: flex; flex-direction: column; box-shadow: 0 24px 60px rgba(0,0,0,.4); }
.lightbox-body { flex: 1; overflow: hidden; display: flex; align-items: center; justify-content: center; background: #111; border-radius: 8px; min-height: 0; }
.lightbox-body img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.lightbox-close { position: absolute; top: -14px; right: -14px; width: 34px; height: 34px; border-radius: 50%; border: none; background: #1f2937; color: #fff; font-size: 18px; cursor: pointer; line-height: 1; }
.lightbox-close:hover { background: #111; }
.lightbox-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border-radius: 50%; border: none; background: rgba(255,255,255,.92); color: #111; font-size: 24px; cursor: pointer; box-shadow: 0 2px 10px rgba(0,0,0,.25); line-height: 1; }
.lightbox-nav:hover { background: #fff; }
.lightbox-nav.prev { left: -18px; }
.lightbox-nav.next { right: -18px; }
.lightbox-caption { padding: 10px 4px 2px; text-align: center; font-size: 13px; color: #374151; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
