:root {
  color-scheme: light;
  --ink: #1f2335;
  --muted: #5e657d;
  --subdued: #777e94;
  --border: #e2e4ee;
  --wash: #f7f7fc;
  --surface: #fff;
  --accent: #6347d5;
  --accent-dark: #4e31be;
  --accent-wash: #f0ebff;
  --dark: #202139;
  --focus: #765af1;
  --danger: #8e344e;
  --new-ink: #78491a;
  --new-wash: #fff0d8;
  --active-ink: #4e31a7;
  --active-wash: #eae2ff;
  --closed-ink: #25634f;
  --closed-wash: #e2f4eb;
  --spam-ink: #8e344e;
  --spam-wash: #fdecef;
  --radius-control: 7px;
  --radius-card: 12px;
  --radius-modal: 14px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --shadow-modal: 0 20px 70px #1d1a3b33;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--wash);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 280px; overflow-wrap: anywhere; }
/* Desktop shells (WebView2/Electron): hairline under OS caption so white headers do not merge. */
html.native-desktop-frame body {
  border-top: 1px solid var(--border);
}
/* Desk shell must own the viewport: a body/app-content scroll offset looks like a panel shift until refresh. */
html:has(.app-shell), body:has(.app-shell) {
  height: 100%; max-height: 100%; overflow: hidden; overscroll-behavior: none;
}
button, select, textarea, input { font: inherit; color: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
button:focus-visible, a:focus-visible, select:focus-visible, textarea:focus-visible, input:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
h1, h2, p { margin: 0; }
svg, img { vertical-align: middle; flex: none; }
.topbar {
  min-height: 67px; display: flex; flex-wrap: wrap; align-items: center; gap: 16px; padding: 10px 24px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand {
  display: inline-flex; align-items: center; gap: 11px; text-decoration: none;
  font-size: 17px; font-weight: 760; letter-spacing: -.4px; white-space: nowrap;
  min-width: 0; max-width: 100%;
}
.brand span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.topbar > .brand { flex: 0 1 240px; }
.demo-tag {
  font-size: 10px; line-height: 1.2; color: #5840a1; background: var(--accent-wash);
  border: 1px solid #e7ddff; padding: 4px 7px; border-radius: 5px; font-weight: 750; letter-spacing: .06em;
}
.top-nav { display: flex; flex-shrink: 0; align-self: stretch; gap: 20px; margin-left: 25px; }
.top-nav a {
  display: flex; align-items: center; position: relative; color: var(--muted);
  text-decoration: none; font-size: 14px; font-weight: 620;
}
.top-nav a[aria-current] { color: var(--accent-dark); }
.top-nav a[aria-current]::after {
  content: ""; position: absolute; inset: auto 0 -1px; height: 3px; border-radius: 4px 4px 0 0; background: var(--accent);
}
.persona { display: flex; align-items: center; gap: 9px; margin-left: auto; font-size: 13px; color: var(--muted); min-width: 0; }
.persona > span { min-width: 0; max-width: 160px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.persona > a, .persona > button { flex-shrink: 0; }
select { padding: 7px 29px 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-control); background-color: #fff; min-width: 0; }
.persona select { color: var(--ink); max-width: 100%; }
.persona > .preview-status { display: inline-block; color: #754d00; background: #fff2ce; padding: 4px 7px; border-radius: 6px; }
.profile-roles { border-top: 1px solid var(--border); margin-top: var(--space-4); padding-top: var(--space-4); }

.desk { display: grid; min-width: 0; }
#app:has(> .desk) { height: 100dvh; display: flex; flex-direction: column; }
#app > .desk { flex: 1; height: auto; min-height: 0; }
#app:has(> .desk) > .topbar, #app:has(> .desk) > .client-language { flex-shrink: 0; }
.operator-desk { height: calc(100dvh - 67px); min-height: 510px; grid-template-columns: 228px minmax(275px, 325px) minmax(0, 1fr); }
.sidebar {
  display: flex; flex-direction: column; padding: 20px 12px 14px; color: #fff; background: var(--dark);
  overflow-y: auto; min-height: 0;
}
.workspace { display: flex; align-items: center; gap: 10px; padding: 2px 8px 24px; }
.workspace-icon {
  display: grid; width: 35px; height: 35px; place-items: center; border-radius: 8px;
  background: #373552; color: #d6ccff;
}
.workspace strong, .sidebar-foot strong { display: block; font-size: 13px; line-height: 1.3; }
.workspace small, .sidebar-foot small { color: #b5b6cb; font-size: 11px; }
.side-label { padding: 0 9px 8px; color: #a7acc6; font-size: 10px; font-weight: 750; letter-spacing: .11em; }
.projects-label { margin-top: 25px; }
.side-link {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; padding: 9px 8px;
  background: transparent; border: 1px solid transparent; color: #d9dbec; border-radius: var(--radius-control); font-size: 12.5px;
}
.side-link > span:not(.unread-count) { flex: 1; min-width: 0; }
.side-link small { min-width: 19px; padding: 0 3px; text-align: center; color: #d9dbec; }
.side-link .unread-count {
  flex: none; margin-left: auto; min-width: 1.25em; height: 18px; padding: 0 5px;
  font-size: 10px; line-height: 1; border-radius: 9px;
}
.side-link:hover, .side-link.selected { color: #fff; background: #353452; }
.side-link.selected { border-color: #48466b; }
.project-dot { width: 7px; height: 7px; margin: 0 5px; border-radius: 50%; background: #a992ff; flex: none; }
.project-label { font-weight: 700; }
.sidebar-foot { margin-top: auto; padding: 16px 7px 0; display: flex; align-items: center; gap: 9px; }
.sidebar-foot .avatar { background: #433b67; color: #eee6ff; }
.list-pane {
  display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border); min-width: 0; min-height: 0;
}
.list-header { padding: 25px 19px 20px; border-bottom: 1px solid var(--border); }
.eyebrow { color: var(--accent-dark); font-size: 10px; font-weight: 790; letter-spacing: .105em; text-transform: uppercase; }
.list-header h1 { font-size: 29px; line-height: 1.15; letter-spacing: -.045em; margin: 5px 0; }
.list-header p { color: var(--muted); font-size: 12.5px; }
.ticket-list { overflow: auto; min-height: 0; padding: 9px; }
.ticket {
  width: 100%; display: grid; min-width: 0; text-align: left; gap: 4px; padding: 11px 11px 10px;
  margin-bottom: 4px; border: 1px solid transparent; border-bottom-color: #ececf4; border-radius: 8px;
  background: var(--surface);
}
.ticket:hover { background: #f8f6ff; }
.ticket.selected { background: #f5f1ff; border-color: #dfd2ff; }
.ticket.unread .ticket-person strong { font-weight: 700; }
.ticket.unread .ticket-preview { color: var(--ink); }
.ticket-meta-end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.ticket-time-row { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.awaiting-reply { display: inline-flex; flex: none; color: var(--muted); }
.awaiting-reply.pulse svg { transform-origin: center; animation: awaiting-pulse 1.15s ease-in-out infinite; }
@keyframes awaiting-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .35; transform: scale(1.18); }
}
@media (prefers-reduced-motion: reduce) {
  .awaiting-reply.pulse svg { animation: none; }
}
.ticket-meta-end .unread-dot { margin-right: 0; }
.ticket strong { font-size: 13.5px; line-height: 1.4; overflow-wrap: anywhere; }
.ticket-person, .person-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ticket-person > span, .person-line > span, .person-line > strong { min-width: 0; overflow-wrap: anywhere; }
.ticket-person .avatar, .person-line .avatar { width: 28px; height: 28px; font-size: 10px; }
.ticket-contact { display: block; color: var(--muted); font-size: 12px; }
.ticket-preview { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticket-meta { display: flex; justify-content: space-between; gap: 8px; align-items: center; color: var(--muted); font-size: 11px; }
.ticket-meta > time { white-space: nowrap; }
.ticket-meta > span { min-width: 0; }
.ticket-bottom { margin-top: 5px; }
.ticket-bottom-main { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ticket-assignee { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  width: max-content; display: inline-flex; align-items: center; gap: 5px;
  white-space: nowrap; line-height: 1.4; border-radius: 6px; font-size: 11px; font-weight: 700; padding: 3px 7px;
}
.badge span { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.new { color: var(--new-ink); background: var(--new-wash); }
.badge.active { color: var(--active-ink); background: var(--active-wash); }
.badge.closed { color: var(--closed-ink); background: var(--closed-wash); }
.badge.spam { color: var(--spam-ink); background: var(--spam-wash); }
.badge.channel-address-badge { color: var(--active-ink); background: var(--active-wash); }
.person-line > .badge { flex: none; }
.detail-pane { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: #f9f9fd; }
#detail-heading { max-height: none; overflow: visible; flex-shrink: 0; }
.detail-header {
  min-height: 120px; display: flex; justify-content: space-between; align-items: flex-start; gap: 14px;
  padding: 23px 26px 17px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.detail-header:has(.thread-tags) {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "title controls" "tags tags"; align-items: start; column-gap: 14px; row-gap: 8px;
}
.detail-header:has(.thread-tags.is-collapsed) { row-gap: 0; }
.detail-header:has(.thread-tags) > .detail-title { grid-area: title; }
.detail-header:has(.thread-tags) > .ticket-controls { grid-area: controls; justify-self: end; }
.detail-header:has(.thread-tags) > .thread-tags { grid-area: tags; }
.detail-header h2 { font-size: clamp(20px, 2.15vw, 28px); line-height: 1.22; margin: 7px 0 9px; letter-spacing: -.035em; overflow-wrap: anywhere; }
.detail-title { min-width: 0; }
.detail-nav-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.detail-nav-row .eyebrow { min-width: 0; flex: 1 1 auto; }
.conversation-return { flex: none; text-decoration: none; }
.queue-heading > .conversation-return, .kit-heading-demo > .conversation-return { justify-self: start; }
.detail-subject-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.detail-subject-row h2 { flex: 1 1 auto; min-width: 0; margin: 7px 0 9px; }
.detail-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.detail-contact { max-width: 100%; color: var(--ink); font-size: 12px; font-weight: 600; }
.detail-contact .avatar { width: 22px; height: 22px; }
.detail-contact > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-reply-email { max-width: 100%; overflow-wrap: anywhere; }
.detail-reply-email strong { font-weight: 650; color: var(--ink); }
.composer-reply-email { margin: 0 0 8px; font-size: 12px; overflow-wrap: anywhere; }
.crm-channel-address { font-weight: 650; }
.channel-address-badge { margin-left: 6px; vertical-align: middle; }
.mid-meta { font-size: 12px; color: var(--muted); }
.middle-dot { color: var(--subdued); padding: 0 2px; }
.detail-header button { white-space: nowrap; flex-shrink: 0; }
.primary, .secondary, .subtle {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 12px;
  border-radius: var(--radius-control); border: 1px solid transparent; font-weight: 670; font-size: 13px;
}
.mobile-crm-back { display: none; }
.primary.compact, .secondary.compact, .detail-header .primary, .detail-header .secondary,
.ticket-controls .primary, .ticket-controls .secondary, .composer-footer .primary {
  padding: 5px 10px; font-size: 12px; min-height: 30px; font-weight: 650;
}
.primary { background: var(--accent); color: #fff; }
.primary:hover { background: var(--accent-dark); }
.secondary { background: var(--surface); border-color: #dadce8; color: #3f4660; }
.secondary:hover, .subtle:hover { background: #f3efff; }
.subtle { background: transparent; color: var(--accent-dark); }
.detail-client-card { display: none; }
.messages { padding: 22px 26px; flex: 1; min-height: 0; overflow: auto; }
.message-day {
  margin: 0 auto 22px; color: var(--muted); width: max-content; padding: 3px 8px; border-radius: 5px;
  background: #f0f0f8; font-size: 11px; max-width: 100%;
}
.message { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 20px; min-width: 0; }
.message.operator { flex-direction: row-reverse; }
.message > div { min-width: 0; max-width: min(88%, 670px); }
.message:has(.attachment-audio) > div { width: min(88%, 520px); }
.message.operator > div { text-align: right; }
.avatar {
  position: relative; overflow: hidden;
  width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex: none;
  background: #eae6f6; color: #524675; font-size: 11px; font-weight: 780;
}
.avatar > .avatar-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar.avatar-has-photo { cursor: zoom-in; }
.avatar > .avatar-photo[hidden] { display: none; }
.message.operator .avatar { color: #f8f5ff; background: var(--accent); }
.message-meta { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; margin: 0 0 4px; font-size: 12px; }
.message.operator .message-meta { justify-content: flex-end; }
.message-meta time { color: var(--muted); font-size: 11px; }
.message-unread-dot { margin-left: 2px; }
.thread-separator.unread-separator { color: var(--accent-dark); border-color: #dfd2ff; }
.profile-page-card { max-width: 560px; }
.profile-page-hero { display: flex; align-items: center; gap: var(--space-4); margin-bottom: var(--space-4); }
.profile-page-hero .avatar { width: 64px; height: 64px; font-size: 22px; }
.profile-page-hero h2 { margin: 0 0 4px; font-size: 22px; }
.profile-page-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-4); }
.profile-media-permissions,
.profile-background-keep,
.profile-native-diagnostics {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  display: grid;
  gap: var(--space-2);
}
.profile-media-permissions h3,
.profile-background-keep h3,
.profile-native-diagnostics h3 { margin: 0; font-size: 15px; }
.profile-media-permissions .field-hint,
.profile-background-keep .field-hint,
.profile-native-diagnostics .field-hint { margin: 0; }
.profile-media-permissions > button,
.profile-background-keep > button,
.profile-native-diagnostics > button { justify-self: start; }
.profile-native-verbose {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  color: var(--ink);
}
.profile-native-verbose input { margin-top: 2px; }
.background-keep-steps {
  margin: 0;
  padding-left: 1.25rem;
  display: grid;
  gap: var(--space-2);
  font-size: 14px;
  line-height: 1.45;
}
#background-keep-form #open-battery-settings { margin-top: var(--space-2); }
.delivery-status { display: inline-flex; align-items: center; color: var(--muted); }
.delivery-status.sent { color: #2f7a4b; }
.delivery-status.sent.email { color: var(--muted); }
.delivery-status.delivered { color: #2f7a4b; }
.delivery-status.failed, .delivery-status.skipped { color: var(--danger); }
.delivery-status.pending { color: #9a6b1f; }
.message p {
  white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface); border: 1px solid var(--border);
  border-radius: 3px 10px 10px; padding: 10px 13px; font-size: 14px; text-align: left;
}
.message.operator p { background: #f0ebff; border-color: #e4d9fd; border-radius: 10px 3px 10px 10px; margin-left: auto; }
.message.internal p, .message.operator.internal p { background: #fff6de; border-color: #f1e3b9; }
.message.operator.internal .avatar { color: #735015; background: #f2e4bc; }
.message-bubble { position: relative; display: flex; flex-direction: column; gap: 6px; min-width: 0; max-width: 100%; }
.message.operator .message-bubble { align-items: flex-end; }
.message-quote {
  display: block; width: 100%; max-width: 100%; margin: 0; padding: 6px 10px 6px 12px;
  border: 0; border-left: 3px solid var(--accent); border-radius: 6px;
  background: #ece8ff; color: inherit; text-align: left; cursor: pointer; font: inherit; overflow: hidden;
}
.message.operator .message-quote { background: #e4dbff; }
.message.client .message-quote { background: #f3f1fb; }
.message-quote:hover, .message-quote:focus-visible { outline: none; filter: brightness(0.97); }
.message-quote-author { display: block; font-size: 12px; font-weight: 600; color: var(--accent-dark); margin-bottom: 2px; }
.message-quote-text {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden; color: var(--muted); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.message-previous { opacity: 0.72; }
.message-previous s { text-decoration: line-through; text-decoration-thickness: 1px; }
.message-deleted p { opacity: 0.72; }
.message-edited { display: inline-block; margin-left: 6px; color: var(--muted); font-size: 11px; font-weight: 400; }
.message-action {
  position: absolute; right: 4px; bottom: 4px; z-index: 1;
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; padding: 0; border: 0; border-radius: 7px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); color: var(--muted); cursor: pointer;
  opacity: 0; transition: opacity .15s ease, background .15s ease, color .15s ease;
}
.message:hover .message-action, .message:focus-within .message-action, .message.quote-menu-open .message-action { opacity: 1; }
.message-action:hover, .message-action:focus-visible { background: var(--accent-wash); color: var(--accent-dark); outline: none; }
@media (hover: none), (pointer: coarse) {
  .message-action { display: none; }
}
.message.quote-flash > div { box-shadow: 0 0 0 2px var(--accent); border-radius: 10px; transition: box-shadow .4s ease; }
.message.long-pressing > div { box-shadow: 0 0 0 2px var(--accent); border-radius: 10px; }
.attachment-audio {
  display: flex; flex-direction: column; gap: 4px; margin-top: 4px;
  width: 100%; max-width: 100%; align-self: stretch; box-sizing: border-box;
  padding: 8px 10px; border: 1px solid #ded3fb; border-radius: 8px; background: var(--accent-wash);
}
.message:has(.attachment-audio) .message-bubble { width: 100%; }
.attachment-audio audio { width: 100%; height: 36px; }
.attachment-audio .attachment { margin: 0; padding: 0; border: 0; background: transparent; font-size: 12px; }
.message-link { color: var(--accent-dark); text-decoration: underline; word-break: break-word; }
.message-link:hover { color: var(--accent); }
.composer-audio-bar, .composer-dictation-bar {
  display: flex; align-items: center; gap: 8px; margin: 0 0 8px; padding: 8px 10px;
  border-radius: 8px; background: var(--accent-wash); color: var(--ink); font-size: 13px;
}
.composer-audio-bar[hidden], .composer-dictation-bar[hidden] { display: none; }
.composer-tool.active { color: var(--accent-dark); background: #e4dbff; border-color: #cfc3f5; }
.composer-quote {
  display: flex; align-items: flex-start; gap: 8px; margin: 0 0 8px; padding: 8px 10px;
  border-left: 3px solid var(--accent); border-radius: 8px; background: var(--accent-wash);
}
.composer-quote-body { min-width: 0; flex: 1; }
.composer-quote-author { display: block; font-size: 12px; font-weight: 600; color: var(--accent-dark); }
.composer-quote-text {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden; color: var(--muted); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.composer-quote-clear { flex: 0 0 auto; }
.thread-separator {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px;
  margin: 18px 0 22px; padding: 10px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  color: var(--muted); font-size: 12px;
}
.thread-separator time { color: var(--subdued); }
.prior-thread { margin-bottom: 8px; }
.composer, .read-only { background: var(--surface); border-top: 1px solid var(--border); padding: 15px 26px; }
.composer label, .new-form label { display: block; font-weight: 700; font-size: 13px; margin-bottom: 5px; }
textarea, input {
  display: block; width: 100%; padding: 9px 11px; border-radius: var(--radius-control); border: 1px solid #d8dbe9; background: var(--surface);
}
textarea { resize: vertical; min-height: 54px; max-height: 220px; }
.composer-body-field { position: relative; min-width: 0; }
.composer-body-field textarea { padding-right: 34px; }
#reply-body { min-height: 62px; max-height: 220px; resize: none; overflow-y: auto; }
.composer-body-clear {
  position: absolute; top: 6px; right: 6px; z-index: 1;
  min-width: 26px; min-height: 26px; padding: 2px; color: var(--muted);
}
.composer-body-clear[hidden] { display: none; }
textarea::placeholder, input::placeholder { color: #70768c; }
.composer-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 9px; }
.composer.composer-inline .composer-footer {
  position: sticky; bottom: 0; z-index: 2; flex-shrink: 0;
  margin-top: 9px; padding-top: 4px; padding-bottom: 2px;
  background: var(--surface);
}
.composer.composer-inline.note-mode .composer-footer { background: #fff9e9; }
.composer .composer-signature {
  display: flex; align-items: center; gap: 8px; margin: 8px 0 0;
  font-weight: 500; font-size: 13px; color: var(--ink);
}
.composer .composer-signature input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.composer .composer-signature[hidden] { display: none; }
.message-expand {
  align-self: flex-start; margin: 0; padding: 0; border: 0; background: none;
  color: var(--accent-dark); font: inherit; font-size: 12px; cursor: pointer; text-decoration: underline;
}
.message-expand:hover, .message-expand:focus-visible { color: var(--accent); }
.composer-tools { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.composer .composer-tool,
.dialog-form .composer-tool,
.ai-icon-button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; margin: 0; padding: 0; flex: none;
  border: 1px solid #dadce8; border-radius: 8px; color: var(--muted);
  background: transparent; cursor: pointer;
}
.composer .composer-tool:hover,
.dialog-form .composer-tool:hover,
.ai-icon-button:hover:not(:disabled) { background: #f3efff; color: var(--accent-dark); }
.ai-icon-button[hidden] { display: none; }
.ai-icon-button:disabled { opacity: .45; cursor: default; }
.ai-icon-button.is-off { color: var(--accent-dark); background: #f3efff; }
.composer .file-picker,
.dialog-form .file-picker {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; margin: 0; border: 1px solid #dadce8; border-radius: 8px; color: var(--muted); cursor: pointer;
}
.composer .file-picker input,
.dialog-form .file-picker input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; opacity: 0; cursor: pointer; }
.composer .template-picker,
.dialog-form .template-picker { width: auto; flex: none; }
.composer .template-picker .popover-toggle,
.dialog-form .template-picker .popover-toggle {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; margin: 0; padding: 0;
  border: 1px solid #dadce8; border-radius: 8px; color: var(--muted); background: transparent;
}
.composer .template-picker .popover-toggle:hover,
.composer .template-picker .popover-toggle[aria-expanded="true"],
.dialog-form .template-picker .popover-toggle:hover,
.dialog-form .template-picker .popover-toggle[aria-expanded="true"] {
  background: #f3efff; border-color: #dadce8; color: var(--accent-dark);
}
.composer .template-picker .popover-toggle > svg,
.dialog-form .template-picker .popover-toggle > svg { margin: 0; }
.composer .template-picker .popover-panel,
.dialog-form .template-picker .popover-panel {
  /* left/width fall back when not fixed; wirePopovers pins .template-picker to the viewport
     so #detail-actions / .dialog-form overflow does not clip the upward menu. */
  left: 0; right: auto; inset-inline: auto; width: min(280px, 70vw); z-index: 30;
}
.composer .template-picker .heading-menu-item,
.dialog-form .template-picker .heading-menu-item { font-weight: 650; }
.composer .template-picker-empty,
.dialog-form .template-picker-empty { margin: 8px 10px; font-size: 12px; }
.dialog-form .composer-footer { justify-content: flex-start; margin-top: 12px; }
.dialog-form .composer-audio-bar,
.dialog-form .composer-dictation-bar { margin-top: 8px; }
.dialog-form .composer-files { margin-top: 8px; }
.composer .template-picker-files {
  display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; font-size: 12px; font-weight: 500;
}
.composer .template-picker-files svg { flex: none; }
.template-files-field .composer-files { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; min-height: 0; }
/* Beat .dialog-form .file-picker (32×32 icon button): template control shows label text. */
.template-files-field .template-file-picker,
.dialog-form .template-files-field .file-picker.template-file-picker {
  position: relative; display: inline-flex; align-items: center; justify-content: flex-start; gap: 8px;
  width: auto; height: auto; min-height: 36px; margin: var(--space-3) 0 0; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius-control);
  background: var(--surface); color: var(--ink); cursor: pointer;
  font-size: 14px; font-weight: 650; white-space: nowrap;
}
.template-files-field .template-file-picker input,
.dialog-form .template-files-field .file-picker.template-file-picker input {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; opacity: 0; cursor: pointer;
}
.composer-footer span { color: var(--muted); font-size: 12px; }
.read-only { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.list-empty { padding: 17px 10px; color: var(--muted); font-size: 13px; }
.empty-detail { display: grid; place-content: center; justify-items: center; height: 100%; min-height: 130px; text-align: center; }
.empty-icon { display: grid; place-items: center; border-radius: var(--radius-modal); background: #eee8ff; color: var(--accent-dark); width: 49px; height: 49px; }
.empty-detail h2 { margin: 8px 0 4px; font-size: 18px; }
.empty-detail p { color: var(--muted); font-size: 13px; }
#compact-filters, .mobile-back { display: none; }
.project-shell { max-width: 1120px; margin: 0 auto; padding: 23px 24px; }
.project-heading { margin-bottom: 15px; }
.project-heading h1 { font-size: 28px; letter-spacing: -.045em; margin: 1px 0; }
.project-heading p { color: var(--muted); font-size: 13px; }
.project-frame {
  width: 100%; height: max(550px, calc(100dvh - 206px)); display: block; border: 1px solid #dedfed;
  border-radius: 13px; background: var(--surface);
}
.client-desk { grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); height: 100dvh; }
.client-desk .list-header .primary { margin-top: 14px; }
.widget-desk { grid-template-columns: minmax(0, 1fr); }
.widget-desk .list-pane { min-width: 0; }
.client-language + .widget-desk { height: calc(100dvh - 41px); }
.new-form { max-width: 560px; padding: 4px 0; }
.new-form label:not(:first-child) { margin-top: 12px; }
.new-form .composer-footer { justify-content: flex-end; margin-top: 15px; }
#notice {
  position: fixed; z-index: 5; bottom: 15px; right: 15px; max-width: min(380px, calc(100% - 30px));
  padding: 10px 14px; color: #fff; border-radius: 8px; background: #2d2d4d; box-shadow: 0 7px 26px #1d1a3b2b;
  font-size: 13px;
}
#notice.error { background: var(--danger); }
@media (max-width: 1040px) {
  .operator-desk { grid-template-columns: 190px minmax(238px, 285px) minmax(0, 1fr); }
  .detail-header, .messages, .composer, .read-only { padding-left: 17px; padding-right: 17px; }
}
@media (max-width: 860px) {
  .operator-desk { grid-template-columns: minmax(225px, 280px) minmax(0, 1fr); }
  .sidebar { display: none; }
  #compact-filters { margin-top: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
  #compact-filters select { font-size: 11px; padding-right: 4px; }
  .topbar { padding-inline: 14px; }
  .top-nav { margin-left: 0; gap: 12px; }
  .persona > span { display: none; }
}
@media (max-width: 660px) {
  .topbar { height: auto; min-height: 66px; padding: 9px 12px; gap: 8px; flex-wrap: wrap; }
  .brand { font-size: 15px; gap: 6px; }
  .brand img { width: 31px; height: 31px; }
  .top-nav { order: 4; flex-basis: 100%; }
  .top-nav a { padding-bottom: 5px; font-size: 13px; }
  .persona select { font-size: 11px; padding: 5px 3px; }
  .persona { max-width: 100%; flex-wrap: wrap; justify-content: flex-end; }
  .operator-desk { height: calc(100dvh - 81px); }
  .desk { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .detail-pane { display: none; }
  .desk.detail-open .list-pane { display: none; }
  .desk.detail-open .detail-pane { display: flex; }
  .detail-pane > .mobile-back { display: inline-flex; align-self: flex-start; margin: 5px 6px; }
  .list-header { padding: 16px 14px; }
  .client-desk .detail-header { min-height: 0; flex-wrap: wrap; padding-top: 48px; padding-bottom: 13px; }
  .client-desk .detail-header h2 { margin-block: 4px; }
  .client-desk .detail-header button { padding: 5px 8px; font-size: 12px; }
  .messages { padding-top: 15px; }
  .project-shell { padding: 13px 9px; }
  .project-heading h1 { font-size: 22px; }
  .project-heading p { font-size: 12px; }
  .project-frame { height: max(490px, calc(100dvh - 189px)); }
}
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.auth-shell { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.auth-card.download-page { width: min(100%, 720px); }
.download-version {
  margin: 10px 0 0;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control, 8px);
  background: var(--surface-2, var(--surface));
  font-size: 14px;
  color: var(--text);
}
.download-grid { display: grid; gap: 14px; margin: 18px 0 8px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.download-card { margin: 0; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-card, 12px); background: var(--bg, var(--surface)); }
.download-card h2 { margin: 0 0 6px; font-size: 18px; }
.download-card .download-meta { margin: 0; line-height: 1.4; }
.download-card .actions { margin-top: 12px; }
.download-card .actions .primary { width: auto; display: inline-flex; }
.auth-card { width: min(100%, 420px); border: 1px solid var(--border); border-radius: var(--radius-modal); padding: 28px; background: var(--surface); }
.auth-card .brand { margin-bottom: 22px; }
.auth-card h1, .settings h1 { font-size: 28px; letter-spacing: -.04em; line-height: 1.2; margin-block: 5px 8px; }
.auth-card label, .settings form label { display: block; margin-block: 12px 5px; font-size: 13px; font-weight: 700; }
.auth-card .primary, .settings form .primary { margin-top: 14px; }
.auth-card .primary { width: 100%; }
.inline-error { color: var(--danger); margin-top: 7px; font-size: 13px; }
.settings { max-width: 1060px; margin: auto; padding: 26px 20px; }
.settings-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr)); }
.settings-card, .settings-panel-body {
  box-sizing: border-box; min-width: 0; border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: var(--space-5); background: var(--surface); margin-top: 14px;
  display: grid; gap: var(--space-3); align-content: start;
}
.settings-card > *, .settings-panel-body > * { min-width: 0; max-width: 100%; }
.settings-card > label, .settings-panel-body > label { display: block; margin: 0; font-size: 13px; font-weight: 700; }
.settings-card > input, .settings-card > textarea, .settings-card > select,
.settings-panel-body > input, .settings-panel-body > textarea, .settings-panel-body > select { margin: 0; }
.settings-card h2, .settings-panel-body h2 { font-size: 18px; margin: 0; }
.access-project { border-top: 1px solid var(--border); padding-block: 12px; }
.access-project h3 { margin: 0; font-size: 15px; }
.access-heading { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.access-heading > div { min-width: 0; max-width: 100%; }
.staff-list { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 9px; }
.staff-list label { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.staff-list input { width: auto; }
.staff-list small { color: var(--muted); }
.integration-key { border-color: #d7c9fb; background: #f9f6ff; }
.integration-key dt { font-weight: 700; }
.integration-key dd { margin: 3px 0 9px; overflow-wrap: anywhere; }
#search { margin-top: 11px; font-size: 13px; }
.unread-dot { display: inline-block; width: 7px; height: 7px; margin-right: 5px; vertical-align: 1px; border-radius: 50%; background: var(--accent); }
.pagination { display: flex; flex-wrap: nowrap; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 11px; border-top: 1px solid var(--border); }
.pagination-total { color: var(--muted); font-size: 12px; white-space: nowrap; flex: none; }
.pagination-pages { display: flex; flex-wrap: nowrap; align-items: center; justify-content: flex-end; gap: 4px; min-width: 0; overflow-x: auto; }
.pagination-pages button { min-width: 30px; height: 30px; padding: 4px 6px; flex: none; white-space: nowrap; }
.pagination-icon { display: none; }
.list-pane .pagination,
.clients-card > .pagination { gap: 6px; padding: 6px 8px; }
.list-pane .pagination-pages,
.clients-card .pagination-pages { gap: 2px; }
.list-pane .pagination-pages button.compact,
.clients-card .pagination-pages button.compact { min-width: 26px; height: 26px; padding: 2px 5px; font-size: 12px; }
.list-pane .pagination-word,
.clients-card .pagination-word { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.list-pane .pagination-icon,
.clients-card .pagination-icon { display: inline-flex; }
.list-pane .pagination-next svg,
.clients-card .pagination-next svg { transform: rotate(180deg); }
.pagination-gap { color: var(--muted); padding: 0 2px; }
.pagination-last svg { transform: rotate(180deg); }
.pagination button:disabled { cursor: default; }
.ticket-controls {
  display: flex; flex-direction: column; flex: none; flex-wrap: nowrap; gap: 6px;
  justify-content: flex-start; align-items: flex-end;
}
.ticket-action-row,
.ticket-secondary-actions {
  display: flex; flex-flow: row nowrap; width: max-content; gap: 6px;
  justify-content: flex-end; align-items: center;
}
.ticket-controls form { display: flex; gap: 5px; }
.ticket-controls select { font-size: 12px; max-width: 145px; }
.ticket-ai-actions { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ticket-secondary-actions:empty,
.ticket-secondary-actions:not(:has(:not([hidden]))) { display: none; }

/* Overflow actions: inline on desktop, hamburger dropdown on narrow screens.
   Use `.actions-menu .actions-menu-toggle` so these win over the later dark-sidebar
   `.popover-toggle` rules (same single-class specificity otherwise shows the burger
   on desktop with sidebar hover colors). */
.actions-menu { position: relative; min-width: 0; }
.actions-menu .actions-menu-toggle {
  display: none; width: 32px; min-width: 32px; max-width: 32px; height: 32px; padding: 4px;
  justify-content: center; gap: 0; border: 1px solid var(--border); border-radius: var(--radius-control);
  color: var(--ink); background: var(--surface); text-align: center;
}
.actions-menu .actions-menu-toggle:hover,
.actions-menu .actions-menu-toggle[aria-expanded="true"] {
  background: var(--accent-wash); border-color: var(--accent); color: var(--accent-dark);
}
.actions-menu .actions-menu-toggle > svg { margin: 0; flex-shrink: 0; }
.crm-card-heading {
  display: flex; align-items: center; gap: 8px; margin: 0 0 8px; min-width: 0;
}
.crm-card-heading > h3 { flex: 1; min-width: 0; margin: 0; }
.crm-card-heading .mobile-crm-back { margin: 0; }
.crm-card-heading .actions-menu { flex: none; margin-left: auto; }
@media (max-width: 1100px) {
  .ticket-controls .actions-menu .actions-menu-toggle { display: inline-flex; }
  .ticket-controls .actions-menu .popover-panel {
    top: calc(100% + 4px); bottom: auto; right: 0; left: auto; inset-inline: auto 0;
    width: min(260px, calc(100vw - 24px)); max-height: min(70dvh, 420px);
    display: flex; flex-direction: column; align-items: stretch; gap: 2px;
    padding: var(--space-2); z-index: 30;
  }
  .ticket-controls .actions-menu .popover-panel[hidden] { display: none !important; }
  .ticket-controls .ticket-action-row,
  .ticket-controls .ticket-secondary-actions {
    flex-direction: column; flex-wrap: nowrap; width: 100%; max-width: none;
    align-items: stretch; gap: 2px;
  }
  .ticket-controls .ticket-action-row > .primary,
  .ticket-controls .ticket-action-row > .secondary,
  .ticket-controls .ticket-secondary-actions > .primary,
  .ticket-controls .ticket-secondary-actions > .secondary,
  .ticket-controls .heading-menu-item {
    flex: none; width: 100%; min-height: 36px; height: auto; padding: 8px 10px; font-size: 13px;
    line-height: 1.4; border-radius: var(--radius-control); font-weight: 650;
    justify-content: flex-start; text-align: left;
  }
  .mobile-menu-source { display: none !important; }
  [data-billing-slot]:has(> .mobile-menu-source) { display: none; }
  .crm-card-heading .actions-menu .actions-menu-toggle { display: inline-flex; }
  .crm-card-heading .actions-menu .popover-panel {
    top: calc(100% + 4px); bottom: auto; right: 0; left: auto; inset-inline: auto 0;
    width: min(260px, calc(100vw - 24px)); z-index: 30;
  }
  .crm-actions:has(> .mobile-menu-source) { display: none; }
}.message.internal .avatar { background: #f2e4bc; color: #735015; }
.note-tag { color: #7a5316; background: #fff0d2; padding: 1px 5px; border-radius: 4px; }
.file-label { min-width: 0; color: var(--muted); font-size: 12px !important; }
.file-label input { font-size: 12px; margin-top: 3px; padding: 3px; width: min(230px, 100%); }
.attachment { display: block; max-width: 100%; overflow-wrap: anywhere; margin-top: 4px; background: var(--accent-wash); color: var(--accent-dark); border: 1px solid #ded3fb; border-radius: 6px; padding: 4px 8px; text-align: left; font-size: 12px; line-height: 1.35; }
.attachment.attachment-pending { color: var(--muted); background: var(--wash); border-color: var(--border); }
.attachment-preview { margin: 6px 0 0; max-width: min(100%, 280px); }
.attachment-thumb {
  display: grid; place-items: center; width: 100%; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-control);
  background: #f4f5fb; overflow: hidden; cursor: zoom-in; min-height: 96px; max-height: 240px;
}
.attachment-thumb img {
  display: block; max-width: 100%; max-height: 240px; width: auto; height: auto; object-fit: contain; background: #fff; border: 0;
}
.attachment-thumb iframe { display: block; width: 100%; height: 180px; border: 0; pointer-events: none; background: #fff; }
.attachment-thumb .attachment-pdf-canvas {
  display: block; max-width: 100%; max-height: 240px; width: auto; height: auto; background: #fff;
}
.attachment-pdf-card {
  display: grid; place-items: center; gap: 6px; min-height: 120px; width: 100%; padding: 16px;
  color: var(--accent-dark); background: linear-gradient(180deg, #f7f5ff, #efeaff);
}
.attachment-pdf-label { font-size: 12px; font-weight: 700; letter-spacing: .04em; }
.attachment-placeholder { display: grid; place-items: center; min-height: 96px; padding: 12px; font-size: 12px; }
.attachment-caption { margin-top: 4px; width: 100%; font-size: 12px; }
.attachment-hover-preview {
  position: fixed; z-index: 40; overflow: auto; pointer-events: none;
  border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface);
  box-shadow: var(--shadow-modal); display: grid; place-items: center; padding: 8px;
}
.attachment-hover-preview img {
  display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; border: 0;
}
.attachment-hover-preview iframe { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.ticket-draft { display: inline-flex; align-items: center; color: var(--accent-dark); margin-right: 4px; vertical-align: -2px; }
.composer.composer-inline {
  display: grid; gap: 6px; background: var(--surface); border-top: 1px solid var(--border);
  padding: 10px 26px 12px; flex: none;
}
.composer-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: 0 0 2px; }
.composer-tabs [role="tab"] {
  border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent;
  padding: 4px 8px; font-weight: 600; font-size: 11px; line-height: 1.3; color: var(--muted); margin-bottom: -1px;
}
.composer-tabs [role="tab"][aria-selected="true"],
.composer-tabs [role="tab"].active { color: var(--accent-dark); border-bottom-color: var(--accent); }
.composer-files { display: flex; flex-wrap: wrap; gap: 6px; }
.composer-files:empty { display: none; }
.composer-file-chip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%;
  padding: 2px 4px 2px 8px; border-radius: 6px; background: var(--accent-wash); border: 1px solid #ded3fb; font-size: 11px;
}
.composer-file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer-file-chip button { min-width: 22px; min-height: 22px; padding: 0; }
#detail-actions {
  flex: 0 1 auto; min-width: 0; min-height: 0; max-height: calc(100% - 72px);
  display: flex; flex-direction: column; align-items: stretch;
  overflow-x: hidden; overflow-y: auto;
}
#detail-actions > .composer { margin: 0; min-height: 0; }
.composer.composer-claim {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface); border-top: 1px solid var(--border); padding: 12px 26px;
}
.composer.composer-claim > p { margin: 0; flex: 1; min-width: 12rem; }
#detail-actions > .ai-assistance {
  order: 0; align-self: stretch; width: 100%; box-sizing: border-box; margin: 0 0 8px;
}
#detail-actions > #reply-form,
#detail-actions > .composer,
#detail-actions > .composer-launcher { order: 1; }
#detail-actions.composer-collapsed {
  gap: 8px; padding: 8px 16px 12px;
  background: var(--surface); border-top: 1px solid var(--border);
}
#detail-actions.composer-collapsed #reply-form { display: none; }
#detail-actions > .composer-collapsed-bar {
  order: 1; display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0;
}
#detail-actions.composer-collapsed .composer-launcher {
  flex: 1; width: auto; height: auto; min-width: 0; min-height: 40px; padding: 8px 12px; gap: 8px;
  justify-content: flex-start; border: 1px solid var(--border); border-radius: var(--radius-control);
  background: var(--surface); color: var(--accent-dark); box-shadow: none;
}
.composer-launcher {
  background: transparent; border-color: transparent; box-shadow: none; color: var(--accent);
}
.composer-launcher:hover { background: transparent; color: var(--accent-dark); }
.composer-launcher-label { font-size: 13px; font-weight: 650; }
.composer-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0;
}
.composer-toolbar .composer-tabs { flex: 1; min-width: 0; margin: 0; border-bottom: 0; }
.composer-title { font-size: 12px; font-weight: 650; color: var(--muted); }
.composer-collapse { min-width: 28px; min-height: 28px; padding: 2px; color: var(--muted); flex-shrink: 0; }
.composer-channel-note {
  margin: 0; padding: 8px 10px; border-radius: 8px; background: #fff6de; border: 1px solid #f1e3b9;
  color: #735015; font-size: 13px;
}
.detail-pane > .pane-toggle {
  position: absolute; top: 10px; z-index: 5; min-width: 30px; min-height: 30px; padding: 4px;
  color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
.detail-pane > .pane-toggle-left { left: 10px; display: none; }
.operator-desk.list-collapsed .detail-pane > .pane-toggle-left { display: inline-grid; }
.detail-pane > .pane-toggle-right { right: 10px; }
.list-pane { position: relative; }
.list-pane > .pane-toggle-list {
  position: absolute; top: 16px; left: 10px; z-index: 4; min-width: 30px; min-height: 30px; padding: 4px;
  color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
.pane-toggle[aria-pressed="true"] { color: var(--accent-dark); background: var(--accent-wash); }
.detail-pane > .mobile-back { position: absolute; top: 8px; left: 8px; z-index: 5; }
.operator-desk.list-collapsed .detail-pane > .mobile-back { left: 46px; }
.operator-desk.list-collapsed .detail-header { padding-left: 56px; }
.operator-desk .detail-layout.crm-collapsed .detail-header { padding-right: 56px; }
@media (min-width: 661px) {
  .app-content > .operator-desk.list-collapsed { grid-template-columns: minmax(0, 1fr); }
  .app-content > .operator-desk.list-collapsed .list-pane { display: none; }
}
.detail-layout.crm-collapsed { grid-template-columns: minmax(0, 1fr); }
.detail-layout.crm-collapsed .detail-sidebar { display: none; }
.message-mode { margin-bottom: 5px; font-size: 13px; }
.older-messages { margin: 0 0 15px; }
#reopen-hint { font-size: 12px; margin-top: 4px; }
@media (max-width: 660px) {
  .ticket-controls { align-items: flex-start; }
  .ticket-controls select { max-width: 130px; }
}

.composer.note-mode { background: #fff9e9; }

.auth-link { margin-top: 17px; color: var(--accent-dark); font-size: 13px; }
.install-card { width: min(100%, 510px); }
.install-steps { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 16px 0; padding: 0; }
.install-steps li { padding: 4px 10px; border: 1px solid var(--border); border-radius: 8px; color: var(--muted); font-size: 13px; }
.install-steps li[aria-current="step"] { border-color: #d7c9fb; background: var(--accent-wash); color: var(--accent-dark); font-weight: 700; }
.install-actions { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px; margin-top: 14px; }
.install-actions .primary { margin: 0; }
.field-hint { margin-top: 6px; font-size: 13px; }
.copy-field { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.copy-field input { flex: 1 1 12rem; min-width: 0; }
.copy-field .crm-label { flex: 0 0 auto; font-size: 13px; color: var(--muted); }
.copy-field-multiline { align-items: stretch; }
.copy-field-multiline textarea {
  flex: 1 1 12rem; min-width: 0; min-height: 4.5rem; resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px;
}
body[data-view="widget"] { background: var(--bg, #f4f5f8); }
body[data-view="widget"] .auth-shell { min-height: 100dvh; }
body[data-view="widget"] .client-language .profile-entry span { display: none; }
.entity-copy-field { margin-top: 6px; }
.entity-copy-field input { font-size: 13px; }
.company-list { list-style: none; padding: 0; margin: 0; }
.company-list li { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; border-bottom: 1px solid var(--border); padding: 8px 0; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.auth-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.auth-card .auth-tools .brand { margin-bottom: 0; }
.language-picker { display: inline-flex; align-items: center; flex: 0 0 auto; }
.language-picker select { max-width: 100%; font-size: 12px; }
.client-language { height: 41px; display: flex; align-items: center; justify-content: flex-end; padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
.client-language + .client-desk { height: calc(100dvh - 41px); }

.help-link { color: var(--accent-dark); font-size: 13px; font-weight: 600; }
.auth-links { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 17px; font-size: 13px; color: var(--accent-dark); }
.client-language { gap: 12px; }
.help-topbar { height: auto; min-height: 67px; flex-wrap: wrap; padding-block: 10px; }
.help-home { color: var(--accent-dark); font-size: 13px; }
.help-languages { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; font-size: 13px; }
.help-languages a { padding: 4px 7px; border-radius: 6px; }
.help-languages a[aria-current="page"] { background: var(--accent-wash); color: var(--accent-dark); font-weight: 700; }
.help-page { max-width: 1160px; margin: 0 auto; padding: 26px 20px 40px; }
.help-page > h1 { font-size: clamp(25px, 4vw, 37px); margin-bottom: 4px; }
.help-layout { display: grid; grid-template-columns: minmax(180px, 235px) minmax(0, 1fr); gap: 16px; margin-top: 20px; }
.help-contents, .help-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 16px; }
.help-contents { align-self: start; }
.help-contents h2, .help-section h2 { font-size: 18px; }
.help-contents ul, .help-section ul { margin: 8px 0 0; padding-left: 20px; }
.help-contents li + li, .help-section li + li { margin-top: 7px; }
.help-contents a { color: var(--accent-dark); }
.help-section + .help-section { margin-top: 12px; }
.help-section li { overflow-wrap: anywhere; }
@media (max-width: 660px) {
  .help-page { padding: 16px 12px 28px; }
  .help-layout { grid-template-columns: minmax(0, 1fr); }
  .help-languages { margin-left: 0; }
}

.settings-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 22px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.settings-tabs [role="tab"] { padding: 10px 16px; border: 1px solid transparent; border-radius: 8px; background: transparent; font-weight: 600; }
.settings-tabs [role="tab"]:hover { background: var(--accent-wash); }
.settings-tabs [aria-selected="true"] { color: var(--accent-dark); background: var(--accent-wash); border-color: var(--accent); }

/* Shared UI-kit: all user data forms live in native modal dialogs. */
body:has(dialog[open]) { overflow: hidden; }
.modal {
  width: min(560px, calc(100% - 24px)); max-height: calc(100dvh - 24px);
  padding: 0; color: var(--ink); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-modal); box-shadow: var(--shadow-modal); overflow: hidden;
}
/* Scroll the form, not the dialog shell — native scrollbars otherwise square off the modal corners. */
.modal[open] { display: flex; flex-direction: column; }
.modal::backdrop { background: #20213980; }
.modal.attachment-fullscreen {
  width: min(96vw, 1100px); max-width: 96vw; height: min(90dvh, 860px); max-height: calc(100dvh - 24px);
  padding: 0; overflow: hidden; flex-direction: column;
}
.attachment-fullscreen-bar {
  display: flex; align-items: center; gap: 10px; flex: none;
  padding: 8px 12px; border-bottom: 1px solid var(--border); margin: 0;
}
.attachment-fullscreen-bar strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-fullscreen-tools { display: inline-flex; align-items: center; gap: 4px; }
.attachment-fullscreen-tools .subtle[hidden] { display: none; }
.attachment-fullscreen-body {
  flex: 1; min-height: 0; overflow: auto; background: #111; display: grid; place-items: center;
}
.attachment-fullscreen-body img {
  display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain;
  background: #111; border: 0;
}
.attachment-fullscreen-body iframe { display: block; width: 100%; height: 100%; min-height: 70dvh; border: 0; background: #fff; }
.attachment-pdf-pages {
  display: grid; gap: 12px; justify-items: center; width: 100%; padding: 8px; box-sizing: border-box;
}
.attachment-pdf-page {
  display: block; max-width: 100%; height: auto; background: #fff;
  border: 1px solid var(--border); border-radius: var(--radius-control);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border); flex: none;
}
.modal-header h2 { font-size: 20px; line-height: 1.3; overflow-wrap: anywhere; margin: 0; }
.modal-close { min-width: 36px; min-height: 36px; font-size: 24px; padding: 0; flex-shrink: 0; }
.modal .dialog-form {
  display: block; width: 100%; max-width: none; margin: 0; padding: var(--space-5); border: 0;
  overflow-y: auto; min-height: 0; flex: 1 1 auto;
}
.dialog-form label { display: block; margin: var(--space-3) 0 5px; font-size: 13px; font-weight: 700; }
/* Only the first field label — not labels nested as :first-child inside .search-select wrappers. */
.dialog-form > label:first-child,
.dialog-form > [data-form-fields] > label:first-child,
.dialog-form > .search-select:first-child > label,
.dialog-form > [data-form-fields] > .search-select:first-child > label { margin-top: 0; }
.modal .dialog-form select { font: inherit; width: 100%; max-width: 100%; }
.dialog-form .checkbox-field { display: flex; align-items: flex-start; gap: var(--space-2); }
.dialog-form .checkbox-field span { min-width: 0; overflow-wrap: anywhere; }
.checkbox-field input { width: 18px; height: 18px; accent-color: var(--accent); }
.modal .dialog-actions {
  display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: var(--space-2);
  margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--border);
}
.modal .dialog-actions .primary { margin: 0; width: auto; }
.dialog-error:empty, .composer-footer:empty { display: none; }
.modal .new-form label:not(:first-child) { margin-top: var(--space-3); }
.modal .file-label input { width: 100%; }
.modal[aria-busy="true"] { cursor: wait; }
#detail-actions > .primary { margin: 15px 26px; }
.access-person { flex: 1 1 240px; min-width: 0; max-width: 100%; padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-control); }
.access-person p { font-size: 12px; margin-block: 4px 8px; }
.settings-summary { margin: var(--space-4) 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-2) var(--space-4); }
.settings-summary dt { color: var(--muted); }
.settings-summary dd { margin: 0; overflow-wrap: anywhere; }
.kit-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--space-4); }
.kit-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: var(--space-4); }
.kit-grid .settings-card { margin: 0; }
.kit-examples { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-top: var(--space-4); }
.kit-palette { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: var(--space-3); margin-top: var(--space-4); }
.kit-swatch { border: 1px solid var(--border); border-radius: var(--radius-control); overflow: hidden; font-size: 12px; }
.kit-swatch div { height: 48px; }
.kit-swatch code { display: block; padding: 8px; overflow-wrap: anywhere; }
.swatch-accent { background: var(--accent); }
.swatch-dark { background: var(--dark); }
.swatch-wash { background: var(--wash); }
.swatch-ink { background: var(--ink); }
.swatch-border { background: var(--border); }
.swatch-surface { background: var(--surface); }
.kit-section { margin-top: var(--space-5); }
.kit-section > h2 { font-size: 20px; margin-bottom: var(--space-3); }
.kit-sample { border: 1px solid var(--border); border-radius: var(--radius-control); padding: var(--space-4); margin-top: var(--space-3); }
.kit-sample label { display: block; margin-block: var(--space-3) 5px; font-size: 13px; font-weight: 700; }
.kit-sample > label:first-child,
.kit-sample > .search-select:first-child > label { margin-top: 0; }
@media (max-width: 660px) {
  .modal-header { padding: var(--space-3) var(--space-4); }
  .modal .dialog-form { padding: var(--space-4); }
  .modal .install-actions { grid-template-columns: minmax(0, 1fr); }
}

.kit-icon { display: inline-flex; align-items: center; gap: 6px; padding: 6px 8px; background: var(--accent-wash); color: var(--accent-dark); border-radius: var(--radius-control); font-size: 12px; }
.kit-message-list { margin-top: var(--space-4); }
.kit-message-list .message:last-child { margin-bottom: 0; }
.settings-card > [data-dialog-trigger] { margin-top: var(--space-3); }

/* Profile entry and preview share the avatar and modal primitives. */
.profile-entry { display: inline-flex; align-items: center; gap: var(--space-2); min-width: 0; text-align: left; }
.profile-entry .profile-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.persona .profile-entry { flex: 0 1 190px; max-width: 190px; }
button.sidebar-foot { width: 100%; color: inherit; background: transparent; border: 0; border-radius: var(--radius-control); cursor: pointer; }
button.sidebar-foot:hover { background: #353452; }
img.avatar { object-fit: cover; }
.profile-preview { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-4); margin-bottom: var(--space-4); }
.profile-preview .avatar { width: 80px; height: 80px; font-size: 24px; border-radius: var(--radius-card); }
.client-language { height: auto; min-height: 41px; flex-wrap: wrap; padding-block: var(--space-1); }
@media (max-width: 860px) { .persona .profile-entry { flex: 0 0 auto; } .persona .profile-name { display: none; } }

.persona #company-switch { max-width: min(260px, 100%); }
.persona #logout { white-space: nowrap; }

/* Shared application shell. Sidebar geometry and controls use equal insets. */
.app-shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); height: 100dvh; max-height: 100dvh; min-height: 0; overflow: hidden; }
.app-sidebar.sidebar { display: flex; position: relative; z-index: 20; height: 100%; max-height: 100dvh; padding: 0; overflow: visible; }
.sidebar-heading { padding: var(--space-3) var(--space-3) 0; flex-shrink: 0; }
.sidebar-heading > .brand { width: 100%; padding: var(--space-3); gap: var(--space-3); color: #fff; font-size: 16px; }
.sidebar-heading .brand img { width: 36px; height: 36px; }
.workspace-switch { width: 100%; min-width: 0; margin-top: var(--space-3); padding: var(--space-3); gap: var(--space-3); text-align: left; color: #fff; background: transparent; border: 1px solid #41415d; border-radius: var(--radius-control); }
.workspace-switch:hover { background: #353452; }
.workspace-copy { flex: 1; min-width: 0; }
.workspace-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-icon { flex-shrink: 0; width: 36px; height: 36px; }
.sidebar-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: var(--space-4) var(--space-3); }
.primary-nav { display: grid; gap: var(--space-1); margin-bottom: var(--space-5); }
.primary-nav a { text-decoration: none; }
.nav-group { display: grid; gap: 2px; }
.nav-group > .side-link > .nav-parent-counts {
  display: none; align-items: center; gap: 4px; margin-left: auto; flex: none;
}
.nav-group > .side-link > .nav-parent-counts .unread-count { margin-left: 0; }
.nav-group > .side-link[aria-expanded="false"] > .nav-parent-counts:not(:empty) { display: inline-flex; }
.nav-group > .side-link > svg:last-child { margin-left: auto; transition: transform .15s ease; opacity: .7; }
.nav-group > .side-link:has(.nav-parent-counts:not(:empty))[aria-expanded="false"] > svg:last-child { margin-left: 0; }
.nav-group > .side-link[aria-expanded=true] > svg:last-child { transform: rotate(180deg); }
.side-subnav {
  display: grid; gap: 2px; margin: 0 0 var(--space-2) 4px; padding: 0 0 0 6px;
  border-left: 2px solid #41415d;
}
.side-subnav[hidden] { display: none !important; }
.side-subnav .side-label { padding-inline: 6px; margin-top: var(--space-2); }
.side-subnav .projects-label { margin-top: var(--space-2); }
.side-subnav .side-link { min-height: 32px; padding: 6px 8px; font-size: 12px; }
.option-search { display: block; margin: var(--space-2) 0 var(--space-3); }
.option-search input { width: 100%; }
.search-select { position: relative; }
.search-select-trigger { width: 100%; justify-content: space-between; text-align: left; margin-top: 5px; }
.search-select-panel {
  position: absolute; z-index: 6; inset-inline: 0; top: calc(100% + 4px); max-height: min(280px, 50dvh); overflow: auto;
  padding: var(--space-2); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-control);
  box-shadow: var(--shadow-modal);
}
/* Inside modals keep the list in normal flow so the dialog does not grow a nested scrollbar. */
.modal .search-select-panel {
  position: static; inset: auto; margin-top: var(--space-2); box-shadow: none; max-height: min(320px, 45dvh);
}
.search-select-filter { margin-bottom: var(--space-2); }
.search-select-options { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.search-select-option {
  width: 100%; text-align: left; padding: 8px 10px; border: 0; border-radius: var(--radius-control);
  background: transparent; color: var(--ink); font-size: 13px;
}
.search-select-option:hover, .search-select-option.selected { background: var(--accent-wash); color: var(--accent-dark); }
.detail-header { position: relative; min-height: 0; padding: 14px 18px 12px; }
.detail-header h2 { font-size: clamp(16px, 1.6vw, 22px); margin: 4px 0 6px; }
.detail-sidebar { padding: var(--space-3); font-size: 13px; }
.detail-sidebar .settings-card h3,
.detail-sidebar .crm-card-heading > h3 { font-size: 15px; margin-bottom: 0; }
.detail-sidebar p { margin: 0 0 8px; }
.detail-sidebar .crm-label { font-weight: 400; }
.detail-sidebar .crm-projects .project-label { font-weight: 600; }
.detail-sidebar .crm-projects-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 8px; }
.detail-sidebar .crm-projects-row .crm-projects { margin: 0; }
.detail-sidebar .crm-tags-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 8px; }
.detail-sidebar .crm-tags-row .customer-tags { margin: 0; }
.detail-sidebar .crm-add-tags { flex: none; }
.list-header h1 { font-size: 22px; }
.app-content .list-header > p { display: none; }
.operator-desk .list-header > #queue-project { display: block; margin: 2px 0 0; font-size: 13px; }
.app-sidebar .side-link { min-height: 40px; padding: 9px var(--space-3); gap: var(--space-3); }
.app-sidebar .side-label { padding-inline: var(--space-3); margin-top: var(--space-4); }
.app-sidebar .settings-tabs { flex-direction: column; align-items: stretch; gap: var(--space-1); border: 0; padding: 0; margin: 0; }
.app-sidebar .settings-tabs [role=tab] { color: #d9dbec; text-align: left; padding: 10px var(--space-3); font-size: 12.5px; font-weight: 600; border-radius: var(--radius-control); }
.app-sidebar .side-subnav .settings-tabs [role=tab] { padding: 8px; font-size: 12px; min-height: 34px; }
.app-sidebar .settings-tabs [role=tab]:hover, .app-sidebar .settings-tabs [aria-selected=true] { background: #353452; color: #fff; }
.app-sidebar .settings-tabs [aria-selected=true] { border-color: #686084; }
.app-content { min-width: 0; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.app-content:has(> .operator-desk),
.app-content:has(> .client-desk),
.app-content:has(> .clients-page),
.app-content:has(> .clients-workspace) { overflow: hidden; display: flex; flex-direction: column; }
.app-content > .operator-desk,
.app-content > .client-desk {
  /* Override the legacy topbar desk height (100dvh - 67px / min-height 510). */
  height: 100% !important; max-height: 100% !important; min-height: 0 !important; flex: 1;
  grid-template-columns: minmax(265px, 340px) minmax(0, 1fr);
}
.app-content > .clients-workspace { flex: 1; min-height: 0; height: 100%; max-height: 100%; }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, 320px); flex: 1; min-height: 0; min-width: 0; overflow: hidden; }
.detail-layout:has(> .detail-sidebar[hidden]) { grid-template-columns: minmax(0, 1fr); }
.detail-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.detail-sidebar {
  min-width: 0; min-height: 0; overflow: auto; border-left: 1px solid var(--border); background: var(--surface); padding: var(--space-4);
}
.operator-desk .detail-sidebar { padding-top: 48px; }
.crm-name-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 8px; }
.crm-name-row p { margin: 0; min-width: 0; }
.detail-sidebar a.client-queue-link {
  width: auto; margin: 0; padding: 4px 8px; min-height: 28px; gap: 4px; flex: none; font-size: 12px; text-decoration: none;
}
.client-queue-label { display: none; }
.crm-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.detail-sidebar .crm-actions > [data-dialog-trigger].primary { width: auto; flex: 1; min-width: 0; margin-top: 0; }
.detail-sidebar .crm-actions > .icon-only { width: 32px; min-width: 32px; height: 32px; padding: 4px; flex: none; }
.detail-sidebar .settings-card { margin-top: 0; border: 0; border-radius: 0; padding: 0; display: block; gap: 0; }
.detail-sidebar [data-dialog-trigger].primary {
  padding: 5px 10px; font-size: 12px; min-height: 30px; width: 100%; margin-top: 6px;
}
.app-content > .clients-page {
  flex: 1; min-height: 0; width: 100%; max-width: 1120px; margin: 0 auto;
  display: flex; flex-direction: column; overflow: hidden; padding: var(--space-6);
}
.clients-header {
  flex: none; display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4);
}
.clients-header h1 { margin-block: 5px 8px; }
.clients-search { width: min(280px, 42%); margin: 8px 0 0; flex: none; }
.clients-search input { width: 100%; }
.clients-card {
  flex: 1; min-height: 0; margin-top: var(--space-4); overflow: hidden;
  display: grid; grid-template-rows: minmax(0, 1fr) auto;
  border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface);
  padding: var(--space-5);
}
.clients-scroll { min-height: 0; overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table th { font-size: 12px; color: var(--muted); font-weight: 700; }
.data-table td:last-child { width: 1%; white-space: nowrap; }
.clients-card > .pagination { margin: 0; border-top: 1px solid var(--border); }
.client-row { align-items: flex-start; }
.client-projects { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.client-ticket-line { margin: 8px 0 0; font-size: 13px; }
.client-ticket { font-weight: 650; text-decoration: none; }
.client-ticket:hover { text-decoration: underline; }
.client-ticket.status-new { color: var(--new-ink); }
.client-ticket.status-active { color: var(--active-ink); }
.client-ticket.status-closed { color: var(--closed-ink); }
.entity-line, .entity-summary strong.entity-line, .entity-summary small.entity-line {
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--space-2);
}
.entity-summary .entity-line .project-label { flex: 1 1 10rem; min-width: 8rem; }
.entity-line .icon-edit { flex-shrink: 0; margin-top: 1px; }
.entity-line > .person-line { flex: 1; min-width: 0; }
.color-field-label,
.dialog-form .color-field-label,
.settings form .color-field-label {
  display: block; margin: var(--space-3) 0 5px; font-size: 13px; font-weight: 700;
}
.color-field-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin: 0 0 var(--space-4); }
.color-swatches { display: grid; grid-template-columns: repeat(6, 28px); gap: 6px; }
.color-swatch {
  width: 28px; height: 28px; padding: 0; border: 2px solid transparent; border-radius: 6px;
  background: #64748b; box-shadow: inset 0 0 0 1px #00000022; cursor: pointer;
}
.color-swatch[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px #00000022, 0 0 0 1px var(--surface); }
.color-swatch[data-color-swatch="e11d48"] { background: #e11d48; }
.color-swatch[data-color-swatch="ea580c"] { background: #ea580c; }
.color-swatch[data-color-swatch="ca8a04"] { background: #ca8a04; }
.color-swatch[data-color-swatch="16a34a"] { background: #16a34a; }
.color-swatch[data-color-swatch="0891b2"] { background: #0891b2; }
.color-swatch[data-color-swatch="2563eb"] { background: #2563eb; }
.color-swatch[data-color-swatch="6347d5"] { background: #6347d5; }
.color-swatch[data-color-swatch="7c6cf5"] { background: #7c6cf5; }
.color-swatch[data-color-swatch="db2777"] { background: #db2777; }
.color-swatch[data-color-swatch="0f766e"] { background: #0f766e; }
.color-swatch[data-color-swatch="64748b"] { background: #64748b; }
.color-swatch[data-color-swatch="111827"] { background: #111827; }
.color-custom,
.dialog-form label.color-custom,
.settings form label.color-custom {
  display: inline-flex; align-items: center; margin: 0; font-weight: inherit;
}
input.color-field { width: 64px; height: 36px; padding: 2px; }
.entity-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); flex-shrink: 0; }
.icon-edit {
  display: inline-grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: var(--radius-control);
  color: var(--accent-dark); background: transparent;
}
.icon-edit:hover { background: var(--accent-wash); }
.app-content > .settings:not(.clients-page) { width: 100%; padding: var(--space-6); margin: 0 auto; max-width: 1120px; }
.app-content .empty-detail { padding: var(--space-5); gap: var(--space-1); }
.app-content .list-header { padding: var(--space-5); }
.app-content > .operator-desk .list-header { padding-left: 48px; }
.app-content .list-empty { padding: var(--space-4); }
.sidebar-toggle, .sidebar-backdrop { display: none; }
.sidebar-guest-tools { padding: var(--space-4) var(--space-5); border-top: 1px solid #41415d; }
.sidebar-guest-tools .language-picker { width: 100%; }
.sidebar-guest-tools select { width: 100%; }

/* A user action menu belongs to the bottom user block, independent of profile editing. */
.user-panel { flex-shrink: 0; padding: var(--space-3); border-top: 1px solid #41415d; }
.popover { position: relative; min-width: 0; }
.popover-toggle { display: flex; align-items: center; width: 100%; gap: var(--space-3); padding: var(--space-3); border: 1px solid transparent; border-radius: var(--radius-control); color: inherit; background: transparent; text-align: left; }
.popover-toggle:hover, .popover-toggle[aria-expanded=true] { background: #353452; border-color: #686084; }
.popover-toggle > svg { flex-shrink: 0; margin-left: auto; }
.user-copy { min-width: 0; flex: 1; display: grid; gap: 3px; }
.user-copy strong { font-size: 13px; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-copy small { font-size: 11px; line-height: 1.4; color: #b5b6cb; }
.user-role-status { color: #f4d99b; font-size: 10px; line-height: 1.4; }
.user-panel .avatar { background: #433b67; color: #eee6ff; }
.popover-panel { position: absolute; z-index: 25; bottom: calc(100% + var(--space-2)); inset-inline: 0; max-height: min(450px, calc(100dvh - 120px)); overflow-y: auto; padding: var(--space-2); color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-modal); }
.user-menu-action { display: flex; width: 100%; gap: var(--space-3); align-items: center; padding: 10px var(--space-2); text-align: left; border: 0; border-radius: var(--radius-control); background: transparent; color: var(--ink); font-size: 13px; text-decoration: none; cursor: pointer; box-sizing: border-box; }
.user-menu-action:hover { background: var(--accent-wash); color: var(--accent-dark); }
.user-menu-action svg { flex-shrink: 0; }
.user-menu-signout { border-top: 1px solid var(--border); border-radius: 0; margin-top: var(--space-2); color: var(--danger); }
.user-menu-language { display: grid; gap: var(--space-2); padding: var(--space-3) var(--space-2); border-top: 1px solid var(--border); margin-top: var(--space-2); font-size: 12px; color: var(--muted); }
.user-menu-language select, .user-menu-language .language-picker { width: 100%; }
.user-menu-language select { font-size: 13px; color: var(--ink); }
.kit-user-demo { max-width: 240px; margin-top: var(--space-4); padding: var(--space-2); background: var(--dark); border-radius: var(--radius-card); color: #fff; }
.kit-user-demo .popover-panel { bottom: auto; top: calc(100% + var(--space-2)); }

/* Page heading menus sit on the light list/settings header and open downward. */
.queue-heading, .page-heading, .kit-heading-demo { position: relative; display: grid; gap: 2px; justify-items: stretch; min-width: 0; width: 100%; }
.queue-heading:has([aria-expanded="true"]), .page-heading:has([aria-expanded="true"]), .kit-heading-demo:has([aria-expanded="true"]) { z-index: 3; }
.kit-heading-demo {
  max-width: min(320px, 100%); margin-top: var(--space-4); padding: var(--space-4);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
}
.page-chrome-row {
  display: flex; align-items: center; gap: 6px; width: 100%; min-width: 0;
}
.page-chrome-row .heading-menu { flex: 1; min-width: 0; width: auto; }
.page-nav-link, .page-search-toggle { display: none; }
.heading-menu { position: relative; min-width: 0; max-width: 100%; }
.queue-heading .heading-menu, .page-heading .heading-menu, .kit-heading-demo .heading-menu { width: 100%; }
.page-chrome-row .heading-menu { width: auto; }
.page-heading > h1 { font-size: 22px; line-height: 1.15; letter-spacing: -.045em; margin: 5px 0; }
.settings > .page-heading { margin-bottom: 2px; }
.clients-header .page-heading { flex: 1; min-width: 0; }
.heading-menu:has([aria-expanded="true"]) { z-index: 1; }
.heading-menu .popover-toggle {
  width: auto; max-width: 100%; min-width: 0; gap: 4px; padding: 2px 4px; margin-inline: -4px;
  border-color: transparent; background: transparent; color: inherit; overflow: hidden;
}
.heading-menu .popover-toggle:hover, .heading-menu .popover-toggle[aria-expanded="true"] {
  background: var(--accent-wash); border-color: transparent; color: var(--accent-dark);
}
.heading-menu .popover-toggle > svg { margin-left: 2px; opacity: .7; transition: transform .15s ease; }
.heading-menu .popover-toggle[aria-expanded="true"] > svg { transform: rotate(180deg); }
.heading-menu-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.heading-menu-section .popover-toggle { color: var(--accent-dark); font-size: 10px; font-weight: 790; letter-spacing: .105em; text-transform: uppercase; }
.heading-menu-project .popover-toggle { color: var(--muted); font-size: 13px; font-weight: 450; letter-spacing: normal; text-transform: none; }
.heading-menu-title .popover-toggle { font-size: 22px; font-weight: 760; letter-spacing: -.045em; line-height: 1.15; text-transform: none; }
.list-header .heading-menu-title .popover-toggle { font-size: inherit; font-weight: inherit; letter-spacing: inherit; line-height: inherit; }
.heading-menu .popover-panel {
  top: calc(100% + 4px); bottom: auto; left: 0; right: 0; width: auto;
  font-size: 13px; font-weight: 650; letter-spacing: normal; line-height: 1.4; text-transform: none; color: var(--ink);
}
.heading-menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; padding: 8px 10px;
  border: 0; border-radius: var(--radius-control); background: transparent; color: var(--ink);
  font-size: 13px; font-weight: 650; line-height: 1.4; text-align: left; text-decoration: none;
  letter-spacing: normal; text-transform: none;
}
:is(.queue-heading, .clients-header .page-heading, .kit-heading-demo) .heading-menu-item {
  min-height: 44px; padding: 10px 12px; font-size: 14px;
}
.heading-menu-item span { min-width: 0; overflow-wrap: anywhere; }
.heading-menu-item .unread-count { margin-left: auto; }
.heading-menu-item:hover, .heading-menu-item[aria-current="true"], .heading-menu-item[aria-current="page"] {
  background: var(--accent-wash); color: var(--accent-dark);
}
.heading-menu-item .project-dot:not([data-project-color]) { background: var(--subdued); }


/* A single photo section: equal gaps around the preview, actions, and hint. */
.profile-photo-section { margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--border); }
.profile-photo-section h3 { margin: 0 0 var(--space-4); font-size: 13px; }
.profile-photo-editor { display: flex; gap: var(--space-4); align-items: center; flex-wrap: wrap; }
.profile-photo-editor .profile-preview { display: block; margin: 0; flex: 0 0 80px; }
.profile-photo-actions { display: flex; align-items: flex-start; flex-direction: column; gap: var(--space-2); min-width: 0; }
.dialog-form label.profile-upload { display: inline-flex; align-items: center; gap: var(--space-2); position: relative; cursor: pointer; margin: 0; font-size: 13px; font-weight: 670; }
.profile-upload:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.profile-photo-section .field-hint { margin-top: var(--space-4); }
.profile-details { padding-block: var(--space-3); border-block: 1px solid var(--border); margin-block: var(--space-4); }
.profile-notify-sound { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.profile-notify-sound select { flex: 1 1 12rem; min-width: 0; }
.profile-notify-sound .secondary { flex: 0 0 auto; }
.selection-hint { margin-bottom: var(--space-4); }
.modal-header { position: sticky; top: 0; z-index: 2; background: var(--surface); }

@media (max-width: 1200px) {
  .detail-layout { grid-template-columns: minmax(0, 1fr) minmax(220px, 270px); }
}
@media (max-width: 1040px) and (min-width: 901px) {
  .app-shell { grid-template-columns: 220px minmax(0, 1fr); }
  .app-content > .operator-desk { grid-template-columns: minmax(250px, 285px) minmax(0, 1fr); }
  .detail-layout { grid-template-columns: minmax(0, 1fr); }
  .detail-sidebar { border-left: 0; border-top: 1px solid var(--border); max-height: 40%; }
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .app-sidebar.sidebar { position: fixed; inset: 0 auto 0 0; width: min(280px, calc(100vw - 40px)); transform: translateX(-100%); visibility: hidden; }
  .app-shell[data-nav-open=true] .app-sidebar { transform: none; visibility: visible; }
  .app-shell > .sidebar-toggle {
    display: inline-flex; position: fixed; top: var(--space-3); left: var(--space-3); z-index: 10;
    box-shadow: 0 2px 8px #20213914;
  }
  .sidebar-backdrop:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 15; border: 0; background: #20213980; }
  .app-content { padding-top: 60px; }
  .app-content > .operator-desk { height: calc(100dvh - 60px); }
  .app-content > .settings,
  .app-content > .settings:not(.clients-page) {
    padding: 0; max-width: none; margin: 0; background: var(--surface); overflow-x: hidden;
  }
  .app-content > .clients-page {
    padding: 0; max-width: none; margin: 0; background: var(--surface);
  }
  .app-content #compact-filters { display: none; }
  .detail-layout { grid-template-columns: minmax(0, 1fr); }
  .detail-sidebar { border-left: 0; border-top: 1px solid var(--border); max-height: 38%; }
  .app-shell:has(.page-nav-link) > .sidebar-toggle { display: none; }
  .app-shell:has(.page-nav-link) .app-content { padding-top: 0; }
  .app-shell:has(.page-nav-link) .app-content > .operator-desk { height: 100dvh; }
  .app-shell.ticket-detail-open > .sidebar-toggle { display: none; }
  .app-shell.ticket-detail-open .app-content { padding-top: 0; }
  .app-shell.ticket-detail-open .app-content > .operator-desk { height: 100dvh; }
  .page-nav-link, .page-search-toggle {
    display: inline-grid; place-items: center; flex: none;
    width: 32px; min-width: 32px; height: 32px; min-height: 32px; padding: 0;
  }
  .page-search-toggle { margin-left: auto; }
  .page-chrome-row { gap: 4px; }
  .page-chrome-row .heading-menu .popover-toggle { margin-inline: 0; }
  .list-header #search,
  .clients-header .clients-search { display: none; width: 100%; }
  .list-header.search-open #search,
  .clients-header.search-open .clients-search { display: block; margin-top: 8px; }
  .clients-header.search-open .clients-search { width: 100%; }
  .clients-header {
    flex-direction: column; align-items: stretch; gap: 0;
    padding: var(--space-4); border-bottom: 1px solid var(--border);
  }
  .clients-header .page-heading-hint { margin: 8px 0 0; font-size: 12.5px; }
  .clients-page .clients-card {
    margin: 0; border: 0; border-radius: 0; padding: 0;
    background: transparent;
  }
  .clients-page .clients-scroll { padding: 0 var(--space-4); }
  .clients-page .clients-card > .pagination { padding: 6px 8px; }
  .settings > .page-heading {
    padding: var(--space-4); border-bottom: 1px solid var(--border); margin: 0;
  }
  .settings > .eyebrow {
    margin: 0; padding: var(--space-4) var(--space-4) 0;
  }
  .settings > h1 {
    margin: 5px 0 0; padding: 0 var(--space-4); font-size: 22px; letter-spacing: -.045em;
  }
  .settings > .page-heading-hint {
    margin: 0; padding: 8px var(--space-4) var(--space-3); font-size: 12.5px;
  }
  .settings .settings-panel-body {
    margin: 0; border: 0; border-radius: 0; padding: var(--space-4);
    background: transparent; box-shadow: none; width: 100%;
  }
  .settings .settings-summary {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: var(--space-2) var(--space-3);
  }
  .settings .list-toolbar h2 { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
  .settings .list-toolbar {
    justify-content: flex-end; margin-bottom: var(--space-3); gap: var(--space-2);
    min-width: 0; max-width: 100%;
  }
  .settings .list-toolbar > [data-dialog-trigger] { max-width: 100%; }
  .settings .entity-row {
    border-radius: 0; border-left: 0; border-right: 0; border-top: 0;
    background: transparent; padding: var(--space-3) 0; max-width: 100%;
  }
  .settings .entity-list { gap: 0; min-width: 0; }
  .settings #issued-key.settings-card {
    margin: var(--space-4); border-radius: var(--radius-card);
  }
}
@media (max-width: 1100px) {
  .app-content > .operator-desk .list-header { padding-left: var(--space-4); padding-right: var(--space-4); }
  .app-content > .operator-desk.detail-open { grid-template-columns: minmax(0, 1fr); }
  .app-content > .operator-desk.detail-open .list-pane { display: none; }
  .app-content > .operator-desk.detail-open .detail-pane { display: flex; }
  .app-content > .operator-desk.detail-open .mobile-back { display: inline-flex; }
  .app-content > .operator-desk.list-collapsed { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 660px) {
  .app-content > .operator-desk { grid-template-columns: minmax(0, 1fr); }
  .app-content .list-pane { display: flex; }
  .app-content .detail-pane { display: none; }
  .app-content > .operator-desk.detail-open .list-pane { display: none; }
  .app-content > .operator-desk.detail-open .detail-pane { display: flex; }
  .app-content .list-header { padding: var(--space-4); }
  .profile-details { grid-template-columns: minmax(0, 1fr); gap: var(--space-1); }
  .profile-details dd { margin-bottom: var(--space-2); }
  .detail-sidebar { max-height: 34%; }
}
.workspace-copy small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.help-shell .help-contents { position: static; padding: var(--space-3); background: transparent; color: #d9dbec; border: 0; }
.help-shell .help-contents h2 { color: #fff; }
.help-shell .help-contents a { color: inherit; }
.help-shell .help-contents li + li { margin-top: var(--space-3); }
.help-shell .help-languages { margin: 0; color: #d9dbec; justify-content: center; }
.help-shell .help-languages a[aria-current] { color: var(--accent-dark); }
.help-shell .help-page { margin: 0 auto; max-width: 980px; padding: var(--space-6); }
.help-shell .help-sections { margin-top: var(--space-5); }
@media (max-width: 900px) {
  .help-shell:not([data-nav-open]) { height: auto; }
  .help-shell:not([data-nav-open]) .app-sidebar { position: static; width: 100%; transform: none; visibility: visible; height: auto; }
  .help-shell:not([data-nav-open]) .sidebar-toggle { display: none; }
  .help-shell .help-page { padding: var(--space-4); }
}
.company-selection-page { display: grid; place-items: center; min-height: 100%; padding: var(--space-5); }
.company-selection-page select { width: 100%; margin-top: var(--space-4); }

/* Lists place creation beside the heading and editing beside the corresponding row. */
.list-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-4); margin-bottom: var(--space-4); }
.list-toolbar h2 { margin: 0; }
.list-toolbar > [data-dialog-trigger] { margin: 0; }
.list-filters {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-3); margin: 0 0 var(--space-4); max-width: 640px;
}
.list-filters > .search-select:first-child > label { margin-top: 0; }
.entity-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-3); }
.entity-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-control); }
.entity-summary { min-width: 0; flex: 1; }
.entity-summary strong, .entity-summary small { display: block; overflow-wrap: break-word; }
.entity-summary small { color: var(--muted); margin-top: var(--space-1); }
.billing-check-error { color: var(--spam-ink); margin: 0; padding: 8px 14px; background: var(--spam-wash); }
.detail-subject-actions { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; flex-shrink: 0; }
.modal.billing-dialog {
  width: min(1120px, calc(100% - 16px));
  height: min(860px, calc(100dvh - 24px));
  max-height: calc(100dvh - 24px);
}
.modal.billing-dialog .dialog-form {
  display: flex; flex-direction: column; gap: 0; padding: 0; overflow: hidden;
}
.modal.billing-dialog .dialog-actions { display: none; }
.billing-shell { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.billing-bar {
  display: flex; align-items: center; gap: 8px; flex: none; flex-wrap: wrap; min-width: 0;
  padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.billing-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; flex: 1 1 auto; }
.billing-chips:empty { display: none; }
.billing-bar-add { display: flex; align-items: center; gap: 4px; flex: 0 1 280px; min-width: min(100%, 200px); margin-left: auto; }
.billing-chips:empty + .billing-bar-add { margin-left: 0; }
.modal.billing-dialog .billing-add {
  display: flex; align-items: center; gap: 4px; flex: 1 1 auto; min-width: 0; margin: 0; font-weight: 400;
}
.billing-add input { flex: 1; min-width: 0; width: auto; height: 32px; padding: 4px 10px; font-size: 13px; }
.billing-bar .icon-only { width: 32px; min-width: 32px; height: 32px; padding: 0; flex: none; }
.modal.billing-dialog .dialog-error:not(:empty) { margin: 0; padding: 8px 14px; }
.billing-results { flex: 1; min-height: 0; display: flex; flex-direction: column; background: #f9f9fd; }
.billing-results > .billing-desk, .billing-results > .billing-empty { flex: 1; min-height: 0; }
.billing-note { margin: 0; padding: 6px 14px; }
.billing-empty.empty-detail { width: 100%; padding: 28px 20px; }
.billing-empty.empty-detail p { max-width: 42ch; }
.kit-billing-demo {
  border: 1px solid var(--border); border-radius: var(--radius-card);
  overflow: hidden; min-height: 280px; margin-top: 8px; background: var(--surface);
}
.kit-billing-demo .billing-desk { min-height: 240px; }
.billing-identifier-text {
  display: flex; align-items: flex-start; gap: 2px; flex: 1 1 auto; margin: 0; min-width: 0;
  color: var(--ink); font-size: 13px; line-height: 1.45;
}
.billing-identifier-text span { min-width: 0; overflow-wrap: anywhere; }
.billing-identifier-text .icon-edit { flex: none; margin-top: -1px; }
.billing-identifier-choices { display: grid; gap: 8px; margin-top: 10px; }
.billing-preloader {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 32px 16px; min-height: 220px; flex: 1;
}
.billing-preloader-spinner {
  width: 28px; height: 28px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: billing-spin 0.8s linear infinite;
}
@keyframes billing-spin { to { transform: rotate(360deg); } }
.billing-desk {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1.35fr) minmax(240px, 300px);
  min-height: 0; flex: 1; overflow: hidden;
}
.billing-desk-list,
.billing-desk-main,
.billing-desk-side {
  min-width: 0; min-height: 0; display: flex; flex-direction: column;
}
.billing-desk-list { background: var(--surface); border-right: 1px solid var(--border); }
.billing-desk-main { background: #f9f9fd; }
.billing-desk-side { background: var(--surface); border-left: 1px solid var(--border); }
.billing-desk-list-header,
.billing-desk-main-header,
.billing-desk-side-header {
  display: flex; align-items: center; gap: 8px; flex: none;
  min-height: 40px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.billing-mobile-back { display: none; }
.billing-account-list,
.billing-desk-scroll { flex: 1; min-height: 0; overflow: auto; }
.billing-account-list { padding: 8px; }
.billing-desk-scroll { padding: 12px 14px; }
.billing-account {
  display: grid; gap: 2px; width: 100%; text-align: left; cursor: pointer;
  margin-bottom: 4px; padding: 10px 11px; border: 1px solid transparent; border-bottom-color: #ececf4;
  border-radius: 8px; background: var(--surface); color: inherit; font: inherit;
}
.billing-account:hover { background: #f8f6ff; }
.billing-account.selected { background: #f5f1ff; border-color: #dfd2ff; }
.billing-account strong { font-size: 13.5px; }
.billing-account .ticket-meta, .billing-account .ticket-preview { font-size: 12px; color: var(--muted); }
.billing-placeholder { margin: 0; color: var(--muted); }
.billing-block { margin: 0 0 16px; }
.billing-block .eyebrow { margin: 0 0 8px; }
.billing-rows { display: grid; gap: 6px; }
.billing-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
.billing-row > div { display: grid; gap: 2px; min-width: 0; }
.billing-row strong, .billing-row span { overflow-wrap: anywhere; }
.billing-details h4 { margin: 0 0 2px; font-size: 18px; letter-spacing: -.03em; }
.billing-details p, .billing-meta-list { margin: 0 0 8px; }
.billing-plan { margin: 6px 0 2px; }
.billing-caption { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; color: var(--ink); }
.billing-period { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; }
.billing-period-left { color: var(--muted); }
.billing-period-mail { flex: none; }
.billing-facts { display: grid; gap: 8px; margin: 0 0 12px; }
.billing-facts div { display: grid; gap: 1px; min-width: 0; }
.billing-facts dt { color: var(--muted); font-size: 12px; font-weight: 400; }
.billing-facts dd { margin: 0; overflow-wrap: anywhere; }
.billing-actions { margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--border); }
.billing-action-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.billing-meta-list { list-style: none; padding: 0; display: grid; gap: 6px; }
.billing-meta-list li {
  display: flex; flex-wrap: wrap; gap: 6px 10px; justify-content: space-between; min-width: 0;
  padding: 6px 8px; background: var(--wash); border-radius: var(--radius-control);
}
.billing-meta-list a { overflow-wrap: anywhere; }
@media (max-width: 860px) {
  .modal.billing-dialog { width: calc(100% - 12px); height: calc(100dvh - 12px); max-height: calc(100dvh - 12px); border-radius: var(--radius-card); }
  .billing-bar-add { flex: 1 1 100%; max-width: none; margin-left: 0; }
  .billing-desk { grid-template-columns: minmax(0, 1fr); }
  .billing-desk-list { border-right: 0; }
  .billing-desk-side { border-left: 0; border-top: 1px solid var(--border); }
  .billing-desk:not(.account-open) .billing-desk-main,
  .billing-desk:not(.account-open) .billing-desk-side { display: none; }
  .billing-desk.account-open .billing-desk-list { display: none; }
  .billing-desk.account-open .billing-mobile-back { display: inline-flex; }
  .billing-desk.account-open .billing-desk-main { min-height: 42%; }
  .billing-desk.account-open .billing-desk-side { flex: 1; }
}
.entity-row > button { flex-shrink: 0; }
@media (max-width: 760px) {
  .entity-row { flex-wrap: wrap; align-items: flex-start; }
  .entity-summary, .entity-actions { flex: 1 1 100%; max-width: 100%; min-width: 0; }
  .entity-actions { flex-shrink: 1; }
}

/* Up to 1100px the queue and the open conversation are separate screens. */
@media (max-width: 1100px) {
  .app-content > .operator-desk {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
    height: 100%;
  }
  .app-content > .operator-desk .list-pane { display: flex; }
  .app-content > .operator-desk .detail-pane { display: none; }
  .app-content > .operator-desk.detail-open { grid-template-columns: minmax(0, 1fr); }
  .app-content > .operator-desk.detail-open .list-pane { display: none; }
  .app-content > .operator-desk.detail-open .detail-pane { display: flex; }
  .app-content > .operator-desk.detail-open .mobile-back { display: inline-flex; }
  .app-content > .operator-desk.list-collapsed:not(.detail-open) .list-pane { display: flex; }
  .pane-toggle,
  .operator-desk.list-collapsed .detail-pane > .pane-toggle-left { display: none; }
  .operator-desk.list-collapsed .detail-header { padding-left: 12px; }
  .operator-desk .detail-layout.crm-collapsed .detail-header { padding-right: 12px; }
  .app-content > .operator-desk.detail-open .detail-header {
    min-height: 0; display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "nav controls"
      "subject subject"
      "meta meta"
      "tags tags";
    align-items: center; column-gap: 8px; row-gap: 0;
    padding: var(--space-4) 12px 8px;
  }
  .app-content > .operator-desk.detail-open .detail-title {
    display: contents;
  }
  .app-content > .operator-desk.detail-open .detail-nav-row {
    grid-area: nav; gap: 6px; margin: 0; min-width: 0;
  }
  .app-content > .operator-desk.detail-open .detail-header .mobile-back {
    display: inline-flex; position: static; margin: 0; min-height: 24px; padding: 2px 6px; flex: none;
  }
  .app-content > .operator-desk.detail-open .detail-header .eyebrow {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; margin: 0;
  }
  .app-content > .operator-desk.detail-open .detail-subject-row {
    grid-area: subject; gap: 8px; margin: 8px 0;
  }
  .app-content > .operator-desk.detail-open .detail-header h2 {
    margin: 0; font-size: 16px; line-height: 1.25;
  }
  .app-content > .operator-desk.detail-open .detail-header h2 {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
  }
  .app-content > .operator-desk.detail-open .detail-client-card {
    display: inline-flex; flex: none; padding: 5px 8px; font-size: 12px; min-height: 28px;
  }
  .app-content > .operator-desk.detail-open .detail-meta {
    grid-area: meta; gap: 6px; margin: 0; min-width: 0;
  }
  .app-content > .operator-desk.detail-open .thread-tags { grid-area: tags; margin-top: 6px; }
  .app-content > .operator-desk.detail-open .detail-header > .thread-tags.is-collapsed { right: 12px; bottom: 6px; margin-top: 0; }
  .app-content > .operator-desk.detail-open .detail-layout.crm-collapsed .detail-header > .thread-tags.is-collapsed { right: 12px; }
  .app-content > .operator-desk.detail-open .detail-contact { flex-basis: 100%; }
  .app-content > .operator-desk.detail-open .mid-meta {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
  }
  .app-content > .operator-desk.detail-open .ticket-controls,
  .app-content > .operator-desk.detail-open .detail-header > .primary {
    grid-area: controls; justify-self: end; align-self: center;
  }
  .app-content > .operator-desk.detail-open .ticket-controls {
    display: flex; flex-direction: column; flex-wrap: nowrap; justify-content: flex-start;
    align-items: flex-end; gap: 0; flex: none; margin: 0;
  }
  .detail-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    min-height: 0;
  }
  .detail-main { min-height: 0; }
  .detail-sidebar,
  .operator-desk .detail-sidebar {
    display: none;
  }
  .detail-layout.crm-mobile-open {
    grid-template-rows: minmax(0, 1fr);
  }
  .detail-layout.crm-mobile-open .detail-main { display: none; }
  .detail-layout.crm-mobile-open .detail-sidebar,
  .operator-desk .detail-layout.crm-mobile-open .detail-sidebar {
    display: block; height: 100%; max-height: none; overflow: auto; flex: none;
    border-left: 0; border-top: 0; padding: 12px; padding-top: 12px;
  }
  .detail-layout.crm-mobile-open .mobile-crm-back {
    display: inline-flex; margin: 0; min-height: 32px; padding: 4px 8px;
  }
  .detail-layout.crm-mobile-open .detail-sidebar .settings-card {
    display: block; padding: 0; margin: 0;
  }
  .detail-layout.crm-mobile-open .detail-sidebar .crm-card-heading,
  .detail-layout.crm-mobile-open .detail-sidebar .crm-card-heading > h3,
  .detail-layout.crm-mobile-open .detail-sidebar .crm-brief,
  .detail-layout.crm-mobile-open .detail-sidebar .crm-extra { display: flex; }
  .detail-layout.crm-mobile-open .detail-sidebar .crm-card-heading > h3 { display: block; flex: 1; }
  .detail-layout.crm-mobile-open .detail-sidebar .crm-name-row {
    display: flex; flex: none; width: auto; margin: 0 0 8px;
  }
  .detail-layout.crm-mobile-open .crm-name-row { flex-wrap: wrap; }
  .detail-layout.crm-mobile-open .detail-sidebar a.client-queue-link { min-height: 44px; max-width: 100%; }
  .detail-layout.crm-mobile-open .client-queue-label { display: inline; }
  .detail-layout.crm-mobile-open .client-queue-count { display: none; }
  .detail-layout.crm-mobile-open .detail-sidebar .crm-actions {
    display: none;
  }
  .messages { min-height: 0; padding: 12px; }
  #detail-actions.composer-collapsed { padding: 8px 12px; }
}
/* Short tablet/desktop panes: one-row composer. Phones keep the stacked layout even when
   the soft keyboard drops viewport height below 720px (otherwise the field collapses beside tools). */
@media (min-width: 761px) and (max-width: 1100px) and (max-height: 720px) {
  .app-content > .operator-desk.detail-open .detail-header { padding: var(--space-4) 10px 6px; }
  .app-content > .operator-desk.detail-open .detail-header > .thread-tags.is-collapsed { right: 10px; bottom: 4px; }
  .app-content > .operator-desk.detail-open .detail-subject-row { margin: 6px 0; }
  .app-content > .operator-desk.detail-open .detail-header h2 { font-size: 15px; }
  .composer.composer-inline {
    display: flex; align-items: center; gap: 6px; padding: 4px 8px;
  }
  .composer.composer-inline .composer-toolbar { flex: 0 1 8rem; min-width: 0; }
  .composer.composer-inline .composer-collapse { display: none; }
  .composer.composer-inline .composer-title,
  .composer.composer-inline .composer-tabs { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .composer.composer-inline [data-composer-fields] { display: contents; }
  .composer.composer-inline #reply-body {
    flex: 1 1 auto; width: auto; min-width: 0; min-height: 34px; max-height: 34px;
  }
  .composer.composer-inline .composer-footer { flex: none; margin-top: 0; }
  .composer.composer-inline .composer-signature {
    flex: 0 1 auto; max-width: 42%; margin: 0; min-width: 0; font-size: 12px;
  }
  .composer.composer-inline .composer-signature span {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .messages { padding: 8px 10px; }
}
@media (max-width: 760px) and (max-height: 720px) {
  .app-content > .operator-desk.detail-open .detail-header { padding: var(--space-4) 10px 6px; }
  .app-content > .operator-desk.detail-open .detail-header > .thread-tags.is-collapsed { right: 10px; bottom: 4px; }
  .app-content > .operator-desk.detail-open .detail-subject-row { margin: 6px 0; }
  .app-content > .operator-desk.detail-open .detail-header h2 { font-size: 15px; }
  .composer.composer-inline {
    display: grid; gap: 4px; padding: 8px 12px 10px;
  }
  .composer.composer-inline #reply-body {
    min-height: 48px; max-height: min(120px, 28dvh);
  }
  .messages { padding: 8px 10px; }
}
@media (max-width: 660px) {
  .client-desk { min-height: 0; }
  .client-desk.detail-open .detail-pane > .mobile-back {
    position: static; align-self: flex-start; margin: 6px 8px 0;
  }
  .client-desk.detail-open .detail-header {
    min-height: 0; flex-wrap: wrap; padding: 4px 12px 8px;
  }
}
@media (min-width: 1101px) {
  .operator-desk:has(.detail-pane .conversation-return) .queue-heading > .conversation-return { display: none; }
  .detail-layout.crm-mobile-open .detail-main { display: flex; }
  .detail-layout.crm-mobile-open .mobile-crm-back { display: none; }
  .ticket-controls:not(.actions-menu-preview) > .actions-menu { display: contents; }
  .ticket-controls:not(.actions-menu-preview) .actions-menu-toggle { display: none; }
  .ticket-controls:not(.actions-menu-preview) .actions-menu .popover-panel,
  .ticket-controls:not(.actions-menu-preview) .actions-menu .popover-panel[hidden] {
    display: flex !important; position: static; inset: auto; width: auto; max-height: none;
    overflow: visible; padding: 0; border: 0; box-shadow: none; background: transparent;
    flex-direction: column; align-items: flex-end; gap: 6px;
  }
  .crm-card-heading .actions-menu { display: none; }
  [data-tag-menu-proxy],
  [data-mobile-action-proxy] { display: none !important; }
}
.actions-menu-preview .actions-menu .actions-menu-toggle { display: inline-flex; }
.actions-menu-preview .actions-menu .popover-panel {
  top: calc(100% + 4px); bottom: auto; right: 0; left: auto; inset-inline: auto 0;
  width: min(260px, calc(100vw - 24px)); max-height: min(70dvh, 420px);
  display: flex; flex-direction: column; align-items: stretch; gap: 2px;
  padding: var(--space-2); z-index: 30;
}
.actions-menu-preview .actions-menu .popover-panel[hidden] { display: none !important; }
.actions-menu-preview .ticket-action-row,
.actions-menu-preview .ticket-secondary-actions {
  flex-direction: column; flex-wrap: nowrap; width: 100%; align-items: stretch; gap: 2px;
}
.actions-menu-preview .ticket-action-row > .primary,
.actions-menu-preview .ticket-action-row > .secondary,
.actions-menu-preview .ticket-secondary-actions > .primary,
.actions-menu-preview .ticket-secondary-actions > .secondary {
  width: 100%; min-height: 36px; justify-content: flex-start; text-align: left;
}
@media (max-width: 760px) {
  .clients-header { flex-direction: column; align-items: stretch; }
  .clients-search { width: 100%; }
  .clients-page .data-table thead { display: none; }
  .clients-page .data-table,
  .clients-page .data-table tbody,
  .clients-page .data-table tr,
  .clients-page .data-table td { display: block; width: auto; }
  .clients-page .data-table tr { border-bottom: 1px solid var(--border); padding: 8px 0; }
  .clients-page .data-table td {
    border: 0; padding: 4px 0; white-space: normal; overflow-wrap: break-word;
  }
  .clients-page .data-table td:last-child { width: auto; padding-top: 8px; }
}

/* Customer workspace and shared compact directory components. */
.page-search-toggle { display: inline-flex; margin-left: auto; flex: none; }
.operator-desk .list-header:not(.search-open) #search,
.clients-header:not(.search-open) .clients-search { display: none; }
.clients-header.search-open .clients-search { display: block; width: 100%; }
.clients-workspace { display: grid; grid-template-columns: minmax(230px,.9fr) minmax(280px,1.2fr) minmax(240px,1fr); height: 100%; min-height: 0; overflow: hidden; }
.clients-workspace > * { min-width: 0; min-height: 0; }
.clients-directory { display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border); }
.clients-directory .clients-header { display: block; padding: var(--space-5); }
.clients-directory .clients-search { width: 100%; margin: 8px 0 0; }
.clients-directory .clients-scroll { flex: 1; padding: 8px; }
.customer-mini-card { display: flex; flex-direction: column; gap: 6px; width: 100%; text-align: left; padding: 12px; border: 1px solid transparent; border-bottom-color: var(--border); background: var(--surface); border-radius: var(--radius-control); color: var(--ink); }
.customer-mini-card:hover { background: var(--accent-wash); }
.customer-mini-card.selected { background: var(--accent-wash); border-color: var(--border); }
.customer-mini-card .person-line { width: 100%; min-width: 0; }
.customer-mini-card strong { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.customer-mini-contacts, .customer-mini-projects { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.customer-mini-projects .project-label { display: inline; }
.clients-workspace > .customer-card-pane { display: block; max-height: none; border-top: 0; border-left: 1px solid var(--border); padding: var(--space-5); }
.clients-workspace .mobile-crm-back { display: none; }
.customer-card-pane > select { margin-bottom: var(--space-4); }
.customer-tickets-pane { display: flex; flex-direction: column; border-left: 1px solid var(--border); background: var(--surface); }
.customer-tickets-pane > header { padding: var(--space-5); }
.customer-tickets-pane h2 { margin: 0; font-size: 18px; }
.customer-tickets-pane .ticket { display: flex; flex-direction: column; text-decoration: none; color: inherit; }
.customer-tickets-pane .ticket-list { flex: 1; min-height: 0; }
.clients-workspace .pagination { flex: none; padding: 6px; gap: 4px; }
.clients-workspace .pagination-pages { gap: 2px; }
.clients-workspace .pagination-pages button.compact { min-width: 24px; height: 26px; padding: 2px 4px; font-size: 12px; }
.clients-workspace .pagination-word { display: none; }
.clients-workspace .pagination-icon { display: inline-flex; }
.clients-workspace .pagination-next svg { transform: rotate(180deg); }
.tag-options { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-options [aria-pressed="true"] { outline: 2px solid var(--ink); outline-offset: 2px; }
.channel-project.unused legend, .channel-project .unused { color: var(--muted); }
.channel-project small { font-size: 12px; }
.operator-projects { display: flex !important; flex-wrap: wrap; align-items: center; gap: 6px; }
.project-chips { display: inline-flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.project-chips > span { display: inline-flex; padding: 2px 6px; border-radius: var(--radius-control); background: var(--accent-wash); }
@media (max-width: 760px) {
  .clients-workspace { display: flex; flex-direction: column; }
  .clients-workspace > * { flex: 1; }
  .clients-workspace[data-client-view="list"] > :not(.clients-directory),
  .clients-workspace[data-client-view="card"] > :not(.customer-card-pane),
  .clients-workspace[data-client-view="tickets"] > :not(.customer-tickets-pane) { display: none; }
  .clients-workspace .mobile-crm-back { display: inline-flex; margin-bottom: 16px; }
  .customer-card-pane .crm-name-row { flex-wrap: wrap; }
  .customer-card-pane a.client-queue-link { min-height: 44px; max-width: 100%; }
  .customer-card-pane .client-queue-label { display: inline; }
  .customer-card-pane .client-queue-count { display: none; }
}

.unread-count { display: inline-flex; align-items: center; justify-content: center; flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; line-height: 1; }
.message-html-preview { gap: 4px; margin-left: auto; }
.email-preview-dialog { width: min(1000px, calc(100vw - 32px)); }
.email-preview-frame { display: block; width: 100%; height: 65vh; min-height: 180px; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--surface); }

/* Shared customer labels and grouped channel choices. */
.customer-tags { display: inline-flex; flex-wrap: wrap; gap: var(--space-1); vertical-align: middle; }
.customer-tag { display: inline-flex; align-items: center; width: fit-content; max-width: 100%; padding: 2px 8px; border: 1px solid var(--accent); border-radius: 6px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
.tag-options { padding: 4px 2px; }
.detail-sidebar [data-customer-create] { margin-top: var(--space-3); }
.search-select-group { padding: var(--space-1) 0; }
.search-select-group ul { list-style: none; padding: 0; margin: 0; }
.search-select-group-label {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  padding: var(--space-2) 10px; border: 0; border-radius: var(--radius-control);
  background: transparent; color: inherit; font-size: 12px; font-weight: 700; text-align: left; cursor: pointer;
}
.search-select-group-label:hover { background: var(--accent-wash); }
.search-select-group-label::after {
  content: ""; flex: none; width: 6px; height: 6px; margin-left: 8px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg);
}
.search-select-group.collapsed .search-select-group-label::after { transform: rotate(-45deg); margin-top: 2px; }
.search-select-group.unused, .search-select-option.unused { color: var(--muted); }
.search-select-option:disabled { opacity: .55; cursor: not-allowed; }
.transfer-dialog .dialog-actions > button { flex: 1 1 0; min-width: 0; max-width: 140px; height: 38px; padding: 8px 12px; font-size: 13px; }

.search-select-trigger::after { content: ''; flex: 0 0 6px; height: 6px; margin: 0 3px 3px 12px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); }
.search-select-trigger[aria-expanded="true"]::after { transform: rotate(225deg); margin-bottom: -3px; }

/* Assignment history stays secondary to the public conversation. */
.assignment-event { display: flex; justify-content: center; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; margin: var(--space-3) 0; color: var(--muted); font-size: 11px; line-height: 1.5; text-align: center; overflow-wrap: anywhere; }
.assignment-event time { white-space: nowrap; }
.staff-person {
  display: inline; padding: 0; border: 0; border-bottom: 1px dotted currentColor; color: inherit;
  background: transparent; font: inherit; cursor: help;
}
.staff-person:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
.message-meta .staff-person { border-bottom-color: transparent; cursor: help; }
.message-meta .staff-person:hover, .assignment-event .staff-person:hover { border-bottom-color: currentColor; }
.staff-hover-card {
  position: fixed; z-index: 40; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-card);
  background: var(--surface); box-shadow: var(--shadow-modal); pointer-events: none;
}
.staff-hover-card .avatar { width: 40px; height: 40px; font-size: 14px; flex: none; }
.staff-hover-copy { display: grid; gap: 2px; min-width: 0; text-align: start; }
.staff-hover-copy strong { font-size: 13px; color: var(--ink); overflow-wrap: anywhere; }
.staff-hover-copy small { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.clients-toolbar { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-top: var(--space-3); }
.clients-toolbar .clients-filters { margin-top: 0; }
.contact-method-field { display: grid; gap: var(--space-1); min-width: 0; }
.contact-method-heading {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  margin-top: var(--space-2); min-width: 0;
}
.contact-method-heading .field-label { margin: 0; }
.contact-method-heading [data-contact-add] {
  flex: none; min-height: 28px; padding: 2px 6px; white-space: nowrap;
}
.contact-method-list { display: flex; flex-direction: column; gap: var(--space-1); }
.contact-method-row { display: flex; align-items: center; gap: var(--space-1); }
.contact-method-row input { flex: 1; min-width: 0; }
.contact-method-remove { flex: none; min-width: 28px; min-height: 28px; padding: 2px; }
.dialog-form .field-label, .settings-card form .field-label { display: block; margin-top: var(--space-3); font-size: 13px; color: var(--ink); }
.modal.crm-card-dialog .dialog-form { padding: var(--space-4); }
.modal.crm-card-dialog .dialog-form > label,
.modal.crm-card-dialog .dialog-form > .search-select > label {
  margin-top: var(--space-2); margin-bottom: 4px;
}
.modal.crm-card-dialog .dialog-form > label:first-child,
.modal.crm-card-dialog .dialog-form > .search-select:first-child > label { margin-top: 0; }
.modal.crm-card-dialog .contact-method-heading { margin-top: var(--space-2); }
.modal.crm-card-dialog .dialog-form > .contact-method-field:first-of-type .contact-method-heading { margin-top: var(--space-2); }
.modal.crm-card-dialog .dialog-form textarea {
  min-height: 38px; max-height: 120px; resize: vertical; field-sizing: content;
}
.modal.crm-card-dialog .dialog-actions { margin-top: var(--space-3); padding-top: var(--space-3); }
.clients-filters { margin-top: var(--space-3); }
.tag-filter { width: fit-content; max-width: 100%; }
.tag-filter .popover-toggle { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; min-height: 32px; border: 1px solid var(--border); border-radius: var(--radius-control); color: var(--ink); background: var(--surface); font-size: 12px; }
.tag-filter .popover-toggle[aria-expanded="true"] { border-color: var(--accent); color: var(--accent-dark); }
.filter-count { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; color: var(--accent-dark); background: var(--accent-wash); font-size: 11px; }
.tag-filter .popover-panel { top: calc(100% + 6px); bottom: auto; width: 280px; max-width: calc(100vw - 56px); padding: var(--space-3); inset-inline-start: 0; inset-inline-end: auto; }
.tag-filter-search { display: block; }
.tag-filter-search input { width: 100%; font-size: 12px; }
.tag-filter-hint { margin: var(--space-2) 0; font-size: 11px; }
.tag-filter-options { display: grid; gap: 4px; max-height: 220px; overflow: auto; }
.tag-filter-options .checkbox-field { display: flex; align-items: center; gap: 8px; min-height: 30px; cursor: pointer; }
.tag-filter-options input { width: 16px; height: 16px; accent-color: var(--accent); }
.tag-filter [data-clear-tag-filter] { margin-top: var(--space-2); padding: 5px 0; font-size: 12px; }

.project-badge { display: inline-flex !important; align-items: center; max-width: 100%; padding: 0; border: 0; border-radius: 0; font-size: inherit; font-weight: 600; line-height: inherit; letter-spacing: inherit; text-transform: inherit; vertical-align: baseline; overflow-wrap: anywhere; background: transparent; }
.project-badge:not([data-project-color]) { color: var(--accent); }
.eyebrow .project-label, .eyebrow .project-badge { font-size: inherit; font-weight: inherit; letter-spacing: inherit; text-transform: inherit; line-height: inherit; }
.thread-separator .project-badge { flex: none; margin-inline-end: 4px; }
.tag-create-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }

/* Sample label colors for /ui-kit examples (production uses /api/project-colors.css). */
.kit-section .customer-tag[data-tag-color="e11d48"] { background: #e11d48; color: #fff; border-color: #e11d48; }
.kit-section .customer-tag[data-tag-color="0891b2"] { background: #0891b2; color: #fff; border-color: #0891b2; }
.kit-section .project-label[data-project-color="kit-support"],
.kit-section .project-badge[data-project-color="kit-support"] { color: #16a34a; }
.kit-section .project-label[data-project-color="kit-sales"],
.kit-section .project-badge[data-project-color="kit-sales"] { color: #ea580c; }

/* Internal knowledge and optional AI controls use the shared UI-kit tokens. */
.ai-thread-tools,.ai-assistance-tools,.markdown-tools { display:flex; flex-wrap:wrap; gap:var(--space-2); align-items:center; }
.ai-section-tabs { margin-top:0; }
.ai-tabs { flex-wrap:wrap; gap:var(--space-2); margin:var(--space-4) 0; }
.ai-tabs [role="tab"] { padding:var(--space-2) var(--space-3); font-size:13px; }
.ai-tabs [role="tab"]:hover { background:var(--accent-wash); }
.ai-tags-fieldset { border:1px solid var(--border); border-radius:var(--radius-control); padding:var(--space-3); margin-top:var(--space-3); min-width:0; }
.ai-tags-fieldset legend { font-size:13px; color:var(--muted); padding:0 var(--space-1); }
.ai-thread-tools { margin-top:var(--space-2); font-size:12px; }
.ai-assistance {
  margin: var(--space-3) 0; padding: var(--space-2) var(--space-3);
  border: 1px solid #ded3fb; border-radius: var(--radius-card);
  background: var(--accent-wash); min-width: 0;
}
.ai-assistance[hidden], .ai-assistance-launcher[hidden] { display: none; }
.ai-assistance-heading {
  display: flex; justify-content: space-between; align-items: center;
  gap: var(--space-2); margin: 0; flex-wrap: wrap;
}
.ai-assistance-title { min-width: 0; flex: 1 1 8rem; }
.ai-assistance-actions { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.ai-assistance-heading strong { display: block; font-size: 12px; font-weight: 700; color: var(--accent-dark); line-height: 1.3; }
.ai-assistance-heading small { display: block; color: var(--muted); font-size: 10px; line-height: 1.35; margin-top: 1px; }
.ai-assistance-collapse { min-width: 28px; min-height: 28px; padding: 2px; color: var(--muted); flex-shrink: 0; }
.ai-assistance-body { display: grid; gap: var(--space-2); margin-top: var(--space-2); min-width: 0; }
.ai-assistance-body > .ai-assistance-tools { margin: 0; }
.ai-assistance-tools { min-width: 0; }
.ai-assistance-tools .subtle.compact,
.ai-assistance-tools .secondary.compact { font-size: 12px; white-space: normal; text-align: left; }
.ai-assistance-status { margin: 0; font-size: 12px; }
.ai-suggestion {
  padding: var(--space-2) var(--space-3); border: 1px solid #ded3fb;
  border-radius: var(--radius-control); background: var(--surface); overflow-wrap: anywhere;
}
.ai-suggestion > strong { font-size: 11px; color: var(--accent-dark); }
.ai-draft { white-space: pre-wrap; margin: var(--space-1) 0 var(--space-2); font-size: 13px; line-height: 1.45; }
.ai-brief {
  padding: var(--space-2) var(--space-3); border: 1px solid #ded3fb;
  border-radius: var(--radius-control); background: var(--surface); overflow-wrap: anywhere;
}
.ai-brief > strong { font-size: 11px; color: var(--accent-dark); }
.ai-brief p { margin: var(--space-1) 0 0; font-size: 13px; line-height: 1.45; white-space: pre-wrap; }
.ai-brief .secondary { margin-top: var(--space-2); }
.ai-disabled-note { margin: 0; font-size: 12px; }
.ai-review { color:var(--new-ink); background:var(--new-wash); }
.ai-feature-state { display:inline-block; font-size:12px; font-weight:600; padding:3px 8px; border-radius:var(--radius-control); color:var(--muted); background:var(--wash); }
.ai-feature-state.enabled { color:var(--accent-dark); background:var(--accent-wash); }
:is(.source-ai-settings, .collapsible-fields) { margin-top:var(--space-4); border-top:1px solid var(--border); padding-top:var(--space-3); }
:is(.source-ai-settings, .collapsible-fields) > summary { cursor:pointer; color:var(--muted); font-size:13px; font-weight:600; }
:is(.source-ai-settings, .collapsible-fields)[open] > summary { color:var(--ink); }
.knowledge-dialog { width:min(900px,calc(100vw - 24px)); }
.knowledge-dialog .dialog-actions { position:sticky; bottom:calc(-1 * var(--space-5)); z-index:2; padding:var(--space-3) 0; background:var(--surface); box-shadow:0 -8px 12px var(--surface); }
.markdown-editor { min-width:0; }
.markdown-editor textarea { width:100%; font-family:ui-monospace,monospace; font-size:14px; min-height:180px; resize:vertical; }
.markdown-editor details { margin-top:var(--space-3); }
.markdown-tools { gap:var(--space-1); margin-top:var(--space-3); }
.markdown-tools [data-md="italic"] { font-style:italic; }
.dialog-form label.md-upload { position:relative; display:inline-flex; align-items:center; gap:var(--space-1); margin:0; overflow:hidden; cursor:pointer; }
.md-upload input { position:absolute; width:1px; height:1px; opacity:0; }
.md-upload:focus-within { outline:2px solid var(--focus); outline-offset:2px; }
.markdown-body { overflow-wrap:anywhere; line-height:1.6; min-width:0; }
.markdown-body img { max-width:100%; height:auto; border-radius:var(--radius-control); }
.markdown-body pre { white-space:pre-wrap; overflow-wrap:anywhere; padding:var(--space-3); background:var(--wash); border-radius:var(--radius-control); }
.markdown-body blockquote { border-left:3px solid var(--border); margin:var(--space-3) 0; padding-left:var(--space-3); }
.markdown-body table { border-collapse:collapse; width:100%; }
.markdown-body td,.markdown-body th { border:1px solid var(--border); padding:var(--space-2); text-align:left; }
.md-table { max-width:100%; overflow-x:auto; }
.markdown-preview { padding:var(--space-3); border:1px solid var(--border); border-radius:var(--radius-control); }
@media(max-width:760px) { .knowledge-dialog .dialog-actions { bottom:calc(-1 * var(--space-4)); } }
@media(max-width:480px) { .ai-thread-tools,.ai-assistance-tools { align-items:stretch; } .ai-thread-tools button,.ai-assistance-tools button { white-space:normal; } .ai-tabs [role="tab"] { padding:var(--space-2); font-size:12px; } }
.thread-tags { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 4px; min-width: 0; margin-top: 2px; }
.detail-header > .thread-tags.is-collapsed {
  position: absolute; right: 18px; bottom: 8px; z-index: 3; width: auto; margin: 0; grid-template-columns: auto;
}
.detail-header > .thread-tags.is-collapsed .thread-tags-toggle { grid-column: 1; }
.detail-layout.crm-collapsed .detail-header > .thread-tags.is-collapsed { right: 56px; }
.thread-tags-toggle,
.thread-tags-edit {
  display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px;
  min-width: 22px; min-height: 22px; padding: 0; color: var(--muted); flex: none; border-radius: 4px;
}
.thread-tags-toggle:hover,
.thread-tags-edit:hover { color: var(--ink); background: #f3efff; }
.thread-tags-toggle svg { transition: transform .15s ease; }
.thread-tags-toggle[aria-expanded="false"] svg { transform: rotate(-90deg); }
.thread-tags-panel { grid-column: 1; grid-row: 1; min-width: 0; display: flex; flex-direction: column; align-items: stretch; gap: 4px; }
.thread-tags-toggle { grid-column: 2; grid-row: 1; align-self: end; }
.thread-tags-panel[hidden] { display: none; }
.thread-tags-row { display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px; min-width: 0; }
.thread-tags-label { flex: none; color: var(--muted); font-size: 11px; font-weight: 650; line-height: 1.3; }
.thread-tags-row .customer-tags { display: flex; flex-direction: row; flex-wrap: wrap; gap: 4px; min-width: 0; flex: 1 1 auto; }
.thread-tags .customer-tag {
  font-size: 10px; font-weight: 650; line-height: 1.4; padding: 0 5px; border-radius: 4px;
  white-space: nowrap; min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.thread-tags-divider { width: 100%; height: 0; margin: 1px 0; border: 0; border-top: 1px solid #c5c8d4; }
.thread-tags-extra { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.thread-tags.ai-thread-tools { align-items: end; }
.thread-tags.ai-thread-tools button { white-space: nowrap; }
