/* 1BENMU project web app. Colours, radii and type follow 1BENMU 工作台设计规范 (light mode only). */
:root {
  --charcoal: #3f3a39; --ink: #3f3a39; --red: #d71618; --red-dark: #b61214; --cream: #eae5df;
  --paper: #f8f5f1; --line: #d3cdc6; --muted: #736d69; --sel-bg: #fbe9e8; --sel-line: #d89d99;
  --note: #eee9e3; --warn: #fff4df; --amber: #f5e7ca; --side-text: #d2cbc5;
  --r: 8px; --r-in: 6px; --side: 236px;
  --font: "Segoe UI Variable", "Segoe UI", "Noto Sans SC", "Microsoft YaHei UI", -apple-system, BlinkMacSystemFont, "PingFang SC", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.5 var(--font); color: var(--ink); background: var(--cream); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
table, time, .badge, .num { font-variant-numeric: tabular-nums; }
h1, h2, h3, .pname { text-wrap: balance; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
img { display: block; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { background: var(--charcoal); color: var(--side-text); position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; z-index: 30; }
.side .brand { padding: 22px 20px 16px; border-bottom: 1px solid #ffffff1a; }
.side .brand img { width: 150px; height: auto; }
.side .brand small { display: block; margin-top: 6px; font-size: 12px; letter-spacing: .08em; color: #bdb5ae; }
.side nav { flex: 1; overflow-y: auto; padding: 12px 12px 16px; }
.side .group { margin-top: 20px; }
.side .group:first-child { margin-top: 4px; }
.side .group-title { font-size: 12px; color: #a39b94; padding: 0 10px 6px; }
.side a.nav { display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin: 2px 0; border-radius: var(--r); text-decoration: none; color: var(--side-text); font-size: 14px; }
.side a.nav svg { width: 18px; height: 18px; flex: none; }
.side a.nav.on { background: var(--paper); color: var(--red); font-weight: 600; }
.side .foot { border-top: 1px solid #ffffff1a; padding: 12px; font-size: 13px; position: relative; }
.side .acct { width: 100%; display: flex; align-items: center; gap: 10px; background: none; border: 0; color: var(--side-text); padding: 8px 10px; border-radius: var(--r); cursor: pointer; text-align: left; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: #5a5352; color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 600; flex: none; text-transform: uppercase; }
.side .ver { font-size: 11px; color: #8d857f; padding: 6px 10px 0; }
.menu { position: absolute; bottom: 64px; left: 12px; right: 12px; background: var(--paper); color: var(--ink); border-radius: var(--r); box-shadow: 0 8px 28px #0003; padding: 4px; z-index: 40; }
.menu button { display: block; width: 100%; text-align: left; padding: 9px 12px; background: none; border: 0; border-radius: var(--r-in); cursor: pointer; }
.menu button:hover { background: var(--note); }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 32px; background: var(--cream); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.top .crumbs { flex: 1; min-width: 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .crumbs a { text-decoration: none; color: var(--muted); }
.top .crumbs b { color: var(--ink); font-weight: 600; }
.menu-btn { display: none; background: none; border: 0; padding: 8px; margin-left: -8px; cursor: pointer; }
.seg { display: inline-flex; border: 1px solid var(--line); background: var(--paper); border-radius: var(--r); padding: 2px; }
.seg button { border: 0; background: none; padding: 4px 10px; font-size: 13px; border-radius: var(--r-in); cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--charcoal); color: #fff; }
.content { padding: 24px 32px 48px; max-width: 1480px; width: 100%; }
.heading { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin: 4px 0 20px; }
.heading h1 { font-size: 32px; font-weight: 700; margin: 0; line-height: 1.2; flex: 1; min-width: 240px; }
.heading .sub { flex-basis: 100%; }
.sub, .muted { font-size: 13px; color: var(--muted); }
.scrim { display: none; }

/* ---------- panels and controls ---------- */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 20px; min-width: 0; }
.panel-head { display: flex; align-items: baseline; gap: 10px; padding: 14px 16px 10px; flex-wrap: wrap; }
.panel-head h2 { font-size: 17px; font-weight: 600; margin: 0; }
.panel-head .sp { flex: 1; }
.pad { padding: 0 16px 16px; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--paper); border-radius: var(--r); padding: 7px 14px; font-size: 13px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #b9b1a9; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.dark { background: var(--red); border-color: var(--red); color: #fff; }
.btn.dark:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }
.linkish { background: none; border: 0; padding: 0; color: var(--red); cursor: pointer; font-size: 13px; text-decoration: none; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.search { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--paper); border-radius: var(--r); padding: 0 10px; width: 100%; max-width: 420px; height: 36px; }
.search:focus-within { border-color: var(--red); }
.search input { border: 0; outline: 0; background: none; flex: 1; min-width: 0; height: 100%; }
.search svg { width: 16px; height: 16px; color: var(--muted); }
select, input[type=text], input[type=email], input[type=password], input[type=date], textarea { border: 1px solid var(--line); background: var(--paper); border-radius: var(--r); padding: 7px 10px; height: 36px; }
textarea { height: auto; min-height: 72px; width: 100%; resize: vertical; }
select:focus, input:focus, textarea:focus { outline: 0; border-color: var(--red); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--red); }
.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); margin: 0 0 18px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 10px 0; text-decoration: none; color: var(--muted); font-size: 14px; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--red); border-bottom-color: var(--red); font-weight: 600; }
.tabs .count { font-size: 12px; margin-left: 4px; }
.badge { display: inline-block; font-size: 12px; line-height: 18px; padding: 0 8px; border-radius: 999px; background: var(--note); color: var(--ink); white-space: nowrap; }
.badge.amber { background: var(--amber); }
.badge.red { background: var(--sel-bg); color: var(--red-dark); }
.note { background: var(--note); border-radius: var(--r); padding: 12px 14px; font-size: 13px; }
.note.warning { background: var(--warn); }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; font-size: 14px; }
.rf-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rf-table th { text-align: left; font-weight: 600; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.rf-table td { padding: 10px; border-bottom: 1px solid #e6e0d9; vertical-align: top; }
.rf-table tr:last-child td { border-bottom: 0; }
.rf-table small { display: block; font-size: 12px; color: var(--muted); }
.table-wrap { overflow-x: auto; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--charcoal); color: #fff; padding: 10px 16px; border-radius: var(--r); font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 100; box-shadow: 0 6px 20px #0003; max-width: calc(100vw - 24px); }
#toast.show { opacity: 1; transform: translateX(-50%); }
.spinner { width: 22px; height: 22px; border: 2px solid var(--line); border-top-color: var(--red); border-radius: 50%; animation: spin .8s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- thumbs ---------- */
.thumb { position: relative; background: #ddd6ce; border-radius: var(--r); overflow: hidden; aspect-ratio: 1; cursor: pointer; border: 0; padding: 0; width: 100%; }
.thumb img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .2s; }
.thumb img.ok { opacity: 1; }
.thumb .ico { position: absolute; inset: 0; display: grid; place-items: center; color: #8f8780; }
.thumb .ico svg { width: 28px; height: 28px; }
.thumb .tag { position: absolute; right: 6px; top: 6px; background: #000a; color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 4px; }
.thumb .flag { position: absolute; left: 6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px #fff; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.grid.small { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.cap { font-size: 12px; color: var(--muted); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day { font-size: 16px; font-weight: 600; margin: 22px 0 10px; display: flex; align-items: baseline; gap: 8px; }
.day:first-child { margin-top: 0; }
.strip { display: grid; grid-auto-flow: column; grid-auto-columns: 132px; gap: 10px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }

/* ---------- home ---------- */
.jump { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.jcard { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; text-decoration: none; display: block; min-width: 0; }
.jcard .thumb { border-radius: 0; aspect-ratio: 16/10; }
.jcard .t { padding: 10px 12px; }
.jcard .t b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }

/* ---------- project list ---------- */
.plist .row { display: grid; grid-template-columns: minmax(220px, 2fr) 140px 150px minmax(200px, 1.6fr); gap: 16px; align-items: center; padding: 12px 16px; border-top: 1px solid #e6e0d9; text-decoration: none; }
.plist .row:first-child { border-top: 0; }
.plist .hdr { font-size: 12px; color: var(--muted); padding-top: 4px; padding-bottom: 4px; }
.pcell { display: flex; gap: 12px; align-items: center; min-width: 0; }
.pcell .thumb { width: 52px; height: 52px; flex: none; aspect-ratio: auto; }
.pcell .pname { font-weight: 600; display: block; }
.pcell .addr { font-size: 12px; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcell .labels { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.stats { font-size: 12px; color: var(--muted); display: grid; gap: 2px; }
.recent4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.recent4 .thumb { aspect-ratio: 1; }
.star { background: none; border: 0; cursor: pointer; color: #b9b1a9; padding: 4px; }
.star.on { color: var(--red); }
.star svg { width: 18px; height: 18px; }

/* ---------- project page ---------- */
.phead { display: flex; gap: 18px; align-items: flex-start; margin: 4px 0 18px; flex-wrap: wrap; }
.phead .cover { width: 112px; height: 112px; flex: none; }
.phead .info { flex: 1; min-width: 240px; }
.phead h1 { font-size: 32px; margin: 0 0 4px; line-height: 1.2; }
.phead .meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: 3px 12px; font-size: 12px; cursor: pointer; }
.chip.on { background: var(--sel-bg); border-color: var(--sel-line); color: var(--red-dark); }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; }
.todo { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid #e6e0d9; }
.todo:first-child { border-top: 0; }
.todo.done .tt { text-decoration: line-through; color: var(--muted); }
.todo .tt { flex: 1; }
.mail { border-top: 1px solid #e6e0d9; padding: 14px 0; }
.mail:first-child { border-top: 0; padding-top: 0; }
.mail h3 { font-size: 15px; margin: 0 0 2px; }
.mail ul { margin: 8px 0 0; padding-left: 18px; font-size: 14px; }

/* ---------- scans ---------- */
.scards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.scard { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; text-decoration: none; display: block; }
.scard .thumb { border-radius: 0; aspect-ratio: 4/3; background: #f1ede8; }
.scard .thumb img { object-fit: contain; padding: 8px; }
.scard .t { padding: 10px 12px; }
.scard .t b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
.stage { background: #f1ede8; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; position: relative; height: min(72vh, 720px); }
.stage model-viewer { width: 100%; height: 100%; --poster-color: transparent; background: #f1ede8; }
.stage .plan { width: 100%; height: 100%; overflow: auto; display: grid; place-items: center; background: #fff; }
.stage .plan img { max-width: 100%; max-height: 100%; }
.stage .modes { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 3; }
.flist { list-style: none; margin: 0; padding: 0; }
.flist li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid #e6e0d9; font-size: 13px; }
.flist li:first-child { border-top: 0; }
.flist .fmt { width: 46px; text-align: center; font-size: 11px; font-weight: 600; background: var(--note); border-radius: 4px; padding: 2px 0; text-transform: uppercase; flex: none; }
.flist .fn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- photo lightbox ---------- */
.lb { position: fixed; inset: 0; background: #1b1918f2; z-index: 60; display: grid; grid-template-columns: 1fr 340px; }
.lb .stagebox { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; padding: 56px 64px; }
.lb .stagebox img, .lb .stagebox video { max-width: 100%; max-height: calc(100vh - 112px); object-fit: contain; }
.lb .tools { position: absolute; top: 12px; left: 12px; display: flex; gap: 6px; }
.lb .tools .btn { background: #ffffff14; border-color: #ffffff26; color: #fff; }
.lb .nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; border: 0; background: #ffffffe6; cursor: pointer; display: grid; place-items: center; }
.lb .nav.prev { left: 12px; } .lb .nav.next { right: 12px; }
.lb .nav svg { width: 20px; height: 20px; }
.lb aside { background: var(--paper); overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 16px; }
.lb aside h3 { margin: 0; font-size: 17px; }
.lb aside .close { position: absolute; top: 12px; right: 12px; }
.lb .section-label { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.comment { font-size: 14px; padding: 8px 0; border-top: 1px solid #e6e0d9; }
.comment:first-child { border-top: 0; }
.comment .who { font-size: 12px; color: var(--muted); }

/* ---------- map ---------- */
#map { height: calc(100vh - 56px - 140px); min-height: 420px; border-radius: var(--r); border: 1px solid var(--line); }
.mapwrap { display: grid; grid-template-columns: 300px 1fr; gap: 16px; }
.maplist { max-height: calc(100vh - 56px - 140px); overflow-y: auto; }
.maplist a { display: block; padding: 10px 14px; border-top: 1px solid #e6e0d9; text-decoration: none; font-size: 14px; }
.maplist a:first-child { border-top: 0; }
.leaflet-container { font: inherit; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login form { width: 100%; max-width: 380px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 28px; }
.login img { width: 170px; margin: 0 auto 6px; }
.login h1 { font-size: 20px; text-align: center; margin: 0 0 20px; font-weight: 600; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 4px; }
.field input { width: 100%; }
.err { color: var(--red-dark); font-size: 13px; min-height: 20px; }
.login .seg { display: flex; width: max-content; margin: 18px auto 0; }

/* ---------- dialogs ---------- */
.dlg-back { position: fixed; inset: 0; background: #0006; z-index: 70; display: grid; place-items: center; padding: 12px; }
.dlg { background: var(--paper); border-radius: var(--r); padding: 22px; width: 100%; max-width: 420px; box-shadow: 0 12px 40px #0004; }
.dlg h2 { font-size: 17px; margin: 0 0 14px; }
.dlg .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .cols, .viewer { grid-template-columns: 1fr; }
  .plist .row { grid-template-columns: minmax(200px, 2fr) 120px minmax(160px, 1.2fr); }
  .plist .row > :nth-child(3) { display: none; }
  .mapwrap { grid-template-columns: 1fr; }
  .maplist { max-height: 240px; }
}
@media (max-width: 850px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .shell.open .side { transform: none; }
  .shell.open .scrim { display: block; position: fixed; inset: 0; background: #0007; z-index: 25; }
  .menu-btn { display: block; }
  .top { padding: 0 24px; }
  .content { padding: 20px 24px 40px; }
  .heading h1, .phead h1 { font-size: 28px; }
  .lb { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .lb aside { max-height: 40vh; }
  .lb .stagebox { padding: 52px 8px 8px; }
  .lb .stagebox img, .lb .stagebox video { max-height: calc(60vh - 60px); }
}
@media (max-width: 700px) {
  .top { padding: 0 16px; }
  .content { padding: 16px 16px 36px; }
  .heading h1, .phead h1 { font-size: 26px; }
  .search { max-width: none; }
  select, input[type=text], input[type=email], input[type=password], input[type=date], .btn { min-height: 44px; font-size: 16px; }
  .btn.small { min-height: 36px; font-size: 13px; }
  .plist .row { grid-template-columns: 1fr; gap: 8px; }
  .plist .row > :nth-child(2), .plist .hdr { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 6px; }
  .phead .cover { width: 72px; height: 72px; }
  .kv { grid-template-columns: 1fr; }
}

/* ---------- fixes after first visual check ---------- */
.search input[type=text] { border: 0; background: none; height: 100%; padding: 0; min-height: 0; }
.jump { grid-auto-columns: 240px; }
.recent4 { max-width: 260px; justify-self: end; width: 100%; }
.plist.compact .row { grid-template-columns: minmax(0, 1fr) auto; }
.plist.compact .row > :nth-child(3), .plist.compact .row > :nth-child(4), .plist.compact .hdr { display: none; }
.phead { position: relative; padding-right: 36px; }
.phead .star { position: absolute; right: 0; top: 0; }
.filters label { display: inline-flex; align-items: center; gap: 6px; }
.viewer .kv { grid-template-columns: 72px 1fr; }
@media (max-width: 700px) {
  .search input[type=text] { min-height: 0; }
  .filters select { flex: 1 1 140px; }
  .filters label { flex: 1 1 100%; }
  .filters label input { flex: 1; }
}
.thumb, .jcard .t, .scard .t { display: block; }
.pcell .thumb { display: block; }
