/* Rose Project Planner (玫瑰工程排程與S-Curve管制作業系統) */
:root {
  color-scheme: dark;
  --bg-main: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --bg-pane: #111827;
  --bg-grid: #1e293b;
  --border-color: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-blue: #38bdf8;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-purple: #a855f7;
  --accent-indigo: #6366f1;
  --critical-glow: 0 0 14px rgba(244, 63, 94, 0.85);
  --row-height: 38px;
  --header-height: 52px;
  --timeline-header-height: 50px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  background-color: var(--bg-main);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
  user-select: none;
}

/* Top App Header & Toolbar */
.app-header {
  height: var(--header-height);
  background: #090d16;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(2px, 0.4vw, 8px);
  gap: clamp(1px, 0.25vw, 4px);
  z-index: 1000;
  overflow: visible;
  position: relative;
}

.brand {
  display: flex;
  align-items: center;
  gap: clamp(2px, 0.35vw, 6px);
  flex-shrink: 0;
  min-width: 0;
}

.brand-logo-img {
  height: 35px;
  width: auto;
  max-width: 170px;
  object-fit: contain;
  transition: opacity 0.2s ease;
}

.brand-logo-dark {
  display: block;
}

.brand-logo-light {
  display: none;
}

body[data-theme="light"] .brand-logo-dark {
  display: none !important;
}

body[data-theme="light"] .brand-logo-light {
  display: block !important;
}

.brand-icon {
  width: 26px;
  height: 26px;
  background: linear-gradient(135deg, #f43f5e, #ec4899);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(244, 63, 94, 0.4);
  flex-shrink: 0;
}

.brand-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: #fff;
  white-space: nowrap;
}

.brand-subtitle {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 2px;
  background: #1e293b;
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: clamp(70px, 9vw, 180px);
  flex-shrink: 1;
}

/* Top Header Search Input Bar */
.header-search-wrap {
  display: flex;
  align-items: center;
  gap: 3px;
  margin: 0 clamp(2px, 0.35vw, 6px);
  flex-shrink: 1;
}

.header-search-wrap input {
  width: clamp(80px, 7vw, 130px) !important;
  padding: 2px 6px !important;
  font-size: 11px !important;
  height: 26px !important;
}

.header-search-wrap input:focus {
  width: clamp(120px, 11vw, 180px) !important;
  border-color: var(--accent-blue) !important;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}

/* Primary View Switcher Navigation Container */
.view-switcher-wrap {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  white-space: nowrap;
}

.view-switcher {
  display: flex;
  background: #1e293b;
  border-radius: 6px;
  padding: 1px;
  border: 1px solid #334155;
  white-space: nowrap;
  flex-shrink: 0;
  gap: 0 !important;
}

.view-switcher .btn {
  padding: 2px clamp(3px, 0.35vw, 6px) !important;
  font-size: 11px !important;
  height: 26px !important;
}

/* Header Action Utilities & Dropdown Menu */
.header-actions {
  display: flex;
  align-items: center;
  gap: clamp(1px, 0.15vw, 2px);
  flex-shrink: 0;
  white-space: nowrap;
}

.header-actions .btn,
.header-actions .btn-sm {
  padding: 2px clamp(3px, 0.3vw, 5px) !important;
  font-size: 11px !important;
  height: 26px !important;
  gap: 3px !important;
}

/* Responsive compact ribbons for BIM and Header toolbars */
.doc-net-toolbar {
  padding: 2px clamp(2px, 0.4vw, 6px) !important;
  gap: clamp(1px, 0.2vw, 3px) !important;
  min-height: 32px;
}

.doc-net-toolbar .btn,
.doc-net-toolbar .btn-xs {
  padding: 2px clamp(3px, 0.35vw, 5px) !important;
  font-size: 11px !important;
  height: 26px !important;
  gap: 3px !important;
  margin: 0 !important;
}

.doc-net-toolbar .btn-group {
  padding: 1px;
  gap: 0 !important;
  margin: 0 !important;
}

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 220px;
  max-width: 90vw;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.6);
  padding: 6px;
  z-index: 1200;
  display: none;
  flex-direction: column;
  gap: 2px;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 500;
  color: #f8fafc;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background 0.15s ease, color 0.15s ease;
}

.dropdown-item:hover {
  background: #1e293b;
  color: #38bdf8;
}

.dropdown-divider {
  height: 1px;
  background: #334155;
  margin: 4px 0;
}

.btn-group {
  display: flex;
  background: #1e293b;
  border-radius: 6px;
  padding: 2px;
  border: 1px solid #334155;
}

.btn {
  background: #1e293b;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn:hover {
  background: var(--bg-card-hover);
  border-color: #475569;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 12px;
  border: none;
  background: transparent;
}

.btn-sm.active {
  background: var(--accent-blue);
  color: #0f172a;
  font-weight: 700;
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  border-color: #38bdf8;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0369a1, #075985);
}

.btn-success {
  background: linear-gradient(135deg, #059669, #047857);
  border-color: #34d399;
  color: #fff;
  font-weight: 600;
}

.btn-critical.active {
  background: #f43f5e;
  border-color: #fda4af;
  color: #fff;
}

.auto-save-badge {
  font-size: 11px;
  color: var(--accent-emerald);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
}

.auto-save-dot {
  width: 6px;
  height: 6px;
  background-color: var(--accent-emerald);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.7; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.7; }
}

@keyframes saveDotPulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.9);
  }
  50% {
    transform: scale(1.6);
    box-shadow: 0 0 0 7px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

@keyframes syncDotPulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.9);
  }
  50% {
    transform: scale(1.6);
    box-shadow: 0 0 0 7px rgba(56, 189, 248, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(56, 189, 248, 0);
  }
}

.auto-save-dot.save-active, #gdriveSyncDot.save-active {
  animation: saveDotPulse 1.2s ease-out 2 !important;
  background-color: #10b981 !important;
}

.auto-save-dot.sync-active, #gdriveSyncDot.sync-active {
  animation: syncDotPulse 1.2s ease-out 2 !important;
  background-color: #38bdf8 !important;
}

@keyframes saveBtnPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.8);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 10px 3px rgba(16, 185, 129, 0.5);
    transform: scale(1.05);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    transform: scale(1);
  }
}

#btnQuickSave.save-active {
  animation: saveBtnPulse 1.2s ease-out 1 !important;
  border-color: #10b981 !important;
}

#btnQuickSave:hover {
  background: rgba(16, 185, 129, 0.22) !important;
  border-color: rgba(16, 185, 129, 0.7) !important;
}

.collaborator-roster-group {
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
  user-select: none;
}

.collaborator-roster-group:hover {
  background-color: rgba(2, 132, 199, 0.15);
  border-color: rgba(56, 189, 248, 0.5);
  transform: translateY(-1px);
}


/* Stats Bar & Schedule Toolbar (Row 2) */
.stats-bar {
  min-height: 38px;
  height: auto;
  background: #111827;
  border-bottom: 1px solid #1f293d;
  display: flex;
  align-items: center;
  padding: 3px 12px;
  gap: 10px;
  font-size: 12px;
  flex-wrap: wrap;
}

.schedule-toolbar-group {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  background: #334155;
  margin: 0 4px;
  flex-shrink: 0;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-label {
  color: var(--text-muted);
}

.stat-value {
  color: #fff;
  font-weight: 600;
}

.stat-value.highlight {
  color: var(--accent-blue);
}

.stat-value.green {
  color: var(--accent-emerald);
}

/* Main Split View */
.main-container {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Left Pane: Task Tree Grid Table */
.left-pane {
  width: 680px;
  min-width: 440px;
  max-width: 950px;
  background: #0f172a;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.table-header {
  height: var(--timeline-header-height);
  background: #1e293b;
  border-bottom: 2px solid #334155;
  display: flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.th-cell {
  padding: 6px 8px;
  border-right: 1px solid var(--border-color);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-body {
  flex: 1;
  overflow-y: scroll;
  overflow-x: hidden;
}

.task-row {
  height: var(--row-height);
  border-bottom: 1px solid #1e293b;
  display: flex;
  align-items: center;
  font-size: 13px;
  transition: background 0.1s;
}

.task-row:hover {
  background: #1e293b55;
}

.task-row.selected {
  background: #33415566;
}

.task-row.summary {
  font-weight: 700;
  background: #131d2e;
}

.td-cell {
  padding: 4px 8px;
  border-right: 1px solid #1e293b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  height: 100%;
  display: flex;
  align-items: center;
}

.td-name {
  flex: 2;
  min-width: 220px;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}

.tree-toggle {
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
}

.tree-toggle:hover {
  color: #fff;
}

/* Pane Splitter (In-flow Flex Divider with Hard Boundary Guard) */
.pane-splitter {
  width: 6px;
  cursor: col-resize;
  background: #1e293b;
  flex-shrink: 0;
  position: relative;
  z-index: 20;
  transition: background 0.15s;
}

.pane-splitter:hover,
.pane-splitter.dragging {
  background: var(--accent-blue) !important;
}

/* Right Pane: Interactive Gantt Chart */
.right-pane {
  flex: 1;
  background: #0b1120;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.timeline-header-container {
  height: var(--timeline-header-height);
  background: #1e293b;
  border-bottom: 2px solid #334155;
  overflow: hidden;
  position: relative;
}

.timeline-header-months,
.timeline-header-days {
  display: flex;
  height: 25px;
  position: relative;
}

.timeline-header-months {
  border-bottom: 1px solid #334155;
}

.th-time-cell {
  border-right: 1px solid #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 600;
  flex-shrink: 0;
}

.gantt-scroll-container {
  flex: 1;
  overflow: auto;
  position: relative;
}

.gantt-body {
  position: relative;
  min-height: 100%;
}

.gantt-grid-lines {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  pointer-events: none;
}

.grid-column {
  border-right: 1px solid #1e293b88;
  height: 100%;
  flex-shrink: 0;
}

.grid-column.weekend {
  background: rgba(15, 23, 42, 0.4);
}

.gantt-row {
  height: var(--row-height);
  border-bottom: 1px solid #1e293b44;
  position: relative;
  display: flex;
  align-items: center;
}

.gantt-row.summary {
  background: #131d2e33;
}

/* Colorful Blobs (Task Bars) */
.gantt-blob {
  position: absolute;
  height: 26px;
  border-radius: 13px; /* Pill / Blob shape */
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 600;
  color: #ffffff;
  cursor: grab;
  user-select: none;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
  transition: box-shadow 0.15s, transform 0.05s;
  overflow: visible;
  white-space: nowrap;
}

.gantt-blob:hover {
  filter: brightness(1.15);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}

.gantt-blob.dragging {
  cursor: grabbing;
  opacity: 0.9;
  z-index: 1000;
  transform: scaleY(1.06);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.gantt-blob.critical {
  box-shadow: var(--critical-glow);
  border: 1px solid #fda4af;
}

.gantt-blob.summary-blob {
  height: 14px;
  border-radius: 4px;
  background: #475569 !important;
  box-shadow: none;
}

/* Drag Handles on Left and Right Edges */
.blob-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 10px;
  cursor: ew-resize;
  border-radius: 13px;
}

.blob-handle-left {
  left: 0;
}

.blob-handle-right {
  right: 0;
}

.blob-title {
  pointer-events: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Dependency SVG Overlay */
.dependency-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

/* Dragging Tooltip */
.drag-tooltip {
  position: fixed;
  background: #0284c7;
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
  z-index: 2000;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  display: none;
  transform: translate(-50%, -120%);
}

/* Bottom Panel Splitter (Draggable horizontal divider) */
.bottom-panel-splitter {
  height: 6px;
  cursor: row-resize;
  background: #1e293b;
  flex-shrink: 0;
  transition: background 0.15s ease;
  z-index: 90;
  position: relative;
}
.bottom-panel-splitter::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 42px;
  height: 2px;
  border-top: 1px solid rgba(255, 255, 255, 0.35);
  border-bottom: 1px solid rgba(255, 255, 255, 0.35);
}
.bottom-panel-splitter:hover,
.bottom-panel-splitter.dragging {
  background: var(--accent-blue) !important;
}
body[data-theme="light"] .bottom-panel-splitter {
  background: #cbd5e1;
}
body[data-theme="light"] .bottom-panel-splitter::after {
  border-color: rgba(0, 0, 0, 0.35);
}

/* Dynamic Column Hiding Classes for Gantt WBS Table */
.col-hidden-id .th-col-id, .col-hidden-id .td-col-id { display: none !important; }
.col-hidden-dur .th-col-dur, .col-hidden-dur .td-col-dur { display: none !important; }
.col-hidden-start-wd .th-col-start-wd, .col-hidden-start-wd .td-col-start-wd { display: none !important; }
.col-hidden-end-wd .th-col-end-wd, .col-hidden-end-wd .td-col-end-wd { display: none !important; }
.col-hidden-start-date .th-col-start-date, .col-hidden-start-date .td-col-start-date { display: none !important; }
.col-hidden-end-date .th-col-end-date, .col-hidden-end-date .td-col-end-date { display: none !important; }
.col-hidden-pred .th-col-pred, .col-hidden-pred .td-col-pred { display: none !important; }
.col-hidden-tf .th-col-tf, .col-hidden-tf .td-col-tf { display: none !important; }
.col-hidden-ff .th-col-ff, .col-hidden-ff .td-col-ff { display: none !important; }
.col-hidden-proc .th-col-proc, .col-hidden-proc .td-col-proc { display: none !important; }
.col-hidden-weather .th-col-weather, .col-hidden-weather .td-col-weather { display: none !important; }

/* Dynamic Column Hiding Classes for 88 Procurement Table */
.proc-col-hidden-id th[data-col-key="id"], .proc-col-hidden-id td[data-col-key="id"] { display: none !important; }
.proc-col-hidden-category th[data-col-key="category"], .proc-col-hidden-category td[data-col-key="category"] { display: none !important; }
.proc-col-hidden-code th[data-col-key="code"], .proc-col-hidden-code td[data-col-key="code"] { display: none !important; }
.proc-col-hidden-daXiang th[data-col-key="daXiang"], .proc-col-hidden-daXiang td[data-col-key="daXiang"] { display: none !important; }
.proc-col-hidden-zhongXiang th[data-col-key="zhongXiang"], .proc-col-hidden-zhongXiang td[data-col-key="zhongXiang"] { display: none !important; }
.proc-col-hidden-xiaoXiang th[data-col-key="xiaoXiang"], .proc-col-hidden-xiaoXiang td[data-col-key="xiaoXiang"] { display: none !important; }
.proc-col-hidden-quanXiang th[data-col-key="quanXiang"], .proc-col-hidden-quanXiang td[data-col-key="quanXiang"] { display: none !important; }
.proc-col-hidden-itemNo th[data-col-key="itemNo"], .proc-col-hidden-itemNo td[data-col-key="itemNo"] { display: none !important; }
.proc-col-hidden-name th[data-col-key="name"], .proc-col-hidden-name td[data-col-key="name"] { display: none !important; }
.proc-col-hidden-subName th[data-col-key="subName"], .proc-col-hidden-subName td[data-col-key="subName"] { display: none !important; }
.proc-col-hidden-drawings th[data-col-key="drawings"], .proc-col-hidden-drawings td[data-col-key="drawings"] { display: none !important; }
.proc-col-hidden-unit th[data-col-key="unit"], .proc-col-hidden-unit td[data-col-key="unit"] { display: none !important; }
.proc-col-hidden-status th[data-col-key="status"], .proc-col-hidden-status td[data-col-key="status"] { display: none !important; }
.proc-col-hidden-contractor th[data-col-key="contractor"], .proc-col-hidden-contractor td[data-col-key="contractor"] { display: none !important; }
.proc-col-hidden-awardStartDay th[data-col-key="awardStartDay"], .proc-col-hidden-awardStartDay td[data-col-key="awardStartDay"] { display: none !important; }
.proc-col-hidden-awardEndDay th[data-col-key="awardEndDay"], .proc-col-hidden-awardEndDay td[data-col-key="awardEndDay"] { display: none !important; }
.proc-col-hidden-workSpan th[data-col-key="workSpan"], .proc-col-hidden-workSpan td[data-col-key="workSpan"] { display: none !important; }
.proc-col-hidden-contractQty th[data-col-key="contractQty"], .proc-col-hidden-contractQty td[data-col-key="contractQty"] { display: none !important; }
.proc-col-hidden-contractPrice th[data-col-key="contractPrice"], .proc-col-hidden-contractPrice td[data-col-key="contractPrice"] { display: none !important; }
.proc-col-hidden-contractAmount th[data-col-key="contractAmount"], .proc-col-hidden-contractAmount td[data-col-key="contractAmount"] { display: none !important; }
.proc-col-hidden-execBudget th[data-col-key="execBudget"], .proc-col-hidden-execBudget td[data-col-key="execBudget"] { display: none !important; }
.proc-col-hidden-drawnQty th[data-col-key="drawnQty"], .proc-col-hidden-drawnQty td[data-col-key="drawnQty"] { display: none !important; }
.proc-col-hidden-drawnUnit th[data-col-key="drawnUnit"], .proc-col-hidden-drawnUnit td[data-col-key="drawnUnit"] { display: none !important; }
.proc-col-hidden-awardQty th[data-col-key="awardQty"], .proc-col-hidden-awardQty td[data-col-key="awardQty"] { display: none !important; }
.proc-col-hidden-awardPrice th[data-col-key="awardPrice"], .proc-col-hidden-awardPrice td[data-col-key="awardPrice"] { display: none !important; }
.proc-col-hidden-awardAmount th[data-col-key="awardAmount"], .proc-col-hidden-awardAmount td[data-col-key="awardAmount"] { display: none !important; }
.proc-col-hidden-qtyDiff th[data-col-key="qtyDiff"], .proc-col-hidden-qtyDiff td[data-col-key="qtyDiff"] { display: none !important; }
.proc-col-hidden-qtyDiffPct th[data-col-key="qtyDiffPct"], .proc-col-hidden-qtyDiffPct td[data-col-key="qtyDiffPct"] { display: none !important; }
.proc-col-hidden-amtDiff th[data-col-key="amtDiff"], .proc-col-hidden-amtDiff td[data-col-key="amtDiff"] { display: none !important; }
.proc-col-hidden-amtDiffPct th[data-col-key="amtDiffPct"], .proc-col-hidden-amtDiffPct td[data-col-key="amtDiffPct"] { display: none !important; }
.proc-col-hidden-profit th[data-col-key="profit"], .proc-col-hidden-profit td[data-col-key="profit"] { display: none !important; }
.proc-col-hidden-profitPct th[data-col-key="profitPct"], .proc-col-hidden-profitPct td[data-col-key="profitPct"] { display: none !important; }
.proc-col-hidden-schedule th[data-col-key="schedule"], .proc-col-hidden-schedule td[data-col-key="schedule"] { display: none !important; }
.proc-col-hidden-source th[data-col-key="source"], .proc-col-hidden-source td[data-col-key="source"] { display: none !important; }
.proc-col-hidden-notes th[data-col-key="notes"], .proc-col-hidden-notes td[data-col-key="notes"] { display: none !important; }

/* Custom Procurement Item Actions & Inputs */
.custom-item-actions {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 6px;
  opacity: 0.65;
  transition: opacity 0.15s ease;
  vertical-align: middle;
}
.proc-row:hover .custom-item-actions {
  opacity: 1;
}
.btn-custom-proc-rename, .btn-custom-proc-delete {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 3px;
  cursor: pointer;
  padding: 1px 4px;
  font-size: 11px;
  line-height: 1;
  color: var(--text-secondary);
}
.btn-custom-proc-rename:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--accent-cyan);
}
.btn-custom-proc-delete:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
  color: #ef4444;
}
.inp-contractor {
  width: 95px;
  text-align: left;
  font-size: 11px;
}
.td-exec-budget {
  font-weight: 600;
  color: var(--accent-gold, #f59e0b);
}

/* Weather Overlay Styles for Gantt */
.grid-column-rainy {
  background: repeating-linear-gradient(
    -45deg,
    rgba(56, 189, 248, 0.04),
    rgba(56, 189, 248, 0.04) 5px,
    rgba(56, 189, 248, 0.12) 5px,
    rgba(56, 189, 248, 0.12) 10px
  ) !important;
  border-left: 1px dashed rgba(56, 189, 248, 0.25) !important;
}
.th-time-cell.th-day-rainy {
  background: rgba(14, 165, 233, 0.16) !important;
  color: #38bdf8 !important;
}
.th-month-weather-badge {
  font-size: 10px;
  margin-left: 5px;
  color: #38bdf8;
  font-weight: 500;
  opacity: 0.9;
}
.badge-weather-risk {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-weather-high {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}
.badge-weather-med {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}
.badge-weather-low {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.editable-date-cell {
  cursor: pointer;
  border-radius: 3px;
  transition: background 0.15s;
}
.editable-date-cell:hover {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
}

/* Bottom Panel: Interactive S-Curve Chart */
.bottom-panel {
  height: 240px;
  background: #090d16;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: relative;
}

.bottom-panel-header {
  height: 36px;
  background: #111827;
  border-bottom: 1px solid #1f293d;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
}

.bottom-panel-content {
  flex: 1;
  padding: 10px 16px;
  position: relative;
  overflow: hidden;
}

.chart-container {
  width: 100%;
  height: 100%;
  position: relative;
}

/* Modal Dialog */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}

.modal-content,
.modal-card {
  background: #1e293b !important;
  border: 1px solid #475569;
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.75);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--text-primary, #f8fafc);
  opacity: 1 !important;
}

.modal-content {
  width: 580px;
  max-width: 90vw;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid #334155;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 16px;
  font-weight: 700;
  background: #1e293b;
  color: #f8fafc;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  max-height: 70vh;
  background: #1e293b;
  color: #f8fafc;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid #334155;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #0f172a;
}

.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  background: #0f172a;
  border: 1px solid #334155;
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}

.form-input:focus {
  border-color: var(--accent-blue);
}

.form-row {
  display: flex;
  gap: 12px;
}

/* In-place Table Editing */
.td-inline-input {
  width: 100%;
  height: 24px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--accent-blue);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  outline: none;
  transition: all 0.15s ease;
  padding: 0 2px;
}

.td-inline-input:hover {
  background: #1e293b88;
  border-color: #334155;
}

.td-inline-input:focus {
  background: #0f172a;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
  color: #ffffff;
}

/* Canvas Drag-to-Pan Navigation */
.gantt-scroll-container {
  cursor: grab;
}

.gantt-scroll-container.is-panning {
  cursor: grabbing !important;
  user-select: none;
}

.gantt-scroll-container.is-panning * {
  pointer-events: none;
}

/* 8888 Procurement View */
.procurement-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  background: var(--bg-dark);
}

.procurement-kpis {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  background: #0f172a;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.kpi-card {
  flex: 1;
  min-width: 140px;
  background: #1e293b88;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi-title {
  font-size: 11px;
  color: var(--text-muted);
}

.kpi-val {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.kpi-val.highlight {
  color: var(--accent-blue);
}

.kpi-val.green {
  color: var(--accent-green);
}

.procurement-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: #131d2e;
  border-bottom: 1px solid var(--border-color);
  gap: 12px;
  flex-wrap: wrap;
}

.proc-select {
  background: #1e293b;
  border: 1px solid #334155;
  color: #fff;
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 12px;
  outline: none;
}

.proc-input {
  background: #1e293b;
  border: 1px solid #334155;
  color: #fff;
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 12px;
  outline: none;
}

.proc-table-wrapper {
  flex: 1;
  overflow: auto;
  position: relative;
}

.proc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  table-layout: fixed;
}

.proc-table thead th {
  position: sticky;
  top: 0;
  background: #0f172a;
  color: var(--text-secondary);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 2px solid var(--border-color);
  border-right: 1px solid #1e293b;
  white-space: nowrap;
  z-index: 10;
  text-align: right;
}

.proc-table thead th:nth-child(1),
.proc-table thead th:nth-child(2),
.proc-table thead th:nth-child(3),
.proc-table thead th:nth-child(4),
.proc-table thead th:nth-child(5),
.proc-table thead th:nth-child(6) {
  text-align: left;
}

.proc-table thead th.th-editable {
  background: #0369a133;
  color: #38bdf8;
  border-bottom-color: #0284c7;
}

.proc-table thead th.th-locked {
  background: #1e293b55;
  color: #94a3b8;
}

.proc-table tbody tr {
  border-bottom: 1px solid #1e293b66;
  transition: background 0.1s;
}

.proc-table tbody tr:hover {
  background: #1e293b44;
}

.proc-table tbody tr.is-subitem {
  background: #09101c44;
}

.proc-table tbody tr.is-subitem:hover {
  background: #1e293b33;
}

.proc-table td {
  padding: 6px 8px;
  border-right: 1px solid #1e293b44;
  white-space: nowrap;
  color: var(--text-primary);
}

.proc-table td.cell-editable {
  background: rgba(2, 132, 199, 0.08);
  padding: 2px 4px;
}

.proc-table td.cell-editable:focus-within {
  background: rgba(2, 132, 199, 0.22);
}

.proc-table td.cell-locked {
  color: var(--text-muted);
}

.proc-inline-input {
  width: 100%;
  height: 26px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  text-align: right;
  outline: none;
  padding: 0 4px;
}

.proc-inline-input:hover {
  border-color: #38bdf855;
}

.proc-inline-input:focus {
  background: #0f172a;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}

.proc-status-select {
  width: 100%;
  background: #1e293b;
  border: 1px solid #334155;
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  outline: none;
}

.status-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.status-badge.unawarded {
  background: #334155;
  color: #94a3b8;
}

.status-badge.inquiry {
  background: #0284c733;
  color: #38bdf8;
}

.status-badge.awarded {
  background: #10b98133;
  color: #34d399;
}

.status-badge.changed {
  background: #f59e0b33;
  color: #fbbf24;
}

.diff-warning {
  color: #f97316 !important;
  font-weight: 700;
}

.diff-danger {
  color: #ef4444 !important;
  font-weight: 700;
}

.profit-pos {
  color: #22c55e !important;
  font-weight: 600;
}

.profit-neg {
  color: #f43f5e !important;
  font-weight: 600;
}

/* Column Header Resizer */
.proc-table thead th {
  position: sticky;
  top: 0;
  user-select: none;
}

.col-resizer {
  position: absolute;
  right: -5px;
  top: 0;
  bottom: 0;
  width: 10px;
  cursor: col-resize;
  z-index: 25;
  background: transparent;
  transition: background 0.15s;
  touch-action: none;
}

.col-resizer:hover,
.col-resizer.is-resizing {
  background: #38bdf8;
  box-shadow: 0 0 6px rgba(56, 189, 248, 0.8);
}

/* Resource Table Styling & Sticky Always-Visible Edit Button */
.res-resizable-table {
  table-layout: fixed;
}

.res-labor-cell-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  position: relative;
}

.labor-badges-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.btn-edit-res {
  flex-shrink: 0;
  position: sticky;
  right: 0;
  z-index: 2;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
  transition: transform 0.1s, box-shadow 0.1s;
}

.btn-edit-res:hover {
  transform: scale(1.08);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.35);
}

/* Multi-Cell Selection & Clipboard Interaction */
.proc-table td.cell-selected {
  background: rgba(56, 189, 248, 0.22) !important;
  outline: 1px solid var(--accent-blue);
}

/* 88 Table Multi-Row Range Selection (Shift + 2 Clicks) */
.proc-table tr.row-selected > td,
.proc-table tr.proc-row-selected > td {
  background-color: rgba(14, 165, 233, 0.32) !important;
  border-top: 1px solid rgba(56, 189, 248, 0.6) !important;
  border-bottom: 1px solid rgba(56, 189, 248, 0.6) !important;
}

body[data-theme="light"] .proc-table tr.row-selected > td,
body[data-theme="light"] .proc-table tr.proc-row-selected > td {
  background-color: #bae6fd !important;
  border-top: 1px solid #0284c7 !important;
  border-bottom: 1px solid #0284c7 !important;
}

.proc-table tr.row-selected .proc-inline-input,
.proc-table tr.row-selected select {
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.5);
  background-color: rgba(255, 255, 255, 0.08);
}

body[data-theme="light"] .proc-table tr.row-selected .proc-inline-input,
body[data-theme="light"] .proc-table tr.row-selected select {
  background-color: rgba(255, 255, 255, 0.75);
}

.proc-table td.cell-copied {
  animation: pulse-copy 0.4s ease-out;
}

@keyframes pulse-copy {
  0% { background-color: rgba(34, 197, 94, 0.5); }
  100% { background-color: transparent; }
}

@keyframes pulse-row-add {
  0% { background-color: rgba(34, 197, 94, 0.6); }
  100% { background-color: transparent; }
}

.row-newly-added {
  animation: pulse-row-add 2.5s ease-out;
}

/* Day 1 Site Start Milestone Marker */
.milestone-day1 {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #ef4444;
  z-index: 20;
  pointer-events: none;
}

.milestone-day1-label {
  position: absolute;
  top: 2px;
  left: 4px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

/* Search Highlight Marker */
mark.search-highlight {
  background: #fde047;
  color: #0f172a;
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 700;
}

/* Light Theme (白色主題模式) */
body[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --border-color: #cbd5e1;
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --accent-blue: #0284c7;
  --accent-cyan: #0284c7;
  background-color: #f8fafc;
  color: #0f172a;
}

body[data-theme="light"] .app-header {
  background: #ffffff;
  border-bottom: 1px solid #cbd5e1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

body[data-theme="light"] .stats-bar {
  background: #f8fafc;
  border-bottom: 1px solid #cbd5e1;
}

body[data-theme="light"] .procurement-kpis .kpi-card {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

body[data-theme="light"] .kpi-title {
  color: #64748b;
}

body[data-theme="light"] .procurement-toolbar {
  background: #ffffff;
  border-bottom: 1px solid #cbd5e1;
}

body[data-theme="light"] .proc-table thead th {
  background: #f1f5f9;
  color: #0f172a;
  border-bottom: 2px solid #cbd5e1;
  border-right: 1px solid #cbd5e1;
}

body[data-theme="light"] .proc-table tbody tr {
  border-bottom: 1px solid #e2e8f0;
}

body[data-theme="light"] .proc-table tbody tr:hover {
  background: #f8fafc;
}

body[data-theme="light"] .cell-locked {
  background: rgba(241, 245, 249, 0.7);
  color: #334155;
}

body[data-theme="light"] .proc-inline-input {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
}

body[data-theme="light"] .proc-inline-input:focus {
  border-color: #0284c7;
  background: #eff6ff;
}

body[data-theme="light"] .proc-status-select {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
}

body[data-theme="light"] .proc-select {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
}

body[data-theme="light"] .modal-card {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
}

body[data-theme="light"] .modal-header {
  border-bottom: 1px solid #e2e8f0;
}

body[data-theme="light"] .modal-footer {
  border-top: 1px solid #e2e8f0;
}

body[data-theme="light"] .form-input {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
}

body[data-theme="light"] .table-header {
  background: #f1f5f9;
  border-bottom: 1px solid #cbd5e1;
}

body[data-theme="light"] .th-cell {
  color: #334155;
}

body[data-theme="light"] .task-row {
  border-bottom: 1px solid #e2e8f0;
  color: #0f172a;
}

body[data-theme="light"] .task-row:hover {
  background: #f1f5f9;
}

body[data-theme="light"] .task-row.selected {
  background: #e0f2fe !important;
}

body[data-theme="light"] .left-pane {
  background: #ffffff !important;
  border-right: 1px solid #cbd5e1;
}

body[data-theme="light"] .table-body {
  background: #ffffff !important;
  color: #0f172a !important;
}

body[data-theme="light"] .stats-bar {
  background: #ffffff !important;
  border-bottom: 1px solid #cbd5e1;
  color: #0f172a !important;
}

body[data-theme="light"] .stats-bar .stat-label {
  color: #475569 !important;
  font-weight: 600;
}

body[data-theme="light"] .stats-bar .stat-value {
  color: #0f172a !important;
  font-weight: 700;
}

body[data-theme="light"] .stats-bar .stat-value.highlight {
  color: #0284c7 !important;
}

body[data-theme="light"] .stats-bar .stat-value.green {
  color: #16a34a !important;
}

body[data-theme="light"] .td-inline-input {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
}

body[data-theme="light"] .gantt-scroll-container {
  background: #ffffff !important;
}

body[data-theme="light"] .gantt-row {
  border-bottom: 1px solid #f1f5f9;
}

body[data-theme="light"] .grid-column {
  border-right: 1px solid #f1f5f9;
}

body[data-theme="light"] .th-time-cell {
  background: #f8fafc;
  color: #1e293b;
  border-right: 1px solid #cbd5e1;
  border-bottom: 1px solid #cbd5e1;
  font-weight: 600;
}

body[data-theme="light"] .timeline-header-months .th-time-cell {
  background: #f1f5f9;
  color: #0f172a;
  font-weight: 700;
}

body[data-theme="light"] .bottom-panel {
  background: #ffffff;
  border-top: 1px solid #cbd5e1;
}

body[data-theme="light"] .bottom-panel-header {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  color: #0f172a;
}

body[data-theme="light"] .btn {
  background: #ffffff;
  color: #334155;
  border: 1px solid #cbd5e1;
}

body[data-theme="light"] .btn:hover {
  background: #f1f5f9;
}

body[data-theme="light"] .btn-primary {
  background: #0284c7;
  color: #ffffff;
}

body[data-theme="light"] .view-switcher .btn.active {
  background: #0284c7;
  color: #ffffff;
}

/* 88 Table Item Group Styling (Color-coded background by group: main item darker, subitems lighter, distinct hues) */
.proc-table tr.group-p0.is-main { background-color: rgba(56, 189, 248, 0.14) !important; }
.proc-table tr.group-p0.is-subitem { background-color: rgba(56, 189, 248, 0.04) !important; }

.proc-table tr.group-p1.is-main { background-color: rgba(168, 85, 247, 0.14) !important; }
.proc-table tr.group-p1.is-subitem { background-color: rgba(168, 85, 247, 0.04) !important; }

.proc-table tr.group-p2.is-main { background-color: rgba(16, 185, 129, 0.14) !important; }
.proc-table tr.group-p2.is-subitem { background-color: rgba(16, 185, 129, 0.04) !important; }

.proc-table tr.group-p3.is-main { background-color: rgba(245, 158, 11, 0.14) !important; }
.proc-table tr.group-p3.is-subitem { background-color: rgba(245, 158, 11, 0.04) !important; }

.proc-table tr.group-p4.is-main { background-color: rgba(236, 72, 153, 0.14) !important; }
.proc-table tr.group-p4.is-subitem { background-color: rgba(236, 72, 153, 0.04) !important; }

.proc-table tr.group-start {
  border-top: 2px solid rgba(56, 189, 248, 0.45) !important;
}

body[data-theme="light"] .proc-table tr.group-p0.is-main { background-color: #e0f2fe !important; }
body[data-theme="light"] .proc-table tr.group-p0.is-subitem { background-color: #f0f9ff !important; }

body[data-theme="light"] .proc-table tr.group-p1.is-main { background-color: #f3e8ff !important; }
body[data-theme="light"] .proc-table tr.group-p1.is-subitem { background-color: #faf5ff !important; }

body[data-theme="light"] .proc-table tr.group-p2.is-main { background-color: #d1fae5 !important; }
body[data-theme="light"] .proc-table tr.group-p2.is-subitem { background-color: #ecfdf5 !important; }

body[data-theme="light"] .proc-table tr.group-p3.is-main { background-color: #fef3c7 !important; }
body[data-theme="light"] .proc-table tr.group-p3.is-subitem { background-color: #fffbeb !important; }

body[data-theme="light"] .proc-table tr.group-p4.is-main { background-color: #fce7f3 !important; }
body[data-theme="light"] .proc-table tr.group-p4.is-subitem { background-color: #fdf2f8 !important; }

body[data-theme="light"] .proc-table tr.group-start {
  border-top: 2px solid #94a3b8 !important;
}

/* Blackout and locked input cells for 88 Table */
.proc-inline-input.cell-blackout,
input.cell-blackout {
  background-color: #030712 !important;
  color: #475569 !important;
  border-color: #1e293b !important;
  cursor: not-allowed !important;
  opacity: 0.45;
  pointer-events: none;
  font-style: italic;
}

body[data-theme="light"] .proc-inline-input.cell-blackout,
body[data-theme="light"] input.cell-blackout {
  background-color: #e2e8f0 !important;
  color: #94a3b8 !important;
  border-color: #cbd5e1 !important;
  opacity: 0.55;
}

.proc-inline-input.cell-input-locked {
  background-color: rgba(30, 41, 59, 0.5) !important;
  color: #64748b !important;
  cursor: not-allowed !important;
  border: 1px dashed rgba(148, 163, 184, 0.25) !important;
}

body[data-theme="light"] .proc-inline-input.cell-input-locked {
  background-color: #f1f5f9 !important;
  color: #94a3b8 !important;
  border: 1px dashed #cbd5e1 !important;
}

/* Source Document interactive button */
.btn-source-doc-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  max-width: 175px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  transition: all 0.2s ease;
}

.btn-source-doc-link:hover {
  background: rgba(56, 189, 248, 0.25);
  border-color: #38bdf8;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(56, 189, 248, 0.25);
  transform: translateY(-1px);
}

body[data-theme="light"] .btn-source-doc-link {
  background: #f0f9ff;
  color: #0284c7;
  border: 1px solid #bae6fd;
}

body[data-theme="light"] .btn-source-doc-link:hover {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
}

/* Unified Floating Multi-Cell / Multi-Row Action Bar & Stats Panel (Hovering bottom-left, zero layout shift) */
.selection-action-bar {
  position: fixed;
  bottom: 20px;
  left: 24px;
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 8px;
  padding: 6px 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 16px rgba(56, 189, 248, 0.2);
  color: #f8fafc;
  font-size: 12px;
  user-select: none;
  pointer-events: auto;
  animation: slideUpFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  margin: 0;
}

body[data-theme="light"] .selection-action-bar {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #cbd5e1;
  color: #0f172a;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.selection-action-bar .proc-cell-stats-bar {
  position: static;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  margin: 0;
  animation: none;
  gap: 12px;
}

.proc-stat-divider {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.2);
}

body[data-theme="light"] .proc-stat-divider {
  background: rgba(0, 0, 0, 0.15);
}

.selection-action-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.selection-badge {
  font-weight: 600;
  color: #38bdf8;
  font-size: 12px;
  white-space: nowrap;
}

body[data-theme="light"] .selection-badge {
  color: #0284c7;
}

.selection-action-bar .btn {
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
  line-height: 1.4;
  white-space: nowrap;
}

.selection-action-bar #btnSelectionCopy {
  background: rgba(14, 165, 233, 0.2);
  border: 1px solid rgba(56, 189, 248, 0.5);
  color: #38bdf8;
}

.selection-action-bar #btnSelectionCopy:hover {
  background: rgba(14, 165, 233, 0.35);
  border-color: #38bdf8;
  color: #fff;
}

body[data-theme="light"] .selection-action-bar #btnSelectionCopy {
  background: #f0f9ff;
  border: 1px solid #0284c7;
  color: #0284c7;
}

body[data-theme="light"] .selection-action-bar #btnSelectionCopy:hover {
  background: #0284c7;
  color: #fff;
}

.selection-action-bar .btn-critical {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #fca5a5;
}

.selection-action-bar .btn-critical:hover {
  background: rgba(239, 68, 68, 0.4);
  color: #fff;
  border-color: #ef4444;
}

body[data-theme="light"] .selection-action-bar .btn-critical {
  background: #fef2f2;
  border: 1px solid #ef4444;
  color: #dc2626;
}

body[data-theme="light"] .selection-action-bar .btn-critical:hover {
  background: #ef4444;
  color: #fff;
}

.selection-action-bar .btn-deselect {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #94a3b8;
}

.selection-action-bar .btn-deselect:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

body[data-theme="light"] .selection-action-bar .btn-deselect {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #475569;
}

body[data-theme="light"] .selection-action-bar .btn-deselect:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* Table Header Sorting Icons */
th[data-sort-col] {
  cursor: pointer;
  user-select: none;
}

th[data-sort-col]:hover {
  background-color: rgba(56, 189, 248, 0.15) !important;
}

.sort-icon {
  display: inline-block;
  font-size: 11px;
  margin-left: 4px;
  opacity: 0.6;
  vertical-align: middle;
}

th.sort-active .sort-icon {
  opacity: 1;
  color: var(--accent-cyan);
  font-weight: 900;
}

/* Enhanced Gantt Tooltip */
#dragTooltip {
  position: fixed;
  z-index: 99999;
  pointer-events: none;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  color: #f8fafc;
  border: 1px solid #38bdf8;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.5;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  max-width: 380px;
}

body[data-theme="light"] #dragTooltip {
  background: rgba(255, 255, 255, 0.97);
  color: #0f172a;
  border: 1px solid #0284c7;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

/* ==========================================
   Excel-Style PivotTable Styles
   ========================================== */
.excel-pivot-container {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
  background: var(--bg-primary);
}

.pivot-grid-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border-color);
}

.pivot-filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

/* Quick Access Pivot Presets & Chips */
.pivot-presets-container {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pivot-preset-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.pivot-preset-chip .btn-pivot-preset {
  padding: 3px 22px 3px 10px;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.4;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  user-select: none;
}

.pivot-preset-chip .btn-pivot-preset:hover {
  background: var(--bg-primary);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

.pivot-preset-chip .btn-pivot-preset.active {
  background: rgba(56, 189, 248, 0.16);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
  font-weight: 700;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.3);
}

/* Gear button at top-right corner of each quick access pivot */
.pivot-preset-gear {
  position: absolute;
  top: 1px;
  right: 2px;
  width: 17px;
  height: 17px;
  padding: 0;
  margin: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  opacity: 0.65;
  transition: color 0.15s ease, opacity 0.15s ease, transform 0.2s ease, background 0.15s ease;
  z-index: 5;
}

.pivot-preset-chip:hover .pivot-preset-gear {
  opacity: 1;
  color: var(--text-secondary);
}

.pivot-preset-gear:hover {
  background: rgba(56, 189, 248, 0.22);
  color: #38bdf8 !important;
  opacity: 1;
  transform: rotate(30deg);
}

.pivot-preset-gear.menu-open {
  background: rgba(56, 189, 248, 0.28);
  color: #38bdf8 !important;
  opacity: 1;
}

/* Gear Context Dropdown Menu */
.pivot-preset-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 2500;
  background: #1a2234;
  border: 1px solid #384b66;
  border-radius: 6px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.08);
  padding: 4px;
  min-width: 130px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: pivotMenuFadeIn 0.12s ease-out;
}

@keyframes pivotMenuFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.pivot-preset-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: none;
  background: transparent;
  color: #f1f5f9;
  font-size: 12px;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background 0.12s ease, color 0.12s ease;
}

.pivot-preset-menu-item:hover {
  background: rgba(56, 189, 248, 0.16);
  color: #38bdf8;
}

.pivot-preset-menu-item.item-delete:hover {
  background: rgba(239, 68, 68, 0.16);
  color: #f87171;
}

/* Light Theme overrides */
body[data-theme="light"] .pivot-preset-chip .btn-pivot-preset {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #334155;
}
body[data-theme="light"] .pivot-preset-chip .btn-pivot-preset:hover {
  background: #f1f5f9;
  border-color: #0284c7;
  color: #0284c7;
}
body[data-theme="light"] .pivot-preset-chip .btn-pivot-preset.active {
  background: #e0f2fe;
  border-color: #0284c7;
  color: #0369a1;
  box-shadow: 0 0 0 1px rgba(2, 132, 199, 0.3);
}
body[data-theme="light"] .pivot-preset-gear {
  color: #64748b;
}
body[data-theme="light"] .pivot-preset-gear:hover {
  background: rgba(2, 132, 199, 0.15);
  color: #0284c7 !important;
}
body[data-theme="light"] .pivot-preset-menu {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
}
body[data-theme="light"] .pivot-preset-menu-item {
  color: #1e293b;
}
body[data-theme="light"] .pivot-preset-menu-item:hover {
  background: #f0f9ff;
  color: #0284c7;
}
body[data-theme="light"] .pivot-preset-menu-item.item-delete:hover {
  background: #fef2f2;
  color: #dc2626;
}

.pivot-active-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  min-height: 40px;
}

.pivot-filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 12px;
}

.pivot-filter-tag select {
  background: var(--bg-main, #0f172a);
  border: 1px solid var(--border-color, #334155);
  color: var(--accent-blue, #38bdf8);
  font-weight: 600;
  cursor: pointer;
  outline: none;
  font-size: 12px;
  border-radius: 4px;
  padding: 2px 6px;
  color-scheme: dark;
}

.pivot-filter-tag select:hover,
.pivot-filter-tag select:focus {
  border-color: var(--accent-blue, #38bdf8);
}

.pivot-filter-tag select option {
  background-color: #0f172a !important;
  color: #f8fafc !important;
  padding: 6px 10px;
}

.pivot-multiselect-container {
  position: relative;
  display: inline-block;
}

.pivot-multiselect-btn {
  background: var(--bg-main, #0f172a);
  border: 1px solid var(--border-color, #334155);
  color: var(--accent-blue, #38bdf8);
  font-weight: 600;
  cursor: pointer;
  outline: none;
  font-size: 12px;
  border-radius: 4px;
  padding: 3px 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  user-select: none;
  transition: all 0.15s ease;
}

.pivot-multiselect-btn:hover {
  border-color: var(--accent-blue, #38bdf8);
  background: rgba(56, 189, 248, 0.08);
}

.pivot-multiselect-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: var(--bg-card, #1e293b);
  border: 1px solid var(--border-color, #334155);
  border-radius: 6px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  padding: 6px;
  z-index: 100;
  min-width: 240px;
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pivot-multiselect-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 6px 6px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 4px;
  font-size: 11px;
}

.pivot-multiselect-action-btn {
  background: none;
  border: none;
  color: var(--accent-blue, #38bdf8);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 4px;
  border-radius: 3px;
}

.pivot-multiselect-action-btn:hover {
  text-decoration: underline;
  background: rgba(56, 189, 248, 0.1);
}

.pivot-multiselect-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-primary);
  user-select: none;
  transition: background 0.1s ease;
}

.pivot-multiselect-item:hover {
  background: var(--bg-pane, #334155);
}

.pivot-multiselect-item input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--accent-blue);
  width: 14px;
  height: 14px;
  margin: 0;
}

.pill-agg-select {
  background: var(--bg-card, #1e293b);
  border: 1px solid var(--border-color, #334155);
  color: var(--text-primary, #f8fafc);
  color-scheme: dark;
  font-size: 10px;
  border-radius: 3px;
  padding: 1px 4px;
}

.pill-agg-select option {
  background-color: #1e293b !important;
  color: #f8fafc !important;
}

.pivot-table-scroll {
  flex: 1;
  overflow: auto;
  padding: 12px;
  background: var(--bg-primary);
}

.pivot-excel-table {
  table-layout: fixed !important;
  border-collapse: collapse;
  font-size: 12px;
  border: 2px solid var(--border-color);
  background: var(--bg-secondary);
}

.pivot-excel-table th {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-weight: 700;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  text-align: left;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
}

.pivot-excel-table td {
  padding: 6px 12px;
  border: 1px solid var(--border-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pivot-excel-table .num-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.pivot-excel-table .row-label-cell {
  font-weight: 600;
  color: var(--text-primary);
  width: 220px;
  min-width: 170px;
}

.pivot-excel-table .grand-total-row {
  background: var(--bg-tertiary);
  font-weight: 700;
  border-top: 2px solid var(--border-color);
  border-bottom: 2px solid var(--border-color);
}

.pivot-excel-table .grand-total-col {
  background: rgba(56, 189, 248, 0.06);
  font-weight: 700;
  width: 150px;
  min-width: 115px;
}

/* Draggable Splitter between Pivot Grid & Sidebar */
#pivotPaneSplitter {
  width: 5px;
  background: var(--border-color);
  cursor: col-resize;
  transition: background 0.15s;
  z-index: 20;
}

#pivotPaneSplitter:hover,
#pivotPaneSplitter.dragging {
  background: var(--accent-cyan) !important;
}

/* Sidebar: PivotTable Fields */
.pivot-fields-sidebar {
  width: 320px;
  min-width: 240px;
  max-width: 650px;
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border-color);
  overflow: hidden;
  transition: width 0.1s ease;
}

.pivot-fields-sidebar.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  max-width: 0 !important;
  border: none !important;
  padding: 0 !important;
}

.fields-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
}

.fields-search-box {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
}

.fields-search-box input {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 5px 8px;
  border-radius: 4px;
  font-size: 12px;
  outline: none;
}

.pivot-field-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 12px;
  max-height: 200px;
  min-height: 140px;
  border-bottom: 1px solid var(--border-color);
}

.pivot-field-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
}

.pivot-field-item:hover {
  background: rgba(56, 189, 248, 0.1);
}

.pivot-field-item input[type="checkbox"] {
  cursor: pointer;
}

.drag-hint-label {
  padding: 6px 12px 2px;
  font-size: 11px;
  color: var(--text-muted);
}

/* 4 Quadrants Grid */
.pivot-quadrants-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
  padding: 8px 12px 12px;
  height: 280px;
}

.quadrant-box {
  border: 1px dashed var(--border-color);
  border-radius: 6px;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.quadrant-box.drag-over {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.08);
}

.quadrant-header {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.quadrant-items {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.quadrant-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 11px;
  cursor: grab;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.quadrant-pill:active {
  cursor: grabbing;
}

.quadrant-pill .pill-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 95px;
}

.quadrant-pill .pill-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.quadrant-pill .btn-pill-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  padding: 0 2px;
}

.quadrant-pill .btn-pill-remove:hover {
  color: #ef4444;
}

.quadrant-pill .pill-agg-select {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 10px;
  padding: 1px 2px;
  border-radius: 3px;
  cursor: pointer;
}

.quadrant-pill.pill-dragging {
  opacity: 0.4;
}

.quadrant-pill.pill-drag-over-top {
  border-top: 2px solid var(--accent-cyan, #0ea5e9) !important;
}

.quadrant-pill.pill-drag-over-bottom {
  border-bottom: 2px solid var(--accent-cyan, #0ea5e9) !important;
}

.pill-reorder-btns {
  display: inline-flex;
  align-items: center;
  gap: 1px;
}

.btn-pill-reorder {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 8px;
  line-height: 1;
  padding: 1px 2px;
  border-radius: 2px;
  opacity: 0.7;
  transition: opacity 0.15s, color 0.15s;
}

.btn-pill-reorder:hover {
  opacity: 1;
  color: var(--accent-cyan, #0ea5e9);
  background: rgba(14, 165, 233, 0.15);
}

/* Floating Multi-Cell Selection Stats Bar (Excel status bar at bottom left) */
.proc-cell-stats-bar {
  position: fixed;
  bottom: 20px;
  left: 24px;
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 8px;
  padding: 6px 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 16px rgba(56, 189, 248, 0.2);
  color: #f8fafc;
  font-size: 12px;
  user-select: none;
  pointer-events: auto;
  animation: slideUpFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

body[data-theme="light"] .proc-cell-stats-bar {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #cbd5e1;
  color: #0f172a;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.proc-cell-stats-bar .proc-stat-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.proc-cell-stats-bar .proc-stat-label {
  color: var(--text-muted, #94a3b8);
  font-size: 11px;
  font-weight: 500;
}

body[data-theme="light"] .proc-cell-stats-bar .proc-stat-label {
  color: #64748b;
}

.proc-cell-stats-bar .proc-stat-val {
  color: #f1f5f9;
  font-weight: 700;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}

body[data-theme="light"] .proc-cell-stats-bar .proc-stat-val {
  color: #0f172a;
}

.proc-cell-stats-bar .proc-stat-val.highlight {
  color: #38bdf8;
}

body[data-theme="light"] .proc-cell-stats-bar .proc-stat-val.highlight {
  color: #0284c7;
}

@keyframes slideUpFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Light Theme Adjustments for Pivot */
body[data-theme="light"] .excel-pivot-container {
  background: #f8fafc;
}

body[data-theme="light"] .pivot-grid-area {
  background: #ffffff;
}

body[data-theme="light"] .pivot-excel-table {
  background: #ffffff;
  border-color: #cbd5e1;
}

body[data-theme="light"] .pivot-excel-table th {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #cbd5e1;
}

body[data-theme="light"] .pivot-excel-table td {
  border-color: #e2e8f0;
  color: #0f172a;
}

body[data-theme="light"] .pivot-excel-table .grand-total-row {
  background: #f1f5f9;
  border-color: #94a3b8;
}

body[data-theme="light"] .pivot-fields-sidebar {
  background: #ffffff;
  border-color: #cbd5e1;
}

body[data-theme="light"] .quadrant-box {
  background: #f8fafc;
  border-color: #cbd5e1;
}

body[data-theme="light"] .quadrant-header {
  background: #f1f5f9;
  color: #334155;
}

body[data-theme="light"] .quadrant-pill {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
}

body[data-theme="light"] .pivot-filter-tag {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

body[data-theme="light"] .pivot-filter-tag select {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0284c7;
  color-scheme: light;
}

body[data-theme="light"] .pivot-filter-tag select option {
  background-color: #ffffff !important;
  color: #0f172a !important;
}

body[data-theme="light"] .pivot-multiselect-btn {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0284c7;
}

body[data-theme="light"] .pivot-multiselect-menu {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15);
}

body[data-theme="light"] .pivot-multiselect-item {
  color: #0f172a;
}

body[data-theme="light"] .pivot-multiselect-item:hover {
  background: #f1f5f9;
}

body[data-theme="light"] .pill-agg-select {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
  color-scheme: light;
}

body[data-theme="light"] .pill-agg-select option {
  background-color: #ffffff !important;
  color: #0f172a !important;
}

/* ==========================================
   Clickable Counterpart Links & Glow Animation
   ========================================== */
.badge-link-to-sched {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(56, 189, 248, 0.15);
  color: #0284c7;
  border: 1px solid rgba(56, 189, 248, 0.4);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
  margin: 1px 2px;
  white-space: nowrap;
}

body[data-theme="dark"] .badge-link-to-sched {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.5);
}

.badge-link-to-sched:hover {
  background: #0284c7;
  color: #ffffff !important;
  box-shadow: 0 0 8px rgba(2, 132, 199, 0.5);
  transform: translateY(-1px);
}

.btn-link-to-proc {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.35);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-link-to-proc:hover {
  background: #10b981;
  color: #ffffff !important;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
  transform: translateY(-1px);
}

.btn-link-to-proc.btn-link-empty {
  background: rgba(148, 163, 184, 0.08);
  color: var(--text-muted);
  border: 1px dashed rgba(148, 163, 184, 0.4);
  font-weight: 500;
}

.btn-link-to-proc.btn-link-empty:hover {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8 !important;
  border-color: #38bdf8;
  border-style: solid;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.35);
}

.lp-edit-row {
  cursor: pointer;
  transition: background 0.15s;
}

.lp-edit-row:hover {
  background: rgba(56, 189, 248, 0.08);
}

.lp-edit-row.selected-row {
  background: rgba(16, 185, 129, 0.12);
}

.flash-highlight {
  animation: flashCyan 2.2s cubic-bezier(0.25, 1, 0.5, 1) forwards !important;
}

@keyframes flashCyan {
  0% {
    background-color: #38bdf8 !important;
    box-shadow: 0 0 20px #38bdf8;
    color: #ffffff !important;
  }
  70% {
    background-color: rgba(56, 189, 248, 0.35) !important;
  }
  100% {
    background-color: inherit;
    box-shadow: none;
  }
}

/* =========================================================================
   Flawless High-Contrast Light Theme (Professional & Streamlined)
   ========================================================================= */
body[data-theme="light"] {
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-pane: #ffffff;
  --bg-grid: #ffffff;
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --border-color: #cbd5e1;
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --accent-blue: #0284c7;
  --accent-cyan: #0284c7;
  background-color: #f8fafc !important;
  color: #0f172a !important;
}

body[data-theme="light"] .brand-title {
  color: #0f172a !important;
}

body[data-theme="light"] .brand-subtitle {
  background: #e2e8f0 !important;
  color: #334155 !important;
  border: 1px solid #cbd5e1 !important;
}

body[data-theme="light"] .app-header {
  background: #ffffff !important;
  border-bottom: 1px solid #cbd5e1 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
}

body[data-theme="light"] .btn {
  background: #ffffff !important;
  color: #1e293b !important;
  border: 1px solid #cbd5e1 !important;
}

body[data-theme="light"] .btn:hover {
  background: #f1f5f9 !important;
  color: #0f172a !important;
}

body[data-theme="light"] .btn-primary {
  background: #0284c7 !important;
  color: #ffffff !important;
  border-color: #0284c7 !important;
}

body[data-theme="light"] .btn-group {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
}

body[data-theme="light"] .btn-group .btn {
  background: transparent !important;
  color: #475569 !important;
  border: none !important;
}

body[data-theme="light"] .btn-group .btn:hover {
  background: #e2e8f0 !important;
  color: #0f172a !important;
}

body[data-theme="light"] .btn-group .btn.active {
  background: #ffffff !important;
  color: #0284c7 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
  font-weight: 600 !important;
}

body[data-theme="light"] .stats-bar {
  background: #f8fafc !important;
  border-bottom: 1px solid #cbd5e1 !important;
}

body[data-theme="light"] .stat-label {
  color: #64748b !important;
}

body[data-theme="light"] .stat-value {
  color: #0f172a !important;
}

body[data-theme="light"] .main-container,
body[data-theme="light"] .table-pane,
body[data-theme="light"] .gantt-pane {
  background: #ffffff !important;
}

body[data-theme="light"] .task-table thead th {
  background: #f1f5f9 !important;
  color: #0f172a !important;
  border-color: #cbd5e1 !important;
}

body[data-theme="light"] .task-row {
  border-bottom: 1px solid #e2e8f0 !important;
  color: #0f172a !important;
}

body[data-theme="light"] .task-row:hover {
  background: #f8fafc !important;
}

body[data-theme="light"] .task-row.selected {
  background: #e0f2fe !important;
}

body[data-theme="light"] .timeline-header-month {
  background: #f1f5f9 !important;
  color: #0f172a !important;
  border-color: #cbd5e1 !important;
}

body[data-theme="light"] .timeline-header-day {
  background: #f8fafc !important;
  color: #475569 !important;
  border-color: #cbd5e1 !important;
}

body[data-theme="light"] .modal-content,
body[data-theme="light"] .modal-card {
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04) !important;
}

body[data-theme="light"] .modal-header {
  border-bottom: 1px solid #e2e8f0 !important;
  color: #0f172a !important;
  background: #ffffff !important;
}

body[data-theme="light"] .modal-body {
  background: #ffffff !important;
  color: #0f172a !important;
}

body[data-theme="light"] .modal-footer {
  border-top: 1px solid #e2e8f0 !important;
  background: #f8fafc !important;
}

body[data-theme="light"] .form-input,
body[data-theme="light"] .form-group input,
body[data-theme="light"] .form-group select {
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid #cbd5e1 !important;
}

body[data-theme="light"] .form-label {
  color: #334155 !important;
}


/* =========================================================================
   Gantt Outside Blob Labels & Light Theme Black Bar Fixes
   ========================================================================= */

/* Fixed layout for 88 Table so name column is compact and fits screen */
.proc-table {
  table-layout: fixed !important;
  border-collapse: collapse !important;
  font-size: 11px !important;
}

.proc-table th {
  padding: 6px 4px !important;
  overflow: visible !important;
  text-overflow: clip !important;
  white-space: normal !important;
  word-break: keep-all !important;
  line-height: 1.2 !important;
  vertical-align: middle !important;
  text-align: center !important;
}

.proc-table td {
  padding: 4px 6px !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

/* Percentage numbers must always be shown in full */
.proc-table td.td-qty-diff-pct,
.proc-table td.td-amt-diff-pct,
.proc-table td.td-profit-pct {
  white-space: nowrap !important;
  overflow: visible !important;
  text-overflow: clip !important;
  font-variant-numeric: tabular-nums;
}

/* Gantt Blob Outside Label */
.blob-label-outside {
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  font-size: 11px;
  font-weight: 600;
  color: #f8fafc;
  pointer-events: none;
  z-index: 5;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
}

body[data-theme="light"] .blob-label-outside {
  color: #0f172a !important;
  text-shadow: 0 0 3px #ffffff, 0 0 5px #ffffff !important;
}

.blob-label-dur {
  font-weight: 400;
  font-size: 10px;
  color: #94a3b8;
  margin-left: 3px;
}

body[data-theme="light"] .blob-label-dur {
  color: #64748b !important;
}

/* Summary Row & Black Bar Elimination in Light Theme */
body[data-theme="light"] .task-row.summary {
  background: #f1f5f9 !important;
  color: #0f172a !important;
  border-bottom: 1px solid #cbd5e1 !important;
}

body[data-theme="light"] .task-row.summary .td-cell {
  color: #0f172a !important;
  border-right-color: #e2e8f0 !important;
}

body[data-theme="light"] .gantt-row.summary {
  background: #f8fafc !important;
  border-bottom: 1px solid #f1f5f9 !important;
}

body[data-theme="light"] .gantt-blob.summary-blob {
  background: #475569 !important;
  border: 1px solid #334155 !important;
}

body[data-theme="light"] .td-cell {
  border-right: 1px solid #e2e8f0 !important;
}

body[data-theme="light"] .procurement-toolbar {
  background: #ffffff !important;
  border-bottom: 1px solid #cbd5e1 !important;
}

body[data-theme="light"] .proc-select,
body[data-theme="light"] .proc-input {
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid #cbd5e1 !important;
}

body[data-theme="light"] .bottom-panel {
  background: #ffffff !important;
  border-top: 1px solid #cbd5e1 !important;
}

body[data-theme="light"] .bottom-panel-header {
  background: #f8fafc !important;
  border-bottom: 1px solid #e2e8f0 !important;
  color: #0f172a !important;
}

/* Tree Toggle Chevron styling */
.tree-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  cursor: pointer;
  font-size: 10px;
  color: var(--text-muted);
  user-select: none;
  margin-right: 4px;
  border-radius: 3px;
  transition: all 0.15s;
}

.tree-toggle:hover {
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent-cyan);
}

/* ==========================================================================
   Drawing Links, Drag & Drop File Links & AI Assistant Styles
   ========================================================================== */

/* Drawing Badge Button */
.btn-drawing-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  background: rgba(14, 165, 233, 0.15);
  border: 1px solid rgba(14, 165, 233, 0.4);
  color: #38bdf8;
  font-size: 11px;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.15s;
}

.btn-drawing-link:hover {
  background: rgba(14, 165, 233, 0.3);
  border-color: #0284c7;
  color: #ffffff;
  box-shadow: 0 0 6px rgba(14, 165, 233, 0.4);
}

body[data-theme="light"] .btn-drawing-link {
  background: #e0f2fe;
  border-color: #7dd3fc;
  color: #0369a1;
}

body[data-theme="light"] .btn-drawing-link:hover {
  background: #bae6fd;
  color: #0c4a6e;
}

/* Attached Local File Badge */
.btn-file-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #34d399;
  font-size: 11px;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: all 0.15s;
}

.btn-file-link:hover {
  background: rgba(16, 185, 129, 0.3);
  border-color: #10b981;
  color: #ffffff;
}

body[data-theme="light"] .btn-file-link {
  background: #dcfce7;
  border-color: #86efac;
  color: #15803d;
}

/* File Drop Target & Add File Button */
.btn-add-file-link,
.file-drop-target {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  border: 1px dashed rgba(255, 255, 255, 0.25);
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  user-select: none;
}

.btn-add-file-link:hover,
.file-drop-target:hover,
.file-drop-target.drag-over {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  transform: translateY(-1px);
}

body[data-theme="light"] .btn-add-file-link,
body[data-theme="light"] .file-drop-target {
  border-color: #cbd5e1;
  color: #64748b;
  background: #f8fafc;
}

body[data-theme="light"] .btn-add-file-link:hover,
body[data-theme="light"] .file-drop-target:hover,
body[data-theme="light"] .file-drop-target.drag-over {
  background: #f0f9ff;
  border-color: #0284c7;
  color: #0284c7;
}

/* File Badge Group with Edit and Delete */
.btn-file-badge-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.35);
  border-radius: 4px;
  padding: 1px 3px;
  transition: all 0.2s;
}

.btn-file-badge-group:hover {
  border-color: #22c55e;
}

body[data-theme="light"] .btn-file-badge-group {
  background: #dcfce7;
  border-color: #86efac;
}

.btn-file-badge-group .btn-file-link {
  background: transparent;
  border: none;
  padding: 1px 4px;
  font-size: 11px;
  font-weight: 500;
  color: #4ade80;
  cursor: pointer;
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}

body[data-theme="light"] .btn-file-badge-group .btn-file-link {
  color: #15803d;
}

.btn-file-action-btn {
  background: transparent;
  border: none;
  padding: 1px 3px;
  font-size: 10px;
  cursor: pointer;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.btn-file-edit {
  color: var(--text-muted);
}
.btn-file-edit:hover {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
}

.btn-file-del {
  color: #ef4444;
  opacity: 0.7;
}
.btn-file-del:hover {
  background: rgba(239, 68, 68, 0.25);
  opacity: 1;
}

/* AI Assistant Drawer */
.ai-assistant-drawer {
  position: fixed;
  top: 48px;
  right: 0;
  width: 440px;
  max-width: 95vw;
  bottom: 0;
  background: var(--bg-card);
  border-left: 1px solid var(--border-color);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  z-index: 999;
  animation: slideInRight 0.25s ease-out;
  transition: right 0.2s ease, left 0.2s ease, transform 0.25s ease;
}

.ai-assistant-drawer.ai-dock-left {
  right: auto !important;
  left: 0 !important;
  border-left: none !important;
  border-right: 1px solid var(--border-color) !important;
  box-shadow: 8px 0 24px rgba(0, 0, 0, 0.35) !important;
  animation: slideInLeft 0.25s ease-out;
}

.ai-assistant-drawer.ai-dock-adjacent {
  right: 390px !important;
}

@keyframes slideInLeft {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.ai-drawer-header {
  padding: 12px 16px;
  background: var(--bg-pane);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ai-quick-prompts {
  padding: 8px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: rgba(0, 0, 0, 0.1);
  border-bottom: 1px solid var(--border-color);
}

.ai-chip {
  padding: 4px 8px;
  font-size: 11px;
  background: rgba(168, 85, 247, 0.12);
  border: 1px solid rgba(168, 85, 247, 0.3);
  color: #c084fc;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.ai-chip:hover {
  background: rgba(168, 85, 247, 0.25);
  border-color: #a855f7;
  color: #ffffff;
  transform: translateY(-1px);
}

body[data-theme="light"] .ai-chip {
  background: #f3e8ff;
  border-color: #d8b4fe;
  color: #7e22ce;
}

.ai-drawer-messages {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-msg {
  display: flex;
  flex-direction: column;
  max-width: 90%;
  font-size: 13px;
  line-height: 1.55;
  border-radius: 8px;
  padding: 10px 12px;
}

.ai-msg.user {
  align-self: flex-end;
  background: #6366f1;
  color: #ffffff;
  border-bottom-right-radius: 2px;
}

.ai-msg.bot {
  align-self: flex-start;
  background: var(--bg-pane);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-bottom-left-radius: 2px;
}

body[data-theme="light"] .ai-msg.bot {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #0f172a;
}

.ai-msg.bot strong {
  color: #38bdf8;
}

body[data-theme="light"] .ai-msg.bot strong {
  color: #0284c7;
}

.ai-drawer-input-area {
  padding: 12px;
  background: var(--bg-pane);
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-input {
  width: 100%;
  resize: none;
  font-size: 12px;
  padding: 8px;
  box-sizing: border-box;
}

/* Linked Contract Inspector Modal Styling */
.linked-proc-row:hover {
  background: rgba(56, 189, 248, 0.1) !important;
}

body[data-theme="light"] .linked-proc-row:hover {
  background: #f0f9ff !important;
}

/* ========================================================================= */
/* Resource Management View Styling (People, Machinery & Materials)          */
/* ========================================================================= */
.res-trade-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 12px;
  padding: 2px 7px;
  font-size: 11px;
  margin: 2px 4px 2px 0;
  font-weight: 500;
}

body[data-theme="light"] .res-trade-tag {
  background: #e0f2fe;
  color: #0284c7;
  border-color: #bae6fd;
}

.res-machine-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 12px;
  padding: 2px 7px;
  font-size: 11px;
  margin: 2px 4px 2px 0;
  font-weight: 500;
}

body[data-theme="light"] .res-machine-tag {
  background: #fef3c7;
  color: #d97706;
  border-color: #fde68a;
}

.res-mat-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.35);
  border-radius: 12px;
  padding: 2px 7px;
  font-size: 11px;
  margin: 2px 4px 2px 0;
  max-width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body[data-theme="light"] .res-mat-tag {
  background: #dcfce7;
  color: #15803d;
  border-color: #bbf7d0;
}

.res-inline-input {
  background: transparent;
  border: 1px dashed var(--border-color);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 11px;
  color: var(--text-primary);
  width: 100%;
  box-sizing: border-box;
}

.res-inline-input:focus {
  outline: none;
  border-color: var(--accent-blue);
  background: rgba(56, 189, 248, 0.08);
}

/* =========================================================================
   5. Document & Drawing Network View & Drawer Styles
   ========================================================================= */

.doc-network-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  background: var(--bg-dark);
  position: relative;
}

.doc-net-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px clamp(2px, 0.4vw, 6px);
  background: #111a2e;
  border-bottom: 1px solid var(--border-color);
  gap: clamp(1px, 0.2vw, 3px);
  flex-wrap: nowrap;
  z-index: 20;
}

body[data-theme="light"] .doc-net-toolbar {
  background: #f8fafc;
}

.doc-net-main-stage {
  display: flex;
  flex: 1;
  position: relative;
  overflow: hidden;
}

.doc-net-canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at center, #111827 0%, #0b0f19 100%);
  cursor: grab;
}

body[data-theme="light"] .doc-net-canvas-wrap {
  background: radial-gradient(circle at center, #f8fafc 0%, #e2e8f0 100%);
}

.doc-net-canvas-wrap:active {
  cursor: grabbing;
}

.doc-net-legend {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 12px;
  z-index: 10;
  max-width: 280px;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

body[data-theme="light"] .doc-net-legend {
  background: rgba(255, 255, 255, 0.9);
}

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* Document Details Drawer */
.doc-detail-drawer {
  width: 380px;
  max-width: 90vw;
  background: var(--bg-card);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.35);
  animation: slideInRight 0.22s ease-out;
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.doc-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-pane);
  border-bottom: 1px solid var(--border-color);
}

.doc-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.doc-meta-badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.doc-drawer-section {
  background: var(--bg-pane);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 10px 12px;
}

.doc-section-title {
  font-weight: 700;
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.doc-tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.doc-tag-item {
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 10px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 500;
}

.doc-drawer-contract-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s;
}

.doc-drawer-contract-row:hover {
  background: rgba(56, 189, 248, 0.12);
  border-color: var(--accent-blue);
}

.doc-drawer-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-pane);
  border-top: 1px solid var(--border-color);
}

/* SVG Network Nodes & Edges */
.node-edge {
  stroke: rgba(148, 163, 184, 0.35);
  stroke-width: 1.5;
  stroke-linecap: round;
  transition: stroke 0.2s, stroke-width 0.2s;
}

.node-edge.active {
  stroke: #38bdf8;
  stroke-width: 2.5;
}

.network-node {
  cursor: pointer;
  transition: transform 0.15s ease-out;
}

.network-node:hover {
  filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.6));
}

.network-node.selected circle {
  stroke: #f59e0b !important;
  stroke-width: 3.5 !important;
}

.network-node.subcat-node circle {
  transition: all 0.2s ease;
}

.network-node.subcat-node:hover circle {
  stroke-width: 3px;
  filter: drop-shadow(0 0 10px rgba(234, 179, 8, 0.7));
}

.node-text {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  pointer-events: none;
  user-select: none;
}

/* ========================================================================= */
/* Document Explorer & Dual-Mode Document Management                         */
/* ========================================================================= */

.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: #38bdf8;
  white-space: nowrap;
  user-select: none;
}

.sync-pill.synced {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.3);
  color: #4ade80;
}

.sync-pill.scanning {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.3);
  color: #fbbf24;
}

.doc-explorer-container {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - 120px);
  background: var(--bg-dark, #0b1329);
}

.doc-explorer-sidebar {
  width: 320px;
  min-width: 260px;
  max-width: 440px;
  background: var(--bg-pane, #131d38);
  border-right: 1px solid var(--border-color, #1e293b);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.doc-discipline-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color, #1e293b);
  background: rgba(15, 23, 42, 0.4);
}

.doc-chip {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color, #334155);
  color: var(--text-secondary, #94a3b8);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.doc-chip:hover {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.3);
  color: #38bdf8;
}

.doc-chip.active {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(2, 132, 199, 0.3);
}

.doc-folder-search-wrap {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color, #1e293b);
  background: rgba(15, 23, 42, 0.2);
}

.doc-folder-search {
  width: 100%;
  height: 28px;
  padding: 0 8px;
  font-size: 11.5px;
  border-radius: 4px;
  border: 1px solid var(--border-color, #334155);
  background: var(--bg-card, #0f172a);
  color: var(--text-primary, #f8fafc);
  outline: none;
}

.doc-folder-search:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.4);
}

.doc-explorer-tree-wrap {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 8px;
}

.doc-tree-node {
  margin: 1px 0;
}

.tree-node-row {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  font-size: 12px;
  color: var(--text-primary, #e2e8f0);
  transition: background 0.12s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-node-row:hover {
  background: rgba(255, 255, 255, 0.05);
}

.tree-node-row.active {
  background: rgba(2, 132, 199, 0.22);
  color: #38bdf8;
  font-weight: 600;
  border-left: 2px solid #38bdf8;
}

.tree-expand-icon {
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text-muted, #64748b);
  cursor: pointer;
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.tree-expand-icon.expanded {
  transform: rotate(90deg);
}

.tree-folder-icon {
  font-size: 13px;
  flex-shrink: 0;
}

.tree-node-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-muted, #94a3b8);
  font-weight: 500;
  margin-left: 4px;
  flex-shrink: 0;
}

.tree-children {
  margin-left: 14px;
  border-left: 1px dashed rgba(255, 255, 255, 0.1);
  padding-left: 4px;
}

.doc-explorer-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-dark, #0b1329);
}

.doc-content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-color, #1e293b);
  background: var(--bg-pane, #131d38);
  min-height: 44px;
  gap: 12px;
}

.doc-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  overflow-x: auto;
  white-space: nowrap;
  flex: 1;
}

.doc-breadcrumbs .crumb {
  cursor: pointer;
  color: var(--text-muted, #94a3b8);
  transition: color 0.12s ease;
  padding: 2px 4px;
  border-radius: 3px;
}

.doc-breadcrumbs .crumb:hover {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
}

.doc-breadcrumbs .crumb.active {
  color: #f1f5f9;
  font-weight: 600;
  cursor: default;
}

.doc-breadcrumbs .crumb-sep {
  color: var(--text-muted, #64748b);
  user-select: none;
}

.doc-folder-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.doc-file-count-badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary, #94a3b8);
  border: 1px solid var(--border-color, #334155);
}

.doc-table-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
}

.doc-file-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.doc-file-table th {
  position: sticky;
  top: 0;
  background: #0f172a;
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary, #94a3b8);
  border-bottom: 1px solid var(--border-color, #1e293b);
  z-index: 5;
  white-space: nowrap;
}

.doc-file-table td {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}

.doc-file-table tbody tr {
  transition: background 0.1s ease;
}

.doc-file-table tbody tr:hover {
  background: rgba(56, 189, 248, 0.05);
}

.doc-file-name-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 220px;
}

.doc-file-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.doc-file-name-text {
  font-weight: 500;
  color: #f1f5f9;
  word-break: break-all;
}

.doc-file-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  margin-left: 6px;
}

.doc-tag-pdf { background: rgba(239, 68, 68, 0.2); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }
.doc-tag-dwg { background: rgba(14, 165, 233, 0.2); color: #38bdf8; border: 1px solid rgba(14, 165, 233, 0.3); }
.doc-tag-bim { background: rgba(168, 85, 247, 0.2); color: #c084fc; border: 1px solid rgba(168, 85, 247, 0.3); }
.doc-tag-xlsx, .doc-tag-xls { background: rgba(34, 197, 94, 0.2); color: #4ade80; border: 1px solid rgba(34, 197, 94, 0.3); }
.doc-tag-docx, .doc-tag-doc { background: rgba(59, 130, 246, 0.2); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.3); }
.doc-tag-img { background: rgba(245, 158, 11, 0.2); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.doc-tag-other { background: rgba(148, 163, 184, 0.2); color: #cbd5e1; border: 1px solid rgba(148, 163, 184, 0.3); }

.doc-linked-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.18);
  border: 1px solid rgba(99, 102, 241, 0.35);
  color: #a5b4fc;
  cursor: pointer;
}

.btn-doc-act {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 7px;
  font-size: 11px;
  border-radius: 4px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color, #334155);
  color: var(--text-secondary, #cbd5e1);
  transition: all 0.12s ease;
  white-space: nowrap;
}

.btn-doc-act:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: #38bdf8;
  color: #38bdf8;
}

.btn-doc-act.primary {
  background: rgba(2, 132, 199, 0.2);
  border-color: #0284c7;
  color: #38bdf8;
}

.btn-doc-act.primary:hover {
  background: #0284c7;
  color: #fff;
}

/* ========================================================================= */
/* Document Explorer & Files Manager - Light Theme Overrides                 */
/* ========================================================================= */
body[data-theme="light"] .doc-network-view {
  background: var(--bg-primary, #f8fafc);
  color: var(--text-primary, #0f172a);
}

body[data-theme="light"] .doc-net-toolbar {
  background: #ffffff;
  border-bottom: 1px solid #cbd5e1;
}

body[data-theme="light"] .doc-explorer-container {
  background: #ffffff;
}

body[data-theme="light"] .doc-explorer-sidebar {
  background: #f8fafc;
  border-right: 1px solid #cbd5e1;
}

body[data-theme="light"] .doc-discipline-chips {
  background: #f1f5f9;
  border-bottom: 1px solid #cbd5e1;
}

body[data-theme="light"] .doc-chip {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #334155;
}

body[data-theme="light"] .doc-chip:hover {
  background: rgba(2, 132, 199, 0.08);
  border-color: #0284c7;
  color: #0284c7;
}

body[data-theme="light"] .doc-chip.active {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
  box-shadow: 0 1px 4px rgba(2, 132, 199, 0.25);
}

body[data-theme="light"] .doc-folder-search-wrap {
  background: #f8fafc;
  border-bottom: 1px solid #cbd5e1;
}

body[data-theme="light"] .doc-folder-search {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #0f172a;
}

body[data-theme="light"] .doc-folder-search:focus {
  border-color: #0284c7;
  box-shadow: 0 0 0 1px rgba(2, 132, 199, 0.3);
}

body[data-theme="light"] .tree-node-row {
  color: #0f172a;
}

body[data-theme="light"] .tree-node-row:hover {
  background: rgba(0, 0, 0, 0.04);
}

body[data-theme="light"] .tree-node-row.active {
  background: rgba(2, 132, 199, 0.12);
  color: #0284c7;
  border-left: 2px solid #0284c7;
}

body[data-theme="light"] .tree-badge {
  background: #e2e8f0;
  color: #475569;
}

body[data-theme="light"] .tree-children {
  border-left: 1px dashed #cbd5e1;
}

body[data-theme="light"] .doc-explorer-content {
  background: #ffffff;
}

body[data-theme="light"] .doc-content-header {
  background: #f8fafc;
  border-bottom: 1px solid #cbd5e1;
}

body[data-theme="light"] .doc-breadcrumbs .crumb {
  color: #64748b;
}

body[data-theme="light"] .doc-breadcrumbs .crumb:hover {
  color: #0284c7;
  background: rgba(2, 132, 199, 0.08);
}

body[data-theme="light"] .doc-breadcrumbs .crumb.active {
  color: #0f172a;
  font-weight: 600;
}

body[data-theme="light"] .doc-breadcrumbs .crumb-sep {
  color: #94a3b8;
}

body[data-theme="light"] .doc-file-count-badge {
  background: #ffffff;
  color: #334155;
  border: 1px solid #cbd5e1;
}

body[data-theme="light"] .doc-file-table th {
  background: #f1f5f9;
  color: #334155;
  border-bottom: 2px solid #cbd5e1;
}

body[data-theme="light"] .doc-file-table td {
  border-bottom: 1px solid #e2e8f0;
  color: #0f172a;
}

body[data-theme="light"] .doc-file-table tbody tr:hover {
  background: rgba(2, 132, 199, 0.04);
}

body[data-theme="light"] .doc-file-name-text {
  color: #0f172a;
}

body[data-theme="light"] .doc-file-name {
  color: #0f172a;
}

body[data-theme="light"] .doc-file-name:hover {
  color: #0284c7;
}

body[data-theme="light"] .btn-doc-act {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #334155;
}

body[data-theme="light"] .btn-doc-act:hover {
  background: #f1f5f9;
  border-color: #0284c7;
  color: #0284c7;
}

body[data-theme="light"] .btn-doc-act.primary {
  background: rgba(2, 132, 199, 0.1);
  border-color: #0284c7;
  color: #0284c7;
}

body[data-theme="light"] .btn-doc-act.primary:hover {
  background: #0284c7;
  color: #ffffff;
}

body[data-theme="light"] .doc-linked-badge {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.3);
  color: #4f46e5;
}

/* ========================================================================= */
/* User Profile Gate Modal - Light Theme Overrides                           */
/* ========================================================================= */
body[data-theme="light"] #userProfileGateModal .modal-card {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.15) !important;
}

body[data-theme="light"] #userProfileGateModal .modal-header {
  background: #f8fafc !important;
  border-bottom: 1px solid #e2e8f0 !important;
}

body[data-theme="light"] #userProfileGateModal .modal-header h3 {
  color: #0f172a !important;
}

body[data-theme="light"] #userProfileGateModal .modal-header p {
  color: #64748b !important;
}

body[data-theme="light"] #userProfileGateModal label {
  color: #334155 !important;
}

body[data-theme="light"] #userProfileGateModal input.form-control {
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid #cbd5e1 !important;
}

body[data-theme="light"] #userProfileGateModal input.form-control:focus {
  border-color: #0284c7 !important;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.2) !important;
}

body[data-theme="light"] #userProfileGateModal .policy-box {
  background: #f1f5f9 !important;
  border: 1px solid #e2e8f0 !important;
  color: #475569 !important;
}

body[data-theme="light"] #userProfileGateModal .policy-box code {
  color: #0284c7 !important;
  background: #e2e8f0 !important;
}

body[data-theme="light"] #btnCloseUserProfileGateModal {
  color: #64748b !important;
}

body[data-theme="light"] #btnCloseUserProfileGateModal:hover {
  color: #0f172a !important;
}

/* ========================================================================= */
/* Multi-Resolution Responsive Breakpoints (1080p, 1366x768, 1440x900, 1600)  */
/* ========================================================================= */

@media (max-width: 1720px) {
  .brand-subtitle {
    max-width: 200px;
  }
  .btn {
    padding: 5px 8px;
    font-size: 12px;
  }
}

@media (max-width: 1520px) {
  .brand-subtitle {
    max-width: 150px;
    font-size: 10px;
  }
  .view-switcher .btn {
    padding: 4px 7px;
    font-size: 11.5px;
  }
  /* Gracefully collapse text on secondary toolbar and header action buttons */
  .toolbar .btn-text,
  .schedule-toolbar-group .btn-text,
  .header-actions .btn-text {
    display: none;
  }
  .toolbar .btn,
  .schedule-toolbar-group .btn,
  .header-actions .btn {
    padding: 5px 8px;
  }
}

@media (max-width: 1366px) {
  .brand-subtitle {
    display: none;
  }
  .brand-title {
    font-size: 13.5px;
  }
  .app-header {
    padding: 0 8px;
    gap: 6px;
  }
  .view-switcher .btn {
    padding: 4px 6px;
    font-size: 11px;
  }
  .header-actions {
    gap: 4px;
  }
  .header-actions .btn {
    padding: 4px 6px;
  }
  .auto-save-badge .badge-text {
    display: none;
  }
  .stat-item {
    gap: 4px;
    font-size: 11px;
  }
  .stat-item#statItemCode,
  .stat-item#statItemStart {
    display: none;
  }
  .stats-bar {
    gap: 8px;
    padding: 3px 8px;
  }
  .schedule-toolbar-group {
    gap: 4px;
  }
  .left-pane {
    width: clamp(380px, 45vw, 550px);
    min-width: 340px;
  }
}

@media (max-width: 1200px) {
  .brand-title {
    font-size: 12.5px;
  }
  .view-switcher .btn {
    padding: 3px 5px;
    font-size: 10.5px;
  }
  .header-actions .btn {
    padding: 3px 5px;
    font-size: 11px;
  }
  .schedule-toolbar-group .btn {
    padding: 3px 5px;
    font-size: 11px;
  }
  #taskSearchInput {
    width: 130px;
    font-size: 10.5px;
  }
  .left-pane {
    width: clamp(340px, 42vw, 480px);
    min-width: 320px;
  }
}

@media (max-width: 1080px) {
  .view-switcher .tab-label {
    display: none;
  }
  .view-switcher .btn {
    padding: 5px 8px;
    font-size: 13px;
  }
  .app-header {
    gap: 4px;
    padding: 0 6px;
  }
  .header-actions {
    gap: 3px;
  }
  #btnDirectExportAppSheet {
    display: none;
  }
  .auto-save-badge {
    padding: 2px 4px;
  }
  .auto-save-badge .badge-text {
    display: none;
  }
  #gdriveSyncBadge .badge-text {
    display: none;
  }
  .stats-bar {
    gap: 6px;
    padding: 3px 6px;
  }
  #taskSearchInput {
    width: 100px;
    font-size: 10px;
  }
  .stat-item#statItemDuration {
    display: none;
  }
  .left-pane {
    width: clamp(300px, 40vw, 440px);
    min-width: 290px;
  }
}

@media (max-width: 850px) {
  .brand-icon {
    font-size: 14px;
  }
  .brand-title {
    display: none;
  }
  .auto-save-badge {
    display: none;
  }
  .stats-bar {
    font-size: 10.5px;
  }
  .stat-item#statItemFinalPct {
    display: none;
  }
}

/* Resource Editor Modal & Steppers */
.res-calc-box {
  background: rgba(14, 165, 233, 0.08);
  border: 1px solid rgba(14, 165, 233, 0.25);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 12px;
  color: var(--text-secondary);
}

.res-calc-formula {
  font-family: var(--font-mono, monospace);
  font-weight: 600;
  color: #38bdf8;
  margin-top: 4px;
}

.res-stepper-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.res-stepper-card {
  background: var(--bg-pane);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.res-stepper-label {
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.res-stepper-ctrl {
  display: flex;
  align-items: center;
  gap: 4px;
}

.res-stepper-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.res-stepper-btn:hover {
  background: var(--accent-blue);
  color: #fff;
  border-color: var(--accent-blue);
}

.res-stepper-inp {
  flex: 1;
  height: 32px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
}

/* Productivity Table */
.prod-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.prod-table th, .prod-table td {
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  text-align: left;
}

.prod-table th {
  background: var(--bg-pane);
  font-weight: 600;
  color: var(--text-secondary);
}

.prod-table tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* =========================================================================
   BIM 3D/4D Construction Sequencing & Model View Styles
   ========================================================================= */
.bim-view {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
  position: relative;
  overflow: hidden;
  background: #0b1329;
}

.bim-main-stage {
  display: flex;
  flex: 1;
  position: relative;
  overflow: hidden;
}

.bim-main-stage.split-mode #bimCanvasContainer {
  width: 55% !important;
  flex: none !important;
}

#bimCanvasContainer,
#bimCanvasContainer canvas {
  cursor: default;
}

#bimCanvasContainer canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.bim-inspector-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 350px;
  max-width: 90vw;
  height: 100%;
  background: var(--bg-card);
  color: var(--text-primary);
  backdrop-filter: blur(12px);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 35;
  overflow: hidden;
  box-shadow: -6px 0 24px rgba(0, 0, 0, 0.45);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
  transform: translateX(0);
  opacity: 1;
}

.bim-inspector-drawer.collapsed {
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}

.bim-timeline-bar input[type="range"] {
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  outline: none;
}

.bim-timeline-bar input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ea580c;
  border: 2px solid #fff;
  box-shadow: 0 0 10px rgba(234, 88, 12, 0.8);
  cursor: pointer;
  transition: transform 0.1s;
}

.bim-timeline-bar input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.25);
}

@keyframes bimPulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.8; }
  100% { transform: scale(1); opacity: 1; }
}

/* =========================================================================
   BIM Category & Type Popover Styling (Dark & Light)
   ========================================================================= */

#bimCategoryPopover {
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid #334155;
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.7);
}

.bim-cat-group {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 4px 0;
}

.bim-cat-header {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background 0.15s;
}

.bim-cat-header:hover {
  background: rgba(255, 255, 255, 0.05);
}

.bim-cat-name {
  color: #f1f5f9;
  font-size: 11px;
  font-weight: 600;
}

.bim-cat-count {
  color: #94a3b8;
  font-size: 10px;
}

.bim-type-list {
  padding-left: 20px;
  margin-top: 3px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-left: 2px solid rgba(56, 189, 248, 0.3);
  margin-left: 8px;
}

.bim-type-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: #cbd5e1;
  cursor: pointer;
  padding: 1px 4px;
  border-radius: 3px;
}

.bim-type-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
}

.bim-type-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bim-type-count {
  color: #64748b;
  font-size: 9px;
}

/* Light Theme BIM Overrides */
body[data-theme="light"] #bimCategoryPopover {
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
}

body[data-theme="light"] .bim-cat-group {
  border-bottom: 1px solid #f1f5f9 !important;
}

body[data-theme="light"] .bim-cat-header:hover {
  background: #f8fafc !important;
}

body[data-theme="light"] .bim-cat-name {
  color: #0f172a !important;
}

body[data-theme="light"] .bim-cat-count {
  color: #64748b !important;
}

body[data-theme="light"] .bim-type-list {
  border-left-color: #0284c7 !important;
}

body[data-theme="light"] .bim-type-item {
  color: #334155 !important;
}

body[data-theme="light"] .bim-type-item:hover {
  background: #f1f5f9 !important;
  color: #0f172a !important;
}

body[data-theme="light"] .bim-type-count {
  color: #94a3b8 !important;
}

/* BIM Toolbar in Light Theme */
body[data-theme="light"] .bim-toolbar {
  background: #ffffff !important;
  border-bottom: 1px solid #e2e8f0 !important;
}

body[data-theme="light"] .bim-toolbar select,
body[data-theme="light"] .bim-toolbar button {
  background: #f8fafc !important;
  color: #0f172a !important;
  border-color: #cbd5e1 !important;
}

body[data-theme="light"] .bim-toolbar button.active {
  background: #e0f2fe !important;
  color: #0284c7 !important;
  border-color: #0284c7 !important;
}

/* BIM Inspector in Light Theme */
body[data-theme="light"] .bim-inspector-drawer {
  background: #ffffff !important;
  border-left: 1px solid #e2e8f0 !important;
  color: #0f172a !important;
}

body[data-theme="light"] .bim-inspector-header {
  background: #f8fafc !important;
  border-bottom: 1px solid #e2e8f0 !important;
  color: #0f172a !important;
}

body[data-theme="light"] .inspector-card {
  background: #ffffff !important;
  color: #0f172a !important;
}

body[data-theme="light"] .bim-prop-grid {
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
  color: #334155 !important;
}

/* BIM Parameters Pane in Light Theme */
body[data-theme="light"] .bim-param-box {
  background: #f8fafc !important;
  border: 1px solid #cbd5e1 !important;
  color: #1e293b !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
}

body[data-theme="light"] .bim-param-box .bim-param-row {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  color: #0f172a !important;
}

body[data-theme="light"] .bim-param-box .param-key {
  color: #475569 !important;
  font-weight: 600 !important;
}

body[data-theme="light"] .bim-param-box .param-val {
  color: #0f172a !important;
  font-weight: 700 !important;
}

body[data-theme="light"] .proc-linked-card {
  background: #ecfdf5 !important;
  border: 1px solid #a7f3d0 !important;
  color: #065f46 !important;
}

body[data-theme="light"] .proc-linked-card-title {
  color: #064e3b !important;
}

body[data-theme="light"] .proc-linked-card-meta {
  color: #047857 !important;
}

/* Universal High-Contrast Light Theme Overrides for KPI Cards */
body[data-theme="light"] .kpi-card,
body[data-theme="light"] .procurement-kpis .kpi-card,
body[data-theme="light"] .resource-view .kpi-dashboard .kpi-card,
body[data-theme="light"] .kpi-dashboard .kpi-card {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05) !important;
}

body[data-theme="light"] .kpi-title {
  color: #475569 !important;
  font-weight: 600 !important;
}

body[data-theme="light"] .kpi-val {
  color: #0f172a !important;
  font-weight: 700 !important;
}

body[data-theme="light"] .kpi-val.highlight {
  color: #0284c7 !important;
}

body[data-theme="light"] .kpi-val.green {
  color: #16a34a !important;
}

/* Schedule Locked State Styling */
.schedule-locked .td-inline-input {
  pointer-events: none !important;
  opacity: 0.65 !important;
  background: transparent !important;
  border: none !important;
}

.schedule-locked .editable-date-cell {
  pointer-events: none !important;
  cursor: not-allowed !important;
}

.schedule-locked .btn-link-to-proc {
  pointer-events: auto !important;
  cursor: pointer !important;
  opacity: 1 !important;
}

/* Inline Date Input Styling for Gantt Table */
.td-inline-input.input-date {
  font-size: 11px;
  font-weight: 500;
  padding: 0 1px;
  color: var(--text-primary);
  color-scheme: dark;
}

body[data-theme="light"] .td-inline-input.input-date {
  color-scheme: light;
}

.td-inline-input.input-date::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.6;
  padding: 0;
  margin-right: 1px;
  filter: invert(0.8);
}

body[data-theme="light"] .td-inline-input.input-date::-webkit-calendar-picker-indicator {
  filter: none;
}

.td-inline-input.input-date:hover::-webkit-calendar-picker-indicator {
  opacity: 1;
}

.schedule-locked .gantt-blob {
  cursor: not-allowed !important;
}

.schedule-locked .blob-handle {
  display: none !important;
}

#btnToggleScheduleLock.locked {
  background: rgba(239, 68, 68, 0.15) !important;
  border-color: rgba(239, 68, 68, 0.5) !important;
  color: #ef4444 !important;
  font-weight: 700 !important;
}

/* Subitems Toggle Rule for 88 Procurement Table */
.proc-table-wrapper.hide-subitems tr.is-subitem {
  display: none !important;
}

/* Column resizers and column/subitem selectors remain fully interactive in locked mode */
.col-resizer,
.col-resizer:hover,
.col-resizer.is-resizing,
.schedule-locked .col-resizer {
  pointer-events: auto !important;
  cursor: col-resize !important;
}

#btnToggleProcColumns,
#procColumnSelectorPopover,
#resColumnSelectorPopover,
#btnToggleSubItems {
  pointer-events: auto !important;
}

#procColumnSelectorPopover,
#resColumnSelectorPopover {
  background: #1e293b !important;
  color: #f8fafc !important;
  border: 1px solid #475569 !important;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.7) !important;
}

body[data-theme="light"] #procColumnSelectorPopover,
body[data-theme="light"] #resColumnSelectorPopover {
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15) !important;
}

/* Resource Variance Badges */
.res-variance-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono, monospace);
}

.res-variance-badge.on-track {
  background: rgba(34, 197, 94, 0.15);
  color: #16a34a;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.res-variance-badge.warning {
  background: rgba(245, 158, 11, 0.15);
  color: #d97706;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.res-variance-badge.overrun {
  background: rgba(239, 68, 68, 0.15);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Spreadsheet Preview Table Styling */
#excelPreviewContainer table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
}

#excelPreviewContainer th {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-weight: 600;
  border: 1px solid var(--border-color);
  padding: 6px 10px;
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 5;
}

#excelPreviewContainer td {
  border: 1px solid var(--border-color);
  padding: 5px 8px;
  color: var(--text-primary);
}

#excelPreviewContainer tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

body[data-theme="light"] #excelPreviewContainer tr:nth-child(even) {
  background: #f8fafc;
}

/* Float Badges (Total Float & Free Float) */
.float-badge {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono, monospace);
  text-align: center;
  line-height: 1.3;
}

.float-badge.critical {
  background: rgba(239, 68, 68, 0.18);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #ef4444;
}

.float-badge.warning {
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.5);
  color: #f59e0b;
}

.float-badge.normal {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #10b981;
}

body[data-theme="light"] .float-badge.critical {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
}

body[data-theme="light"] .float-badge.warning {
  background: #fef3c7;
  border-color: #fcd34d;
  color: #d97706;
}

body[data-theme="light"] .float-badge.normal {
  background: #dcfce7;
  border-color: #86efac;
  color: #16a34a;
}

/* AI Scheduling Suggestions Modal & Cards */
.suggestion-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.suggestion-card:hover {
  border-color: #a855f7;
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.15);
}

.suggestion-card.applied {
  opacity: 0.65;
  border-color: #10b981 !important;
  background: rgba(16, 185, 129, 0.05);
}

.suggestion-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sug-type-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sug-type-compression {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.sug-type-leveling {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.sug-type-logic {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.sug-diff-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-tertiary);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-family: var(--font-mono, monospace);
  flex-wrap: wrap;
}

.diff-before {
  color: #ef4444;
  text-decoration: line-through;
  opacity: 0.85;
}

.diff-arrow {
  color: var(--text-muted);
}

.diff-after {
  color: #10b981;
  font-weight: 700;
}

.impact-pill {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.3);
  font-weight: 600;
}

body[data-theme="light"] .impact-pill {
  background: #f3e8ff;
  border-color: #d8b4fe;
  color: #7e22ce;
}

/* Rulebook Linking & Procurement Overdue Badges */
.badge-overdue {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.4);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
}

body[data-theme="light"] .badge-overdue {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fca5a5;
}

.badge-rule-linked {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.4);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 600;
}

.badge-unlinked {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.4);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 600;
}

/* Ambiguity Candidate Buttons */
.btn-ambiguity-candidate {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  color: var(--text-primary);
}

.btn-ambiguity-candidate:hover {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
  transform: translateX(4px);
}

/* =========================================================================
   Resource Table Resizing & Sticky Edit Button Fix (Task 2)
   ========================================================================= */
.res-resizable-table {
  table-layout: fixed;
}

.res-labor-cell-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  position: relative;
  width: 100%;
}

.labor-badges-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1;
  min-width: 0;
  max-height: 80px;
  overflow-y: auto;
}

.btn-edit-res {
  flex-shrink: 0;
  position: sticky;
  right: 0;
  z-index: 2;
  padding: 3px 8px;
  font-size: 11px;
  background: var(--bg-tertiary, #1e293b);
  border: 1px solid var(--border-color, #475569);
  color: var(--text-primary, #f8fafc);
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  transition: all 0.2s ease;
}

.btn-edit-res:hover {
  background: var(--accent-blue, #0284c7);
  color: #ffffff;
  border-color: #38bdf8;
  transform: scale(1.05);
}

.col-resizer {
  position: absolute;
  top: 0;
  right: -4px;
  width: 8px;
  bottom: 0;
  cursor: col-resize;
  user-select: none;
  z-index: 15;
  background: transparent;
  transition: background 0.15s ease;
}

.col-resizer:hover,
.col-resizer.is-resizing {
  background: #38bdf8;
  box-shadow: 0 0 6px rgba(56, 189, 248, 0.8);
}

/* Universal Select Option Contrast Protection in Dark & Light Themes */
select,
select option {
  color-scheme: dark;
}

body[data-theme="dark"] select,
body:not([data-theme="light"]) select,
#selSCurveValuationMode,
.doc-net-select,
.form-select {
  color-scheme: dark;
}

body[data-theme="dark"] select option,
body:not([data-theme="light"]) select option,
#selSCurveValuationMode option,
.doc-net-select option,
.form-select option {
  background-color: #0f172a !important;
  color: #f8fafc !important;
}

body[data-theme="light"] select,
body[data-theme="light"] select option,
body[data-theme="light"] #selSCurveValuationMode,
body[data-theme="light"] .doc-net-select,
body[data-theme="light"] .form-select {
  color-scheme: light !important;
}

body[data-theme="light"] select option,
body[data-theme="light"] #selSCurveValuationMode option,
body[data-theme="light"] .doc-net-select option,
body[data-theme="light"] .form-select option {
  background-color: #ffffff !important;
  color: #0f172a !important;
}

/* =========================================================================
   Real-Time Multi-User Collaboration & Presence Awareness Styles (Option B)
   ========================================================================= */

/* Top Header Collaborator Roster */
.collaborator-roster-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 20px;
  font-size: 11px;
  max-width: 140px;
  flex-shrink: 1;
  overflow: hidden;
}

body[data-theme="light"] .collaborator-roster-group {
  background: rgba(241, 245, 249, 0.85);
  border-color: rgba(56, 189, 248, 0.4);
}

.collaborator-roster {
  display: flex;
  align-items: center;
  gap: 4px;
}

.collaborator-avatar {
  position: relative;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: #ffffff;
  font-weight: 700;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px var(--bg-card, #0f172a);
  cursor: pointer;
  transition: transform 0.15s ease;
  user-select: none;
}

.collaborator-avatar:hover {
  transform: scale(1.15) translateY(-2px);
  z-index: 5;
}

.collaborator-avatar.is-self {
  border: 2px dashed #ffffff;
}

.online-indicator-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 7px;
  height: 7px;
  background: #10b981;
  border-radius: 50%;
  border: 1px solid var(--bg-card, #0f172a);
}

.collaborator-count-text {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Badge Counter for Header Buttons */
.badge-counter {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 5px;
  line-height: 1.2;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Google Sheets-Style Live Cell Cursor & Border */
.collab-row-active,
.collab-row-editing,
tr.collab-row-active,
tr.collab-row-editing,
.proc-table tr.collab-row-active,
.proc-table tr.collab-row-editing,
.task-row.collab-row-active,
.task-row.collab-row-editing,
tr:has(.collab-peer-editing),
tr:has(.collab-peer-active),
.proc-table tr:has(.collab-peer-editing),
.proc-table tr:has(.collab-peer-active),
.task-row:has(.collab-peer-editing),
.task-row:has(.collab-peer-active) {
  position: relative !important;
  z-index: 10000 !important;
  overflow: visible !important;
}

.collab-peer-active,
.proc-table td.collab-peer-active,
.proc-table tr > td.collab-peer-active {
  position: relative !important;
  box-shadow: inset 0 0 0 2px var(--peer-color, #0284c7), 0 0 8px rgba(2, 132, 199, 0.45) !important;
  z-index: 10005 !important;
  overflow: visible !important;
}

.collab-peer-editing,
.proc-table td.collab-peer-editing,
.proc-table tr > td.collab-peer-editing {
  position: relative !important;
  box-shadow: inset 0 0 0 2.5px var(--peer-color, #e11d48), 0 0 12px var(--peer-color, rgba(225, 29, 72, 0.6)) !important;
  z-index: 10006 !important;
  overflow: visible !important;
  animation: peerEditingPulse 1.2s infinite alternate ease-in-out;
}

@keyframes peerEditingPulse {
  0% {
    box-shadow: inset 0 0 0 2px var(--peer-color, #e11d48), 0 0 5px var(--peer-color, rgba(225, 29, 72, 0.4));
  }
  100% {
    box-shadow: inset 0 0 0 2.5px var(--peer-color, #e11d48), 0 0 14px var(--peer-color, rgba(225, 29, 72, 0.75));
  }
}

.collab-peer-badge {
  position: absolute;
  top: -18px;
  left: 2px;
  padding: 1.5px 8px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 700;
  color: #ffffff;
  pointer-events: none;
  z-index: 10010 !important;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.75), 0 0 0 1.5px rgba(255, 255, 255, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.35);
  line-height: 1.35;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  animation: peerBadgeFadeIn 0.2s ease-out;
}

.collab-peer-badge.collab-peer-badge-align-right {
  left: auto;
  right: 0px;
}

.collab-peer-badge.collab-peer-badge-align-left {
  left: 0px;
  right: auto;
}

.collab-peer-badge.collab-peer-badge-flip-bottom {
  top: auto;
  bottom: -18px;
}

.collab-peer-badge-editing {
  box-shadow: 0 0 0 2px #ffffff, 0 4px 16px rgba(0, 0, 0, 0.85);
  animation: peerBadgeFadeIn 0.2s ease-out, peerBadgeEditingBounce 1.5s infinite ease-in-out;
}

@keyframes peerBadgeEditingBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

/* Remote Cell Update Flash Animation */
@keyframes remoteCellPulse {
  0% { background-color: rgba(56, 189, 248, 0.35); }
  50% { background-color: rgba(16, 185, 129, 0.35); }
  100% { background-color: transparent; }
}

.collab-remote-updated {
  animation: remoteCellPulse 1.4s ease-out;
}

/* Presence Palette Color Swatches in Settings */
.collab-color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  border: 2px solid transparent;
}

.collab-color-swatch:hover {
  transform: scale(1.2);
}

.collab-color-swatch.active {
  border-color: #ffffff;
  box-shadow: 0 0 0 2px #0284c7;
  transform: scale(1.15);
}

/* History Diff Styling */
.hist-diff-old {
  color: #ef4444;
  text-decoration: line-through;
  margin-right: 6px;
  font-weight: 500;
}

.hist-diff-new {
  color: #10b981;
  font-weight: 700;
}
/* ==========================================================================
   BIM Advanced Engineering Tools (Measure, Section, Markers, Comments)
   ========================================================================== */
.bim-main-stage #bimAreasPanel,
.bim-main-stage #bimMeasurePanel,
.bim-main-stage #bimSectionPanel,
.bim-main-stage #bimMarkersPanel,
.bim-main-stage #bimCommentsPanel {
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
  animation: fadeInDown 0.2s ease-out;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.bim-tool-slider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.bim-tool-slider-row input[type="range"] {
  flex: 1;
  height: 4px;
  cursor: pointer;
}

.comment-card {
  transition: all 0.2s ease;
}

.comment-card:hover {
  border-color: #38bdf8 !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* =========================================================================
   User Profile Onboarding Gate & Quick Switcher Styles
   ========================================================================= */
.profile-gate-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.profile-gate-card:hover {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.08);
  transform: translateY(-1px);
}

.profile-gate-card.selected {
  border-color: #0284c7 !important;
  background: rgba(2, 132, 199, 0.16) !important;
  box-shadow: 0 0 0 1px #0284c7;
}

.gate-color-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.15s ease, border-color 0.15s ease;
  display: inline-block;
}

.gate-color-dot:hover {
  transform: scale(1.18);
}

.gate-color-dot.active {
  border-color: #ffffff !important;
  box-shadow: 0 0 0 2px #0284c7;
  transform: scale(1.15);
}

#btnQuickProfileSwitch:hover {
  background: rgba(2, 132, 199, 0.28) !important;
  border-color: #38bdf8 !important;
}

/* 3D Measurement Dynamic Rubber-Band Floating Tooltip */
.bim-measure-floating-badge {
  position: absolute;
  pointer-events: none;
  z-index: 60;
  transform: translate(-50%, -140%);
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1.5px solid #00f0ff;
  color: #00f0ff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 8px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.55), 0 0 12px rgba(0, 240, 255, 0.4);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  letter-spacing: 0.5px;
  transition: opacity 0.08s ease;
  user-select: none;
}

/* 3D Marker Placement Live TWD97 Coordinates Floating Tooltip */
.bim-marker-floating-badge {
  position: absolute;
  pointer-events: none;
  z-index: 60;
  transform: translate(18px, -50%);
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1.5px solid #10b981;
  color: #f8fafc;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.65), 0 0 14px rgba(16, 185, 129, 0.4);
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  user-select: none;
  transition: opacity 0.06s ease;
}

/* =========================================================================
   Responsive Dense Tool Ribbon Rules for Compact & Small Screens
   ========================================================================= */
@media (max-width: 1400px) {
  .header-actions .btn-text {
    display: none;
  }
  .collaborator-count-text {
    display: none;
  }
}

@media (max-width: 1280px) {
  #bimToolbarSubtitle {
    display: none !important;
  }
  #lblBimSplitMode,
  #lblBimFutureStyle,
  #lblBimLighting,
  #lblBimSiteScan,
  #lblBimImportModel {
    display: none;
  }
  #bimGenericModelHiddenBadge {
    display: none;
  }
}

/* =========================================================================
   User Identity Picker Modal Theme Styling (Light & Dark Mode)
   ========================================================================= */
#userProfileGateModal .gate-modal-card {
  max-width: 580px;
  width: 92%;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  background: var(--bg-card, #1e293b);
  border: 1px solid var(--border-color, #334155);
  transition: background-color 0.2s, border-color 0.2s;
}

body[data-theme="light"] #userProfileGateModal .gate-modal-card {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  box-shadow: 0 20px 45px -8px rgba(0, 0, 0, 0.15);
}

#userProfileGateModal .gate-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color, #334155);
  background: rgba(15, 23, 42, 0.6);
}

body[data-theme="light"] #userProfileGateModal .gate-header {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

#userProfileGateModal .gate-search-input,
#userProfileGateModal .gate-form-input {
  background: var(--bg-main, #0f172a);
  color: var(--text-primary, #f8fafc);
  border: 1px solid var(--border-color, #334155);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12.5px;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

body[data-theme="light"] #userProfileGateModal .gate-search-input,
body[data-theme="light"] #userProfileGateModal .gate-form-input {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
}

#userProfileGateModal .gate-search-input:focus,
#userProfileGateModal .gate-form-input:focus {
  border-color: var(--accent-blue, #0284c7);
  outline: none;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.25);
}

#userProfileGateModal .gate-footnote {
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 11.5px;
  line-height: 1.5;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: var(--text-muted, #94a3b8);
}

body[data-theme="light"] #userProfileGateModal .gate-footnote {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #475569;
}

/* User Profile Cards */
.gate-user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.25);
  cursor: pointer;
  transition: all 0.15s ease;
}

.gate-user-card:hover {
  background: rgba(51, 65, 85, 0.9);
  border-color: rgba(56, 189, 248, 0.5);
  transform: translateY(-1px);
}

.gate-user-card.active {
  background: rgba(56, 189, 248, 0.18);
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.4), 0 4px 12px rgba(2, 132, 199, 0.25);
}

body[data-theme="light"] .gate-user-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

body[data-theme="light"] .gate-user-card:hover {
  background: #f1f5f9;
  border-color: #0284c7;
  transform: translateY(-1px);
}

body[data-theme="light"] .gate-user-card.active {
  background: #e0f2fe;
  border-color: #0284c7;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.35), 0 4px 12px rgba(2, 132, 199, 0.15);
}

/* Responsive User Identity Picker Modal (Mobile Viewports & Landscape) */
@media (max-width: 768px), (max-height: 720px) {
  #userProfileGateModal {
    align-items: center !important;
    justify-content: center !important;
    padding: 10px !important;
  }

  #userProfileGateModal .gate-modal-card {
    max-width: 95vw !important;
    width: 95vw !important;
    max-height: 92vh !important;
    border-radius: 10px !important;
    margin: auto !important;
  }

  #userProfileGateModal .gate-header {
    padding: 10px 14px !important;
  }

  #userProfileGateModal .gate-header h3 {
    font-size: 13.5px !important;
  }

  #userProfileGateModal .gate-header p {
    font-size: 11px !important;
  }

  #userProfileGateModal .modal-body {
    padding: 12px 14px !important;
    gap: 12px !important;
    max-height: 60vh !important;
  }

  #gateExistingUsersGrid {
    grid-template-columns: 1fr !important;
    max-height: 180px !important;
  }

  #gateAddUserForm > div:first-child {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  #userProfileGateModal .gate-footer {
    padding: 10px 14px !important;
    flex-direction: column !important;
    gap: 8px !important;
    align-items: stretch !important;
  }

  #userProfileGateModal .gate-footer > div {
    display: flex !important;
    width: 100% !important;
    gap: 6px !important;
  }

  #userProfileGateModal .gate-footer button {
    flex: 1 !important;
    text-align: center !important;
    justify-content: center !important;
    padding: 8px 10px !important;
  }
}

body.gc-mobile-active #userProfileGateModal {
  align-items: center !important;
  justify-content: center !important;
  padding: 10px !important;
}

body.gc-mobile-active #userProfileGateModal .gate-modal-card {
  max-width: 95vw !important;
  width: 95vw !important;
  max-height: 92vh !important;
  max-height: 92dvh !important;
  border-radius: 10px !important;
  margin: auto !important;
}

body.gc-mobile-active #userProfileGateModal .modal-body {
  padding: 12px 14px !important;
  gap: 12px !important;
  max-height: 60vh !important;
  max-height: 60dvh !important;
}


.edit-color-swatch {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.edit-color-swatch:hover {
  transform: scale(1.15);
}
.edit-color-swatch.active {
  transform: scale(1.2);
  border-color: #ffffff !important;
  box-shadow: 0 0 0 2px #38bdf8;
}

/* =========================================================================
   Coordinate Accuracy & Multi-Layer Realignment Wizard & HUD Styles
   ========================================================================= */
.coord-wizard-overlay {
  position: fixed !important;
  top: 92px !important;
  right: 0 !important;
  bottom: 58px !important;
  left: 0 !important;
  height: auto !important;
  max-height: calc(100vh - 150px) !important;
  z-index: 995 !important;
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  pointer-events: none !important;
  display: flex;
  justify-content: flex-end;
  align-items: stretch;
  padding: 0 14px !important;
}
.coord-wizard-card {
  pointer-events: auto !important;
  width: 440px;
  max-width: calc(100vw - 28px);
  height: 100% !important;
  max-height: calc(100vh - 150px) !important;
  margin-left: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: -8px 0 35px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.coord-step-tab {
  transition: all 0.2s ease;
  user-select: none;
  border-radius: 0;
}
.coord-step-tab:hover {
  background: rgba(139, 92, 246, 0.08) !important;
  color: #c4b5fd !important;
}
.coord-step-tab.active {
  color: #8b5cf6 !important;
  border-bottom-color: #8b5cf6 !important;
}
.coord-step-panel {
  animation: fadeIn 0.2s ease-out;
}
.coord-gcp-row {
  transition: border-color 0.2s ease, background-color 0.2s ease;
}
.coord-gcp-row:hover {
  border-color: rgba(255, 255, 255, 0.3) !important;
}
#bimCoordInspectorHUD {
  animation: fadeIn 0.2s ease-out;
}

/* Coordinate Wizard input formatting & spinner suppression */
.coord-wizard-card input[type=number]::-webkit-inner-spin-button,
.coord-wizard-card input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.coord-wizard-card input[type=number] {
  -moz-appearance: textfield;
}
.coord-wizard-card .form-input,
.coord-step-panel input[type=number] {
  width: 72px;
  min-width: 68px;
  padding: 2px 6px;
  box-sizing: border-box;
  text-align: right;
}

/* Site Scan Dynamic Loading Progress Animations */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes scan-stripes-move {
  0% { background-position: 24px 0; }
  100% { background-position: 0 0; }
}

.scan-progress-bar-animated {
  background-image: linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.22) 25%,
    transparent 25%,
    transparent 50%,
    rgba(255, 255, 255, 0.22) 50%,
    rgba(255, 255, 255, 0.22) 75%,
    transparent 75%,
    transparent
  ) !important;
  background-size: 24px 24px !important;
  animation: scan-stripes-move 0.8s linear infinite !important;
}

/* Site 3D Scan Mode Tabs styling & Cutout Mask Controls */
#btnTabAlignScan.active,
body[data-theme="light"] #btnTabAlignScan.active {
  background: #38bdf8 !important;
  color: #ffffff !important;
  border-color: #38bdf8 !important;
  box-shadow: 0 1px 3px rgba(56, 189, 248, 0.4) !important;
}

#btnTabAlignBim.active,
body[data-theme="light"] #btnTabAlignBim.active {
  background: #10b981 !important;
  color: #ffffff !important;
  border-color: #10b981 !important;
  box-shadow: 0 1px 3px rgba(16, 185, 129, 0.4) !important;
}

#btnTabAlignMaps.active,
body[data-theme="light"] #btnTabAlignMaps.active {
  background: #4285f4 !important;
  color: #ffffff !important;
  border-color: #4285f4 !important;
  box-shadow: 0 1px 3px rgba(66, 133, 244, 0.4) !important;
}

#siteScanPanelBody #btnTabAlignScan:not(.active),
#siteScanPanelBody #btnTabAlignBim:not(.active),
#siteScanPanelBody #btnTabAlignMaps:not(.active),
body[data-theme="light"] #siteScanPanelBody #btnTabAlignScan:not(.active),
body[data-theme="light"] #siteScanPanelBody #btnTabAlignBim:not(.active),
body[data-theme="light"] #siteScanPanelBody #btnTabAlignMaps:not(.active) {
  background: transparent !important;
  color: var(--text-secondary) !important;
  border: none !important;
  box-shadow: none !important;
}

#siteScanOverlayPanel {
  flex-direction: column !important;
}

#cutoutSectionCard #btnSaveCutoutMask,
body[data-theme="light"] #cutoutSectionCard #btnSaveCutoutMask {
  background: #f59e0b !important;
  color: #1e1e2e !important;
  border: none !important;
  font-weight: 700 !important;
}

#cutoutSectionCard #btnDrawCutoutPoly:not(.drawing-active),
body[data-theme="light"] #cutoutSectionCard #btnDrawCutoutPoly:not(.drawing-active) {
  background: rgba(245, 158, 11, 0.25) !important;
  border: 1px solid #f59e0b !important;
  color: #d97706 !important;
}

body[data-theme="dark"] #cutoutSectionCard #btnDrawCutoutPoly:not(.drawing-active) {
  color: #fbbf24 !important;
}

#cutoutSectionCard #btnDrawCutoutPoly.drawing-active,
body[data-theme="light"] #cutoutSectionCard #btnDrawCutoutPoly.drawing-active,
body[data-theme="dark"] #cutoutSectionCard #btnDrawCutoutPoly.drawing-active {
  background: #ef4444 !important;
  border-color: #dc2626 !important;
  color: #ffffff !important;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.6) !important;
}

/* Light Theme High Contrast for Map Mask Card */
body[data-theme="light"] #cutoutSectionCard {
  background: rgba(245, 158, 11, 0.12) !important;
  border: 1px solid rgba(217, 119, 6, 0.5) !important;
}

body[data-theme="light"] #cutoutSectionCard [data-i18n="lbl3DTilesCutout"] {
  color: #b45309 !important;
}

body[data-theme="light"] #cutoutSectionCard #numCutoutMinY,
body[data-theme="light"] #cutoutSectionCard #numCutoutMaxY {
  color: #b45309 !important;
  font-weight: 700 !important;
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
}

body[data-theme="light"] #cutoutSectionCard #badgeCutoutPolyCount {
  color: #b45309 !important;
}

/* Light Theme High Contrast for 3D Photorealistic Tiles & Street View Toolbar */
body[data-theme="light"] #siteScanOverlayPanel [data-i18n="lbl3DTilesTitle"] {
  color: #6d28d9 !important;
}

body[data-theme="light"] #siteScanOverlayPanel [data-i18n="lbl3DTilesPrimaryBadge"] {
  background: rgba(109, 40, 217, 0.12) !important;
  color: #6d28d9 !important;
}

body[data-theme="light"] #siteScanOverlayPanel #btnToggleGoogle3DTiles,
body[data-theme="light"] #btnToggleGoogle3DTiles,
body.theme-light #siteScanOverlayPanel #btnToggleGoogle3DTiles,
body.theme-light #btnToggleGoogle3DTiles {
  background: rgba(109, 40, 217, 0.1) !important;
  border-color: #7c3aed !important;
  color: #6d28d9 !important;
  transition: none !important;
}

body[data-theme="light"] #btnBIMStreetView {
  color: #6d28d9 !important;
  border-color: rgba(109, 40, 217, 0.4) !important;
  background: rgba(109, 40, 217, 0.1) !important;
}

/* ==========================================================================
   Autodesk Viewer Style Measurement Toolbar & Constant-Size Overlay Badges
   ========================================================================== */
.gc-reticle-cursor,
.gc-reticle-cursor canvas,
.gc-reticle-cursor * {
  cursor: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48Y2lyY2xlIGN4PSIxMiIgY3k9IjEyIiByPSI2IiBmaWxsPSJub25lIiBzdHJva2U9IiMwMGU1ZmYiIHN0cm9rZS13aWR0aD0iMS41Ii8+PGNpcmNsZSBjeD0iMTIiIGN5PSIxMiIgcj0iMS41IiBmaWxsPSIjMDBlNWZmIi8+PGxpbmUgeDE9IjEyIiB5MT0iMSIgeDI9IjEyIiB5Mj0iNCIgc3Ryb2tlPSIjMDBlNWZmIiBzdHJva2Utd2lkdGg9IjEuNSIvPjxsaW5lIHgxPSIxMiIgeTE9IjIwIiB4Mj0iMTIiIHkyPSIyMyIgc3Ryb2tlPSIjMDBlNWZmIiBzdHJva2Utd2lkdGg9IjEuNSIvPjxsaW5lIHgxPSIxIiB5MT0iMTIiIHgyPSI0IiB5Mj0iMTIiIHN0cm9rZT0iIzAwZTVmZiIgc3Ryb2tlLXdpZHRoPSIxLjUiLz48bGluZSB4MT0iMjAiIHkxPSIxMiIgeDI9IjIzIiB5Mj0iMTIiIHN0cm9rZT0iIzAwZTVmZiIgc3Ryb2tlLXdpZHRoPSIxLjUiLz48L3N2Zz4=") 12 12, crosshair !important;
}

.autodesk-measure-toolbar {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  background: #ffffff !important;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 6px 12px;
  border-radius: 28px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(0, 0, 0, 0.08);
  z-index: 100;
  user-select: none;
}

body[data-theme="light"] .autodesk-measure-toolbar {
  background: #ffffff !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.16), 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.autodesk-measure-subtools {
  display: flex;
  align-items: center;
  gap: 4px;
}

.autodesk-measure-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1.5px solid transparent;
  border-radius: 22px;
  padding: 5px 12px;
  min-width: 56px;
  cursor: pointer;
  color: #475569 !important;
  transition: all 0.15s ease;
}

body[data-theme="light"] .autodesk-measure-btn {
  color: #475569 !important;
}

.autodesk-measure-btn:hover {
  background: rgba(0, 0, 0, 0.04) !important;
  color: #1e293b !important;
}

body[data-theme="light"] .autodesk-measure-btn:hover {
  background: rgba(0, 0, 0, 0.05) !important;
}

.autodesk-measure-btn.active {
  border: 1.5px solid #d0d5dd !important;
  background: #ffffff !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12) !important;
  color: #0084ff !important;
}

.autodesk-measure-btn.active svg {
  stroke: #0084ff !important;
  color: #0084ff !important;
}

.autodesk-measure-btn svg {
  stroke: currentColor;
  color: currentColor;
}

.autodesk-measure-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 22px;
}

.autodesk-measure-label {
  font-size: 11px;
  font-weight: 500;
  margin-top: 2px;
  white-space: nowrap;
}

.autodesk-measure-divider {
  width: 1px;
  height: 24px;
  background: rgba(0, 0, 0, 0.12) !important;
  margin: 0 6px;
}

body[data-theme="light"] .autodesk-measure-divider {
  background: rgba(0, 0, 0, 0.12) !important;
}

.autodesk-measure-clear-btn {
  border: 1px solid #d0d5dd !important;
  background: #ffffff !important;
  color: #64748b !important;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

body[data-theme="light"] .autodesk-measure-clear-btn {
  border-color: #cbd5e1 !important;
  background: #ffffff !important;
  color: #475569 !important;
}

.autodesk-measure-clear-btn:hover {
  border-color: #94a3b8 !important;
  color: #0f172a !important;
  background: #f8fafc !important;
}

body[data-theme="light"] .autodesk-measure-clear-btn:hover {
  color: #0f172a !important;
}

.autodesk-measure-close-btn {
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 14px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.autodesk-measure-close-btn:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

/* Autodesk Measurement Badges (CONSTANT screen size with zooming) */
.autodesk-dist-badge {
  position: absolute;
  pointer-events: none !important;
  z-index: 50;
  background: #0084ff;
  color: #ffffff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 132, 255, 0.45);
  white-space: nowrap;
  user-select: none;
  transform: translate(-50%, -50%);
}

/* Delta Badges (X, Y, Z) - Cleanly offset to never overlap main badge */
.autodesk-delta-badge {
  position: absolute;
  pointer-events: none !important;
  z-index: 50;
  display: flex;
  align-items: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  border-radius: 10px;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  user-select: none;
}

.autodesk-delta-badge.delta-x,
.autodesk-delta-badge.delta-y,
.autodesk-delta-badge.delta-z {
  transform: translate(-50%, -50%);
}

.autodesk-delta-axis {
  padding: 2px 6px;
  color: #ffffff;
  font-weight: 700;
}
.autodesk-delta-axis.axis-x { background: #ef4444; }
.autodesk-delta-axis.axis-y { background: #10b981; }
.autodesk-delta-axis.axis-z { background: #3b82f6; }

.autodesk-delta-val {
  background: #ffffff;
  color: #0099ff;
  padding: 2px 8px;
}

/* Coordinates Badge */
.autodesk-coord-badge {
  position: absolute;
  pointer-events: none !important;
  z-index: 50;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
  padding: 8px 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #0099ff;
  line-height: 1.5;
  white-space: nowrap;
  user-select: none;
  transform: translate(-50%, calc(-100% - 14px));
}

.autodesk-coord-badge .coord-line {
  color: #0099ff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
}

.autodesk-coord-badge .coord-twd {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  font-size: 11px;
  color: #64748b;
  font-weight: 500;
}

.autodesk-coord-badge .coord-gl {
  margin-top: 2px;
  font-size: 11px;
  color: #0284c7;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
}

body[data-theme="dark"] .autodesk-coord-badge .coord-gl {
  color: #38bdf8;
}

#btnToggleScanMaskInvert,
#btnToggleCutoutInvert {
  transition: all 0.2s ease;
  user-select: none;
}

#btnToggleScanMaskInvert:hover {
  filter: brightness(1.15);
}

#btnToggleCutoutInvert:hover {
  filter: brightness(1.15);
}

body[data-theme="light"] .autodesk-coord-badge {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
  color: #0099ff;
}

/* Angle Badge */
.autodesk-angle-badge {
  position: absolute;
  pointer-events: none !important;
  z-index: 50;
  background: #0084ff;
  color: #ffffff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 132, 255, 0.45);
  white-space: nowrap;
  user-select: none;
  transform: translate(-50%, -50%);
}

/* Area Badge */
.autodesk-area-badge {
  position: absolute;
  pointer-events: none !important;
  z-index: 50;
  background: rgba(15, 23, 42, 0.94);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.5);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  padding: 6px 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  user-select: none;
  transform: translate(-50%, -50%);
}

body[data-theme="light"] .autodesk-area-badge {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(0, 132, 255, 0.4);
  color: #0084ff;
}

/* Laser Badges */
.autodesk-laser-badge {
  position: absolute;
  pointer-events: none !important;
  z-index: 50;
  background: #ffffff;
  color: #0084ff;
  border: 1px solid rgba(0, 132, 255, 0.35);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  white-space: nowrap;
  user-select: none;
  transform: translate(-50%, -50%);
}

body[data-theme="light"] .autodesk-laser-badge {
  background: #ffffff;
  color: #0084ff;
  border-color: rgba(0, 132, 255, 0.4);
}

/* Autodesk Precision Snap Reticle (Orange Square [ ] or Cyan/Emerald Snapped) */
#bimSnapReticle,
.autodesk-snap-reticle {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 2px;
  border: 2px solid #ff7a00;
  background: rgba(255, 122, 0, 0.12);
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.4);
  box-sizing: border-box;
  transform: translate(-50%, -50%);
  pointer-events: none !important;
  z-index: 55;
  display: none;
  transition: width 0.08s ease, height 0.08s ease, border-color 0.08s ease, background 0.08s ease;
}
.autodesk-snap-reticle.static-reticle {
  display: block !important;
}
.autodesk-snap-reticle::after {
  display: none !important;
}

/* Snapped state: vibrant Autodesk cyan/emerald with center dot */
.autodesk-snap-reticle.snapped {
  border-color: #00f0ff !important;
  background: rgba(0, 240, 255, 0.22) !important;
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.8), 0 0 2px #fff !important;
  width: 16px;
  height: 16px;
}
.autodesk-snap-reticle.snapped::after {
  content: '';
  display: block !important;
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 4px;
  background: #00f0ff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 4px #00f0ff;
}

/* Snapped to Marker: Emerald Green */
.autodesk-snap-reticle.snapped.snap-marker {
  border-color: #10b981 !important;
  background: rgba(16, 185, 129, 0.25) !important;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.8), 0 0 2px #fff !important;
}
.autodesk-snap-reticle.snapped.snap-marker::after {
  background: #10b981 !important;
  box-shadow: 0 0 4px #10b981 !important;
}

/* Snapped to Placed Measurement Point: Sky Blue */
.autodesk-snap-reticle.snapped.snap-measurement {
  border-color: #38bdf8 !important;
  background: rgba(56, 189, 248, 0.25) !important;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.8), 0 0 2px #fff !important;
}
.autodesk-snap-reticle.snapped.snap-measurement::after {
  background: #38bdf8 !important;
  box-shadow: 0 0 4px #38bdf8 !important;
}

/* Snapped to Element Vertex / Intersection: Cyan */
.autodesk-snap-reticle.snapped.snap-vertex,
.autodesk-snap-reticle.snapped.snap-intersection {
  border-color: #00f0ff !important;
}

/* Snapped to Edge / Midpoint: Amber / Gold */
.autodesk-snap-reticle.snapped.snap-edge,
.autodesk-snap-reticle.snapped.snap-midpoint {
  border-color: #f59e0b !important;
  background: rgba(245, 158, 11, 0.22) !important;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.8), 0 0 2px #fff !important;
}
.autodesk-snap-reticle.snapped.snap-edge::after,
.autodesk-snap-reticle.snapped.snap-midpoint::after {
  background: #f59e0b !important;
  box-shadow: 0 0 4px #f59e0b !important;
}

/* Snap Guide Tooltip floating beside the reticle */
.autodesk-snap-tooltip {
  position: absolute;
  left: 20px;
  top: -6px;
  background: rgba(15, 23, 42, 0.9);
  color: #f8fafc;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  letter-spacing: 0.3px;
}

/* Mask Drawing Vertex Badge */
.autodesk-mask-vertex-badge {
  position: absolute;
  pointer-events: none !important;
  z-index: 52;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #10b981;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  border: 1.5px solid #ffffff;
  transform: translate(-50%, -50%);
  user-select: none;
}
.autodesk-mask-vertex-badge.vertex-cutout {
  background: #f59e0b;
}
.autodesk-mask-vertex-badge.vertex-first {
  background: #ef4444;
}

/* Popover Panel */
.autodesk-measure-popover {
  position: absolute;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  width: 260px;
  background: rgba(30, 41, 59, 0.98);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  z-index: 105;
  padding: 12px 14px;
  font-size: 11.5px;
  color: #f8fafc;
}

body[data-theme="light"] .autodesk-measure-popover {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(0, 0, 0, 0.1);
  color: var(--text-primary);
}

.autodesk-measure-popover-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 6px;
  margin-bottom: 10px;
}

.autodesk-measure-popover-close {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 0 4px;
}
.autodesk-measure-popover-close:hover {
  color: #ef4444;
}

.autodesk-measure-field {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.autodesk-measure-field label {
  color: var(--text-secondary);
  font-weight: 500;
}

.autodesk-measure-field select {
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 11px;
}

.autodesk-measure-field-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  cursor: pointer;
}

.autodesk-measure-field-checkbox label {
  cursor: pointer;
  color: var(--text-secondary);
}

@media (max-width: 768px) {
  .autodesk-measure-toolbar {
    bottom: 84px !important;
    max-width: 95vw !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 3px 6px !important;
    gap: 3px !important;
  }
  .autodesk-measure-toolbar::-webkit-scrollbar {
    display: none;
  }
  .autodesk-measure-btn {
    min-width: 44px !important;
    padding: 2px 4px !important;
  }
  .autodesk-measure-label {
    font-size: 9px !important;
  }
  .autodesk-measure-popover {
    bottom: 140px !important;
    max-width: 90vw !important;
  }
}


