:root {
  --bg: #f4f6f9; --card: #ffffff; --border: #e3e8ef; --text: #1f2937;
  --muted: #6b7280; --primary: #2563eb; --primary-dark: #1d4ed8;
  --green: #16a34a; --red: #dc2626; --amber: #d97706;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif; background: var(--bg); color: var(--text); }
.nav { background: #1e3a8a; box-shadow: 0 2px 8px rgba(0,0,0,.12); position: sticky; top: 0; z-index: 10; }
.nav-inner { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; gap: 4px; padding: 0 16px; overflow-x: auto; scrollbar-width: thin; }
.nav .brand { color: #fff; font-weight: 700; font-size: 17px; margin-right: 24px; line-height: 48px; white-space: nowrap; flex-shrink: 0; }
.nav a { color: #c7d2fe; text-decoration: none; padding: 0 14px; line-height: 48px; font-size: 15px; white-space: nowrap; flex-shrink: 0; }
.nav a:hover { color: #fff; }
.nav a.active { color: #fff; background: rgba(255,255,255,.14); border-bottom: 2px solid #93c5fd; }
.nav-user { color: #93c5fd; font-size: 13px; margin-right: 10px; white-space: nowrap; flex-shrink: 0; }
.container { max-width: 1200px; margin: 20px auto 60px; padding: 0 16px; }
h2 { font-size: 20px; margin-bottom: 14px; }
h3 { font-size: 16px; margin: 18px 0 10px; color: #374151; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 18px; margin-bottom: 16px; }
.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 6px; color: var(--primary); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { background: #f8fafc; color: #475569; font-weight: 600; }
tr:hover td { background: #f8fbff; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.bar { position: relative; background: #eef2f7; border-radius: 4px; height: 18px; min-width: 90px; overflow: hidden; }
.bar > span { position: absolute; left: 6px; top: 0; line-height: 18px; font-size: 12px; color: #1e3a8a; z-index: 2; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg,#60a5fa,#2563eb); }
.bar > i.full { background: linear-gradient(90deg,#4ade80,#16a34a); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
input, select, button { font: inherit; }
input, select { padding: 7px 10px; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; color: var(--text); }
input:focus, select:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }
button { padding: 7px 16px; border: none; border-radius: 6px; background: var(--primary); color: #fff; cursor: pointer; }
button:hover { background: var(--primary-dark); }
button.ghost { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
button.danger { background: #fff; color: var(--red); border: 1px solid #fca5a5; }
button.danger:hover { background: #fef2f2; }
button.small { padding: 3px 10px; font-size: 13px; }
.muted { color: var(--muted); font-size: 13px; }
.right { text-align: right; }
.tabs { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; }
.tabs button { border-radius: 0; background: #fff; color: #475569; border: none; border-right: 1px solid var(--border); padding: 8px 18px; }
.tabs button:last-child { border-right: none; }
.tabs button.on { background: var(--primary); color: #fff; }
.total-row td { font-weight: 700; background: #f0f6ff !important; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: #e0e7ff; color: #3730a3; }
.toast { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%) translateY(20px); opacity: 0;
  padding: 10px 22px; border-radius: 8px; color: #fff; font-size: 14px; transition: all .25s; pointer-events: none; z-index: 99; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: #16a34a; } .toast.err { background: #dc2626; }
.empty { text-align: center; color: var(--muted); padding: 30px 0; }
dialog { border: none; border-radius: 10px; padding: 22px; min-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog h3 { margin-top: 0; }
.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.form-row input, .form-row select { width: 100%; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
@media (max-width: 700px) { th, td { padding: 6px; font-size: 12px; } .nav a { padding: 0 8px; } }

/* ---- 表格填报 ---- */
.grid-wrap { max-height: calc(100vh - 320px); overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.grid-table { border-collapse: separate; border-spacing: 0; }
.grid-table thead th { position: sticky; top: 0; z-index: 3; box-shadow: 0 1px 0 var(--border); }
.grid-table td { background: #fff; padding: 5px 8px; }
.grid-table tr.dirty td { background: #fffbeb; }
.grid-table tr.dirty td:first-child { box-shadow: inset 3px 0 0 var(--amber); }
.grid-table input.qty-in, .grid-table input.note-in {
  width: 100%; padding: 5px 8px; border: 1px solid #dbe3ec; border-radius: 5px; font-size: 14px;
}
.grid-table input.qty-in { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: #1d4ed8; }
.grid-table input.qty-in:focus, .grid-table input.note-in:focus {
  background: #fff; border-color: var(--primary); outline: 2px solid #bfdbfe;
}
.grid-table input.qty-in::-webkit-outer-spin-button,
.grid-table input.qty-in::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.savebar {
  position: sticky; bottom: 0; margin-top: 12px; display: flex; align-items: center; gap: 12px;
  background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 10px 16px;
  box-shadow: 0 -4px 16px rgba(15,23,42,.08); z-index: 5;
}
.savebar #saveInfo { flex: 1; font-size: 13px; color: var(--muted); }
.savebar button { padding: 8px 22px; }
/* ---- 批量上传区 ---- */
.upload-box {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  border: 2px dashed #bfdbfe; border-radius: 10px; background: #f8fbff;
  padding: 26px 16px; cursor: pointer; text-align: center;
}
.upload-box:hover, .upload-box.drag { border-color: var(--primary); background: #eff6ff; }
.upload-box span:first-child { color: var(--primary); font-weight: 600; }

button.attention { animation: pulse 1.4s infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(37,99,235,.5); }
  50% { box-shadow: 0 0 0 8px rgba(37,99,235,0); }
}

/* ---- 可复制的统计结果 ---- */
.copybox {
  margin-top: 18px; border: 1px solid #bfdbfe; background: #f8fbff;
  border-radius: 10px; padding: 14px 16px;
}
.copybox-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.copybox-head b { color: var(--primary); }
.copybox textarea {
  width: 100%; box-sizing: border-box; min-height: 210px; resize: vertical;
  font-family: Consolas, "Courier New", "Microsoft YaHei", monospace;
  font-size: 13px; line-height: 1.75; color: var(--text);
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; white-space: pre; overflow: auto;
}

/* ---- 顶部项目切换 ---- */
.nav .proj-sel {
  height: 30px; max-width: 240px; min-width: 60px; margin-right: 10px; padding: 0 8px;
  font-size: 13px; border-radius: 6px; cursor: pointer;
  background: rgba(255,255,255,.15); color: #fff;
  border: 1px solid rgba(255,255,255,.35);
  flex: 0 1 auto; text-overflow: ellipsis;
}
.nav .proj-sel option { color: #1f2937; background: #fff; }
.nav .proj-sel:focus { outline: 2px solid #93c5fd; }
@media (max-width: 900px) { .nav .proj-sel { max-width: 140px; } }

/* ---- 项目卡片 ---- */
.proj-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.proj-card { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; background: #fff; }
.proj-card.cur { border-color: var(--primary); box-shadow: 0 0 0 3px #dbeafe; }
.proj-card h4 { font-size: 16px; margin-bottom: 4px; }
.proj-card .meta { color: var(--muted); font-size: 13px; line-height: 1.8; }
.proj-card .ops { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- 施工日志 ---- */
textarea { width: 100%; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 6px;
  font-family: inherit; color: var(--text); resize: vertical; background: #fff; }
textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }
.grid-4 > div > label, .grid > div > label {
  display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.grid-4 input, .grid-4 textarea { width: 100%; }
#printArea { display: none; white-space: pre-wrap; font-family: SimSun, "宋体", serif;
  font-size: 14pt; line-height: 1.9; color: #000; }

/* 施工日志：手写签名上传 */
.sign-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
.sign-box { border: 1px dashed var(--border); border-radius: 8px; padding: 8px 12px;
  min-width: 250px; background: #fff; }
.sign-head { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.sign-pic { height: 54px; display: flex; align-items: center; justify-content: center;
  background: #fafbfc; border-radius: 6px; font-size: 13px; }
.sign-pic img { max-height: 50px; max-width: 230px; }
.sign-ops { display: flex; gap: 8px; margin-top: 6px; }
@media print {
  .nav, .no-print, #toast { display: none !important; }
  body { background: #fff; }
  .container { max-width: none; margin: 0; padding: 0; }
  #printArea { display: block; }
}
