/* Centro de mando: pestañas en el encabezado, configuración por módulo y la Huella de actividad. */

/* Ningún bloque puede ensanchar la vista. */
.tab-panel, .cc-pane, .huella, .huella-panel { min-width: 0; }

/* Pestañas en el encabezado: sin tarjeta, a todo su ancho y con el indicador sobre su borde inferior.
   Caben en una fila desde 1280 px. Más angosto se ven los iconos y el nombre de la activa; en celulares, solo
   los iconos. Los nombres ocultos siguen siendo el nombre accesible de cada pestaña. */
.topbar-tabs { container-type: inline-size; }
/* Las pestañas pueden compartir la fila con un control de la vista, como el país en Planillas. */
.topbar-tabs-row { display: flex; align-items: flex-end; gap: 14px; }
.topbar-tabs-row > nav { flex: 1; min-width: 0; }
.topbar-tabs-row > :not(nav) { flex: none; padding-bottom: 4px; }
/* Con las pestañas arriba, el panel no necesita separarse de ellas: basta el espacio de la vista. */
.view-system-settings > .tab-panel, .view-payroll > .tab-panel { margin-top: 0; }
.topbar-tabs .tabs { overflow: visible; padding: 0 0 7px; border: 0; border-radius: 0; background: none; box-shadow: none; }
.topbar-tabs .tab { flex: 1 1 auto; justify-content: center; gap: 7px; min-height: 42px; padding: 6px 10px 6px 6px; font-size: 12.5px; }
.topbar-tabs .tab-icon { width: 28px; height: 28px; border-radius: 9px; }
@container (max-width: 960px) {
  .topbar-tabs .tab:not(.active) { padding: 6px; }
  .topbar-tabs .tab:not(.active) > span:not(.tab-icon) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
@container (max-width: 520px) {
  .topbar-tabs .tab { flex: 1 1 0; min-width: 0; padding: 6px; }
  .topbar-tabs .tab > span:not(.tab-icon) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

/* Subpestañas: una segunda fila más liviana bajo las pestañas, como en Mensajería. Son pocas, así que conservan
   sus nombres hasta los celulares, donde solo la activa muestra el suyo. */
.topbar-subtabs { margin-top: 2px; padding-top: 6px; border-top: 1px solid var(--line-soft); }
.topbar-subtabs:not([hidden]) { animation: subtabs-in .32s var(--spring) both; }
@keyframes subtabs-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.topbar-tabs .topbar-subtabs .tabs { gap: 6px; padding-bottom: 6px; }
.topbar-tabs .topbar-subtabs .tab { flex: 0 0 auto; gap: 7px; min-height: 36px; padding: 4px 12px 4px 4px; font-size: 12.5px; }
.topbar-tabs .topbar-subtabs .tab-icon { width: 26px; height: 26px; border-radius: 8px; }
.topbar-tabs .topbar-subtabs .tab-icon .i { width: 14px; height: 14px; }
@container (max-width: 960px) {
  .topbar-tabs .topbar-subtabs .tab:not(.active) { padding: 4px 12px 4px 4px; }
  .topbar-tabs .topbar-subtabs .tab:not(.active) > span:not(.tab-icon) { position: static; width: auto; height: auto; overflow: visible; clip-path: none; }
}
@container (max-width: 520px) {
  .topbar-tabs .topbar-subtabs .tab { flex: 1 1 0; justify-content: center; padding: 4px; }
  .topbar-tabs .topbar-subtabs .tab.active { flex: 2 1 auto; padding-right: 12px; }
  .topbar-tabs .topbar-subtabs .tab.active > span:not(.tab-icon) { position: static; width: auto; height: auto; overflow: visible; clip-path: none; }
  .topbar-tabs .topbar-subtabs .tab:not(.active) > span:not(.tab-icon) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}

/* Pestañas reutilizables */
.tabs {
  position: relative; display: flex; gap: 4px; overflow-x: auto; padding: 6px 6px 10px;
  border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-sm);
  scrollbar-width: thin;
}
.tab {
  display: inline-flex; align-items: center; gap: 9px; flex: none; min-height: 44px; padding: 8px 16px 8px 8px;
  border-radius: var(--r-md); color: var(--ink-3); font-size: 13.5px; font-weight: 700; white-space: nowrap;
  transition: color .2s var(--ease), background-color .2s var(--ease), transform .2s var(--ease);
}
.tab:hover { color: var(--tone-ink); background: var(--surface-2); }
.tab:active { transform: scale(.97); }
.tab.active { color: var(--tone-ink); background: var(--tone-soft); }
.tab:focus-visible { outline: 3px solid var(--tone-soft); outline-offset: 2px; }
.tab-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 10px; background: var(--tone-soft); color: var(--tone-ink); transition: transform .3s var(--spring); }
.tab.active .tab-icon { background: var(--tone); color: var(--surface); }
.tab:hover .tab-icon { transform: rotate(-8deg) scale(1.08); }
.tab-icon .i { width: 16px; height: 16px; }
.tab-count { display: grid; place-items: center; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--line-soft); color: var(--ink-3); font-size: 11.5px; font-weight: 800; }
.tab.active .tab-count { background: var(--surface); color: var(--tone-ink); }
.tabs-ink {
  position: absolute; left: 0; top: 0; width: 100px; height: 3px; border-radius: 3px;
  background: var(--ink-tone, var(--blue-500)); transform-origin: left center; transition: transform .35s var(--ease); pointer-events: none;
}
.tab-panel { margin-top: 18px; border-radius: var(--r-lg); }
.tab-panel:focus-visible { outline: 3px solid var(--blue-100); outline-offset: 4px; }
.cc-pane.is-entering { animation: cc-enter .32s var(--ease) both; }
@keyframes cc-enter { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Configuración de un módulo con sus últimos cambios */
.cc-settings { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, 1fr); gap: 18px; align-items: start; }
.cc-history { position: relative; overflow: hidden; padding: 20px 20px 18px; }
.cc-history::before { position: absolute; inset: 0 0 auto; height: 4px; content: ""; background: var(--tone-ink); opacity: .85; }
.cc-history-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.cc-history-head h3 { margin-top: 2px; }
.cc-history-body { display: grid; gap: 10px; }
.cc-history-list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.cc-history-list li { display: flex; gap: 12px; padding: 10px; border-radius: var(--r-md); transition: background-color .2s var(--ease), transform .2s var(--ease); }
.cc-history-list li:hover { background: var(--surface-2); transform: translateX(3px); }
.cc-history-list strong { font-size: 13px; }
.cc-history-list p { margin-top: 2px; font-size: 12.5px; color: var(--ink-2); line-height: 1.45; }
.cc-history-list time { display: block; margin-top: 3px; font-size: 11.5px; color: var(--ink-4); }
.cc-history-error { display: flex; align-items: center; gap: 8px; color: var(--red-500); font-size: 13px; font-weight: 600; }
.cc-history .empty { padding: 18px 8px; }

/* Huella */
.huella { display: grid; gap: 18px; }
.huella-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.huella-panel { overflow: hidden; }
.huella-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 20px 22px 6px; }
.huella-top h3 { margin-top: 2px; }
.huella-top p { margin-top: 4px; font-size: 13px; }
.huella-top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.huella-live { min-height: 38px; padding: 6px 12px; }
.huella-live .live-dot { display: inline-block; margin-right: 6px; opacity: .35; transition: opacity .2s var(--ease); }
.huella-live.is-on .live-dot { opacity: 1; }
.huella-filters { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; padding: 14px 22px 0; }
.huella-search .input { width: 100%; }
.huella-modules { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 22px 4px; }
.huella-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 6px 12px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--surface-2); color: var(--ink-3); font-size: 12.5px; font-weight: 700;
  transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .25s var(--spring);
}
.huella-chip .i { width: 14px; height: 14px; }
.huella-chip:hover { transform: translateY(-1px); border-color: var(--tone); }
.huella-chip:active { transform: scale(.95); }
.huella-chip[aria-pressed="true"] { border-color: transparent; background: var(--tone-soft); color: var(--tone-ink); }
.huella-chip:focus-visible { outline: 3px solid var(--tone-ink); outline-offset: 2px; }
.huella-warning {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 12px 22px 0; padding: 10px 14px;
  border-radius: var(--r-md); background: var(--tone-soft); color: var(--tone-ink); font-size: 13px;
}
.huella-warning > span { flex: 1 1 220px; }
.huella-count { padding: 12px 22px 0; font-size: 12.5px; font-weight: 650; color: var(--ink-3); }
.huella-count:empty { display: none; }
.huella-timeline { display: grid; gap: 18px; padding: 14px 22px 22px; }
.huella-skeleton { display: grid; gap: 8px; }
.huella-day-title {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px;
  font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3);
}
.huella-day-title span { font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--ink-4); }
.huella-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.huella-row {
  position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease);
}
.huella-row::before { position: absolute; inset: 0 auto 0 0; width: 3px; content: ""; background: var(--tone); opacity: .8; }
.huella-row::after { position: absolute; inset: 0; content: ""; background: var(--tone-soft); opacity: 0; pointer-events: none; }
.huella-row.is-new::after { animation: huella-flash 1.6s var(--ease); }
@keyframes huella-flash { 0%, 30% { opacity: .9; } 100% { opacity: 0; } }
.huella-row:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); border-color: var(--tone-soft); }
.huella-head {
  position: relative; z-index: 1; display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto auto auto; align-items: center;
  gap: 12px; width: 100%; min-height: 58px; padding: 10px 14px 10px 16px; text-align: left; color: var(--ink);
}
.huella-head:focus-visible { outline: 3px solid var(--tone-soft); outline-offset: -3px; border-radius: var(--r-md); }
.huella-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--tone-soft); color: var(--tone-ink); transition: transform .3s var(--spring); }
.huella-row:hover .huella-icon { transform: scale(1.1) rotate(-6deg); }
.huella-icon .i { width: 16px; height: 16px; }
.huella-bot { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--tone-soft); color: var(--tone-ink); }
.huella-bot .i { width: 15px; height: 15px; }
.huella-text { min-width: 0; font-size: 13.5px; line-height: 1.45; color: var(--ink-2); }
.huella-text strong { color: var(--ink); }
.huella-text small { display: block; margin-top: 1px; overflow: hidden; font-size: 12px; color: var(--ink-3); text-overflow: ellipsis; white-space: nowrap; }
.huella-module { flex: none; }
.huella-head time { font-size: 12.5px; font-weight: 650; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.huella-chevron { display: grid; place-items: center; color: var(--ink-4); transition: transform .25s var(--ease); }
.huella-head[aria-expanded="true"] .huella-chevron { transform: rotate(180deg); }
.huella-detail { position: relative; z-index: 1; padding: 2px 16px 16px 60px; animation: cc-enter .25s var(--ease); }
.huella-pairs { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 18px; margin: 0; padding: 12px 14px; border-radius: var(--r-sm); background: var(--surface-2); }
.huella-pairs dt { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-4); }
.huella-pairs dd { margin: 2px 0 0; font-size: 13px; color: var(--ink-2); overflow-wrap: anywhere; }
.huella-pairs code { font-size: 12px; }
/* Acciones sensibles (ADR 0057): un escudo ámbar junto al texto y el borde con el mismo tono. */
.huella-row.is-sensitive { border-color: var(--amber-100); }
.huella-sensitive {
  display: inline-grid; place-items: center; width: 20px; height: 20px; margin-left: 6px; border-radius: 6px;
  background: var(--tone-soft); color: var(--tone-ink); vertical-align: -4px;
}
.huella-sensitive .i { width: 12px; height: 12px; }
.huella-more { display: flex; justify-content: center; padding: 0 22px 22px; }
.huella-more .is-busy { opacity: .6; }

@media (max-width: 980px) {
  .cc-settings { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .huella-filters { grid-template-columns: 1fr 1fr; }
  .huella-search { grid-column: 1 / -1; }
  .huella-head { grid-template-columns: auto minmax(0, 1fr) auto auto; }
  .huella-head .avatar, .huella-head .huella-bot, .huella-module { display: none; }
  .huella-detail { padding-left: 16px; }
}
@media (max-width: 480px) {
  .huella-top, .huella-filters, .huella-modules, .huella-count, .huella-timeline { padding-left: 16px; padding-right: 16px; }
  .huella-warning { margin-left: 16px; margin-right: 16px; }
  .huella-filters { grid-template-columns: 1fr; }
  .huella-chevron { display: none; }
  .huella-head { grid-template-columns: auto minmax(0, 1fr) auto; }
}
@media (prefers-reduced-motion: reduce) {
  .huella-row.is-new::after, .cc-pane.is-entering, .huella-detail { animation: none; }
}
