* { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0; 
  user-select: none; 
}

html, body { 
  width: 100%; 
  height: 100%; 
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Microsoft JhengHei", sans-serif; 
  overflow: hidden; 
  background: #1a202c; 
  color: #2d3748; 
}

img { 
  -webkit-user-drag: none; 
  pointer-events: none; 
}

/* 頂部 Header */
.app-header {
  height: 52px;
  background: #1a202c;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid #2d3748;
  z-index: 1001;
  position: relative;
}

.brand-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #63b3ed;
  display: flex;
  align-items: center;
  gap: 8px;
}

.view-switcher {
  display: flex;
  background: #2d3748;
  padding: 3px;
  border-radius: 8px;
  gap: 4px;
}

.switch-btn {
  background: transparent;
  border: none;
  color: #cbd5e0;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: bold;
  transition: all 0.2s;
}

.switch-btn.active { 
  background: #3182ce; 
  color: white; 
}

.presence-bar {
  display: flex;
  align-items: center;
  background: #2d3748;
  padding: 4px 10px;
  border-radius: 20px;
  gap: 8px;
  font-size: 12px;
  color: #cbd5e0;
}

.online-indicator {
  width: 8px;
  height: 8px;
  background: #48bb78;
  border-radius: 50%;
  box-shadow: 0 0 6px #48bb78;
}

.avatar-stack { 
  display: flex; 
  align-items: center; 
  margin-left: 2px; 
}

.user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #2d3748;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: bold;
  color: white;
  margin-left: -6px;
  cursor: pointer;
}

.user-avatar:first-child { 
  margin-left: 0; 
}

.header-actions { 
  display: flex; 
  align-items: center; 
  gap: 8px; 
}

.main-wrapper {
  position: relative;
  width: 100%;
  height: calc(100% - 52px);
  display: flex;
}

/* 抽屜式側邊欄 */
.sidebar-drawer {
  position: absolute;
  top: 0; 
  left: 0;
  width: 380px;
  height: 100%;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(8px);
  box-shadow: 4px 0 16px rgba(0,0,0,0.15);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-drawer.open { 
  transform: translateX(0); 
}

.drawer-header {
  padding: 14px 16px;
  background: #2d3748;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drawer-filters {
  padding: 12px 16px;
  background: #f7fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search-box {
  width: 100%;
  padding: 7px 12px;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  user-select: text;
}

.filter-tags { 
  display: flex; 
  gap: 6px; 
}

.filter-btn {
  padding: 4px 10px;
  font-size: 12px;
  border: 1px solid #cbd5e0;
  border-radius: 20px;
  background: white;
  cursor: pointer;
  font-weight: 500;
}

.filter-btn.active { 
  background: #3182ce; 
  color: white; 
  border-color: #3182ce; 
}

.filter-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #718096;
}

.quick-link { 
  color: #3182ce; 
  cursor: pointer; 
  text-decoration: underline; 
  margin-left: 4px; 
}

.sort-toggle-btn {
  border: 1px solid #cbd5e0;
  background: white;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  color: #4a5568;
}

.drawer-content { 
  flex: 1; 
  overflow-y: auto; 
  padding: 12px 16px; 
}

.drawer-footer {
  padding: 10px 16px;
  background: #edf2f7;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.year-group { 
  margin-bottom: 8px; 
  border-bottom: 1px solid #edf2f7; 
  padding-bottom: 6px; 
}

.year-header, .month-header, .day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
}

.year-label, .month-label, .day-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: bold;
  color: #2d3748;
  cursor: pointer;
}

.month-group { 
  padding-left: 10px; 
  margin-top: 4px; 
}

.month-label { 
  font-size: 12px; 
  color: #4a5568; 
}

.day-group { 
  padding-left: 12px; 
  margin-top: 3px; 
  border-left: 2px solid #e2e8f0; 
}

.day-label { 
  font-size: 12px; 
  color: #718096; 
  font-weight: normal; 
}

.btn {
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  font-size: 12px;
  border: none;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 5px;
}

.btn-primary { 
  background: #3182ce; 
  color: white; 
}

.btn-primary:hover { 
  background: #2b6cb0; 
}

.btn-secondary { 
  background: #4a5568; 
  color: white; 
}

.btn-secondary:hover { 
  background: #2d3748; 
}

#map-view-container { 
  width: 100%; 
  height: 100%; 
  position: relative; 
}

#map { 
  width: 100%; 
  height: 100%; 
}

.leaflet-div-icon {
  background: transparent !important;
  border: none !important;
}

/* 360 環景數量徽章 */
.cluster-badge-360 {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: white;
  font-weight: 800;
  font-size: 12px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.35);
  border: 2px solid white;
  background: #e53e3e;
  transition: transform 0.2s;
  cursor: pointer;
}

.cluster-badge-360:hover { 
  transform: scale(1.15); 
}

/* 相機照射視錐 (FOV) */
.camera-fov-beam {
  position: absolute;
  bottom: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-left: 35px solid transparent;
  border-right: 35px solid transparent;
  border-top: 80px solid rgba(236, 201, 75, 0.55);
  transform-origin: 50% 100%;
  transform: translateX(-50%);
  pointer-events: none;
  filter: drop-shadow(0 0 10px rgba(236, 201, 75, 0.75));
  z-index: 1;
}

#drive-view-container {
  width: 100%;
  height: 100%;
  background: #f7fafc;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.drive-toolbar {
  padding: 8px 16px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.drive-nav-box { 
  display: flex; 
  align-items: center; 
  gap: 8px; 
}

.date-select-dropdown {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid #cbd5e0;
  font-size: 13px;
  font-weight: bold;
  color: #2b6cb0;
  background: #ebf8ff;
  outline: none;
  cursor: pointer;
}

.date-nav-btn {
  background: #edf2f7;
  border: 1px solid #cbd5e0;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: bold;
}

.date-nav-btn:hover { 
  background: #e2e8f0; 
}

.tab-pills { 
  display: flex; 
  background: #edf2f7; 
  padding: 2px; 
  border-radius: 6px; 
}

.tab-pill {
  border: none;
  background: transparent;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  border-radius: 4px;
  font-weight: bold;
  color: #718096;
}

.tab-pill.active { 
  background: white; 
  color: #2b6cb0; 
  box-shadow: 0 1px 3px rgba(0,0,0,0.1); 
}

.drive-grid {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
  align-content: start;
}

.drive-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: all 0.2s;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  position: relative;
}

.drive-card:hover { 
  transform: translateY(-2px); 
  box-shadow: 0 6px 16px rgba(0,0,0,0.1); 
  border-color: #bee3f8; 
}

.drive-card.is-hidden-card { 
  opacity: 0.65; 
  border: 1px dashed #e53e3e; 
}

.card-thumb-wrap {
  width: 100%;
  height: 130px;
  background: #edf2f7;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.25s ease-in;
}

.card-thumb-wrap img.loaded { 
  opacity: 1; 
}

.thumb-spinner { 
  position: absolute; 
  font-size: 11px; 
  color: #a0aec0; 
}

.shield-layer { 
  position: absolute; 
  inset: 0; 
  background: transparent; 
  z-index: 2; 
}

.card-badge {
  position: absolute;
  top: 6px; 
  left: 6px;
  background: rgba(0,0,0,0.7);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  z-index: 3;
}

.hidden-badge {
  position: absolute;
  top: 6px; 
  right: 6px;
  background: #e53e3e;
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  z-index: 3;
}

.card-body { 
  padding: 10px; 
  display: flex; 
  flex-direction: column; 
  gap: 4px; 
}

.file-note-heading {
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: text;
}

.file-key-title { 
  font-size: 11px; 
  color: #718096; 
  user-select: text; 
  word-break: break-all; 
}

.file-time-sub { 
  font-size: 10px; 
  color: #a0aec0; 
}

.card-actions-row {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  border-top: 1px solid #edf2f7;
  padding-top: 8px;
}

.btn-action-col {
  flex: 1;
  background: #edf2f7;
  border: none;
  padding: 5px 0;
  font-size: 11px;
  border-radius: 4px;
  cursor: pointer;
  color: #4a5568;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-weight: 500;
}

.btn-action-col:hover { 
  background: #e2e8f0; 
  color: #2d3748; 
}

/* 懸浮點位卡片 (地圖) */
.floating-side-card {
  position: absolute;
  top: 15px; 
  right: 15px;
  width: 320px;
  max-height: calc(100vh - 100px);
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(8px);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  z-index: 1500;
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #e2e8f0;
}

.floating-card-header {
  padding: 10px 14px;
  background: #f7fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: bold;
}

.floating-card-content { 
  padding: 10px; 
  overflow-y: auto; 
  flex: 1; 
}

/* 大圖檢視燈箱 */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.96);
  z-index: 9999;
}

.modal-content {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.modal-top-right-box {
  position: fixed;
  top: 16px; 
  right: 20px;
  z-index: 10005;
  display: flex;
  align-items: center;
  gap: 12px;
}

.close-btn {
  color: #cbd5e0;
  font-size: 32px;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s;
}

.close-btn:hover { 
  color: #fff; 
}

.btn-top-hide {
  background: rgba(229, 62, 62, 0.25);
  border: 1px solid rgba(229, 62, 62, 0.5);
  color: #feb2b2;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: none;
  align-items: center;
  gap: 4px;
}

.btn-top-hide:hover {
  background: rgba(229, 62, 62, 0.45);
  color: #fff;
}

.btn-top-hide.is-hidden-state {
  background: rgba(72, 187, 120, 0.25);
  border-color: rgba(72, 187, 120, 0.5);
  color: #9ae6b4;
}

.btn-top-hide.is-hidden-state:hover {
  background: rgba(72, 187, 120, 0.45);
  color: #fff;
}

#viewer-container { 
  width: 100%; 
  height: 100%; 
}

#flat-stage {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

#flat-stage:active { 
  cursor: grabbing; 
}

#flat-inner-wrap {
  position: relative;
  transform-origin: center center;
  display: flex;
  justify-content: center;
  align-items: center;
  will-change: transform;
  transition: transform 0.05s ease-out;
  margin: auto;
}

#flat-photo {
  display: block;
  max-width: 90vw;
  max-height: 80vh;
  width: auto;
  height: auto;
  object-fit: contain;
  pointer-events: none;
}

#paint-canvas {
  position: absolute;
  top: 0; 
  left: 0;
  width: 100%; 
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

#paint-canvas.drawing-mode {
  pointer-events: auto;
  cursor: crosshair;
}

.timeline-bar {
  position: fixed;
  top: 16px; 
  left: 50%;
  transform: translateX(-50%);
  z-index: 10002;
  background: rgba(18, 22, 31, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 6px 14px;
  border-radius: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
}

.timeline-nav-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #edf2f7;
  font-size: 12px;
  cursor: pointer;
  width: 28px; 
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.timeline-nav-btn:hover { 
  background: rgba(255, 255, 255, 0.25); 
  color: #fff; 
}

.timeline-title-text {
  font-size: 13px;
  font-weight: 600;
  color: #e2e8f0;
  padding: 0 6px;
  white-space: nowrap;
  user-select: text;
}

.modal-tool-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #f7fafc;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  transition: all 0.2s;
}

.modal-tool-btn:hover { 
  background: rgba(255, 255, 255, 0.24); 
  color: #fff; 
}

.modal-tool-btn.active { 
  background: #e53e3e; 
  border-color: #fc8181; 
}

.note-sub-badge {
  position: fixed;
  top: 66px; 
  left: 50%;
  transform: translateX(-50%);
  z-index: 10002;
  background: rgba(26, 32, 44, 0.85);
  backdrop-filter: blur(8px);
  padding: 5px 16px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
  white-space: nowrap;
}

.note-text-display {
  font-size: 13px;
  font-weight: 700;
  color: #63b3ed;
  user-select: text;
}

.btn-note-edit-pencil {
  background: transparent;
  border: none;
  color: #cbd5e0;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  padding: 2px 4px;
  border-radius: 4px;
  transition: all 0.2s;
}

.btn-note-edit-pencil:hover {
  color: #fff;
  background: rgba(255,255,255,0.2);
}

.paint-toolbar {
  position: fixed;
  top: 104px; 
  left: 50%;
  transform: translateX(-50%);
  z-index: 10002;
  background: rgba(18, 22, 31, 0.9);
  backdrop-filter: blur(8px);
  padding: 5px 12px;
  border-radius: 25px;
  display: none;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(255,255,255,0.2);
}

.color-swatch {
  width: 18px; 
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.2s;
}

.color-swatch.active { 
  transform: scale(1.25); 
  border-color: #fff; 
}

.bottom-timeline-strip {
  position: fixed;
  bottom: 12px; 
  left: 50%;
  transform: translateX(-50%);
  width: 85%;
  max-width: 900px;
  height: 72px;
  background: rgba(18, 22, 31, 0.82);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  z-index: 10002;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  overflow-x: auto;
  scroll-behavior: smooth;
}

.strip-thumb {
  flex: 0 0 68px;
  height: 52px;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
  opacity: 0.65;
  transition: all 0.2s;
}

.strip-thumb:hover { 
  opacity: 1; 
  transform: translateY(-2px); 
}

.strip-thumb.active { 
  border-color: #3182ce; 
  opacity: 1; 
  transform: scale(1.05); 
}

.strip-thumb img { 
  width: 100%; 
  height: 100%; 
  object-fit: cover; 
}

.strip-thumb-time {
  position: absolute;
  bottom: 0; 
  left: 0; 
  right: 0;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 9px;
  text-align: center;
  line-height: 14px;
}

/* 登入視窗 */
#auth-screen {
  position: fixed;
  inset: 0;
  background: #1a202c;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  background: white;
  padding: 28px;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  width: 350px;
  text-align: center;
}

.auth-tabs { 
  display: flex; 
  border-bottom: 2px solid #edf2f7; 
  margin-bottom: 16px; 
}

.auth-tab {
  flex: 1;
  padding: 8px;
  background: none;
  border: none;
  font-weight: bold;
  color: #718096;
  cursor: pointer;
}

.auth-tab.active { 
  color: #3182ce; 
  border-bottom: 2px solid #3182ce; 
}

.auth-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  margin-bottom: 10px;
  font-size: 13px;
  outline: none;
  user-select: text;
}

.auth-btn {
  width: 100%;
  padding: 9px;
  background: #3182ce;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  font-size: 14px;
  transition: background 0.2s;
}

.auth-btn:hover { 
  background: #2b6cb0; 
}

.loading-tip {
  position: absolute;
  top: 65px; 
  left: 15px;
  z-index: 1500;
  background: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: bold;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

#file-input { 
  display: none; 
}

/* 帳號審核與權限管理彈窗 */
.user-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.user-modal-card {
  background: white;
  width: 100%;
  max-width: 820px;
  max-height: 85vh;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-modal-header {
  padding: 14px 20px;
  background: #2d3748;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.user-modal-close {
  background: none;
  border: none;
  color: #cbd5e0;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}

.user-modal-close:hover { 
  color: white; 
}

.user-modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

.user-modal-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.user-table-wrap {
  overflow-x: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.user-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 12px;
}

.user-table th {
  background: #f7fafc;
  padding: 10px 12px;
  font-weight: 700;
  color: #4a5568;
  border-bottom: 1px solid #e2e8f0;
}

.user-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #edf2f7;
  color: #2d3748;
  user-select: text;
}

.user-table tr:hover { 
  background: #f8fafc; 
}

.badge-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
}

.badge-status.approved { 
  background: #c6f6d5; 
  color: #22543d; 
}

.badge-status.pending { 
  background: #feebc8; 
  color: #7b341e; 
}

.badge-status.disabled { 
  background: #fed7d7; 
  color: #742a2a; 
}

.btn-table-action {
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 4px;
  border: 1px solid #cbd5e0;
  background: white;
  cursor: pointer;
  transition: all 0.2s;
  margin-right: 4px;
}

.btn-table-action:hover { 
  background: #edf2f7; 
}

.btn-table-action.danger { 
  color: #e53e3e; 
  border-color: #feb2b2; 
}

.btn-table-action.danger:hover { 
  background: #fff5f5; 
}