/* Sites Notes — compact cell + floating tooltip + click modal.
   Must not expand table cells or sit on Week/Crew. */

.stm-notes-col,
td.stm-notes-col {
  max-width: none !important;
  width: auto !important;
  min-width: 10rem !important;
  overflow: hidden !important;
  vertical-align: middle !important;
  white-space: nowrap !important;
}

.stm-notes-cluster {
  display: flex;
  align-items: stretch;
  width: 100%;
  min-width: 0;
  height: 1.85rem;
  border: 1px solid #d8e0ea;
  border-radius: 999px;
  overflow: hidden;
  background: var(--gce-canvas, #eeeae3);
  box-sizing: border-box;
}

.stm-notes-cell,
button.stm-notes-cell {
  display: flex !important;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  width: auto;
  max-width: none;
  min-width: 0;
  height: 100%;
  margin: 0;
  padding: 0 0.65rem;
  border: 0;
  background: transparent !important;
  box-shadow: none !important;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  line-height: 1.3;
  overflow: hidden;
}

.stm-notes-add {
  flex: 0 0 1.85rem;
  width: 1.85rem;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-left: 1px solid #d8e0ea;
  background: #1e3a8a;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.stm-notes-text {
  display: block !important;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
}

.stm-notes-cell--empty .stm-notes-text {
  color: #94a3b8;
}

.stm-notes-count {
  flex: 0 0 auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1e3a8a;
  font-size: 10px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.stm-notes-top,
.stm-notes-comments,
.stm-notes-open-hint,
.stm-notes-empty-label {
  display: none !important;
}

/* Hover tooltip — viewport overlay, never in-flow in the row */
#stm-notes-hover-card,
.stm-notes-hover-card {
  display: none;
  position: fixed !important;
  z-index: 2147483003 !important;
  width: min(380px, calc(100vw - 24px));
  max-height: min(380px, 50vh);
  overflow: hidden;
  flex-direction: column;
  color: #0f172a;
  border-radius: 1.15rem;
  padding: 0;
  pointer-events: none;
  background: var(--gce-glass-panel, rgba(255, 251, 246, 0.92)) !important;
  border: 1px solid var(--gce-glass-edge, rgba(90, 86, 78, 0.22)) !important;
  box-shadow: var(--gce-glass-shine, inset 0 1px 0 rgba(255,252,247,.9)), 0 22px 48px rgba(40, 36, 30, 0.18) !important;
  backdrop-filter: blur(var(--gce-glass-blur, 28px)) saturate(var(--gce-glass-sat, 1.35));
  -webkit-backdrop-filter: blur(var(--gce-glass-blur, 28px)) saturate(var(--gce-glass-sat, 1.35));
}
#stm-notes-hover-card.is-open,
.stm-notes-hover-card.is-open {
  display: flex !important;
}

.stm-notes-hover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--gce-glass-line, rgba(90, 86, 78, 0.18));
  flex: 0 0 auto;
}
.stm-notes-hover-head strong {
  font-size: 0.8125rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.01em;
}
.stm-notes-hover-site { font-weight: 800; color: #1e3a8a; }
.stm-notes-hover-count {
  font-size: 0.6875rem;
  font-weight: 800;
  color: #1e3a8a;
  background: #dbeafe;
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
}
.stm-notes-hover-feed {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 8px 12px 10px;
  pointer-events: auto;
}
.stm-notes-hover-item { display: flex; gap: 10px; padding: 9px 4px; border-bottom: 1px solid rgba(90, 86, 78, 0.1); }
.stm-notes-hover-item:last-child { border-bottom: 0; }
.stm-notes-hover-dot {
  width: 8px; height: 8px; margin-top: 7px; border-radius: 999px;
  background: #93c5fd; flex: 0 0 auto;
}
.stm-notes-hover-item--blocker .stm-notes-hover-dot { background: #fca5a5; }
.stm-notes-hover-item--info .stm-notes-hover-dot { background: #86efac; }
.stm-notes-hover-body { min-width: 0; flex: 1; }
.stm-notes-hover-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
.stm-notes-hover-line b { font-size: 0.75rem; font-weight: 800; color: #0f172a; }
.stm-notes-hover-when { font-size: 0.6875rem; font-weight: 600; color: #64748b; margin-left: auto; }
.stm-notes-hover-body p {
  margin: 0; font-size: 0.8125rem; line-height: 1.5; color: #334155;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.stm-notes-hover-empty { padding: 16px 8px; font-size: 0.8125rem; color: #64748b; text-align: center; }
.stm-notes-hover-foot {
  flex: 0 0 auto;
  padding: 8px 14px 10px;
  border-top: 1px solid var(--gce-glass-line, rgba(90, 86, 78, 0.18));
  font-size: 0.6875rem;
  font-weight: 700;
  color: #64748b;
}

.stm-notes-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  background: #dbeafe;
  color: #1e3a8a;
  border: 1px solid transparent;
}
button.stm-notes-tag {
  font: inherit;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
  margin: 0;
  line-height: 1.3;
}
.stm-notes-tag--update { background: #dbeafe; color: #1e3a8a; border-color: #93c5fd; }
.stm-notes-tag--info { background: #dcfce7; color: #166534; border-color: #86efac; }
.stm-notes-tag--blocker { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.stm-notes-tag--pending {
  background: #fef3c7;
  color: #a16207;
  border-color: #fcd34d;
}
.stm-notes-tag--approved {
  background: #dcfce7;
  color: #166534;
  border-color: #86efac;
}
.stm-notes-tag--pending:not(.is-active),
.stm-notes-tag--approved:not(.is-active) {
  background: rgba(255, 252, 247, 0.7);
  color: #64748b;
  border-color: #d8e0ea;
}
.stm-notes-review,
.stm-notes-item-review {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.stm-notes-pop-tools .stm-notes-item-review {
  margin-right: auto;
}
.sdt-sn-actions .stm-notes-item-review {
  margin-right: 0.35rem;
}

/* Click editor — centered glass modal, never pinned to the Notes cell */
#stm-notes-popover-backdrop,
.stm-notes-popover-backdrop {
  display: none;
  position: fixed !important;
  inset: 0;
  z-index: 2147483004 !important;
  background: rgba(28, 25, 22, 0.42);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
#stm-notes-popover-backdrop.is-open,
.stm-notes-popover-backdrop.is-open {
  display: block !important;
}

#stm-notes-popover,
.stm-notes-popover {
  position: fixed !important;
  z-index: 2147483005 !important;
  left: 50% !important;
  top: 50% !important;
  transform: translate(-50%, -50%);
  width: min(480px, calc(100vw - 32px)) !important;
  max-height: min(78vh, 620px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: #0f172a;
  border-radius: 1.25rem;
  background: var(--gce-glass-panel, rgba(255, 251, 246, 0.94)) !important;
  border: 1px solid var(--gce-glass-edge, rgba(90, 86, 78, 0.22)) !important;
  box-shadow:
    var(--gce-glass-shine, inset 0 1px 0 rgba(255,252,247,.9)),
    0 28px 64px rgba(40, 36, 30, 0.22) !important;
  backdrop-filter: blur(var(--gce-glass-blur, 32px)) saturate(var(--gce-glass-sat, 1.4));
  -webkit-backdrop-filter: blur(var(--gce-glass-blur, 32px)) saturate(var(--gce-glass-sat, 1.4));
}
.stm-notes-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--gce-glass-line, rgba(90, 86, 78, 0.16));
  flex: 0 0 auto;
}
.stm-notes-pop-title {
  min-width: 0;
  flex: 1 1 auto;
}
.stm-notes-pop-kicker {
  display: block;
  margin: 0 0 0.2rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
}
.stm-notes-popover-head h3 {
  margin: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem 0.55rem;
  font-size: 0.9375rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #0f172a;
}
.stm-notes-pop-site {
  color: #1e3a8a;
  background: #dbeafe;
  border: 1px solid #93c5fd;
  border-radius: 999px;
  padding: 0.12rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 800;
}
.stm-notes-pop-count {
  font-size: 0.6875rem;
  font-weight: 800;
  color: #475569;
  background: rgba(255, 252, 247, 0.7);
  border: 1px solid var(--gce-glass-line, #d8e0ea);
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
}
.stm-notes-popover-close {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--gce-glass-line, #d8e0ea);
  border-radius: 999px;
  background: rgba(255, 252, 247, 0.72);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  color: #475569;
}
.stm-notes-popover-close:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}
.stm-notes-popover-timeline {
  flex: 1 1 auto;
  min-height: 8rem;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 14px 8px;
}
.stm-notes-pop-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.35rem;
  min-height: 9rem;
  padding: 1.25rem 0.75rem;
  color: #475569;
}
.stm-notes-pop-empty-mark {
  width: 2.5rem;
  height: 2.5rem;
  margin-bottom: 0.35rem;
  border-radius: 999px;
  background: #dbeafe;
  border: 1px solid #93c5fd;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7);
}
.stm-notes-pop-empty strong {
  font-size: 0.9rem;
  font-weight: 800;
  color: #0f172a;
}
.stm-notes-pop-empty p {
  margin: 0;
  max-width: 16rem;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: #64748b;
}
.stm-notes-pop-item {
  display: flex;
  gap: 0.7rem;
  padding: 0.75rem 0.65rem;
  margin-bottom: 0.45rem;
  border-radius: 0.9rem;
  background: rgba(255, 252, 247, 0.55);
  border: 1px solid rgba(90, 86, 78, 0.12);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.65);
}
.stm-notes-pop-item:last-child { margin-bottom: 0; }
.stm-notes-pop-item--issue {
  background: rgba(254, 226, 226, 0.45);
  border-color: #fca5a5;
}
.stm-notes-pop-item--complete {
  background: rgba(220, 252, 231, 0.4);
  border-color: #86efac;
}
.stm-notes-pop-avatar {
  flex: 0 0 auto;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.625rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #1e3a8a;
  background: #dbeafe;
  border: 1px solid #93c5fd;
}
.stm-notes-pop-body { min-width: 0; flex: 1; }
.stm-notes-pop-line {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.28rem;
}
.stm-notes-pop-line b {
  font-size: 0.75rem;
  font-weight: 800;
  color: #0f172a;
}
.stm-notes-pop-when {
  font-size: 0.6875rem;
  font-weight: 600;
  color: #64748b;
  margin-left: auto;
}
.stm-notes-pop-body p {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: #0f172a;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.stm-notes-pop-tools {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.45rem;
}
.stm-notes-pop-tool {
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 0.6875rem;
  font-weight: 800;
  color: #1e3a8a;
  cursor: pointer;
}
.stm-notes-pop-tool:hover { text-decoration: underline; }
.stm-notes-pop-tool--danger { color: #991b1b; }
.stm-notes-popover-compose {
  flex: 0 0 auto;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--gce-glass-line, rgba(90, 86, 78, 0.16));
  background: rgba(245, 240, 232, 0.38);
}
.stm-notes-pop-input,
#stm-notes-pop-input {
  width: 100%;
  box-sizing: border-box;
  min-height: 4.5rem;
  max-height: 10rem;
  resize: vertical;
  border: 1px solid var(--gce-glass-line, #d8e0ea);
  border-radius: 0.85rem;
  padding: 0.7rem 0.85rem;
  font: inherit;
  font-size: 0.875rem;
  line-height: 1.45;
  color: #0f172a;
  background: rgba(255, 252, 247, 0.88);
}
.stm-notes-pop-input:focus,
#stm-notes-pop-input:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(147, 197, 253, 0.35);
}
.stm-notes-popover-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.sdt-sn-composer .stm-notes-pop-review {
  grid-column: 2 / -1;
  justify-self: start;
}
.stm-notes-pop-types {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  padding: 2px;
  border-radius: 999px;
  background: rgba(255, 252, 247, 0.7);
  border: 1px solid var(--gce-glass-line, #d8e0ea);
}
.stm-notes-pop-type-btn,
.stm-notes-pop-review-btn {
  border: 0;
  background: transparent;
  color: #475569;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 800;
  cursor: pointer;
}
.stm-notes-pop-type-btn.is-active {
  background: #1e3a8a;
  color: #fff;
}
.stm-notes-pop-review-btn.is-active[data-review="pending"] {
  background: #fef3c7;
  color: #a16207;
  box-shadow: inset 0 0 0 1px #fcd34d;
}
.stm-notes-pop-review-btn.is-active[data-review="approved"] {
  background: #dcfce7;
  color: #166534;
  box-shadow: inset 0 0 0 1px #86efac;
}
.stm-notes-pop-attach,
.stm-notes-pop-type {
  border: 1px solid var(--gce-glass-line, #d8e0ea);
  background: rgba(255, 252, 247, 0.85);
  color: #0f172a;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.stm-notes-pop-post {
  margin-left: auto;
  background: #1e3a8a;
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18);
}
.stm-notes-pop-post:hover { filter: brightness(1.08); }
.stm-notes-pop-post:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

html[data-gce-mode="dark"] #stm-notes-popover,
html[data-gce-mode="dark"] .stm-notes-popover,
html[data-gce-mode="dark"] #stm-notes-hover-card {
  color: #e2e8f0;
}
html[data-gce-mode="dark"] .stm-notes-popover-head h3,
html[data-gce-mode="dark"] .stm-notes-pop-empty strong,
html[data-gce-mode="dark"] .stm-notes-pop-line b,
html[data-gce-mode="dark"] .stm-notes-pop-body p,
html[data-gce-mode="dark"] .stm-notes-hover-head strong,
html[data-gce-mode="dark"] .stm-notes-hover-line b {
  color: #f1f5f9;
}
html[data-gce-mode="dark"] .stm-notes-pop-item {
  background: rgba(30, 41, 59, 0.45);
  border-color: rgba(148, 163, 184, 0.22);
}
html[data-gce-mode="dark"] .stm-notes-pop-input,
html[data-gce-mode="dark"] #stm-notes-pop-input {
  background: rgba(15, 23, 42, 0.55);
  color: #f1f5f9;
  border-color: rgba(148, 163, 184, 0.28);
}

tr.stm-row--notes-open td.stm-notes-col {
  overflow: hidden !important;
  position: static !important;
}

html.gce-lights-off #stm-notes-hover-card,
html.gce-lights-off #stm-notes-popover,
html.gce-lights-off #sdt-wf-notes-modal {
  position: fixed !important;
}

/* Site Preparation Workflow — reuse Sites notes modal, not a cell popover */
#sdt-wf-notes-modal-backdrop.stm-notes-popover-backdrop.is-open {
  display: block !important;
}
#sdt-wf-notes-modal.sdt-wf-notes-modal {
  width: min(560px, calc(100vw - 32px)) !important;
  max-height: min(80vh, 640px);
}
#sdt-wf-notes-modal .stm-notes-popover-compose {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
}
#sdt-wf-notes-modal .sdt-wf-notes-modal-input,
#sdt-wf-notes-modal-input {
  flex: 1 1 auto;
  min-height: 240px;
  height: min(42vh, 320px);
  resize: vertical;
  font-size: 14px;
  line-height: 1.5;
}
#sdt-wf-notes-modal .sdt-wf-notes-modal-hint {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
}
#sdt-wf-notes-modal .stm-notes-pop-post.is-synced {
  background: #166534;
}
#sdt-wf-notes-modal .stm-notes-pop-post.is-saving {
  background: #1e3a8a;
  opacity: 0.85;
}
#sdt-wf-notes-modal .stm-notes-pop-post.is-error {
  background: #991b1b;
}
