/* ==========================================================================
   FlowTime UI - componentes (prefixo ft-)
   Depende de /css/ft-tokens.css. Sem build: carregado depois das folhas do
   legado (Bootstrap 3 / INSPINIA). A ponte com as classes antigas fica em
   /css/ft-legacy.css.
   ========================================================================== */

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Utilitarios ------------------------------------------------------------ */
.ft-num { font-variant-numeric: tabular-nums; }
.ft-mono { font-family: var(--font-mono); font-size: 13px; }
.ft-muted { color: var(--text-muted); }
.ft-secondary { color: var(--text-secondary); }
.ft-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ft-icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.ft-icon--20 { width: 20px; height: 20px; }
.ft-spinner { display: inline-block; width: 16px; height: 16px; flex: none; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: ft-spin .7s linear infinite; }
@keyframes ft-spin { to { transform: rotate(360deg); } }

/* Button ----------------------------------------------------------------- */
.ft-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--control-md); padding: 0 var(--space-4);
  font-family: inherit; font-size: 14px; font-weight: 500; line-height: 1; white-space: nowrap; text-decoration: none;
  border: 1px solid transparent; border-radius: var(--radius-md);
  cursor: pointer; user-select: none;
  transition: background-color .12s ease-out, border-color .12s ease-out, color .12s ease-out;
}
.ft-btn:hover, .ft-btn:focus { text-decoration: none; }
.ft-btn--primary { background: var(--primary); color: var(--on-primary); }
.ft-btn--primary:hover, .ft-btn--primary:focus { background: var(--primary-hover); color: var(--on-primary); }
.ft-btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.ft-btn--secondary:hover, .ft-btn--secondary:focus { background: var(--surface-hover); color: var(--text); }
.ft-btn--ghost { background: transparent; color: var(--text-secondary); }
.ft-btn--ghost:hover, .ft-btn--ghost:focus { background: var(--surface-hover); color: var(--text); }
.ft-btn--danger { background: var(--danger); color: var(--on-danger); }
.ft-btn--danger:hover, .ft-btn--danger:focus { background: var(--danger-hover); color: var(--on-danger); }
.ft-btn--link { background: none; height: auto; padding: 0; color: var(--primary-text); }
.ft-btn--link:hover { text-decoration: underline; text-underline-offset: 3px; }
.ft-btn--sm { height: var(--control-sm); padding: 0 var(--space-3); font-size: 13px; }
.ft-btn--lg { height: var(--control-lg); padding: 0 var(--space-5); font-size: 15px; }
.ft-btn--icon { width: var(--control-md); padding: 0; }
.ft-btn--icon.ft-btn--sm { width: var(--control-sm); }
.ft-btn--icon.ft-btn--lg { width: var(--control-lg); }
.ft-btn--block { width: 100%; }
.ft-btn:disabled, .ft-btn.is-disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.ft-btn.is-loading { cursor: progress; }
.ft-btn-group { display: inline-flex; gap: var(--space-2); flex-wrap: wrap; }

/* Field, Input ----------------------------------------------------------- */
.ft-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ft-label { font-size: 13px; line-height: 18px; font-weight: 500; color: var(--text); margin: 0; }
.ft-label__req { color: var(--danger); margin-left: 2px; }
.ft-label__opt { color: var(--text-muted); font-weight: 400; margin-left: 4px; }
.ft-help { font-size: 12px; line-height: 16px; color: var(--text-muted); }
.ft-error { display: flex; align-items: center; gap: var(--space-1); font-size: 12px; line-height: 16px; color: var(--danger); }
.ft-error .ft-icon { width: 14px; height: 14px; }

.ft-input, .ft-textarea, .ft-select__control {
  width: 100%; height: var(--control-md); padding: 0 var(--space-3);
  font-family: inherit; font-size: 14px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-input); border-radius: var(--radius-md);
  transition: border-color .12s ease-out, box-shadow .12s ease-out;
}
.ft-textarea { height: auto; min-height: 88px; padding: var(--space-2) var(--space-3); line-height: 20px; resize: vertical; }
.ft-input::placeholder, .ft-textarea::placeholder { color: var(--text-muted); opacity: 1; }
.ft-input:hover, .ft-textarea:hover, .ft-select__control:hover { border-color: var(--text-muted); }
.ft-input:focus, .ft-textarea:focus, .ft-select__control:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
.ft-input:disabled, .ft-textarea:disabled, .ft-select__control:disabled { background: var(--surface-sunken); color: var(--text-muted); border-color: var(--border-strong); cursor: not-allowed; }
.ft-input[readonly] { background: var(--surface-sunken); }
.is-invalid .ft-input, .is-invalid .ft-textarea, .is-invalid .ft-select__control, .ft-input[aria-invalid="true"] { border-color: var(--danger); }
.is-invalid .ft-input:focus, .is-invalid .ft-select__control:focus, .ft-input[aria-invalid="true"]:focus { box-shadow: 0 0 0 1px var(--danger); }
.ft-input--sm, .ft-select--sm .ft-select__control { height: var(--control-sm); font-size: 13px; }
.ft-input--lg, .ft-select--lg .ft-select__control { height: var(--control-lg); font-size: 16px; }

.ft-input-wrap { position: relative; display: flex; align-items: center; }
.ft-input-wrap > .ft-icon { position: absolute; left: var(--space-3); color: var(--text-muted); pointer-events: none; }
.ft-input-wrap > .ft-input { padding-left: 36px; }

.ft-form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-4) var(--space-3); }

/* Select ----------------------------------------------------------------- */
.ft-select { position: relative; display: block; }
.ft-select__control { appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer; }
.ft-select > .ft-icon { position: absolute; right: var(--space-3); top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }

/* Menu */
.ft-menu { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-md); padding: var(--space-1); min-width: 220px; }
.ft-menu__item { display: flex; align-items: center; gap: var(--space-2); min-height: 32px; padding: 6px var(--space-2); border-radius: var(--radius-sm); color: var(--text); font-size: 14px; line-height: 20px; cursor: pointer; text-decoration: none; }
.ft-menu__item:hover, .ft-menu__item:focus, .ft-menu__item.is-highlighted { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.ft-menu__item[aria-selected="true"] { color: var(--primary-text); font-weight: 500; }
.ft-menu__meta { margin-left: auto; font-size: 12px; color: var(--text-muted); }
.ft-menu__item--danger, .ft-menu__item--danger:hover { color: var(--danger); }
.ft-menu__sep { height: 1px; background: var(--border); margin: var(--space-1) calc(var(--space-1) * -1); }

/* Badge ------------------------------------------------------------------ */
.ft-badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 var(--space-2);
  font-size: 12px; line-height: 1; font-weight: 500; white-space: nowrap;
  border-radius: var(--radius-sm); background: var(--surface-sunken); color: var(--text-secondary);
}
.ft-badge--info { background: var(--info-soft); color: var(--info); }
.ft-badge--success { background: var(--success-soft); color: var(--success); }
.ft-badge--warning { background: var(--warning-soft); color: var(--warning); }
.ft-badge--danger { background: var(--danger-soft); color: var(--danger); }
.ft-badge--outline { background: transparent; border: 1px solid var(--border-strong); }
.ft-badge__dot { width: 6px; height: 6px; border-radius: var(--radius-full); background: currentColor; flex: none; }
.ft-badge--warning .ft-badge__dot { background: var(--warning-fill); }
.ft-count { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-full); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; background: var(--surface-sunken); color: var(--text-secondary); }
.ft-count--primary { background: var(--primary); color: var(--on-primary); }

/* Card ------------------------------------------------------------------- */
.ft-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); min-width: 0; }
.ft-card__header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: 14px var(--space-5); border-bottom: 1px solid var(--border); }
.ft-card__title { margin: 0; font-size: 15px; line-height: 22px; font-weight: 600; color: var(--text); }
.ft-card__subtitle { margin: 2px 0 0; font-size: 13px; line-height: 18px; color: var(--text-muted); }
.ft-card__body { padding: var(--space-5); }
.ft-card__body--flush { padding: 0; }
.ft-card__footer { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border); font-size: 13px; color: var(--text-muted); }
.ft-card--interactive { cursor: pointer; transition: border-color .12s ease-out; }
.ft-card--interactive:hover { border-color: var(--border-strong); }

.ft-stat { padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-1); }
.ft-stat__label { font-size: 13px; line-height: 18px; color: var(--text-secondary); font-weight: 500; }
.ft-stat__value { font-size: 30px; line-height: 36px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; color: var(--text); }
.ft-stat__meta { display: flex; align-items: center; gap: var(--space-2); font-size: 12px; line-height: 16px; color: var(--text-muted); }
.ft-delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ft-delta--up { color: var(--success); }
.ft-delta--down { color: var(--danger); }
.ft-meter { height: 6px; border-radius: var(--radius-full); background: var(--surface-sunken); overflow: hidden; }
.ft-meter__bar { height: 100%; background: var(--primary); border-radius: inherit; }

/* Table ------------------------------------------------------------------ */
.ft-table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.ft-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ft-table-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
.ft-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; line-height: 20px; }
.ft-table th { padding: 10px var(--space-4); text-align: left; white-space: nowrap; font-size: 12px; line-height: 16px; font-weight: 600; color: var(--text-secondary); background: var(--surface-sunken); border-bottom: 1px solid var(--border); }
.ft-table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.ft-table tbody tr:last-child td { border-bottom: 0; }
.ft-table tbody tr:hover td { background: var(--surface-hover); }
.ft-table .is-num { text-align: right; font-variant-numeric: tabular-nums; }
.ft-table .is-actions { width: 1%; text-align: right; white-space: nowrap; }
.ft-table__secondary { display: block; font-size: 12px; line-height: 16px; color: var(--text-muted); }

/* Avatar */
.ft-avatar { width: 32px; height: 32px; flex: none; border-radius: var(--radius-full); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; background: var(--primary-soft); color: var(--primary-text); text-transform: uppercase; }
.ft-avatar--sm { width: 24px; height: 24px; font-size: 11px; }

/* Alert ------------------------------------------------------------------ */
.ft-alert { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--surface-sunken); color: var(--text); }
.ft-alert > .ft-icon { width: 20px; height: 20px; color: var(--text-secondary); }
.ft-alert__content { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ft-alert__title { margin: 0; font-size: 14px; line-height: 20px; font-weight: 600; }
.ft-alert__text { margin: 0; font-size: 14px; line-height: 20px; color: var(--text-secondary); }
.ft-alert__actions { display: flex; gap: var(--space-3); margin-top: var(--space-2); }
.ft-alert--info { background: var(--info-soft); }
.ft-alert--info > .ft-icon { color: var(--info); }
.ft-alert--success { background: var(--success-soft); }
.ft-alert--success > .ft-icon { color: var(--success); }
.ft-alert--warning { background: var(--warning-soft); }
.ft-alert--warning > .ft-icon { color: var(--warning); }
.ft-alert--danger { background: var(--danger-soft); }
.ft-alert--danger > .ft-icon { color: var(--danger); }

/* Skeleton --------------------------------------------------------------- */
.ft-skeleton { position: relative; overflow: hidden; display: block; background: var(--skeleton); border-radius: var(--radius-sm); }
.ft-skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, var(--skeleton-shine), transparent); animation: ft-shimmer 1.4s ease-in-out infinite; }
.ft-skeleton--text { height: 12px; }
.ft-skeleton--title { height: 18px; }
.ft-skeleton--kpi { height: 32px; width: 96px; }
.ft-skeleton--circle { border-radius: var(--radius-full); }
@keyframes ft-shimmer { to { transform: translateX(100%); } }
.ft-loading-inline { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--text-muted); font-size: 13px; }

/* Empty state ------------------------------------------------------------ */
.ft-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-2); padding: var(--space-10) var(--space-6); }
.ft-empty--page { padding: var(--space-12) var(--space-6); }
.ft-empty__icon { width: 40px; height: 40px; margin-bottom: var(--space-2); display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-md); background: var(--surface-sunken); color: var(--text-secondary); }
.ft-empty__icon .ft-icon { width: 20px; height: 20px; }
.ft-empty--error .ft-empty__icon { background: var(--danger-soft); color: var(--danger); }
.ft-empty__title { margin: 0; font-size: 15px; line-height: 22px; font-weight: 600; color: var(--text); }
.ft-empty__text { margin: 0; max-width: 360px; font-size: 14px; line-height: 20px; color: var(--text-secondary); }
.ft-empty__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; justify-content: center; margin-top: var(--space-3); }

/* Page header + breadcrumb ---------------------------------------------- */
.ft-breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: 13px; line-height: 18px; color: var(--text-muted); }
.ft-breadcrumb li { display: inline-flex; align-items: center; gap: 6px; }
.ft-breadcrumb a { color: var(--text-secondary); text-decoration: none; }
.ft-breadcrumb a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.ft-breadcrumb [aria-current="page"] { color: var(--text); font-weight: 500; }
.ft-breadcrumb .ft-icon { width: 14px; height: 14px; color: var(--text-muted); }
.ft-page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.ft-page-header__text { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.ft-page-header__title { margin: 0; font-size: 24px; line-height: 32px; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
.ft-page-header__desc { margin: 0; font-size: 14px; color: var(--text-secondary); }

/* Indicador de tempo real (MQTT) ---------------------------------------- */
.ft-live { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: var(--radius-md); font-size: 12px; font-weight: 500; white-space: nowrap; color: var(--success); background: var(--success-soft); }
.ft-live__dot { width: 8px; height: 8px; border-radius: var(--radius-full); background: currentColor; }
.ft-live--reconnecting { color: var(--warning); background: var(--warning-soft); }
.ft-live--reconnecting .ft-live__dot { background: var(--warning-fill); animation: ft-pulse 1.2s ease-in-out infinite; }
.ft-live--offline { color: var(--danger); background: var(--danger-soft); }
@keyframes ft-pulse { 50% { opacity: .35; } }

/* ==========================================================================
   Shell: sidebar + topbar
   ========================================================================== */
.ft-sidebar { width: var(--sidebar); display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border); font-family: var(--font-sans); }
.ft-sidebar__brand { height: var(--topbar); flex: none; display: flex; align-items: center; gap: var(--space-3); padding: 0 var(--space-4); border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; }
.ft-sidebar__brand:hover, .ft-sidebar__brand:focus { text-decoration: none; color: var(--text); }
.ft-sidebar__logo { height: 32px; max-width: 120px; flex: none; display: inline-flex; align-items: center; }
.ft-sidebar__logo img { max-height: 32px; max-width: 120px; width: auto; display: block; }
.ft-sidebar__mark { width: 32px; height: 32px; border-radius: var(--radius-md); background: var(--brand-tenant); color: var(--on-primary); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; flex: none; }
.ft-sidebar__nav { flex: 1; min-height: 0; overflow-y: auto; padding: var(--space-3) var(--space-2); display: flex; flex-direction: column; gap: var(--space-4); }
.ft-sidebar__group { display: flex; flex-direction: column; gap: 2px; }
.ft-sidebar__heading { padding: 0 var(--space-3) 6px; font-size: 11px; line-height: 16px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); white-space: nowrap; }
.ft-nav-item { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 var(--space-3); border-radius: var(--radius-md); color: var(--text-secondary); font-size: 14px; font-weight: 500; text-decoration: none; white-space: nowrap; }
.ft-nav-item .ft-icon { width: 18px; height: 18px; }
.ft-nav-item:hover, .ft-nav-item:focus { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.ft-nav-item[aria-current="page"] { background: var(--primary-soft); color: var(--primary-text); }
.ft-nav-item .ft-count { margin-left: auto; }
.ft-sidebar__label { overflow: hidden; text-overflow: ellipsis; }
.ft-sidebar__footer { flex: none; border-top: 1px solid var(--border); padding: var(--space-2); display: flex; flex-direction: column; gap: 2px; }
.ft-sidebar__collapse { display: none; }

/* Posicionamento nas paginas legadas: sidebar fixa, conteudo recuado */
.ft-shell-sidebar { position: fixed; top: 0; left: 0; bottom: 0; z-index: 1025; }
body.ft-has-shell { padding-left: var(--sidebar); }
.ft-shell-backdrop { display: none; position: fixed; inset: 0; z-index: 1024; background: var(--overlay); }
.ft-topbar-host { border: 0 !important; padding: 0 !important; margin: 0 !important; background: transparent !important; }

@media (min-width: 1024px) {
  .ft-sidebar__collapse { display: flex; }
  body.ft-has-shell.ft-shell-collapsed { padding-left: var(--sidebar-collapsed); }
  .ft-shell-collapsed .ft-shell-sidebar { width: var(--sidebar-collapsed); }
  .ft-shell-collapsed .ft-sidebar__brand { justify-content: center; padding: 0; }
  .ft-shell-collapsed .ft-sidebar__logo,
  .ft-shell-collapsed .ft-sidebar__label,
  .ft-shell-collapsed .ft-sidebar__heading,
  .ft-shell-collapsed .ft-nav-item .ft-count { display: none; }
  .ft-shell-collapsed .ft-sidebar__nav { overflow: visible; }
  .ft-shell-collapsed .ft-nav-item { justify-content: center; padding: 0; position: relative; }
  .ft-shell-collapsed .ft-sidebar__collapse .ft-icon { transform: rotate(180deg); }
  .ft-shell-collapsed .ft-nav-item:hover::after,
  .ft-shell-collapsed .ft-nav-item:focus-visible::after {
    content: attr(data-tip); position: absolute; left: calc(100% + 8px); top: 50%; transform: translateY(-50%);
    z-index: var(--z-tooltip); padding: 6px var(--space-2); border-radius: var(--radius-sm);
    background: var(--tooltip-bg); color: var(--tooltip-text); box-shadow: var(--shadow-md);
    font-size: 12px; line-height: 16px; font-weight: 400; white-space: nowrap; pointer-events: none;
  }
  .ft-sidebar__mark--collapsed-only { display: none; }
  .ft-shell-collapsed .ft-sidebar__mark--collapsed-only { display: inline-flex; }
}

@media (max-width: 1023px) {
  body.ft-has-shell { padding-left: 0; }
  .ft-shell-sidebar { transform: translateX(-100%); transition: transform .18s ease-out; visibility: hidden; }
  body.ft-nav-open .ft-shell-sidebar { transform: none; visibility: visible; box-shadow: var(--shadow-lg); }
  body.ft-nav-open .ft-shell-backdrop { display: block; }
  .ft-sidebar__mark--collapsed-only { display: none; }
}

/* Topbar */
.ft-topbar { position: relative; z-index: 1015; height: var(--topbar); display: flex; align-items: center; gap: var(--space-3); padding: 0 var(--space-6); background: var(--surface); border-bottom: 1px solid var(--border); font-family: var(--font-sans); }
.ft-topbar__menu-toggle { display: none; margin-left: calc(var(--space-2) * -1); }
.ft-topbar__context { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.ft-topbar__title { display: flex; flex-direction: column; min-width: 0; }
.ft-topbar__title strong { font-size: 14px; line-height: 20px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ft-topbar__title span { font-size: 12px; line-height: 16px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ft-topbar__context select.form-control { min-width: 220px; }
.ft-topbar__actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }
.ft-topbar .dropdown-menu { right: 0; left: auto; margin-top: 6px; }
.ft-user { display: inline-flex; align-items: center; gap: var(--space-2); height: 40px; padding: 0 var(--space-2) 0 4px; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--text); font-family: inherit; font-size: 14px; font-weight: 500; cursor: pointer; }
.ft-user:hover, .ft-user:focus { background: var(--surface-hover); }
.ft-user__name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ft-user .ft-icon { color: var(--text-muted); }

/* Botao de tema: lua no claro, sol no escuro */
.ft-theme-toggle { color: var(--text-secondary); }
.ft-theme-toggle .ft-theme-toggle__sun { display: none; }
:root[data-theme="dark"] .ft-theme-toggle .ft-theme-toggle__sun { display: block; }
:root[data-theme="dark"] .ft-theme-toggle .ft-theme-toggle__moon { display: none; }

/* Logos com variante _light (ft_logo()): cada tema mostra a sua */
:root[data-theme="dark"] .ft-theme-light-only,
:root:not([data-theme="dark"]) .ft-theme-dark-only { display: none !important; }

/* Logos das construtoras sao desenhados para fundo claro: base clara no escuro
   (dispensada quando o logo tem variante _light) */
:root[data-theme="dark"] .ft-sidebar__logo:not(.ft-sidebar__logo--themed) { background: #f4f6f8; border-radius: var(--radius-sm); padding: 3px 6px; height: auto; }

@media (max-width: 1023px) {
  .ft-topbar { padding: 0 var(--space-4); }
  .ft-topbar__menu-toggle { display: inline-flex; }
}
@media (max-width: 599px) {
  .ft-user__name { display: none; }
  .ft-topbar__context select.form-control { min-width: 0; max-width: 160px; }
}

/* ==========================================================================
   Launcher: pagina-indice de modulo (Financeiro, RH/DP...) com atalhos agrupados
   ========================================================================== */
.ft-launcher { display: flex; flex-direction: column; gap: var(--space-8); padding: var(--space-2) 0 var(--space-8); max-width: var(--content-max); }
.ft-launcher__group { display: flex; flex-direction: column; gap: var(--space-3); }
.ft-launcher__heading { margin: 0; font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.ft-launcher__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--space-3); }
.ft-tile {
  display: flex; align-items: center; gap: var(--space-3); width: 100%; min-height: 64px; padding: 12px 14px;
  text-align: left; font-family: inherit; font-size: 14px; line-height: 20px; font-weight: 500; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); cursor: pointer;
  transition: border-color .12s ease-out, background-color .12s ease-out;
}
.ft-tile:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.ft-tile:focus { outline: 0; }
.ft-tile:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.ft-tile:active { transform: translateY(1px); }
.ft-tile__icon { width: 36px; height: 36px; flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-md); background: var(--primary-soft); color: var(--primary-text); font-size: 16px; }
.ft-tile__icon img { max-width: 20px; max-height: 20px; display: block; }
.ft-tile__text { min-width: 0; display: flex; flex-direction: column; }
.ft-tile__desc { font-size: 12px; line-height: 16px; font-weight: 400; color: var(--text-muted); }
.ft-tile__chev { margin-left: auto; color: var(--text-muted); opacity: 0; transition: opacity .12s ease-out; }
.ft-tile:hover .ft-tile__chev, .ft-tile:focus-visible .ft-tile__chev { opacity: 1; }
@media (max-width: 599px) {
  .ft-launcher { gap: var(--space-6); }
  .ft-launcher__grid { grid-template-columns: 1fr; gap: var(--space-2); }
  .ft-tile__chev { opacity: 1; }
}

/* ==========================================================================
   Auth (telas de login): formulario a esquerda, foto do modulo a direita
   ========================================================================== */
body.ft-auth { margin: 0; min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 520px) 1fr; background: var(--surface); padding: 0 !important; }
.ft-auth__panel { display: flex; flex-direction: column; justify-content: space-between; gap: var(--space-8); padding: var(--space-10) var(--space-12); min-height: 100vh; }
.ft-auth__brand img { height: 32px; width: auto; display: block; }
.ft-auth__body { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: var(--space-6); }
.ft-auth__eyebrow { margin: 0; font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--primary-text); }
.ft-auth__title { margin: var(--space-2) 0 0; font-size: 24px; line-height: 32px; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
.ft-auth__subtitle { margin: var(--space-1) 0 0; font-size: 14px; line-height: 20px; color: var(--text-secondary); }
.ft-auth__form { display: flex; flex-direction: column; gap: var(--space-4); margin: 0; }
.ft-auth__form .ft-input { height: var(--control-lg); font-size: 15px; }
.ft-auth__form .ft-btn { margin-top: var(--space-2); }
.ft-auth__toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--text-muted); cursor: pointer; }
.ft-auth__toggle:hover { background: var(--surface-hover); color: var(--text); }
.ft-auth__form .ft-input-wrap .ft-input.has-toggle { padding-right: 44px; }
.ft-auth__note { font-size: 13px; line-height: 18px; color: var(--text-secondary); }
.ft-auth__note:empty { display: none; }
.ft-auth__footer { font-size: 12px; line-height: 16px; color: var(--text-muted); }
.ft-auth__media { margin: var(--space-4) var(--space-4) var(--space-4) 0; border-radius: var(--radius-lg); background-color: var(--surface-sunken); background-size: cover; background-position: center; }
.ft-auth input:-webkit-autofill,
.ft-auth input:-webkit-autofill:hover,
.ft-auth input:-webkit-autofill:focus { -webkit-text-fill-color: var(--text); -webkit-box-shadow: 0 0 0 40px var(--surface) inset; }
@media (max-width: 899px) {
  body.ft-auth { grid-template-columns: 1fr; }
  .ft-auth__media { display: none; }
  .ft-auth__panel { padding: var(--space-8) var(--space-6); padding-top: calc(var(--space-8) + env(safe-area-inset-top, 0px)); }
  .ft-auth__body { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  .ft-skeleton::after, .ft-spinner, .ft-live--reconnecting .ft-live__dot { animation: none; }
  .ft-btn, .ft-input, .ft-shell-sidebar { transition: none; }
}
