/* Nexaminds CRM primitives in the monday / Vibe style (spec §3). Tokens come from ui/tokens.css.
   Loaded after the older stylesheets, so these rules win where both style the same class. */

/* ---------- 3.1 Buttons ---------- */
.button { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-8); height: 32px; min-height: 32px;
  padding: var(--space-4) var(--space-8); border: 1px solid transparent; border-radius: var(--border-radius-small);
  font: 400 13px/22px var(--font-family); white-space: nowrap; cursor: pointer; box-shadow: none; text-decoration: none;
  transition: background-color var(--motion-productive-short) var(--motion-timing-transition), border-color var(--motion-productive-short) var(--motion-timing-transition), transform var(--motion-productive-short) var(--motion-timing-transition); }
.button:active:not(:disabled) { transform: scale(.95); }
.button svg.icon { width: 20px; height: 20px; }
.button.xs { height: 24px; min-height: 24px; padding: var(--space-4) var(--space-8); font-size: 13px; line-height: 16px; gap: var(--space-4); }
.button.xs svg.icon { width: 16px; height: 16px; }
.button.medium { height: 40px; min-height: 40px; padding: var(--space-8) var(--space-16); font: var(--font-text1-normal); }
.button.large { height: 48px; min-height: 48px; padding: var(--space-12) var(--space-24); font: var(--font-text1-normal); }
.button.primary { background: var(--primary-color); border-color: var(--primary-color); color: var(--text-color-on-primary); }
.button.primary:hover:not(:disabled) { background: var(--primary-hover-color); border-color: var(--primary-hover-color); }
.button.secondary { background: transparent; border-color: var(--ui-border-color); color: var(--primary-text-color); }
.button.secondary:hover:not(:disabled) { background: var(--primary-background-hover-color); border-color: var(--ui-border-color); }
.button.secondary.selected, .button.secondary[aria-expanded="true"] { background: var(--primary-selected-color); border-color: var(--primary-color); }
.button.tertiary { background: transparent; border-color: transparent; color: var(--primary-text-color); }
.button.tertiary svg.icon { color: var(--primary-text-color); }
.button.tertiary:hover:not(:disabled) { background: var(--primary-background-hover-color); }
.button.tertiary.selected, .button.tertiary[aria-expanded="true"], details[open] > summary.button.tertiary { background: var(--primary-selected-color); }
.button.positive { background: var(--positive-color); border-color: var(--positive-color); color: var(--text-color-on-primary); }
.button.positive:hover:not(:disabled) { background: var(--positive-color-hover); }
.button.negative { background: var(--negative-color); border-color: var(--negative-color); color: var(--text-color-on-primary); }
.button.negative:hover:not(:disabled) { background: var(--negative-color-hover); }
.button.tertiary.negative { background: transparent; border-color: transparent; color: var(--negative-color); }
.button.tertiary.negative:hover:not(:disabled) { background: var(--negative-color-selected); }
.button:disabled, .button[aria-disabled="true"] { cursor: not-allowed; opacity: 1; }
.button.primary:disabled { background: var(--disabled-background-color); border-color: var(--disabled-background-color); color: var(--disabled-text-color); }
.button.secondary:disabled { border-color: rgba(195, 198, 212, var(--disabled-component-opacity)); color: var(--disabled-text-color); }
.button.tertiary:disabled { color: var(--disabled-text-color); }

/* Split button ("New deal ▾"): primary small, the caret part 28px wide with a darker divider. */
.split-button { display: inline-flex; align-items: stretch; height: 32px; border-radius: var(--border-radius-small); position: relative;
  transition: transform var(--motion-productive-short) var(--motion-timing-transition); }
.split-button:active { transform: scale(.95); }
.split-button > .button { border-radius: 0; height: 32px; min-height: 32px; }
.split-button > .button:active { transform: none; }
.split-button > .split-main { border-radius: var(--border-radius-small) 0 0 var(--border-radius-small); padding: var(--space-4) var(--space-8); }
.split-button > .split-caret { width: 28px; padding: 0 var(--space-4); border-radius: 0 var(--border-radius-small) var(--border-radius-small) 0;
  border-inline-start: 1px solid var(--primary-hover-color); }
.split-button > .split-caret[aria-expanded="true"] { background: var(--primary-hover-color); border-inline-start-color: #fff; }

/* Segmented control (ButtonGroup) */
.button-group, .view-switch:not(.board-view-tabs) { display: inline-flex; align-items: stretch; height: 32px; padding: 0; gap: 0;
  border: 0; border-radius: var(--border-radius-small); background: transparent; box-shadow: none; }
.button-group > button, .view-switch:not(.board-view-tabs) > button { height: 32px; min-height: 32px; margin: 0; padding: 0 var(--space-12);
  border: 1px solid var(--ui-border-color); border-radius: 0; background: transparent; color: var(--primary-text-color);
  font: var(--font-text2-normal); box-shadow: none; white-space: nowrap; cursor: pointer; }
.button-group > button + button, .view-switch:not(.board-view-tabs) > button + button { margin-left: -1px; }
.button-group > button:first-child, .view-switch:not(.board-view-tabs) > button:first-child { border-radius: var(--border-radius-small) 0 0 var(--border-radius-small); }
.button-group > button:last-child, .view-switch:not(.board-view-tabs) > button:last-child { border-radius: 0 var(--border-radius-small) var(--border-radius-small) 0; }
/* Hover only where a pointer hovers: on touch the last-tapped tab would keep the grey box. */
@media (hover: hover) { .button-group > button:hover, .view-switch:not(.board-view-tabs) > button:hover { background: var(--primary-background-hover-color); } }
.button-group > button.selected, .view-switch:not(.board-view-tabs) > button.selected { position: relative; z-index: 1; background: var(--primary-selected-color);
  border-color: var(--primary-color); color: var(--primary-text-color); font-weight: 400; box-shadow: none; }

/* ---------- 3.2 Icon buttons ---------- */
.icon-button { display: inline-flex; align-items: center; justify-content: center; flex: none; position: relative; width: 32px; height: 32px;
  padding: 0; border: 0; border-radius: var(--border-radius-small); background: transparent; color: var(--primary-text-color);
  font-size: 15px; line-height: 1; cursor: pointer; text-decoration: none;
  transition: background-color var(--motion-productive-short) var(--motion-timing-transition); }
.icon-button:hover:not(:disabled) { background: var(--primary-background-hover-color); }
.icon-button[aria-expanded="true"], .icon-button.selected { background: var(--primary-selected-color); }
.icon-button:disabled { color: var(--disabled-text-color); cursor: not-allowed; opacity: 1; }
.icon-button svg.icon { width: 20px; height: 20px; }
.icon-button.xs { width: 24px; height: 24px; }
.icon-button.xs svg.icon, .icon-button.xxs svg.icon { width: 16px; height: 16px; }
.icon-button.xxs { width: 16px; height: 16px; }
.icon-button.medium { width: 40px; height: 40px; }

/* ---------- 3.3 Generic tabs (drawers, cards) ---------- */
.tabs { display: flex; align-items: stretch; border-bottom: 1px solid var(--layout-border-color); }
.tabs > button, .tabs > a { position: relative; height: 40px; padding: 0 var(--space-16); border: 0; background: none; color: var(--primary-text-color);
  font: var(--font-text2-normal); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; }
.tabs > * + *::before { content: ""; position: absolute; left: 0; top: 12px; height: 16px; width: 1px; background: var(--layout-border-color); }
.tabs > .selected::after, .tabs > [aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: var(--primary-color); animation: tab-underline var(--motion-productive-medium) var(--motion-timing-enter); }
@keyframes tab-underline { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ---------- 3.5 / 3.6 Search, inputs, field labels ---------- */
.search-input { display: inline-flex; align-items: center; gap: var(--space-4); height: 32px; padding: 0 var(--space-4) 0 var(--space-8);
  background: var(--primary-background-color); border: 1px solid var(--ui-border-color); border-radius: var(--border-radius-small); color: var(--icon-color); }
.search-input:hover { border-color: var(--primary-text-color); }
.search-input:focus-within { border-color: var(--primary-color); }
.search-input input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: transparent; padding: 0; color: var(--primary-text-color); font: var(--font-text2-normal); }
.search-input.medium { height: 40px; padding-left: var(--space-12); gap: var(--space-8); }
.input, .textarea, .select { width: 100%; height: 40px; padding: var(--space-8) var(--space-12); border: 1px solid var(--ui-border-color); border-radius: var(--border-radius-small);
  background: var(--primary-background-color); color: var(--primary-text-color); font: var(--font-text1-normal); outline: none;
  transition: border-color var(--motion-productive-medium) var(--motion-timing-transition); }
.input.small, .select.small { height: 32px; font: var(--font-text2-normal); }
.input:hover, .textarea:hover, .select:hover { border-color: var(--primary-text-color); }
.input:focus, .textarea:focus, .select:focus { border-color: var(--primary-color); }
.input:disabled, .textarea:disabled, .select:disabled { background: var(--disabled-background-color); border-color: transparent; color: var(--disabled-text-color); }
.input[readonly], .textarea[readonly] { background: var(--allgrey-background-color); border-color: transparent; }
.textarea { height: auto; min-height: 80px; resize: vertical; }
.input.error, .textarea.error { border-color: var(--negative-color); }
input::placeholder, textarea::placeholder { color: var(--placeholder-color); opacity: 1; }
.field-label { display: block; padding-bottom: var(--space-4); font: var(--font-text2-normal); color: var(--primary-text-color); }
.field-label .required, .required-mark { color: var(--negative-color); margin-left: 2px; }
.helper-text { margin-top: var(--space-4); font: var(--font-text2-normal); color: var(--secondary-text-color); }
.helper-text.error { color: var(--negative-color); }

/* ---------- 3.8 Checkboxes, radios, toggles ---------- */
input[type="checkbox"]:not(.toggle):not(.native) { appearance: none; -webkit-appearance: none; flex: none; width: 16px; height: 16px; margin: 0;
  border: 1px solid var(--ui-border-color); border-radius: 2px; background: var(--primary-background-color); cursor: pointer; display: inline-grid; place-content: center;
  vertical-align: middle; transition: background-color var(--motion-productive-short), border-color var(--motion-productive-short); }
input[type="checkbox"]:not(.toggle):not(.native):hover { border-color: var(--secondary-text-color); }
input[type="checkbox"]:not(.toggle):not(.native)::after { content: ""; width: 10px; height: 10px; transform: scale(0); background: #fff;
  clip-path: polygon(14% 50%, 0 64%, 38% 100%, 100% 22%, 86% 9%, 38% 72%); transition: transform var(--motion-productive-short) var(--motion-timing-enter); }
input[type="checkbox"]:not(.toggle):not(.native):checked, input[type="checkbox"]:not(.toggle):not(.native):indeterminate { background: var(--primary-color); border-color: transparent; }
input[type="checkbox"]:not(.toggle):not(.native):checked:hover { background: var(--primary-hover-color); }
input[type="checkbox"]:not(.toggle):not(.native):checked::after { transform: scale(1); }
input[type="checkbox"]:not(.toggle):not(.native):indeterminate::after { transform: scale(1); clip-path: inset(40% 10%); }
input[type="checkbox"]:not(.toggle):not(.native):disabled { background: var(--disabled-background-color); border-color: transparent; cursor: not-allowed; }
input[type="checkbox"]:not(.toggle):not(.native):focus-visible { outline: none; box-shadow: var(--focus-ring); }
input[type="radio"]:not(.native) { appearance: none; -webkit-appearance: none; width: 16px; height: 16px; margin: 0; flex: none; border: 1px solid var(--ui-border-color);
  border-radius: 50%; background: var(--primary-background-color); cursor: pointer; vertical-align: middle; }
input[type="radio"]:not(.native):checked { border: 5px solid var(--primary-color); }
input[type="radio"]:not(.native):checked:hover { border-color: var(--primary-hover-color); }
input.toggle[type="checkbox"] { appearance: none; -webkit-appearance: none; position: relative; width: 41px; height: 24px; margin: 0; flex: none; border-radius: 100px;
  background: var(--ui-border-color); cursor: pointer; transition: background-color var(--motion-productive-medium); }
input.toggle[type="checkbox"]::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff;
  transition: left var(--motion-productive-medium) var(--motion-timing-transition); }
input.toggle[type="checkbox"]:checked { background: var(--primary-color); }
input.toggle[type="checkbox"]:checked::after { left: 20px; }

/* ---------- 3.9 Avatars ---------- */
.avatar { --size: 28px; width: var(--size); height: var(--size); min-width: var(--size); border-radius: 50%; overflow: hidden; flex: none;
  display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; border: 1px solid var(--avatar-ring, #fff);
  background: var(--avatar-color, var(--color-explosive)); color: var(--avatar-text, #fff); font-family: var(--font-family); font-weight: 600; line-height: 1;
  font-size: calc(var(--size) * .43); letter-spacing: -0.3px; user-select: none; vertical-align: middle; text-transform: uppercase; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.square { border-radius: var(--border-radius-small); }
/* An account logo: the whole image on white in the same tile, so a logo that fails turns into initials without moving anything. */
.avatar.logo { background: #fff; border-color: var(--application-border-color); }
.avatar.logo img { object-fit: contain; }
.chip .avatar.chip-logo { --size: 16px; border: 0; border-radius: 3px; }
.avatar.empty { background: transparent; color: var(--person-empty-color); border: 0; }
.avatar.empty svg.icon { width: 100%; height: 100%; }
.avatar.team { background: #000; }
.avatar.team svg.icon { width: 60%; height: 60%; color: #fff; }
.avatar-group { display: inline-flex; align-items: center; flex-direction: row; }
.avatar-group > .avatar, .avatar-group > .avatar-counter { position: relative; }
.avatar-group > * + * { margin-left: -8px; }
.avatar-group.cell > * + * { margin-left: -6px; }
.avatar-counter { --size: 28px; height: var(--size); min-width: var(--size); padding: 0 var(--space-4); border-radius: 999px; border: 1px solid #fff;
  background: var(--ui-background-color); color: var(--primary-text-color); font: 400 12px/1 var(--font-family); display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; }
.avatar-group.cell .avatar-counter { background: var(--counter-dark); color: #fff; font-weight: 300; }
.person { display: inline-flex; align-items: center; gap: var(--space-8); white-space: nowrap; font: var(--font-text2-normal); color: var(--primary-text-color); }
.person > .avatar { --size: 24px; font-size: 11px; }

/* ---------- 3.10 / 3.11 Labels and chips ---------- */
.status-label { display: inline-flex; align-items: center; height: 24px; padding: 2px var(--space-8); border-radius: var(--border-radius-small);
  background: var(--label-color, var(--color-explosive)); color: var(--label-color-text, #fff); font: var(--font-text2-normal); white-space: nowrap; }
.status-label.small { height: 16px; padding: 0 var(--space-4); border-radius: 2px; font: var(--font-text3-normal); }
.status-label.line { background: transparent; color: var(--primary-text-color); border: 1px solid var(--label-color); }
.status-label.ai { --label-color: var(--ai-color); }
.overview-pill { display: inline-flex; align-items: center; height: 20px; padding: 0 var(--space-8); border-radius: 999px; background: var(--label-color, var(--color-explosive));
  color: var(--label-color-text, #fff); font: 400 11.5px/19px var(--font-family); white-space: nowrap; }
.chip { display: inline-flex; align-items: center; gap: var(--space-4); height: 24px; padding: 0 var(--space-8); margin: 0; border: 0; border-radius: var(--border-radius-small);
  background: var(--primary-selected-color); color: var(--primary-text-color); font: var(--font-text2-normal); max-width: 100%; white-space: nowrap; box-shadow: none; }
.chip > .chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.small { height: 20px; padding: 0 var(--space-4); gap: 2px; }
.chip.clickable { cursor: pointer; }
.chip.clickable:hover { background: var(--primary-selected-hover-color); }
.chip .chip-remove { width: 16px; height: 16px; border-radius: var(--border-radius-small); color: var(--icon-color); }
.chip .avatar { --size: 18px; border: 0; font-size: 9px; }
.chip.crm { background: var(--crm-chip-color); height: 22px; }
.chip.crm svg.icon { width: 16px; height: 16px; color: var(--primary-text-color); }
/* Selectable chips (person filters, quick filters): quick-filter value-button look (QA-2.6). */
button.chip { height: 32px; padding: 0 var(--space-8) 0 var(--space-4); gap: var(--space-8); background: var(--pulse-background-color); cursor: pointer;
  transition: background-color var(--motion-productive-short) var(--motion-timing-transition); }
button.chip:not(:has(.avatar)) { padding-left: var(--space-8); }
button.chip .avatar { --size: 24px; font-size: 10px; border: 0; }
button.chip:hover { background: var(--pulse-hover-background-color); border-color: transparent; }
button.chip.selected, button.chip[aria-pressed="true"] { background: var(--primary-selected-color); color: var(--primary-text-color); box-shadow: inset 0 0 0 1px var(--primary-color); border-color: transparent; }
button.chip.selected:hover, button.chip[aria-pressed="true"]:hover { background: var(--primary-selected-hover-color); }
button.chip.selected .avatar { background: var(--avatar-color, var(--color-explosive)); color: var(--avatar-text, #fff); }

/* ---------- Counters ---------- */
.counter { position: absolute; top: -3px; right: -3px; min-width: 18px; height: 18px; padding: 0 var(--space-4); border-radius: 30px; box-sizing: border-box;
  background: var(--negative-color); color: #fff; border: 2px solid #fff; font: 400 11.5px/13px var(--font-family); display: inline-flex; align-items: center; justify-content: center; pointer-events: none; }
.counter.light { background: #fff; color: var(--primary-text-color); }
.counter.dot { min-width: 8px; width: 8px; height: 8px; padding: 0; border: 0; }
.counter.inline { position: static; border: 0; height: 18px; }

/* ---------- 3.12 Tooltip (CSS-only, from data-tip) ----------
   Hidden tooltips are display:none so they never widen the page; they fade in after 300ms on hover/focus. */
[data-tip] { position: relative; }
[data-tip]::after { content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 8px); z-index: 10002; transform: translateX(-50%);
  width: max-content; max-width: 240px; padding: var(--space-8) var(--space-16); border-radius: var(--border-radius-small); background: var(--tooltip-background);
  color: #fff; font: var(--font-text2-normal); text-align: center; white-space: pre-wrap; box-shadow: var(--box-shadow-medium); pointer-events: none; display: none; }
[data-tip]::before { content: ""; position: absolute; left: 50%; bottom: calc(100% + 3px); z-index: 10002; width: 10px; height: 10px; border-radius: 2px;
  background: var(--tooltip-background); transform: translateX(-50%) rotate(45deg); pointer-events: none; display: none; }
[data-tip]:hover::after, [data-tip]:hover::before, [data-tip]:focus-visible::after, [data-tip]:focus-visible::before { display: block; animation: tip-in var(--motion-productive-medium) 300ms both; }
@keyframes tip-in { from { opacity: 0; } to { opacity: 1; } }
[data-tip][data-tip-pos="bottom"]::after { bottom: auto; top: calc(100% + 8px); }
[data-tip][data-tip-pos="bottom"]::before { bottom: auto; top: calc(100% + 3px); }
[data-tip][data-tip-pos="right"]::after { left: calc(100% + 8px); bottom: auto; top: 50%; transform: translateY(-50%); }
[data-tip][data-tip-pos="right"]::before { left: calc(100% + 3px); bottom: auto; top: 50%; transform: translateY(-50%) rotate(45deg); }
[data-tip][data-tip-pos="bottom-end"]::after { bottom: auto; top: calc(100% + 8px); left: auto; right: 0; transform: none; }
[data-tip][data-tip-pos="bottom-end"]::before { bottom: auto; top: calc(100% + 3px); }
[data-tip=""]::after, [data-tip=""]::before { content: none; }
@media (hover: none) { [data-tip]:hover::after, [data-tip]:hover::before { display: none; } }

/* ---------- 3.13 Toast ---------- */
#toast { position: fixed; top: var(--space-16); bottom: auto; left: 50%; transform: translateX(-50%); z-index: 10001; display: flex; align-items: center; gap: var(--space-8);
  min-width: 200px; max-width: min(680px, calc(100vw - 32px)); min-height: 48px; padding: var(--space-8) var(--space-8) var(--space-8) var(--space-16);
  border-radius: var(--border-radius-small); background: var(--inverted-color-background); color: #fff; font: var(--font-text2-normal);
  box-shadow: var(--box-shadow-medium); flex-wrap: wrap; animation: toast-in 350ms cubic-bezier(.6, 0, .4, 1); }
#toast[hidden], #toast:not(:popover-open) { display: none; }
/* The toast is a manual popover in the top layer (above any open dialog); reset the UA popover box. */
#toast:popover-open { display: flex; inset: 16px auto auto 50%; margin: 0; border: 0; overflow: visible; color: #fff; }
#toast.toast-warning:popover-open { color: var(--primary-text-color); }
#toast > span { margin: 0 var(--space-8) 0 0; }
#toast button { height: 32px; min-height: 32px; padding: 0 var(--space-8); border: 1px solid #fff; border-radius: var(--border-radius-small); background: transparent;
  color: #fff; font: var(--font-text2-normal); cursor: pointer; }
#toast button:hover { backdrop-filter: brightness(85%); background: rgba(255, 255, 255, .12); }
#toast.positive { background: var(--positive-color); }
#toast.normal { background: var(--primary-color); }
#toast.negative { background: var(--negative-color); }
#toast.warning { background: var(--warning-color); color: var(--primary-text-color); }
@keyframes toast-in { 0% { transform: translate(-50%, -100px); } 70% { transform: translate(-50%, 16px); } 100% { transform: translate(-50%, 0); } }

/* ---------- 3.16 Menus and popovers ---------- */
.popover { position: absolute; z-index: 1000; background: var(--primary-background-color); border-radius: var(--border-radius-medium);
  box-shadow: var(--box-shadow-medium); padding: var(--space-8); color: var(--primary-text-color); }
.popover[hidden] { display: none; }
.menu { min-width: 220px; display: flex; flex-direction: column; gap: 0; }
.menu-item { display: flex; align-items: center; gap: var(--space-8); width: 100%; min-height: 32px; padding: var(--space-4) var(--space-8); border: 1px solid transparent;
  border-radius: var(--border-radius-small); background: transparent; color: var(--primary-text-color); font: var(--font-text2-normal); text-align: left;
  text-decoration: none; cursor: pointer; white-space: nowrap; }
.menu-item svg.icon { width: 18px; height: 18px; color: var(--icon-color); }
.menu-item:hover, .menu-item:focus-visible { background: var(--primary-background-hover-color); box-shadow: none; }
.menu-item.selected { background: var(--primary-selected-color); }
.menu-item.selected svg.icon { color: var(--primary-color); }
.menu-item:disabled { opacity: var(--disabled-component-opacity); cursor: not-allowed; }
.menu-item .menu-item-end { margin-left: auto; color: var(--secondary-text-color); }
.menu-title { margin: var(--space-8) 0; padding: 0 var(--space-8); font: var(--font-text2-normal); color: var(--secondary-text-color); }
.menu-divider { height: 1px; margin: var(--space-8); background: var(--layout-border-color); border: 0; }

/* ---------- 3.17 Attention box ---------- */
.attention-box { display: grid; grid-template-columns: auto 1fr auto; gap: var(--space-4) var(--space-8); align-items: start; width: 100%; box-sizing: border-box;
  padding: var(--space-12) var(--space-16); border-radius: var(--border-radius-medium); background: var(--primary-selected-color); color: var(--primary-text-color); font: var(--font-text2-normal); }
.attention-box > svg.icon { width: 20px; height: 20px; }
.attention-box .attention-title { font: 600 15px/21px var(--font-family); }
.attention-box .attention-body { grid-column: 1 / -1; }
.attention-box.positive { background: var(--positive-color-selected); }
.attention-box.negative { background: var(--negative-color-selected); }
.attention-box.warning { background: var(--warning-color-selected); }
.attention-box.neutral { background: var(--allgrey-background-color); }
.attention-box.ai { background: var(--ai-surface-color); border: 1px solid var(--ai-selected-color); }

/* ---------- 3.18 Skeleton, loader, progress ---------- */
.skeleton { background: var(--ui-background-color); border-radius: var(--border-radius-small); animation: skeleton-pulse .8s steps(10, end) infinite alternate; }
@keyframes skeleton-pulse { from { opacity: .4; } to { opacity: 1; } }
.loader { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--ui-background-color); border-top-color: currentColor; animation: loader-spin 1s linear infinite; display: inline-block; box-sizing: border-box; }
@keyframes loader-spin { to { transform: rotate(360deg); } }
.progress { height: 8px; border-radius: var(--border-radius-small); background: var(--ui-background-color); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary-color); border-radius: inherit; }

/* ---------- AI sparkle (QA-6.1) ---------- */
.ai-sparkle { display: inline-block; flex: none; width: 16px; height: 16px; background: var(--sparkle-gradient);
  -webkit-mask: var(--sparkle-mask) center / contain no-repeat; mask: var(--sparkle-mask) center / contain no-repeat; }
.ai-sparkle.mono { background: currentColor; }

/* Closed <details> menus must not take space or widen the page (Chrome still lays out positioned children). */
details:not([open]) > :not(summary) { display: none !important; }
/* A record's photo or initials before its name (contacts board). */
.cell-name:has(> .avatar) { display: flex; align-items: center; }
.cell-name > .avatar { margin-right: var(--space-8); }
.dialog-heading > .avatar { margin-right: var(--space-16); align-self: center; }
.dialog-heading > .avatar + div { flex: 1; min-width: 0; }
/* Links that open another site: text plus the Vibe ExternalPage glyph */
.external-link { display: inline-flex; align-items: center; gap: var(--space-4); }
.external-link svg.icon { flex: none; }

/* ---------- 3.15 Confirmation dialog (QA-5.3): body question, close ✕, divider, Cancel + primary action ---------- */
.confirm-dialog { width: min(532px, calc(100vw - 32px)); max-width: none; padding: 0; border: 0; border-radius: var(--border-radius-medium); background: var(--primary-background-color);
  color: var(--primary-text-color); box-shadow: var(--box-shadow-large); }
.confirm-dialog[open] { animation: confirm-in 150ms cubic-bezier(0, 0, .4, 1); }
.confirm-dialog::backdrop { background: var(--backdrop-color); }
.confirm-card { position: relative; margin: 0; }
.confirm-close { position: absolute; top: 16px; right: 16px; }
.confirm-title { margin: 0; padding: 32px 64px 0 24px; font: 600 17px/23px var(--font-family); color: var(--primary-text-color); letter-spacing: 0; }
.confirm-body { margin: 0; padding: 32px 64px 24px 24px; font: var(--font-text1-normal); color: var(--primary-text-color); white-space: pre-line; overflow-wrap: anywhere; }
.confirm-title + .confirm-body { padding-top: 8px; }
.confirm-foot { display: flex; justify-content: flex-end; gap: var(--space-8); padding: 16px 24px; border-top: 1px solid var(--layout-border-color); }
@keyframes confirm-in { from { transform: scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
/* Restore preview inside the confirmation: counts per board, removed names, and the word to type before records are removed */
.confirm-extra { padding: 0 24px 16px; max-height: min(40vh, 360px); overflow: auto; }
.restore-preview { width: 100%; border-collapse: collapse; font: var(--font-text2-normal); color: var(--primary-text-color); }
.restore-preview th, .restore-preview td { padding: 6px 8px; border-bottom: 1px solid var(--layout-border-color); text-align: left; }
.restore-preview thead th { font-weight: 600; color: var(--secondary-text-color); }
.restore-preview tbody th { font-weight: 500; }
.restore-preview td { text-align: right; font-variant-numeric: tabular-nums; }
.restore-preview thead th:not(:first-child) { text-align: right; }
.negative-text { color: var(--negative-color); }
.restore-removed-title { margin: var(--space-16) 0 var(--space-4); font: 600 13px/19px var(--font-family); }
.restore-removed { margin: 0; padding-left: 20px; font: var(--font-text2-normal); overflow-wrap: anywhere; }
.confirm-typed { display: flex; flex-direction: column; gap: var(--space-4); padding: 0 24px 16px; font: var(--font-text2-normal); color: var(--primary-text-color); }
.confirm-typed input { height: 32px; padding: 0 var(--space-8); border: 1px solid var(--ui-border-color); border-radius: var(--border-radius-small); font: var(--font-text1-normal); color: var(--primary-text-color); background: var(--primary-background-color); }
.confirm-typed input:focus { outline: none; border-color: var(--primary-color); }
/* Record history (card … menu > History): one entry per saved version, who and when, then field old → new */
.history-dialog { width: min(640px, calc(100vw - 32px)); }
.history-sub { margin: 4px 0 0; padding: 0 64px 0 24px; font: var(--font-text2-normal); color: var(--secondary-text-color); overflow-wrap: anywhere; }
.history-body { max-height: min(65vh, 560px); overflow: auto; padding: 16px 24px 24px; }
.history-list { margin: 0; padding: 0; list-style: none; }
.history-entry { padding: var(--space-12) 0; border-bottom: 1px solid var(--layout-border-color); }
.history-entry:last-child { border-bottom: 0; }
.history-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-8); }
.history-head small, .history-kind { font: var(--font-text2-normal); color: var(--secondary-text-color); }
.history-kind { margin: var(--space-4) 0 0; }
.history-loading { display: flex; align-items: center; gap: var(--space-8); margin: 0; color: var(--secondary-text-color); }
.history-changes { margin: var(--space-8) 0 0; padding: 0; list-style: none; }
.history-changes .change-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-8); padding: 2px 0; }
.history-changes strong { font-weight: 600; min-width: 120px; }
.history-changes .change-old, .history-changes .change-new { display: inline-flex; align-items: center; min-height: 24px; padding: 0 var(--space-8); border-radius: var(--border-radius-small); color: var(--primary-text-color); overflow-wrap: anywhere; }
.history-changes .change-old { background: var(--ui-background-color); text-decoration: line-through; text-decoration-color: var(--secondary-text-color); }
.history-changes .change-new { background: var(--primary-selected-color); }
/* Save conflict actions under the form message; an informational message is not red */
.form-error .conflict-actions { display: flex; flex-wrap: wrap; gap: var(--space-8); margin-top: var(--space-8); }
.form-error.is-info { color: var(--primary-text-color); }
/* The toast never blocks what is under it, only its own buttons; on phones it sits above the tab bar. */
#toast { pointer-events: none; }
#toast button, #toast a { pointer-events: auto; }
@media (max-width: 760px) {
  #toast:popover-open { inset: auto 8px calc(56px + env(safe-area-inset-bottom, 0px) + 8px) 8px; transform: none; max-width: none; animation: toast-up 250ms var(--motion-timing-enter); }
}
@keyframes toast-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
/* A control's tooltip hides while its own menu or popover is open. */
[data-tip][aria-expanded="true"]:hover::after, [data-tip][aria-expanded="true"]:hover::before, [data-tip][aria-expanded="true"]:focus-visible::after, [data-tip][aria-expanded="true"]:focus-visible::before { display: none; }
