:root {
  --accent: #e8833a;
  --accent-dark: #c96a26;
  --ink: #1f2430;
  --muted: #8b909c;
  --line: #ececf0;
  --bg: #f5f6f8;
  --side: #1f2430;
  --side-soft: #2a3140;
  --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--ink); }
a { text-decoration: none; color: inherit; }

.layout { display: grid; grid-template-columns: 234px 1fr; min-height: 100vh; }

/* sidebar */
.sidebar { background: var(--side); color: #cdd2da; display: flex; flex-direction: column; padding: 18px 14px; position: sticky; top: 0; height: 100vh; }
.side-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; color: #fff; font-size: 18px; padding: 8px 8px 18px; }
.side-brand .mark { width: 32px; height: 32px; border-radius: 8px; background: linear-gradient(135deg,var(--accent),#f3b07a); display: grid; place-items: center; color: #fff; }
.side-brand .mark.has-logo { background: none; }
.side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.side-nav a { display: flex; align-items: center; gap: 11px; padding: 11px 13px; border-radius: 9px; color: #aeb4bf; font-size: 14.5px; transition: .15s; }
.side-nav a:hover { background: var(--side-soft); color: #fff; }
.side-nav a.active { background: var(--accent); color: #fff; font-weight: 600; }
.nav-group { margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,.08); }
.nav-group-title { padding: 4px 13px 8px; font-size: 12px; letter-spacing: 1.2px; color: #6f7887; }
.side-nav .nav-group a { padding-left: 24px; font-size: 14px; }
.side-foot { padding-top: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.side-link { display: block; padding: 10px 13px; color: #98a0ad; font-size: 13.5px; border-radius: 9px; }
.side-link:hover { background: var(--side-soft); color: #fff; }

/* main */
.main { display: flex; flex-direction: column; }
.topbar { height: 62px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 26px; position: sticky; top: 0; z-index: 20; }
.crumb { font-size: 17px; font-weight: 700; }
.top-actions { display: flex; align-items: center; gap: 16px; }
.who { color: var(--muted); font-size: 14px; }
.logout { border: 1px solid var(--line); background: #fff; padding: 7px 15px; border-radius: 8px; cursor: pointer; font-size: 13.5px; color: var(--ink); }
.logout:hover { border-color: var(--accent); color: var(--accent); }
.content { padding: 26px; flex: 1; }

.loading { color: var(--muted); padding: 40px; text-align: center; }

/* cards */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 26px; }
.cards.cards-3 { grid-template-columns: repeat(3, 1fr); }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.stat .lbl { color: var(--muted); font-size: 13px; }
.stat .num { font-size: 28px; font-weight: 800; margin-top: 6px; }
.stat .num.accent { color: var(--accent); }
.stat .num.green { color: #1f9d5b; }
.stat .num.red { color: #d9534f; }

.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.table-wrap { overflow-x: auto; }
.table-wrap table { min-width: 100%; }
.table-wrap th, .table-wrap td { white-space: nowrap; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.panel-head h3 { font-size: 17px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input, .toolbar select { padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.toolbar .spacer { flex: 1; }

/* table */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 13px; background: #fafbfc; }
tbody tr:hover { background: #fafbfc; }
.tag-pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; background: #eef0f3; color: #555; }
.tag-pill.green { background: #e6f7ee; color: #1f9d5b; }
.tag-pill.orange { background: #fff1e6; color: var(--accent-dark); }
.tag-pill.blue { background: #e8f0fe; color: #2f6bdc; }
.bar { height: 7px; background: #eee; border-radius: 99px; overflow: hidden; width: 90px; display: inline-block; vertical-align: middle; }
.bar > i { display: block; height: 100%; background: var(--accent); }

/* 财务总览 */
.fin-table td.num, .fin-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.fin-table .t-sub { color: #9aa2af; font-size: 12px; margin-top: 2px; }
.fin-table tfoot td { border-bottom: 0; border-top: 2px solid var(--line); font-weight: 700; background: #fafbfc; }
.fin-table .total-row td:first-child { color: var(--ink); }
.red { color: #d9534f; }
.green { color: #1f9d5b; }
.accent { color: var(--accent); }
.kv b.red { color: #d9534f; }
.kv b.green { color: #1f9d5b; }
.kv b.accent { color: var(--accent); }
.panel-note { color: var(--muted); font-size: 12.5px; }

/* 工地资料（预算单 / 720 全景） */
.doc-sec { border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 16px; }
.doc-sec:last-child { margin-bottom: 0; }
.doc-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.doc-head h4 { font-size: 15px; }
.doc-file { display: flex; align-items: center; gap: 12px; background: #fafbfc; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.doc-ico { flex: none; width: 38px; height: 38px; border-radius: 9px; background: #e6f7ee; color: #1f9d5b; font-size: 12px; font-weight: 800; display: grid; place-items: center; letter-spacing: .5px; }
.doc-info { flex: 1; min-width: 0; }
.doc-name { display: block; font-size: 14px; font-weight: 600; color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-name:hover { color: var(--accent); text-decoration: underline; }
.doc-sec .t-sub { color: #9aa2af; font-size: 12px; margin-top: 2px; }
.doc-act { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.doc-sec #panoInput { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; font-family: inherit; }
.doc-sec #panoInput:focus { outline: none; border-color: var(--accent); }

.btn-sm { border: 1px solid var(--line); background: #fff; padding: 6px 12px; border-radius: 7px; cursor: pointer; font-size: 13px; margin-right: 6px; }
.btn-sm:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm.danger:hover { border-color: #d9534f; color: #d9534f; }
.btn-primary { background: var(--accent); color: #fff; border: none; padding: 9px 18px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 14px; }
.btn-primary:hover { background: var(--accent-dark); }

/* modal */
.modal-mask { position: fixed; inset: 0; background: rgba(20,24,33,.5); display: grid; place-items: center; z-index: 60; }
.modal-mask[hidden] { display: none !important; }
.modal { background: #fff; width: 560px; max-width: 94vw; max-height: 90vh; overflow: auto; border-radius: 14px; box-shadow: 0 30px 70px rgba(0,0,0,.3); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 16px; }
.modal-close { border: none; background: none; font-size: 24px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body { padding: 22px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.form-grid input, .form-grid select, .form-grid textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; font-family: inherit; }
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus { outline: none; border-color: var(--accent); }
.modal-foot { margin-top: 20px; display: flex; justify-content: flex-end; gap: 10px; }

/* 工程进度勾选项 */
.form-grid input[type="checkbox"] { width: 15px; height: 15px; padding: 0; accent-color: var(--accent); cursor: pointer; }
.form-grid .stage-wrap { width: 100%; }
.form-grid .stage-count { font-size: 12.5px; color: var(--accent-dark); letter-spacing: .3px; margin-bottom: 9px; }
.stage-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 12px; }
.form-grid .stage-item { display: flex; align-items: center; gap: 9px; margin-bottom: 0; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 13.5px; color: var(--ink); cursor: pointer; transition: .15s; background: #fff; }
.form-grid .stage-item:hover { border-color: var(--accent); }
.form-grid .stage-item:has(input:checked) { background: #fff6f0; border-color: var(--accent); }
.bar-cnt { color: var(--ink); font-weight: 700; }

/* wechat / settings */
.box { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 20px; }
.box h3 { margin-bottom: 16px; font-size: 16px; }
.kv { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 14px; color: var(--muted); }
.kv b { color: var(--ink); }

/* 总览：双栏与列表 */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.kv-bar { display: flex; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.kv-bar:last-child { border-bottom: 0; }
.kv-bar .name { width: 88px; flex: none; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv-bar .bar { flex: 1; width: auto; }
.kv-bar b { color: var(--ink); font-weight: 600; min-width: 24px; text-align: right; }
.kv-bar .sub { flex: 1; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv-bar .sub em { font-style: normal; color: #9aa2af; margin-left: 8px; }
.empty { color: var(--muted); font-size: 13.5px; padding: 16px 0; }
.proj-row { display: flex; align-items: center; gap: 14px; padding: 11px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.proj-row:last-child { border-bottom: 0; }
.proj-row .nm { width: 190px; flex: none; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-row .bar { flex: 1; width: auto; }
.proj-row .pc { width: 42px; text-align: right; color: var(--ink); font-weight: 600; }
.proj-row .st { width: 64px; text-align: right; color: var(--muted); font-size: 13px; }
.log { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; background: #1f2430; color: #cdeac0; padding: 14px; border-radius: 10px; max-height: 220px; overflow: auto; white-space: pre-wrap; }
.switch { display: inline-flex; align-items: center; gap: 10px; }

.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 22px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.3); opacity: 0; transition: .3s; z-index: 100; font-size: 14px; }
.toast.show { opacity: 1; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .side-nav { flex-direction: row; flex-wrap: wrap; }
  .cards { grid-template-columns: 1fr 1fr; }
  .cards.cards-3 { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .proj-row .nm { width: 110px; }
}

/* ---------------- 凭证图片（财务收据） ---------------- */
.thumb-wrap { position: relative; display: inline-flex; align-items: center; cursor: zoom-in; }
.cell-thumb {
  width: 42px; height: 42px; object-fit: cover; display: block;
  border-radius: 6px; border: 1px solid var(--line); background: #f7f7f9;
}
.thumb-more {
  position: absolute; right: -7px; bottom: -7px;
  background: rgba(0, 0, 0, 0.62); color: #fff;
  font-size: 11px; line-height: 1; padding: 3px 5px; border-radius: 8px;
}

.img-field { display: flex; flex-direction: column; gap: 10px; }
.img-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.img-grid:empty { display: none; }
.img-item {
  position: relative; width: 86px; height: 86px; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--line); background: #f7f7f9;
}
.img-item img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.img-del {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px;
  border: none; border-radius: 50%; background: rgba(0, 0, 0, 0.55); color: #fff;
  font-size: 14px; line-height: 1; cursor: pointer; padding: 0;
  display: grid; place-items: center;
}
.img-del:hover { background: #c0392b; }
.img-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.img-actions .t-sub, .img-actions span { color: var(--muted); font-size: 12px; }
.img-actions .btn-sm { margin-right: 0; }

.gallery { display: flex; flex-wrap: wrap; gap: 12px; }
.gallery img {
  max-width: 260px; max-height: 260px; display: block;
  border-radius: 8px; border: 1px solid var(--line);
}

/* ---------------- 附件在线预览 ---------------- */
.modal.modal-wide { width: min(1120px, 96vw); max-height: 92vh; overflow: hidden; display: flex; flex-direction: column; }
.modal-wide .modal-head { flex: none; }
.modal-body.modal-body-file {
  padding: 0; flex: 1; min-height: 0;
  display: flex; flex-direction: column; overflow: hidden;
}
.file-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 20px; border-bottom: 1px solid var(--line); background: #fafbfc; flex: none;
}
.file-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.file-meta strong { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta .t-sub { color: #9aa2af; font-size: 12px; }
.file-ops { display: flex; align-items: center; gap: 8px; flex: none; }
.file-ops .btn-sm { margin-right: 0; display: inline-flex; align-items: center; }

.sheet-tabs { display: flex; gap: 6px; padding: 10px 20px 0; flex-wrap: wrap; flex: none; }
.sheet-tab {
  border: 1px solid var(--line); background: #fff; color: #5b6270;
  padding: 6px 14px; border-radius: 999px; cursor: pointer; font-size: 13px; font-family: inherit;
}
.sheet-tab:hover { border-color: var(--accent); color: var(--accent); }
.sheet-tab.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

.xls-wrap {
  overflow: auto; max-height: 64vh; margin: 12px 20px 20px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
.xls-table { border-collapse: separate; border-spacing: 0; font-size: 12.5px; width: auto; min-width: 100%; }
.xls-table td {
  border-right: 1px solid #f0f1f4; border-bottom: 1px solid #f0f1f4;
  padding: 7px 10px; vertical-align: top; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word; min-width: 64px; max-width: 340px; color: var(--ink);
}
.xls-table tr:first-child td { background: #f7f8fa; }
.xls-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.xls-table td.xls-rowno {
  position: sticky; left: 0; z-index: 2; background: #f7f8fa; color: #aab0ba;
  text-align: right; font-size: 11.5px; min-width: 46px; max-width: 46px; padding: 7px 8px;
  border-right: 1px solid var(--line);
}
.xls-table tr:hover td { background: #fffaf5; }
.xls-table tr:hover td.xls-rowno { background: #f7f8fa; }

.file-frame { display: block; width: 100%; height: 66vh; border: 0; background: #f1f2f4; flex: 1; min-height: 320px; }
.file-img-wrap { display: grid; place-items: center; padding: 16px; background: #f7f8fa; overflow: auto; }
.file-img { max-width: 100%; max-height: 64vh; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.12); background: #fff; }
.file-text {
  margin: 12px 20px 20px; padding: 16px 18px; background: #fafbfc; border: 1px solid var(--line);
  border-radius: 10px; font-size: 13px; line-height: 1.75; white-space: pre-wrap; word-break: break-word;
  max-height: 64vh; overflow: auto; font-family: "PingFang SC", "Microsoft YaHei", Consolas, monospace;
}
.file-loading { padding: 60px 20px; text-align: center; color: var(--muted); font-size: 14px; }
.file-err { padding: 40px 26px; text-align: center; color: #6b7280; font-size: 14px; line-height: 1.8; }

/* 预算单文件行：右侧操作按钮 */
.doc-file .doc-ops { margin-left: auto; display: flex; align-items: center; gap: 6px; flex: none; }
.doc-file .doc-ops .btn-sm { margin-right: 0; }
.doc-name.as-link {
  border: none; background: none; padding: 0; text-align: left; font-family: inherit;
  cursor: pointer; max-width: 100%;
}
.btn-sm.primary-sm { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-sm.primary-sm:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
button.file-open { border: none; cursor: pointer; font-family: inherit; }
button.file-open:hover { filter: brightness(.95); }

@media (max-width: 700px) {
  .modal.modal-wide { width: 96vw; }
  .xls-wrap { margin: 10px 12px 14px; max-height: 58vh; }
  .file-bar { padding: 10px 14px; flex-wrap: wrap; }
  .sheet-tabs { padding: 8px 12px 0; }
  .file-frame { height: 60vh; }
}

/* 单图上传（案例封面） */
.img-field-single .img-grid.single { gap: 0; }
.img-field-single .img-item { width: 200px; height: 126px; border-radius: 10px; }
.img-field-single .img-item img { cursor: zoom-in; }
.img-url-input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 13px; font-family: inherit; color: var(--ink); background: #fff;
}
.img-url-input:focus { outline: none; border-color: var(--accent); }
.cell-thumb.wide { width: 64px; height: 42px; border-radius: 6px; }
