* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --primary: #2563eb;
  --primary-d: #1d4ed8;
  --primary-grad: linear-gradient(135deg, #3b82f6 0%, #4f46e5 100%);
  --text: #0f172a;
  --muted: #64748b;
  --line: #e7eaf0;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 4px 16px rgba(15,23,42,.06);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}
.view { min-height: 100vh; }
.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login-view {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #dbeafe 0%, var(--bg) 55%);
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--card);
  border-radius: 20px;
  padding: 32px 24px 24px;
  box-shadow: 0 10px 40px rgba(37,99,235,.10), var(--shadow);
}
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.brand-logo { width: 56px; height: 56px; border-radius: 15px; box-shadow: 0 6px 16px rgba(79,70,229,.28); }
.brand-text h1 { font-size: 21px; font-weight: 700; letter-spacing: .5px; }
.brand-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.login-foot { text-align: center; color: #94a3b8; font-size: 12px; margin-top: 18px; letter-spacing: 1px; }

/* ---------- 表单元素 ---------- */
.field, label.field { display: block; font-size: 13px; color: var(--muted); margin-bottom: 14px; font-weight: 500; }
input, select, textarea {
  width: 100%; margin-top: 7px;
  padding: 12px 13px; font-size: 16px;
  border: 1.5px solid var(--line); border-radius: 11px;
  background: #fff; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 80px; font-family: inherit; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M6 8 0 0h12z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 34px; }

button { font-size: 15px; border: none; border-radius: 11px; padding: 12px 16px; cursor: pointer; font-weight: 600; transition: transform .08s, filter .15s, background .15s; }
button:active { transform: scale(.98); }
button.primary { width: 100%; background: var(--primary-grad); color: #fff; letter-spacing: 2px; box-shadow: 0 6px 16px rgba(37,99,235,.28); }
button.primary:disabled { filter: grayscale(.3) opacity(.7); }
button.ghost { background: transparent; color: var(--muted); padding: 7px 12px; font-weight: 500; border: 1px solid var(--line); }
button.small { padding: 7px 13px; font-size: 13px; }
.err { color: var(--bad); font-size: 13px; min-height: 18px; margin-top: 10px; text-align: center; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); padding: calc(10px + var(--safe-top)) 16px 10px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar-brand { display: flex; align-items: center; gap: 9px; }
.topbar-logo { width: 30px; height: 30px; border-radius: 8px; }
.topbar-title { font-weight: 700; font-size: 16px; letter-spacing: .5px; }
.topbar-version {
  font-size: 10px;
  color: var(--muted);
  background: #f1f5f9;
  padding: 2px 7px;
  border-radius: 999px;
  margin-left: 8px;
  letter-spacing: .5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.topbar-user { display: flex; align-items: center; gap: 12px; }
.user-meta { text-align: right; line-height: 1.25; }
.user-meta strong { font-size: 14px; }
.topbar .meta { display: block; color: var(--muted); font-size: 11px; }

/* ---------- 标签页 ---------- */
.tabs {
  display: flex; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: calc(51px + var(--safe-top)); z-index: 9;
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: 1 0 auto; background: none; border-radius: 0; color: var(--muted);
  padding: 13px 16px; font-size: 14px; font-weight: 500;
  border-bottom: 2.5px solid transparent; white-space: nowrap;
}
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

main { padding-bottom: calc(40px + var(--safe-bottom)); max-width: 1400px; margin: 0 auto; }
.page-title { font-size: 14px; font-weight: 600; color: var(--muted); margin: 16px 16px 4px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); margin: 12px;
}
.card .page-title { margin: 0 0 12px; font-size: 15px; color: var(--text); }

/* 记录卡片 */
.rec {
  background: var(--card); border-radius: 14px; padding: 15px; margin: 12px;
  box-shadow: var(--shadow);
  animation: rise .18s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.rec .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.rec .who { font-weight: 600; font-size: 15px; }
.rec .when { color: var(--muted); font-size: 13px; margin-top: 5px; }
.rec .reason { margin: 9px 0; font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.rec .sub { color: var(--muted); font-size: 12px; font-weight: 400; }
.badge { font-size: 12px; padding: 3px 11px; border-radius: 999px; white-space: nowrap; font-weight: 600; }
.badge.待审核 { background: #fef3c7; color: var(--warn); }
.badge.已通过 { background: #dcfce7; color: var(--ok); }
.badge.已驳回 { background: #fee2e2; color: var(--bad); }

.actions { display: flex; gap: 10px; margin-top: 13px; }
.actions button { flex: 1; }
button.approve { background: var(--ok); color: #fff; }
button.reject { background: var(--bad); color: #fff; }

.empty { text-align: center; color: var(--muted); padding: 48px 16px; font-size: 14px; }
.empty .empty-ico { font-size: 30px; opacity: .35; display: block; margin-bottom: 8px; }

/* 时长实时预览 */
.hours-preview { background: #eff6ff; color: var(--primary); border-radius: 10px; padding: 9px 13px; font-size: 14px; font-weight: 600; margin-bottom: 12px; text-align: center; }

/* 筛选 */
.filters { display: flex; flex-wrap: wrap; gap: 10px; }
.filters > div { flex: 1; min-width: 120px; }
.filters .field { margin-bottom: 0; }

/* 分段控件 */
.seg { display: flex; background: #eef2f7; border-radius: 10px; padding: 3px; margin: 12px; }
.seg button { flex: 1; background: none; color: var(--muted); padding: 8px; font-size: 13px; border-radius: 8px; }
.seg button.active { background: #fff; color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* 统计条 */
.summary-bar { display: flex; gap: 10px; margin: 12px; }
.stat { background: var(--card); border-radius: 14px; padding: 14px 10px; flex: 1; text-align: center; box-shadow: var(--shadow); }
.stat .n { font-size: 22px; font-weight: 700; color: var(--primary); }
.stat .l { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* 汇总表 */
.sumtable { margin: 12px; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.sumrow { display: flex; align-items: center; padding: 12px 15px; border-bottom: 1px solid var(--line); font-size: 14px; }
.sumrow:last-child { border-bottom: none; }
.sumrow.head { color: var(--muted); font-size: 12px; font-weight: 600; background: #fafbfc; }
.sumrow .c-name { flex: 1; font-weight: 600; }
.sumrow.head .c-name { font-weight: 600; }
.sumrow .c-dept { width: 78px; color: var(--muted); font-size: 13px; }
.sumrow .c-cnt { width: 52px; text-align: right; color: var(--muted); }
.sumrow .c-hrs { width: 70px; text-align: right; font-weight: 700; color: var(--primary); }
.sumrow.head .c-hrs, .sumrow.head .c-cnt { color: var(--muted); font-weight: 600; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(40px + var(--safe-bottom)); transform: translateX(-50%);
  background: rgba(15,23,42,.94); color: #fff; padding: 11px 20px; border-radius: 12px;
  font-size: 14px; z-index: 50; max-width: 80%; box-shadow: 0 8px 24px rgba(0,0,0,.25);
  animation: rise .18s ease both;
}

/* ---------- 通用数据表格（Excel 风格）---------- */
.data-table-wrap {
  overflow-x: auto;
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  margin: 0 12px;
}
.data-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: 680px;
  font-size: 13px;
}
.data-table th, .data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}
.data-table thead th {
  background: linear-gradient(180deg, #f8fafc, #eef2f7);
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 1px;
  border-bottom: 1.5px solid var(--line);
  padding: 11px 12px;
}
.data-table tbody tr { transition: background .12s; }
.data-table tbody tr:nth-child(even) { background: #fafbfc; }
.data-table tbody tr:hover { background: #eff6ff; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody td.cell-name { font-weight: 600; color: var(--text); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .strong { font-weight: 700; color: var(--text); }

/* 首列吸附（小屏横滚时保留姓名/日期可见）*/
.data-table thead th:first-child,
.data-table tbody td:first-child {
  position: sticky; left: 0; z-index: 1;
}
.data-table thead th:first-child {
  background: linear-gradient(180deg, #f8fafc, #eef2f7);
  z-index: 3;
}
.data-table tbody td:first-child { background: var(--card); }
.data-table tbody tr:nth-child(even) td:first-child { background: #fafbfc; }
.data-table tbody tr:hover td:first-child { background: #eff6ff; }
.data-table tbody tr.cs-expand-row td:first-child { position: static; background: #f8fafc; }

/* 表内编辑控件 */
.data-table input,
.data-table select,
.data-table textarea {
  width: 100%;
  padding: 6px 8px;
  font-size: 13px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  margin-top: 0;
  transition: background .15s, border-color .15s, box-shadow .15s;
  min-height: 30px;
}
.data-table input:hover,
.data-table select:hover,
.data-table textarea:hover { border-color: var(--line); background: #fff; }
.data-table input:focus,
.data-table select:focus,
.data-table textarea:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
  outline: none;
}

/* 单元格按钮 */
.cell-btn {
  background: #eef2ff;
  color: var(--primary);
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  white-space: nowrap;
}
.cell-btn:hover { background: #dbeafe; }
.cell-btn.bad { background: transparent; color: var(--bad); }
.cell-btn.bad:hover { background: #fee2e2; }
.cell-btn.ok { background: #dcfce7; color: var(--ok); }
.cell-btn.ok:hover { background: #bbf7d0; }
.cell-btn.warn { background: #fef3c7; color: var(--warn); }
.cell-btn.warn:hover { background: #fde68a; }
.cell-btn.gray { background: #f1f5f9; color: var(--muted); }
.cell-btn.gray:hover { background: #e2e8f0; }

/* 行内进度条 */
.cell-progress-wrap { display: flex; align-items: center; gap: 8px; min-width: 130px; }
.cell-progress { flex: 1; height: 6px; background: #f1f5f9; border-radius: 3px; overflow: hidden; }
.cell-progress-fill { height: 100%; background: var(--primary); transition: width .3s; }
.cell-progress-text { font-size: 11px; color: var(--muted); font-weight: 600; min-width: 38px; text-align: right; font-variant-numeric: tabular-nums; }

/* 紧凑型「报产量」 */
.prod-report-card { padding: 12px 14px; }
.prod-report-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.prod-field {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 0;
  background: #f8fafc; border-radius: 8px; padding: 2px 10px;
}
.prod-field > span { font-size: 12px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.prod-field input,
.prod-field select {
  margin-top: 0;
  padding: 8px 6px;
  font-size: 14px;
  min-height: 36px;
  border: 1px solid transparent !important;
  background: transparent;
}
.prod-field input:focus,
.prod-field select:focus { background: #fff !important; }
.prod-note-inline {
  flex: 1; min-width: 160px;
  margin-top: 0;
  padding: 9px 12px; font-size: 14px; min-height: 36px;
}
.prod-plan-info {
  font-size: 13px; color: var(--primary);
  background: #eff6ff; border-radius: 8px;
  padding: 8px 12px; margin-top: 8px;
}
.prod-steps-table { min-width: 540px; }
.prod-steps-table .p_qty_in {
  margin-top: 0; padding: 7px 10px; font-size: 15px; min-height: 34px;
  border: 1.5px solid var(--line); background: #fff;
}
.prod-steps-table .p_qty_in:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.prod-submit-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px 0;
}
.prod-submit-bar button.primary {
  flex: 1; padding: 12px; letter-spacing: 2px;
}
.prod-submit-bar .err { margin: 0; min-width: 100px; }

/* 紧凑型「新建生产计划」单行表单 */
.plan-add-card { padding: 12px 14px; }
.plan-add-title { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.plan-add-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
}
.plan-add-row input,
.plan-add-row select {
  margin-top: 0;
  padding: 8px 10px;
  font-size: 14px;
  min-height: 36px;
}
.plan-spec-group {
  display: flex; align-items: center; gap: 4px;
  padding: 0 4px;
  background: #f8fafc;
  border-radius: 8px;
}
.plan-spec-group input {
  width: 64px; text-align: center;
  background: transparent;
  border: 1px solid transparent !important;
  padding: 8px 4px;
}
.plan-spec-group input:focus { background: #fff !important; }
.plan-spec-group span { color: var(--muted); font-weight: 600; font-size: 14px; }
.plan-add-btn {
  width: auto;
  padding: 9px 22px;
  letter-spacing: 1px;
  font-size: 14px;
}

/* 表上方工具栏 */
.table-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin: 14px 12px 10px; gap: 8px; flex-wrap: wrap;
}
.table-toolbar .title { font-weight: 600; font-size: 15px; }
.table-toolbar .actions { display: flex; gap: 8px; }

/* 表内复选框/展开行 */
.data-table .cs-cb { width: auto !important; min-height: 0 !important; padding: 0 !important; }
.cs-expand-row td { padding: 14px !important; white-space: normal !important; }

/* 骨架/加载 */
.loading { text-align: center; color: var(--muted); padding: 40px; font-size: 14px; }
.spin { display: inline-block; width: 22px; height: 22px; border: 2.5px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
