:root {
  --navy: #1d2a3a;
  --accent: #2f6fde;
  --accent-dark: #2156b5;
  --bg: #f4f6f9;
  --card: #fff;
  --text: #17202b;
  --muted: #667385;
  --line: #dde3ea;
  --err: #b42318; --err-soft: #fee4e2;
  --ok: #067647;  --ok-soft: #dcfae6;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: var(--accent-dark); }
h1 { font-size: 1.4rem; margin: 0 0 14px; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 20px 16px 60px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; font-weight: normal; }
.inline { display: inline; margin: 0; }

/* 顶部导航 */
.top { background: var(--navy); color: #fff; }
.top-in { max-width: 1200px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 18px; min-height: 52px; flex-wrap: wrap; }
.brand { color: #fff; font-weight: 700; text-decoration: none; font-size: 1.05rem; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a { color: #c9d4e3; text-decoration: none; padding: 14px 10px; white-space: nowrap; border-bottom: 3px solid transparent; }
.nav a.on, .nav a:hover { color: #fff; border-bottom-color: #6fa0ff; }
.me { display: flex; gap: 10px; align-items: center; font-size: .9rem; }
.me a { color: #c9d4e3; }
button.link { background: none; border: 0; color: #c9d4e3; font: inherit; cursor: pointer; text-decoration: underline; padding: 0; }
@media (max-width: 700px) {
  .top-in { gap: 0 12px; padding-top: 8px; }
  .nav { order: 3; flex-basis: 100%; }
  .nav a { padding: 10px 8px; }
  .me { margin-left: auto; }
}

/* 卡片、表单 */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.panel.narrow { max-width: 560px; }
.login { max-width: 360px; margin: 60px auto; }
label { display: block; margin-bottom: 12px; font-size: .9rem; color: var(--muted); }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 9px 10px; font: inherit; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bcd3fb; border-color: var(--accent); }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); }
label.check input { width: auto; margin: 0; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid .span2 { grid-column: span 2; }
@media (max-width: 700px) { .grid { grid-template-columns: 1fr; } .grid .span2 { grid-column: auto; } }
.actions { display: flex; gap: 10px; margin-top: 8px; }
.danger-zone { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }

.btn { display: inline-block; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--text);
  font: inherit; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.danger { color: var(--err); border-color: #f3b7b1; }
.btn.full { width: 100%; }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.err { background: var(--err-soft); color: var(--err); }

/* 列表 */
.head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.search { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.search input { flex: 1; min-width: 180px; margin: 0; }
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
.list th, .list td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.list th { background: #f8fafc; font-weight: 600; font-size: .85rem; color: var(--muted); }
.list tbody tr { cursor: pointer; }
.list tbody tr:hover { background: #f5f8ff; }
.list tr.off td { color: var(--muted); }
.list .r { text-align: right; }

.tiles { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px; min-width: 150px;
  text-decoration: none; color: var(--text); display: flex; flex-direction: column; }
.tile .num { font-size: 1.8rem; font-weight: 700; color: var(--accent-dark); }

/* ---------- 单据 ---------- */
h3 { font-size: 1.05rem; margin: 18px 0 10px; }
.tabs { display: flex; gap: 4px; margin: 4px 0 12px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.search select { width: auto; margin: 0; max-width: 220px; }
.inline-label { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--text); }
.inline-label input { margin: 0; width: auto; }
.tag { display: inline-block; font-size: .78rem; padding: 1px 8px; border-radius: 999px; background: #eef2f7; color: #334; white-space: nowrap; }
.tag.t-quote { background: #fff4e0; color: #9a5b00; }
.tag.t-order { background: #e7f0ff; color: #1f4fa8; }
.tag.t-invoice { background: #e3f8ec; color: #08703f; }
.st { font-size: .85rem; }
.st-已完工, .st-已付款 { color: var(--ok); font-weight: 600; }
.st-已欠费, .st-已延迟 { color: var(--err); font-weight: 600; }
.list td.clip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 14px; }
.actions.wrap { flex-wrap: wrap; }
.actions form { margin: 0; }
.head .actions { margin: 0; }

.doc .panel { margin-bottom: 14px; }
.grid4 { display: grid; grid-template-columns: 2fr 2fr 1fr 1fr; gap: 0 14px; }
@media (max-width: 900px) { .grid4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .grid4 { grid-template-columns: 1fr; } }
.checks { display: flex; gap: 18px; flex-wrap: wrap; }
.checks label { margin: 0; }

.lines-wrap { margin-bottom: 8px; }
table.lines { width: 100%; border-collapse: collapse; min-width: 1050px; }
.lines th { background: #f8fafc; font-size: .8rem; color: var(--muted); padding: 8px 4px; text-align: left; font-weight: 600; white-space: nowrap; }
.lines td { padding: 3px 4px; border-top: 1px solid var(--line); vertical-align: middle; }
.lines input, .lines select { margin: 0; padding: 6px 6px; font-size: .92rem; }
.lines .no { color: var(--muted); width: 28px; text-align: center; }
.lines .w-name { min-width: 230px; }
.lines input.n { width: 78px; text-align: right; }
.lines input.n.s { width: 58px; }
.lines td.c { text-align: center; }
.lines td.c input { width: auto; }
.lines .f-sub { min-width: 90px; font-variant-numeric: tabular-nums; }
.lines .r { text-align: right; }
.lines .manual { display: none; font-size: .72rem; color: #9a5b00; cursor: pointer; white-space: nowrap; margin-left: 4px; }
.lines tr.is-manual .manual { display: inline; }
.lines tr.is-manual .f-measure { background: #fff7e6; border-color: #f0c36d; }
.lines tr.pt-length .f-wid, .lines tr.pt-length .f-wid-e, .lines tr.pt-length .f-dbl,
.lines tr.pt-qty .f-wid, .lines tr.pt-qty .f-wid-e, .lines tr.pt-qty .f-dbl,
.lines tr.pt-qty .f-len, .lines tr.pt-qty .f-len-e { visibility: hidden; }
.link-btn { background: none; border: 0; cursor: pointer; color: var(--muted); font-size: 1rem; padding: 4px 6px; }
.link-btn:hover { color: var(--err); }
.line-tools { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }

.totals { max-width: 380px; margin-left: auto; display: flex; flex-direction: column; gap: 6px; }
.totals > div { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.totals > div > span:first-child { color: var(--muted); }
.totals input { width: 130px; margin: 0; text-align: right; display: inline-block; }
.totals input.is-manual { background: #fff7e6; border-color: #f0c36d; }
.totals .grand { border-top: 2px solid var(--text); padding-top: 8px; font-size: 1.2rem; }
.doc-more { margin-top: 18px; }

/* ---------- 标签学习 ---------- */
.good { color: var(--ok); font-weight: 600; }
.bad { color: var(--err); font-weight: 600; }
.scans { display: flex; flex-direction: column; gap: 12px; }
.scan { display: flex; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.scan.corr { border-left: 4px solid #f0a020; }
.scan.excl { opacity: .55; }
.scan img { width: 180px; height: 130px; object-fit: contain; background: #eee; border-radius: 8px; }
.scan-body { flex: 1; min-width: 0; }
.scan .actions { flex-wrap: wrap; margin-top: 8px; }
.scan .actions .btn { padding: 6px 12px; font-size: .9rem; }
table.cmp { border-collapse: collapse; margin-top: 6px; font-size: .92rem; }
.cmp th, .cmp td { padding: 3px 12px 3px 0; text-align: left; }
.cmp th { color: var(--muted); font-weight: 600; font-size: .8rem; }
.cmp tr.diff td { background: #fff4e0; }
@media (max-width: 600px) { .scan { flex-direction: column; } .scan img { width: 100%; } }
.teach { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 800px) { .teach { grid-template-columns: 1fr; } }
.teach-img { width: 100%; max-height: 70vh; object-fit: contain; background: #eee; border-radius: 10px; }
.boxes { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.box-btn { border: 1px solid var(--line); background: #f8fafc; border-radius: 8px; padding: 6px 10px; cursor: pointer; font: inherit; }
.box-btn:hover { border-color: var(--accent); }
.box-btn.picked { background: #e7f0ff; border-color: var(--accent); }
.alert.warn { background: #fff4e0; color: #8a5200; }

/* ---------- 完工短信 ---------- */
.finish textarea { font-size: 1rem; }
.m-wide { width: 100%; padding: 14px; font-size: 1.05rem; margin-top: 6px; }
.sms-log { display: flex; flex-direction: column; gap: 8px; }
.sms-row { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.sms-st { float: right; font-size: .85rem; font-weight: 600; }
.sms-sent { color: var(--ok); } .sms-failed { color: var(--err); } .sms-dev { color: var(--muted); }
.notice { background: #fff4e0; border: 1px solid #f0c36d; border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; }
