:root {
  --bg: #0f1117;
  --surface: #181b24;
  --surface-2: #1f2430;
  --border: #2a3142;
  --text: #e8ecf4;
  --muted: #8b95a8;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.15);
  --success: #3ecf8e;
  --warn: #f0b429;
  --danger: #f07178;
  --radius: 12px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --font: "DM Sans", system-ui, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  scrollbar-color: #3d4659 var(--surface-2);
  scrollbar-width: thin;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: var(--surface-2);
}

*::-webkit-scrollbar-thumb {
  background: #3d4659;
  border: 2px solid var(--surface-2);
  border-radius: 6px;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

*::-webkit-scrollbar-corner {
  background: var(--surface-2);
}

.hidden {
  display: none !important;
}

/* Login */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(79, 140, 255, 0.25), transparent),
    var(--bg);
  position: relative;
  overflow: hidden;
}

.login-watermark {
  position: absolute;
  left: 50%;
  top: 45%;
  transform: translate(-50%, -50%);
  width: 1040px;
  max-width: 85vw;
  height: auto;
  opacity: 0.07;
  z-index: 0;
  pointer-events: none;
  user-select: none;
  filter: grayscale(0.2);
}

.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  padding: 2rem;
  box-shadow: var(--shadow);
}

.login-title {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
  font-weight: 600;
}

.login-sub {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.login-card label {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

.login-card input {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}

.login-card input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.login-card input[readonly] {
  background: var(--surface);
  color: var(--muted);
  border-style: dashed;
  cursor: default;
  opacity: 0.85;
}

.login-loading {
  margin-top: 0.5rem;
  color: var(--accent);
  font-size: 0.85rem;
  text-align: center;
}

.error-text {
  color: var(--danger);
  font-size: 0.85rem;
  margin: 0 0 1rem;
}

/* Buttons */
.btn {
  font: inherit;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  text-decoration: none;
  display: inline-block;
  box-sizing: border-box;
  line-height: 1.25;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--muted);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  color: var(--text);
}

.btn-block {
  width: 100%;
}

/* Hero (landing-style header) */
.hero {
  position: relative;
  border-bottom: 1px solid var(--border);
  background:
    linear-gradient(135deg, rgba(79, 140, 255, 0.08) 0%, transparent 50%),
    var(--surface);
}

.hero-sign-out {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  z-index: 3;
}

.event-log-btn {
  position: absolute;
  top: 1rem;
  right: 6.75rem;
  z-index: 3;
}

.app-version {
  margin-left: 0.6rem;
  font-size: 0.72rem;
  color: var(--muted);
  opacity: 0.65;
  vertical-align: middle;
  user-select: none;
  pointer-events: none;
}

.hero-inner {
  max-width: 1820px;
  margin: 0 auto;
  padding: 2rem 1rem 1.6rem;
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
}

.hero-logo-wrap {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  padding: 0;
  line-height: 0;
  pointer-events: none;
}

.hero-copy {
  flex: 0 1 auto;
  min-width: 0;
  white-space: nowrap;
}

.eyebrow {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
}

.hero-logo {
  display: block;
  flex-shrink: 0;
  width: 84px;
  height: auto;
  margin: 0;
  padding: 0;
  object-fit: contain;
}

.hero-title {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  font-weight: 400;
  line-height: 1.1;
  white-space: nowrap;
}

.hero-title em {
  font-style: italic;
  color: var(--accent);
}

.hero-desc {
  margin: 0.75rem 0 0;
  max-width: none;
  color: var(--muted);
  white-space: nowrap;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  white-space: nowrap;
}

.btn-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-icon-only {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.55rem;
  min-width: 2.25rem;
  min-height: 2.25rem;
}

.btn-inline-icon {
  display: block;
  flex-shrink: 0;
}

/* Refresh button spin animation during CRM data load */
.refresh-btn-loading .btn-inline-icon {
  animation: crm-refresh-spin 0.8s linear infinite;
}

@keyframes crm-refresh-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.field-required {
  font-weight: 500;
  color: var(--muted);
  font-size: 0.85em;
}

.hero-actions .btn-primary.btn-icon-only {
  color: #fff;
}

#quick-note-opportunity-selected .contact-clear {
  cursor: pointer;
  text-decoration: underline;
  margin-left: 0.35rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.global-opp-search {
  position: relative;
  flex-shrink: 0;
}

.global-opp-search-input {
  width: min(220px, 28vw);
  padding: 0.45rem 0.65rem;
  font: inherit;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
}

.global-opp-search-input::placeholder {
  color: var(--muted);
}

.global-opp-search-input:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.global-opp-search-results {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  right: 0;
  min-width: max(100%, 320px);
  width: max(320px, 100%);
  max-height: min(70vh, 420px);
  overflow-x: hidden;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.global-opp-search-item {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  padding: 0.45rem 0.5rem 0.45rem 0.65rem;
  border-bottom: 1px solid var(--border);
}

.global-opp-search-item:last-child {
  border-bottom: none;
}

.global-opp-search-item:hover,
.global-opp-search-item:focus-within {
  background: var(--accent-soft);
}

.global-opp-search-item-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 0.1rem 0;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.82rem;
  line-height: 1.35;
  color: var(--text);
  text-align: left;
  white-space: normal;
  word-break: break-word;
  overflow: visible;
  cursor: pointer;
}

.global-opp-search-item-title:hover,
.global-opp-search-item-title:focus {
  color: var(--accent);
  outline: none;
}

.global-opp-search-open {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.65rem;
  margin-top: 0.05rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
}

.global-opp-search-open:hover,
.global-opp-search-open:focus {
  border-color: var(--border);
  background: var(--surface);
  color: var(--accent);
  outline: none;
}

.crm-open-external svg {
  display: block;
}

.global-opp-search-results .search-empty {
  display: block;
  padding: 0.55rem 0.75rem;
  font-size: 0.78rem;
  color: var(--muted);
}

/* Toolbar */
.toolbar {
  max-width: 1820px;
  margin: 0 auto;
  padding: 1rem 1rem;
}

.toolbar-presets {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}

.presets-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.chip {
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--text);
}

.chip-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
}

.field label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.field input:not([type="checkbox"]):not([type="radio"]),
.field select {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  min-width: 8rem;
}

.field input[type="checkbox"],
.field input[type="radio"] {
  width: 1rem;
  height: 1rem;
  min-width: 1rem;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  border-radius: 0;
  flex-shrink: 0;
}

.field input:focus,
.field select:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.field-narrow input {
  width: 5.5rem;
}

.field-check {
  padding-bottom: 0.35rem;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

.toolbar-meta {
  margin-top: 0.75rem;
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
}

.portal-label {
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  opacity: 0.85;
}

/* Kanban board */
.board {
  max-width: 1820px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  min-height: 420px;
  align-items: flex-start;
}

.column {
  flex: 0 0 280px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 280px);
}

.column-header {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  position: sticky;
  top: 0;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
}

.column-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.column-title {
  font-weight: 600;
  font-size: 0.9rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.column-count {
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--surface-2);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.column-body {
  padding: 0.65rem;
  overflow-y: auto;
  flex: 1;
  min-height: 80px;
}



.card {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 3.6rem 1.65rem 0.75rem;
  margin-bottom: 0.5rem;
  cursor: default;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.card-actions {
  position: absolute;
  top: 0.3rem;
  right: 0.3rem;
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.card-preview-btn,
.card-edit-btn {
  width: 1.65rem;
  height: 1.65rem;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.card-preview-btn .card-action-icon {
  display: block;
}

.card:hover .card-preview-btn,
.card:hover .card-edit-btn,
.card-preview-btn:focus-visible,
.card-edit-btn:focus-visible {
  opacity: 1;
}

.card-preview-btn:hover,
.card-edit-btn:hover {
  background: var(--surface);
  color: var(--text);
}

.card-due {
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  bottom: 0.4rem;
  margin: 0;
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.card-due--overdue {
  color: var(--danger);
  font-weight: 600;
}

.card:hover {
  border-color: var(--muted);
}

.card-title {
  margin: 0 0 0.35rem;
  font-weight: 600;
  font-size: 1rem;
}

.card-meta {
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.card-value {
  color: var(--success);
  font-weight: 600;
}

.card-details {
  margin-top: 0.45rem;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.45;
}

.card-contact {
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.card-description {
  margin: 0 0 0.35rem;
  color: var(--text);
}

.card-detail-line {
  margin: 0.15rem 0 0;
}

.card-detail-label {
  color: var(--muted);
  font-weight: 600;
}

.card-stage-pill {
  display: inline-block;
  margin-top: 0.35rem;
  font-size: 0.7rem;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
}

.card-checklist-warn {
  margin: 0.5rem 0 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--danger);
}

.empty-column {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.board-loading,
.board-error {
  padding: 3rem;
  text-align: center;
  color: var(--muted);
  width: 100%;
}

.board-error {
  color: var(--danger);
}

/* Tile-level loading indicator */
.tile-loading {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.tile-loading-spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--muted);
  border-top-color: transparent;
  border-radius: 50%;
  animation: tile-loading-spin 0.6s linear infinite;
  margin-right: 0.5rem;
  vertical-align: middle;
}
@keyframes tile-loading-spin {
  to { transform: rotate(360deg); }
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  max-width: 360px;
  padding: 0.85rem 1.1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  z-index: 2003;
  animation: slide-in 0.25s ease;
}

.toast.error {
  border-color: var(--danger);
  color: var(--danger);
}

/* Also shift header meta indicators when sidebar is open */
.bookmark-open #mutation-sync-status,
.bookmark-open #crm-crash-banner {
  margin-right: 240px;
}

.toast.warning {
  border-color: #f59e0b;
  color: #1f2937;
  background: #fef3c7;
}

/* Bottom-right CRM sync / action status (for connecting, sent, queued feedback) */
.crm-sync-status {
  position: fixed;
  bottom: 3.5rem;
  right: 1.5rem;
  padding: 0.5rem 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.82rem;
  z-index: 2001;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 320px;
}

.crm-sync-status.warning {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #1f2937;
}

.crm-sync-status .progress {
  width: 50px;
  height: 2px;
  background: #e5e7eb;
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}

.crm-sync-status .progress-bar {
  height: 100%;
  background: #3b82f6;
  animation: crm-progress 3s infinite ease-in-out;
}

@keyframes crm-progress {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(20%); }
  100% { transform: translateX(300%); }
}

.refreshing-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid #e5e7eb;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: refresh-spin 0.6s linear infinite;
  flex-shrink: 0;
}

@keyframes refresh-spin {
  to { transform: rotate(360deg); }
}

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

/* (removed all .crm-*-banner rules: no header warning banners per spec.
   Unreachability is indicated only via bottom progress bar on timeout + compact header marquee after 8s) */

/* Multi-group layout */
.global-meta {
  max-width: 1820px;
  margin: 0 auto;
  padding: 0 1rem 0.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.global-meta-right {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
  min-width: 0;
}

#mutation-sync-status {
  font-size: 0.75rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #f59e0b;
}

/* Note attachments queue list — matches .crm-sync-status style, stacked above it on the left */
#note-queue-list {
  position: fixed;
  bottom: 5.5rem;
  right: 1.5rem;
  z-index: 2002;
  max-width: 420px;
  padding: 0.5rem 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.82rem;
  box-shadow: var(--shadow);
  line-height: 1.4;
}
#note-queue-list:empty {
  display: none;
}
.note-queue-item {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.note-queue-item.success { color: #166534; }
.note-queue-item.fail { color: #9f1239; }
.note-queue-item .q-attach { opacity: 0.8; font-size: 0.9em; }
.note-queue-item .q-check { margin-left: 0.25em; }
.note-queue-item .q-fail { margin-left: 0.25em; color: #9f1239; }

/* Indicator stack: holds toast, CRM sync status, and note queue so they stack
   vertically on the right by default, and on the left when a bookmark preview is open. */
.bookmark-indicator-stack {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  left: auto;
  z-index: 2004;
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-end;
  gap: 0.5rem;
  max-width: min(420px, calc(100vw - 3rem));
  pointer-events: none;
}
.bookmark-indicator-stack.bookmark-open {
  right: auto;
  left: 1.5rem;
  align-items: flex-start;
}
.bookmark-indicator-stack.hidden {
  display: none !important;
}
.bookmark-indicator-stack > * {
  pointer-events: auto;
}
.bookmark-indicator-stack .toast,
.bookmark-indicator-stack .crm-sync-status,
.bookmark-indicator-stack #note-queue-list {
  position: static !important;
  right: auto !important;
  left: auto !important;
  bottom: auto !important;
  margin: 0 !important;
  animation: slide-in 0.2s ease;
}
.bookmark-indicator-stack .toast {
  max-width: 100%;
}
.bookmark-indicator-stack .crm-sync-status {
  max-width: 100%;
}
.bookmark-indicator-stack #note-queue-list {
  max-width: 100%;
}

/* Attachments field in note editors (deal-edit + quick-note) */
.note-attachments-field {
  margin-top: 0.25rem;
}
.note-attachments-field label {
  font-size: 0.75rem;
  display: block;
  margin-bottom: 0.1rem;
}
.note-attachments-input {
  font-size: 0.75rem;
}
.selected-attachments {
  margin-top: 0.15rem;
  font-size: 0.7rem;
  line-height: 1.25;
}
.selected-attachments .sel-item {
  display: inline-block;
  margin-right: 0.5em;
  background: var(--surface-2);
  padding: 0 0.3em;
  border-radius: 2px;
}
.selected-attachments .sel-remove {
  cursor: pointer;
  margin-left: 0.2em;
  opacity: 0.7;
}
.selected-attachments .sel-remove:hover { opacity: 1; }

/* Compact scrolling marquee indicator pinned to the underside of the header (inside .global-meta), on the right side.
   Width stays compact/narrow (like previous small version). Height larger via bigger font + padding (user: "font needed to be larger" for height).
   Matches the font-size/style of the left-side meta text ("open opportunities · 2 open tasks ...") which is 0.8rem.
   More amber colors, starts with emoji (set in JS). */
.crm-header-marquee {
  margin-left: auto; /* push to the right side of the global-meta flex row */
  font-size: 0.9rem; /* larger than the old 9.5px tiny version, to give more height/visibility while matching surrounding meta text size */
  line-height: 1.25;
  color: #713f12;
  background: #fef08c;
  border: 1px solid #b45309;
  border-radius: 3px;
  padding: 2px 6px;
  max-width: 480px; /* doubled width, nothing else changed */
  overflow: hidden;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(180, 83, 9, 0.2);
  flex-shrink: 0;
}
.crm-header-marquee span {
  display: inline-block;
  min-width: 100%;
  animation: crm-marquee 8s linear infinite;
  padding-left: 0;
}
@keyframes crm-marquee {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}
.crm-header-marquee.hidden {
  display: none !important;
}

.crm-crash-banner {
  margin-left: auto;
  font-size: 0.75rem;
  line-height: 1.3;
  background: #f59e0b;
  color: #1f2937; /* dark text, readable on amber in both light and dark mode */
  border: 1px solid #b45309;
  border-radius: 3px;
  padding: 2px 6px;
  max-width: 320px;
  white-space: normal;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.btn-collapse-tile {
  flex-shrink: 0;
}

.tile-collapsed-hint,
.feed-collapsed-hint {
  color: var(--muted);
  font-size: 0.82rem;
  font-style: italic;
  margin: 0.5rem 0;
  padding: 0.35rem 0.5rem;
  list-style: none;
}

.feed-collapsed-hint {
  padding: 0.65rem 0.85rem;
}

/* Fixed top row: notifications + team + tasks (equal thirds) */
.dashboard-panel-row,
.dashboard-tiles-pinned {
  --panel-content-width: 100%;
}

.dashboard-panel-row {
  max-width: 1820px;
  margin: 0 auto 0.5rem;
  padding: 0 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  align-items: stretch;
}

.dashboard-panel-row .panel-slot-left {
  order: 1;
}

.daily-focus {
  font-family: var(--font);
  font-size: 0.85rem;
  font-style: italic;
  font-weight: 500;
  line-height: 1.45;
  color: var(--muted);
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: nowrap;
  white-space: nowrap;
  overflow: hidden;
  max-width: 50vw;
  min-width: 0;
  flex-shrink: 1;
}

.daily-focus-quote {
  color: var(--text);
  font-style: italic;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
  min-width: 0;
}

.daily-focus-author {
  font-size: 0.78rem;
  font-style: italic;
  font-weight: 400;
  color: var(--muted);
  font-family: var(--font);
  letter-spacing: normal;
  white-space: nowrap;
  flex-shrink: 0;
}

.daily-focus-refresh {
  font-size: 0.75rem;
  font-family: var(--font);
  font-style: normal;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0.05rem 0.2rem;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
  line-height: 1;
}

.daily-focus-refresh:hover {
  background: var(--surface-2);
  color: var(--text);
}

.daily-focus-refresh:focus {
  outline: none;
  background: var(--surface-2);
}

.dashboard-panel-row .panel-slot-right {
  order: 2;
}

/* Panel tiles: equal thirds in the top row */
.dashboard-panel-row .dashboard-tile {
  flex: 1 1 calc(33.333% - 0.834rem);
  min-width: 0;
  max-width: calc(33.333% - 0.834rem);
}

/* Pinned row: collapsed panels — minimal height, same left/right slots */
.dashboard-tiles-pinned {
  max-width: 1820px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  align-items: stretch;
}

.dashboard-tiles-pinned:not(.hidden) {
  margin-bottom: 0.65rem;
}

.dashboard-tiles-pinned .dashboard-tile {
  min-height: 0;
  height: auto;
  align-self: start;
}

.dashboard-tiles-pinned .panel-slot-left {
  order: 1;
}

.dashboard-tiles-pinned .panel-slot-right {
  order: 2;
}

.dashboard-tiles-pinned .dashboard-tile.panel-width-quarter {
  flex: 0 0 calc(25% - 0.625rem);
  max-width: calc(25% - 0.625rem);
}

.dashboard-tiles-pinned .dashboard-tile.panel-width-half {
  flex: 1 1 calc(50% - 0.625rem);
  max-width: calc(50% - 0.625rem);
}

.dashboard-tiles-pinned .dashboard-tile.panel-width-full {
  flex: 0 0 var(--panel-content-width);
  width: var(--panel-content-width);
  max-width: var(--panel-content-width);
}

.dashboard-tiles-pinned .dashboard-tile.tile-body-collapsed {
  min-height: 0;
}

.dashboard-tiles-pinned .tile-toolbar {
  padding: 0.3rem 0.55rem;
  border-bottom: 1px solid var(--border);
}

/* Dashboard tile grid — 2 columns; double height spans 2 rows */
.dashboard-tiles {
  --tile-row-height: 400px;
  max-width: 1820px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: auto;
  gap: 1.25rem;
  align-items: start;
}

.dashboard-tile {
  grid-column: span 4;
  min-width: 0;
  min-height: var(--tile-row-height);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.dashboard-tile.tile-half {
  grid-column: span 2;
}

.dashboard-tile.tile-quarter {
  grid-column: span 1;
}

.dashboard-tile.tile-double {
  grid-row: span 2;
  min-height: 0;
  height: auto;
  max-height: none;
}

.dashboard-tile.tile-double .feed-list,
.dashboard-tile.tile-double .tasks-by-user {
  max-height: none;
  flex: 1;
  min-height: 0;
}

.dashboard-tile.tile-double.board-group-tile {
  min-height: calc(var(--tile-row-height) * 2 + 1.25rem);
}

.dashboard-tile.tile-double.board-group-tile .board {
  flex: 1;
  min-height: calc(var(--tile-row-height) * 2 - 80px);
}

.dashboard-tile.tile-double.board-group-tile .column {
  max-height: calc(var(--tile-row-height) * 2 - 120px);
}

.dashboard-tile.tile-body-collapsed {
  min-height: 0;
  height: auto;
  grid-row: auto;
  align-self: start;
}

.dashboard-tile.tile-body-collapsed.tile-double {
  grid-row: auto;
}

.dashboard-tile.tile-body-collapsed > *:not(.tile-toolbar):not(.group-tile-bar) {
  display: none !important;
}

.dashboard-tile.dragging {
  opacity: 0.55;
  border-color: var(--accent);
}

.dashboard-tile.drag-over {
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.tile-toolbar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  cursor: grab;
  user-select: none;
}

.tile-toolbar:active {
  cursor: grabbing;
}

.tile-drag-hint {
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0.12em;
  padding: 0.15rem 0.4rem 0.15rem 0.1rem;
  flex-shrink: 0;
  cursor: grab;
  border-radius: 2px;
}
.tile-drag-hint:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.035);
}

.tile-drag-hint.hidden {
  display: none;
}

.tile-toolbar-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0;
  white-space: nowrap;
}

.tile-toolbar-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  margin-left: 0.15rem;
  flex-shrink: 0;
}

.group-tile-bar {
  flex-wrap: wrap;
  gap: 0.4rem 0.5rem;
}

.group-tile-name {
  flex: 1 1 140px;
  min-width: 120px;
  max-width: 280px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.group-tile-count {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

.group-tile-templates {
  font: inherit;
  font-size: 0.72rem;
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  max-width: 10rem;
}

.tile-toolbar-spacer {
  flex: 1 1 auto;
  min-width: 0.5rem;
}

.tile-menu-wrap {
  position: relative;
  flex-shrink: 0;
}

.tile-menu-trigger {
  font-size: 0.72rem;
  padding: 0.2rem 0.45rem;
  font-weight: 500;
}

.tile-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 50;
  min-width: 9.5rem;
  padding: 0.25rem 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.tile-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.78rem;
  padding: 0.4rem 0.65rem;
  cursor: pointer;
}

.tile-menu-item:hover,
.tile-menu-item:focus-visible {
  background: var(--surface-2);
  outline: none;
}

.tile-menu-item--danger {
  color: var(--danger, #c45c5c);
}

.tile-layout-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-left: auto;
}

/* In quarter (narrow) view for tiles (esp. tasks tile in top panel row), make the
   toolbar button groupings tighter so they stay in a single row without bunching
   or adding extra height/row to the title bar. Reduced gaps + paddings + force
   nowrap on layout sub-group. */
.dashboard-tile.tile-quarter .tile-toolbar,
.dashboard-tile.panel-width-quarter .tile-toolbar,
.dashboard-tiles-pinned .dashboard-tile.panel-width-quarter .tile-toolbar {
  gap: 0.15rem;
  padding: 0.25rem 0.4rem;
}
.dashboard-tile.tile-quarter .tile-layout-btns,
.dashboard-tile.panel-width-quarter .tile-layout-btns,
.dashboard-tiles-pinned .dashboard-tile.panel-width-quarter .tile-layout-btns {
  gap: 0.1rem;
  flex-wrap: nowrap;
  margin-left: 0.15rem;
}
.dashboard-tile.tile-quarter .tile-btn-icon,
.dashboard-tile.panel-width-quarter .tile-btn-icon,
.dashboard-tiles-pinned .dashboard-tile.panel-width-quarter .tile-btn-icon {
  padding: 0.1rem 0.2rem;
}
.dashboard-tile.panel-width-quarter .btn-tasks-list,
.dashboard-tile.tile-quarter .btn-tasks-list {
  padding: 0.1rem 0.2rem;
}
.dashboard-tile.panel-width-quarter .tile-toolbar .btn-new-task,
.dashboard-tile.tile-quarter .tile-toolbar .btn-new-task {
  padding: 0.15rem 0.3rem;
  font-size: 0.65rem;
}
.dashboard-tile.panel-width-quarter .tile-btn,
.dashboard-tile.tile-quarter .tile-btn {
  font-size: 0.65rem;
  padding: 0.15rem 0.3rem;
}

.tile-btn {
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.tile-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.tile-btn-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.dashboard-tile.feed-panel,
.dashboard-tile.tasks-panel,
.dashboard-tile.presence-panel,
.dashboard-tile.panel-tile {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: auto;
  align-self: stretch;
}

/* Team tile body fills available height with scroll constraint */
.dashboard-tile.presence-panel .presence-tile-body {
  flex: 1;
  min-height: 0;
  max-height: 280px;
  overflow-y: auto;
}

.dashboard-tile.feed-panel .panel-header,
.dashboard-tile.tasks-panel .panel-header,
.dashboard-tile.presence-panel .panel-header {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  padding: 0.65rem 1rem 0;
  margin-bottom: 0.5rem;
  min-height: auto;
}

.panel-header-feed {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.panel-header-feed .feed-keyword-filter {
  flex: 1 1 auto;
  min-width: 0;
  max-width: none;
  margin-left: 0;
}

.dashboard-tile.panel-tile .feed-list,
.dashboard-tile.panel-tile .tasks-by-user {
  list-style: none;
  margin: 0 1rem 1rem;
  padding: 0;
  flex: 0 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: visible;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-sizing: border-box;
}

.dashboard-tile.panel-tile .feed-list {
  max-height: 280px;
  overflow-y: auto;
}

.dashboard-tile.panel-tile .tasks-by-user:not(.tasks-by-user-columns) {
  max-height: 280px;
  overflow-y: auto;
}

.dashboard-tile.tasks-panel.tasks-tile-full .tasks-by-user.tasks-by-user-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0 1.25rem;
  align-items: start;
  max-height: none;
  overflow: visible;
}

.tasks-column {
  min-width: 0;
}

.tasks-column .task-row:first-of-type {
  border-top: none;
  border-bottom: 1px solid var(--border);
}

.dashboard-tiles-pinned .dashboard-tile.tile-body-collapsed {
  max-height: none;
}

.dashboard-tile .tasks-by-user .board-loading {
  padding: 0.65rem 0.85rem;
  margin: 0;
}

.dashboard-tile .tasks-user-block {
  padding: 0.65rem 0.85rem;
  margin: 0;
  background: transparent;
  border: none;
  border-radius: 0;
}

.dashboard-tile .tasks-user-block + .tasks-user-block {
  border-top: 1px solid var(--border);
}

.dashboard-tile.board-group-tile .board-group-header {
  border-top: none;
}

.dashboard-tile.board-group-tile .board {
  padding-bottom: 1rem;
}

/* Top panels */
.panel {
  max-width: 1820px;
  margin: 0 auto 1.25rem;
  padding: 0 1rem;
}

.panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: flex-start;
  gap: 0.35rem 1rem;
  margin-bottom: 0.65rem;
}

.panel-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.panel-sub {
  font-size: 0.8rem;
  color: var(--muted);
}

.feed-range-hint {
  margin-left: auto;
  font-size: 0.75rem;
  opacity: 0.85;
}

.panel-header-feed {
  align-items: center;
}

.feed-loading-indicator {
  display: inline-flex;
  align-items: center;
  margin-left: 0.35rem;
  color: var(--muted);
}

.feed-loading-indicator.hidden {
  display: none;
}

.feed-loading-spinner {
  animation: feed-spin 0.85s linear infinite;
}

@keyframes feed-spin {
  to {
    transform: rotate(360deg);
  }
}

.feed-list .feed-loading {
  color: var(--muted);
  font-style: italic;
}

.btn-tile-remove {
  flex-shrink: 0;
  margin-left: 0.15rem;
  color: #e5484d;
}

.btn-tile-remove:hover {
  color: #ff6b6b;
  background: rgba(229, 72, 77, 0.12);
}

.btn-tile-remove .tile-remove-icon {
  stroke: currentColor;
}

.feed-keyword-filter {
  flex: 1 1 140px;
  min-width: 120px;
  max-width: 220px;
  padding: 0.35rem 0.55rem;
  font: inherit;
  font-size: 0.78rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
}

.feed-keyword-filter::placeholder {
  color: var(--muted);
}

.feed-keyword-filter:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.feed-list li {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.feed-item.feed-item-today,
.feed-list li.feed-item-today {
  border-left: 3px solid rgba(255, 255, 255, 0.25);
  padding-left: 0.5rem;
}

.feed-item-hiding {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.feed-item-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.feed-item-body {
  flex: 1;
  min-width: 0;
}

.feed-hide-btn {
  flex-shrink: 0;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.feed-hide-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.btn-feed-hidden-toggle {
  opacity: 0.55;
}

.btn-feed-hidden-toggle:hover {
  opacity: 1;
}

.modal-card-feed-hidden {
  max-width: 32rem;
}

.feed-hidden-hint {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.feed-hidden-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.feed-hidden-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.feed-hidden-item:last-child {
  border-bottom: none;
}

.feed-hidden-empty {
  padding: 0.85rem 0.75rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.feed-restore-btn {
  flex-shrink: 0;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.45rem;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.feed-restore-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.feed-list li:last-child {
  border-bottom: none;
}

.feed-load-more {
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  font-style: italic;
  padding: 0.65rem 0.85rem !important;
  border-bottom: none !important;
  cursor: default;
}

.feed-list a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.feed-list a:hover {
  text-decoration: underline;
}

.feed-meta {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.tasks-by-user {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.tasks-user-block {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0.65rem 0.85rem;
}

/* (h3 name header removed from tasks-by-user render; dropdown indicates selected user.
   Rule left commented to avoid accidental re-introduction of duplicate label) */
/* .tasks-user-block h3 { margin: 0 0 0.5rem; font-size: 0.9rem; color: var(--accent); } */

.task-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.task-row:last-of-type {
  margin-bottom: 0;
}

.task-row.done {
  opacity: 0.55;
}

.task-row--overdue {
  background: rgba(240, 180, 41, 0.08);
  border-color: var(--warn);
  border-left: 3px solid var(--warn);
}

/* High Priority tag highlight on opportunity cards */
.card--high-priority {
  background: rgba(240, 180, 41, 0.08);
  border-color: var(--warn);
  border-left: 3px solid var(--warn);
}

.task-row label {
  flex: 1;
  cursor: pointer;
}

.tasks-filter-label {
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  margin-left: auto;
  align-items: center;
  gap: 0.4rem;
}

.tasks-filter-label select {
  font: inherit;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
}

.task-row label a:first-of-type,
.tasks-list-row label a:first-of-type {
  color: #d4942b;
  text-decoration: none;
  font-weight: 500;
}
.task-row label a:hover,
.tasks-list-row label a:hover {
  text-decoration: underline;
}

.group-filter-summary {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.btn-tasks-list {
  font-size: 0.9rem;
  padding: 0.28rem 0.35rem;
  min-width: auto;
  margin-right: 2px;
  opacity: 0.7;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.btn-tasks-list:hover {
  opacity: 1;
}
.btn-tasks-list svg {
  width: 16px;
  height: 16px;
  display: inline-block;
  vertical-align: middle;
}
/* Note: tasks archive button now lives in toolbar (moved left of New task); header only has user filter label */

.tasks-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.tasks-list-filter {
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--text);
}

.tasks-list-body {
  max-height: 60vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.25rem;
  background: var(--surface);
  color: inherit;
}

.tasks-list-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  border-radius: 4px;
  background: var(--surface);
  margin-bottom: 2px;
  transition: background 0.1s;
  border-bottom: 1px solid var(--border);
}
.tasks-list-row:last-child {
  border-bottom: none;
}
.tasks-list-row:hover {
  background: var(--surface-2, #e9ecef);
}
.tasks-list-row.done {
  opacity: 0.75;
  text-decoration: line-through;
  background: var(--surface);
}
.tasks-list-row label {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  color: inherit;
  font-size: 0.85rem;
}
.tasks-list-row input[type="checkbox"] {
  accent-color: var(--accent, #0d6efd);
}
.tasks-list-row .feed-meta {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.template-delete-list {
  max-height: 40vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 0.5rem 0;
}
.template-delete-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
}
.template-delete-row:last-child {
  border-bottom: none;
}
.template-delete-name {
  flex: 1;
}
.btn-delete-tpl {
  color: var(--danger);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.1rem 0.3rem;
}

/* Collapsible tag multiselect (matches select height/style) */
.multiselect {
  position: relative;
  min-width: 160px;
}

.multiselect-trigger {
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 0.875rem;
  padding: 0.5rem 2rem 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b95a8' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
}

.multiselect-trigger:hover {
  border-color: var(--muted);
}

.multiselect-panel {
  position: absolute;
  z-index: 30;
  top: calc(100% + 2px);
  left: 0;
  min-width: 100%;
  max-width: 280px;
  max-height: 200px;
  overflow-y: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0.35rem;
}

.multiselect-panel label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.4rem;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
}

.multiselect-panel label:hover {
  background: var(--accent-soft);
}

.checkbox-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
  user-select: none;
  margin: 0;
  padding: 0;
  width: auto;
  min-width: 0;
}

.checkbox-filter input {
  accent-color: var(--accent);
}

.group-filters .field.field-checkbox {
  min-width: 0;
  flex: 0 1 auto;
  align-self: flex-end;
  padding-bottom: 0.35rem;
}

.card-title-link {
  color: inherit;
  text-decoration: none;
  font-weight: 600;
}

.card-title-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.dashboard-tile.board-group-tile.board-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.board-group {
  background: transparent;
  border: none;
  border-radius: 0;
  overflow: visible;
}

.board-group-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.board-group.filters-collapsed .board-group-header {
  display: none;
}

.board-group.filters-collapsed .group-tile-bar .group-filter-summary-compact {
  display: inline;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-tile-bar .group-filter-summary-compact {
  display: none;
  font-size: 0.72rem;
  color: var(--muted);
}

.group-filters-panel {
  margin-top: 0.35rem;
}

.btn-toggle-filters {
  font-size: 0.75rem;
  padding: 0.35rem 0.65rem;
  white-space: nowrap;
}

.board-group-title-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.board-group-title-row input[type="text"] {
  flex: 1;
  font: inherit;
  font-size: 1.1rem;
  font-weight: 600;
  padding: 0.4rem 0.6rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
}

.board-group-title-row input[type="text"]:focus {
  border-color: var(--accent);
  background: var(--surface);
}

.board-group-count {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

/* Local kanban controls row (now just the +status / +task buttons, since the board name is in the tile toolbar title bar above). */
.local-kanban-header {
  display: flex;
  justify-content: flex-end;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem 0;
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--border);
}

.btn-danger:hover {
  border-color: var(--danger);
}

.group-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-start;
}

.group-filters .field {
  min-width: 120px;
}



.contact-field {
  position: relative;
  min-width: 200px;
}

.contact-field input[type="search"] {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.contact-results {
  position: absolute;
  z-index: 20;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 2px;
  max-height: 200px;
  overflow-y: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.contact-results button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.65rem;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.contact-results button:hover {
  background: var(--accent-soft);
}

.contact-selected {
  font-size: 0.75rem;
  color: var(--accent);
  margin-top: 0.25rem;
}

.contact-clear {
  font-size: 0.7rem;
  margin-left: 0.5rem;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
}

.board-group .board {
  padding: 1rem 1.25rem;
  max-width: none;
  margin: 0;
}

.column-empty .column-body {
  min-height: 72px;
  border: 1px dashed var(--border);
  margin: 0.65rem;
  border-radius: 8px;
}

@media (max-width: 900px) {
  .dashboard-tiles {
    grid-template-columns: 1fr;
  }

  .dashboard-tile,
  .dashboard-tile.tile-half,
  .dashboard-tile.tile-quarter {
    grid-column: 1 / -1;
  }

  .dashboard-panel-row .dashboard-tile.panel-width-quarter,
  .dashboard-panel-row .dashboard-tile.panel-width-half,
  .dashboard-panel-row .dashboard-tile.panel-width-full,
  .dashboard-panel-row .dashboard-tile,
  .dashboard-tiles-pinned .dashboard-tile.panel-width-quarter,
  .dashboard-tiles-pinned .dashboard-tile.panel-width-half,
  .dashboard-tiles-pinned .dashboard-tile.panel-width-full,
  .dashboard-tiles-pinned .dashboard-tile {
    flex: 1 1 100%;
    max-width: 100%;
    width: 100%;
  }
}

/* Confirm modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.modal-card {
  position: relative;
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
}

/* Make the Team/Presence popup resizable (user can drag bottom-right corner to see more messages) */
#presence-modal .modal-card {
  width: min(624px, 96vw);
  resize: both;
  overflow: auto;
  min-width: 408px;
  min-height: 504px;
  max-width: 90vw;
  max-height: 85vh;
}

.modal-title {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
}

.modal-message {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.modal-card-form {
  width: min(480px, 92vw);
  max-height: min(90vh, 720px);
  overflow-y: auto;
}

.modal-form .field {
  margin-bottom: 0.85rem;
}

.modal-form .field label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.modal-form .field input:not([type="checkbox"]),
.modal-form .field select,
.modal-form .field textarea,
.modal-form .field .note-editor {
  display: block;
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  box-sizing: border-box;
}

.modal-form .field textarea {
  resize: vertical;
  min-height: 4.5rem;
}

.modal-form .field .note-editor {
  resize: vertical;
  min-height: 4.5rem;
  max-height: 12rem;
  overflow: auto;
  white-space: pre-wrap;
  outline: none;
}

.note-format-toolbar {
  display: flex;
  gap: 0.2rem;
  margin: 0.1rem 0 0.2rem;
  flex-wrap: wrap;
}

.note-format-btn {
  font: inherit;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.1rem 0.3rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  min-width: 1.35em;
  text-align: center;
  user-select: none;
}
.note-format-btn:hover {
  background: var(--surface-2);
  border-color: var(--accent);
}
.note-format-btn:active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Single light-green highlighter button swatch (subtle so it doesn't look like the bright applied highlight) */
.note-format-btn[data-cmd="hiliteColor"] { background: #c8e6c9; color: #222; border-color: #81c784; }
.note-format-btn[data-cmd="hiliteColor"]:hover { filter: brightness(0.95); }

.note-editor {
  display: block;
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  box-sizing: border-box;
}

.note-editor:focus {
  border-color: var(--accent);
}

.note-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
  font-style: italic;
  pointer-events: none;
  display: block;
}

/* Rich text (bold/italic/underline) + highlight from quick event notes / deal-edit event notes
   must render visibly in the preview deal modal history (and while editing in the modals).
   Use <mark> for highlight + the notes-tile low-opacity light-green tint so it doesn't wash out text. */
.opp-preview-history-body strong,
.opp-preview-history-body b,
.opp-preview-history-body--html strong,
.opp-preview-history-body--html b,
.note-editor strong,
.note-editor b {
  font-weight: 700;
}
.opp-preview-history-body em,
.opp-preview-history-body i,
.opp-preview-history-body--html em,
.opp-preview-history-body--html i,
.note-editor em,
.note-editor i {
  font-style: italic;
}
.opp-preview-history-body u,
.opp-preview-history-body--html u,
.note-editor u {
  text-decoration: underline;
}

/* Light green highlight (more green, much lower opacity for readability, copied from notes-tile mark fix).
   !important to override inline styles from execCommand hiliteColor.
   Targets both <mark> (if produced) and spans. */
.note-editor mark,
.note-editor span[style*="background-color"],
.opp-preview-history-body mark,
.opp-preview-history-body span[style*="background-color"],
.opp-preview-history-body--html mark,
.opp-preview-history-body--html span[style*="background-color"] {
  background-color: rgba(34, 197, 94, 0.12) !important;
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}

.modal-checkbox {
  margin: 0.25rem 0 0.85rem;
}

.modal-error {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--danger);
}

.modal-card-deal-edit {
  max-width: 28rem;
}

.modal-card-deal-edit.modal-card-form {
  display: flex;
  flex-direction: column;
  overflow-y: hidden;
}

.modal-card-deal-edit .modal-form {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.modal-card-deal-edit .modal-actions {
  flex-shrink: 0;
  background: var(--surface);
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
}

.modal-card-deal-edit .note-editor {
  max-height: 6rem;
  resize: none;
}

.deal-edit-user-fields-bar {
  margin: 0.5rem 0 0.25rem;
}

.deal-edit-user-fields {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--surface-2);
  max-height: 30vh;
  overflow-y: auto;
}

.modal-card-deal-edit .modal-actions {
  z-index: 2;
}

.modal-card-create-opp {
  width: min(520px, 94vw);
  max-height: min(92vh, 800px);
}

.create-opp-legend {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0 0.25rem;
}

.create-opp-field-heading {
  margin: 0.75rem 0 0.35rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
}

.field-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.create-opp-user-fields-unavailable {
  margin: 0.35rem 0 0.5rem;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px dashed var(--border);
  background: var(--surface);
  cursor: help;
}

.create-opp-custom-fields .field {
  margin-bottom: 0.75rem;
}

.create-opp-custom-fields .checkbox-filter {
  margin: 0;
}

/* ===================== Presence / Team (header button, modal, pinned tile) ===================== */

#presence-btn {
  position: relative;
}

#presence-btn.has-waiting-messages::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: -1px;
  width: 8px;
  height: 8px;
  background: #ef4444;
  border: 1px solid #fff;
  border-radius: 50%;
  animation: presence-wait-flash 1s infinite;
  pointer-events: none;
}

/* Self-online indicator on the presence icon (green dot). 
   Now the bottom-right green counter (small circle for 1 online, with number if >1) is the .presence-online-badge span.
   The ::before is suppressed in JS when the counter badge is shown to avoid double/big green visuals. */
#presence-btn.is-online::before {
  content: "";
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 7px;
  height: 7px;
  background: #22c55e;
  border: 1px solid var(--bg, #111);
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
}

@keyframes presence-wait-flash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.presence-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
  border: 1px solid var(--surface);
  pointer-events: none;
}

.presence-badge.hidden {
  display: none;
}


.presence-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.presence-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.presence-tab {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 0.3rem 0.8rem;
  font-size: 0.82rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: 0;
}
.presence-tab:hover {
  color: var(--text);
}
.presence-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.presence-my-status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
}

.presence-my-status .btn {
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
}

.presence-my-status textarea {
  width: 100%;
  max-width: 320px;
  font: inherit;
  font-size: 0.8rem;
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  resize: vertical;
}

.presence-status-select {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85rem;
}

.presence-section-header {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  padding: 0.25rem 0.5rem 0.1rem;
  margin-top: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.presence-divider {
  height: 1px;
  background: var(--border);
  margin: 0.3rem 0.5rem;
}

/* Recent messages (inbox) section in the Team modal — gives visibility to past/new DMs + clear */
#presence-recent {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  margin-bottom: 0.5rem;
  max-height: 140px;
  overflow: auto;
}
.presence-recent-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 1rem; /* larger for inbox on Messages tab (twice as prominent) */
}
.presence-recent-row:last-child {
  border-bottom: none;
}
.presence-recent-row:hover {
  background: var(--surface-2);
}

/* Unread vs read shading in the Messages inbox recent list.
   Unread = more prominent (darker surface + blue accent border for "new").
   Read = lighter/muted (faded, less emphasis).
   This makes it easy to see which threads have unread messages.
   The demo message will be shaded as unread until you click it in the session. */
.presence-recent-row.unread {
  background: var(--surface-2);
  border-left: 4px solid #3b82f6; /* blue accent to clearly mark unread/new */
  font-weight: 500;
}
.presence-recent-row.unread::after {
  content: "●";
  color: #3b82f6;
  font-size: 8px;
  margin-left: auto;
  flex-shrink: 0;
}
.presence-recent-row.read {
  opacity: 0.65;
}
.presence-recent-row.read .presence-recent-who,
.presence-recent-row.read .presence-recent-snip,
.presence-recent-row.read .presence-recent-time {
  color: var(--muted);
}
.presence-recent-who {
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
  max-width: 38%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.presence-recent-snip {
  color: var(--muted);
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
}
.presence-recent-time {
  color: var(--muted);
  font-size: 0.8rem;
  flex-shrink: 0;
  margin-right: 0.1rem;
}
.presence-clear-btn {
  font-size: 0.85rem !important;
  padding: 0 0.25rem !important;
  line-height: 1 !important;
  opacity: 0.7;
}
.presence-clear-btn:hover {
  opacity: 1;
  background: rgba(239,68,68,0.15);
}

.presence-list {
  max-height: 480px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  margin-bottom: 0.5rem;
}

.presence-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.presence-user:last-child {
  border-bottom: none;
}
.presence-user:hover {
  background: var(--surface-2);
}

.presence-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.15);
}
.presence-dot.online { background: #22c55e; } /* green */
.presence-dot.offline { background: #475569; } /* dark slate */
.presence-dot.idle { background: #eab308; }   /* amber for idle >2h */
.presence-dot.afd { background: #64748b; }   /* subtle slate gray for "away from dashboard" (tab not focused, but session active) */

.presence-name {
  font-weight: 600;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.presence-status {
  font-size: 0.78rem;
  color: var(--muted);
  margin-left: auto;
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}

.presence-dm {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  margin-bottom: 0.5rem;
  display: flex;
  flex-direction: column;
  max-height: 480px;
}

.presence-dm-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.presence-dm-log {
  flex: 1 1 auto;
  overflow: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.95rem; /* larger for viewing more messages at once */
  min-height: 260px;   /* ensure the chat history area is tall even if parent constrained */
}

.presence-msg {
  max-width: 80%;
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.presence-msg.me {
  align-self: flex-end;
  background: var(--accent-soft);
  color: var(--text);
}

.presence-dm-input {
  display: grid;
  grid-template-areas:
    "text buttons"
    "picker .";
  grid-template-columns: 1fr auto;
  gap: 0.35rem;
  padding: 0.5rem;
  border-top: 1px solid var(--border);
  position: relative;
}
.presence-dm-input textarea {
  grid-area: text;
  font: inherit;
  font-size: 0.85rem;
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  resize: vertical;
  min-height: 2.2em;
}
.presence-dm-input-buttons {
  grid-area: buttons;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.35rem;
}

.presence-admin {
  margin-top: 0.5rem;
  padding: 0.5rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.8rem;
}
.presence-admin-header {
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 0.35rem;
}
.presence-admin-list .presence-admin-row {
  padding: 0.2rem 0;
  border-top: 1px solid var(--border);
}
.presence-admin-list .presence-admin-row:first-child {
  border-top: none;
}

.presence-admin-list .presence-admin-row .admin-label {
  color: var(--muted);
  font-size: 0.72rem;
}

/* DM rich features: replies, read receipts, emoji picker, colors */
.presence-reply-context {
  font-size: 0.7em;
  line-height: 1.2;
  color: var(--muted);
  border-left: 2px solid var(--border);
  padding-left: 0.35rem;
  margin-bottom: 0.2rem;
  opacity: 0.85;
  font-style: italic;
}
.presence-reply-context .presence-reply-label {
  font-weight: 600;
  font-style: normal;
}
.presence-reply-preview {
  font-size: 0.72rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--muted);
}
.presence-reply-preview span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.presence-reply-preview button {
  font-size: 0.7rem;
  padding: 0 0.2rem;
}
.presence-read-receipt {
  font-size: 0.6em;
  color: #22c55e;
  margin-top: 0.1rem;
  align-self: flex-end;
}

.presence-msg-status {
  font-size: 0.6em;
  margin-top: 0.1rem;
  align-self: flex-end;
}

.presence-msg-time {
  font-size: 0.6em;
  color: var(--muted);
  margin-top: 0.15rem;
  opacity: 0.75;
  line-height: 1;
  text-align: right;
}
.presence-msg:not(.me) .presence-msg-time {
  text-align: left;
}

/* ---------- DM pagination ---------- */
.presence-dm-load-more {
  display: block;
  width: 100%;
  text-align: center;
  padding: 10px;
  background: rgba(255,255,255,0.04);
  border: 1px dashed rgba(255,255,255,0.12);
  border-radius: 6px;
  cursor: pointer;
  color: rgba(255,255,255,0.6);
  font-size: 13px;
  margin-bottom: 8px;
  transition: background 0.15s, color 0.15s;
}
.presence-dm-load-more:hover { background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.9); }
.presence-dm-load-more:disabled { opacity: 0.4; cursor: not-allowed; }

/* CRM Mail Inbox modal styles */
.mail-inbox-card {
  width: 96vw;
  max-width: 1400px;
  height: 85vh;
  max-height: 900px;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.mail-inbox-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.mail-account-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}
.mail-account-select {
  min-width: 180px;
}
.mail-header-actions {
  margin-left: 1rem;
}
.mail-toolbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}
.mail-search {
  flex: 1;
  max-width: 300px;
}
.mail-main-area {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.mail-list-container {
  flex: 3;
  overflow: auto;
  border-right: 1px solid var(--border);
  padding: 0.5rem;
}
.mail-list {
  width: 100%;
}
.mail-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  font-size: 0.9rem;
}
.mail-row:hover {
  background: #f8f9fa;
}
.mail-row.selected {
  background: #e6f0ff;
}
.mail-from,
.mail-subject {
  color: #aaa; /* less bright grey for readability in dark */
}
.mail-row-read .mail-from,
.mail-row-read .mail-subject {
  color: #777; /* even darker for read emails */
}
.mail-row input[type="checkbox"] {
  margin-top: 0.2rem;
  flex-shrink: 0;
}
.mail-from {
  width: 160px;
  flex-shrink: 0;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #aaa; /* less bright grey for dark bg */
}
.mail-subject {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #aaa; /* less bright grey instead of white */
  font-weight: 600;
}
.mail-date {
  width: 90px;
  flex-shrink: 0;
  text-align: right;
  color: #666;
  font-size: 0.8rem;
}
.mail-sidebar-toggle {
  flex: 0 0 auto;
  align-self: stretch;
  width: 18px;
  min-width: 18px;
  padding: 0;
  border: none;
  border-left: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  font-size: 10px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  writing-mode: vertical-lr;
  text-orientation: mixed;
  user-select: none;
}
.mail-sidebar-toggle:hover {
  background: var(--hover);
  color: var(--text);
}
.mail-right-sidebar {
  flex: 0 0 auto;
  width: 210px;
  min-width: 210px;
  max-width: 230px;
  padding: 0.5rem;
  border-left: 1px solid var(--border);
  background: var(--surface-2);
  overflow: auto;
  font-size: 0.75rem;
  color: var(--text);
  transition: width 0.15s, min-width 0.15s, padding 0.15s;
}
.mail-right-sidebar.mail-viewer-warning {
  background: var(--surface-2);
  border-left: 3px solid var(--warn);
}
.mail-right-sidebar.hidden {
  display: none;
}
.mail-right-sidebar.mail-sidebar-collapsed {
  width: 0 !important;
  min-width: 0 !important;
  max-width: 0 !important;
  padding: 0 !important;
  overflow: hidden;
  border-left: none;
}
.mail-viewer-warning-content {
  position: relative;
}
.mail-warning-dismiss {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0 4px;
  color: var(--muted);
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.mail-warning-dismiss:hover {
  color: var(--text);
}
.mail-viewer-warning-content h4 {
  color: var(--warn);
  font-size: 0.85rem;
  margin: 0 0 .25rem 0;
}
.mail-viewer-warning-content p,
.mail-viewer-warning-content ul {
  margin: 0.15rem 0;
  line-height: 1.2;
}
.mail-viewer-warning-content ul {
  padding-left: 1rem;
}
.mail-viewer-warning-content li {
  margin-bottom: 0.1rem;
}
.mail-viewer-warning-content p.small {
  font-size: 0.65rem;
  color: var(--muted);
}
.mail-deal-search {
  width: 100%;
  margin-bottom: 0.5rem;
}
.mail-deal-results {
  max-height: 180px;
  overflow: auto;
  border: 1px solid var(--border);
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}
.mail-deal-result {
  padding: 0.25rem 0.4rem;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
}
.mail-deal-result:hover {
  background: #f0f8ff;
}
.mail-deal-result.selected {
  background: #d0e8ff;
  font-weight: 500;
}
.mail-link-btn {
  width: 100%;
}
.mail-selected-info {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: #555;
}

#mail-inbox-btn {
  position: relative;
}

.mail-today-count {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

/* Dark mode / theme fixes for mail modal (use CSS vars, avoid hard light colors) */
.mail-inbox-card select,
.mail-inbox-card input[type="search"],
.mail-deal-search {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.mail-row {
  border-bottom-color: var(--border);
}
.mail-row:hover {
  background: var(--surface-2);
}
.mail-row.selected {
  background: var(--accent-soft);
}
.mail-deal-result {
  border-bottom-color: var(--border);
}
.mail-deal-result:hover {
  background: var(--surface-2);
}
.mail-deal-result.selected {
  background: var(--accent-soft);
}

/* Additional for link field and readability */
.mail-deal-results button {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.25rem 0.4rem;
  font-size: 0.85rem;
  margin-bottom: 1px;
}
.mail-deal-results button.selected {
  background: var(--accent-soft);
  font-weight: 500;
}
.mail-subject {
  color: #d0d0d0; /* muted brightness for dark bg, following other tiles' secondary text */
  font-weight: 600;
}
.mail-row {
  font-size: 0.92rem;
  line-height: 1.35;
}
.mail-from {
  color: var(--text);
  font-weight: 500;
}

.mail-item {
  border-bottom: 1px solid var(--border);
}
.mail-detail {
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin: 0.1rem 0 0.4rem;
  font-size: 0.9rem;
}
.mail-expand-btn {
  font-size: 0.75rem;
  padding: 0 0.5rem;
  min-width: 70px; /* wider as requested */
  margin-left: auto;
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  text-align: center;
}
.mail-detail .opp-preview-mail-header,
.mail-detail .opp-preview-mail-body,
.mail-detail .opp-preview-mail-embed,
.mail-detail .opp-preview-mail-text,
.mail-detail .opp-preview-mail-iframe {
  /* follow deal/other tiles contrast: darker bg for container, much darker text for body readability */
  background: #24272e;
  color: #222; /* dark text, not light grey */
  border-color: var(--border);
}
.mail-detail .opp-preview-mail-text {
  color: #222;
  background: transparent;
}
  /* reuse some preview styles but scope for readability */
  font-size: 0.85rem;
}
/* Emoji picker as a floating overlay (used by inline DM) */
.presence-emoji-picker-overlay {
  position: fixed;
  max-height: 180px;
  overflow-y: auto;
  z-index: 99999;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  width: auto;
  min-width: 220px;
  max-width: calc(100vw - 16px);
  box-sizing: border-box;
}

.presence-emoji-picker {
  grid-area: picker;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 0.25rem;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  max-width: 100%;
  max-height: 160px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  margin-top: 0;
}
.presence-emoji-btn {
  font-size: 1.1rem;
  padding: 0.15rem;
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: 4px;
}
.presence-emoji-btn:hover {
  background: var(--surface-2);
}

/* Color code: received (others) always green bubble; sent (me) uses the current accent */
.presence-msg {
  background: #22c55e; /* received = green */
  color: #111;
}
.presence-msg.me {
  background: var(--accent-soft); /* sent = current accent */
  color: var(--text);
}
.presence-msg-text {
  white-space: pre-wrap;
  word-break: break-word;
}
.presence-msg-text a {
  color: var(--accent);
  text-decoration: underline;
  word-break: break-all;
}

/* Small button variant used inside the modal */
.btn-small {
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
}

/* The pinned presence tile uses normal tile styles + a compact list inside the body */
.presence-tile-body {
  padding: 0.25rem 0.5rem 0.5rem;
  font-size: 0.78rem;
  cursor: default;
}
.presence-tile-body .presence-user {
  padding: 0.2rem 0.35rem;
  font-size: 0.9rem;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.1s;
}

.presence-tile-body .presence-name {
  font-size: 0.9rem;
}

.presence-tile-body .presence-recent-who {
  font-size: 0.9rem;
}
.presence-tile-body .presence-user:hover {
  background: var(--surface-2);
}
/* Manual status: directly right of username, bold */
.presence-manual-status {
  font-weight: 700;
  color: var(--text);
  font-size: 0.9rem;
  margin-left: 0.35rem;
  margin-right: auto;
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Auto-derived status: keep original styling, no overrides */
.presence-tile-body .presence-status {
  margin-left: auto;
  text-align: right;
}

/* Divider between online and offline users */
.presence-tile-divider {
  border-top: 1px solid var(--border);
  margin: 0.3rem 0;
}

/* Team tile tabs */
.presence-tile-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  padding: 0 0.75rem;
  background: var(--surface);
}

.presence-tile-tab {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: 0;
  font-family: var(--font);
  transition: color 0.15s, border-color 0.15s;
  position: relative;
}

.presence-tile-tab:hover {
  color: var(--text);
}

.presence-tile-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.presence-tile-tab .msg-badge {
  background: #3b82f6;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 600;
  padding: 0 0.25rem;
  border-radius: 8px;
  margin-left: 0.2rem;
  min-width: 12px;
  display: inline-block;
  text-align: center;
  vertical-align: middle;
}

/* Messages tab content header with pop-out button */
.presence-tile-messages-header {
  display: flex;
  justify-content: flex-end;
  padding: 0.25rem 0.5rem;
}

/* Messages tab / DM inline — body constrained with scroll instead of unbounded expansion */
.presence-tile-expanded .presence-tile-body {
  max-height: 280px;
  overflow-y: auto;
}

/* Waiting messages flash on the messages button */
.presence-msg-count-btn.has-waiting-messages {
  position: relative;
}

.presence-msg-count-btn.has-waiting-messages::after {
  content: "";
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  background: #ef4444;
  border: 1px solid var(--surface);
  border-radius: 50%;
  animation: presence-wait-flash 1s infinite;
  pointer-events: none;
  z-index: 1;
}

/* Team tile toolbar controls */
.dashboard-tile.presence-panel .panel-header.panel-header-presence {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.presence-tile-toolbar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  flex: 1 1 auto;
}

.presence-status-select-tile {
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.75rem;
  font-family: var(--font);
  cursor: pointer;
  max-width: 160px;
}

.presence-status-select-tile:focus {
  outline: none;
  border-color: var(--accent);
}

/* Inline custom status input in tile toolbar */
.presence-custom-wrap {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  flex: 1 1 auto;
}
.presence-custom-input {
  flex: 1 1 auto;
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.75rem;
  font-family: var(--font);
  min-width: 80px;
}
.presence-custom-input:focus {
  outline: none;
  border-color: var(--accent);
}
.presence-custom-ok,
.presence-custom-cancel {
  padding: 0.2rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.7rem;
  cursor: pointer;
  line-height: 1;
}
.presence-custom-ok:hover { border-color: #22c55e; color: #22c55e; }
.presence-custom-cancel:hover { border-color: #ef4444; color: #ef4444; }

.presence-msg-count-btn {
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.75rem;
  font-family: var(--font);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}

.presence-msg-count-btn:hover {
  border-color: var(--accent);
  background: var(--surface);
}

.presence-msg-count-btn .msg-badge {
  background: #3b82f6;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0 0.3rem;
  border-radius: 8px;
  margin-left: 0.25rem;
  min-width: 14px;
  display: inline-block;
  text-align: center;
}

.presence-admin-toggle-tile {
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.72rem;
  font-family: var(--font);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.presence-admin-toggle-tile:hover {
  border-color: var(--accent);
  color: var(--text);
}

/* Popup button on right edge of tile */
.presence-popup-btn {
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
}

.presence-popup-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--surface);
}

/* Flashing unread indicator in team title bar */
.presence-unread-flash {
  color: #ffffff;
  font-size: 1.25rem;
  line-height: 1;
  animation: presence-unread-blink 1s ease-in-out infinite;
  flex-shrink: 0;
  margin-right: 0.15rem;
  cursor: default;
  user-select: none;
  text-shadow: 0 0 6px rgba(255,255,255,0.5);
}
@keyframes presence-unread-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.15; }
}

/* Inline DM inside the tile */
#presence-tile-dm-inline {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.presence-dm-inline-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.presence-dm-inline-back {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0.15rem 0.25rem;
  font-family: var(--font);
}

.presence-dm-inline-back:hover {
  color: var(--text);
}

.presence-dm-inline-title {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.presence-dm-inline-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0.5rem;
  font-size: 0.78rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.presence-dm-inline-log .presence-msg {
  margin-bottom: 0.35rem;
}

.presence-dm-inline-input {
  display: flex;
  gap: 0.35rem;
  padding: 0.35rem 0.5rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}

.presence-dm-inline-field {
  flex: 1 1 auto;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.78rem;
  font-family: var(--font);
}

.presence-dm-inline-field:focus {
  outline: none;
  border-color: var(--accent);
}

.presence-dm-inline-buttons {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  flex-shrink: 0;
}

.presence-emoji-inline-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.15rem 0.25rem;
  line-height: 1;
}
.presence-emoji-inline-btn:hover {
  border-color: var(--border);
  background: var(--surface-2);
}

.presence-dm-inline-send {
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.75rem;
  font-family: var(--font);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.presence-dm-inline-send:hover {
  border-color: var(--accent);
  background: var(--surface);
}

/* DM popup modal */
.modal-card-dm-popup {
  width: min(560px, 94vw);
  max-height: 85vh;
  min-height: 450px;
  display: flex;
  flex-direction: column;
}

/* Larger DM popup for pop-out from messages inbox */
.modal-card-dm-popup.dm-popup-large,
.dm-popup-large .modal-card-dm-popup {
  width: min(720px, 96vw);
  max-height: 92vh;
  min-height: 600px;
}

#dm-popup-modal.dm-popup-large .modal-card-dm-popup {
  width: min(720px, 96vw);
  max-height: 92vh;
  min-height: 600px;
}

.dm-popup-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem 0.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.dm-popup-header .modal-title {
  flex: 1;
  font-size: 0.95rem;
}

.dm-popup-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.dm-popup-input {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}

.dm-popup-input textarea {
  flex: 1;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.85rem;
  font-family: var(--font);
  resize: vertical;
  min-height: 2.5rem;
}

.dm-popup-input textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* Messages inbox popup modal */
.modal-card-messages-popup {
  width: min(640px, 94vw);
  max-height: 90vh;
  min-height: 500px;
  display: flex;
  flex-direction: column;
}

.messages-popup-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem 0.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.messages-popup-header .modal-title {
  flex: 1;
}

.messages-popup-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.5rem 1rem;
}

.messages-popup-list .presence-recent-row {
  cursor: pointer;
}

/* Notes tile narrow (quarter/half) toolbar restructure:
   resizing buttons (layouts + remove) on top row,
   file/copy/date/lists/edit etc on bottom "toolbar" row.
*/
.dashboard-tile.notes-tile.tile-quarter .notes-tile-bar,
.dashboard-tile.notes-tile.tile-half .notes-tile-bar {
  flex-wrap: wrap;
  align-items: flex-start;
}
.dashboard-tile.notes-tile.tile-quarter .notes-tile-bar .notes-layout-top-row,
.dashboard-tile.notes-tile.tile-half .notes-tile-bar .notes-layout-top-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.2rem;
  width: 100%;
  padding-bottom: 0.15rem;
  margin-bottom: 0.15rem;
  border-bottom: 1px solid var(--border);
}
/* When the note name lives in the narrow top row (with layout buttons), keep it on the left */
.dashboard-tile.notes-tile .notes-layout-top-row .notes-tile-name {
  margin-right: auto;
  flex: 1 1 auto;
  min-width: 0;
}
.dashboard-tile.notes-tile.tile-quarter .notes-tile-bar .tile-layout-btns,
.dashboard-tile.notes-tile.tile-half .notes-tile-bar .tile-layout-btns {
  /* the group is moved into the top-row by JS */
}

.deal-edit-modal-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.deal-edit-modal-head .modal-title {
  margin: 0;
}

.deal-edit-crm-link {
  font-size: 0.75rem;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

.deal-edit-crm-link:hover {
  text-decoration: underline;
}

.modal-card-opp-preview {
  width: min(720px, 96vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}

.modal-card-opp-preview .modal-actions {
  padding-top: 0.75rem;
}

/* Changelog modal */
.modal-card-changelog {
  width: min(720px, 96vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}

.changelog-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
  flex-shrink: 0;
}

.changelog-version {
  font-size: 0.85rem;
  color: var(--muted);
  font-family: var(--font);
  font-weight: 500;
}

.changelog-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.5rem 0.75rem;
  background: var(--surface-2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  line-height: 1.55;
}

.changelog-body .notes-md-h1,
.changelog-body .notes-md-h2,
.changelog-body .notes-md-h3 {
  margin: 0.5rem 0 0.35rem;
  color: var(--text);
  font-family: var(--font);
  font-weight: 600;
}

.changelog-body .notes-md-h1 { font-size: 1.1rem; }
.changelog-body .notes-md-h2 { font-size: 0.95rem; }
.changelog-body .notes-md-h3 { font-size: 0.85rem; }

.changelog-body p {
  margin: 0.35rem 0;
  color: var(--text);
}

.changelog-body ul,
.changelog-body ol {
  margin: 0.35rem 0;
  padding-left: 1.25rem;
}

.changelog-body li {
  margin: 0.2rem 0;
}

.changelog-body a {
  color: var(--accent);
  text-decoration: underline;
}

.changelog-body code {
  background: rgba(255,255,255,0.08);
  padding: 0.1rem 0.25rem;
  border-radius: 4px;
  font-size: 0.78rem;
}

.changelog-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.5rem 0;
}

.modal-card-changelog .modal-actions {
  padding-top: 0.75rem;
  justify-content: flex-end;
}

.opp-preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
  flex-shrink: 0;
}

.opp-preview-head .modal-title {
  margin: 0;
  flex: 1;
  min-width: 0;
  line-height: 1.3;
  word-break: break-word;
}

.opp-preview-head-actions {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.opp-preview-edit-btn {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.opp-preview-edit-btn:hover,
.opp-preview-edit-btn:focus-visible {
  border-color: var(--accent);
  color: var(--text);
  background: var(--surface-2);
  outline: none;
}

.opp-preview-bookmark-btn {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.opp-preview-bookmark-btn:hover,
.opp-preview-bookmark-btn:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--surface-2);
  outline: none;
}

.opp-preview-bookmark-btn.bookmarked {
  color: var(--accent);
  border-color: var(--accent);
}

.opp-preview-bookmark-btn.bookmarked:hover {
  color: #ef4444;
  border-color: #ef4444;
}

.opp-preview-bookmark-btn .bookmark-ribbon-icon {
  width: 14px;
  height: 14px;
}

.opp-preview-refresh-btn {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  margin-right: 0.25rem;
}

.opp-preview-refresh-btn:hover,
.opp-preview-refresh-btn:focus-visible {
  border-color: var(--accent);
  color: var(--text);
  background: var(--surface-2);
  outline: none;
}

.opp-preview-open-crm {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  text-decoration: none;
}

.opp-preview-open-crm:hover,
.opp-preview-open-crm:focus {
  border-color: var(--accent);
  color: var(--accent);
  outline: none;
}

.opp-preview-body {
  flex: 1;
  min-height: 0;
  max-height: min(72vh, 640px);
  overflow-y: auto;
  padding-right: 0.15rem;
}

.opp-preview-loading,
.opp-preview-error {
  padding: 1rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.opp-preview-error {
  color: var(--danger, #c44);
}

.opp-preview-section {
  margin-bottom: 1.15rem;
}

.opp-preview-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.opp-preview-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.25rem 0.75rem;
  margin-bottom: -1px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.opp-preview-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.opp-preview-tab:hover:not(.active) {
  color: var(--text);
}

.opp-preview-section:last-child {
  margin-bottom: 0;
}

.opp-preview-section-title {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.field-value-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.15rem 0.55rem;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  line-height: 1.4;
  width: fit-content;
}

.field-value-tag.tag-amber {
  color: var(--warn);
  border-color: var(--warn);
  background: rgba(240, 180, 41, 0.12);
}

.opp-preview-fields {
  display: grid;
  gap: 0.5rem 1rem;
  margin: 0;
}

.opp-preview-field {
  display: grid;
  grid-template-columns: minmax(7rem, 34%) 1fr;
  gap: 0.35rem 0.75rem;
  padding: 0.5rem 0.7rem;
  font-size: 0.84rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.opp-preview-field dt {
  margin: 0;
  font-weight: 600;
  color: var(--muted);
}

.opp-preview-field dd {
  margin: 0;
  color: var(--text);
  word-break: break-word;
}

.opp-preview-description {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

.opp-preview-history {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.opp-preview-history-item {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}

.opp-preview-history-row {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
}

.opp-preview-history-main {
  flex: 1;
  min-width: 0;
}

.opp-preview-history-attachments {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
  max-width: 42%;
  text-align: right;
}

.opp-preview-attachment-link {
  font-size: 0.68rem;
  line-height: 1.25;
  color: inherit;
  text-decoration: none;
  word-break: break-all;
  max-width: 11rem;
}

.opp-preview-attachment-link:hover,
.opp-preview-attachment-link:focus {
  color: inherit;
  text-decoration: underline;
  outline: none;
}

.opp-preview-history-item:last-child {
  border-bottom: none;
}

.opp-preview-history-meta-row {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  margin-bottom: 0.3rem;
}

.opp-preview-history-type-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.05rem;
  color: var(--muted);
  opacity: 0.72;
}

.opp-preview-history-type-icon svg {
  display: block;
}

.opp-preview-history-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem 0.35rem;
  min-width: 0;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.35;
}

.opp-preview-history-meta-sep {
  opacity: 0.65;
}

.opp-preview-history-meta-author-line {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem;
  min-width: 0;
}

.opp-preview-history-meta-author {
  color: var(--muted);
}

.opp-preview-history-meta-when {
  font-size: 0.7rem;
  color: var(--muted);
  opacity: 0.9;
  white-space: nowrap;
}

.opp-preview-history-delete {
  margin-left: auto;
  font-size: 0.85rem;
  padding: 0 0.15rem;
  line-height: 1;
  color: var(--muted);
  opacity: 0.45;
  background: transparent;
  border: 0;
  cursor: pointer;
  flex-shrink: 0;
}
.opp-preview-history-delete:hover {
  opacity: 1;
  color: #dc2626;
}

.opp-preview-history-body {
  margin: 0;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

.opp-preview-mail-summary {
  margin: 0 0 0.35rem;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--text);
}

.opp-preview-note-toggle {
  margin: 0 0 0.35rem;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.opp-preview-note-toggle:hover,
.opp-preview-note-toggle:focus {
  border-color: var(--accent);
  color: var(--accent);
  outline: none;
}

.opp-preview-note-detail[hidden],
.opp-preview-note-detail.hidden {
  display: none !important;
}

.opp-preview-mail-embed[hidden],
.opp-preview-mail-embed.hidden {
  display: none !important;
}

.opp-preview-note-detail.opp-preview-history-body--html {
  max-height: 220px;
  overflow: auto;
  margin-top: 0.25rem;
  padding: 0.35rem 0.45rem;
  border: 1px dashed var(--border);
  border-radius: 6px;
  font-size: 0.78rem;
}

.opp-preview-history-body--collapsed-mail .opp-preview-mail-summary {
  color: var(--muted);
}

.opp-preview-history-body--html {
  white-space: normal;
  max-height: 280px;
  overflow: auto;
}

.opp-preview-history-body--html p {
  margin: 0 0 0.45rem;
}

.opp-preview-history-body--html p:last-child {
  margin-bottom: 0;
}

.opp-preview-history-body--html a {
  color: inherit;
}
.opp-preview-body a,
.opp-preview-body a:visited,
.preview-link {
  color: inherit;
}

.opp-preview-history-body--html ul,
.opp-preview-history-body--html ol {
  margin: 0.25rem 0 0.45rem 1.1rem;
  padding: 0;
}

.opp-preview-mail-toggle {
  margin-top: 0.4rem;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.opp-preview-mail-toggle:hover,
.opp-preview-mail-toggle:focus {
  border-color: var(--accent);
  color: inherit;
  outline: none;
}

.opp-preview-mail-embed {
  width: 100%;
  box-sizing: border-box;
  margin-top: 0.45rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 0.5rem 0.6rem;
}

/* Expanded linked email in deal preview / bookmark preview spans full history-item width */
.opp-preview-history-item > .opp-preview-mail-embed {
  width: 100%;
  box-sizing: border-box;
}

.opp-preview-history-body--mail-received .opp-preview-mail-summary {
  color: var(--text);
}



.opp-preview-mail-head {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
  line-height: 1.35;
}

.opp-preview-mail-head strong {
  display: block;
  color: var(--text);
  font-size: 0.82rem;
  margin-bottom: 0.15rem;
}

.opp-preview-mail-body {
  width: 100%;
  box-sizing: border-box;
  max-height: min(70vh, 560px);
  overflow: auto;
  border: 1px solid #2a3142;
  border-radius: 6px;
  background: #181b24;
}

.opp-preview-mail-iframe {
  display: block;
  width: 100%;
  min-height: 240px;
  height: 360px;
  border: none;
  background: #181b24;
}

.opp-preview-mail-text {
  margin: 0;
  padding: 0.65rem;
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  color: #e8ecf4;
  background: transparent;
}

.opp-preview-mail-foot {
  margin-top: 0.35rem;
  font-size: 0.72rem;
}

.opp-preview-mail-foot a,
.opp-preview-mail-fallback {
  color: inherit;
}

.opp-preview-mail-loading,
.opp-preview-mail-error {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.opp-preview-mail-error {
  color: var(--danger, #b33);
}

.opp-preview-empty {
  margin: 0;
  font-size: 0.84rem;
  color: var(--muted);
}

.opp-preview-documents {
  list-style: none;
  padding: 0;
  margin: 0;
}
.opp-preview-documents li {
  margin: 0.25rem 0;
  display: flex;
  align-items: center;
  gap: 0.25em;
}
.opp-preview-documents a {
  text-decoration: none;
  color: inherit;
}
.opp-preview-documents a:hover {
  text-decoration: underline;
}

.deal-edit-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-height: 1.5rem;
}

.deal-edit-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

.deal-edit-tag-remove {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0 0.1rem;
  font-size: 0.9rem;
  line-height: 1;
  opacity: 0.7;
}

.deal-edit-tag-remove:hover {
  opacity: 1;
}

.deal-edit-tag-add {
  margin-top: 0.4rem;
}

.deal-edit-tag-add select {
  width: 100%;
  font-size: 0.85rem;
}

.deal-edit-note-fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.75rem 0.25rem;
  margin: 0.5rem 0 0;
}

.deal-edit-note-legend {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0 0.25rem;
}

.field-optional {
  font-weight: 400;
  color: var(--muted);
}

/* Add tile modal */
.modal-card-add-tile {
  width: min(480px, 100%);
}

.add-tile-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1rem 0 1.25rem;
}

.add-tile-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  text-align: left;
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.add-tile-option:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.add-tile-option-title {
  font-weight: 700;
  font-size: 0.95rem;
}

.add-tile-option-desc {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}

.add-tile-calendar-form {
  margin-top: 0.5rem;
}

.add-tile-calendar-form .field input[type="url"] {
  width: 100%;
  font-size: 0.82rem;
}

/* Calendar tile (monthly) */
.dashboard-tile.calendar-tile {
  min-height: var(--tile-row-height);
}

.dashboard-tile.calendar-tile .calendar-month-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0.65rem 0.85rem 1rem;
}

.dashboard-tile.calendar-tile.tile-double .calendar-month-body {
  max-height: none;
}

.dashboard-tile.calendar-tile.tile-double {
  min-height: calc(var(--tile-row-height) * 2 + 1.25rem);
}

/* Double height: scale calendar content vertically instead of adding empty space below fixed min-heights */
.dashboard-tile.calendar-tile.tile-double .calendar-month-body {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.dashboard-tile.calendar-tile.tile-double .calendar-month-grid {
  flex: 1;
  min-height: 0;
}
.dashboard-tile.calendar-tile.tile-double .calendar-day {
  min-height: 7.5rem; /* grow days for extra vertical space in double tiles */
}

/* Collapsed notes/calendar must actually shrink (their min-height rules override the
   generic .tile-body-collapsed { min-height:0 } due to later cascade). */
.dashboard-tile.calendar-tile.tile-body-collapsed,
.dashboard-tile.notes-tile.tile-body-collapsed {
  min-height: 0 !important;
  height: auto;
}

.calendar-tile-bar .calendar-month-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.35rem;
}

.calendar-tz-label {
  display: inline-flex;
  align-items: center;
  margin-left: 0.35rem;
  flex-shrink: 1;
  min-width: 0;
  max-width: 11rem;
}

.calendar-tz-select {
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  max-width: 100%;
  padding: 0.2rem 0.35rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.calendar-tz-select:hover,
.calendar-tz-select:focus {
  border-color: var(--accent);
  outline: none;
}

.calendar-month-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  min-width: 7.5rem;
  text-align: center;
}

.btn-calendar-nav {
  padding: 0.15rem 0.45rem;
  font-size: 1.1rem;
  line-height: 1;
}

.calendar-month-grid {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.calendar-weekdays,
.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
}

.calendar-weekday {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-align: center;
  padding: 0.2rem 0;
}

.calendar-day {
  min-height: 4.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  padding: 0.2rem 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  overflow: hidden;
}

.calendar-day-outside {
  opacity: 0.45;
}

.calendar-day-today .calendar-day-num {
  color: var(--accent);
  font-weight: 700;
}

.calendar-day-num {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  flex-shrink: 0;
}

.calendar-day-events {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  overflow: hidden;
}

.calendar-event-chip {
  display: flex;
  align-items: flex-start;
  gap: 0.2rem;
  font-family: inherit;
  font-weight: inherit;
  font-size: 0.62rem;
  line-height: 1.25;
  padding: 0.1rem 0.2rem;
  border-radius: 4px;
  background: color-mix(in srgb, var(--event-color) 22%, transparent);
  border-left: 3px solid var(--event-color);
  color: var(--text);
  min-width: 0;
  width: 100%;
  margin: 0;
  border-top: none;
  border-right: none;
  border-bottom: none;
  text-align: left;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.calendar-event-chip .calendar-event-label {
  font-size: inherit;
  line-height: inherit;
}

.calendar-event-chip:hover {
  background: color-mix(in srgb, var(--event-color) 35%, transparent);
}

.modal-card-calendar-event {
  width: min(520px, 100%);
}

.calendar-event-modal-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 0.45rem;
  vertical-align: middle;
}

.calendar-event-modal-body {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin: 0.75rem 0 1rem;
  max-height: min(60vh, 420px);
  overflow: auto;
}

.calendar-event-detail-row {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr);
  gap: 0.5rem 0.75rem;
  align-items: start;
}

.calendar-event-detail-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.calendar-event-detail-value {
  font-size: 0.88rem;
  color: var(--text);
  word-break: break-word;
}

.calendar-event-detail-value a {
  color: var(--accent);
}

.calendar-event-detail-desc-text {
  white-space: pre-wrap;
  line-height: 1.45;
}

.calendar-event-detail-empty {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0;
}

/* Notes / to-do tile */
.dashboard-tile.notes-tile {
  min-height: var(--tile-row-height);
}

.dashboard-tile.notes-tile[data-accent] .notes-tile-body {
  border-left: 3px solid var(--notes-accent, var(--accent));
  padding-left: 0.6rem;
}

.dashboard-tile.notes-tile .notes-tile-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0.65rem 0.85rem 1rem;
  overflow: hidden;
}

.dashboard-tile.notes-tile.tile-double .notes-tile-body {
  min-height: calc(var(--tile-row-height) * 2 - 100px);
}

.dashboard-tile.notes-tile.tile-quarter .notes-tile-name {
  max-width: 5.5rem;
}

.dashboard-tile.notes-tile.tile-quarter .notes-tile-utils .btn-notes-pin,
.dashboard-tile.notes-tile.tile-quarter .notes-tile-utils .btn-notes-print,
.dashboard-tile.notes-tile.tile-quarter .notes-tile-utils .btn-notes-accent-select,
.dashboard-tile.notes-tile.tile-quarter .notes-accent-select {
  display: none;
}

.dashboard-tile.notes-tile.tile-quarter .notes-tile-utils {
  gap: 0.1rem;
}

/* Ensure notes and calendar tiles actually shrink when collapsed (their specific min-height
   rules were overriding the general .tile-body-collapsed min-height:0) */
.dashboard-tile.calendar-tile.tile-body-collapsed,
.dashboard-tile.notes-tile.tile-body-collapsed {
  min-height: 0 !important;
  height: auto;
}

.notes-editor {
  flex: 1;
  min-height: 12rem;
  width: 100%;
  resize: vertical;
  font: inherit;
  font-size: 0.88rem;
  line-height: 1.5;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

.notes-editor:focus {
  outline: none;
  border-color: var(--accent);
}



.notes-preview {
  flex: 1;
  min-height: 12rem;
  overflow: auto;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 0.88rem;
  line-height: 1.5;
}

.notes-preview.hidden,
.notes-editor.hidden {
  display: none !important;
}

.notes-md-h1,
.notes-md-h2,
.notes-md-h3 {
  margin: 0.5rem 0 0.35rem;
  line-height: 1.25;
}

.notes-md-h1 {
  font-size: 1.15rem;
}

.notes-md-h2 {
  font-size: 1rem;
}

.notes-md-h3 {
  font-size: 0.92rem;
}

.notes-preview p {
  margin: 0.35rem 0;
}

.notes-md-list {
  margin: 0.35rem 0 0.35rem 1.1rem;
  padding: 0;
}

.notes-md-quote {
  margin: 0.35rem 0;
  padding: 0.35rem 0.65rem;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}

.notes-preview code {
  font-size: 0.82em;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  background: var(--bg);
}

.notes-preview a {
  color: var(--accent);
}

.notes-preview u {
  text-decoration: underline;
}

.notes-preview mark {
  background-color: rgba(255, 235, 59, 0.35);
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}

.notes-preview del {
  opacity: 0.65;
  text-decoration: line-through;
}

.notes-md-empty {
  color: var(--muted);
  font-style: italic;
}

.notes-tile-bar {
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
}

.notes-tile-utils {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem;
  margin-left: auto;
}

.notes-tile-utils .btn-notes-mode {
  font-size: 0.68rem;
  padding: 0.12rem 0.35rem;
}

.notes-tile-utils .tile-menu-trigger {
  font-size: 0.68rem;
}

/* Tight group for the bullet + numbered list buttons: right next to each other,
   with a subtle box + shadow to make them obviously clickable buttons.
   Reduced side padding as requested. */
.notes-list-btns {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem; /* a little more padding between the bullet and numbered icons */
  padding: 1px;
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  background: var(--surface-2);
  margin: 0 0.05rem; /* minimal external side space, shrunk */
}
.notes-list-btns .btn-notes-bullet,
.notes-list-btns .btn-notes-numbered {
  font-size: 0.75rem;
  line-height: 1;
  padding: 0.2rem 0.3rem; /* more side padding + height to match neighboring icons */
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  min-width: 1.1em;
  text-align: center;
}
.notes-list-btns .btn-notes-bullet:hover,
.notes-list-btns .btn-notes-numbered:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.04);
}
.notes-list-btns .btn-notes-bullet + .btn-notes-numbered {
  border-left: 1px solid var(--border);
}

/* Formatting buttons (bold/italic/underline etc) grouped next to lists buttons */
.notes-format-btns {
  display: inline-flex;
  align-items: center;
  gap: 0.1rem;
  padding: 1px;
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  background: var(--surface-2);
  margin: 0 0.05rem;
}
.notes-format-btns .btn-notes-bold,
.notes-format-btns .btn-notes-italic,
.notes-format-btns .btn-notes-strike,
.notes-format-btns .btn-notes-underline,
.notes-format-btns .btn-notes-highlight,
.notes-format-btns .btn-notes-quote,
.notes-format-btns .btn-notes-code {
  font-size: 0.7rem;
  line-height: 1;
  padding: 0.15rem 0.25rem;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  min-width: 1em;
  text-align: center;
  font-family: ui-monospace, monospace;
}
.notes-format-btns .btn-notes-bold:hover,
.notes-format-btns .btn-notes-italic:hover,
.notes-format-btns .btn-notes-strike:hover,
.notes-format-btns .btn-notes-underline:hover,
.notes-format-btns .btn-notes-highlight:hover,
.notes-format-btns .btn-notes-quote:hover,
.notes-format-btns .btn-notes-code:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.04);
}
.notes-format-btns .btn-notes-bold + .btn-notes-italic,
.notes-format-btns .btn-notes-italic + .btn-notes-strike,
.notes-format-btns .btn-notes-strike + .btn-notes-underline,
.notes-format-btns .btn-notes-underline + .btn-notes-highlight,
.notes-format-btns .btn-notes-highlight + .btn-notes-quote,
.notes-format-btns .btn-notes-quote + .btn-notes-code {
  border-left: 1px solid var(--border);
}

.notes-tile-bar .btn-remove-notes {
  flex-shrink: 0;
}

/* Hide the printer button (does not appear to work) */
.notes-tile-utils .btn-notes-print,
.btn-notes-print {
  display: none !important;
}

.modal-card-notes-archive {
  max-width: 420px;
}

.notes-archive-restore-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  max-height: 280px;
  overflow-y: auto;
}

.notes-archive-restore-item {
  border-bottom: 1px solid var(--border);
}

.notes-archive-restore-pick {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  width: 100%;
  padding: 0.65rem 0.5rem;
  border: none;
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: var(--text);
}

.notes-archive-restore-pick:hover {
  background: var(--surface-2);
}

.notes-archive-restore-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.notes-archive-restore-date {
  font-size: 0.78rem;
  color: var(--muted);
}

.notes-archive-restore-empty {
  padding: 0.75rem 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.notes-accent-select {
  font-size: 0.65rem;
  padding: 0.1rem 0.25rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  max-width: 5.5rem;
}

.btn-notes-pin.tile-btn-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.notes-md-hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.65rem 0;
}

.notes-md-checklist {
  list-style: none;
  margin: 0.35rem 0;
  padding: 0;
}

.notes-md-check-label {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  cursor: pointer;
}

.notes-md-check-input {
  margin-top: 0.2rem;
  flex-shrink: 0;
}

.notes-md-check-text del {
  opacity: 0.7;
}

.notes-preview del {
  opacity: 0.72;
}

.notes-tile-footer {
  flex-shrink: 0;
  margin-top: 0.45rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.35rem;
}

.notes-stats-label,
.notes-updated-label {
  font-size: 0.65rem;
  color: var(--muted);
  cursor: default;
}

.notes-tile-footer:hover .notes-updated-label {
  color: var(--text);
}

.calendar-event-attendees {
  line-height: 1.4;
}

.calendar-event-detail-uid {
  margin: 0.75rem 0 0;
  font-size: 0.65rem;
  color: var(--muted);
  word-break: break-all;
}

.notes-tile-bar .btn-notes-copy {
  flex-shrink: 0;
}

.notes-tile-bar .btn-notes-mode.tile-btn-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.add-tile-notes-form {
  margin-top: 0.5rem;
}

.add-tile-notes-option {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.5rem 0;
  font-size: 0.82rem;
  color: var(--text);
}

.add-tile-notes-archived-wrap {
  margin-top: 0.65rem;
}

.add-tile-notes-archived-list {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0;
}

.add-tile-notes-archived-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.3rem 0;
  font-size: 0.8rem;
  border-bottom: 1px solid var(--border);
}

.add-tile-notes-archived-item:last-child {
  border-bottom: none;
}

.btn-notes-restore {
  font-size: 0.72rem;
  padding: 0.15rem 0.4rem;
  flex-shrink: 0;
}

.calendar-event-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--event-color);
  flex-shrink: 0;
  margin-top: 0.15rem;
}

.calendar-event-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.calendar-more-events {
  font-size: 0.6rem;
  color: var(--muted);
  padding-left: 0.15rem;
}

.calendar-loading-hint,
.calendar-error {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.5rem 0;
}

.dashboard-tile.calendar-loading .calendar-month-body {
  opacity: 0.55;
}

.field-hint {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.7rem;
  color: var(--muted);
}

.deal-edit-attach-hint {
  margin-top: 0.35rem;
  font-size: 0.65rem;
  font-style: italic;
  opacity: 0.85;
}

.modal-error.hidden {
  display: none;
}

.tile-toolbar .btn-new-task {
  font-size: 0.72rem;
  padding: 0.3rem 0.65rem;
  flex-shrink: 0;
}

.tile-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.35rem;
  line-height: 0;
  flex-shrink: 0;
}

/* Hide the pin button for now (completely broken on the top tiles) */
.tile-pin-btn {
  display: none !important;
}

.btn-tile-refresh {
  margin-left: 0.1rem;
  color: var(--muted);
}

.btn-tile-refresh:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent);
}

.btn-tile-refresh:disabled {
  opacity: 0.55;
  cursor: wait;
}

.btn-tile-refresh.is-refreshing .tile-refresh-icon {
  animation: tile-refresh-spin 0.75s linear infinite;
}

.tile-layout-icon {
  display: block;
}

@keyframes tile-refresh-spin {
  to {
    transform: rotate(360deg);
  }
}

.opportunity-picker-field {
  position: relative;
}

@media (max-width: 640px) {
  .hero-sign-out {
    top: 0.65rem;
    right: 1rem;
    font-size: 0.8rem;
    padding: 0.35rem 0.55rem;
  }

  .hero-logo {
    width: 64px;
  }

  .hero-inner {
    padding: 1.5rem 1rem 1rem;
    padding-top: 2.75rem;
    flex-wrap: wrap;
  }

  .hero-actions {
    flex-wrap: wrap;
    width: 100%;
    justify-content: flex-end;
  }

  .global-opp-search {
    flex: 1 1 100%;
    order: -1;
  }

  .global-opp-search-input {
    width: 100%;
  }

  .global-opp-search-results {
    left: 0;
    right: 0;
    width: auto;
  }

  .dashboard-tiles {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  .board-group .board {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  .column {
    flex: 0 0 260px;
  }

  .daily-focus {
    flex-wrap: wrap;
    white-space: normal;
    overflow: visible;
    max-width: 100%;
  }
  .daily-focus-quote {
    white-space: normal;
    overflow: visible;
  }
}

/* Mail attachments shown inside expanded email panel */
.mail-attachments-panel {
  padding: 6px 8px;
  font-size: 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.mail-attachments-panel .mail-attachment-link {
  padding: 1px 4px;
  margin: 0 2px;
  border: 1px solid var(--border);
  border-radius: 3px;
  white-space: nowrap;
  display: inline-block;
}
.mail-attachments-panel .mail-attachment-link a {
  color: var(--accent);
  text-decoration: underline;
  font-size: 11px;
}
.mail-attachments-panel .mail-attachment-link a:hover {
  text-decoration: underline;
}

/* ================================================================================
   Search popup modal — large search with tabbed preview (max 5 tabs)
   ================================================================================ */

.modal-card-search-popup {
  width: min(900px, 96vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.search-popup-tabs {
  display: flex;
  gap: 0.35rem;
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0.75rem 0;
  flex-shrink: 0;
  overflow-x: hidden;
  background: var(--surface);
  flex-wrap: nowrap;
}

.search-popup-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 1;
  min-width: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
  position: relative;
  overflow: hidden;
}

.search-popup-tab.active {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
  border-bottom: 1px solid var(--surface);
  font-weight: 600;
  z-index: 1;
  flex-shrink: 0;
}

.search-popup-tab:hover:not(.active) {
  color: var(--text);
  background: var(--surface-3, var(--surface-2));
  border-color: var(--border);
}

.search-popup-tab-search {
  border-left: 3px solid var(--accent);
  padding-left: 0.6rem;
  flex-shrink: 0;
}

.search-popup-tab-title {
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.search-popup-tab-close {
  margin-left: 0.25rem;
  font-size: 1rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0 0.15rem;
  border-radius: 3px;
  flex-shrink: 0;
}

.search-popup-tab-close:hover {
  color: var(--text);
  background: var(--surface-2);
}

/* Content wrapper: holds both search tab and preview containers */
#search-popup-preview-containers {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.search-popup-tab-content {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: none;
}

.search-popup-tab-content.active {
  display: flex;
  flex-direction: column;
}

/* Search tab specific */
.search-popup-tab-content[data-tab-content="search"] {
  display: none;
}

.search-popup-tab-content[data-tab-content="search"].active {
  display: flex;
  flex-direction: column;
}

/* Ensure preview container fills the tab content */
.search-popup-tab-content.active .search-popup-preview-container {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Search tab */
.search-popup-input-wrap {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.search-popup-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.95rem;
  font-family: var(--font);
}

.search-popup-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.search-popup-tag-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.search-popup-tag-select {
  flex: 1;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.85rem;
  font-family: var(--font);
  cursor: pointer;
}

.search-popup-tag-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.search-popup-results {
  flex: 1;
  min-height: 0;
  padding: 0.5rem 1rem;
  overflow-y: auto;
}

.search-popup-results-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.25rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
}

.search-popup-results-header-label {
  font-weight: 500;
}

.search-popup-results-header-tag {
  font-weight: 600;
  color: var(--accent);
  background: var(--surface-2);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

.search-popup-results-header-count {
  margin-left: auto;
  font-size: 0.8rem;
}

.search-popup-results-empty {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 1rem 0;
  text-align: center;
}

.search-popup-export-bar {
  display: flex;
  justify-content: flex-end;
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
}
.search-popup-export-bar .btn {
  font-size: 0.8rem;
}

.search-popup-error {
  padding: 0.75rem 1rem;
  margin: 0.5rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--warn, #f0b429);
  font-size: 0.9rem;
  text-align: center;
  font-weight: 500;
}

.search-popup-error.hidden {
  display: none;
}

/* Result rows */
.search-popup-result-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius);
  transition: background 0.15s;
  cursor: default;
}

.search-popup-result-row:hover {
  background: var(--surface-2);
}

.search-popup-result-title {
  font-weight: 600;
  flex-shrink: 0;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.search-popup-result-meta {
  color: var(--muted);
  font-size: 0.8rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-popup-result-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.search-popup-result-actions .btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  min-height: 1.6rem;
}

.search-popup-result-bookmark {
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.search-popup-result-bookmark:hover {
  color: var(--accent);
  background: var(--surface-2);
}
.search-popup-result-bookmark.bookmarked {
  color: var(--accent);
}
.search-popup-result-bookmark.bookmarked:hover {
  color: #ef4444;
}

/* Preview tab */
.search-popup-preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
  flex-shrink: 0;
}

.search-popup-preview-title {
  margin: 0;
  font-size: 1rem;
  flex: 1;
  word-break: break-word;
  line-height: 1.3;
}

.search-popup-preview-actions {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.search-popup-preview-refresh {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  margin-right: 0.25rem;
}

.search-popup-preview-refresh:hover,
.search-popup-preview-refresh:focus-visible {
  border-color: var(--accent);
  color: var(--text);
  background: var(--surface-2);
  outline: none;
}

.search-popup-preview-edit {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.search-popup-preview-edit:hover,
.search-popup-preview-edit:focus-visible {
  border-color: var(--accent);
  color: var(--text);
  background: var(--surface-2);
  outline: none;
}

.search-popup-preview-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.15rem;
}

/* Preview tab container (flex wrapper for each tab) */
.search-popup-preview-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 0.75rem 1rem;
  overflow: hidden;
}

/* ================================================================================
   Bookmark ribbon button on search popup preview
   ================================================================================ */

.search-popup-preview-bookmark {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.search-popup-preview-bookmark:hover,
.search-popup-preview-bookmark:focus-visible {
  border-color: var(--accent);
  color: var(--text);
  background: var(--surface-2);
  outline: none;
}

.search-popup-preview-bookmark.bookmarked {
  color: var(--accent);
}

.search-popup-preview-bookmark.bookmarked:hover {
  color: #ef4444;
  border-color: #ef4444;
}

/* ================================================================================
   Bookmark ribbon button on deal tiles
   ================================================================================ */

.card-bookmark-btn {
  position: absolute;
  bottom: 0.3rem;
  right: 0.75rem;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  z-index: 1;
}

.card-bookmark-btn:hover,
.card-bookmark-btn:focus-visible {
  color: var(--accent);
  background: var(--surface-2);
  outline: none;
}

.card-bookmark-btn.bookmarked {
  color: var(--accent);
}

.card-bookmark-btn.bookmarked:hover {
  color: #ef4444;
}

/* ================================================================================
   Bookmark trigger tab — rounded pill on right edge when sidebar is hidden
   ================================================================================ */

.bookmark-trigger {
  position: fixed;
  top: 33%;
  right: 0;
  transform: translateY(-50%);
  z-index: 1499;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.7rem 0.4rem;
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 8px 0 0 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.62rem;
  font-weight: 600;
  line-height: 1.2;
  transition: color 0.15s, background 0.15s, opacity 0.2s, transform 0.2s;
  box-shadow: -2px 0 8px rgba(0,0,0,0.08);
}

.bookmark-trigger-text {
  writing-mode: vertical-lr;
  text-orientation: upright;
  text-transform: uppercase;
  letter-spacing: -0.15em;
  font-size: 0.55rem;
  font-weight: 700;
}

.bookmark-trigger:hover,
.bookmark-trigger:focus-visible {
  color: var(--accent);
  background: var(--surface-2);
  outline: none;
}

/* When sidebar is visible, hide the trigger */
.bookmark-sidebar:not(.sidebar-hidden) ~ .bookmark-trigger,
.bookmark-sidebar:not(.sidebar-hidden) + .bookmark-trigger {
  /* Can't use sibling selector since trigger is before sidebar in DOM.
     Handled via JS by toggling .trigger-hidden class. */
}

.bookmark-trigger.trigger-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) translateX(10px);
}

/* ================================================================================
   Bookmark sidebar — slides in from right
   ================================================================================ */

.bookmark-preview-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 1499;
  transition: opacity 0.25s ease;
}
.bookmark-preview-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}

.bookmark-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  z-index: 1500;
  display: flex;
  flex-direction: row;
  transition: transform 0.25s ease;
  overflow: hidden;
  pointer-events: none;
}

.bookmark-sidebar.sidebar-hidden {
  transform: translateX(100%);
}

.bookmark-sidebar:not(.sidebar-hidden) {
  transform: translateX(0);
}

.bookmark-sidebar-strip {
  width: 220px;
  min-width: 220px;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
  pointer-events: auto;
  overflow: hidden;
}

.bookmark-sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.5rem 0.35rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.bookmark-sidebar-toggle {
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}

.bookmark-sidebar-toggle:hover,
.bookmark-sidebar-toggle:focus-visible {
  color: var(--text);
  background: var(--surface-2);
  outline: none;
}

.bookmark-sidebar-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bookmark-sidebar-tabs {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0.25rem 0;
}

.bookmark-tabs-empty {
  padding: 1rem 0.65rem;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.4;
}

/* Individual tab button */
.bookmark-tab {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  padding: 0.4rem 0.5rem 0.4rem 0.65rem;
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, border-color 0.12s;
  position: relative;
  min-height: 0;
  gap: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  margin-bottom: 4px;
  border-radius: 6px;
}

/* High Priority tag highlight on bookmark tabs */
.bookmark-tab--high-priority {
  background: rgba(240, 180, 41, 0.08);
  border-color: var(--warn);
  border-left: 3px solid var(--warn);
}

.bookmark-tab:hover {
  background: var(--surface-2);
}

.bookmark-tab.active {
  background: var(--surface-2);
  border-left-color: var(--accent);
}

.bookmark-tab-icon {
  position: absolute;
  top: 0.4rem;
  right: 0.5rem;
  color: var(--accent);
  opacity: 0.7;
  flex-shrink: 0;
  cursor: pointer;
  transition: opacity 0.12s;
  pointer-events: auto;
}
.bookmark-tab-icon:hover {
  opacity: 1;
  color: #ef4444;
}

.bookmark-tab-stage-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-right: 0.35rem;
  vertical-align: middle;
}

.bookmark-tab-title {
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  padding-right: 1.25rem;
}

.bookmark-tab-meta {
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.3;
  margin-top: 0.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 1.25rem;
}

.bookmark-tab-dragging {
  opacity: 0.4;
}

.bookmark-tab-drag-over {
  border-top: 2px solid var(--accent) !important;
  border-left-color: var(--accent) !important;
  background: var(--surface-2);
}

/* Expanded preview panel */
.bookmark-sidebar-preview {
  width: 880px;
  min-width: 880px;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  pointer-events: auto;
  overflow: hidden;
}

.bookmark-sidebar-preview.hidden {
  display: none;
}

.bookmark-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.bookmark-preview-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bookmark-preview-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.bookmark-preview-action-btn {
  width: 1.85rem;
  height: 1.85rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.bookmark-preview-action-btn:hover,
.bookmark-preview-action-btn:focus-visible {
  border-color: var(--accent);
  color: var(--text);
  background: var(--surface-2);
  outline: none;
}

#bookmark-preview-unbookmark {
  color: var(--accent);
}

#bookmark-preview-unbookmark:hover {
  color: #ef4444;
  border-color: #ef4444;
}

.bookmark-preview-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.65rem 0.85rem;
}

.bookmark-preview-body .opp-preview-tabs {
  margin-top: 0;
}

/* Responsive: narrow screen — reduce sidebar widths */
@media (max-width: 1400px) {
  .bookmark-sidebar-preview {
    width: 600px;
    min-width: 600px;
  }
}

@media (max-width: 1100px) {
  .bookmark-sidebar-strip {
    width: 170px;
    min-width: 170px;
  }
  .bookmark-sidebar-preview {
    width: 420px;
    min-width: 420px;
  }
}

@media (max-width: 768px) {
  .bookmark-sidebar-strip {
    width: 140px;
    min-width: 140px;
  }
  .bookmark-sidebar-preview {
    width: calc(100vw - 160px);
    min-width: 260px;
  }

  /* When a bookmark preview is open on mobile, hide the tab strip and let the preview fill the screen */
  .bookmark-sidebar.mobile-preview-open .bookmark-sidebar-strip {
    display: none;
  }
  .bookmark-sidebar.mobile-preview-open .bookmark-sidebar-preview {
    width: 100vw;
    min-width: 100vw;
    border-right: none;
  }
}

/* ================================================================================
   Event log modal
   ================================================================================ */

.event-log-btn {
  z-index: 3;
}

.event-log-list {
  max-height: 60vh;
  overflow-y: auto;
  font-size: 0.82rem;
  line-height: 1.4;
}

.event-log-entry {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

.event-log-entry:last-child {
  border-bottom: none;
}

.event-log-entry-icon {
  flex-shrink: 0;
  width: 1.3rem;
  text-align: center;
  font-size: 0.9rem;
}

.event-log-entry-body {
  flex: 1;
  min-width: 0;
}

.event-log-entry-opp {
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--text);
}

.event-log-entry-msg {
  color: var(--muted);
  font-size: 0.76rem;
  word-break: break-word;
}

.event-log-entry-time {
  flex-shrink: 0;
  font-size: 0.7rem;
  color: var(--muted);
  white-space: nowrap;
}

.event-log-entry.success .event-log-entry-icon {
  color: #166534;
}

.event-log-entry.fail .event-log-entry-icon {
  color: #9f1239;
}

.event-log-empty {
  padding: 2rem;
  text-align: center;
  color: var(--muted);
  font-style: italic;
}

