:root {
  --brand: #a5161d;
  --brand-deep: #650a0f;
  --gold: #d9b53f;
  --ink: #171717;
  --panel: rgba(17, 17, 17, 0.94);
  --line: rgba(217, 181, 63, 0.34);
  --muted: #aaa;
  --blue: #19b8e6;
  --green: #22b573;
  --orange: #f39c12;
  --red: #ff4d4f;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body {
  color: #fff;
  background: #0b0b0b;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
#map-container { position: fixed; inset: 0; }

.top-title {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  height: 84px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, rgba(101,10,15,.94), transparent);
  pointer-events: none;
}
.top-title h1 { margin: 0; font-size: 34px; letter-spacing: 4px; text-shadow: 0 4px 14px #000; }

.search-panel {
  position: fixed; top: 24px; left: 30px; z-index: 80; width: 320px;
  padding: 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); box-shadow: 0 10px 30px rgba(0,0,0,.5); backdrop-filter: blur(12px);
}
.search-panel input, .control-input, .control-select {
  width: 100%; padding: 11px 12px; border: 1px solid rgba(255,255,255,.16);
  border-radius: 8px; color: #fff; background: rgba(255,255,255,.08); outline: none;
}
.search-panel input:focus, .control-input:focus, .control-select:focus { border-color: var(--gold); }
.control-select option { color: #fff; background: #171717; }
.search-results { display: none; max-height: 52vh; margin-top: 9px; overflow-y: auto; }
.search-result { padding: 11px; border-bottom: 1px solid rgba(255,255,255,.08); cursor: pointer; }
.search-result:hover { background: rgba(217,181,63,.12); }
.search-result b { display: block; color: var(--gold); }
.search-result span { display: block; margin-top: 5px; color: #bbb; font-size: 12px; }

.stats {
  position: fixed; top: 24px; right: 30px; z-index: 80;
  display: grid; grid-template-columns: repeat(5, minmax(82px, auto)); gap: 0;
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background: var(--panel); box-shadow: 0 10px 30px rgba(0,0,0,.5); backdrop-filter: blur(12px);
}
.stat { min-height: 78px; padding: 13px 16px; border-right: 1px solid rgba(217,181,63,.18); text-align: center; }
.stat:last-child { border-right: 0; }
.stat b { display: block; color: var(--gold); font-size: 28px; line-height: 1; }
.stat span { display: block; margin-top: 8px; color: #ddd; font-size: 12px; font-weight: 800; }
.stat.construction b { color: var(--blue); }
.stat.invite b { color: #f0c84b; }
.stat.delivered b { color: var(--green); }
.stat.risk b { color: var(--red); }

.floating-actions {
  position: fixed; right: 30px; top: 122px; z-index: 80;
  display: flex; flex-direction: column; gap: 10px;
}
.action-button {
  min-height: 46px; padding: 0 17px; border: 1px solid var(--line); border-radius: 9px;
  color: var(--gold); background: rgba(15,15,15,.9); font-weight: 900;
  box-shadow: 0 8px 22px rgba(0,0,0,.45);
}
.action-button.live { color: #fff; border-color: rgba(255,77,79,.62); }
.action-button .live-dot { display: inline-block; width: 9px; height: 9px; margin-right: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 10px var(--red); animation: pulse 1.4s infinite; }

.community-bubble { position: absolute; z-index: 15; pointer-events: auto; }
.bubble {
  display: flex; align-items: center; gap: 8px; padding: 7px 11px;
  border: 1px solid #fff; border-radius: 999px; cursor: pointer; white-space: nowrap;
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  box-shadow: 0 8px 20px rgba(0,0,0,.48); transition: transform .18s ease;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none;
}
.bubble:hover { transform: scale(1.08); }
.bubble.design { background: linear-gradient(135deg, #71429d, #281736); }
.bubble.invite { background: linear-gradient(135deg, #9a6518, #3d280c); border-color: #f0c84b; }
.bubble.construction { background: linear-gradient(135deg, #087baa, #0a2332); border-color: #48dcff; }
.bubble.delivered { background: linear-gradient(135deg, #16915c, #0c3425); border-color: #75e9b2; }
.bubble.risk { box-shadow: 0 0 24px rgba(255,77,79,.82); border-color: #ff9a9b; }
.bubble.cluster { color: #111; background: linear-gradient(135deg, #fff, #e8e8e8); border-color: var(--brand); }
.bubble-name { font-size: 14px; font-weight: 900; }
.bubble-count { min-width: 23px; height: 23px; display: grid; place-items: center; padding: 0 6px; border-radius: 999px; color: #111; background: var(--gold); font-size: 12px; font-weight: 900; }
.hammer {
  width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%;
  color: #111; background: #fff; transform-origin: 72% 72%; animation: hammer 1.05s ease-in-out infinite;
}
@keyframes hammer { 0%,100%{transform:rotate(-24deg)} 45%{transform:rotate(20deg) translateY(-2px)} 58%{transform:rotate(13deg) translateY(1px)} }
@keyframes pulse { 50% { opacity:.45; transform:scale(1.3); } }

.drawer-mask { position: fixed; inset: 0; z-index: 300; display: none; background: rgba(0,0,0,.34); }
.drawer-mask.active { display: block; }
.control-panel, .list-panel {
  position: fixed; top: 0; right: 0; z-index: 310; width: 510px; max-width: 96vw; height: 100vh;
  display: flex; flex-direction: column; color: #fff; background: rgba(14,14,14,.985);
  border-left: 1px solid var(--line); box-shadow: -20px 0 55px rgba(0,0,0,.68);
  transform: translateX(104%); transition: transform .28s ease;
}
.control-panel.active, .list-panel.active { transform: translateX(0); }
.drawer-head { padding: 22px; border-bottom: 1px solid rgba(217,181,63,.2); background: linear-gradient(135deg, rgba(165,22,29,.75), #161616); }
.drawer-title-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.drawer-title { color: var(--gold); font-size: 24px; font-weight: 900; }
.drawer-close { border: 0; color: #fff; background: transparent; font-size: 28px; }
.drawer-sub { margin-top: 7px; color: #bbb; font-size: 13px; line-height: 1.55; }
.drawer-body { flex: 1; padding: 16px; overflow-y: auto; }
.control-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 13px; }
.metric-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.metric {
  padding: 12px; border: 1px solid rgba(255,255,255,.09); border-radius: 8px;
  background: rgba(255,255,255,.055); cursor: pointer;
}
.metric:hover { border-color: var(--gold); }
.metric b { color: var(--gold); font-size: 23px; }
.metric span { display: block; margin-top: 5px; color: #ccc; font-size: 12px; }
.section-title { margin: 18px 0 9px; font-size: 16px; font-weight: 900; }
.role-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.role-tab { padding: 9px 4px; border: 1px solid rgba(255,255,255,.1); border-radius: 7px; color: #ccc; background: rgba(255,255,255,.05); }
.role-tab.active { color: #fff; border-color: var(--brand); background: rgba(165,22,29,.35); }
.staff-row, .risk-row, .project-card {
  margin-bottom: 8px; padding: 12px; border: 1px solid rgba(255,255,255,.08);
  border-radius: 9px; background: rgba(255,255,255,.055); cursor: pointer;
}
.staff-row:hover, .risk-row:hover, .project-card:hover { border-color: var(--gold); }
.staff-top, .risk-top, .project-top { display: flex; justify-content: space-between; gap: 10px; }
.staff-name, .risk-name, .project-name { font-weight: 900; }
.staff-meta, .risk-meta, .project-meta { margin-top: 6px; color: #aaa; font-size: 12px; line-height: 1.55; }
.staff-count, .risk-badge, .stage-badge { color: var(--gold); font-size: 12px; font-weight: 900; }
.risk-badge { color: #ff898a; }
.next-action { margin-top: 7px; color: #ddd; font-size: 12px; }

.popup {
  position: fixed; left: 50%; top: 50%; z-index: 400; width: 440px; max-width: 92vw; max-height: 76vh;
  display: none; flex-direction: column; overflow: hidden; border: 1px solid var(--line); border-radius: 10px;
  background: rgba(15,15,15,.97); box-shadow: 0 24px 70px rgba(0,0,0,.75); transform: translate(-50%,-50%);
}
.popup.active { display: flex; }
.popup-head { padding: 17px 20px; display: flex; justify-content: space-between; background: linear-gradient(90deg, var(--brand), #171717); }
.popup-head h3 { margin: 0; color: var(--gold); }
.popup-list { padding: 14px; overflow-y: auto; }

.detail {
  position: fixed; inset: 0; z-index: 500; display: flex; color: #fff; background: #0c0c0c;
  transform: translateX(102%); transition: transform .3s ease;
}
.detail.active { transform: translateX(0); }
.detail-media { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(circle,#252525,#050505); }
.preview { position: relative; width: 100%; height: 100%; display: grid; place-items: center; overflow: hidden; border: 1px solid rgba(255,255,255,.12); border-radius: 9px; background: #000; }
.preview img, .preview video {
  display:block; width:auto; height:auto; max-width:92%; max-height:92%;
  object-fit:contain; border:0; border-radius:6px; background:#000;
}
@media (min-width: 901px) {
  body[data-city-key="baoying"] .preview img,
  body[data-city-key="baoying"] .preview video {
    max-width: 80%;
    max-height: 84%;
  }
}
.preview iframe { width:100%; height:100%; border:0; }
.detail-side { width: 470px; max-width: 44vw; display: flex; flex-direction: column; border-left: 1px solid var(--line); background: #151515; }
.detail-head { flex:none; padding: 18px 20px 12px; border-bottom: 1px solid rgba(217,181,63,.18); }
.detail-head h2 { margin: 0; color: #fff; font-size: 22px; }
.detail-core { display:grid; gap:8px; margin-top:12px; }
.core-address, .core-action { padding:9px 11px; border:1px solid rgba(255,255,255,.08); border-radius:7px; color:#d3d3d3; background:rgba(255,255,255,.045); font-size:12px; line-height:1.55; }
.core-address b, .core-action b { display:inline; margin-right:8px; color:var(--gold); }
.core-action { border-color:rgba(217,181,63,.28); background:rgba(217,181,63,.07); }
.detail-more { margin-top:8px; }
.detail-more > summary { display:inline-flex; align-items:center; gap:5px; padding:5px 0; color:#aaa; cursor:pointer; font-size:12px; list-style:none; }
.detail-more > summary::-webkit-details-marker { display:none; }
.detail-more > summary::after { content:"＋"; color:var(--gold); font-size:15px; }
.detail-more[open] > summary::after { content:"－"; }
.detail-more[open] { max-height:46vh; overflow-y:auto; padding-right:4px; }
.detail-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.summary { padding: 9px; border: 1px solid rgba(255,255,255,.08); border-radius: 7px; color: #ccc; background: rgba(255,255,255,.05); font-size: 12px; line-height: 1.5; }
.summary b { display: block; color: var(--gold); margin-bottom: 3px; }
.summary.full { grid-column: 1/-1; }
.detail-close { position: fixed; top: 20px; left: 20px; z-index: 510; display: none; padding: 10px 16px; border: 1px solid var(--line); border-radius: 8px; color: var(--gold); background: rgba(0,0,0,.86); font-weight: 900; }
.detail.active + .detail-close, .detail-close.active { display: block; }
.timeline { flex: 1; min-height:0; padding: 14px 20px 20px; overflow-y: auto; }
.timeline-heading { position:sticky; top:-14px; z-index:2; display:flex; align-items:center; justify-content:space-between; margin:0 -2px 14px; padding:12px 2px 10px; border-bottom:1px solid rgba(217,181,63,.18); background:#151515; }
.timeline-heading b { color:#fff; font-size:16px; }
.timeline-heading span { color:#888; font-size:11px; }
.log { position: relative; margin: 0 0 28px 7px; padding-left: 18px; border-left: 2px solid rgba(217,181,63,.28); }
.log::before { content:""; position:absolute; left:-7px; top:0; width:12px; height:12px; border-radius:50%; background:var(--brand); }
.log-date { color: #aaa; font-size: 12px; }
.log-title { margin-top: 7px; line-height: 1.6; }
.amount { display: inline-block; margin-top: 9px; padding: 6px 11px; border: 1px solid var(--line); border-radius: 6px; color: var(--gold); }
.media-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 8px; margin-top: 10px; }
.media-thumb { position: relative; height: 116px; overflow: hidden; border: 1px solid #333; border-radius: 6px; background: #222; cursor: pointer; }
.media-thumb img, .media-thumb video { width:100%; height:100%; object-fit:cover; }
.file-link, .vr-link { display:block; margin-top:8px; padding:10px; border:1px solid var(--line); border-radius:7px; color:#fff; cursor:pointer; background:rgba(255,255,255,.055); text-decoration:none; }
.file-link:hover, .vr-link:hover { border-color:var(--gold); color:var(--gold); }
.preview-empty { padding:24px; color:#888; text-align:center; line-height:1.7; }
.open-detail-button { width:100%; margin-top:12px; padding:10px; border:1px solid var(--line); border-radius:7px; color:#111; background:var(--gold); font-weight:900; }
.camera-entry { width:100%; border-color:rgba(255,77,79,.45); color:#fff; text-align:left; cursor:pointer; }
.camera-entry:hover { border-color:var(--red); }
.video-thumb span { position:absolute; left:7px; right:7px; bottom:7px; padding:5px; overflow:hidden; border-radius:4px; color:#fff; background:rgba(0,0,0,.72); text-overflow:ellipsis; white-space:nowrap; font-size:11px; }

.live-wall { position: fixed; inset: 0; z-index: 600; display: none; flex-direction: column; background: radial-gradient(circle,#171717,#000); }
.live-wall.active { display: flex; }
.live-head { height: 72px; padding: 0 26px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.live-head h2 { margin:0; color:var(--gold); }
.live-grid { flex:1; display:grid; grid-template-columns:repeat(3,1fr); gap:14px; padding:18px; overflow-y:auto; }
.live-item { position:relative; min-height:240px; border:1px solid var(--line); border-radius:8px; overflow:hidden; background:#050505; }
.live-player { position:absolute; inset:0; }
.live-player video { width:100%; height:100%; object-fit:contain; background:#000; }
.live-label { position:absolute; left:0; right:0; bottom:0; z-index:2; padding:18px 12px 10px; background:linear-gradient(transparent,rgba(0,0,0,.9)); font-size:13px; font-weight:900; }
.live-status { position:absolute; left:50%; top:50%; z-index:1; width:80%; color:#aaa; text-align:center; transform:translate(-50%,-50%); font-size:13px; }
.live-status.ready { top:14px; left:14px; width:auto; padding:5px 8px; border-radius:999px; color:#b9f6d8; background:rgba(0,0,0,.68); transform:none; }
.live-status.failed { color:#ff9a9b; }
.live-empty { grid-column:1/-1; min-height:240px; display:grid; place-items:center; color:#888; }

.login-overlay { position: fixed; inset: 0; z-index: 1000; display: none; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(circle at center, rgba(165,22,29,.35), rgba(5,5,5,.98) 64%); }
.login-overlay.active { display:flex; }
.login-card { width:390px; max-width:100%; padding:28px; border:1px solid var(--line); border-radius:10px; background:rgba(17,17,17,.97); box-shadow:0 24px 70px rgba(0,0,0,.72); }
.login-kicker { color:var(--gold); font-size:12px; font-weight:900; letter-spacing:2px; text-align:center; }
.login-card h2 { margin:8px 0 5px; text-align:center; }
.login-card p { margin:0 0 20px; color:#aaa; text-align:center; font-size:13px; line-height:1.6; }
.login-field { margin-bottom:13px; }
.login-field label { display:block; margin-bottom:6px; color:#ddd; font-size:13px; font-weight:800; }
.login-field input { width:100%; padding:12px; border:1px solid rgba(255,255,255,.16); border-radius:7px; color:#fff; background:rgba(255,255,255,.08); outline:none; }
.login-submit { width:100%; padding:12px; border:0; border-radius:7px; color:#fff; background:var(--brand); font-weight:900; }
.login-message { min-height:20px; margin-top:11px; color:#ff9192; text-align:center; font-size:13px; }

@media (prefers-reduced-motion: reduce) { .hammer, .action-button .live-dot { animation:none; } }
@media (max-width: 850px) {
  .top-title { height:58px; } .top-title h1 { font-size:19px; letter-spacing:1px; }
  .search-panel { top:68px; left:4%; width:92%; }
  .stats { top:auto; bottom:12px; left:3%; right:3%; grid-template-columns:repeat(5,1fr); }
  .stat { min-height:62px; padding:9px 3px; } .stat b{font-size:20px}.stat span{font-size:10px}
  .floating-actions {
    top:140px; left:4%; right:4%; display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:7px;
  }
  .action-button { min-height:38px; padding:0 8px; font-size:12px; }
  .community-bubble { max-width:72vw; }
  .bubble { max-width:100%; padding:6px 9px; }
  .bubble-name { min-width:0; overflow:hidden; text-overflow:ellipsis; }
  .hammer { width:22px; height:22px; flex:none; }
  .popup { top:48%; max-height:68vh; }
  .detail { flex-direction:column; } .detail-media{height:40vh;flex:none;padding:10px}.detail-side{width:100%;max-width:none;height:60vh;border-left:0;border-top:1px solid var(--line)}
  .detail-head { padding:16px; }
  .detail-head h2 { padding-left:88px; font-size:18px; }
  .timeline { padding:14px; }
  .detail-close { top:10px; left:10px; padding:8px 10px; font-size:12px; }
  .live-grid { grid-template-columns:1fr; }
}

@media (max-width: 430px) {
  .top-title h1 { max-width:94%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:17px; }
  .search-panel { padding:10px; }
  .stats { bottom:8px; }
  .stat { min-width:0; }
  .stat span { white-space:nowrap; transform:scale(.92); }
  .detail-media { height:34vh; }
  .detail-side { height:66vh; display:block; overflow-y:auto; }
  .detail-side .timeline { overflow:visible; }
  .detail-summary { grid-template-columns:1fr; }
  .summary.full { grid-column:auto; }
}
