/* ============ 对账台 全站样式 v2 ============
   风格：现代桌面软件（类用友/金蝶云）——全屏铺满、左侧功能树、页签工作区、
   密集表格完整网格线、关键数字清晰。打印纸样式(.stmt-paper)保持1:1不变。 */

:root {
  --bg: #e9edf2;
  --panel: #ffffff;
  --border: #d5dce5;
  --border-soft: #e8edf3;
  --text: #1c2733;
  --text-2: #445262;
  --text-3: #8494a5;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --green: #16a34a;
  --red: #dc2626;
  --yellow: #d97706;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(28, 39, 51, .06);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "Microsoft YaHei", "微软雅黑", "PingFang SC", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
  margin: 0;
}

main {
  padding: 14px 18px 40px;
}

h1 { font-size: 18px; font-weight: 700; color: var(--text); margin: 12px 0 10px; }
h2 { font-size: 14.5px; font-weight: 700; color: var(--text-2); margin: 18px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
h3 { font-size: 13px; font-weight: 600; margin: 12px 0 6px; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

label { vertical-align: middle; }

/* ---- 顶部导航（独立打开/手机时用；页签框架内隐藏） ---- */
nav {
  background: #2f5597;
  border-bottom: 1px solid #244476;
  position: sticky; top: 0; z-index: 50;
}
html.framed nav { display: none; }
.nav-inner {
  padding: 0 16px;
  height: 40px; display: flex; align-items: center; justify-content: space-between;
}
.brand { font-size: 15px; font-weight: 700; color: #fff; letter-spacing: .02em; }
.brand:hover { text-decoration: none; }
.links { display: flex; gap: 2px; align-items: center; }
.links a {
  color: #dbe6f5; font-size: 13px; padding: 5px 12px; border-radius: 3px;
}
.links a:hover { background: rgba(255,255,255,.14); color: #fff; text-decoration: none; }
.links a.logout { color: #b9c8dc; margin-left: 8px; }

/* ---- 区块面板 ---- */
.block {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 12px 0;
  overflow: hidden;
}
.block > h2 {
  font-size: 13px; font-weight: 700; color: #33475f;
  margin: 0; padding: 8px 14px;
  background: #f4f7fb; border-bottom: 1px solid var(--border);
}
.block > .body { padding: 12px 14px; }
.block.tight > .body { padding: 0; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  margin: 10px 0;
}

/* ---- KPI 指标卡 ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.kpi {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 11px 14px;
}
.kpi .k, .kpi label { font-size: 12px; color: var(--text-3); font-weight: 500; display: block; }
.kpi .v {
  font-size: 22px; font-weight: 700; color: var(--text);
  margin-top: 3px; line-height: 1.25;
  font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpi .v small { font-size: 12.5px; font-weight: 500; color: var(--text-3); margin-left: 4px; }
.kpi h2 { border: none; margin: 3px 0 0; padding: 0; font-size: 21px; font-variant-numeric: tabular-nums; }

/* ---- 表格：完整网格线、密集、数字等宽 ---- */
table {
  width: 100%; border-collapse: collapse;
  background: var(--panel); font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
th {
  font-size: 12px; font-weight: 600; color: #55637a;
  text-align: left; padding: 6px 10px;
  background: #eef2f7;
  border: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 5px 10px;
  border: 1px solid var(--border-soft);
  vertical-align: middle;
}
tbody tr:nth-child(even) td { background: #f7fafd; }
tbody tr:hover td { background: #e8f1fc; }
td.num, th.num, .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
td.center, .center { text-align: center; }

/* ---- 文本语义色 ---- */
.muted { color: var(--text-3); }
.bad { color: var(--red); font-weight: 600; }
.ok { color: var(--green); font-weight: 600; }

/* ---- 按钮 ---- */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px; border-radius: 4px;
  border: 1px solid #c6cfda; background: #fff;
  color: var(--text-2); font-size: 12.5px; font-weight: 500;
  cursor: pointer; white-space: nowrap; vertical-align: middle;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #f2f6fb; border-color: #9fb2c8; text-decoration: none; color: var(--text); }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.green:hover { background: #15803d; border-color: #15803d; color: #fff; }
.btn.red { background: var(--red); border-color: var(--red); color: #fff; }
.btn.red:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn.gray { background: #fff; }
.btn.small { padding: 3px 9px; font-size: 12px; border-radius: 3px; }

button, input[type="submit"] { font-family: inherit; }

/* ---- 表单 ---- */
input, select, textarea {
  font-family: inherit; font-size: 12.5px; color: var(--text);
  padding: 5px 9px; border: 1px solid #c6cfda; border-radius: 4px;
  background: #fff; vertical-align: middle;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, .13);
}
input.num { text-align: right; font-variant-numeric: tabular-nums; }
table input, table select, table textarea { padding: 3px 6px; font-size: 12px; }
button {
  padding: 6px 14px; border-radius: 4px; border: 1px solid var(--accent);
  background: var(--accent); color: #fff; font-size: 12.5px; font-weight: 500; cursor: pointer;
}
button:hover { background: var(--accent-dark); }
.btn button, .btn input { border: none; background: none; color: inherit; padding: 0; }

.form-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px 14px;
}
/* 三入口（基本信息/对账/客户资料）横向排列 */
.nav-entries { display: flex; flex-direction: row; flex-wrap: wrap; gap: 8px; align-items: center; }
.form-grid label { display: block; font-size: 12px; color: var(--text-3); margin-bottom: 3px; font-weight: 500; }
.form-grid input, .form-grid select, .form-grid textarea { width: 100%; }

/* ---- 标签 / 提示 ---- */
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 3px;
  font-size: 11.5px; font-weight: 500; white-space: nowrap;
}
.tag.draft { background: #f1f2f5; color: #6b7280; }
.tag.sent { background: #e4edfb; color: #1d4ed8; }
.tag.disputed { background: #fdf0e4; color: #b45309; }
.tag.confirmed { background: #e3f4e8; color: #15803d; }
.tag.signed { background: #d7eedd; color: #166534; }
.tag.archived { background: #eee9f7; color: #6d28d9; }
.tag.upstream { background: #e4edfb; color: #1d4ed8; }
.tag.downstream { background: #e3f4e8; color: #15803d; }
.tag.internal { background: #faf3e0; color: #a16207; }
.tag.gray { background: #f1f2f5; color: #6b7280; }
.tag.green { background: #e3f4e8; color: #15803d; }
.tag.red { background: #fdeaea; color: #b91c1c; }

.notice { padding: 7px 12px; margin: 8px 0; border-radius: 4px; border: 1px solid; font-size: 12.5px; }
.notice.warn { background: #fffaf3; border-color: #f3d9b7; color: #92400e; }
.notice.err { background: #fdf3f2; border-color: #f2c9c5; color: #991b1b; }
.notice.info { background: #f2f7fd; border-color: #cddffb; color: #1e40af; }
.notice.ok { background: #f1f9f2; border-color: #c8e6cd; color: #166534; }

/* ---- 布局工具 ---- */
.flex { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 12px; }

/* ---- 登录页 ---- */
.login-box label { display: block; margin: 10px 0 4px; font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.login-box input { width: 100%; }
.login-box h1 { text-align: center; margin-top: 0; }
.login-box {
  max-width: 360px; margin: 10vh auto;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 4px 16px rgba(28, 39, 51, .08);
  padding: 28px 30px;
}

/* ============ 软件外壳（多页签工作区） ============ */
html.framed body { background: #fff; }
html.framed main { padding: 12px 14px 30px; }

.shell { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.shell-top {
  height: 42px; flex: none;
  background: linear-gradient(180deg, #33609f 0%, #2b5288 100%);
  display: flex; align-items: center; padding: 0 12px; gap: 4px;
  color: #fff;
}
.shell-top .logo { font-size: 15px; font-weight: 700; margin-right: 14px; letter-spacing: .02em; }

.menu { position: relative; height: 100%; display: flex; align-items: center; }
.menu > a {
  color: #e2ebf7; font-size: 13px; padding: 5px 12px; border-radius: 3px; cursor: default;
}
.menu:hover > a { background: rgba(255,255,255,.16); color: #fff; text-decoration: none; }
.dropdown {
  display: none; position: absolute; top: 100%; left: 0; z-index: 200;
  background: #fff; border: 1px solid var(--border); border-radius: 4px;
  box-shadow: 0 6px 18px rgba(28, 39, 51, .16);
  min-width: 150px; padding: 4px;
}
.menu:hover .dropdown { display: block; }
.dropdown a {
  display: block; padding: 6px 12px; color: var(--text); font-size: 12.5px;
  border-radius: 3px; cursor: pointer;
}
.dropdown a:hover { background: #eef4fb; text-decoration: none; }
.dropdown .sep { height: 1px; background: var(--border-soft); margin: 4px 6px; }

.shell-top .right { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 12.5px; color: #cdd9ea; }
.shell-top .right a { color: #e2ebf7; padding: 4px 10px; border-radius: 3px; }
.shell-top .right a:hover { background: rgba(255,255,255,.16); text-decoration: none; }

.shell-tool {
  height: 34px; flex: none;
  background: #f3f6fa; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 10px; gap: 6px;
}
.shell-tool .sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }

.shell-body { flex: 1; display: flex; min-height: 0; }

.shell-side {
  width: 152px; flex: none;
  background: #f7f9fc; border-right: 1px solid var(--border);
  padding: 6px 0; overflow-y: auto;
}
.shell-side a {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px 7px 12px; margin: 1px 6px;
  color: var(--text-2); font-size: 13px;
  border-left: 3px solid transparent; border-radius: 0 3px 3px 0;
}
.shell-side a:hover { background: #e9f0f9; color: var(--text); text-decoration: none; }
.shell-side a.active {
  background: #e3edfa; border-left-color: var(--accent);
  color: var(--accent-dark); font-weight: 600;
}
.shell-side .grp {
  padding: 10px 16px 3px; font-size: 11px; color: var(--text-3);
  letter-spacing: .06em;
}

.shell-main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }

.tabbar {
  height: 32px; flex: none;
  background: #dfe6ee; border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-end; padding: 0 6px;
  overflow-x: auto;
}
.tabbar .tab {
  display: flex; align-items: center; gap: 6px;
  height: 27px; padding: 0 8px 0 12px; margin-right: 3px;
  background: #c9d4e1; border: 1px solid var(--border); border-bottom: none;
  border-radius: 4px 4px 0 0;
  font-size: 12px; color: var(--text-2); cursor: pointer;
  white-space: nowrap; max-width: 180px; flex: none;
}
.tabbar .tab .t { overflow: hidden; text-overflow: ellipsis; }
.tabbar .tab.active {
  background: var(--bg); color: var(--accent-dark); font-weight: 600;
  border-color: var(--border);
}
.tabbar .tab .x {
  width: 15px; height: 15px; border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--text-3);
}
.tabbar .tab .x:hover { background: #d9534f; color: #fff; }

.stage { flex: 1; position: relative; min-height: 0; }
.stage iframe {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border: none; background: #fff; display: none;
}
.stage iframe.active { display: block; }

.shell-status {
  height: 24px; flex: none;
  background: #eef2f7; border-top: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 12px; gap: 16px;
  font-size: 11.5px; color: var(--text-2);
}
.shell-status .dot { color: var(--green); }
.shell-status .r { margin-left: auto; }

@media (max-width: 900px) {
  .shell-side { width: 128px; }
}

/* ============ 对账单打印纸（1:1 还原用户Excel样板） ============
   字体：微软雅黑；标题14pt粗、表头/汇总12pt、明细11pt
   背景色：上期欠款余额#F5F5F5浅灰 | 本期发生#FFFF00黄 | 已支付#92D050绿 | 已开票#FCE6D5浅橙
   金额数字格式：#,##0.00（千分位两位小数） */
.stmt-paper {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 30px 36px;
  margin: 16px 0;
  font-family: "Microsoft YaHei", "微软雅黑", sans-serif;
}
.stmt-paper h1 {
  border: none; text-align: center;
  font-family: "Microsoft YaHei", "微软雅黑", sans-serif;
  font-size: 14pt; font-weight: 700;
  margin: 2px 0 10px;
}
.sp { width: 100%; border-collapse: collapse; table-layout: fixed; font-variant-numeric: tabular-nums; }
.sp td {
  border: 1px solid #000;
  padding: 3px 7px;
  vertical-align: middle;
  font-family: "Microsoft YaHei", "微软雅黑", sans-serif;
  font-size: 11pt; color: #000;
  background: #fff;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.sp td.num { text-align: right; }
.sp td.center { text-align: center; }
.sp-label { font-size: 12pt !important; text-align: center; }
.sp-info { font-size: 12pt !important; }
.sp-head { font-size: 12pt !important; text-align: center; }
.sp-cell { font-size: 11pt !important; }
.sp-sum { font-size: 12pt !important; font-weight: 700; text-align: center; }
.sp-kv { font-size: 12pt !important; font-weight: 700; text-align: center; }
.sp-kv.gray { background: #F5F5F5 !important; }
.sp-kv.yellow { background: #FFFF00 !important; }
.sp-kv.green { background: #92D050 !important; }
.sp-kv.peach { background: #FCE6D5 !important; }
.sp-remark { font-size: 12pt !important; height: 36px; }
.sp-sign { font-size: 12pt !important; vertical-align: top; height: 84px; }
.sp-foot {
  font-size: 12pt !important;
  border: none !important; border-top: 1px solid #000 !important;
}

/* ============ 打印 ============ */
@page { size: A4 portrait; margin: 12mm; }

@media print {
  nav, .no-print { display: none !important; }
  body { background: #fff; }
  main { max-width: none; padding: 0; }
  h1, h2 { margin-top: 8px; }
  .block, .card, .kpi { box-shadow: none; border-color: #d5d9e0; }
  .stmt-paper { border: none; padding: 0; margin: 0; border-radius: 0; }
  .sp td { background: #fff; }
  .sp-kv.gray { background: #F5F5F5 !important; }
  .sp-kv.yellow { background: #FFFF00 !important; }
  .sp-kv.green { background: #92D050 !important; }
  .sp-kv.peach { background: #FCE6D5 !important; }
}
