/*
 * TimeBit Design System — Components
 * Clases reutilizables para toda la app.
 * Requiere: timebit-tokens.css cargado antes.
 * Versión: 1.0 · 2026-03-14
 */

/* ════════════════════════════════════════
   BASE GLOBAL
════════════════════════════════════════ */

body {
  background: var(--tb-bg-app) !important;
  font-family: var(--tb-font-family);
  color: var(--tb-text-primary);
  font-size: var(--tb-font-md);
}

/* ════════════════════════════════════════
   SHELL: SIDEBAR + TOPBAR (.tb-shell)
   Layout único de toda la app autenticada,
   inspirado en Sesame HR: sidebar izquierdo
   colapsable + topbar clara + contenido.
════════════════════════════════════════ */

.tb-shell {
  display: flex;
  min-height: 100vh;
  background: var(--tb-bg-app);
}

/* ── Sidebar ── */

.tb-sidebar {
  flex-shrink: 0;
  width: var(--tb-sidebar-width);
  background: var(--tb-bg-sidebar);
  border-right: 1px solid var(--tb-sidebar-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: width .18s ease;
  z-index: 1040;
}

.tb-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--tb-sidebar-border);
  flex-shrink: 0;
}

.tb-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  text-decoration: none;
}

.tb-sidebar-brand img {
  height: 30px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
  flex-shrink: 0;
}

/* Colapsado (desktop): recorta al icono, oculta el wordmark */
@media (min-width: 900px) {
  .tb-shell.is-nav-collapsed .tb-sidebar-brand img {
    width: 30px;
    max-width: 30px;
    object-fit: cover;
    object-position: left center;
  }
}

.tb-sidebar-brand-text {
  font-weight: var(--tb-weight-black);
  font-size: 1rem;
  color: var(--tb-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tb-sidebar-toggle {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--tb-radius-sm);
  border: 1px solid var(--tb-sidebar-border);
  background: transparent;
  color: var(--tb-sidebar-text);
  cursor: pointer;
  transition: var(--tb-transition);
}
.tb-sidebar-toggle:hover { background: var(--tb-sidebar-hover-bg); }

.tb-sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tb-sidebar-group + .tb-sidebar-group { margin-top: 14px; }

.tb-sidebar-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  font-size: var(--tb-font-xs);
  font-weight: var(--tb-weight-medium);
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--tb-sidebar-text);
  padding: 4px 10px 6px;
  white-space: nowrap;
}

.tb-sidebar-group-chevron {
  font-size: 9px;
  flex-shrink: 0;
  transition: transform .15s ease;
}

.tb-sidebar-group.is-collapsed .tb-sidebar-group-chevron { transform: rotate(-90deg); }

.tb-sidebar-group-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tb-sidebar-group.is-collapsed .tb-sidebar-group-links { display: none; }

.tb-sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: var(--tb-radius-sm);
  color: var(--tb-sidebar-text);
  font-size: var(--tb-font-body);
  font-weight: var(--tb-weight-normal);
  text-decoration: none !important;
  white-space: nowrap;
  transition: background .12s, color .12s, box-shadow .12s;
}

.tb-sidebar-link i { width: 18px; text-align: center; flex-shrink: 0; font-size: .9rem; opacity: .65; }

.tb-sidebar-link:hover { background: var(--tb-sidebar-hover-bg); color: var(--tb-text-primary); }
.tb-sidebar-link:hover i { opacity: .9; }

.tb-sidebar-link.is-active {
  background: rgba(99, 102, 241, 0.06);
  box-shadow: inset 3px 0 0 var(--tb-primary);
  color: var(--tb-sidebar-text-active);
  font-weight: 500;
}
.tb-sidebar-link.is-active i { opacity: 1; color: var(--tb-primary); }

.tb-sidebar-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--tb-radius-pill);
  background: var(--tb-danger);
  color: #fff;
  font-size: .68rem;
  font-weight: var(--tb-weight-bold);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Colapsado (desktop): solo iconos */
@media (min-width: 900px) {
  .tb-shell.is-nav-collapsed .tb-sidebar { width: var(--tb-sidebar-width-collapsed); }
  .tb-shell.is-nav-collapsed .tb-sidebar-brand-text,
  .tb-shell.is-nav-collapsed .tb-sidebar-group-title,
  .tb-shell.is-nav-collapsed .tb-sidebar-link span,
  .tb-shell.is-nav-collapsed .tb-sidebar-badge { display: none; }
  .tb-shell.is-nav-collapsed .tb-sidebar-link { justify-content: center; }
  /* En modo icono, ignorar el acordeón: mostrar siempre los iconos */
  .tb-shell.is-nav-collapsed .tb-sidebar-group.is-collapsed .tb-sidebar-group-links { display: flex; }
}

/* Off-canvas (mobile): oculto por defecto */
@media (max-width: 899px) {
  .tb-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    box-shadow: var(--tb-shadow-lg);
    transform: translateX(-100%);
  }
  .tb-shell.is-nav-collapsed .tb-sidebar { transform: translateX(0); }

  /* Overlay oscuro detrás del sidebar en móvil */
  .tb-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1039;
    background: rgba(0,0,0,.35);
    cursor: pointer;
  }
  .tb-shell.is-nav-collapsed .tb-sidebar-overlay { display: block; }
}

/* ── Topbar ── */

.tb-shell-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.tb-topbar {
  height: var(--tb-topbar-height);
  background: var(--tb-topbar-bg);
  border-bottom: 1px solid var(--tb-topbar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 1030;
}

.tb-topbar-left,
.tb-topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.tb-topbar-right { flex-shrink: 0; }

.tb-content {
  flex: 1;
  padding: var(--tb-space-lg);
}

@media (max-width: 640px) {
  .tb-content { padding: var(--tb-space-md); }
}

/* ════════════════════════════════════════
   CABECERA DE PÁGINA (.tb-page-header)
   Aparece arriba de cada pantalla.
   Incluye título, subtítulo, breadcrumb
   y zona de botones de acción.
════════════════════════════════════════ */

.tb-page-header {
  background: var(--tb-bg-card);
  border-radius: var(--tb-radius-lg);
  padding: var(--tb-space-lg) var(--tb-space-xl);
  box-shadow: var(--tb-shadow-card);
  margin-bottom: var(--tb-space-lg);
  border: var(--tb-border);
}

.tb-breadcrumb {
  font-size: var(--tb-font-xs);
  color: var(--tb-text-muted);
  margin-bottom: var(--tb-space-sm);
  display: flex;
  align-items: center;
  gap: 6px;
}

.tb-breadcrumb a {
  color: var(--tb-text-muted);
  text-decoration: none;
}

.tb-breadcrumb a:hover {
  color: var(--tb-primary);
}

.tb-breadcrumb-sep { color: var(--tb-border-color); }

.tb-page-title {
  font-size: var(--tb-font-xl);
  font-weight: var(--tb-weight-black);
  color: var(--tb-text-primary);
  line-height: 1.2;
  margin: 0 0 2px;
}

.tb-page-subtitle {
  font-size: var(--tb-font-sm);
  color: var(--tb-text-secondary);
  margin: 0;
}

.tb-page-header-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: var(--tb-space-md);
}

.tb-page-actions {
  display: flex;
  align-items: center;
  gap: var(--tb-space-sm);
  flex-wrap: wrap;
  margin-top: var(--tb-space-md);
}

/* ════════════════════════════════════════
   BOTONES (.tb-btn-*)
   Usar SIEMPRE en lugar de clases ad-hoc.
════════════════════════════════════════ */

.tb-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: var(--tb-font-sm);
  font-weight: var(--tb-weight-medium);
  line-height: 1;
  cursor: pointer;
  border: 2px solid transparent;
  text-decoration: none !important;
  transition: var(--tb-transition);
  white-space: nowrap;
}

.tb-btn:hover { transform: translateY(-1px); }
.tb-btn:active { transform: translateY(0); }

/* Tamaño pequeño */
.tb-btn-sm {
  padding: 7px 12px;
  font-size: var(--tb-font-xs);
}

/* Tamaño grande */
.tb-btn-lg {
  padding: 13px 28px;
  font-size: var(--tb-font-md);
  font-weight: var(--tb-weight-bold);
}

/* Bloque (ancho completo) */
.tb-btn-block { width: 100%; justify-content: center; }

/* Primary — guardar, enviar, confirmar */
.tb-btn-primary {
  background: var(--tb-primary);
  color: var(--tb-text-on-dark) !important;
  border-color: var(--tb-primary);
}
.tb-btn-primary:hover {
  background: var(--tb-primary-mid);
  border-color: var(--tb-primary-mid);
  color: var(--tb-text-on-dark) !important;
  box-shadow: 0 4px 14px rgba(99,102,241,.35);
}

/* Success — aprobar, activar, entrada */
.tb-btn-success {
  background: var(--tb-success);
  color: var(--tb-text-on-dark) !important;
  border-color: var(--tb-success);
}
.tb-btn-success:hover {
  background: #047857;
  border-color: #047857;
  color: var(--tb-text-on-dark) !important;
  box-shadow: 0 4px 14px rgba(5,150,105,.35);
}

/* Danger — eliminar, rechazar, salida */
.tb-btn-danger {
  background: var(--tb-danger);
  color: var(--tb-text-on-dark) !important;
  border-color: var(--tb-danger);
}
.tb-btn-danger:hover {
  background: #be123c;
  border-color: #be123c;
  color: var(--tb-text-on-dark) !important;
  box-shadow: 0 4px 14px rgba(225,29,72,.35);
}

/* Secondary (gris) — volver, cancelar */
.tb-btn-secondary {
  background: var(--tb-neutral);
  color: var(--tb-text-on-dark) !important;
  border-color: var(--tb-neutral);
}
.tb-btn-secondary:hover {
  background: #4b5563;
  border-color: #4b5563;
  color: var(--tb-text-on-dark) !important;
}

/* Outline — acción secundaria sobre fondo claro */
.tb-btn-outline {
  background: transparent;
  color: var(--tb-primary) !important;
  border-color: var(--tb-primary);
}
.tb-btn-outline:hover {
  background: var(--tb-primary-bg);
  color: var(--tb-primary) !important;
}

/* Warning — revisar, pendiente */
.tb-btn-warning {
  background: var(--tb-warning);
  color: var(--tb-text-on-dark) !important;
  border-color: var(--tb-warning);
}
.tb-btn-warning:hover {
  background: #b45309;
  border-color: #b45309;
  color: var(--tb-text-on-dark) !important;
}

/* ════════════════════════════════════════
   TARJETAS (.tb-card)
════════════════════════════════════════ */

.tb-card {
  background: var(--tb-bg-card);
  border-radius: 12px;
  box-shadow: var(--tb-shadow-card);
  border: var(--tb-border);
  overflow: hidden;
}

.tb-card-header {
  background: #f8fafc;
  color: #334155;
  padding: 10px 16px;
  font-weight: var(--tb-weight-bold);
  font-size: var(--tb-font-section);
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--tb-border-color);
}

.tb-card-header-primary {
  background: #eef2ff;
  color: #3730a3;
}

.tb-card-body {
  padding: var(--tb-space-lg) var(--tb-space-xl);
}

/* ════════════════════════════════════════
   SECCIÓN DENTRO DE CARD (.tb-section)
════════════════════════════════════════ */

.tb-section-title {
  font-size: var(--tb-font-xs);
  font-weight: var(--tb-weight-bold);
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--tb-text-muted);
  margin-bottom: var(--tb-space-sm);
}

/* ════════════════════════════════════════
   BADGES DE ESTADO (.tb-badge-*)
════════════════════════════════════════ */

.tb-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--tb-radius-pill);
  font-size: var(--tb-font-xs);
  font-weight: var(--tb-weight-bold);
  white-space: nowrap;
}

.tb-badge-success  { background: var(--tb-success-bg);  color: var(--tb-success-txt); }
.tb-badge-warning  { background: var(--tb-warning-bg);  color: var(--tb-warning-txt); }
.tb-badge-danger   { background: var(--tb-danger-bg);   color: var(--tb-danger-txt);  }
.tb-badge-primary  { background: var(--tb-primary-bg);  color: #3730a3;               }
.tb-badge-neutral  { background: var(--tb-neutral-bg);  color: var(--tb-neutral-txt); }
.tb-badge-info     { background: var(--tb-info-bg);     color: var(--tb-info-txt);    }
.tb-badge-dark     { background: var(--tb-dark);        color: var(--tb-text-on-dark);}

/* ════════════════════════════════════════
   FORMULARIOS (.tb-form-*)
════════════════════════════════════════ */

.tb-form-label {
  font-size: var(--tb-form-label-font-size);
  font-weight: var(--tb-form-label-weight);
  text-transform: none;
  letter-spacing: normal;
  color: var(--tb-form-label-color);
  margin-bottom: var(--tb-form-label-gap);
  display: block;
}

/* Compactación global en el shell autenticado para evitar cambios en páginas públicas. */
.tb-shell :where(
  .tb-form-input,
  .tb-form-select,
  .tb-form-textarea,
  .form-control,
  .form-select,
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="hidden"]),
  select,
  textarea
) {
  border: 1px solid var(--tb-form-border-color);
  border-radius: var(--tb-form-radius);
  min-height: var(--tb-form-height);
  padding: var(--tb-form-padding-y) var(--tb-form-padding-x);
  font-size: var(--tb-font-sm);
  line-height: 1.25;
  color: var(--tb-text-primary);
  background: var(--tb-form-bg);
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}

.tb-shell :where(.tb-form-input, .tb-form-select, .tb-form-textarea, .form-control, .form-select) {
  width: 100%;
}

.tb-shell :where(textarea, .tb-form-textarea) {
  min-height: var(--tb-form-min-height-textarea);
  resize: vertical;
}

.tb-shell :where(
  .tb-form-input,
  .tb-form-select,
  .tb-form-textarea,
  .form-control,
  .form-select,
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="hidden"]),
  select,
  textarea
):hover {
  border-color: var(--tb-form-border-color-hover);
}

.tb-shell :where(
  .tb-form-input,
  .tb-form-select,
  .tb-form-textarea,
  .form-control,
  .form-select,
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="hidden"]),
  select,
  textarea
):focus,
.tb-shell :where(
  .tb-form-input,
  .tb-form-select,
  .tb-form-textarea,
  .form-control,
  .form-select,
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="hidden"]),
  select,
  textarea
):focus-visible {
  outline: none;
  border-color: var(--tb-form-border-color-focus);
  box-shadow: 0 0 0 1px var(--tb-bg-card), 0 0 0 var(--tb-form-focus-ring-size) var(--tb-form-focus-ring-color);
}

.tb-shell :where(
  .tb-form-input,
  .tb-form-select,
  .tb-form-textarea,
  .form-control,
  .form-select,
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="hidden"]),
  select,
  textarea
):disabled,
.tb-shell :where(
  .tb-form-input,
  .tb-form-select,
  .tb-form-textarea,
  .form-control,
  .form-select,
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="hidden"]),
  select,
  textarea
)[readonly] {
  background: var(--tb-form-bg-disabled);
  border-color: var(--tb-border-color);
  color: var(--tb-form-text-disabled);
  cursor: not-allowed;
  opacity: 1;
}

.tb-shell :where(
  .tb-form-input,
  .tb-form-select,
  .tb-form-textarea,
  .form-control,
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="hidden"]),
  textarea
)::placeholder {
  color: var(--tb-form-placeholder);
  opacity: 1;
}

.tb-shell :where(.form-group, .tb-form-group, .mb-3) {
  margin-bottom: var(--tb-form-group-gap);
}

.tb-shell :where(.form-group, .tb-form-group, .mb-3) > label,
.tb-shell :where(.form-label, .col-form-label, .tb-form-label) {
  font-size: var(--tb-form-label-font-size);
  font-weight: var(--tb-form-label-weight);
  color: var(--tb-form-label-color);
}

@media (max-width: 640px) {
  .tb-shell :where(
    .tb-form-input,
    .tb-form-select,
    .tb-form-textarea,
    .form-control,
    .form-select,
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="hidden"]),
    select,
    textarea
  ) {
    min-height: 30px;
    padding: 4px 8px;
    font-size: var(--tb-font-xs);
  }
}

/* ════════════════════════════════════════
   TABLA ESTÁNDAR (.tb-table)
════════════════════════════════════════ */

.tb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--tb-font-sm);
}

.tb-table thead th {
  background: #f8fafc;
  color: #64748b;
  padding: 11px 14px;
  font-size: var(--tb-font-xs);
  font-weight: var(--tb-weight-bold);
  text-transform: uppercase;
  letter-spacing: .06em;
  text-align: left;
  white-space: nowrap;
  border-bottom: var(--tb-border);
}

.tb-table tbody tr {
  border-bottom: var(--tb-border);
  transition: background .1s;
}

.tb-table tbody tr:hover {
  background: #f8fafc;
}

.tb-table tbody td {
  padding: 12px 14px;
  color: var(--tb-text-primary);
}

/* ════════════════════════════════════════
   ALERTAS / MENSAJES (.tb-alert-*)
════════════════════════════════════════ */

.tb-alert {
  padding: var(--tb-space-md) var(--tb-space-lg);
  border-radius: var(--tb-radius-md);
  font-size: var(--tb-font-sm);
  font-weight: var(--tb-weight-medium);
  border-left: 4px solid;
  margin-bottom: var(--tb-space-md);
}

.tb-alert-success { background: var(--tb-success-bg); color: var(--tb-success-txt); border-color: var(--tb-success); }
.tb-alert-warning { background: var(--tb-warning-bg); color: var(--tb-warning-txt); border-color: var(--tb-warning); }
.tb-alert-danger  { background: var(--tb-danger-bg);  color: var(--tb-danger-txt);  border-color: var(--tb-danger);  }
.tb-alert-info    { background: var(--tb-primary-bg); color: #3730a3;               border-color: var(--tb-primary); }

/* ════════════════════════════════════════
   ESTADÍSTICAS KPI (.tb-kpi-*)
════════════════════════════════════════ */

.tb-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--tb-space-md);
  margin-bottom: var(--tb-space-lg);
}

.tb-kpi-card {
  background: var(--tb-bg-card);
  border-radius: var(--tb-radius-lg);
  padding: var(--tb-space-lg);
  box-shadow: var(--tb-shadow-card);
  text-align: center;
  border-top: 3px solid var(--tb-primary);
}

.tb-kpi-value {
  font-size: 2.2rem;
  font-weight: var(--tb-weight-black);
  color: var(--tb-text-primary);
  line-height: 1;
}

.tb-kpi-label {
  font-size: var(--tb-font-xs);
  font-weight: var(--tb-weight-bold);
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--tb-text-muted);
  margin-top: var(--tb-space-xs);
}

/* ════════════════════════════════════════
   CONTENEDOR PRINCIPAL
════════════════════════════════════════ */

.tb-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--tb-space-lg);
}

@media (max-width: 900px) {
  .tb-main {
    padding-left: 0;
    padding-right: 0;
  }
}

/* ════════════════════════════════════════
   UTILIDADES RÁPIDAS
════════════════════════════════════════ */

.tb-text-muted    { color: var(--tb-text-muted) !important; }
.tb-text-primary  { color: var(--tb-primary) !important; }
.tb-text-success  { color: var(--tb-success) !important; }
.tb-text-danger   { color: var(--tb-danger) !important; }
.tb-text-warning  { color: var(--tb-warning) !important; }

.tb-bg-dark       { background: var(--tb-dark) !important; }
.tb-bg-app        { background: var(--tb-bg-app) !important; }

.tb-mt-sm  { margin-top: var(--tb-space-sm); }
.tb-mt-md  { margin-top: var(--tb-space-md); }
.tb-mt-lg  { margin-top: var(--tb-space-lg); }
.tb-mb-sm  { margin-bottom: var(--tb-space-sm); }
.tb-mb-md  { margin-bottom: var(--tb-space-md); }
.tb-mb-lg  { margin-bottom: var(--tb-space-lg); }

/* ════════════════════════════════════════
   TOPBAR ATOMS (from base.html)
   Movido aquí desde base.html <style> inline
════════════════════════════════════════ */
.tb-empresa-badge {
    font-size: 12px; color: var(--tb-text-secondary);
    background: var(--tb-bg-app);
    border-radius: 5px; padding: 4px 10px;
    max-width: 180px; overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap;
}
.tb-btn-back {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--tb-bg-app); color: var(--tb-text-secondary);
    border: 1px solid var(--tb-border-color);
    padding: 5px 12px; border-radius: 6px;
    font-size: 13px; text-decoration: none; transition: background .15s;
    white-space: nowrap;
}
.tb-btn-back:hover { background: var(--tb-sidebar-hover-bg); color: var(--tb-text-primary); }
.tb-nav-link {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 5px 12px; border-radius: 6px;
    font-size: 13px; color: var(--tb-text-secondary); text-decoration: none;
    transition: background .15s, color .15s;
    white-space: nowrap; border: 0; background: none; cursor: pointer;
}
.tb-nav-link:hover { background: var(--tb-sidebar-hover-bg); color: var(--tb-text-primary); }
.tb-nav-link.active { background: var(--tb-primary); color: #fff; }
.tb-user {
    display: flex; align-items: center; gap: 6px;
  font-size: var(--tb-font-xs); color: var(--tb-text-secondary);
}
.tb-user-menu {
  position: relative;
}
.tb-user-menu-trigger {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0 8px;
  height: 38px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--tb-text-secondary);
}
.tb-user-menu-trigger::-webkit-details-marker { display: none; }
.tb-user-menu-trigger:hover,
.tb-user-menu[open] .tb-user-menu-trigger {
  background: var(--tb-sidebar-hover-bg);
  color: var(--tb-text-primary);
}
.tb-user-menu-chevron {
  font-size: var(--tb-font-xs);
  opacity: .7;
  transition: transform .15s ease;
}
.tb-user-menu[open] .tb-user-menu-chevron {
  transform: rotate(180deg);
}
.tb-user-menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: 420px;
  min-width: 0;
  max-width: calc(100vw - 24px);
  box-sizing: border-box;
  background: var(--tb-bg-card);
  border: 1px solid #e7ecf8;
  border-radius: 26px;
  box-shadow: 0 24px 48px rgba(28, 44, 94, 0.12);
  padding: 26px;
  z-index: 1050;
}
.tb-user-menu-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0;
  margin-bottom: 22px;
  min-width: 0;
}
.tb-user-menu-meta {
  min-width: 0;
  flex: 1 1 auto;
}
.tb-user-menu-name {
  margin: 0;
  font-size: var(--tb-font-section);
  font-weight: var(--tb-weight-bold);
  color: #1f315f;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tb-user-menu-status {
  margin: 0;
  margin-top: 4px;
  font-size: var(--tb-font-md);
  color: #6d7f9d;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tb-user-menu-status-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #7b8faa;
  flex-shrink: 0;
}
.tb-user-menu-status.is-working .tb-user-menu-status-dot {
  background: #24c05a;
}
.tb-user-menu-link {
  display: inline-flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
  border-radius: 12px;
  color: #233a6c;
  text-decoration: none;
  font-size: var(--tb-font-body);
  font-weight: 500;
}
.tb-user-menu-link:hover {
  color: #1a2f61;
}
.tb-user-menu-link.is-danger {
  color: #ff6a68;
  margin-top: 14px;
}
.tb-user-menu-link.is-disabled {
  color: #9aa9c2;
  pointer-events: none;
  cursor: not-allowed;
}
.tb-user-avatar {
    width: 44px; height: 44px; border-radius: 50%;
  background: var(--tb-primary); color: var(--tb-text-on-dark);
    display: flex; align-items: center; justify-content: center;
  font-size: var(--tb-font-xs); font-weight: 700; flex-shrink: 0;
  overflow: hidden;
}
.tb-user-avatar-trigger {
  width: 38px;
  height: 38px;
}
.tb-user-avatar-menu {
  width: 66px;
  height: 66px;
}
.tb-user-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.tb-btn-logout {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 5px 12px; border-radius: 6px;
    font-size: 13px; color: var(--tb-danger); text-decoration: none;
    transition: background .15s;
    white-space: nowrap;
}
.tb-btn-logout:hover { background: var(--tb-danger-bg); }
.tb-version {
    font-size: 10px; color: var(--tb-text-muted);
    background: var(--tb-bg-app);
    padding: 2px 7px; border-radius: 4px; flex-shrink: 0;
}
.tb-nav-badge {
    position: absolute; top: -2px; right: -2px;
    min-width: 15px; height: 15px; padding: 0 3px;
    border-radius: 999px; background: #dc2626; color: #fff;
    font-size: 10px; font-weight: 700; line-height: 15px; text-align: center;
}
.tb-novedad-item {
    padding: 14px 0; border-bottom: 1px solid #f1f5f9;
}
.tb-novedad-item:last-child { border-bottom: 0; }
.tb-novedad-tag {
    font-size: 10px; font-weight: 700; letter-spacing: .03em;
    text-transform: uppercase; padding: 2px 8px; border-radius: 20px;
}
.tb-novedad-tag.cat-nueva  { background: #dbeafe; color: #1d4ed8; }
.tb-novedad-tag.cat-mejora { background: #ede9fe; color: #6d28d9; }
.tb-novedad-tag.cat-fix    { background: #dcfce7; color: #15803d; }
.tb-plan-badge {
    font-size: 10px; font-weight: 700; letter-spacing: .04em;
    padding: 2px 8px; border-radius: 20px; flex-shrink: 0;
    text-transform: uppercase;
}
.tb-plan-free     { background: #e2e8f0; color: #64748b; }
.tb-plan-starter  { background: #dbeafe; color: #1d4ed8; }
.tb-plan-pro      { background: #ede9fe; color: #6d28d9; }
.tb-plan-business { background: #fef9c3; color: #92400e; }
.tb-subbar {
    background: var(--tb-bg-card);
    border-bottom: 1px solid var(--tb-border-color);
    padding: 9px 24px;
    display: flex; align-items: center; gap: 10px;
    font-size: 13px; color: var(--tb-text-secondary);
}
.tb-subbar-title { font-weight: 600; color: var(--tb-text-primary); }
.tb-preview-banner {
    background: #7c3aed; color: #fff;
    padding: 7px 20px; display: flex; align-items: center; gap: 10px;
    font-size: 13px; flex-wrap: wrap;
}
.tb-preview-banner a {
    margin-left: auto; color: #e9d5ff; text-decoration: none;
    background: rgba(255,255,255,.15);
    padding: 3px 12px; border-radius: 5px; font-size: 12px; white-space: nowrap;
}
@media (max-width: 640px) {
    .tb-empresa-badge, .tb-version { display: none; }
    .tb-nav-link span { display: none; }
    .tb-nav-link { padding: 5px 8px; }
  .tb-user-menu-dropdown {
    position: fixed;
    left: 12px;
    right: 12px;
    top: calc(var(--tb-topbar-height) + 8px);
    width: auto;
    min-width: 0;
    max-width: none;
    padding: 20px;
    border-radius: 22px;
    max-height: calc(100dvh - var(--tb-topbar-height) - 24px);
    overflow-y: auto;
  }
  .tb-user-menu-link {
    font-size: var(--tb-font-body);
  }
}

/* ── Fichaje rápido: chip topbar (opción B) ──────────────────────────────── */
.tb-fichar-chip {
    display: flex; align-items: center; gap: 6px;
    padding: 0 4px 0 0;
}
.tb-fichar-timer {
    font-size: 12px; font-weight: 600; color: var(--tb-text-secondary);
    min-width: 52px; text-align: right;
    font-variant-numeric: tabular-nums;
}
.tb-fichar-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 14px; border-radius: 8px; border: none;
    font-size: 13px; font-weight: 600; cursor: pointer;
    transition: filter .15s, transform .1s;
    white-space: nowrap;
}
.tb-fichar-btn:hover  { filter: brightness(1.08); }
.tb-fichar-btn:active { transform: scale(.97); }
.tb-fichar-btn.entrada  { background: #16a34a; color: #fff; }
.tb-fichar-btn.salida   { background: #dc2626; color: #fff; }

/* ── Fichaje rápido: FAB (opción A) ─────────────────────────────────────── */
.tb-fichar-fab {
    position: fixed; bottom: 28px; right: 28px; z-index: 1050;
    display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
}
.tb-fichar-fab form { margin: 0; }
.tb-fichar-fab-btn {
    width: 56px; height: 56px; border-radius: 50%; border: none;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; cursor: pointer; box-shadow: 0 4px 16px rgba(0,0,0,.22);
    transition: transform .15s, box-shadow .15s;
}
.tb-fichar-fab-btn:hover  { transform: scale(1.08); box-shadow: 0 6px 20px rgba(0,0,0,.3); }
.tb-fichar-fab-btn:active { transform: scale(.96); }
.tb-fichar-fab-btn.entrada { background: #16a34a; color: #fff; }
.tb-fichar-fab-btn.salida  { background: #dc2626; color: #fff; }
.tb-fichar-fab-label {
    font-size: 11px; font-weight: 600; background: var(--tb-surface);
    padding: 2px 8px; border-radius: 6px; color: var(--tb-text-secondary);
    box-shadow: 0 2px 6px rgba(0,0,0,.12); white-space: nowrap;
}
.tb-fichar-fab-timer {
    font-size: 11px; font-weight: 700; color: #dc2626;
    background: var(--tb-surface); padding: 2px 8px;
    border-radius: 6px; box-shadow: 0 2px 6px rgba(0,0,0,.12);
    font-variant-numeric: tabular-nums;
}
@media (max-width: 640px) {
    .tb-fichar-timer { display: none; }
    .tb-fichar-btn span { display: none; }
    .tb-fichar-fab { bottom: 20px; right: 16px; }
}
