/* RockfyTalks Design System — componentes v0.1
   Usa somente tokens de tokens.css. Prefixo de classe: .rt- */

*, *::before, *::after { box-sizing: border-box; }
/* O atributo hidden sempre esconde, mesmo em componentes com display próprio */
[hidden] { display: none !important; }

.rt-root {
  font-family: var(--rt-font-sans);
  font-size: var(--rt-text-md);
  line-height: var(--rt-leading-md);
  color: var(--rt-text);
  background: var(--rt-bg-app);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}

.rt-icon { width: var(--rt-size-icon); height: var(--rt-size-icon); flex: none; color: var(--rt-icon); stroke-width: 1.5; }
.rt-icon--lg { width: var(--rt-size-icon-lg); height: var(--rt-size-icon-lg); }
.rt-mono { font-family: var(--rt-font-mono); font-size: var(--rt-text-2xs); letter-spacing: var(--rt-tracking-mono); text-transform: uppercase; }
.rt-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
:where(button, a, input, textarea, [tabindex]):focus-visible { outline: none; box-shadow: var(--rt-shadow-focus); }

/* ═══ Shell ═══════════════════════════════════════════ */
.rt-shell {
  display: grid;
  grid-template-columns: var(--rt-size-rail) var(--rt-size-sidebar) var(--rt-size-list) minmax(0, 1fr);
  grid-template-rows: var(--rt-size-header) minmax(0, 1fr);
  height: 100%;
  background: var(--rt-bg-app);
}
.rt-shell--with-details { grid-template-columns: var(--rt-size-rail) var(--rt-size-sidebar) var(--rt-size-list) minmax(0, 1fr) var(--rt-size-details); }

.rt-topbar-logo { grid-row: 1; grid-column: 1; display: grid; place-items: center; border-right: 1px solid var(--rt-border); border-bottom: 1px solid var(--rt-border); }
.rt-topbar { grid-row: 1; grid-column: 2 / -1; display: flex; align-items: center; gap: var(--rt-space-2); padding: 0 var(--rt-space-4); border-bottom: 1px solid var(--rt-border); }
.rt-topbar__title { font-size: var(--rt-text-md); font-weight: var(--rt-weight-medium); }

.rt-logo { width: 28px; height: 28px; border-radius: var(--rt-radius-md); background: var(--rt-bg-inverse); color: var(--rt-text-on-inverse); display: grid; place-items: center; }
.rt-logo .rt-icon { color: var(--rt-text-on-inverse); }

/* ═══ Rail ════════════════════════════════════════════ */
.rt-rail { grid-row: 2; grid-column: 1; display: flex; flex-direction: column; align-items: center; gap: var(--rt-space-1); padding: var(--rt-space-3) 0; border-right: 1px solid var(--rt-border); overflow-y: auto; }
.rt-rail__sep { width: 24px; height: 0; border-top: 1px dashed var(--rt-border-dashed); margin: var(--rt-space-2) 0; }
.rt-rail__spacer { flex: 1; }
.rt-rail-btn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: var(--rt-radius-md); border: 0; background: transparent; color: var(--rt-icon); cursor: pointer; transition: background var(--rt-duration-fast) var(--rt-ease); position: relative; }
.rt-rail-btn:hover { background: var(--rt-bg-hover); }
.rt-rail-btn[aria-current="page"] { background: var(--rt-bg-selected); }
.rt-rail-btn[aria-current="page"] .rt-icon { color: var(--rt-icon-strong); }
.rt-rail-btn--raised { background: var(--rt-bg-app); border: 1px solid var(--rt-border); box-shadow: var(--rt-shadow-xs); border-radius: var(--rt-radius-lg); margin-bottom: var(--rt-space-2); }

/* ═══ Sidebar (navegação secundária) ═════════════════ */
.rt-sidebar { grid-row: 2; grid-column: 2; display: flex; flex-direction: column; gap: var(--rt-space-0-5); padding: var(--rt-space-3) var(--rt-space-2-5); border-right: 1px solid var(--rt-border); overflow-y: auto; }
.rt-section { display: flex; align-items: center; justify-content: space-between; height: var(--rt-size-control); padding: 0 var(--rt-space-2-5); margin-top: var(--rt-space-5); color: var(--rt-text-muted); }
.rt-section:first-child { margin-top: 0; }

.rt-nav-item { display: flex; align-items: center; gap: var(--rt-space-2-5); height: var(--rt-size-control); padding: 0 var(--rt-space-2-5); border-radius: var(--rt-radius-md); color: var(--rt-text); text-decoration: none; font-size: var(--rt-text-md); cursor: pointer; transition: background var(--rt-duration-fast) var(--rt-ease); border: 0; background: transparent; width: 100%; text-align: left; font-family: inherit; }
.rt-nav-item:hover { background: var(--rt-bg-hover); }
.rt-nav-item[aria-current="page"] { background: var(--rt-bg-selected); font-weight: var(--rt-weight-medium); }
.rt-nav-item__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rt-count { font-size: var(--rt-text-sm); color: var(--rt-text-muted); font-variant-numeric: tabular-nums; font-weight: var(--rt-weight-regular); }

/* ═══ Controles ═══════════════════════════════════════ */
.rt-input { display: flex; align-items: center; gap: var(--rt-space-2); height: var(--rt-size-control); padding: 0 var(--rt-space-2-5); border: 1px solid var(--rt-border); border-radius: var(--rt-radius-md); background: var(--rt-bg-app); color: var(--rt-text); transition: border-color var(--rt-duration-fast) var(--rt-ease); }
.rt-input:hover { border-color: var(--rt-border-strong); }
.rt-input:focus-within { border-color: var(--rt-border-strong); box-shadow: var(--rt-shadow-focus); }
.rt-input input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font: inherit; color: inherit; }
.rt-input input::placeholder { color: var(--rt-text-subtle); }
.rt-input .rt-icon { color: var(--rt-icon-subtle); }
.rt-input--error { border-color: var(--rt-danger-text); }
.rt-field { display: flex; flex-direction: column; gap: var(--rt-space-1-5); }
.rt-field__label { font-size: var(--rt-text-sm); font-weight: var(--rt-weight-medium); }
.rt-field__hint { font-size: var(--rt-text-xs); color: var(--rt-text-subtle); }
.rt-field__error { font-size: var(--rt-text-xs); color: var(--rt-danger-text); }

.rt-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--rt-space-1-5); height: var(--rt-size-control); padding: 0 var(--rt-space-3); border-radius: var(--rt-radius-md); border: 1px solid transparent; font: inherit; font-size: var(--rt-text-md); font-weight: var(--rt-weight-medium); cursor: pointer; white-space: nowrap; transition: background var(--rt-duration-fast) var(--rt-ease), border-color var(--rt-duration-fast) var(--rt-ease); }
.rt-btn--primary { background: var(--rt-bg-inverse); color: var(--rt-text-on-inverse); }
.rt-btn--primary .rt-icon { color: var(--rt-text-on-inverse); }
.rt-btn--primary:hover { background: var(--rt-bg-inverse-hover); }
.rt-btn--secondary { background: var(--rt-bg-app); color: var(--rt-text); border-color: var(--rt-border); box-shadow: var(--rt-shadow-xs); }
.rt-btn--secondary:hover { background: var(--rt-bg-hover); }
.rt-btn--ghost { background: transparent; color: var(--rt-text); }
.rt-btn--ghost:hover { background: var(--rt-bg-hover); }
.rt-btn--danger { background: var(--rt-bg-app); color: var(--rt-danger-text); border-color: var(--rt-border); }
.rt-btn--danger:hover { background: var(--rt-danger-bg); }
.rt-btn--sm { height: var(--rt-size-control-sm); padding: 0 var(--rt-space-2-5); font-size: var(--rt-text-sm); }
.rt-btn:disabled, .rt-btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }

.rt-icon-btn { width: var(--rt-size-control-sm); height: var(--rt-size-control-sm); display: inline-grid; place-items: center; border-radius: var(--rt-radius-sm); border: 0; background: transparent; color: var(--rt-icon); cursor: pointer; transition: background var(--rt-duration-fast) var(--rt-ease); }
.rt-icon-btn:hover { background: var(--rt-bg-hover); }
.rt-icon-btn--outline { width: 22px; height: 22px; border: 1px solid var(--rt-border); background: var(--rt-bg-app); border-radius: var(--rt-radius-sm); box-shadow: var(--rt-shadow-xs); }
.rt-icon-btn--outline .rt-icon { width: 12px; height: 12px; }

/* ═══ Avatar ══════════════════════════════════════════ */
.rt-avatar { position: relative; flex: none; display: inline-grid; place-items: center; width: var(--rt-size-avatar-md); height: var(--rt-size-avatar-md); border-radius: var(--rt-radius-sm); background: var(--rt-avatar-1); color: var(--rt-avatar-ink); font-size: var(--rt-text-2xs); font-weight: var(--rt-weight-semibold); letter-spacing: 0.02em; }
.rt-avatar--xs { width: var(--rt-size-avatar-xs); height: var(--rt-size-avatar-xs); border-radius: var(--rt-radius-xs); font-size: 8px; }
.rt-avatar--sm { width: var(--rt-size-avatar-sm); height: var(--rt-size-avatar-sm); font-size: 10px; }
.rt-avatar--lg { width: var(--rt-size-avatar-lg); height: var(--rt-size-avatar-lg); border-radius: var(--rt-radius-md); font-size: var(--rt-text-sm); }
.rt-avatar--round { border-radius: var(--rt-radius-full); }
.rt-avatar[data-tone="2"] { background: var(--rt-avatar-2); }
.rt-avatar[data-tone="3"] { background: var(--rt-avatar-3); }
.rt-avatar[data-tone="4"] { background: var(--rt-avatar-4); }
.rt-avatar[data-tone="5"] { background: var(--rt-avatar-5); }
.rt-avatar[data-tone="6"] { background: var(--rt-avatar-6); }
.rt-avatar--ai { background: var(--rt-bg-inverse); color: var(--rt-text-on-inverse); }
.rt-avatar--ai .rt-icon { color: var(--rt-text-on-inverse); width: 60%; height: 60%; }
.rt-avatar__dot { position: absolute; left: -2px; bottom: -2px; width: 8px; height: 8px; border-radius: var(--rt-radius-full); background: var(--rt-unread-dot); box-shadow: 0 0 0 2px var(--rt-bg-app); }
.rt-avatar__channel { position: absolute; right: -4px; bottom: -4px; box-shadow: 0 0 0 2px var(--rt-bg-app); border-radius: var(--rt-radius-xs); }

/* ═══ Ícones de canal (marca) ═════════════════════════ */
.rt-channel { flex: none; display: inline-grid; place-items: center; width: var(--rt-size-icon); height: var(--rt-size-icon); border-radius: var(--rt-radius-xs); color: #fff; }
.rt-channel svg { width: 11px; height: 11px; stroke: #fff; }
.rt-channel--sm { width: 12px; height: 12px; border-radius: 3px; }
.rt-channel--sm svg { width: 8px; height: 8px; }
.rt-channel--whatsapp { background: var(--rt-brand-whatsapp); }
.rt-channel--email { background: var(--rt-brand-email); }
.rt-channel--instagram { background: var(--rt-brand-instagram); }
.rt-channel--phone { background: var(--rt-brand-phone); }
.rt-channel--widget { background: var(--rt-brand-widget); }

/* ═══ Ícones de status ════════════════════════════════ */
.rt-status { width: var(--rt-size-icon); height: var(--rt-size-icon); flex: none; }
.rt-status--open { color: var(--rt-status-open); }
.rt-status--ai { color: var(--rt-status-ai); }
.rt-status--needs-reply { color: var(--rt-status-needs-reply); }
.rt-status--waiting { color: var(--rt-status-waiting); }
.rt-status--resolved { color: var(--rt-status-resolved); }

.rt-status-chip { display: inline-flex; align-items: center; gap: var(--rt-space-1-5); font-family: var(--rt-font-mono); font-size: var(--rt-text-xs); letter-spacing: var(--rt-tracking-mono); text-transform: uppercase; color: var(--rt-text-muted); }
.rt-status-chip .rt-status { width: 14px; height: 14px; }
.rt-status-chip--ai { color: var(--rt-status-ai-text); }
.rt-status-chip--needs-reply { color: var(--rt-status-needs-reply-text); }
.rt-status-chip--waiting { color: var(--rt-status-waiting-text); }
.rt-status-chip--resolved { color: var(--rt-status-resolved-text); }

.rt-tag { display: inline-flex; align-items: center; gap: var(--rt-space-1-5); height: 22px; padding: 0 var(--rt-space-2); border: 1px solid var(--rt-border); border-radius: var(--rt-radius-sm); font-size: var(--rt-text-xs); color: var(--rt-text-secondary); background: var(--rt-bg-app); }
.rt-tag__dot { width: 6px; height: 6px; border-radius: var(--rt-radius-full); background: currentColor; }

/* ═══ Cabeçalho de painel ═════════════════════════════ */
.rt-panel { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.rt-panel--bordered { border-right: 1px solid var(--rt-border); }
.rt-panel-header { flex: none; display: flex; align-items: center; gap: var(--rt-space-2); height: var(--rt-size-header); padding: 0 var(--rt-space-3) 0 var(--rt-space-4); border-bottom: 1px solid var(--rt-border); }
.rt-panel-header__title { flex: 1; min-width: 0; font-weight: var(--rt-weight-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rt-shell:not(.rt-shell--with-details) .rt-details { display: none; }
.rt-panel-header__actions { display: flex; gap: var(--rt-space-0-5); }
.rt-panel-body { flex: 1; min-height: 0; overflow-y: auto; }

/* ═══ Lista de conversas ══════════════════════════════ */
.rt-conv-list { display: flex; flex-direction: column; gap: var(--rt-space-0-5); padding: var(--rt-space-1-5); }
.rt-conv-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; column-gap: var(--rt-space-3); row-gap: var(--rt-space-0-5); align-items: center; min-height: var(--rt-size-row); padding: var(--rt-space-2-5) var(--rt-space-3) var(--rt-space-2-5) var(--rt-space-3); border-radius: var(--rt-radius-lg); cursor: pointer; text-decoration: none; color: inherit; transition: background var(--rt-duration-fast) var(--rt-ease); }
.rt-conv-item:hover { background: var(--rt-bg-hover); }
.rt-conv-item[aria-current="true"] { background: var(--rt-bg-selected); }
.rt-conv-item .rt-avatar { grid-row: 1 / 3; align-self: start; margin-top: 2px; }
.rt-conv-item__name { font-weight: var(--rt-weight-medium); display: flex; align-items: center; gap: var(--rt-space-1-5); min-width: 0; }
.rt-conv-item__preview { font-size: var(--rt-text-md); color: var(--rt-text-secondary); }
.rt-conv-item__time { font-size: var(--rt-text-sm); color: var(--rt-text-subtle); justify-self: end; font-variant-numeric: tabular-nums; }
.rt-conv-item--read .rt-conv-item__name { font-weight: var(--rt-weight-regular); color: var(--rt-text-secondary); }
.rt-conv-item--read .rt-conv-item__preview { color: var(--rt-text-subtle); }
.rt-conv-item__status { justify-self: end; display: flex; }

/* ═══ Conversa ════════════════════════════════════════ */
.rt-thread { display: flex; flex-direction: column; gap: var(--rt-space-5); padding: var(--rt-space-6) var(--rt-space-10) var(--rt-space-6) var(--rt-space-12); }

.rt-activity { display: flex; flex-direction: column; gap: var(--rt-space-2-5); padding-bottom: var(--rt-space-5); border-bottom: 1px dashed var(--rt-border-dashed); }
.rt-activity__title { color: var(--rt-text-muted); font-size: var(--rt-text-md); margin-bottom: var(--rt-space-1); }
.rt-activity__row { display: flex; align-items: center; gap: var(--rt-space-2); flex-wrap: wrap; font-size: var(--rt-text-md); }
.rt-activity__actor { font-weight: var(--rt-weight-medium); }
.rt-activity__verb { color: var(--rt-text-muted); }
.rt-activity__time { color: var(--rt-text-subtle); font-size: var(--rt-text-xs); margin-left: auto; }

.rt-msg { display: flex; align-items: flex-end; gap: var(--rt-space-3); max-width: 78%; }
.rt-msg--out { align-self: flex-end; flex-direction: row-reverse; }
.rt-msg__avatar { align-self: flex-start; margin-top: var(--rt-space-1); }
.rt-msg__body { display: flex; flex-direction: column; gap: var(--rt-space-1); align-items: flex-start; }
.rt-msg--out .rt-msg__body { align-items: flex-end; }
.rt-bubble { padding: var(--rt-space-1-5) var(--rt-space-2-5); border-radius: var(--rt-radius-lg); background: var(--rt-bg-bubble-in); color: var(--rt-text); font-size: var(--rt-text-md); line-height: var(--rt-leading-md); white-space: pre-wrap; overflow-wrap: anywhere; }
.rt-msg--out .rt-bubble { background: var(--rt-bg-bubble-out); color: var(--rt-text-on-inverse); }
.rt-msg__time { flex: none; font-size: var(--rt-text-sm); color: var(--rt-text-subtle); padding-bottom: var(--rt-space-1); white-space: nowrap; display: inline-flex; align-items: center; gap: var(--rt-space-1); }
.rt-msg__time .rt-icon { width: 14px; height: 14px; color: var(--rt-icon-subtle); }
.rt-msg__author { display: inline-flex; align-items: center; gap: var(--rt-space-1); font-family: var(--rt-font-mono); font-size: var(--rt-text-2xs); letter-spacing: var(--rt-tracking-mono); text-transform: uppercase; color: var(--rt-text-muted); }
.rt-msg__author .rt-icon { width: 12px; height: 12px; }
.rt-msg__author--ai { color: var(--rt-status-ai-text); }
.rt-msg__author--ai .rt-icon { color: var(--rt-status-ai); }

/* Nota interna: tracejada, nunca preenchida com cor */
.rt-msg--note { align-self: stretch; max-width: none; }
.rt-note { flex: 1; padding: var(--rt-space-2-5) var(--rt-space-3); border: 1px dashed var(--rt-border-strong); border-radius: var(--rt-radius-lg); background: var(--rt-bg-subtle); font-size: var(--rt-text-md); color: var(--rt-text-secondary); }
.rt-note__head { display: flex; align-items: center; gap: var(--rt-space-1-5); margin-bottom: var(--rt-space-1); }

/* Mensagem de sistema */
.rt-system { align-self: center; display: inline-flex; align-items: center; gap: var(--rt-space-2); font-size: var(--rt-text-sm); color: var(--rt-text-muted); }

/* Resumo de transferência da IA */
.rt-summary { border: 1px solid var(--rt-border); border-radius: var(--rt-radius-xl); padding: var(--rt-space-3) var(--rt-space-4); display: flex; flex-direction: column; gap: var(--rt-space-1-5); }
.rt-summary__head { display: flex; align-items: center; gap: var(--rt-space-1-5); color: var(--rt-status-ai-text); }
.rt-summary__head .rt-icon { color: var(--rt-status-ai); }
.rt-summary__text { color: var(--rt-text-secondary); font-size: var(--rt-text-md); }

/* ═══ Composer ════════════════════════════════════════ */
.rt-composer-wrap { flex: none; padding: 0 var(--rt-space-6) var(--rt-space-5) var(--rt-space-12); display: flex; flex-direction: column; gap: var(--rt-space-2); }
.rt-composer { border: 1px solid var(--rt-border); border-radius: var(--rt-radius-xl); background: var(--rt-bg-app); box-shadow: var(--rt-shadow-sm); display: flex; flex-direction: column; }
.rt-composer textarea { border: 0; outline: none; resize: none; background: transparent; font: inherit; color: var(--rt-text); padding: var(--rt-space-3) var(--rt-space-4) var(--rt-space-1); min-height: 64px; }
.rt-composer textarea::placeholder { color: var(--rt-text-subtle); }
.rt-composer__bar { display: flex; align-items: center; gap: var(--rt-space-0-5); padding: var(--rt-space-1-5) var(--rt-space-2) var(--rt-space-2); }
.rt-composer__spacer { flex: 1; }
.rt-composer--note { border-style: dashed; background: var(--rt-bg-subtle); }

.rt-segmented { display: inline-flex; gap: var(--rt-space-0-5); padding: var(--rt-space-0-5); border-radius: var(--rt-radius-md); background: var(--rt-bg-hover); }
.rt-segmented button { height: 24px; padding: 0 var(--rt-space-2-5); border: 0; border-radius: var(--rt-radius-sm); background: transparent; font: inherit; font-size: var(--rt-text-sm); color: var(--rt-text-muted); cursor: pointer; }
.rt-segmented button[aria-pressed="true"] { background: var(--rt-bg-app); color: var(--rt-text); box-shadow: var(--rt-shadow-xs); font-weight: var(--rt-weight-medium); }

/* Sugestão da IA */
.rt-suggestion { border: 1px solid var(--rt-border); border-radius: var(--rt-radius-xl); background: var(--rt-bg-app); padding: var(--rt-space-3) var(--rt-space-4); display: flex; flex-direction: column; gap: var(--rt-space-2); }
.rt-suggestion__head { display: flex; align-items: center; gap: var(--rt-space-2); }
.rt-suggestion__label { display: inline-flex; align-items: center; gap: var(--rt-space-1); color: var(--rt-status-ai-text); font-family: var(--rt-font-mono); font-size: var(--rt-text-2xs); letter-spacing: var(--rt-tracking-mono); text-transform: uppercase; }
.rt-suggestion__label .rt-icon { width: 13px; height: 13px; color: var(--rt-status-ai); }
.rt-suggestion__meta { margin-left: auto; color: var(--rt-text-subtle); font-size: var(--rt-text-xs); }
.rt-suggestion__text { color: var(--rt-text); }
.rt-suggestion__actions { display: flex; gap: var(--rt-space-2); }
.rt-caret { display: inline-block; width: 2px; height: 1em; vertical-align: -2px; background: var(--rt-status-ai); animation: rt-blink 1s steps(1) infinite; }
@keyframes rt-blink { 50% { opacity: 0; } }

.rt-window { display: inline-flex; align-items: center; gap: var(--rt-space-1); font-size: var(--rt-text-xs); color: var(--rt-text-subtle); }
.rt-window--warn { color: var(--rt-status-waiting-text); }
.rt-window .rt-icon { width: 13px; height: 13px; color: currentColor; }

/* ═══ Painel de detalhes ══════════════════════════════ */
.rt-details { border-left: 1px solid var(--rt-border); }
.rt-details__block { padding: var(--rt-space-4); border-bottom: 1px solid var(--rt-border); display: flex; flex-direction: column; gap: var(--rt-space-3); }
.rt-kv { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: var(--rt-space-2) var(--rt-space-3); font-size: var(--rt-text-md); align-items: center; }
.rt-kv dt { color: var(--rt-text-muted); }
.rt-kv dd { margin: 0; min-width: 0; display: flex; align-items: center; gap: var(--rt-space-1-5); }

/* ═══ Menu, toast, vazio ══════════════════════════════ */
.rt-menu { min-width: 200px; padding: var(--rt-space-1); border: 1px solid var(--rt-border); border-radius: var(--rt-radius-lg); background: var(--rt-bg-app); box-shadow: var(--rt-shadow-md); display: flex; flex-direction: column; gap: var(--rt-space-0-5); }
.rt-menu__item { display: flex; align-items: center; gap: var(--rt-space-2-5); height: var(--rt-size-control); padding: 0 var(--rt-space-2); border-radius: var(--rt-radius-sm); font-size: var(--rt-text-md); cursor: pointer; }
.rt-menu__item:hover, .rt-menu__item[data-active] { background: var(--rt-bg-hover); }
.rt-menu__kbd { margin-left: auto; }
.rt-menu__sep { height: 1px; background: var(--rt-border); margin: var(--rt-space-1) 0; }
.rt-kbd { font-family: var(--rt-font-mono); font-size: var(--rt-text-2xs); color: var(--rt-text-subtle); border: 1px solid var(--rt-border); border-radius: var(--rt-radius-xs); padding: 0 var(--rt-space-1); line-height: var(--rt-leading-tight); }

.rt-toast { display: inline-flex; align-items: center; gap: var(--rt-space-3); padding: var(--rt-space-2-5) var(--rt-space-2-5) var(--rt-space-2-5) var(--rt-space-4); border-radius: var(--rt-radius-lg); background: var(--rt-bg-inverse); color: var(--rt-text-on-inverse); box-shadow: var(--rt-shadow-md); font-size: var(--rt-text-md); }
.rt-toast .rt-btn--ghost { color: var(--rt-text-on-inverse); height: 26px; }
.rt-toast .rt-btn--ghost:hover { background: var(--rt-bg-inverse-hover); }

.rt-empty { display: flex; flex-direction: column; align-items: center; gap: var(--rt-space-2); padding: var(--rt-space-12) var(--rt-space-6); text-align: center; color: var(--rt-text-muted); }
.rt-empty__title { color: var(--rt-text); font-weight: var(--rt-weight-medium); }

.rt-skeleton { background: var(--rt-bg-hover); border-radius: var(--rt-radius-sm); animation: rt-pulse 1.4s ease-in-out infinite; }
@keyframes rt-pulse { 50% { opacity: 0.5; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ═══ v0.2 — componentes para as telas de módulo ═══════ */

/* Shell sem coluna de lista (módulos de configuração) */
.rt-shell--no-list { grid-template-columns: var(--rt-size-rail) var(--rt-size-sidebar) minmax(0, 1fr); }
.rt-island { display: contents; }
.rt-main { grid-row: 2; min-width: 0; min-height: 0; overflow-y: auto; }
.rt-shell--no-list .rt-main { grid-column: 3; }

/* Página de conteúdo */
.rt-page { max-width: 880px; padding: var(--rt-space-8) var(--rt-space-10) var(--rt-space-12); display: flex; flex-direction: column; gap: var(--rt-space-6); }
.rt-page--narrow { max-width: 640px; }
.rt-page__head { display: flex; align-items: flex-start; gap: var(--rt-space-4); }
.rt-page__titles { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--rt-space-1); }
.rt-page__title { margin: 0; font-size: var(--rt-text-xl); line-height: var(--rt-leading-lg); font-weight: var(--rt-weight-medium); }
.rt-page__desc { margin: 0; color: var(--rt-text-muted); }
.rt-page__actions { display: flex; gap: var(--rt-space-2); }
.rt-group { display: flex; flex-direction: column; gap: var(--rt-space-4); padding-top: var(--rt-space-6); border-top: 1px solid var(--rt-border); }
.rt-group__title { margin: 0; font-size: var(--rt-text-md); font-weight: var(--rt-weight-medium); }
.rt-group__desc { margin: calc(var(--rt-space-3) * -1) 0 0; color: var(--rt-text-muted); font-size: var(--rt-text-sm); }
.rt-back { display: inline-flex; align-items: center; gap: var(--rt-space-1); color: var(--rt-text-muted); text-decoration: none; font-size: var(--rt-text-sm); }
.rt-back:hover { color: var(--rt-text); }

/* Cartão */
.rt-card { border: 1px solid var(--rt-border); border-radius: var(--rt-radius-xl); background: var(--rt-bg-app); padding: var(--rt-space-4); display: flex; flex-direction: column; gap: var(--rt-space-3); }
.rt-card--link { text-decoration: none; color: inherit; transition: background var(--rt-duration-fast) var(--rt-ease); }
.rt-card--link:hover { background: var(--rt-bg-hover); }
.rt-card__head { display: flex; align-items: center; gap: var(--rt-space-2-5); }
.rt-card__title { font-weight: var(--rt-weight-medium); flex: 1; min-width: 0; }
.rt-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--rt-space-3); }

/* Tabela administrativa */
.rt-table { width: 100%; border-collapse: collapse; font-size: var(--rt-text-md); }
.rt-table th { height: 36px; padding: 0 var(--rt-space-3); text-align: left; font-family: var(--rt-font-mono); font-size: var(--rt-text-2xs); letter-spacing: var(--rt-tracking-mono); text-transform: uppercase; font-weight: var(--rt-weight-regular); color: var(--rt-text-muted); border-bottom: 1px solid var(--rt-border); }
.rt-table td { height: 48px; padding: 0 var(--rt-space-3); border-bottom: 1px solid var(--rt-border); }
.rt-table tbody tr { transition: background var(--rt-duration-fast) var(--rt-ease); }
.rt-table tbody tr:hover { background: var(--rt-bg-hover); }
.rt-table td.rt-table__muted { color: var(--rt-text-muted); }
.rt-table td.rt-table__num, .rt-table th.rt-table__num { text-align: right; font-variant-numeric: tabular-nums; }
.rt-table a { color: inherit; text-decoration: none; }
.rt-cell { display: flex; align-items: center; gap: var(--rt-space-2-5); min-width: 0; }

/* Abas */
.rt-tabs { display: flex; gap: var(--rt-space-1); border-bottom: 1px solid var(--rt-border); }
.rt-tab { position: relative; display: inline-flex; align-items: center; gap: var(--rt-space-1-5); height: 36px; padding: 0 var(--rt-space-2-5); color: var(--rt-text-muted); text-decoration: none; font-size: var(--rt-text-md); border-radius: var(--rt-radius-sm) var(--rt-radius-sm) 0 0; }
.rt-tab:hover { color: var(--rt-text); }
.rt-tab[aria-current="page"] { color: var(--rt-text); font-weight: var(--rt-weight-medium); }
.rt-tab[aria-current="page"]::after { content: ""; position: absolute; left: var(--rt-space-2-5); right: var(--rt-space-2-5); bottom: -1px; height: 2px; border-radius: 2px; background: var(--rt-text); }

/* Interruptor */
.rt-switch { position: relative; display: inline-block; width: 32px; height: 18px; flex: none; }
.rt-switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.rt-switch span { position: absolute; inset: 0; border-radius: var(--rt-radius-full); background: var(--rt-border-strong); transition: background var(--rt-duration-fast) var(--rt-ease); pointer-events: none; }
.rt-switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: var(--rt-radius-full); background: var(--rt-gray-0); box-shadow: var(--rt-shadow-xs); transition: transform var(--rt-duration-fast) var(--rt-ease); }
.rt-switch input:checked + span { background: var(--rt-bg-inverse); }
.rt-switch input:checked + span::after { transform: translateX(14px); background: var(--rt-bg-app); }
.rt-switch input:focus-visible + span { box-shadow: var(--rt-shadow-focus); }

/* Linha de opção (rótulo + descrição + controle) */
.rt-option { display: flex; align-items: center; gap: var(--rt-space-4); padding: var(--rt-space-3) 0; border-bottom: 1px dashed var(--rt-border-dashed); }
.rt-option:last-child { border-bottom: 0; }
.rt-option__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--rt-space-0-5); }
.rt-option__desc { color: var(--rt-text-muted); font-size: var(--rt-text-sm); }

/* Área de texto */
.rt-textarea { width: 100%; min-height: 160px; padding: var(--rt-space-2-5) var(--rt-space-3); border: 1px solid var(--rt-border); border-radius: var(--rt-radius-md); background: var(--rt-bg-app); color: var(--rt-text); font: inherit; line-height: var(--rt-leading-md); resize: vertical; }
.rt-textarea:hover { border-color: var(--rt-border-strong); }
.rt-textarea:focus { outline: none; border-color: var(--rt-border-strong); box-shadow: var(--rt-shadow-focus); }
.rt-select { appearance: none; height: var(--rt-size-control); padding: 0 var(--rt-space-8) 0 var(--rt-space-2-5); border: 1px solid var(--rt-border); border-radius: var(--rt-radius-md); background: var(--rt-bg-app) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23767676' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 8px center; color: var(--rt-text); font: inherit; }

/* Métricas */
.rt-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--rt-space-3); }
.rt-stat { border: 1px solid var(--rt-border); border-radius: var(--rt-radius-xl); padding: var(--rt-space-4); display: flex; flex-direction: column; gap: var(--rt-space-1); }
.rt-stat__label { color: var(--rt-text-muted); }
.rt-stat__value { font-size: var(--rt-text-xl); line-height: var(--rt-leading-lg); font-weight: var(--rt-weight-medium); font-variant-numeric: tabular-nums; }
.rt-stat__delta { font-size: var(--rt-text-xs); color: var(--rt-text-subtle); }
.rt-stat__delta--up { color: var(--rt-status-resolved-text); }

/* Barras horizontais (relatórios simples) */
.rt-bars { display: flex; flex-direction: column; gap: var(--rt-space-2-5); }
.rt-bar { display: grid; grid-template-columns: 140px minmax(0, 1fr) 56px; align-items: center; gap: var(--rt-space-3); font-size: var(--rt-text-md); }
.rt-bar__track { height: 8px; border-radius: var(--rt-radius-full); background: var(--rt-bg-hover); overflow: hidden; }
.rt-bar__fill { height: 100%; border-radius: var(--rt-radius-full); background: var(--rt-bg-inverse); }
.rt-bar__fill--ai { background: var(--rt-status-ai); }
.rt-bar__value { text-align: right; color: var(--rt-text-muted); font-variant-numeric: tabular-nums; }

/* Toasts */
.rt-toasts { position: fixed; left: 50%; bottom: var(--rt-space-6); transform: translateX(-50%); z-index: var(--rt-z-toast); display: flex; flex-direction: column; align-items: center; gap: var(--rt-space-2); pointer-events: none; }
.rt-toasts .rt-toast { pointer-events: auto; }

/* Login */
.rt-auth { min-height: 100vh; display: grid; place-items: center; padding: var(--rt-space-6); background: var(--rt-bg-subtle); }
.rt-auth__card { width: 100%; max-width: 380px; border: 1px solid var(--rt-border); border-radius: var(--rt-radius-2xl); background: var(--rt-bg-app); box-shadow: var(--rt-shadow-sm); padding: var(--rt-space-8); display: flex; flex-direction: column; gap: var(--rt-space-5); }

/* Lista virtualizada */
.rt-conv-list--virtual { display: block; position: relative; }
.rt-conv-list--virtual .rt-conv-item { position: absolute; left: var(--rt-space-1-5); right: var(--rt-space-1-5); height: var(--rt-size-row); }

/* Botão de voltar só no celular */
.rt-only-mobile { display: none; }

/* ═══ Responsivo (v0.2: tablet e celular básicos) ═════ */
@media (max-width: 1279px) {
  .rt-shell { grid-template-columns: var(--rt-size-rail) var(--rt-size-list) minmax(0, 1fr); }
  .rt-shell > .rt-sidebar, .rt-shell .rt-island > .rt-sidebar { display: none; }
  .rt-shell .rt-list-col { grid-column: 2 !important; }
  .rt-shell .rt-thread-col { grid-column: 3 !important; }
  .rt-shell--no-list { grid-template-columns: var(--rt-size-rail) minmax(0, 1fr); }
  .rt-shell--no-list .rt-main { grid-column: 2; }
  .rt-shell--with-details > .rt-details, .rt-shell--with-details .rt-island > .rt-details { position: fixed; top: 0; right: 0; bottom: 0; width: var(--rt-size-details); background: var(--rt-bg-app); box-shadow: var(--rt-shadow-md); z-index: var(--rt-z-overlay); }
}
@media (max-width: 767px) {
  .rt-shell { grid-template-columns: minmax(0, 1fr); }
  .rt-topbar-logo, .rt-rail { display: none; }
  .rt-topbar { grid-column: 1; }
  .rt-shell .rt-list-col, .rt-shell .rt-thread-col { grid-column: 1 !important; }
  .rt-shell[data-mobile="list"] .rt-thread-col { display: none; }
  .rt-shell[data-mobile="thread"] .rt-list-col { display: none; }
  .rt-shell--no-list .rt-main { grid-column: 1; }
  .rt-only-mobile { display: inline-grid; }
  .rt-thread { padding: var(--rt-space-4); }
  .rt-composer-wrap { padding: 0 var(--rt-space-3) var(--rt-space-3); }
  .rt-msg { max-width: 92%; }
  .rt-page { padding: var(--rt-space-5) var(--rt-space-4) var(--rt-space-10); }
  .rt-shell--with-details > .rt-details, .rt-shell--with-details .rt-island > .rt-details { width: 100%; }
}

/* Shell ocupando a janela inteira */
.rt-shell--app { height: 100vh; height: 100dvh; }

/* Utilitários mínimos (v0.2) */
.rt-push { margin-left: auto; }
.rt-page--wide { max-width: none; }
.rt-page--report { max-width: 1080px; }
.rt-status-chip--danger { color: var(--rt-danger-text); }
.rt-status-chip--danger .rt-icon { color: var(--rt-danger-text); width: 14px; height: 14px; }
.rt-sidebar__search { margin-bottom: var(--rt-space-3); }
.rt-code { font-family: var(--rt-font-mono); font-size: var(--rt-text-sm); }

/* Posições das colunas do inbox (a ilha usa display: contents) */
.rt-list-col { grid-row: 2; grid-column: 3; }
.rt-thread-col { grid-row: 2; grid-column: 4; }
.rt-details { grid-row: 2; grid-column: 5; }

/* Menu suspenso ancorado */
.rt-anchor { position: relative; display: inline-flex; }
.rt-menu--pop { position: absolute; top: calc(100% + var(--rt-space-1)); right: 0; z-index: var(--rt-z-dropdown); }
.rt-menu__label { padding: var(--rt-space-1-5) var(--rt-space-2) var(--rt-space-1); color: var(--rt-text-muted); }

/* Aviso dentro do composer (janela fechada, aprovação) */
.rt-notice { display: flex; align-items: center; gap: var(--rt-space-2); padding: var(--rt-space-2-5) var(--rt-space-3); border: 1px dashed var(--rt-border-strong); border-radius: var(--rt-radius-lg); color: var(--rt-text-secondary); font-size: var(--rt-text-sm); }
.rt-notice .rt-icon { color: var(--rt-status-waiting-text); }

/* Esqueletos com tamanhos de conteúdo */
.rt-skeleton--icon { width: var(--rt-size-icon); height: var(--rt-size-icon); }
.rt-skeleton--avatar { width: var(--rt-size-avatar-md); height: var(--rt-size-avatar-md); }
.rt-skeleton--line { height: 12px; flex: 1; }
.rt-skeleton--w40 { width: 40%; flex: none; }
.rt-skeleton--w50 { width: 50%; flex: none; }
.rt-skeleton--w85 { width: 85%; flex: none; }
.rt-skeleton--title { height: 12px; width: 140px; }

/* Busca no cabeçalho da lista */
.rt-panel-header .rt-input { flex: 1; height: var(--rt-size-control-sm); }

/* Tempo real: destaque breve de item novo */
@keyframes rt-flash { from { background: var(--rt-bg-selected); } to { background: transparent; } }
.rt-conv-item--new { animation: rt-flash 1.2s var(--rt-ease); }

.rt-kbd--inverse { color: inherit; border-color: currentColor; opacity: 0.6; }

/* Link de texto: neutro, sublinhado só no hover */
.rt-link { color: inherit; text-decoration: none; font-weight: var(--rt-weight-medium); }
.rt-link:hover { text-decoration: underline; text-underline-offset: 2px; }

/* Correções v0.2: links no trilho e cabeçalho/composer no celular */
.rt-rail-btn, .rt-logo { text-decoration: none; }
@media (max-width: 767px) {
  .rt-hide-mobile { display: none !important; }
  .rt-panel-header { padding: 0 var(--rt-space-2); }
}

/* Barra inferior de módulos (celular) */
.rt-tabbar { display: none; }
@media (max-width: 767px) {
  .rt-shell { grid-template-rows: var(--rt-size-header) minmax(0, 1fr) auto; }
  .rt-tabbar { grid-row: 3; grid-column: 1 / -1; display: flex; justify-content: space-around; align-items: center; height: calc(56px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--rt-border); background: var(--rt-bg-app); }
  .rt-shell[data-mobile="thread"] .rt-tabbar { display: none; }
  .rt-tabbar a { display: flex; flex-direction: column; align-items: center; gap: var(--rt-space-0-5); min-width: 56px; padding: var(--rt-space-1) 0; color: var(--rt-text-muted); text-decoration: none; font-size: var(--rt-text-2xs); }
  .rt-tabbar a[aria-current="page"] { color: var(--rt-text); font-weight: var(--rt-weight-medium); }
  .rt-tabbar a[aria-current="page"] .rt-icon { color: var(--rt-icon-strong); }
  .rt-tabbar .rt-icon { width: var(--rt-size-icon-lg); height: var(--rt-size-icon-lg); }
}

/* Navegação recolhível (desktop) e gaveta (tablet/celular) — v0.2 */
.rt-backdrop { display: none; }
@media (min-width: 1280px) {
  .rt-shell--nav-collapsed { grid-template-columns: var(--rt-size-rail) var(--rt-size-list) minmax(0, 1fr); }
  .rt-shell--nav-collapsed.rt-shell--with-details { grid-template-columns: var(--rt-size-rail) var(--rt-size-list) minmax(0, 1fr) var(--rt-size-details); }
  .rt-shell--nav-collapsed .rt-sidebar { display: none; }
  .rt-shell--nav-collapsed .rt-list-col { grid-column: 2; }
  .rt-shell--nav-collapsed .rt-thread-col { grid-column: 3; }
  .rt-shell--nav-collapsed .rt-details { grid-column: 4; }
}
@media (max-width: 1279px) {
  .rt-shell--nav-open .rt-island > .rt-sidebar { display: flex; position: fixed; top: 0; bottom: 0; left: 0; width: var(--rt-size-sidebar); background: var(--rt-bg-app); box-shadow: var(--rt-shadow-md); z-index: var(--rt-z-modal); }
  .rt-shell--nav-open .rt-backdrop, .rt-shell--with-details .rt-backdrop { display: block; position: fixed; inset: 0; background: var(--rt-bg-overlay); z-index: var(--rt-z-overlay); }
  .rt-shell--with-details .rt-island > .rt-details { z-index: var(--rt-z-modal); }
}

/* ═══ v0.3 — edição, diálogos, anexos e composer completo ═══ */

/* Diálogo (elemento <dialog> nativo) */
.rt-dialog { width: min(480px, calc(100vw - 2 * var(--rt-space-4))); max-height: calc(100dvh - 2 * var(--rt-space-8)); padding: 0; border: 1px solid var(--rt-border); border-radius: var(--rt-radius-2xl); background: var(--rt-bg-app); color: var(--rt-text); box-shadow: var(--rt-shadow-md); }
.rt-dialog--wide { width: min(640px, calc(100vw - 2 * var(--rt-space-4))); }
.rt-dialog::backdrop { background: var(--rt-bg-overlay); }
.rt-dialog[open] { animation: rt-dialog-in var(--rt-duration-base) var(--rt-ease); }
@keyframes rt-dialog-in { from { opacity: 0; transform: translateY(6px) scale(0.98); } }
.rt-dialog__form { display: flex; flex-direction: column; gap: var(--rt-space-4); padding: var(--rt-space-6); }
.rt-dialog__head { display: flex; align-items: flex-start; gap: var(--rt-space-3); }
.rt-dialog__head .rt-page__titles { flex: 1; }
.rt-dialog__title { margin: 0; font-size: var(--rt-text-lg); line-height: var(--rt-leading-lg); font-weight: var(--rt-weight-medium); }
.rt-dialog__actions { display: flex; justify-content: flex-end; gap: var(--rt-space-2); padding-top: var(--rt-space-2); }

/* Formulários */
.rt-form { display: flex; flex-direction: column; gap: var(--rt-space-4); }
.rt-form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--rt-space-3); }
.rt-fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--rt-space-2); }
.rt-fieldset legend { padding: 0; margin-bottom: var(--rt-space-2); }
.rt-fieldset__options { display: flex; flex-wrap: wrap; gap: var(--rt-space-2) var(--rt-space-4); }
.rt-check-row { display: inline-flex; align-items: center; gap: var(--rt-space-2); font-size: var(--rt-text-md); cursor: pointer; }
.rt-check { width: 16px; height: 16px; margin: 0; accent-color: var(--rt-bg-inverse); cursor: pointer; }
.rt-input--time { width: 96px; }
.rt-file { font: inherit; font-size: var(--rt-text-sm); color: var(--rt-text-secondary); }
.rt-file::file-selector-button { font: inherit; font-size: var(--rt-text-sm); height: var(--rt-size-control-sm); padding: 0 var(--rt-space-2-5); margin-right: var(--rt-space-3); border: 1px solid var(--rt-border); border-radius: var(--rt-radius-md); background: var(--rt-bg-app); color: var(--rt-text); cursor: pointer; }
.rt-table__clip { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rt-menu__item { border: 0; background: transparent; width: 100%; font: inherit; color: inherit; text-decoration: none; text-align: left; }
.rt-menu__item--danger { color: var(--rt-danger-text); }
.rt-menu__item--danger .rt-icon { color: var(--rt-danger-text); }
.rt-menu form { display: contents; }
.rt-toast--error { background: var(--rt-danger-text); }
.rt-toast--error .rt-icon { color: var(--rt-text-on-inverse); }
@media (max-width: 767px) { .rt-form-row { grid-template-columns: minmax(0, 1fr); } }

/* Popover do composer (respostas rápidas, emojis) */
.rt-composer { position: relative; }
.rt-popover { position: absolute; left: var(--rt-space-2); bottom: calc(100% + var(--rt-space-2)); z-index: var(--rt-z-dropdown); width: min(360px, calc(100% - 2 * var(--rt-space-2))); max-height: 320px; overflow-y: auto; padding: var(--rt-space-1); border: 1px solid var(--rt-border); border-radius: var(--rt-radius-lg); background: var(--rt-bg-app); box-shadow: var(--rt-shadow-md); }
.rt-popover__head { display: flex; align-items: center; gap: var(--rt-space-2); padding: var(--rt-space-1-5) var(--rt-space-2); color: var(--rt-text-muted); }
.rt-popover__item { display: flex; flex-direction: column; gap: var(--rt-space-0-5); width: 100%; padding: var(--rt-space-2); border: 0; border-radius: var(--rt-radius-sm); background: transparent; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.rt-popover__item:hover, .rt-popover__item[data-active] { background: var(--rt-bg-hover); }
.rt-popover__title { display: flex; align-items: center; gap: var(--rt-space-2); font-weight: var(--rt-weight-medium); }
.rt-popover__body { color: var(--rt-text-muted); font-size: var(--rt-text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rt-popover__empty { padding: var(--rt-space-3); color: var(--rt-text-muted); font-size: var(--rt-text-sm); }
.rt-emoji-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: var(--rt-space-0-5); padding: var(--rt-space-1); }
.rt-emoji { height: 34px; border: 0; border-radius: var(--rt-radius-sm); background: transparent; font-size: 18px; line-height: 1; cursor: pointer; }
.rt-emoji:hover, .rt-emoji:focus-visible { background: var(--rt-bg-hover); }

/* Anexos no composer */
.rt-file-chips { display: flex; flex-wrap: wrap; gap: var(--rt-space-2); padding: var(--rt-space-2-5) var(--rt-space-3) 0; }
.rt-file-chip { position: relative; display: inline-flex; align-items: center; gap: var(--rt-space-1-5); height: 28px; max-width: 240px; padding: 0 var(--rt-space-0-5) 0 var(--rt-space-2); border: 1px solid var(--rt-border); border-radius: var(--rt-radius-md); background: var(--rt-bg-subtle); font-size: var(--rt-text-sm); overflow: hidden; }
.rt-file-chip--error { border-color: var(--rt-danger-text); color: var(--rt-danger-text); }
.rt-file-chip .rt-icon-btn { width: 22px; height: 22px; }
.rt-file-chip__progress { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--rt-status-ai); transition: width var(--rt-duration-fast) linear; }
.rt-composer--drop { border-style: dashed; border-color: var(--rt-status-ai); }

/* Anexos nas mensagens */
.rt-attachments { display: flex; flex-direction: column; gap: var(--rt-space-1-5); }
.rt-msg--out .rt-attachments { align-items: flex-end; }
.rt-att-image { display: block; max-width: 280px; border: 1px solid var(--rt-border); border-radius: var(--rt-radius-lg); overflow: hidden; background: var(--rt-bg-subtle); }
.rt-att-image img { display: block; width: 100%; height: auto; }
.rt-att-file { display: flex; align-items: center; gap: var(--rt-space-2-5); min-width: 220px; max-width: 320px; padding: var(--rt-space-2) var(--rt-space-3); border: 1px solid var(--rt-border); border-radius: var(--rt-radius-lg); background: var(--rt-bg-app); color: var(--rt-text); text-decoration: none; }
.rt-att-file:hover { background: var(--rt-bg-hover); }
.rt-att-file__text { display: flex; flex-direction: column; min-width: 0; }
.rt-att-file__meta { font-size: var(--rt-text-xs); color: var(--rt-text-subtle); }
.rt-audio { display: flex; align-items: center; gap: var(--rt-space-2-5); min-width: 260px; max-width: 320px; padding: var(--rt-space-1-5) var(--rt-space-3) var(--rt-space-1-5) var(--rt-space-1-5); border: 1px solid var(--rt-border); border-radius: var(--rt-radius-lg); background: var(--rt-bg-app); }
.rt-audio__btn { flex: none; width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: var(--rt-radius-full); background: var(--rt-bg-inverse); cursor: pointer; }
.rt-audio__btn .rt-icon { width: 14px; height: 14px; color: var(--rt-text-on-inverse); fill: var(--rt-text-on-inverse); }
.rt-audio__track { position: relative; flex: 1; height: 4px; border-radius: var(--rt-radius-full); background: var(--rt-bg-selected); cursor: pointer; }
.rt-audio__fill { position: absolute; inset: 0 auto 0 0; border-radius: var(--rt-radius-full); background: var(--rt-bg-inverse); }
.rt-audio__time { font-size: var(--rt-text-xs); color: var(--rt-text-subtle); font-variant-numeric: tabular-nums; min-width: 32px; text-align: right; }
.rt-transcript { max-width: 320px; padding-left: var(--rt-space-2); border-left: 2px solid var(--rt-border-strong); color: var(--rt-text-secondary); font-size: var(--rt-text-sm); }
.rt-transcript__label { display: block; margin-bottom: var(--rt-space-0-5); color: var(--rt-text-muted); }
.rt-msg__template { display: inline-flex; align-items: center; gap: var(--rt-space-1); font-family: var(--rt-font-mono); font-size: var(--rt-text-2xs); letter-spacing: var(--rt-tracking-mono); text-transform: uppercase; color: var(--rt-text-muted); }

/* Prévia de modelo do WhatsApp */
.rt-template-preview { padding: var(--rt-space-2-5) var(--rt-space-3); border-radius: var(--rt-radius-lg); background: var(--rt-bg-bubble-out); color: var(--rt-text-on-inverse); white-space: pre-wrap; }
.rt-template-list { display: flex; flex-direction: column; gap: var(--rt-space-1); max-height: 220px; overflow-y: auto; }

/* Chat de teste do agente */
.rt-testchat { display: flex; flex-direction: column; height: min(560px, calc(100dvh - 280px)); min-height: 360px; border: 1px solid var(--rt-border); border-radius: var(--rt-radius-xl); overflow: hidden; }
.rt-testchat__head { display: flex; align-items: center; gap: var(--rt-space-2); padding: var(--rt-space-2-5) var(--rt-space-4); border-bottom: 1px solid var(--rt-border); }
.rt-testchat__body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: var(--rt-space-4); padding: var(--rt-space-5) var(--rt-space-5); }
.rt-testchat .rt-composer-wrap { padding: 0 var(--rt-space-4) var(--rt-space-4); }
.rt-testchat__meta { display: flex; flex-wrap: wrap; gap: var(--rt-space-1-5); }
.rt-search-results { display: flex; flex-direction: column; gap: var(--rt-space-0-5); max-height: 220px; overflow-y: auto; }

.rt-popover__search { margin: var(--rt-space-1) var(--rt-space-1) var(--rt-space-0-5); }
.rt-icon-btn--active { background: var(--rt-bg-selected); }
.rt-icon-btn--active .rt-icon { color: var(--rt-icon-strong); }
.rt-icon-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.rt-cell--wrap { flex-wrap: wrap; gap: var(--rt-space-1-5); }
.rt-tag__remove { display: inline-grid; place-items: center; width: 16px; height: 16px; margin-right: calc(var(--rt-space-1) * -1); padding: 0; border: 0; border-radius: var(--rt-radius-xs); background: transparent; color: var(--rt-icon); cursor: pointer; }
.rt-tag__remove:hover { background: var(--rt-bg-hover); }
.rt-tag__remove .rt-icon { width: 12px; height: 12px; }
.rt-avatar__dot--inline { position: static; display: inline-block; margin: 0 4px; box-shadow: none; }
.rt-tag--button { cursor: pointer; font: inherit; font-size: var(--rt-text-xs); }
.rt-tag--button:hover { background: var(--rt-bg-hover); }
.rt-tag .rt-icon { width: 12px; height: 12px; }

/* Correções v0.3: botões-link sem sublinhado e um único anel de foco nos campos */
a.rt-btn { text-decoration: none; }
.rt-input input:focus-visible, .rt-input input:focus { box-shadow: none; outline: none; }
@media (max-width: 767px) {
  .rt-page .rt-table { display: block; overflow-x: auto; white-space: nowrap; }
}

/* ═══ v0.4 — telas menores, falhas e conexão ═══════════ */
.rt-only-compact, .rt-only-mobile-flex { display: none !important; }
@media (max-width: 1279px) {
  .rt-only-compact { display: inline-grid !important; }
  .rt-shell--nav-open > .rt-sidebar { display: flex; position: fixed; top: 0; bottom: 0; left: 0; width: var(--rt-size-sidebar); background: var(--rt-bg-app); box-shadow: var(--rt-shadow-md); z-index: var(--rt-z-modal); }
  .rt-topbar { padding-left: var(--rt-space-2); }
}
@media (max-width: 767px) {
  .rt-only-mobile-flex { display: flex !important; }
  .rt-shell--with-details .rt-island > .rt-details { left: 0; width: auto; }
}

/* Falhas e conexão */
.rt-banner { position: fixed; top: calc(var(--rt-size-header) + var(--rt-space-2)); left: 50%; transform: translateX(-50%); z-index: var(--rt-z-toast); display: inline-flex; align-items: center; gap: var(--rt-space-2); max-width: calc(100vw - 2 * var(--rt-space-4)); padding: var(--rt-space-2) var(--rt-space-3); border: 1px solid var(--rt-border); border-radius: var(--rt-radius-lg); background: var(--rt-bg-app); box-shadow: var(--rt-shadow-md); font-size: var(--rt-text-sm); color: var(--rt-text-secondary); }
.rt-banner .rt-icon { color: var(--rt-status-waiting-text); }
.rt-empty--error .rt-icon { color: var(--rt-danger-text); }
.rt-msg--pending .rt-bubble { opacity: 0.6; }
.rt-msg--failed .rt-bubble { box-shadow: 0 0 0 1px var(--rt-danger); }
.rt-msg__failed { display: inline-flex; align-items: center; gap: var(--rt-space-1); font-size: var(--rt-text-xs); color: var(--rt-danger-text); }
.rt-msg__failed .rt-icon { width: 14px; height: 14px; color: var(--rt-danger-text); }
.rt-retry { border: 0; padding: 0; margin-left: var(--rt-space-1); background: transparent; font: inherit; font-weight: var(--rt-weight-medium); color: var(--rt-text); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }

/* Contraste AA em linhas selecionadas ou com hover: horário e prévia lida sobem para text-muted */
.rt-conv-item:hover .rt-conv-item__time, .rt-conv-item[aria-current="true"] .rt-conv-item__time,
.rt-conv-item--read:hover .rt-conv-item__preview, .rt-conv-item--read[aria-current="true"] .rt-conv-item__preview { color: var(--rt-text-muted); }

/* A conversa controla a própria rolagem (fica no fim); a ancoragem do navegador atrapalharia ao redimensionar */
.rt-thread-col .rt-panel-body { overflow-anchor: none; }

/* ═══ v0.5 — WhatsApp não oficial (D-21) ═══════════════ */
.rt-tag--warn { color: var(--rt-status-waiting-text); border-color: var(--rt-border); }
.rt-tag--warn .rt-icon { color: var(--rt-status-waiting-text); }
.rt-notice--warn { align-items: flex-start; }
.rt-notice--warn .rt-icon { margin-top: 2px; flex: none; }
.rt-option--card { padding: var(--rt-space-3); border: 1px solid var(--rt-border); border-radius: var(--rt-radius-lg); border-bottom-style: solid; align-items: flex-start; cursor: pointer; }
.rt-option--card:has(input:checked) { border-color: var(--rt-border-strong); background: var(--rt-bg-subtle); }
.rt-option--card + .rt-option--card { margin-top: var(--rt-space-2); }
.rt-option--disabled { opacity: 0.55; cursor: not-allowed; }
.rt-fieldset__options:has(.rt-option--card) { flex-direction: column; flex-wrap: nowrap; gap: 0; }
.rt-qr { display: flex; gap: var(--rt-space-6); align-items: center; padding: var(--rt-space-5); border: 1px solid var(--rt-border); border-radius: var(--rt-radius-xl); }
.rt-qr__img { width: 200px; height: 200px; border-radius: var(--rt-radius-md); border: 1px solid var(--rt-border); background: #fff; flex: none; }
.rt-qr__steps { margin: 0; padding-left: var(--rt-space-5); display: flex; flex-direction: column; gap: var(--rt-space-2); color: var(--rt-text-secondary); }
@media (max-width: 767px) { .rt-qr { flex-direction: column; align-items: flex-start; } }
.rt-segmented--wrap { flex-wrap: wrap; }
.rt-option--card:last-child { border-bottom: 1px solid var(--rt-border); }
.rt-option--card:last-child:has(input:checked) { border-bottom-color: var(--rt-border-strong); }
/* Campos que só valem para WhatsApp somem quando outro tipo de canal é escolhido */
.rt-dialog__form:not(:has(select[name="kind"] option[value="whatsapp"]:checked)) [data-only-whatsapp] { display: none; }

/* Gravação de áudio no composer */
.rt-recording { display: flex; align-items: center; gap: var(--rt-space-2); padding: var(--rt-space-2) var(--rt-space-2) var(--rt-space-2) var(--rt-space-3); border-bottom: 1px dashed var(--rt-border-dashed); font-size: var(--rt-text-sm); color: var(--rt-text-secondary); }
.rt-recording__dot { width: 8px; height: 8px; border-radius: var(--rt-radius-full); background: var(--rt-danger); animation: rt-pulse 1.2s ease-in-out infinite; }
.rt-recording__time { font-family: var(--rt-font-mono); font-size: var(--rt-text-xs); color: var(--rt-text-muted); font-variant-numeric: tabular-nums; }

/* ═══ v0.6 — painel da plataforma (/dash) ═══════════════ */
.rt-platform { min-height: 100vh; min-height: 100dvh; background: var(--rt-bg-app); }
.rt-platform__bar { display: flex; align-items: center; gap: var(--rt-space-3); height: var(--rt-size-header); padding: 0 var(--rt-space-4); border-bottom: 1px solid var(--rt-border); }
.rt-platform .rt-page { margin: 0 auto; }
.rt-btn--block { width: 100%; }
.rt-kv--wide { grid-template-columns: 140px minmax(0, 1fr); }

/* v0.7 — autenticação e modo administrativo */
.rt-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.rt-notice--ok .rt-icon { color: var(--rt-status-resolved-text); }
.rt-admin-mode { display: flex; align-items: center; gap: var(--rt-space-2); margin-left: auto; min-width: 0; }
.rt-admin-mode form { display: contents; }
@media (max-width: 720px) { .rt-admin-mode .rt-tag { display: none; } }
