/* ============================================================
   星灼财务日常管理系统 — 样式
   ============================================================ */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #3b82f6;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --sidebar-bg: #0f1b2d;
  --sidebar-hover: #1b2c47;
  --sidebar-text: #b6c2d9;
  --green: #16a34a;
  --green-bg: #dcfce7;
  --orange: #d97706;
  --orange-bg: #fef3c7;
  --blue: #2563eb;
  --blue-bg: #dbeafe;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --purple: #7c3aed;
  --purple-bg: #ede9fe;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .05);
  --shadow-lg: 0 8px 32px rgba(15, 23, 42, .14);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

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

.hidden { display: none !important; }

/* ---------------- 登录页 ---------------- */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f1b2d 0%, #1e3a8a 55%, #1d4ed8 100%);
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 16px;
  padding: 40px 36px 32px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.login-logo {
  width: 88px;
  height: 88px;
  border-radius: 20px;
  object-fit: cover;
  box-shadow: 0 4px 14px rgba(29, 78, 216, .25);
}
/* 统一品牌 logo 白底圆角卡片 */
.logo-chip { display:inline-flex; align-items:center; justify-content:center; background:#fff; border-radius:11px; padding:5px 7px; box-shadow:0 2px 10px rgba(0,0,0,.12); border:1px solid #eef2f7; flex:none; }
.logo-chip img { height:32px; width:auto; display:block; }
.logo-chip.lg { padding:9px 11px; border-radius:15px; box-shadow:0 6px 20px rgba(0,0,0,.16); }
.logo-chip.lg img { height:56px; }
.login-title { font-size: 20px; margin-top: 16px; color: var(--text); font-weight: 700; }
.login-sub { color: var(--text-3); font-size: 13px; margin: 4px 0 26px; }
#login-form { text-align: left; }

/* ---------------- 布局 ---------------- */
.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.brand-logo { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; }
.brand-name { font-size: 15px; font-weight: 700; color: #fff; line-height: 1.3; }
.brand-sub { font-size: 11px; color: var(--sidebar-text); opacity: .8; }

.sidebar-nav { flex: 1; padding: 12px 10px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 4px;
  border-radius: 10px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  transition: background .15s, color .15s;
  cursor: pointer;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.nav-icon { width: 20px; text-align: center; font-size: 15px; }

.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.07); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 4px 12px; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
  color: #fff; font-weight: 700; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-name { color: #fff; font-size: 13px; font-weight: 600; line-height: 1.3; }
.user-role { font-size: 11px; color: var(--sidebar-text); opacity: .85; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 60px;
  flex-shrink: 0;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}
.topbar-title { font-size: 17px; font-weight: 700; }
.topbar-date { color: var(--text-3); font-size: 13px; }

.content { flex: 1; overflow-y: auto; padding: 24px; }

/* ---------------- 通用组件 ---------------- */
/* 全局规范：按钮不换行 */
button, .btn { white-space: nowrap; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
  background: #fff;
  color: var(--text-2);
  border-color: var(--border);
  white-space: nowrap;
}
.btn:hover { border-color: var(--primary-light); color: var(--primary); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); color: #fff; border-color: var(--primary-dark); }
.btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: var(--green); color: #fff; border-color: var(--green); }
.btn-success:hover { background: #15803d; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-xs { padding: 3px 8px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--sidebar-text); border-color: rgba(255,255,255,.18); }
.btn-ghost:hover { background: var(--sidebar-hover); color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 20px;
}
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card-title .sub { font-size: 12px; color: var(--text-3); font-weight: 400; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; font-weight: 500; }
input[type="text"], input[type="password"], input[type="number"], input[type="date"], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .12);
}
textarea { resize: vertical; min-height: 70px; }
.form-error { color: var(--red); font-size: 13px; margin-bottom: 12px; text-align: center; }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left;
  padding: 10px 12px;
  background: #f8fafc;
  color: var(--text-2);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
tbody tr:hover { background: #f8fafc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.total-row td { background: #f8fafc; font-weight: 700; border-top: 2px solid var(--border); }

.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.tag-pending { background: var(--orange-bg); color: var(--orange); }
.tag-partial { background: var(--blue-bg); color: var(--blue); }
.tag-paid { background: var(--green-bg); color: var(--green); }
.tag-overdue { background: var(--red-bg); color: var(--red); }
.tag-blue { background: var(--blue-bg); color: var(--blue); }
.tag-green { background: var(--green-bg); color: var(--green); }
.tag-red { background: var(--red-bg); color: var(--red); }
.tag-purple { background: var(--purple-bg, #f3e8ff); color: var(--purple, #7c3aed); }
.tag-orange { background: var(--orange-bg); color: var(--orange); }
.tag-gray { background: #f1f5f9; color: var(--text-3); }
.tag-muted { background: #f1f5f9; color: var(--text-3); }

/* ---------------- 统计卡片 ---------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 18px;
  position: relative;
  overflow: hidden;
}
.stat-card .stat-label { font-size: 13px; color: var(--text-2); padding-right: 48px; line-height: 1.4; }
.stat-card .stat-value { font-size: 26px; font-weight: 800; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat-card .stat-sub { font-size: 12px; color: var(--text-3); margin-top: 4px; padding-right: 48px; line-height: 1.4; }
.stat-card .stat-icon {
  position: absolute; right: 14px; top: 14px;
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px;
}
.stat-blue .stat-icon { background: var(--blue-bg); }
.stat-green .stat-icon { background: var(--green-bg); }
.stat-orange .stat-icon { background: var(--orange-bg); }
.stat-red .stat-icon { background: var(--red-bg); }
.stat-purple .stat-icon { background: var(--purple-bg); }
.stat-blue .stat-value { color: var(--blue); }
.stat-green .stat-value { color: var(--green); }
.stat-orange .stat-value { color: var(--orange); }
.stat-red .stat-value { color: var(--red); }
.stat-purple .stat-value { color: var(--purple); }

/* ---------------- 工具条 ---------------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.toolbar input[type="date"], .toolbar select, .toolbar input[type="text"] { width: auto; min-width: 150px; }

/* ---------------- 预警横幅 ---------------- */
.alert-banner {
  background: linear-gradient(90deg, var(--red-bg), #fff7ed);
  border: 1px solid #fecaca;
  border-radius: 12px;
  padding: 12px 18px;
  margin-bottom: 16px;
  font-size: 14px;
  line-height: 1.8;
  color: var(--text);
}

/* ---------------- 通知铃铛 ---------------- */
#btn-notifications { position: relative; }
.notif-badge {
  position: absolute;
  top: -6px; right: -8px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px; height: 18px;
  border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
  box-shadow: 0 0 0 2px #fff;
}
.topbar-right { display: flex; align-items: center; gap: 14px; }

/* ---------------- 网格 ---------------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 1100px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---------------- 集团看板 / 平台对账 ---------------- */
.mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 12px; }
.plat-banner {
  border-radius: 10px;
  padding: 10px 16px;
  margin-bottom: 16px;
  font-size: 13.5px;
  line-height: 1.6;
  display: flex;
  align-items: center;
  gap: 8px;
}
.plat-ok { background: var(--green-bg); border: 1px solid #bbf7d0; color: #14532d; }
.plat-down { background: var(--orange-bg); border: 1px solid #fde68a; color: #92400e; }
.group-kvs .kv {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13.5px;
}
.group-kvs .kv span { color: var(--text-2); }
.group-kvs .kv b { font-size: 16px; font-variant-numeric: tabular-nums; }

/* ---------------- 趋势图（纯 CSS 条形） ---------------- */
.trend { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding-top: 10px; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.trend-bar { width: 60%; max-width: 34px; border-radius: 6px 6px 2px 2px; background: linear-gradient(180deg, var(--primary-light), var(--primary)); transition: height .4s; min-height: 2px; }
.trend-bar.paid { background: linear-gradient(180deg, #4ade80, var(--green)); }
.trend-bar.due { background: linear-gradient(180deg, #fbbf24, var(--orange)); }
.trend-val { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.trend-label { font-size: 11px; color: var(--text-3); }
.trend-legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-2); margin-top: 8px; }
.trend-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }

/* ---------------- 弹窗 ---------------- */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .5);
  backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center;
  z-index: 100;
  padding: 60px 16px 16px;
  overflow-y: auto;
}
.modal {
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  padding: 24px;
  animation: modal-in .18s ease;
}
.modal.modal-lg { max-width: 760px; }
.modal.modal-xl { max-width: 980px; }
@keyframes modal-in { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; top: 22px; left: 50%; transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: 10px 22px; border-radius: 10px;
  font-size: 14px; z-index: 200; box-shadow: var(--shadow-lg);
  animation: toast-in .2s ease;
}
.toast.ok { background: var(--green); }
.toast.err { background: var(--red); }
@keyframes toast-in { from { transform: translate(-50%, -12px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* ---------------- 报表 tab ---------------- */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 18px; }
.tab {
  padding: 9px 20px; cursor: pointer; font-size: 14px; color: var(--text-2);
  border-bottom: 2px solid transparent; margin-bottom: -2px; font-weight: 500;
  user-select: none;
}
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 700; }

/* ---------------- 空状态 ---------------- */
.empty { text-align: center; color: var(--text-3); padding: 40px 0; font-size: 13px; }

/* ---------------- 打印 ---------------- */
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .toolbar, .no-print, .tabs, .toast { display: none !important; }
  .content { padding: 0; overflow: visible; }
  .app { display: block; height: auto; }
  .card { box-shadow: none; border: none; padding: 0; margin-bottom: 16px; }
  table td, table th { border: 1px solid #cbd5e1; }
  .print-header { display: block !important; }
}
.print-header { display: none; text-align: center; margin-bottom: 14px; }
.print-header h2 { font-size: 18px; }
.print-header p { color: var(--text-3); font-size: 12px; }
.print-header img { width: 40px; height: 40px; border-radius: 8px; vertical-align: middle; margin-right: 8px; }

/* ---------------- 滚动条 ---------------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 860px) {
  .sidebar { width: 64px; }
  .brand-text, .user-meta, .sidebar-foot .btn { display: none; }
  .nav-item { justify-content: center; padding: 12px; }
  .nav-icon { font-size: 18px; }
  .content { padding: 14px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------------- 手机端优化（≤640px） ---------------- */
@media (max-width: 640px) {
  body { font-size: 13px; }
  .app { display: block; height: auto; min-height: 100vh; }
  .sidebar {
    width: 100%;
    flex-direction: row;
    position: sticky;
    top: 0;
    z-index: 50;
    overflow-x: auto;
    padding: 0;
  }
  .sidebar-brand { display: none; }
  .sidebar-nav { display: flex; flex: 1; padding: 6px; gap: 4px; }
  .nav-item { flex: 1; min-width: 52px; padding: 8px 4px; flex-direction: column; gap: 2px; font-size: 10px; }
  .nav-icon { font-size: 16px; }
  .sidebar-foot { display: none; }
  .main { height: auto; }
  .topbar { height: 50px; padding: 0 12px; }
  .topbar-title { font-size: 15px; }
  .content { padding: 10px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 12px; }
  .stat-card .stat-value { font-size: 20px; }
  .stat-card .stat-icon { width: 32px; height: 32px; font-size: 15px; right: 10px; top: 10px; }
  .card { padding: 14px; }
  .toolbar { gap: 6px; }
  .toolbar input[type="date"], .toolbar select, .toolbar input[type="text"] { min-width: 0; flex: 1; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .modal { padding: 16px; margin: 0 8px; }
  .table-wrap { font-size: 12px; }
  th, td { padding: 8px 6px; }
  .tabs { overflow-x: auto; white-space: nowrap; }
  .tab { padding: 8px 12px; font-size: 13px; }
  .alert-banner { font-size: 12.5px; padding: 10px 12px; }
  .topbar-date { display: none; }
}
