/* 外贸台账系统 · 样式 */
:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --line: #e3e8ee;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #1d6fb8;
  --primary-dark: #175a97;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --row-hover: #f0f7ff;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  font-size: 13px; color: var(--text); background: var(--bg);
  display: flex; flex-direction: column; overflow: hidden;
}
header {
  display: flex; align-items: center; gap: 24px;
  background: #123a5c; color: #fff; padding: 0 20px;
  flex: none; position: relative; z-index: 50;
}
.logo {
  font-size: 16px; font-weight: 700; padding: 8px 0; white-space: nowrap;
  display: flex; align-items: center; gap: 8px;
}
.logo-img { height: 32px; width: auto; border-radius: 7px; display: block; }
nav { display: flex; gap: 2px; overflow-x: auto; }
nav button {
  background: transparent; border: none; color: #cfe0ef;
  padding: 12px 14px; cursor: pointer; font-size: 13px;
  border-bottom: 3px solid transparent; white-space: nowrap;
}
nav button:hover { color: #fff; background: rgba(255,255,255,.08); }
nav button.active { color: #fff; border-bottom-color: #4ea1e0; font-weight: 700; }

main { padding: 14px 20px; flex: 1; min-height: 0;
  display: flex; flex-direction: column; }
.tab { display: none; }
.tab.active { display: flex; flex-direction: column; flex: 1; min-height: 0; }
/* 设置页内容（计算参数＋历史月终汇率）按自然高度排列、整页上下滚动：
   flex 布局下窗口一矮面板就被压缩，旧月份汇率看不到又没法往下滚 */
#tab-settings.active { display: block; overflow-y: auto; }

.toolbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-bottom: 12px;
}
.toolbar input, .toolbar select {
  padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px;
  background: #fff; font-size: 13px;
}
.toolbar input[type="month"] { width: 150px; }
.toolbar input[type="checkbox"] { width: auto; }
.hint { color: var(--muted); font-size: 12px; }
.chk { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }

button {
  padding: 6px 14px; border: 1px solid var(--line); border-radius: 6px;
  background: #fff; cursor: pointer; font-size: 13px; color: var(--text);
}
button:hover { background: var(--row-hover); }
button.primary {
  background: var(--primary); border-color: var(--primary); color: #fff;
}
button.primary:hover { background: var(--primary-dark); }
button.small { padding: 2px 8px; font-size: 12px; }
button.danger { color: var(--bad); border-color: #f3c1c1; }
button.danger:hover { background: #fef2f2; }

.table-wrap {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; overflow: auto;
  flex: 1; min-height: 0;   /* 填满工具栏以下的剩余空间，底部不留白 */
}
table { border-collapse: collapse; width: 100%; }
th, td {
  padding: 7px 9px; border-bottom: 1px solid var(--line);
  text-align: left; white-space: nowrap; font-size: 12.5px;
}
th {
  background: #f8fafc; position: sticky; top: 0; z-index: 5;
  font-weight: 700; color: #374151;
}
/* 列筛选行：表头第二行，每列一个筛选控件（sticky 于首行之下） */
thead tr:first-child th { height: 34px; }
thead tr.frow th {
  top: 34px; z-index: 4; padding: 3px 5px;
  background: #f8fafc; border-bottom: 1px solid var(--line);
}
thead tr.frow input, thead tr.frow select {
  width: 100%; height: 24px; box-sizing: border-box;
  border: 1px solid var(--line); border-radius: 4px;
  padding: 2px 6px; font-size: 12px; background: #fff; color: var(--text);
}
thead tr.frow input:focus, thead tr.frow select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(29,111,184,.15);
}
thead tr.frow input::placeholder { color: #9ca3af; }
tbody tr:hover { background: var(--row-hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.neg { color: var(--bad); font-weight: 700; }
td.neglight { color: #e07b7b; }
/* td 上的截断：不改 display（inline-block 会把单元格挤出行布局、
   导致同一行边框高低不齐），保持 table-cell 只做超宽省略 */
.clip { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.tag {
  display: inline-block; padding: 1px 7px; border-radius: 10px;
  font-size: 11.5px; background: #eef1f4; color: var(--muted);
}
.tag.ok { background: #dcfce7; color: var(--ok); }
.tag.warn { background: #fef3c7; color: var(--warn); }
.row-unclaimed { background: #fffbeb; }
.row-remind { background: #fff7ed; }
tr.row-bold td { font-weight: 700; background: #f8fafc; }
tr.row-total td { font-weight: 800; background: #eef6ff; }
tr.row-section td { font-weight: 700; color: var(--primary-dark); background: #f8fafc; }
tr.row-pct td { color: var(--muted); }

.cards { display: flex; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 18px; min-width: 160px;
}
.card .cv { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.card .cl { color: var(--muted); font-size: 12px; margin-top: 2px; }
.card.bad .cv { color: var(--bad); }
.card.warn .cv { color: var(--warn); }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 16px 20px; margin-bottom: 16px; max-width: 900px;
}
.panel h3 { margin: 0 0 12px; font-size: 14px; }

.form-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 8px 14px; margin-bottom: 10px;
}
.form-grid label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.form-grid input, .form-grid select {
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px;
  font-size: 13px; color: var(--text); background: #fff;
}
.form-grid input.num { text-align: right; }
/* 富通主信息对齐：多行文本（文字唛）与只读框（产品款数/收款金额） */
.form-grid textarea {
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px;
  font-size: 13px; color: var(--text); background: #fff;
  font-family: inherit; resize: vertical;
}
.form-grid input.ro { background: #f8fafc; color: var(--muted); }
/* 富通必填红星：label 文字包在 .req 里（它才能和文字同行），星号由 CSS 前置成红色 */
.form-grid .req::before {
  content: "*"; color: var(--bad); font-weight: 700; margin-right: 2px;
}
/* 图片唛的网格单元（用 div 而非 label：点"移除"按钮不会触发文件选择框） */
.form-grid .fcell {
  display: flex; flex-direction: column; gap: 3px;
  font-size: 12px; color: var(--muted);
}
.form-grid .fcell input[type="file"] { font-size: 12px; color: var(--text); }
/* 订单弹窗：固定 4 列、按富通主信息逐格对齐（自适应列数会让行整体错位）；
   富通留空的格子用 .fcell-spacer 占位 */
#modal-order .form-grid { grid-template-columns: repeat(4, 1fr); }
.form-grid .fcell-spacer { min-height: 1px; }
/* 客户输入框占 2 列（联系人/联系人邮箱相应右移一格） */
#modal-order .form-grid .span2 { grid-column: span 2; }
@media (max-width: 900px) {
  #modal-order .form-grid { grid-template-columns: repeat(2, 1fr); }
}
/* 收款弹窗：固定三列，且标签再多行也把输入框压到底部对齐——
   保证 汇率/入账换算金额/银行扣费 等同行输入框在同一水平线上 */
#modal-receipt .form-grid { grid-template-columns: repeat(3, 1fr); }
#modal-receipt .form-grid label { justify-content: flex-end; }

/* 收款弹窗：水单附件行 */
.att-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.att-row label {
  display: flex; flex-direction: column; gap: 3px;
  font-size: 12px; color: var(--muted);
}
.att-row input[type="file"] { font-size: 12.5px; color: var(--text); }
.att-row .hint a { font-weight: 700; }

/* 弹窗 */
.modal {
  display: none; position: fixed; inset: 0; background: rgba(15,23,42,.45);
  z-index: 100; align-items: flex-start; justify-content: center; padding: 4vh 12px;
}
.modal.open { display: flex; }
.modal-box {
  background: #fff; border-radius: 10px; width: 720px; max-width: 100%;
  max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.modal-box.big { width: 1080px; }
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 18px; border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-head .x { border: none; background: none; font-size: 16px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 14px 18px; overflow: auto; }
.modal-body h4 { margin: 14px 0 8px; font-size: 13px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 18px; border-top: 1px solid var(--line);
}
#mo-lines input { padding: 4px 6px; border: 1px solid var(--line); border-radius: 4px; width: 100%; font-size: 12px; }
#mo-lines td { padding: 3px 4px; }
#mo-lines th { padding: 6px 4px; }
/* 额外费用登记表（产品明细下方） */
#mo-extra input, #mo-extra select {
  padding: 4px 6px; border: 1px solid var(--line); border-radius: 4px;
  width: 100%; font-size: 12px; color: var(--text); background: #fff;
}
#mo-extra td { padding: 3px 4px; }
#mo-extra th { padding: 6px 4px; }

/* 订单详情底部：挂接费用/挂接收款明细（点预览行的笔数展开，再点收起） */
.linked-block { display: none; margin-top: 10px; }
.linked-block.open { display: block; }
.linked-block h4 { margin: 0 0 6px; font-size: 12.5px; color: var(--primary-dark); }
.linked-block table { border: 1px solid var(--line); }
.linked-empty { color: var(--muted); font-size: 12px; padding: 4px 0; }
a.lnk.active { font-weight: 700; text-decoration: underline; }

/* 订单详情顶部：六环节流程进度条（下订单→采购→出运→结汇→对账→结算） */
.flow-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
  background: #f8fafc; border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 12px; margin-bottom: 12px;
}
.flow-steps { display: flex; flex: 1; min-width: 340px; }
.fstep { position: relative; flex: 1; text-align: center; padding: 24px 2px 4px; }
.fstep::after {              /* 节点连接线：本步圆心 → 下一步圆心 */
  content: ""; position: absolute; top: 13px; left: 50%; width: 100%;
  border-top: 2px solid var(--line);
}
.fstep:last-child::after { display: none; }
.fstep::before {             /* 节点圆点 */
  content: ""; position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  width: 12px; height: 12px; box-sizing: border-box; z-index: 1;
  border-radius: 50%; background: #fff; border: 2px solid var(--line);
}
.fstep.on::before { background: var(--primary); border-color: var(--primary); }
.fstep.on::after { border-top-color: var(--primary); }
.fstep.cur::before {         /* 当前环节：大一号 + 光圈 */
  width: 16px; height: 16px; top: 6px;
  box-shadow: 0 0 0 3px rgba(29, 111, 184, .18);
}
.fstep .fname { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.fstep .fdate { font-size: 11px; color: var(--muted); min-height: 14px; }
.fstep.on .fname { color: var(--primary-dark); }
.fstep.cur .fname, .fstep.cur .fdate { color: var(--primary); }
.flow-acts { display: flex; align-items: center; gap: 8px; }
/* 收款弹窗：银行扣费后面的币种提示（扣费币种=录入时选的币种） */
#mr-bank-cur { font-style: normal; font-weight: 700; color: var(--primary-dark); }

@media (max-width: 900px) {
  header { flex-direction: column; gap: 0; padding: 0 10px; align-items: stretch; }
  nav { padding-bottom: 4px; }
  main { padding: 10px; }
}

/* ============================================================
   云端账号登录：登录页 + 顶栏用户区 + 账号管理
   ============================================================ */
.userbar {
  margin-left: auto; display: flex; align-items: center; gap: 10px;
  padding: 6px 0; white-space: nowrap;
}
.user-chip { display: inline-flex; align-items: center; gap: 6px; color: #e8f1f9; font-size: 12.5px; }
.role-tag {
  display: inline-block; padding: 1px 7px; border-radius: 10px;
  background: rgba(255,255,255,.14); color: #d7e8f7; font-size: 11px;
}
.userbar button.linkbtn {
  background: transparent; border: none; color: #cfe0ef; padding: 4px 6px;
  font-size: 12.5px; border-radius: 5px;
}
.userbar button.linkbtn:hover { background: rgba(255,255,255,.1); color: #fff; }

/* 登录页 */
body.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; height: auto; overflow: auto;
  background: linear-gradient(135deg, #0f3352 0%, #1d5f95 55%, #2f86c8 100%);
}
.login-wrap { width: 100%; max-width: 400px; padding: 24px 16px; }
.login-card {
  background: #fff; border-radius: 14px; padding: 30px 30px 22px;
  box-shadow: 0 18px 50px rgba(0, 20, 40, .28);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.login-brand img { width: 46px; height: 46px; border-radius: 10px; }
.login-brand h1 { margin: 0; font-size: 19px; color: #123a5c; }
.login-brand p { margin: 3px 0 0; font-size: 12px; color: var(--muted); }
.login-card .lf { display: block; font-size: 12.5px; color: #374151; margin-bottom: 14px; }
.login-card .lf input {
  display: block; width: 100%; margin-top: 5px; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 7px; font-size: 14px;
  background: #fff; color: var(--text);
}
.login-card .lf input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29,111,184,.14);
}
.login-remember {
  display: flex; align-items: center; gap: 6px; font-size: 12.5px;
  color: var(--muted); margin: -2px 0 16px;
}
.login-remember input { width: auto; }
.login-btn { width: 100%; padding: 10px; font-size: 14.5px; border-radius: 8px; }
.login-msg { min-height: 18px; margin: 12px 0 0; font-size: 12.5px; }
.login-msg.err { color: var(--bad); }
.login-msg.ok { color: var(--ok); }
.login-foot {
  margin: 16px 0 0; padding-top: 12px; border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--muted); text-align: center;
}

/* 账号管理 / 操作日志 */
#panel-users .table-wrap, #panel-audit .table-wrap { max-height: 380px; }
#user-table td, #audit-table td { white-space: nowrap; }
.tag.role-admin { background: #dbeafe; color: #1d4ed8; }
.tag.role-finance { background: #dcfce7; color: var(--ok); }
.tag.role-sales { background: #fef3c7; color: var(--warn); }
.tag.role-viewer { background: #eef1f4; color: var(--muted); }
.tag.off { background: #fee2e2; color: var(--bad); }
.panel .panel-hint { font-weight: 400; font-size: 12px; color: var(--muted); margin-left: 8px; }
