/* ============ 基础 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --warning: #d97706;
  --text: #111827;
  --text-2: #4b5563;
  --text-3: #9ca3af;
  --border: #e5e7eb;
  --bg: #f3f5f9;
  --card: #ffffff;
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
  --shadow-lg: 0 10px 30px rgba(16,24,40,.12);
  --radius: 12px;
  --radius-sm: 8px;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit; font-size: 14px; color: var(--text);
}
a { color: var(--primary); text-decoration: none; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: 14px; font-weight: 500; transition: all .15s; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover { background: #f9fafb; color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ============ 表单 ============ */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); outline: none; background: #fff; transition: border .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.field textarea { resize: vertical; min-height: 60px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 16px; }

/* ============ 登录页 ============ */
.view-login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 55%, #3b82f6 100%);
  padding: 20px;
}
.login-card {
  width: 400px; max-width: 100%; background: #fff; border-radius: 18px;
  padding: 38px 36px 30px; box-shadow: var(--shadow-lg); text-align: center;
}
.login-logo { margin-bottom: 10px; }
.login-title { font-size: 24px; font-weight: 700; color: var(--text); }
.login-sub { color: var(--text-3); font-size: 13px; margin: 4px 0 26px; }
.login-card form { text-align: left; }
.login-error { color: var(--danger); font-size: 13px; min-height: 20px; margin-bottom: 6px; }
.login-hint { margin-top: 18px; font-size: 12px; color: var(--text-3); }

/* ============ 主布局 ============ */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 228px; background: #fff; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px 14px; border-bottom: 1px solid var(--border); }
.brand-icon { display: flex; align-items: center; }
.brand-text strong { display: block; font-size: 15.5px; }
.brand-text span { font-size: 11.5px; color: var(--text-3); }
.nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 2px;
  border-radius: var(--radius-sm); color: var(--text-2); font-weight: 500; transition: all .15s;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.nav-ico { font-size: 16px; width: 20px; text-align: center; }
.sidebar-foot { border-top: 1px solid var(--border); padding: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; flex-shrink: 0;
}
.user-meta strong { display: block; font-size: 13.5px; }
.user-meta span { font-size: 12px; color: var(--text-3); }
.user-actions { display: flex; gap: 8px; }
.user-actions .btn { flex: 1; }

.main { flex: 1; margin-left: 228px; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: #fff; border-bottom: 1px solid var(--border); padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10;
}
.topbar h2 { font-size: 18px; }
.topbar-date { color: var(--text-3); font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 14px; position: relative; }

/* ============ 通知铃铛 ============ */
.bell-wrap { position: relative; }
.bell-btn {
  background: none; border: none; cursor: pointer; color: var(--text-2);
  display: flex; align-items: center; justify-content: center; padding: 5px; border-radius: 8px; position: relative;
}
.bell-btn:hover { background: var(--bg); color: var(--primary); }
.bell-badge {
  position: absolute; top: -2px; right: -4px; min-width: 17px; height: 17px; padding: 0 4px;
  background: #ef4444; color: #fff; font-size: 11px; font-weight: 600; line-height: 17px;
  border-radius: 9px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.bell-panel {
  position: absolute; right: 0; top: 40px; width: 340px; max-height: 420px; overflow-y: auto;
  background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.12); z-index: 50;
}
.bell-panel .panel-head {
  display: flex; align-items: center; justify-content: space-between; padding: 12px 14px;
  border-bottom: 1px solid var(--border); font-size: 14px; font-weight: 600; position: sticky; top: 0; background: #fff;
}
.bell-panel .panel-head a { font-size: 12.5px; color: var(--primary); cursor: pointer; font-weight: 400; text-decoration: none; }
.notif-item { padding: 11px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: #eff6ff; }
.notif-item .n-title { font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.notif-item .n-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }
.notif-item .n-content { font-size: 12.5px; color: var(--text-2); margin-top: 3px; line-height: 1.5; }
.notif-item .n-time { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }
.notif-empty { padding: 34px 16px; text-align: center; color: var(--text-3); font-size: 13px; }
.notif-item .n-type-success { color: #16a34a; }
.notif-item .n-type-error { color: #dc2626; }
.notif-item .n-type-info { color: #2563eb; }
.page-container { padding: 22px 24px 40px; flex: 1; }

/* ============ 卡片 ============ */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }
.card-title .sub { font-size: 12.5px; color: var(--text-3); font-weight: 400; }

/* ============ 统计卡 ============ */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; display: flex; align-items: center; gap: 14px;
}
.stat-ico { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.stat-ico.blue { background: #eff6ff; }
.stat-ico.green { background: #f0fdf4; }
.stat-ico.orange { background: #fff7ed; }
.stat-ico.purple { background: #faf5ff; }
.stat-info .num { font-size: 22px; font-weight: 700; line-height: 1.2; }
.stat-info .label { font-size: 12.5px; color: var(--text-3); }

/* ============ 表格 ============ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text-3); font-weight: 500; font-size: 12.5px; background: #fafbfc; }
tbody tr:hover { background: #f9fafb; }
td.money { font-variant-numeric: tabular-nums; }
.text-right { text-align: right; }

/* 徽标 */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.badge-blue { background: #eff6ff; color: var(--primary); }
.badge-green { background: var(--success-light); color: var(--success); }
.badge-gray { background: #f3f4f6; color: var(--text-2); }
.badge-red { background: var(--danger-light); color: var(--danger); }
.badge-orange { background: #fff7ed; color: var(--warning); }

/* 空态 */
.empty { text-align: center; color: var(--text-3); padding: 36px 0; font-size: 13.5px; }
.empty .big { font-size: 34px; display: block; margin-bottom: 8px; }

/* ============ 工具条 ============ */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.search-box { position: relative; }
.search-box input {
  padding: 8px 12px 8px 34px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  width: 240px; outline: none; font-size: 13.5px; background: #fff;
}
.search-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.search-box::before { content: "🔍"; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 13px; opacity: .6; }

/* ============ 工作台 ============ */
.workbench-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 1100px) { .workbench-grid { grid-template-columns: 1fr; } }
.paste-box textarea { min-height: 150px; font-size: 14px; line-height: 1.7; }
.recognize-tip { font-size: 12.5px; color: var(--text-3); margin-top: 8px; }
.match-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.match-chip {
  border: 1px solid var(--border); background: #fff; border-radius: 8px; padding: 6px 10px;
  font-size: 12.5px; cursor: pointer; transition: all .15s; text-align: left;
}
.match-chip:hover { border-color: var(--primary); background: var(--primary-light); }
.match-chip .nm { font-weight: 600; color: var(--text); display: block; }
.match-chip .score { color: var(--success); font-size: 11.5px; }
.match-chip .tx { color: var(--text-3); font-size: 11.5px; display: block; }

.amount-big {
  background: var(--primary-light); border: 1px dashed #bfdbfe; border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 16px; font-weight: 600; color: var(--primary-dark); margin-bottom: 14px;
  font-variant-numeric: tabular-nums;
}
.calc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 4px; }
.calc-item { background: #fafbfc; border-radius: var(--radius-sm); padding: 10px 12px; }
.calc-item .lbl { font-size: 12px; color: var(--text-3); }
.calc-item .val { font-size: 16px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 20px; overflow-y: auto;
}
.modal {
  background: #fff; border-radius: 14px; width: 560px; max-width: 100%;
  box-shadow: var(--shadow-lg); animation: pop .18s ease;
}
.modal.sm { width: 420px; }
.modal.lg { width: 720px; }
@keyframes pop { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-close { border: none; background: none; font-size: 20px; color: var(--text-3); line-height: 1; padding: 2px 6px; border-radius: 6px; }
.modal-close:hover { background: #f3f4f6; color: var(--text); }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ============ 轻提示 ============ */
#toast-root { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #111827; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13.5px;
  box-shadow: var(--shadow-lg); animation: toastIn .2s ease; max-width: 80vw;
}
.toast.ok { background: #065f46; }
.toast.err { background: #991b1b; }
@keyframes toastIn { from { transform: translateY(-12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ============ 发票预览（详情） ============ */
.invoice-paper { border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; background: #fff; }
.invoice-paper .ip-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #111; padding-bottom: 12px; margin-bottom: 14px; }
.invoice-paper .ip-title { font-size: 20px; font-weight: 700; letter-spacing: 4px; }
.invoice-paper .ip-meta { text-align: right; font-size: 12.5px; color: var(--text-2); }
.ip-rows { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px; font-size: 13.5px; margin-bottom: 16px; }
.ip-rows .r b { color: var(--text-2); font-weight: 500; margin-right: 6px; }
.ip-big { text-align: right; font-size: 17px; font-weight: 700; margin-top: 12px; }
.ip-big .cn { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin-top: 4px; }

/* ============ 设置 ============ */
.radio-row { display: flex; gap: 22px; margin-top: 4px; }
.radio-row label { display: flex; align-items: center; gap: 7px; cursor: pointer; font-size: 13.5px; }
.channel-desc {
  margin-top: 10px; background: #f8fafc; border-radius: var(--radius-sm); padding: 12px 14px;
  font-size: 12.5px; color: var(--text-2); line-height: 1.8;
}
.channel-desc code { background: #eef2ff; color: #3730a3; padding: 1px 6px; border-radius: 4px; font-size: 12px; }

/* ============ 滚动条 ============ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ 响应式 ============ */
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .calc-grid { grid-template-columns: 1fr 1fr; }
  .page-container { padding: 16px; }
}
