/* ============================================================
   生产计件工资系统 · 基础样式（PC 与 H5 共用）
   零构建、零 CDN，全部本地资源
   ============================================================ */

:root {
  --c-primary: #2563eb;
  --c-primary-hover: #1d4ed8;
  --c-primary-soft: #eff4ff;
  --c-primary-border: #c7d7fe;

  --c-text: #1e293b;
  --c-text-2: #475569;
  --c-text-3: #94a3b8;

  --c-bg: #f5f7fb;
  --c-surface: #ffffff;
  --c-border: #e6eaf2;
  --c-border-strong: #d3dae6;

  --c-success: #16a34a;
  --c-success-soft: #ecfdf3;
  --c-warn: #d97706;
  --c-warn-soft: #fffbeb;
  --c-danger: #dc2626;
  --c-danger-soft: #fef2f2;
  --c-info: #0e7490;
  --c-info-soft: #ecfeff;

  --radius: 10px;
  --radius-sm: 8px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow: 0 2px 8px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.12);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 数字与金额 ---------- */
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.money { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 600; }
.money::before { content: "¥"; font-size: 0.85em; opacity: 0.6; margin-right: 1px; font-weight: 400; }
.text-muted { color: var(--c-text-3); }
.text-2 { color: var(--c-text-2); }
.text-success { color: var(--c-success); }
.text-danger { color: var(--c-danger); }
.text-warn { color: var(--c-warn); }
.text-sm { font-size: 12.5px; }
.text-lg { font-size: 16px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.elide { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 布局 ---------- */
.row { display: flex; align-items: center; gap: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }
.gap-4 { gap: 4px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 16px 18px; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--c-border);
  font-weight: 600;
}
.card-body { padding: 16px 18px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--c-border-strong);
  background: #fff;
  color: var(--c-text);
  font-size: 13.5px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, opacity 0.15s;
  user-select: none;
}
.btn:hover { background: #f8fafc; border-color: #b9c3d4; }
.btn:active { transform: translateY(0.5px); }
.btn:focus-visible { outline: 2px solid var(--c-primary-border); outline-offset: 1px; }
.btn[disabled],
.btn.is-disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; box-shadow: 0 1px 2px rgba(37, 99, 235, 0.28); }
.btn-primary:hover { background: var(--c-primary-hover); border-color: var(--c-primary-hover); }
.btn-success { background: var(--c-success); border-color: var(--c-success); color: #fff; }
.btn-success:hover { background: #15803d; border-color: #15803d; }
.btn-danger { background: var(--c-danger); border-color: var(--c-danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: #eef2f8; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn-lg { height: 42px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-link { background: none; border: none; color: var(--c-primary); cursor: pointer; font-size: inherit; padding: 0; font-family: inherit; }
.btn-link:hover { text-decoration: underline; }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label,
.label { font-size: 12.5px; color: var(--c-text-2); font-weight: 500; }
.label-req::after { content: " *"; color: var(--c-danger); }

.input,
select.input,
textarea.input {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--c-text);
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea.input { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.6; }
.input:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.input:disabled, .input[readonly] { background: #f6f8fb; color: var(--c-text-2); cursor: default; }
.input-error { border-color: var(--c-danger) !important; }
select.input { appearance: none; background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8.5 1.8 4.3l.9-.9L6 6.7l3.3-3.3.9.9z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; padding-right: 26px; }
.hint { font-size: 12px; color: var(--c-text-3); }
.err-text { font-size: 12px; color: var(--c-danger); }

.check { display: inline-flex; align-items: flex-start; gap: 7px; font-size: 13px; cursor: pointer; line-height: 1.5; }
.check input { margin: 3px 0 0; width: 15px; height: 15px; accent-color: var(--c-primary); flex: none; }

/* ---------- 表格 ---------- */
.table-wrap { width: 100%; overflow: auto; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.tbl th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--c-text-2);
  background: #f8fafc;
  padding: 10px 12px;
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}
table.tbl td { padding: 10px 12px; border-bottom: 1px solid #f1f4f9; vertical-align: middle; }
table.tbl tbody tr:hover td { background: #fafbfe; }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl td.right, table.tbl th.right { text-align: right; }
table.tbl td.center, table.tbl th.center { text-align: center; }
table.tbl tr.row-total td { background: #f8fafc; font-weight: 600; }
.tbl-click tbody tr { cursor: pointer; }

/* ---------- 徽标 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  background: #f1f5f9;
  color: var(--c-text-2);
  border: 1px solid transparent;
}
.badge-gray { background: #f1f5f9; color: #64748b; }
.badge-blue { background: var(--c-primary-soft); color: var(--c-primary); }
.badge-amber { background: var(--c-warn-soft); color: var(--c-warn); }
.badge-green { background: var(--c-success-soft); color: var(--c-success); }
.badge-red { background: var(--c-danger-soft); color: var(--c-danger); }
.badge-cyan { background: var(--c-info-soft); color: var(--c-info); }
.badge-dot::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* ---------- 空态 / 加载 ---------- */
.empty { padding: 44px 20px; text-align: center; color: var(--c-text-3); font-size: 13px; }
.empty svg { display: block; margin: 0 auto 10px; opacity: 0.5; }
.loading { padding: 40px; text-align: center; color: var(--c-text-3); font-size: 13px; }
.spinner {
  width: 18px; height: 18px; margin: 0 auto 8px;
  border: 2px solid var(--c-border-strong);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 提示条 ---------- */
.alert {
  display: flex;
  gap: 9px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.55;
  border: 1px solid transparent;
}
.alert-info { background: var(--c-primary-soft); color: #1e40af; border-color: var(--c-primary-border); }
.alert-warn { background: var(--c-warn-soft); color: #92400e; border-color: #fde68a; }
.alert-danger { background: var(--c-danger-soft); color: #991b1b; border-color: #fecaca; }
.alert-success { background: var(--c-success-soft); color: #166534; border-color: #bbf7d0; }
.alert b { font-weight: 600; }

/* ---------- 弹层 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  animation: fade 0.15s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: pop 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.modal-lg { max-width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--c-border); }
.modal-head h3 { font-size: 15.5px; }
.modal-body { padding: 18px 20px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--c-border); background: #fcfdff; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.modal-close { border: none; background: none; font-size: 20px; line-height: 1; color: var(--c-text-3); cursor: pointer; padding: 2px 4px; border-radius: 6px; }
.modal-close:hover { background: #f1f5f9; color: var(--c-text); }

/* Toast */
#toast-root { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  background: #1e293b;
  color: #fff;
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.2s ease;
  max-width: 80vw;
}
.toast.ok { background: #166534; }
.toast.err { background: #b91c1c; }
.toast.warn { background: #b45309; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } }

/* ---------- 描述列表 ---------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; font-size: 13px; }
.kv dt { color: var(--c-text-3); }
.kv dd { margin: 0; color: var(--c-text); }

/* ---------- 工具 ---------- */
.divider { height: 1px; background: var(--c-border); margin: 14px 0; }
.scroll-x { overflow-x: auto; }
.pointer { cursor: pointer; }
.hidden { display: none !important; }
.tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: #f1f5f9;
  color: var(--c-text-2);
  font-size: 11.5px;
  margin-left: 6px;
}

/* 打印：只留报表主体 */
@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
}
