/* ==========================================================
   仓库出入库系统 · 界面样式
   风格：深蓝顶栏 + 横向页签 + 白色卡片表单（对齐参考图）
   ========================================================== */
* { box-sizing: border-box; }
:root {
  --blue: #0d5aa7;
  --blue-deep: #0a4b8c;
  --blue-soft: #eef4fb;
  --blue-line: #dbe6f1;
  --green: #2f9e44;
  --red: #d92d20;
  --ink: #1f2d3d;
  --ink-2: #5c6b7a;
  --ink-3: #8a99a8;
  --line: #e3ebf3;
  --bg: #f2f4f7;
}
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.6 -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
}
.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(160deg, #0a4b8c 0%, #0d5aa7 45%, #0b4478 100%);
}
.login-card {
  width: 420px; max-width: 100%; background: #fff; border-radius: 10px;
  padding: 30px 32px 24px; box-shadow: 0 24px 50px rgba(4, 26, 51, .4);
}
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 24px; }
.login-mark {
  width: 46px; height: 46px; border-radius: 8px; background: var(--blue); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700;
}
.login-brand h1 { margin: 0; font-size: 20px; }
.login-brand p { margin: 3px 0 0; font-size: 12px; color: var(--ink-3); }
.fld { display: flex; align-items: center; margin-bottom: 14px; }
.fld span { width: 60px; color: var(--ink-2); font-size: 13px; }
.fld input {
  flex: 1; height: 38px; border: 1px solid var(--blue-line); background: #f9fbfd;
  border-radius: 4px; padding: 0 12px; font-size: 14px; outline: none;
}
.fld input:focus { border-color: var(--blue); background: #fff; }
.btn-primary {
  background: var(--blue); color: #fff; border: 0; border-radius: 4px; cursor: pointer;
  padding: 10px 18px; font-size: 14px;
}
.btn-primary:hover { background: var(--blue-deep); }
.btn-block { width: 100%; height: 42px; font-size: 16px; letter-spacing: 6px; margin-top: 6px; }
.login-error { color: var(--red); font-size: 13px; min-height: 20px; margin-top: 8px; }
.login-tip { color: var(--ink-3); font-size: 12px; margin: 8px 0 0; }

/* ---------- 顶栏 ---------- */
.app-header {
  background: linear-gradient(180deg, var(--blue-deep), var(--blue));
  color: #fff; box-shadow: 0 2px 6px rgba(10, 40, 70, .18);
}
.header-inner {
  max-width: 1240px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand-block { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 6px; background: rgba(255,255,255,.16);
  display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700;
}
.brand-text h1 { margin: 0; font-size: 21px; letter-spacing: 1px; font-weight: 700; }
.brand-text p { margin: 2px 0 0; font-size: 12px; color: rgba(255,255,255,.72); letter-spacing: .3px; }
.header-right { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.identity-label { color: rgba(255,255,255,.8); }
.identity-select {
  height: 32px; border: 1px solid rgba(255,255,255,.35); background: rgba(255,255,255,.12);
  color: #fff; border-radius: 4px; padding: 0 8px; outline: none; font-size: 13px;
}
.identity-select option { color: var(--ink); }
.user-label { color: rgba(255,255,255,.85); margin-left: 4px; white-space: nowrap; }
.role-badge {
  display: inline-block; padding: 2px 10px; border-radius: 3px;
  background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.3);
  color: #fff; font-size: 12.5px; white-space: nowrap;
}
.header-btn { white-space: nowrap; }
@media (max-width: 980px) {
  .header-inner { flex-direction: column; align-items: flex-start; gap: 10px; }
  .header-right { flex-wrap: wrap; row-gap: 8px; }
  .brand-text h1 { font-size: 18px; }
  .tabs-bar { padding: 0 12px; }
  .tab-item { padding: 11px 12px 9px; font-size: 13px; }
  .page { padding: 12px 12px 40px; }
  .card { padding: 14px 14px; }
}
.header-btn {
  background: transparent; border: 1px solid rgba(255,255,255,.35); color: #fff;
  height: 30px; padding: 0 10px; border-radius: 4px; font-size: 12.5px; cursor: pointer;
}
.header-btn:hover { background: rgba(255,255,255,.14); }

/* ---------- 页签 ---------- */
.tabs-bar {
  background: #fff; border-bottom: 1px solid #d9e2ec; display: flex; flex-wrap: nowrap;
  overflow-x: auto; scrollbar-width: thin;
  padding: 0 max(20px, calc((100vw - 1240px) / 2)); gap: 2px;
  position: sticky; top: 0; z-index: 10;
}
.tab-item {
  padding: 13px 16px 11px; font-size: 13.5px; color: #33475b; cursor: pointer;
  border-bottom: 3px solid transparent; white-space: nowrap; user-select: none;
}
.tab-item:hover { color: var(--blue); }
.tab-item.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }

/* ---------- 页面容器 ---------- */
.page { max-width: 1240px; margin: 0 auto; padding: 16px 20px 50px; }

.card {
  background: #fff; border-radius: 8px; box-shadow: 0 1px 4px rgba(16, 42, 67, .08);
  padding: 16px 20px; margin-bottom: 14px;
}
.sec-title {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px;
  font-size: 15px; font-weight: 700; color: #16324f; margin-bottom: 16px;
}
.sec-bar { width: 4px; height: 15px; background: #2166a8; display: inline-block; margin-right: 6px; border-radius: 2px; }
.sec-hint { font-size: 12px; font-weight: 400; color: var(--ink-3); margin-left: 8px; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 26px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 900px) { .form-grid { grid-template-columns: 1fr; } }
.fld { display: flex; align-items: center; }
.fld > span { width: 92px; flex: 0 0 92px; text-align: right; color: #5c6b7a; font-size: 13px; padding-right: 12px; }
.fld > span.req::after { content: " *"; color: var(--red); }
.fld input, .fld select, .fld textarea {
  flex: 1; min-width: 0; height: 36px; border: 1px solid var(--blue-line); background: #f8fafc;
  border-radius: 4px; padding: 0 10px; font-size: 13.5px; color: var(--ink); outline: none;
  font-family: inherit;
}
.fld textarea { height: auto; min-height: 38px; padding: 8px 10px; resize: vertical; }
.fld input:focus, .fld select:focus, .fld textarea:focus { border-color: #2c74c0; background: #fff; }
.fld input[readonly] { background: #f0f3f7; color: #5c6b7a; }

/* ---------- 表格 ---------- */
.table-scroll { overflow-x: auto; border-radius: 6px; }
table.grid-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.grid-table th {
  background: #eaf2fa; color: #27557f; font-weight: 600; padding: 9px 10px;
  border: 1px solid #d7e3f0; white-space: nowrap;
}
.grid-table td {
  padding: 6px 8px; border: 1px solid var(--line); background: #fff; height: 42px;
}
.grid-table td.num, .grid-table th.num { text-align: right; }
.grid-table tr:hover td { background: #fbfdff; }
.grid-table input, .grid-table select {
  width: 100%; border: 1px solid transparent; background: transparent; height: 30px;
  padding: 2px 6px; font-size: 13px; border-radius: 3px; outline: none; font-family: inherit;
}
.grid-table input:focus, .grid-table select:focus { border-color: #2c74c0; background: #fff; }
.grid-table input.num { text-align: right; }
.grid-table input[readonly] { background: transparent; color: #5c6b7a; }
.grid-table .pl-name { color: #27557f; }
.grid-table tfoot td { background: #f7fafd; font-weight: 600; }
.cell-muted { color: var(--ink-3); }

.btn-del {
  background: var(--red); color: #fff; border: 0; border-radius: 3px;
  padding: 5px 10px; font-size: 12px; cursor: pointer; line-height: 1.2;
}
.btn-del:hover { background: #b42318; }
.line-tools { display: flex; gap: 10px; margin: 10px 0 14px; flex-wrap: wrap; }
.btn-line {
  border: 1px solid #cfdbe8; background: #fff; color: #2c4a66; border-radius: 4px;
  padding: 6px 12px; font-size: 13px; cursor: pointer;
}
.btn-line:hover { border-color: #2c74c0; color: var(--blue); }
.summary-bar {
  background: #eef3f8; border-radius: 6px; padding: 10px 18px;
  display: flex; justify-content: flex-end; gap: 28px; font-size: 13px; color: var(--ink-2);
  margin-bottom: 16px; flex-wrap: wrap;
}
.summary-bar b { color: #16324f; font-size: 14px; }
.summary-bar .money { color: #1f9d55; }
.form-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.btn-save {
  background: var(--green); color: #fff; border: 0; border-radius: 4px;
  padding: 11px 22px; font-size: 14px; font-weight: 600; cursor: pointer; letter-spacing: .5px;
}
.btn-save:hover { background: #268039; }
.btn-save:disabled { background: #9cc7a8; cursor: not-allowed; }
.btn-reset {
  background: #fff; color: var(--blue); border: 1px solid #b9cde3; border-radius: 4px;
  padding: 10px 20px; font-size: 14px; cursor: pointer;
}
.btn-reset:hover { background: #f5f9ff; }
.btn-ghost {
  background: #fff; border: 1px solid var(--blue-line); color: #33475b;
  border-radius: 4px; padding: 7px 14px; font-size: 13px; cursor: pointer;
}
.btn-ghost:hover { border-color: #2c74c0; color: var(--blue); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; border-radius: 3px; }
.btn-danger { border-color: #f0c3bf; color: var(--red); }

/* ---------- 记录页 ---------- */
.page-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px;
}
.page-toolbar .spacer { flex: 1; }
.page-toolbar input, .page-toolbar select {
  height: 34px; border: 1px solid var(--blue-line); border-radius: 4px;
  padding: 0 10px; background: #fff; font-size: 13px; outline: none;
}
.page-toolbar input[type=search] { width: 210px; }
.page-toolbar input:focus, .page-toolbar select:focus { border-color: #2c74c0; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 3px; font-size: 12px; line-height: 19px; }
.tag-done { background: #e7f6ec; color: #1f8a3b; }
.tag-draft { background: #fff4e5; color: #b25f00; }
.tag-red { background: #fdecea; color: var(--red); }
.empty { padding: 44px 0; text-align: center; color: var(--ink-3); font-size: 13px; }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 12px; font-size: 12.5px; color: var(--ink-3); }

/* ---------- 库存 ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: #fff; border-radius: 8px; padding: 14px 16px; box-shadow: 0 1px 4px rgba(16,42,67,.08); }
.kpi .l { color: var(--ink-3); font-size: 12.5px; }
.kpi .v { font-size: 20px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi.blue { background: linear-gradient(135deg, #0d5aa7, #2273c9); color: #fff; }
.kpi.blue .l { color: rgba(255,255,255,.78); }

/* ---------- 子页签 ---------- */
.sub-tabs { display: flex; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; }
.sub-tab {
  padding: 7px 16px; border-radius: 4px; background: #fff; border: 1px solid var(--blue-line);
  font-size: 13px; color: #33475b; cursor: pointer;
}
.sub-tab.active { background: var(--blue); border-color: var(--blue); color: #fff; }

/* ---------- 图表 ---------- */
.bar-chart { display: flex; align-items: flex-end; gap: 4px; height: 150px; padding-top: 12px; }
.bar { flex: 1; height: 100%; position: relative; min-width: 4px; }
.bar > i { position: absolute; bottom: 0; left: 0; right: 0; background: #2c74c0; border-radius: 3px 3px 0 0; display: block; opacity: .85; }
.chart-legend { display: flex; justify-content: space-between; color: var(--ink-3); font-size: 11.5px; margin-top: 6px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(12, 32, 56, .45); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow: auto;
}
.modal {
  background: #fff; border-radius: 8px; width: 560px; max-width: 100%;
  box-shadow: 0 20px 44px rgba(8, 28, 52, .28);
}
.modal.wide { width: 940px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--blue-line); background: #f7fafd;
  border-radius: 8px 8px 0 0;
}
.modal-head h3 { margin: 0; font-size: 15px; color: #16324f; }
.modal-close { border: 0; background: none; font-size: 20px; color: var(--ink-3); cursor: pointer; line-height: 1; }
.modal-body { padding: 18px; max-height: 70vh; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--blue-line); }
.btn { padding: 8px 16px; border: 1px solid var(--blue-line); background: #fff; border-radius: 4px; cursor: pointer; font-size: 13.5px; }
.btn:hover { border-color: #2c74c0; color: var(--blue); }

/* ---------- Toast ---------- */
.toast-root { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  padding: 9px 16px; border-radius: 4px; background: #16324f; color: #fff; font-size: 13.5px;
  box-shadow: 0 8px 20px rgba(8, 28, 52, .25); max-width: 80vw;
}
.toast.ok { background: #1f8a3b; }
.toast.err { background: #b42318; }

/* 弹窗按钮：.btn 基础样式会把 btn-primary 的底色盖掉，这里提高优先级 */
.btn.btn-primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn.btn-primary:hover { background: var(--blue-deep); border-color: var(--blue-deep); }
.btn.btn-danger:hover { background: #fff6f5; }
